1 #ifndef _CAM_SENSOR_H 2 #define _CAM_SENSOR_H 3 4 #include "CamDevice.h" 5 #include <Rect.h> 6 7 // This class represents the camera's (cmos or whatever) sensor chip 8 class CamSensor 9 { 10 public: 11 CamSensor(CamDevice *_camera); 12 virtual ~CamSensor(); 13 14 virtual status_t Probe(); // returns B_OK if found. 15 16 virtual status_t InitCheck(); 17 18 virtual status_t Setup(); 19 20 virtual const char* Name(); 21 22 virtual status_t StartTransfer(); 23 virtual status_t StopTransfer(); 24 virtual bool TransferEnabled() const { return fTransferEnabled; }; 25 26 virtual bool IsBigEndian() const { return fIsBigEndian; }; 27 virtual bool Use400kHz() const { return false; }; 28 virtual bool UseRealIIC() const { return true; }; 29 virtual uint8 IICReadAddress() const { return 0; }; 30 virtual uint8 IICWriteAddress() const { return 0; }; 31 32 virtual int MaxWidth() const { return -1; }; 33 virtual int MaxHeight() const { return -1; }; 34 35 virtual status_t AcceptVideoFrame(uint32 &width, uint32 &height); 36 virtual status_t SetVideoFrame(BRect rect); 37 virtual BRect VideoFrame() const { return fVideoFrame; }; 38 virtual status_t SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue); 39 40 virtual void AddParameters(BParameterGroup *group, int32 &index); 41 virtual status_t GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size); 42 virtual status_t SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size); 43 44 CamDevice *Device(); 45 46 #if 0 47 // generic register-like access 48 virtual status_t WriteReg(uint16 address, uint8 *data, size_t count=1); 49 virtual status_t WriteReg8(uint16 address, uint8 data); 50 virtual status_t WriteReg16(uint16 address, uint16 data); 51 virtual status_t ReadReg(uint16 address, uint8 *data, size_t count=1, bool cached=false); 52 53 // I2C-like access 54 virtual status_t WriteIIC(uint8 address, uint8 *data, size_t count=1); 55 virtual status_t ReadIIC(uint8 address, uint8 *data); 56 #endif 57 protected: 58 status_t fInitStatus; 59 bool fIsBigEndian; 60 bool fTransferEnabled; 61 BRect fVideoFrame; 62 int32 fFirstParameterID; 63 bigtime_t fLastParameterChanges; 64 private: 65 CamDevice *fCamDevice; 66 }; 67 68 // internal modules 69 #define B_WEBCAM_DECLARE_SENSOR(sensorclass,sensorname) \ 70 extern "C" CamSensor *Instantiate##sensorclass(CamDevice *cam); \ 71 CamSensor *Instantiate##sensorclass(CamDevice *cam) \ 72 { return new sensorclass(cam); }; 73 74 75 #endif /* _CAM_SENSOR_H */ 76