#ifndef _SONIX_CAM_DEVICE_H
#define _SONIX_CAM_DEVICE_H
#include "CamDevice.h"
#define SN9C102_REG_COUNT 0x20
#define SN9C102_ASIC_ID 0x00
#define SN9C102_CHIP_CTRL 0x01
#define SN9C102_GPIO 0x02
#define SN9C103_G_GAIN 0x04
#define SN9C102_R_GAIN 0x05
#define SN9C102_B_GAIN 0x06
#define SN9C102_I2C_SETUP 0x08
#define SN9C102_I2C_SLAVE_ID 0x09
#define SN9C102_I2C_DATA0 0x0a
#define SN9C102_I2C_DATA1 0x0b
#define SN9C102_I2C_DATA2 0x0c
#define SN9C102_I2C_DATA3 0x0d
#define SN9C102_I2C_DATA4 0x0e
#define SN9C102_CONTROL_STAT 0x0f
#define SN9C102_R_B_GAIN 0x10
#define SN9C102_G_GAIN 0x11
#define SN9C102_H_START 0x12
#define SN9C102_V_START 0x13
#define SN9C102_OFFSET 0x14
#define SN9C102_H_SIZE 0x15
#define SN9C102_V_SIZE 0x16
#define SN9C102_CLOCK_SEL 0x17
#define SN9C102_SYNC_N_SCALE 0x18
#define SN9C102_PIX_CLK 0x19
#define SN9C102_HO_SIZE 0x1a
#define SN9C102_VO_SIZE 0x1b
#define SN9C102_AE_STRX 0x1c
#define SN9C102_AE_STRY 0x1d
#define SN9C102_AE_ENDX 0x1e
#define SN9C102_AE_ENDY 0x1f
#define SN9C10x_CONTRAST 0x84
#define SN9C10x_BRIGHTNESS 0x96
#undef SN9C102_REG_COUNT
#define SN9C102_REG_COUNT 0x100
#define SN9C102_RGB_GAIN_MAX 0x7f
class SonixCamDevice : public CamDevice {
public:
SonixCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device);
~SonixCamDevice();
virtual bool SupportsBulk();
virtual bool SupportsIsochronous();
virtual status_t StartTransfer();
virtual status_t StopTransfer();
virtual status_t PowerOnSensor(bool on);
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);
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);
virtual status_t SetVideoFrame(BRect rect);
virtual status_t SetScale(float scale);
virtual status_t SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue);
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 size_t MinRawFrameSize();
virtual size_t MaxRawFrameSize();
virtual bool ValidateStartOfFrameTag(const uint8 *tag, size_t taglen);
virtual bool ValidateEndOfFrameTag(const uint8 *tag, size_t taglen, size_t datalen);
virtual status_t GetFrameBitmap(BBitmap **bm, bigtime_t *stamp=NULL);
virtual status_t FillFrameBuffer(BBuffer *buffer, bigtime_t *stamp=NULL);
void DumpRegs();
private:
uint8 fCachedRegs[SN9C102_REG_COUNT];
int fChipVersion;
int fFrameTagState;
uint8 fRGain;
uint8 fGGain;
uint8 fBGain;
float fContrast;
float fBrightness;
};
class SonixCamDeviceAddon : public CamDeviceAddon {
public:
SonixCamDeviceAddon(WebCamMediaAddOn* webcam);
virtual ~SonixCamDeviceAddon();
virtual const char *BrandName();
virtual SonixCamDevice *Instantiate(CamRoster &roster, BUSBDevice *from);
};
#endif