xref: /haiku/src/add-ons/media/media-add-ons/usb_webcam/sensors/pb0100.cpp (revision b55a57da7173b9af0432bd3e148d03f06161d036)
1 /*
2  * Copyright 2004-2008, François Revol, <revol@free.fr>.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include "CamSensor.h"
7 #include "CamDebug.h"
8 
9 #define PB_ADDR_QC	0xba
10 
11 #define PB_IDENT	0x00
12 
13 
14 class PB0100Sensor : public CamSensor {
15 public:
16 	PB0100Sensor(CamDevice *_camera);
17 	~PB0100Sensor();
18 	virtual status_t	Probe();
19 
20 	virtual uint8		IICReadAddress() const { return PB_ADDR_QC; };
21 	virtual uint8		IICWriteAddress() const { return PB_ADDR_QC; };
22 };
23 
24 
25 PB0100Sensor::PB0100Sensor(CamDevice *_camera)
26 : CamSensor(_camera)
27 {
28 		Device()->SetIICBitsMode(16);
29 
30 }
31 
32 
33 PB0100Sensor::~PB0100Sensor()
34 {
35 }
36 
37 
38 status_t
39 PB0100Sensor::Probe()
40 {
41 	status_t err;
42 	uint16 data;
43 	PRINT((CH "()" CT));
44 	Device()->SetIICBitsMode(16);
45 	// QuickCam only ?
46 	err = Device()->ReadIIC16(PB_IDENT, &data);
47 	if (err < B_OK)
48 		return ENODEV;
49 	if (data == 0x64) {
50 		PRINT((CH ": found %s sensor!" CT, Name()));
51 		return B_OK;
52 	}
53 	return ENODEV;
54 }
55 
56 
57 B_WEBCAM_DECLARE_SENSOR(PB0100Sensor, pb0100)
58 
59