vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / media-add-ons / usb_webcam / CamSensor.h
blob5321c5c53616efedc510cc539f2f711cee3e81e7
1 /*
2 * Copyright 2004-2008, François Revol, <revol@free.fr>.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _CAM_SENSOR_H
6 #define _CAM_SENSOR_H
8 #include "CamDevice.h"
9 #include <Rect.h>
11 // This class represents the camera's (cmos or whatever) sensor chip
12 class CamSensor {
13 public:
14 CamSensor(CamDevice *_camera);
15 virtual ~CamSensor();
17 virtual status_t Probe(); // returns B_OK if found.
19 virtual status_t InitCheck();
21 virtual status_t Setup();
23 virtual const char* Name();
25 virtual status_t StartTransfer();
26 virtual status_t StopTransfer();
27 virtual bool TransferEnabled() const { return fTransferEnabled; };
29 virtual bool IsBigEndian() const { return fIsBigEndian; };
30 virtual bool Use400kHz() const { return false; };
31 virtual bool UseRealIIC() const { return true; };
32 virtual uint8 IICReadAddress() const { return 0; };
33 virtual uint8 IICWriteAddress() const { return 0; };
35 virtual int MaxWidth() const { return -1; };
36 virtual int MaxHeight() const { return -1; };
38 virtual status_t AcceptVideoFrame(uint32 &width, uint32 &height);
39 virtual status_t SetVideoFrame(BRect rect);
40 virtual BRect VideoFrame() const { return fVideoFrame; };
41 virtual status_t SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue);
43 virtual void AddParameters(BParameterGroup *group, int32 &index);
44 virtual status_t GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size);
45 virtual status_t SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size);
47 CamDevice *Device();
49 #if 0
50 // generic register-like access
51 virtual status_t WriteReg(uint16 address, uint8 *data, size_t count=1);
52 virtual status_t WriteReg8(uint16 address, uint8 data);
53 virtual status_t WriteReg16(uint16 address, uint16 data);
54 virtual status_t ReadReg(uint16 address, uint8 *data, size_t count=1, bool cached=false);
56 // I2C-like access
57 virtual status_t WriteIIC(uint8 address, uint8 *data, size_t count=1);
58 virtual status_t ReadIIC(uint8 address, uint8 *data);
59 #endif
60 protected:
62 status_t ProbeByIICSignature(const uint8 *regList,
63 const uint8 *matchList,
64 size_t count);
66 status_t fInitStatus;
67 bool fIsBigEndian;
68 bool fTransferEnabled;
69 BRect fVideoFrame;
70 int32 fFirstParameterID;
71 bigtime_t fLastParameterChanges;
72 private:
73 CamDevice *fCamDevice;
76 // internal modules
77 #define B_WEBCAM_DECLARE_SENSOR(sensorclass,sensorname) \
78 extern "C" CamSensor *Instantiate##sensorclass(CamDevice *cam); \
79 CamSensor *Instantiate##sensorclass(CamDevice *cam) \
80 { return new sensorclass(cam); };
83 #endif /* _CAM_SENSOR_H */