1 /* 2 */ 3 4 #include "CamSensor.h" 5 #include "CamDebug.h" 6 #include "addons/sonix/SonixCamDevice.h" 7 8 class TAS5110C1BSensor : public CamSensor { 9 public: 10 TAS5110C1BSensor(CamDevice *_camera); 11 ~TAS5110C1BSensor(); 12 virtual status_t Setup(); 13 const char *Name(); 14 virtual bool Use400kHz() const { return false; }; 15 virtual bool UseRealIIC() const { return false; }; 16 virtual uint8 IICReadAddress() const { return 0x00; }; 17 virtual uint8 IICWriteAddress() const { return 0xff; }; 18 virtual int MaxWidth() const { return 352; }; 19 virtual int MaxHeight() const { return 288; }; 20 virtual status_t SetVideoFrame(BRect rect); 21 private: 22 bool fIsSonix; 23 }; 24 25 // ----------------------------------------------------------------------------- 26 TAS5110C1BSensor::TAS5110C1BSensor(CamDevice *_camera) 27 : CamSensor(_camera) 28 { 29 fIsSonix = (dynamic_cast<SonixCamDevice *>(_camera) != NULL); 30 if (fIsSonix) { 31 fInitStatus = B_OK; 32 } else { 33 PRINT((CH ": unknown camera device!" CT)); 34 fInitStatus = ENODEV; 35 } 36 } 37 38 // ----------------------------------------------------------------------------- 39 TAS5110C1BSensor::~TAS5110C1BSensor() 40 { 41 } 42 43 // ----------------------------------------------------------------------------- 44 status_t 45 TAS5110C1BSensor::Setup() 46 { 47 PRINT((CH "()" CT)); 48 if (InitCheck()) 49 return InitCheck(); 50 if (fIsSonix) { 51 Device()->WriteReg8(SN9C102_CHIP_CTRL, 0x01); /* power down the sensor */ 52 Device()->WriteReg8(SN9C102_CHIP_CTRL, 0x44); /* power up the sensor, enable tx, sysclk@24MHz */ 53 Device()->WriteReg8(SN9C102_R_B_GAIN, 0x00); /* red, blue gain = 1+0/8 = 1 */ 54 Device()->WriteReg8(SN9C102_G_GAIN, 0x00); /* green gain = 1+0/8 = 1 */ 55 Device()->WriteReg8(SN9C102_OFFSET, 0x0a); /* 10 pix offset */ 56 Device()->WriteReg8(SN9C102_CLOCK_SEL, 0x60); /* enable sensor clk, and invert it */ 57 Device()->WriteReg8(SN9C102_SYNC_N_SCALE, 0x06); /* no compression, normal curve, 58 * no scaling, vsync active low, 59 * v/hsync change at rising edge, 60 * falling edge of sensor pck */ 61 Device()->WriteReg8(SN9C102_PIX_CLK, 0xfb); /* pixclk = 2 * masterclk, sensor is slave mode */ 62 } 63 64 //sonix_i2c_write_multi(dev, dev->sensor->i2c_wid, 2, 0xc0, 0x80, 0, 0, 0); /* AEC = 0x203 ??? */ 65 Device()->WriteIIC8(0xc0, 0x80); /* AEC = 0x203 ??? */ 66 67 if (fIsSonix) { 68 // set crop 69 Device()->WriteReg8(SN9C102_H_SIZE, 69); 70 Device()->WriteReg8(SN9C102_V_SIZE, 9); 71 Device()->WriteReg8(SN9C102_PIX_CLK, 0xfb); 72 Device()->WriteReg8(SN9C102_HO_SIZE, 0x14); 73 Device()->WriteReg8(SN9C102_VO_SIZE, 0x0a); 74 fVideoFrame.Set(0, 0, 352-1, 288-1); 75 /* HACK: TEST IMAGE */ 76 //Device()->WriteReg8(SN_CLOCK_SEL, 0x70); /* enable sensor clk, and invert it, test img */ 77 78 } 79 80 //Device()->SetScale(1); 81 82 return B_OK; 83 } 84 85 // ----------------------------------------------------------------------------- 86 const char * 87 TAS5110C1BSensor::Name() 88 { 89 return "TASC tas5110c1b"; 90 } 91 92 // ----------------------------------------------------------------------------- 93 status_t 94 TAS5110C1BSensor::SetVideoFrame(BRect rect) 95 { 96 if (fIsSonix) { 97 // set crop 98 Device()->WriteReg8(SN9C102_H_START, /*rect.left + */69); 99 Device()->WriteReg8(SN9C102_V_START, /*rect.top + */9); 100 Device()->WriteReg8(SN9C102_PIX_CLK, 0xfb); 101 Device()->WriteReg8(SN9C102_HO_SIZE, 0x14); 102 Device()->WriteReg8(SN9C102_VO_SIZE, 0x0a); 103 fVideoFrame = rect; 104 /* HACK: TEST IMAGE */ 105 //Device()->WriteReg8(SN9C102_CLOCK_SEL, 0x70); /* enable sensor clk, and invert it, test img */ 106 107 } 108 109 return B_OK; 110 } 111 112 // ----------------------------------------------------------------------------- 113 B_WEBCAM_DECLARE_SENSOR(TAS5110C1BSensor, tas5110c1b) 114 115