Patch from Gabriel Hartmann for his GSoC UVC project. Coding style updates by myself. Thanks!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42688 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
61f3c5c1c7
commit
51a01ea03b
|
@ -565,8 +565,15 @@ CamDevice::DataPumpThread()
|
|||
}
|
||||
#ifdef SUPPORT_ISO
|
||||
else if (SupportsIsochronous()) {
|
||||
int numPacketDescriptors = 20;
|
||||
int numPacketDescriptors = 16;
|
||||
usb_iso_packet_descriptor packetDescriptors[numPacketDescriptors];
|
||||
|
||||
// Initialize packetDescriptor request lengths
|
||||
for (int i = 0; i<numPacketDescriptors; i++)
|
||||
packetDescriptors[i].request_length = 256;
|
||||
|
||||
int fullPackets = 0;
|
||||
int totalPackets = 0;
|
||||
while (fTransferEnabled) {
|
||||
ssize_t len = -1;
|
||||
BAutolock lock(fLocker);
|
||||
|
@ -575,7 +582,8 @@ CamDevice::DataPumpThread()
|
|||
if (!fIsoIn)
|
||||
break;
|
||||
#ifndef DEBUG_DISCARD_INPUT
|
||||
len = fIsoIn->IsochronousTransfer(fBuffer, fBufferLen, packetDescriptors, numPacketDescriptors);
|
||||
len = fIsoIn->IsochronousTransfer(fBuffer, fBufferLen, packetDescriptors,
|
||||
numPacketDescriptors);
|
||||
#endif
|
||||
|
||||
//PRINT((CH ": got %d bytes" CT, len));
|
||||
|
@ -594,8 +602,16 @@ CamDevice::DataPumpThread()
|
|||
|
||||
#ifndef DEBUG_DISCARD_DATA
|
||||
if (fDataInput) {
|
||||
fDataInput->Write(fBuffer, len);
|
||||
// else drop
|
||||
int fBufferIndex = 0;
|
||||
for (int i = 0; i < numPacketDescriptors; i++) {
|
||||
int actual_length = ((usb_iso_packet_descriptor)
|
||||
packetDescriptors[i]).actual_length;
|
||||
if (actual_length > 0) {
|
||||
fDataInput->Write(&fBuffer[fBufferIndex],
|
||||
actual_length);
|
||||
}
|
||||
fBufferIndex += actual_length;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//snooze(2000);
|
||||
|
|
|
@ -35,7 +35,7 @@ addonSources =
|
|||
QuickCamDevice.cpp
|
||||
SonixCamDevice.cpp
|
||||
NW80xCamDevice.cpp
|
||||
# UVCCamDevice.cpp
|
||||
# UVCCamDevice.cpp UVCDeframer.cpp
|
||||
;
|
||||
|
||||
## colorspace transforms sources
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
* Copyright 2011, Gabriel Hartmann, gabriel.hartmann@gmail.com.
|
||||
* Copyright 2011, Jérôme Duval, korli@users.berlios.de.
|
||||
* Copyright 2009, Ithamar Adema, <ithamar.adema@team-embedded.nl>.
|
||||
* Distributed under the terms of the MIT License.
|
||||
|
@ -24,6 +25,15 @@ public:
|
|||
uint32 &height);
|
||||
virtual status_t AcceptVideoFrame(uint32 &width,
|
||||
uint32 &height);
|
||||
virtual void AddParameters(BParameterGroup *group,
|
||||
int32 &index);
|
||||
virtual status_t GetParameterValue(int32 id,
|
||||
bigtime_t *last_change, void *value,
|
||||
size_t *size);
|
||||
virtual status_t SetParameterValue(int32 id, bigtime_t when,
|
||||
const void *value, size_t size);
|
||||
virtual status_t FillFrameBuffer(BBuffer *buffer,
|
||||
bigtime_t *stamp = NULL);
|
||||
|
||||
private:
|
||||
void _ParseVideoControl(
|
||||
|
@ -35,14 +45,52 @@ private:
|
|||
status_t _ProbeCommitFormat();
|
||||
status_t _SelectBestAlternate();
|
||||
status_t _SelectIdleAlternate();
|
||||
void _DecodeColor(unsigned char *dst,
|
||||
unsigned char *src, int32 width,
|
||||
int32 height);
|
||||
|
||||
float _AddParameter(BParameterGroup* group,
|
||||
BParameterGroup** subgroup, int32 index,
|
||||
uint16 wValue, const char* name);
|
||||
int _AddAutoParameter(BParameterGroup* subgroup,
|
||||
int32 index, uint16 wValue);
|
||||
|
||||
usbvc_interface_header_descriptor *fHeaderDescriptor;
|
||||
|
||||
const BUSBEndpoint* fInterruptIn;
|
||||
uint32 fControlIndex;
|
||||
uint16 fControlRequestIndex;
|
||||
uint32 fStreamingIndex;
|
||||
uint32 fUncompressedFormatIndex;
|
||||
uint32 fUncompressedFrameIndex;
|
||||
uint32 fMJPEGFormatIndex;
|
||||
uint32 fMJPEGFrameIndex;
|
||||
uint32 fMaxVideoFrameSize;
|
||||
uint32 fMaxPayloadTransferSize;
|
||||
|
||||
BList fUncompressedFrames;
|
||||
BList fMJPEGFrames;
|
||||
|
||||
float fBrightness;
|
||||
float fContrast;
|
||||
float fHue;
|
||||
float fSaturation;
|
||||
float fSharpness;
|
||||
float fGamma;
|
||||
float fWBTemp;
|
||||
float fWBComponent;
|
||||
float fBacklightCompensation;
|
||||
float fGain;
|
||||
|
||||
bool fBinaryBacklightCompensation;
|
||||
|
||||
int fWBTempAuto;
|
||||
int fWBCompAuto;
|
||||
int fHueAuto;
|
||||
int fBacklightCompensationBinary;
|
||||
int fPowerlineFrequency;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright 2011, Gabriel Hartmann, gabriel.hartmann@gmail.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "UVCDeframer.h"
|
||||
|
||||
#include "CamDebug.h"
|
||||
#include "CamDevice.h"
|
||||
|
||||
#include <Autolock.h>
|
||||
|
||||
|
||||
#define MAX_TAG_LEN CAMDEFRAMER_MAX_TAG_LEN
|
||||
#define MAXFRAMEBUF CAMDEFRAMER_MAX_QUEUED_FRAMES
|
||||
|
||||
|
||||
UVCDeframer::UVCDeframer(CamDevice* device)
|
||||
: CamDeframer(device),
|
||||
fFrameCount(0),
|
||||
fID(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
UVCDeframer::~UVCDeframer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
UVCDeframer::Write(const void* buffer, size_t size)
|
||||
{
|
||||
const uint8* buf = (const uint8*)buffer;
|
||||
int payloadSize = size - buf[0]; // total length - header length
|
||||
|
||||
// This packet is just a header
|
||||
if (size == buf[0])
|
||||
return 0;
|
||||
|
||||
// Allocate frame
|
||||
if (!fCurrentFrame) {
|
||||
BAutolock l(fLocker);
|
||||
if (fFrames.CountItems() < MAXFRAMEBUF)
|
||||
fCurrentFrame = AllocFrame();
|
||||
else {
|
||||
printf("Dropped %ld bytes. Too many queued frames.)\n", size);
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
// Write payload to buffer
|
||||
fInputBuffer.Write(&buf[buf[0]], payloadSize);
|
||||
|
||||
// If end of frame add frame to list of frames
|
||||
if ((buf[1] & 2) || (buf[1] & 1) != fID) {
|
||||
fID = buf[1] & 1;
|
||||
fFrameCount++;
|
||||
buf = (uint8*)fInputBuffer.Buffer();
|
||||
fCurrentFrame->Write(buf, fInputBuffer.BufferLength());
|
||||
fFrames.AddItem(fCurrentFrame);
|
||||
release_sem(fFrameSem);
|
||||
fCurrentFrame = NULL;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UVCDeframer::_PrintBuffer(const void* buffer, size_t size)
|
||||
{
|
||||
uint8* b = (uint8*)buffer;
|
||||
for (size_t i = 0; i < size; i++)
|
||||
printf("0x%x\t", b[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright 2011, Gabriel Hartmann, gabriel.hartmann@gmail.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _UVC_DEFRAMER_H
|
||||
#define _UVC_DEFRAMER_H
|
||||
|
||||
|
||||
#include "CamDeframer.h"
|
||||
|
||||
#include <USB3.h>
|
||||
|
||||
|
||||
class UVCDeframer : public CamDeframer {
|
||||
public:
|
||||
UVCDeframer(CamDevice *device);
|
||||
virtual ~UVCDeframer();
|
||||
// BPositionIO interface
|
||||
// write from usb transfers
|
||||
virtual ssize_t Write(const void *buffer, size_t size);
|
||||
|
||||
private:
|
||||
void _PrintBuffer(const void* buffer, size_t size);
|
||||
|
||||
int32 fFrameCount;
|
||||
int32 fID;
|
||||
BMallocIO fInputBuffer;
|
||||
};
|
||||
|
||||
#endif /* _UVC_DEFRAMER_H */
|
||||
|
|
@ -52,7 +52,7 @@ ClassName(int classNumber) {
|
|||
case 0xE0:
|
||||
return "Wireless controller";
|
||||
case 0xEF:
|
||||
return "Miscelaneous";
|
||||
return "Miscellaneous";
|
||||
case 0xFE:
|
||||
return "Application specific";
|
||||
case 0xFF:
|
||||
|
|
Loading…
Reference in New Issue