xref: /haiku/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h (revision 02af02f93ae67777d65cce1eda1c5f21aaed3446)
1a1830cbdSFrançois Revol /*
2a1830cbdSFrançois Revol  * Copyright 2004-2008, François Revol, <revol@free.fr>.
3a1830cbdSFrançois Revol  * Distributed under the terms of the MIT License.
4a1830cbdSFrançois Revol  */
52c9bd703SFrançois Revol #ifndef _CAM_SENSOR_H
62c9bd703SFrançois Revol #define _CAM_SENSOR_H
72c9bd703SFrançois Revol 
82c9bd703SFrançois Revol #include "CamDevice.h"
92c9bd703SFrançois Revol #include <Rect.h>
102c9bd703SFrançois Revol 
112c9bd703SFrançois Revol // This class represents the camera's (cmos or whatever) sensor chip
12*02af02f9SJérôme Duval class CamSensor {
132c9bd703SFrançois Revol 	public:
142c9bd703SFrançois Revol 						CamSensor(CamDevice *_camera);
152c9bd703SFrançois Revol 	virtual				~CamSensor();
162c9bd703SFrançois Revol 
1774b3713aSFrançois Revol 	virtual status_t	Probe(); // returns B_OK if found.
1874b3713aSFrançois Revol 
192c9bd703SFrançois Revol 	virtual status_t	InitCheck();
202c9bd703SFrançois Revol 
212c9bd703SFrançois Revol 	virtual status_t	Setup();
222c9bd703SFrançois Revol 
232c9bd703SFrançois Revol 	virtual const char*	Name();
242c9bd703SFrançois Revol 
252c9bd703SFrançois Revol 	virtual status_t	StartTransfer();
262c9bd703SFrançois Revol 	virtual status_t	StopTransfer();
TransferEnabled()272c9bd703SFrançois Revol 	virtual bool		TransferEnabled() const { return fTransferEnabled; };
282c9bd703SFrançois Revol 
IsBigEndian()2974b3713aSFrançois Revol 	virtual bool		IsBigEndian() const { return fIsBigEndian; };
Use400kHz()302c9bd703SFrançois Revol 	virtual bool		Use400kHz() const { return false; };
UseRealIIC()312c9bd703SFrançois Revol 	virtual bool		UseRealIIC() const { return true; };
IICReadAddress()322c9bd703SFrançois Revol 	virtual uint8		IICReadAddress() const { return 0; };
IICWriteAddress()33d55e0f83SFrançois Revol 	virtual uint8		IICWriteAddress() const { return 0; };
340866ac7eSFrançois Revol 
MaxWidth()352c9bd703SFrançois Revol 	virtual int			MaxWidth() const { return -1; };
MaxHeight()362c9bd703SFrançois Revol 	virtual int			MaxHeight() const { return -1; };
372c9bd703SFrançois Revol 
380866ac7eSFrançois Revol 	virtual status_t	AcceptVideoFrame(uint32 &width, uint32 &height);
392c9bd703SFrançois Revol 	virtual status_t	SetVideoFrame(BRect rect);
VideoFrame()402c9bd703SFrançois Revol 	virtual BRect		VideoFrame() const { return fVideoFrame; };
412c9bd703SFrançois Revol 	virtual status_t	SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue);
422c9bd703SFrançois Revol 
43a486abdcSFrançois Revol 	virtual void		AddParameters(BParameterGroup *group, int32 &index);
44a486abdcSFrançois Revol 	virtual status_t	GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size);
45a486abdcSFrançois Revol 	virtual status_t	SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size);
46a486abdcSFrançois Revol 
472c9bd703SFrançois Revol 	CamDevice			*Device();
482c9bd703SFrançois Revol 
492c9bd703SFrançois Revol #if 0
502c9bd703SFrançois Revol 	// generic register-like access
512c9bd703SFrançois Revol 	virtual status_t	WriteReg(uint16 address, uint8 *data, size_t count=1);
522c9bd703SFrançois Revol 	virtual status_t	WriteReg8(uint16 address, uint8 data);
532c9bd703SFrançois Revol 	virtual status_t	WriteReg16(uint16 address, uint16 data);
542c9bd703SFrançois Revol 	virtual status_t	ReadReg(uint16 address, uint8 *data, size_t count=1, bool cached=false);
552c9bd703SFrançois Revol 
562c9bd703SFrançois Revol 	// I2C-like access
572c9bd703SFrançois Revol 	virtual status_t	WriteIIC(uint8 address, uint8 *data, size_t count=1);
582c9bd703SFrançois Revol 	virtual status_t	ReadIIC(uint8 address, uint8 *data);
592c9bd703SFrançois Revol #endif
602c9bd703SFrançois Revol 	protected:
61586b09a4SFrançois Revol 
62586b09a4SFrançois Revol 	status_t			ProbeByIICSignature(const uint8 *regList,
63586b09a4SFrançois Revol 											const uint8 *matchList,
64586b09a4SFrançois Revol 											size_t count);
65586b09a4SFrançois Revol 
662c9bd703SFrançois Revol 		status_t		fInitStatus;
6774b3713aSFrançois Revol 		bool			fIsBigEndian;
682c9bd703SFrançois Revol 		bool			fTransferEnabled;
692c9bd703SFrançois Revol 		BRect			fVideoFrame;
70a486abdcSFrançois Revol 		int32			fFirstParameterID;
71a486abdcSFrançois Revol 		bigtime_t		fLastParameterChanges;
722c9bd703SFrançois Revol 	private:
732c9bd703SFrançois Revol 		CamDevice		*fCamDevice;
742c9bd703SFrançois Revol };
752c9bd703SFrançois Revol 
762c9bd703SFrançois Revol // internal modules
772c9bd703SFrançois Revol #define B_WEBCAM_DECLARE_SENSOR(sensorclass,sensorname) \
782c9bd703SFrançois Revol extern "C" CamSensor *Instantiate##sensorclass(CamDevice *cam); \
792c9bd703SFrançois Revol CamSensor *Instantiate##sensorclass(CamDevice *cam) \
802c9bd703SFrançois Revol { return new sensorclass(cam); };
812c9bd703SFrançois Revol 
822c9bd703SFrançois Revol 
832c9bd703SFrançois Revol #endif /* _CAM_SENSOR_H */
84