- some code to support isochronous, not yet functional.
- some code for quickcam, not yet functional. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25319 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -413,8 +413,48 @@ CamDevice::DataPumpThread()
|
|||||||
//snooze(2000);
|
//snooze(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SupportsIsochronous()) {
|
#ifdef SUPPORT_ISO
|
||||||
;//XXX: TODO
|
else if (SupportsIsochronous()) {
|
||||||
|
int numPacketDescriptors = 20;
|
||||||
|
usb_iso_packet_descriptor packetDescriptors[numPacketDescriptors];
|
||||||
|
while (fTransferEnabled) {
|
||||||
|
ssize_t len = -1;
|
||||||
|
BAutolock lock(fLocker);
|
||||||
|
if (!lock.IsLocked())
|
||||||
|
break;
|
||||||
|
if (!fIsoIn)
|
||||||
|
break;
|
||||||
|
#ifndef DEBUG_DISCARD_INPUT
|
||||||
|
len = fIsoIn->IsochronousTransfer(fBuffer, fBufferLen, packetDescriptors, numPacketDescriptors);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//PRINT((CH ": got %d bytes" CT, len));
|
||||||
|
#ifdef DEBUG_WRITE_DUMP
|
||||||
|
write(fDumpFD, fBuffer, len);
|
||||||
|
#endif
|
||||||
|
#ifdef DEBUG_READ_DUMP
|
||||||
|
if ((len = read(fDumpFD, fBuffer, fBufferLen)) < fBufferLen)
|
||||||
|
lseek(fDumpFD, 0LL, SEEK_SET);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (len <= 0) {
|
||||||
|
PRINT((CH ": BulkIn: %s" CT, strerror(len)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef DEBUG_DISCARD_DATA
|
||||||
|
if (fDataInput) {
|
||||||
|
fDataInput->Write(fBuffer, len);
|
||||||
|
// else drop
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//snooze(2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
PRINT((CH ": No supported transport." CT));
|
||||||
|
return B_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -433,6 +473,22 @@ CamDevice::DumpRegs()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
status_t
|
||||||
|
CamDevice::SendCommand(uint8 dir, uint8 request, uint16 value,
|
||||||
|
uint16 index, uint16 length, void* data)
|
||||||
|
{
|
||||||
|
size_t ret;
|
||||||
|
if (!GetDevice())
|
||||||
|
return ENODEV;
|
||||||
|
if (length > GetDevice()->MaxEndpoint0PacketSize())
|
||||||
|
return EINVAL;
|
||||||
|
ret = GetDevice()->ControlTransfer(
|
||||||
|
USB_REQTYPE_VENDOR | USB_REQTYPE_INTERFACE_OUT | dir,
|
||||||
|
request, value, index, length, data);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
CamDeviceAddon::CamDeviceAddon(WebCamMediaAddOn* webcam)
|
CamDeviceAddon::CamDeviceAddon(WebCamMediaAddOn* webcam)
|
||||||
: fWebCamAddOn(webcam),
|
: fWebCamAddOn(webcam),
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
|
//#if 1
|
||||||
# include <USB3.h>
|
# include <USB3.h>
|
||||||
# include <USBKit.h>
|
# include <USBKit.h>
|
||||||
|
# define SUPPORT_ISO
|
||||||
#else
|
#else
|
||||||
# include <USB.h>
|
# include <USB.h>
|
||||||
# include <usb/USBKit.h>
|
# include <usb/USBKit.h>
|
||||||
@@ -104,6 +106,8 @@ class CamDevice {
|
|||||||
virtual void DumpRegs();
|
virtual void DumpRegs();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value,
|
||||||
|
uint16 index, uint16 length, void* data);
|
||||||
CamSensor *CreateSensor(const char *name);
|
CamSensor *CreateSensor(const char *name);
|
||||||
status_t fInitStatus;
|
status_t fInitStatus;
|
||||||
flavor_info fFlavorInfo;
|
flavor_info fFlavorInfo;
|
||||||
@@ -114,6 +118,7 @@ class CamDevice {
|
|||||||
CamDeframer* fDeframer;
|
CamDeframer* fDeframer;
|
||||||
BDataIO* fDataInput; // where data from usb goes, likely fDeframer
|
BDataIO* fDataInput; // where data from usb goes, likely fDeframer
|
||||||
const BUSBEndpoint* fBulkIn;
|
const BUSBEndpoint* fBulkIn;
|
||||||
|
const BUSBEndpoint* fIsoIn;
|
||||||
int32 fFirstParameterID;
|
int32 fFirstParameterID;
|
||||||
bigtime_t fLastParameterChanges;
|
bigtime_t fLastParameterChanges;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
|||||||
if $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
|
if $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
|
||||||
usbKitLibraryName = libdevice.so ;
|
usbKitLibraryName = libdevice.so ;
|
||||||
} else {
|
} else {
|
||||||
usbKitLibraryName = usb ;
|
# usbKitLibraryName = usb ;
|
||||||
|
usbKitLibraryName = USBKit.a ;
|
||||||
|
UsePublicHeaders [ FDirName drivers ] ;
|
||||||
|
UsePublicHeaders [ FDirName device ] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
# source directories
|
# source directories
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
#include "QuickCamDevice.h"
|
#include "QuickCamDevice.h"
|
||||||
|
#include "CamDebug.h"
|
||||||
|
#include "CamSensor.h"
|
||||||
|
|
||||||
|
// see http://www.lrr.in.tum.de/~acher/quickcam/quickcam.html
|
||||||
|
|
||||||
|
|
||||||
const usb_named_support_descriptor kSupportedDevices[] = {
|
const usb_named_support_descriptor kSupportedDevices[] = {
|
||||||
{{ 0, 0, 0, 0x046d, 0x0840 }, "Logitech", "QuickCam Express"},
|
{{ 0, 0, 0, 0x046d, 0x0840 }, "Logitech", "QuickCam Express"},
|
||||||
@@ -21,6 +26,152 @@ QuickCamDevice::~QuickCamDevice()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
QuickCamDevice::SupportsBulk()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
QuickCamDevice::SupportsIsochronous()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
status_t
|
||||||
|
QuickCamDevice::StartTransfer()
|
||||||
|
{
|
||||||
|
status_t err;
|
||||||
|
uint8 r;
|
||||||
|
|
||||||
|
SetScale(1);
|
||||||
|
if (Sensor())
|
||||||
|
SetVideoFrame(BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1));
|
||||||
|
|
||||||
|
//SetVideoFrame(BRect(0, 0, 320-1, 240-1));
|
||||||
|
|
||||||
|
DumpRegs();
|
||||||
|
#if 0
|
||||||
|
err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
r |= 0x04;
|
||||||
|
err = WriteReg8(SN9C102_CHIP_CTRL, r);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
#endif
|
||||||
|
return CamDevice::StartTransfer();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
status_t
|
||||||
|
QuickCamDevice::StopTransfer()
|
||||||
|
{
|
||||||
|
status_t err;
|
||||||
|
uint8 r;
|
||||||
|
|
||||||
|
DumpRegs();
|
||||||
|
err = CamDevice::StopTransfer();
|
||||||
|
#if 0
|
||||||
|
// if (err < 0)
|
||||||
|
// return err;
|
||||||
|
err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
r &= ~0x04;
|
||||||
|
err = WriteReg8(SN9C102_CHIP_CTRL, r);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
#endif
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
ssize_t
|
||||||
|
QuickCamDevice::WriteReg(uint16 address, uint8 *data, size_t count)
|
||||||
|
{
|
||||||
|
PRINT((CH "(%u, @%p, %u)" CT, address, data, count));
|
||||||
|
return SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, address, 0, count, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
ssize_t
|
||||||
|
QuickCamDevice::ReadReg(uint16 address, uint8 *data, size_t count, bool cached)
|
||||||
|
{
|
||||||
|
PRINT((CH "(%u, @%p, %u, %d)" CT, address, data, count, cached));
|
||||||
|
return SendCommand(USB_REQTYPE_DEVICE_IN, 0x04, address, 0, count, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
status_t
|
||||||
|
QuickCamDevice::GetStatusIIC()
|
||||||
|
{
|
||||||
|
status_t err;
|
||||||
|
uint8 status = 0;
|
||||||
|
#warning WRITEME
|
||||||
|
//dprintf(ID "i2c_status: error 0x%08lx, status = %02x\n", err, status);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
return (status&0x08)?EIO:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
status_t
|
||||||
|
QuickCamDevice::WaitReadyIIC()
|
||||||
|
{
|
||||||
|
status_t err;
|
||||||
|
#warning WRITEME
|
||||||
|
return EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
ssize_t
|
||||||
|
QuickCamDevice::WriteIIC(uint8 address, uint8 *data, size_t count)
|
||||||
|
{
|
||||||
|
status_t err;
|
||||||
|
int i;
|
||||||
|
uint8 buffer[0x23];
|
||||||
|
if (count > 16)
|
||||||
|
return EINVAL;
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
buffer[0x20] = Sensor() ? Sensor()->IICWriteAddress() : 0;
|
||||||
|
buffer[0x21] = count - 1;
|
||||||
|
buffer[0x22] = 0x01;
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
buffer[i] = address + i;
|
||||||
|
buffer[i+16] = data[i];
|
||||||
|
}
|
||||||
|
return SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
ssize_t
|
||||||
|
QuickCamDevice::ReadIIC(uint8 address, uint8 *data)
|
||||||
|
{
|
||||||
|
#warning WRITEME
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
status_t
|
||||||
|
QuickCamDevice::SendCommand(uint8 dir, uint8 request, uint16 value,
|
||||||
|
uint16 index, uint16 length, void* data)
|
||||||
|
{
|
||||||
|
size_t ret;
|
||||||
|
if (!GetDevice())
|
||||||
|
return ENODEV;
|
||||||
|
if (length > GetDevice()->MaxEndpoint0PacketSize())
|
||||||
|
return EINVAL;
|
||||||
|
ret = GetDevice()->ControlTransfer(
|
||||||
|
USB_REQTYPE_VENDOR | dir,
|
||||||
|
request, value, index, length, data);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
QuickCamDeviceAddon::QuickCamDeviceAddon(WebCamMediaAddOn* webcam)
|
QuickCamDeviceAddon::QuickCamDeviceAddon(WebCamMediaAddOn* webcam)
|
||||||
: CamDeviceAddon(webcam)
|
: CamDeviceAddon(webcam)
|
||||||
|
|||||||
@@ -3,14 +3,48 @@
|
|||||||
|
|
||||||
#include "CamDevice.h"
|
#include "CamDevice.h"
|
||||||
|
|
||||||
|
#define STV_REG_COUNT 0x0c
|
||||||
|
// Control registers of the STV0600 ASIC
|
||||||
|
#define STV_I2C_WRITE 0x400
|
||||||
|
#define STV_I2C_WRITE1 0x400
|
||||||
|
#define STV_I2C_READ 0x1410
|
||||||
|
#define STV_ISO_ENABLE 0x1440
|
||||||
|
#define STV_SCAN_RATE 0x1443
|
||||||
|
#define STV_ISO_SIZE 0x15c1
|
||||||
|
#define STV_Y_CTRL 0x15c3
|
||||||
|
#define STV_X_CTRL 0x1680
|
||||||
|
#define STV_REG00 0x1500
|
||||||
|
#define STV_REG01 0x1501
|
||||||
|
#define STV_REG02 0x1502
|
||||||
|
#define STV_REG03 0x1503
|
||||||
|
#define STV_REG04 0x1504
|
||||||
|
#define STV_REG23 0x0423
|
||||||
|
|
||||||
|
|
||||||
// This class represents each webcam
|
// This class represents each webcam
|
||||||
class QuickCamDevice : public CamDevice
|
class QuickCamDevice : public CamDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QuickCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device);
|
QuickCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device);
|
||||||
~QuickCamDevice();
|
~QuickCamDevice();
|
||||||
|
virtual bool SupportsBulk();
|
||||||
|
virtual bool SupportsIsochronous();
|
||||||
|
virtual status_t StartTransfer();
|
||||||
|
virtual status_t StopTransfer();
|
||||||
|
|
||||||
|
// generic register-like access
|
||||||
|
virtual ssize_t WriteReg(uint16 address, uint8 *data, size_t count=1);
|
||||||
|
virtual ssize_t ReadReg(uint16 address, uint8 *data, size_t count=1, bool cached=false);
|
||||||
|
|
||||||
|
// I2C-like access
|
||||||
|
virtual status_t GetStatusIIC();
|
||||||
|
virtual status_t WaitReadyIIC();
|
||||||
|
virtual ssize_t WriteIIC(uint8 address, uint8 *data, size_t count=1);
|
||||||
|
virtual ssize_t ReadIIC(uint8 address, uint8 *data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value,
|
||||||
|
uint16 index, uint16 length, void* data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// the addon itself, that instanciate
|
// the addon itself, that instanciate
|
||||||
|
|||||||
@@ -470,12 +470,20 @@ SonixCamDevice::SetParameterValue(int32 id, bigtime_t when, const void *value, s
|
|||||||
* but it doesn't seem to work any better for a rev 2 chip.
|
* but it doesn't seem to work any better for a rev 2 chip.
|
||||||
* XXX
|
* XXX
|
||||||
*/
|
*/
|
||||||
|
#if 1
|
||||||
WriteReg8(SN9C102_R_GAIN, fRGain);
|
WriteReg8(SN9C102_R_GAIN, fRGain);
|
||||||
WriteReg8(SN9C102_B_GAIN, fBGain);
|
WriteReg8(SN9C102_B_GAIN, fBGain);
|
||||||
if (fChipVersion >= 3)
|
if (fChipVersion >= 3)
|
||||||
WriteReg8(SN9C103_G_GAIN, fGGain);
|
WriteReg8(SN9C103_G_GAIN, fGGain);
|
||||||
else
|
else
|
||||||
WriteReg8(SN9C102_G_GAIN, (fGGain / 16));
|
WriteReg8(SN9C102_G_GAIN, (fGGain / 16));
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
uint8 buf[2];
|
||||||
|
buf[0] = (fBGain << 4) | fRGain;
|
||||||
|
buf[1] = fGGain;
|
||||||
|
WriteReg(SN9C102_R_B_GAIN, buf, 2);
|
||||||
|
#endif
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -616,21 +624,23 @@ SonixCamDevice::DumpRegs()
|
|||||||
regs[24], regs[25], regs[26], regs[27], regs[28], regs[29], regs[30], regs[31]);
|
regs[24], regs[25], regs[26], regs[27], regs[28], regs[29], regs[30], regs[31]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
status_t
|
status_t
|
||||||
SonixCamDevice::SendCommand(uint8 dir, uint8 request, uint16 value,
|
SonixCamDevice::SendCommand(uint8 dir, uint8 request, uint16 value,
|
||||||
uint16 index, uint16 length, void* data)
|
uint16 index, uint16 length, void* data)
|
||||||
{
|
{
|
||||||
size_t ret;
|
size_t ret;
|
||||||
if (length > 64)
|
|
||||||
return EINVAL;
|
|
||||||
if (!GetDevice())
|
if (!GetDevice())
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
|
if (length > GetDevice()->MaxEndpoint0PacketSize())
|
||||||
|
return EINVAL;
|
||||||
ret = GetDevice()->ControlTransfer(
|
ret = GetDevice()->ControlTransfer(
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_INTERFACE_OUT | dir,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_INTERFACE_OUT | dir,
|
||||||
request, value, index, length, data);
|
request, value, index, length, data);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
SonixCamDeviceAddon::SonixCamDeviceAddon(WebCamMediaAddOn* webcam)
|
SonixCamDeviceAddon::SonixCamDeviceAddon(WebCamMediaAddOn* webcam)
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ class SonixCamDevice : public CamDevice
|
|||||||
void DumpRegs();
|
void DumpRegs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t SendCommand(uint8 dir, uint8 request, uint16 value,
|
// status_t SendCommand(uint8 dir, uint8 request, uint16 value,
|
||||||
uint16 index, uint16 length, void* data);
|
// uint16 index, uint16 length, void* data);
|
||||||
uint8 fCachedRegs[SN9C102_REG_COUNT];
|
uint8 fCachedRegs[SN9C102_REG_COUNT];
|
||||||
int fChipVersion;
|
int fChipVersion;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user