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 10 CamSensor::CamSensor(CamDevice *_camera) 11 : fInitStatus(B_NO_INIT), 12 fIsBigEndian(false), 13 fTransferEnabled(false), 14 fVideoFrame(), 15 fLastParameterChanges(0), 16 fCamDevice(_camera) 17 { 18 19 } 20 21 22 CamSensor::~CamSensor() 23 { 24 25 } 26 27 28 status_t 29 CamSensor::Probe() 30 { 31 // default is to match by USB IDs 32 return B_OK; 33 } 34 35 36 status_t 37 CamSensor::InitCheck() 38 { 39 return fInitStatus; 40 } 41 42 43 status_t 44 CamSensor::Setup() 45 { 46 return fInitStatus; 47 } 48 49 50 const char * 51 CamSensor::Name() 52 { 53 return "<unknown>"; 54 } 55 56 57 status_t 58 CamSensor::StartTransfer() 59 { 60 fTransferEnabled = true; 61 return B_OK; 62 } 63 64 65 status_t 66 CamSensor::StopTransfer() 67 { 68 fTransferEnabled = false; 69 return B_OK; 70 } 71 72 73 status_t 74 CamSensor::AcceptVideoFrame(uint32 &width, uint32 &height) 75 { 76 // minimum sanity 77 if (width < 1) 78 width = MaxWidth(); 79 if (height < 1) 80 height = MaxHeight(); 81 if (width > (uint32)MaxWidth()) 82 width = MaxWidth(); 83 if (height > (uint32)MaxHeight()) 84 height = MaxHeight(); 85 return B_OK; 86 } 87 88 89 status_t 90 CamSensor::SetVideoFrame(BRect rect) 91 { 92 return ENOSYS; 93 } 94 95 96 status_t 97 CamSensor::SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue) 98 { 99 return ENOSYS; 100 } 101 102 103 void 104 CamSensor::AddParameters(BParameterGroup *group, int32 &index) 105 { 106 fFirstParameterID = index; 107 } 108 109 status_t 110 CamSensor::GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size) 111 { 112 return B_BAD_VALUE; 113 } 114 115 status_t 116 CamSensor::SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size) 117 { 118 return B_BAD_VALUE; 119 } 120 121 122 CamDevice * 123 CamSensor::Device() 124 { 125 return fCamDevice; 126 } 127 128 129 status_t 130 CamSensor::ProbeByIICSignature(const uint8 *regList, const uint8 *matchList, 131 size_t count) 132 { 133 for (size_t i = 0; i < count; i++) { 134 uint8 value = 0; 135 ssize_t len; 136 len = Device()->ReadIIC8(regList[i], &value); 137 PRINT((CH ": ReadIIC8 = %" B_PRIdSSIZE " val = %d" CT, len, value)); 138 if (len < 1) 139 return ENODEV; 140 if (value != matchList[i]) 141 return ENODEV; 142 } 143 return B_OK; 144 } 145