1 /* 2 * Copyright 2004-2008, François Revol, <revol@free.fr>. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include "CamDebug.h" 7 #include "CamSensor.h" 8 #include "addons/sonix/SonixCamDevice.h" 9 10 //XXX: unfinished! 11 12 static const uint8 sProbeAddressList[] = { 13 0x01,0x02,0x03,0x04,0x05,0x06,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x10 14 }; 15 static const uint8 sProbeMatchList[] = { 16 0x70,0x02,0x12,0x05,0x05,0x06,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x06 17 }; 18 19 class PAS106BSensor : public CamSensor { 20 public: 21 PAS106BSensor(CamDevice *_camera); 22 ~PAS106BSensor(); 23 status_t Probe(); 24 const char* Name(); 25 26 virtual bool Use400kHz() const { return true; }; // supports both 27 virtual bool UseRealIIC() const { return true; }; 28 29 private: 30 bool fIsSonix; 31 }; 32 33 34 PAS106BSensor::PAS106BSensor(CamDevice *_camera) 35 : CamSensor(_camera) 36 { 37 fIsSonix = (dynamic_cast<SonixCamDevice *>(_camera) != NULL); 38 if (fIsSonix) { 39 fInitStatus = B_OK; 40 } else { 41 PRINT((CH ": unknown camera device!" CT)); 42 fInitStatus = ENODEV; 43 } 44 } 45 46 47 PAS106BSensor::~PAS106BSensor() 48 { 49 } 50 51 52 status_t 53 PAS106BSensor::Probe() 54 { 55 Device()->PowerOnSensor(false); 56 Device()->PowerOnSensor(true); 57 if (fIsSonix) { 58 Device()->WriteReg8(SN9C102_CHIP_CTRL, 0x00); /* power on the sensor, Fsys_clk=12MHz */ 59 Device()->WriteReg8(SN9C102_CLOCK_SEL, 0x17); /* enable sensor, force 24MHz */ 60 } 61 62 return ProbeByIICSignature(sProbeAddressList, sProbeMatchList, 63 sizeof(sProbeMatchList)); 64 } 65 66 67 const char * 68 PAS106BSensor::Name() 69 { 70 return "PixArt Imaging pas106b"; 71 } 72 73 74 B_WEBCAM_DECLARE_SENSOR(PAS106BSensor, pas106b) 75 76