vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / media-add-ons / usb_webcam / sensors / hdcs1000.cpp
blob30f40407bec2b4eeebb21cd068a1da774d7f6cee
1 /*
2 * Copyright 2004-2008, François Revol, <revol@free.fr>.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "CamSensor.h"
7 #include "CamDebug.h"
9 #define HDCS_ADDR_QC 0xaa
11 #define HDCS_IDENT 0x00
13 class HDCS1000Sensor : public CamSensor {
14 public:
15 HDCS1000Sensor(CamDevice *_camera);
16 ~HDCS1000Sensor();
18 virtual status_t Probe();
20 virtual uint8 IICReadAddress() const { return HDCS_ADDR_QC; };
21 virtual uint8 IICWriteAddress() const { return HDCS_ADDR_QC; };
25 HDCS1000Sensor::HDCS1000Sensor(CamDevice *_camera)
26 : CamSensor(_camera)
31 HDCS1000Sensor::~HDCS1000Sensor()
36 status_t
37 HDCS1000Sensor::Probe()
39 status_t err;
40 uint8 data;
41 PRINT((CH "()" CT));
42 Device()->SetIICBitsMode(8);
43 // QuickCam only ?
44 err = Device()->ReadIIC8(HDCS_IDENT+1, &data);
45 if (err < B_OK)
46 return ENODEV;
47 if (data == 8) {
48 PRINT((CH ": found %s sensor!" CT, Name()));
49 return B_OK;
51 return ENODEV;
55 B_WEBCAM_DECLARE_SENSOR(HDCS1000Sensor, hdcs1000)