1 /* 2 * Copyright 2004-2008, François Revol, <revol@free.fr>. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _NW80X_CAM_DEVICE_H 6 #define _NW80X_CAM_DEVICE_H 7 8 #include "CamDevice.h" 9 10 #define STV_REG_COUNT 0x0c 11 // Control registers of the STV0600 ASIC 12 #define STV_I2C_WRITE 0x400 13 #define STV_I2C_WRITE1 0x400 14 #define STV_I2C_READ 0x1410 15 #define STV_ISO_ENABLE 0x1440 16 #define STV_SCAN_RATE 0x1443 17 #define STV_ISO_SIZE 0x15c1 18 #define STV_Y_CTRL 0x15c3 19 #define STV_X_CTRL 0x1680 20 #define STV_REG00 0x1500 21 #define STV_REG01 0x1501 22 #define STV_REG02 0x1502 23 #define STV_REG03 0x1503 24 #define STV_REG04 0x1504 25 #define STV_REG23 0x0423 26 27 28 // This class represents each webcam 29 class NW80xCamDevice : public CamDevice 30 { 31 public: 32 NW80xCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device); 33 ~NW80xCamDevice(); 34 virtual bool SupportsBulk(); 35 virtual bool SupportsIsochronous(); 36 virtual status_t StartTransfer(); 37 virtual status_t StopTransfer(); 38 39 // generic register-like access 40 virtual ssize_t WriteReg(uint16 address, uint8 *data, size_t count=1); 41 virtual ssize_t ReadReg(uint16 address, uint8 *data, size_t count=1, bool cached=false); 42 43 // I2C-like access 44 virtual status_t GetStatusIIC(); 45 virtual status_t WaitReadyIIC(); 46 virtual ssize_t WriteIIC(uint8 address, uint8 *data, size_t count=1); 47 virtual ssize_t ReadIIC(uint8 address, uint8 *data); 48 virtual ssize_t ReadIIC8(uint8 address, uint8 *data); 49 virtual ssize_t ReadIIC16(uint8 address, uint16 *data); 50 virtual status_t SetIICBitsMode(size_t bits=8); 51 52 private: 53 virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value, 54 uint16 index, uint16 length, void* data); 55 }; 56 57 // the addon itself, that instanciate 58 59 class NW80xCamDeviceAddon : public CamDeviceAddon 60 { 61 public: 62 NW80xCamDeviceAddon(WebCamMediaAddOn* webcam); 63 virtual ~NW80xCamDeviceAddon(); 64 65 virtual const char *BrandName(); 66 virtual NW80xCamDevice *Instantiate(CamRoster &roster, BUSBDevice *from); 67 68 }; 69 70 #endif /* _NW80X_CAM_CAM_DEVICE_H */ 71