sonixj.c 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775
  1. /*
  2. * Sonix sn9c102p sn9c105 sn9c120 (jpeg) library
  3. * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
  4. *
  5. * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #define MODULE_NAME "sonixj"
  22. #include "gspca.h"
  23. #include "jpeg.h"
  24. #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
  25. MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
  26. MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
  27. MODULE_LICENSE("GPL");
  28. /* specific webcam descriptor */
  29. struct sd {
  30. struct gspca_dev gspca_dev; /* !! must be the first item */
  31. atomic_t avg_lum;
  32. unsigned int exposure;
  33. unsigned short brightness;
  34. unsigned char contrast;
  35. unsigned char colors;
  36. unsigned char autogain;
  37. __u8 vflip; /* ov7630 only */
  38. __u8 infrared; /* mi0360 only */
  39. signed char ag_cnt;
  40. #define AG_CNT_START 13
  41. char qindex;
  42. unsigned char bridge;
  43. #define BRIDGE_SN9C102P 0
  44. #define BRIDGE_SN9C105 1
  45. #define BRIDGE_SN9C110 2
  46. #define BRIDGE_SN9C120 3
  47. #define BRIDGE_SN9C325 4
  48. char sensor; /* Type of image sensor chip */
  49. #define SENSOR_HV7131R 0
  50. #define SENSOR_MI0360 1
  51. #define SENSOR_MO4000 2
  52. #define SENSOR_OM6802 3
  53. #define SENSOR_OV7630 4
  54. #define SENSOR_OV7648 5
  55. #define SENSOR_OV7660 6
  56. unsigned char i2c_base;
  57. };
  58. /* V4L2 controls supported by the driver */
  59. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
  60. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
  61. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
  62. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
  63. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
  64. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
  65. static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
  66. static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
  67. static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
  68. static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
  69. static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
  70. static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
  71. static struct ctrl sd_ctrls[] = {
  72. {
  73. {
  74. .id = V4L2_CID_BRIGHTNESS,
  75. .type = V4L2_CTRL_TYPE_INTEGER,
  76. .name = "Brightness",
  77. .minimum = 0,
  78. #define BRIGHTNESS_MAX 0xffff
  79. .maximum = BRIGHTNESS_MAX,
  80. .step = 1,
  81. #define BRIGHTNESS_DEF 0x7fff
  82. .default_value = BRIGHTNESS_DEF,
  83. },
  84. .set = sd_setbrightness,
  85. .get = sd_getbrightness,
  86. },
  87. {
  88. {
  89. .id = V4L2_CID_CONTRAST,
  90. .type = V4L2_CTRL_TYPE_INTEGER,
  91. .name = "Contrast",
  92. .minimum = 0,
  93. #define CONTRAST_MAX 127
  94. .maximum = CONTRAST_MAX,
  95. .step = 1,
  96. #define CONTRAST_DEF 63
  97. .default_value = CONTRAST_DEF,
  98. },
  99. .set = sd_setcontrast,
  100. .get = sd_getcontrast,
  101. },
  102. {
  103. {
  104. .id = V4L2_CID_SATURATION,
  105. .type = V4L2_CTRL_TYPE_INTEGER,
  106. .name = "Color",
  107. .minimum = 0,
  108. .maximum = 64,
  109. .step = 1,
  110. #define COLOR_DEF 32
  111. .default_value = COLOR_DEF,
  112. },
  113. .set = sd_setcolors,
  114. .get = sd_getcolors,
  115. },
  116. #define AUTOGAIN_IDX 3
  117. {
  118. {
  119. .id = V4L2_CID_AUTOGAIN,
  120. .type = V4L2_CTRL_TYPE_BOOLEAN,
  121. .name = "Auto Gain",
  122. .minimum = 0,
  123. .maximum = 1,
  124. .step = 1,
  125. #define AUTOGAIN_DEF 1
  126. .default_value = AUTOGAIN_DEF,
  127. },
  128. .set = sd_setautogain,
  129. .get = sd_getautogain,
  130. },
  131. /* ov7630 only */
  132. #define VFLIP_IDX 4
  133. {
  134. {
  135. .id = V4L2_CID_VFLIP,
  136. .type = V4L2_CTRL_TYPE_BOOLEAN,
  137. .name = "Vflip",
  138. .minimum = 0,
  139. .maximum = 1,
  140. .step = 1,
  141. #define VFLIP_DEF 1
  142. .default_value = VFLIP_DEF,
  143. },
  144. .set = sd_setvflip,
  145. .get = sd_getvflip,
  146. },
  147. /* mi0360 only */
  148. #define INFRARED_IDX 5
  149. {
  150. {
  151. .id = V4L2_CID_INFRARED,
  152. .type = V4L2_CTRL_TYPE_BOOLEAN,
  153. .name = "Infrared",
  154. .minimum = 0,
  155. .maximum = 1,
  156. .step = 1,
  157. #define INFRARED_DEF 0
  158. .default_value = INFRARED_DEF,
  159. },
  160. .set = sd_setinfrared,
  161. .get = sd_getinfrared,
  162. },
  163. };
  164. static struct v4l2_pix_format vga_mode[] = {
  165. {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  166. .bytesperline = 160,
  167. .sizeimage = 160 * 120 * 4 / 8 + 590,
  168. .colorspace = V4L2_COLORSPACE_JPEG,
  169. .priv = 2},
  170. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  171. .bytesperline = 320,
  172. .sizeimage = 320 * 240 * 3 / 8 + 590,
  173. .colorspace = V4L2_COLORSPACE_JPEG,
  174. .priv = 1},
  175. {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  176. .bytesperline = 640,
  177. .sizeimage = 640 * 480 * 3 / 8 + 590,
  178. .colorspace = V4L2_COLORSPACE_JPEG,
  179. .priv = 0},
  180. };
  181. /*Data from sn9c102p+hv71331r */
  182. static const __u8 sn_hv7131[] = {
  183. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  184. 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
  185. /* reg8 reg9 rega regb regc regd rege regf */
  186. 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10,
  187. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  188. 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
  189. /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */
  190. 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  191. };
  192. static const __u8 sn_mi0360[] = {
  193. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  194. 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
  195. /* reg8 reg9 rega regb regc regd rege regf */
  196. 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
  197. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  198. 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
  199. /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */
  200. 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  201. };
  202. static const __u8 sn_mo4000[] = {
  203. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  204. 0x12, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
  205. /* reg8 reg9 rega regb regc regd rege regf */
  206. 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  207. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  208. 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
  209. /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */
  210. 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  211. };
  212. static const __u8 sn_om6802[] = {
  213. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  214. 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20,
  215. /* reg8 reg9 rega regb regc regd rege regf */
  216. 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  217. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  218. 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
  219. /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */
  220. 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  221. 0x08, 0x22, 0x44, 0x63, 0x7d, 0x92, 0xa3, 0xaf,
  222. 0xbc, 0xc4, 0xcd, 0xd5, 0xdc, 0xe1, 0xe8, 0xef,
  223. 0xf7
  224. };
  225. static const __u8 sn_ov7630[] = {
  226. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  227. 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
  228. /* reg8 reg9 rega regb regc regd rege regf */
  229. 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10,
  230. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  231. 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
  232. /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */
  233. 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00
  234. };
  235. static const __u8 sn_ov7648[] = {
  236. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  237. 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
  238. /* reg8 reg9 rega regb regc regd rege regf */
  239. 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
  240. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  241. 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
  242. /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */
  243. 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00
  244. };
  245. static const __u8 sn_ov7660[] = {
  246. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  247. 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
  248. /* reg8 reg9 rega regb regc regd rege regf */
  249. 0x81, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
  250. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  251. 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
  252. /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */
  253. 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  254. };
  255. /* sequence specific to the sensors - !! index = SENSOR_xxx */
  256. static const __u8 *sn_tb[] = {
  257. sn_hv7131,
  258. sn_mi0360,
  259. sn_mo4000,
  260. sn_om6802,
  261. sn_ov7630,
  262. sn_ov7648,
  263. sn_ov7660
  264. };
  265. static const __u8 gamma_def[] = {
  266. 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
  267. 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
  268. };
  269. /* color matrix and offsets */
  270. static const __u8 reg84[] = {
  271. 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
  272. 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
  273. 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
  274. 0x00, 0x00, 0x00 /* YUV offsets */
  275. };
  276. static const __u8 hv7131r_sensor_init[][8] = {
  277. {0xC1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
  278. {0xB1, 0x11, 0x34, 0x17, 0x7F, 0x00, 0x00, 0x10},
  279. {0xD1, 0x11, 0x40, 0xFF, 0x7F, 0x7F, 0x7F, 0x10},
  280. {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10},
  281. {0xD1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
  282. {0xD1, 0x11, 0x14, 0x01, 0xE2, 0x02, 0x82, 0x10},
  283. {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
  284. {0xA1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
  285. {0xA1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
  286. {0xC1, 0x11, 0x25, 0x00, 0x61, 0xA8, 0x00, 0x10},
  287. {0xA1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
  288. {0xC1, 0x11, 0x31, 0x20, 0x2E, 0x20, 0x00, 0x10},
  289. {0xC1, 0x11, 0x25, 0x00, 0xC3, 0x50, 0x00, 0x10},
  290. {0xA1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
  291. {0xC1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
  292. {0xA1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
  293. {0xA1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
  294. {0xA1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10},
  295. {0xA1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
  296. {0xA1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
  297. {0xA1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
  298. {0xA1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
  299. {0xA1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10},
  300. {0xA1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
  301. {0xA1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
  302. {}
  303. };
  304. static const __u8 mi0360_sensor_init[][8] = {
  305. {0xB1, 0x5D, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
  306. {0xB1, 0x5D, 0x0D, 0x00, 0x01, 0x00, 0x00, 0x10},
  307. {0xB1, 0x5D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x10},
  308. {0xD1, 0x5D, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
  309. {0xD1, 0x5D, 0x03, 0x01, 0xE2, 0x02, 0x82, 0x10},
  310. {0xD1, 0x5D, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
  311. {0xB1, 0x5D, 0x0D, 0x00, 0x02, 0x00, 0x00, 0x10},
  312. {0xD1, 0x5D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x10},
  313. {0xD1, 0x5D, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x10},
  314. {0xD1, 0x5D, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x10},
  315. {0xD1, 0x5D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
  316. {0xD1, 0x5D, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
  317. {0xD1, 0x5D, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
  318. {0xD1, 0x5D, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
  319. {0xD1, 0x5D, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
  320. {0xD1, 0x5D, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x10},
  321. {0xD1, 0x5D, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x10},
  322. {0xB1, 0x5D, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
  323. {0xD1, 0x5D, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
  324. {0xD1, 0x5D, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
  325. {0xD1, 0x5D, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
  326. {0xD1, 0x5D, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
  327. {0xD1, 0x5D, 0x2F, 0xF7, 0xB0, 0x00, 0x04, 0x10},
  328. {0xD1, 0x5D, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
  329. {0xD1, 0x5D, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
  330. {0xB1, 0x5D, 0x3D, 0x06, 0x8F, 0x00, 0x00, 0x10},
  331. {0xD1, 0x5D, 0x40, 0x01, 0xE0, 0x00, 0xD1, 0x10},
  332. {0xB1, 0x5D, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
  333. {0xD1, 0x5D, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
  334. {0xD1, 0x5D, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x10},
  335. {0xD1, 0x5D, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x10},
  336. {0xD1, 0x5D, 0x5E, 0x00, 0x00, 0xA3, 0x1D, 0x10},
  337. {0xB1, 0x5D, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
  338. {0xB1, 0x5D, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
  339. {0xB1, 0x5D, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
  340. {0xB1, 0x5D, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
  341. {0xD1, 0x5D, 0x2B, 0x00, 0xA0, 0x00, 0xB0, 0x10},
  342. {0xD1, 0x5D, 0x2D, 0x00, 0xA0, 0x00, 0xA0, 0x10},
  343. {0xB1, 0x5D, 0x0A, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
  344. {0xB1, 0x5D, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
  345. {0xB1, 0x5D, 0x05, 0x00, 0x0A, 0x00, 0x00, 0x10},
  346. {0xB1, 0x5D, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
  347. {0xD1, 0x5D, 0x2B, 0x00, 0xB9, 0x00, 0xE3, 0x10},
  348. {0xD1, 0x5D, 0x2D, 0x00, 0x5f, 0x00, 0xB9, 0x10}, /* 42 */
  349. /* {0xB1, 0x5D, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
  350. /* {0xB1, 0x5D, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
  351. {0xB1, 0x5D, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
  352. {0xB1, 0x5D, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
  353. {}
  354. };
  355. static const __u8 mo4000_sensor_init[][8] = {
  356. {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
  357. {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
  358. {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
  359. {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
  360. {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
  361. {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
  362. {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
  363. {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
  364. {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
  365. {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
  366. {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
  367. {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
  368. {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
  369. {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
  370. {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
  371. {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
  372. {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
  373. {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
  374. {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
  375. {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
  376. {}
  377. };
  378. static __u8 om6802_sensor_init[][8] = {
  379. {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10},
  380. {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10},
  381. {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
  382. {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
  383. /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
  384. {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
  385. /* white balance & auto-exposure */
  386. /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
  387. * set color mode */
  388. /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
  389. * max AGC value in AE */
  390. /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
  391. * preset AGC */
  392. /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
  393. * preset brightness */
  394. /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
  395. * preset contrast */
  396. /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
  397. * preset gamma */
  398. {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
  399. /* luminance mode (0x4f = AE) */
  400. {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
  401. /* preset shutter */
  402. /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
  403. * auto frame rate */
  404. /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
  405. /* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */
  406. /* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */
  407. /* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */
  408. /* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */
  409. {}
  410. };
  411. static const __u8 ov7630_sensor_init[][8] = {
  412. {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
  413. {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
  414. /* win: delay 20ms */
  415. {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
  416. {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
  417. /* win: delay 20ms */
  418. {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
  419. /* win: i2c_r from 00 to 80 */
  420. {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
  421. {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
  422. {0xd1, 0x21, 0x11, 0x00, 0x48, 0xc0, 0x00, 0x10},
  423. {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
  424. {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
  425. {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
  426. {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
  427. {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
  428. {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
  429. {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
  430. {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
  431. {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
  432. {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
  433. {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
  434. {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
  435. {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
  436. {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
  437. {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
  438. {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
  439. {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
  440. {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
  441. {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
  442. {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
  443. {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
  444. {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
  445. {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
  446. /* */
  447. {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
  448. {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
  449. /*fixme: + 0x12, 0x04*/
  450. /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
  451. * set by setvflip */
  452. {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
  453. {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
  454. {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
  455. /* */
  456. {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
  457. {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10},
  458. {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10},
  459. /* */
  460. {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
  461. /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
  462. {}
  463. };
  464. static const __u8 ov7648_sensor_init[][8] = {
  465. {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
  466. {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
  467. {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
  468. {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
  469. {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
  470. {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
  471. {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
  472. {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
  473. {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
  474. {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
  475. {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
  476. {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
  477. {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
  478. {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
  479. {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
  480. {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
  481. {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
  482. {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
  483. {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
  484. {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
  485. {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
  486. {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
  487. /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
  488. /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
  489. {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10},
  490. /*...*/
  491. /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
  492. /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, jfm done */
  493. {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
  494. {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
  495. /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
  496. /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
  497. /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
  498. /*...*/
  499. {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
  500. /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
  501. /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
  502. /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
  503. /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
  504. /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
  505. {}
  506. };
  507. static const __u8 ov7660_sensor_init[][8] = {
  508. {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
  509. /* (delay 20ms) */
  510. {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
  511. /* Outformat = rawRGB */
  512. {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
  513. {0xd1, 0x21, 0x00, 0x01, 0x74, 0x74, 0x00, 0x10},
  514. /* GAIN BLUE RED VREF */
  515. {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
  516. /* COM 1 BAVE GEAVE AECHH */
  517. {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
  518. {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
  519. {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
  520. /* AECH CLKRC COM7 COM8 */
  521. {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
  522. {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
  523. /* HSTART HSTOP VSTRT VSTOP */
  524. {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
  525. {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
  526. {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
  527. /* BOS GBOS GROS ROS (BGGR offset) */
  528. /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
  529. {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
  530. /* AEW AEB VPT BBIAS */
  531. {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
  532. /* GbBIAS RSVD EXHCH EXHCL */
  533. {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
  534. /* RBIAS ADVFL ASDVFH YAVE */
  535. {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
  536. /* HSYST HSYEN HREF */
  537. {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
  538. {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
  539. /* ADC ACOM OFON TSLB */
  540. {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
  541. /* COM11 COM12 COM13 COM14 */
  542. {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
  543. /* EDGE COM15 COM16 COM17 */
  544. {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
  545. {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
  546. {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
  547. {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
  548. {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
  549. {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
  550. {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
  551. {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
  552. {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
  553. {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
  554. /* LCC1 LCC2 LCC3 LCC4 */
  555. {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
  556. {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
  557. {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
  558. /* band gap reference [0:3] DBLV */
  559. {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
  560. {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
  561. {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
  562. {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
  563. {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
  564. {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
  565. {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
  566. {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
  567. {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
  568. {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
  569. /****** (some exchanges in the win trace) ******/
  570. {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
  571. /* bits[3..0]reserved */
  572. {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
  573. {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
  574. /* VREF vertical frame ctrl */
  575. {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
  576. {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
  577. {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
  578. {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
  579. {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
  580. /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
  581. /****** (some exchanges in the win trace) ******/
  582. {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
  583. {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
  584. {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
  585. {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
  586. /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
  587. /****** (some exchanges in the win trace) ******/
  588. /******!! startsensor KO if changed !!****/
  589. {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
  590. {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
  591. {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
  592. {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
  593. {}
  594. };
  595. static const __u8 qtable4[] = {
  596. 0x06, 0x04, 0x04, 0x06, 0x04, 0x04, 0x06, 0x06, 0x06, 0x06, 0x08, 0x06,
  597. 0x06, 0x08, 0x0A, 0x11,
  598. 0x0A, 0x0A, 0x08, 0x08, 0x0A, 0x15, 0x0F, 0x0F, 0x0C, 0x11, 0x19, 0x15,
  599. 0x19, 0x19, 0x17, 0x15,
  600. 0x17, 0x17, 0x1B, 0x1D, 0x25, 0x21, 0x1B, 0x1D, 0x23, 0x1D, 0x17, 0x17,
  601. 0x21, 0x2E, 0x21, 0x23,
  602. 0x27, 0x29, 0x2C, 0x2C, 0x2C, 0x19, 0x1F, 0x30, 0x32, 0x2E, 0x29, 0x32,
  603. 0x25, 0x29, 0x2C, 0x29,
  604. 0x06, 0x08, 0x08, 0x0A, 0x08, 0x0A, 0x13, 0x0A, 0x0A, 0x13, 0x29, 0x1B,
  605. 0x17, 0x1B, 0x29, 0x29,
  606. 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
  607. 0x29, 0x29, 0x29, 0x29,
  608. 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
  609. 0x29, 0x29, 0x29, 0x29,
  610. 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
  611. 0x29, 0x29, 0x29, 0x29
  612. };
  613. /* read <len> bytes to gspca_dev->usb_buf */
  614. static void reg_r(struct gspca_dev *gspca_dev,
  615. __u16 value, int len)
  616. {
  617. #ifdef GSPCA_DEBUG
  618. if (len > USB_BUF_SZ) {
  619. err("reg_r: buffer overflow");
  620. return;
  621. }
  622. #endif
  623. usb_control_msg(gspca_dev->dev,
  624. usb_rcvctrlpipe(gspca_dev->dev, 0),
  625. 0,
  626. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  627. value, 0,
  628. gspca_dev->usb_buf, len,
  629. 500);
  630. PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
  631. }
  632. static void reg_w1(struct gspca_dev *gspca_dev,
  633. __u16 value,
  634. __u8 data)
  635. {
  636. PDEBUG(D_USBO, "reg_w1 [%02x] = %02x", value, data);
  637. gspca_dev->usb_buf[0] = data;
  638. usb_control_msg(gspca_dev->dev,
  639. usb_sndctrlpipe(gspca_dev->dev, 0),
  640. 0x08,
  641. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  642. value,
  643. 0,
  644. gspca_dev->usb_buf, 1,
  645. 500);
  646. }
  647. static void reg_w(struct gspca_dev *gspca_dev,
  648. __u16 value,
  649. const __u8 *buffer,
  650. int len)
  651. {
  652. PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..",
  653. value, buffer[0], buffer[1]);
  654. #ifdef GSPCA_DEBUG
  655. if (len > USB_BUF_SZ) {
  656. err("reg_w: buffer overflow");
  657. return;
  658. }
  659. #endif
  660. memcpy(gspca_dev->usb_buf, buffer, len);
  661. usb_control_msg(gspca_dev->dev,
  662. usb_sndctrlpipe(gspca_dev->dev, 0),
  663. 0x08,
  664. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  665. value, 0,
  666. gspca_dev->usb_buf, len,
  667. 500);
  668. }
  669. /* I2C write 1 byte */
  670. static void i2c_w1(struct gspca_dev *gspca_dev, __u8 reg, __u8 val)
  671. {
  672. struct sd *sd = (struct sd *) gspca_dev;
  673. PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
  674. gspca_dev->usb_buf[0] = 0x81 | (2 << 4); /* = a1 */
  675. gspca_dev->usb_buf[1] = sd->i2c_base;
  676. gspca_dev->usb_buf[2] = reg;
  677. gspca_dev->usb_buf[3] = val;
  678. gspca_dev->usb_buf[4] = 0;
  679. gspca_dev->usb_buf[5] = 0;
  680. gspca_dev->usb_buf[6] = 0;
  681. gspca_dev->usb_buf[7] = 0x10;
  682. usb_control_msg(gspca_dev->dev,
  683. usb_sndctrlpipe(gspca_dev->dev, 0),
  684. 0x08,
  685. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  686. 0x08, /* value = i2c */
  687. 0,
  688. gspca_dev->usb_buf, 8,
  689. 500);
  690. }
  691. /* I2C write 8 bytes */
  692. static void i2c_w8(struct gspca_dev *gspca_dev,
  693. const __u8 *buffer)
  694. {
  695. memcpy(gspca_dev->usb_buf, buffer, 8);
  696. usb_control_msg(gspca_dev->dev,
  697. usb_sndctrlpipe(gspca_dev->dev, 0),
  698. 0x08,
  699. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  700. 0x08, 0, /* value, index */
  701. gspca_dev->usb_buf, 8,
  702. 500);
  703. msleep(2);
  704. }
  705. /* read 5 bytes in gspca_dev->usb_buf */
  706. static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg)
  707. {
  708. struct sd *sd = (struct sd *) gspca_dev;
  709. __u8 mode[8];
  710. mode[0] = 0x81 | 0x10;
  711. mode[1] = sd->i2c_base;
  712. mode[2] = reg;
  713. mode[3] = 0;
  714. mode[4] = 0;
  715. mode[5] = 0;
  716. mode[6] = 0;
  717. mode[7] = 0x10;
  718. i2c_w8(gspca_dev, mode);
  719. msleep(2);
  720. mode[0] = 0x81 | (5 << 4) | 0x02;
  721. mode[2] = 0;
  722. i2c_w8(gspca_dev, mode);
  723. msleep(2);
  724. reg_r(gspca_dev, 0x0a, 5);
  725. }
  726. static int probesensor(struct gspca_dev *gspca_dev)
  727. {
  728. struct sd *sd = (struct sd *) gspca_dev;
  729. i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
  730. msleep(10);
  731. reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
  732. msleep(10);
  733. i2c_r5(gspca_dev, 0); /* read sensor id */
  734. if (gspca_dev->usb_buf[0] == 0x02
  735. && gspca_dev->usb_buf[1] == 0x09
  736. && gspca_dev->usb_buf[2] == 0x01
  737. && gspca_dev->usb_buf[3] == 0x00
  738. && gspca_dev->usb_buf[4] == 0x00) {
  739. PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R");
  740. sd->sensor = SENSOR_HV7131R;
  741. return SENSOR_HV7131R;
  742. }
  743. PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
  744. gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
  745. gspca_dev->usb_buf[2]);
  746. PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
  747. return -ENODEV;
  748. }
  749. static int configure_gpio(struct gspca_dev *gspca_dev,
  750. const __u8 *sn9c1xx)
  751. {
  752. struct sd *sd = (struct sd *) gspca_dev;
  753. const __u8 *reg9a;
  754. static const __u8 reg9a_def[] =
  755. {0x08, 0x40, 0x20, 0x10, 0x00, 0x04};
  756. static const __u8 reg9a_sn9c325[] =
  757. {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20};
  758. static const __u8 regd4[] = {0x60, 0x00, 0x00};
  759. reg_w1(gspca_dev, 0xf1, 0x00);
  760. reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
  761. /* configure gpio */
  762. reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
  763. reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
  764. reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
  765. switch (sd->bridge) {
  766. case BRIDGE_SN9C325:
  767. reg9a = reg9a_sn9c325;
  768. break;
  769. default:
  770. reg9a = reg9a_def;
  771. break;
  772. }
  773. reg_w(gspca_dev, 0x9a, reg9a, 6);
  774. reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); /*fixme:jfm was 60 only*/
  775. reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
  776. switch (sd->sensor) {
  777. case SENSOR_OM6802:
  778. reg_w1(gspca_dev, 0x02, 0x71);
  779. reg_w1(gspca_dev, 0x01, 0x42);
  780. reg_w1(gspca_dev, 0x17, 0x64);
  781. reg_w1(gspca_dev, 0x01, 0x42);
  782. break;
  783. /*jfm: from win trace */
  784. case SENSOR_OV7630:
  785. reg_w1(gspca_dev, 0x01, 0x61);
  786. reg_w1(gspca_dev, 0x17, 0xe2);
  787. reg_w1(gspca_dev, 0x01, 0x60);
  788. reg_w1(gspca_dev, 0x01, 0x40);
  789. break;
  790. case SENSOR_OV7648:
  791. reg_w1(gspca_dev, 0x01, 0x63);
  792. reg_w1(gspca_dev, 0x17, 0x20);
  793. reg_w1(gspca_dev, 0x01, 0x42);
  794. break;
  795. /*jfm: from win trace */
  796. case SENSOR_OV7660:
  797. if (sd->bridge == BRIDGE_SN9C120) {
  798. reg_w1(gspca_dev, 0x01, 0x61);
  799. reg_w1(gspca_dev, 0x17, 0x20);
  800. reg_w1(gspca_dev, 0x01, 0x60);
  801. reg_w1(gspca_dev, 0x01, 0x40);
  802. break;
  803. }
  804. /* fall thru */
  805. default:
  806. reg_w1(gspca_dev, 0x01, 0x43);
  807. reg_w1(gspca_dev, 0x17, 0x61);
  808. reg_w1(gspca_dev, 0x01, 0x42);
  809. if (sd->sensor == SENSOR_HV7131R) {
  810. if (probesensor(gspca_dev) < 0)
  811. return -ENODEV;
  812. }
  813. break;
  814. }
  815. return 0;
  816. }
  817. static void hv7131R_InitSensor(struct gspca_dev *gspca_dev)
  818. {
  819. int i = 0;
  820. static const __u8 SetSensorClk[] = /* 0x08 Mclk */
  821. { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 };
  822. while (hv7131r_sensor_init[i][0]) {
  823. i2c_w8(gspca_dev, hv7131r_sensor_init[i]);
  824. i++;
  825. }
  826. i2c_w8(gspca_dev, SetSensorClk);
  827. }
  828. static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
  829. {
  830. int i = 0;
  831. while (mi0360_sensor_init[i][0]) {
  832. i2c_w8(gspca_dev, mi0360_sensor_init[i]);
  833. i++;
  834. }
  835. }
  836. static void mo4000_InitSensor(struct gspca_dev *gspca_dev)
  837. {
  838. int i = 0;
  839. while (mo4000_sensor_init[i][0]) {
  840. i2c_w8(gspca_dev, mo4000_sensor_init[i]);
  841. i++;
  842. }
  843. }
  844. static void om6802_InitSensor(struct gspca_dev *gspca_dev)
  845. {
  846. int i = 0;
  847. while (om6802_sensor_init[i][0]) {
  848. i2c_w8(gspca_dev, om6802_sensor_init[i]);
  849. i++;
  850. }
  851. }
  852. static void ov7630_InitSensor(struct gspca_dev *gspca_dev)
  853. {
  854. int i = 0;
  855. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 76 01 */
  856. i++;
  857. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 (RGB+SRST) */
  858. i++;
  859. msleep(20);
  860. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
  861. i++;
  862. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 */
  863. i++;
  864. msleep(20);
  865. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
  866. i++;
  867. /*jfm:win i2c_r from 00 to 80*/
  868. while (ov7630_sensor_init[i][0]) {
  869. i2c_w8(gspca_dev, ov7630_sensor_init[i]);
  870. i++;
  871. }
  872. }
  873. static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
  874. {
  875. int i = 0;
  876. i2c_w8(gspca_dev, ov7648_sensor_init[i]);
  877. i++;
  878. /* win: dble reset */
  879. i2c_w8(gspca_dev, ov7648_sensor_init[i]); /* reset */
  880. i++;
  881. msleep(20);
  882. /* win: i2c reg read 00..7f */
  883. while (ov7648_sensor_init[i][0]) {
  884. i2c_w8(gspca_dev, ov7648_sensor_init[i]);
  885. i++;
  886. }
  887. }
  888. static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
  889. {
  890. int i = 0;
  891. i2c_w8(gspca_dev, ov7660_sensor_init[i]); /* reset SCCB */
  892. i++;
  893. msleep(20);
  894. while (ov7660_sensor_init[i][0]) {
  895. i2c_w8(gspca_dev, ov7660_sensor_init[i]);
  896. i++;
  897. }
  898. }
  899. /* this function is called at probe time */
  900. static int sd_config(struct gspca_dev *gspca_dev,
  901. const struct usb_device_id *id)
  902. {
  903. struct sd *sd = (struct sd *) gspca_dev;
  904. struct cam *cam;
  905. cam = &gspca_dev->cam;
  906. cam->epaddr = 0x01;
  907. cam->cam_mode = vga_mode;
  908. cam->nmodes = ARRAY_SIZE(vga_mode);
  909. sd->bridge = id->driver_info >> 16;
  910. sd->sensor = id->driver_info >> 8;
  911. sd->i2c_base = id->driver_info;
  912. sd->qindex = 4; /* set the quantization table */
  913. sd->brightness = BRIGHTNESS_DEF;
  914. sd->contrast = CONTRAST_DEF;
  915. sd->colors = COLOR_DEF;
  916. sd->autogain = AUTOGAIN_DEF;
  917. sd->ag_cnt = -1;
  918. sd->vflip = VFLIP_DEF;
  919. sd->infrared = INFRARED_DEF;
  920. switch (sd->sensor) {
  921. case SENSOR_OV7630:
  922. case SENSOR_OV7648:
  923. case SENSOR_OV7660:
  924. gspca_dev->ctrl_dis = (1 << AUTOGAIN_IDX);
  925. break;
  926. }
  927. if (sd->sensor != SENSOR_OV7630)
  928. gspca_dev->ctrl_dis |= (1 << VFLIP_IDX);
  929. if (sd->sensor != SENSOR_MI0360)
  930. gspca_dev->ctrl_dis |= (1 << INFRARED_IDX);
  931. return 0;
  932. }
  933. /* this function is called at probe and resume time */
  934. static int sd_init(struct gspca_dev *gspca_dev)
  935. {
  936. struct sd *sd = (struct sd *) gspca_dev;
  937. /* const __u8 *sn9c1xx; */
  938. __u8 regGpio[] = { 0x29, 0x74 };
  939. __u8 regF1;
  940. /* setup a selector by bridge */
  941. reg_w1(gspca_dev, 0xf1, 0x01);
  942. reg_r(gspca_dev, 0x00, 1);
  943. reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
  944. reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
  945. regF1 = gspca_dev->usb_buf[0];
  946. PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
  947. switch (sd->bridge) {
  948. case BRIDGE_SN9C102P:
  949. if (regF1 != 0x11)
  950. return -ENODEV;
  951. reg_w1(gspca_dev, 0x02, regGpio[1]);
  952. break;
  953. case BRIDGE_SN9C105:
  954. if (regF1 != 0x11)
  955. return -ENODEV;
  956. reg_w(gspca_dev, 0x01, regGpio, 2);
  957. break;
  958. case BRIDGE_SN9C120:
  959. if (regF1 != 0x12)
  960. return -ENODEV;
  961. regGpio[1] = 0x70;
  962. reg_w(gspca_dev, 0x01, regGpio, 2);
  963. break;
  964. default:
  965. /* case BRIDGE_SN9C110: */
  966. /* case BRIDGE_SN9C325: */
  967. if (regF1 != 0x12)
  968. return -ENODEV;
  969. reg_w1(gspca_dev, 0x02, 0x62);
  970. break;
  971. }
  972. reg_w1(gspca_dev, 0xf1, 0x01);
  973. return 0;
  974. }
  975. static unsigned int setexposure(struct gspca_dev *gspca_dev,
  976. unsigned int expo)
  977. {
  978. struct sd *sd = (struct sd *) gspca_dev;
  979. static const __u8 doit[] = /* update sensor */
  980. { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
  981. static const __u8 sensorgo[] = /* sensor on */
  982. { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
  983. static const __u8 gainMo[] =
  984. { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
  985. switch (sd->sensor) {
  986. case SENSOR_HV7131R: {
  987. __u8 Expodoit[] =
  988. { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
  989. Expodoit[3] = expo >> 16;
  990. Expodoit[4] = expo >> 8;
  991. Expodoit[5] = expo;
  992. i2c_w8(gspca_dev, Expodoit);
  993. break;
  994. }
  995. case SENSOR_MI0360: {
  996. __u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
  997. { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
  998. if (expo > 0x0635)
  999. expo = 0x0635;
  1000. else if (expo < 0x0001)
  1001. expo = 0x0001;
  1002. expoMi[3] = expo >> 8;
  1003. expoMi[4] = expo;
  1004. i2c_w8(gspca_dev, expoMi);
  1005. i2c_w8(gspca_dev, doit);
  1006. i2c_w8(gspca_dev, sensorgo);
  1007. break;
  1008. }
  1009. case SENSOR_MO4000: {
  1010. __u8 expoMof[] =
  1011. { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
  1012. __u8 expoMo10[] =
  1013. { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
  1014. if (expo > 0x1fff)
  1015. expo = 0x1fff;
  1016. else if (expo < 0x0001)
  1017. expo = 0x0001;
  1018. expoMof[3] = (expo & 0x03fc) >> 2;
  1019. i2c_w8(gspca_dev, expoMof);
  1020. expoMo10[3] = ((expo & 0x1c00) >> 10)
  1021. | ((expo & 0x0003) << 4);
  1022. i2c_w8(gspca_dev, expoMo10);
  1023. i2c_w8(gspca_dev, gainMo);
  1024. PDEBUG(D_CONF, "set exposure %d",
  1025. ((expoMo10[3] & 0x07) << 10)
  1026. | (expoMof[3] << 2)
  1027. | ((expoMo10[3] & 0x30) >> 4));
  1028. break;
  1029. }
  1030. case SENSOR_OM6802: {
  1031. __u8 gainOm[] =
  1032. { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
  1033. if (expo > 0x03ff)
  1034. expo = 0x03ff;
  1035. if (expo < 0x0001)
  1036. expo = 0x0001;
  1037. gainOm[3] = expo >> 2;
  1038. i2c_w8(gspca_dev, gainOm);
  1039. reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f);
  1040. PDEBUG(D_CONF, "set exposure %d", gainOm[3]);
  1041. break;
  1042. }
  1043. }
  1044. return expo;
  1045. }
  1046. /* this function is used for sensors o76xx only */
  1047. static void setbrightcont(struct gspca_dev *gspca_dev)
  1048. {
  1049. struct sd *sd = (struct sd *) gspca_dev;
  1050. int val;
  1051. __u8 reg84_full[0x15];
  1052. memcpy(reg84_full, reg84, sizeof reg84_full);
  1053. val = sd->contrast * 0x30 / CONTRAST_MAX + 0x10; /* 10..40 */
  1054. reg84_full[0] = (val + 1) / 2; /* red */
  1055. reg84_full[2] = val; /* green */
  1056. reg84_full[4] = (val + 1) / 5; /* blue */
  1057. val = (sd->brightness - BRIGHTNESS_DEF) * 0x10
  1058. / BRIGHTNESS_MAX;
  1059. reg84_full[0x12] = val & 0x1f; /* 5:0 signed value */
  1060. reg_w(gspca_dev, 0x84, reg84_full, sizeof reg84_full);
  1061. }
  1062. /* sensor != ov76xx */
  1063. static void setbrightness(struct gspca_dev *gspca_dev)
  1064. {
  1065. struct sd *sd = (struct sd *) gspca_dev;
  1066. unsigned int expo;
  1067. __u8 k2;
  1068. k2 = sd->brightness >> 10;
  1069. switch (sd->sensor) {
  1070. case SENSOR_HV7131R:
  1071. expo = sd->brightness << 4;
  1072. if (expo > 0x002dc6c0)
  1073. expo = 0x002dc6c0;
  1074. else if (expo < 0x02a0)
  1075. expo = 0x02a0;
  1076. sd->exposure = setexposure(gspca_dev, expo);
  1077. break;
  1078. case SENSOR_MI0360:
  1079. case SENSOR_MO4000:
  1080. expo = sd->brightness >> 4;
  1081. sd->exposure = setexposure(gspca_dev, expo);
  1082. break;
  1083. case SENSOR_OM6802:
  1084. expo = sd->brightness >> 6;
  1085. sd->exposure = setexposure(gspca_dev, expo);
  1086. k2 = sd->brightness >> 11;
  1087. break;
  1088. }
  1089. reg_w1(gspca_dev, 0x96, k2);
  1090. }
  1091. /* sensor != ov76xx */
  1092. static void setcontrast(struct gspca_dev *gspca_dev)
  1093. {
  1094. struct sd *sd = (struct sd *) gspca_dev;
  1095. __u8 k2;
  1096. __u8 contrast[] = { 0x00, 0x00, 0x28, 0x00, 0x07, 0x00 };
  1097. k2 = sd->contrast;
  1098. contrast[2] = k2;
  1099. contrast[0] = (k2 + 1) >> 1;
  1100. contrast[4] = (k2 + 1) / 5;
  1101. reg_w(gspca_dev, 0x84, contrast, 6);
  1102. }
  1103. static void setcolors(struct gspca_dev *gspca_dev)
  1104. {
  1105. struct sd *sd = (struct sd *) gspca_dev;
  1106. __u8 blue, red;
  1107. if (sd->colors >= 32) {
  1108. red = 32 + (sd->colors - 32) / 2;
  1109. blue = 64 - sd->colors;
  1110. } else {
  1111. red = sd->colors;
  1112. blue = 32 + (32 - sd->colors) / 2;
  1113. }
  1114. reg_w1(gspca_dev, 0x05, red);
  1115. /* reg_w1(gspca_dev, 0x07, 32); */
  1116. reg_w1(gspca_dev, 0x06, blue);
  1117. }
  1118. static void setautogain(struct gspca_dev *gspca_dev)
  1119. {
  1120. struct sd *sd = (struct sd *) gspca_dev;
  1121. if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
  1122. return;
  1123. if (sd->autogain)
  1124. sd->ag_cnt = AG_CNT_START;
  1125. else
  1126. sd->ag_cnt = -1;
  1127. }
  1128. static void setvflip(struct sd *sd)
  1129. {
  1130. i2c_w1(&sd->gspca_dev, 0x75, /* COMN */
  1131. sd->vflip ? 0x82 : 0x02);
  1132. }
  1133. static void setinfrared(struct sd *sd)
  1134. {
  1135. /*fixme: different sequence for StarCam Clip and StarCam 370i */
  1136. /* Clip */
  1137. i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
  1138. sd->infrared ? 0x66 : 0x64);
  1139. }
  1140. /* -- start the camera -- */
  1141. static int sd_start(struct gspca_dev *gspca_dev)
  1142. {
  1143. struct sd *sd = (struct sd *) gspca_dev;
  1144. int i;
  1145. __u8 reg1, reg17, reg18;
  1146. const __u8 *sn9c1xx;
  1147. int mode;
  1148. static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
  1149. static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
  1150. static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
  1151. static const __u8 CE_ov76xx[] =
  1152. { 0x32, 0xdd, 0x32, 0xdd };
  1153. sn9c1xx = sn_tb[(int) sd->sensor];
  1154. configure_gpio(gspca_dev, sn9c1xx);
  1155. reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
  1156. reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
  1157. reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
  1158. reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
  1159. reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
  1160. reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
  1161. reg_w1(gspca_dev, 0xd3, 0x50);
  1162. reg_w1(gspca_dev, 0xc6, 0x00);
  1163. reg_w1(gspca_dev, 0xc7, 0x00);
  1164. reg_w1(gspca_dev, 0xc8, 0x50);
  1165. reg_w1(gspca_dev, 0xc9, 0x3c);
  1166. reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
  1167. switch (sd->sensor) {
  1168. case SENSOR_OV7630:
  1169. reg17 = 0xe2;
  1170. break;
  1171. case SENSOR_OV7648:
  1172. reg17 = 0x20;
  1173. break;
  1174. /*jfm: from win trace */
  1175. case SENSOR_OV7660:
  1176. if (sd->bridge == BRIDGE_SN9C120) {
  1177. reg17 = 0xa0;
  1178. break;
  1179. }
  1180. /* fall thru */
  1181. default:
  1182. reg17 = 0x60;
  1183. break;
  1184. }
  1185. reg_w1(gspca_dev, 0x17, reg17);
  1186. /* set reg1 was here */
  1187. reg_w1(gspca_dev, 0x05, sn9c1xx[5]);
  1188. reg_w1(gspca_dev, 0x07, sn9c1xx[7]);
  1189. reg_w1(gspca_dev, 0x06, sn9c1xx[6]);
  1190. reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
  1191. reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def);
  1192. for (i = 0; i < 8; i++)
  1193. reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
  1194. switch (sd->sensor) {
  1195. case SENSOR_OV7648:
  1196. reg_w1(gspca_dev, 0x9a, 0x0a);
  1197. reg_w1(gspca_dev, 0x99, 0x60);
  1198. break;
  1199. case SENSOR_OV7660:
  1200. if (sd->bridge == BRIDGE_SN9C120) {
  1201. reg_w1(gspca_dev, 0x9a, 0x05);
  1202. break;
  1203. }
  1204. /* fall thru */
  1205. default:
  1206. reg_w1(gspca_dev, 0x9a, 0x08);
  1207. reg_w1(gspca_dev, 0x99, 0x59);
  1208. break;
  1209. }
  1210. mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
  1211. if (mode)
  1212. reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
  1213. else
  1214. reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
  1215. reg17 = 0x61; /* 0x:20: enable sensor clock */
  1216. switch (sd->sensor) {
  1217. case SENSOR_HV7131R:
  1218. hv7131R_InitSensor(gspca_dev);
  1219. break;
  1220. case SENSOR_MI0360:
  1221. mi0360_InitSensor(gspca_dev);
  1222. break;
  1223. case SENSOR_MO4000:
  1224. mo4000_InitSensor(gspca_dev);
  1225. if (mode) {
  1226. /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
  1227. reg1 = 0x06; /* clk 24Mz */
  1228. } else {
  1229. reg17 = 0x22; /* 640 MCKSIZE */
  1230. /* reg1 = 0x06; * 640 clk 24Mz (done) */
  1231. }
  1232. break;
  1233. case SENSOR_OM6802:
  1234. om6802_InitSensor(gspca_dev);
  1235. reg17 = 0x64; /* 640 MCKSIZE */
  1236. break;
  1237. case SENSOR_OV7630:
  1238. ov7630_InitSensor(gspca_dev);
  1239. setvflip(sd);
  1240. reg17 = 0xe2;
  1241. reg1 = 0x44;
  1242. break;
  1243. case SENSOR_OV7648:
  1244. ov7648_InitSensor(gspca_dev);
  1245. reg17 = 0x21;
  1246. /* reg1 = 0x42; * 42 - 46? */
  1247. /* if (mode)
  1248. ; * 320x2...
  1249. else
  1250. ; * 640x... */
  1251. break;
  1252. default:
  1253. /* case SENSOR_OV7660: */
  1254. ov7660_InitSensor(gspca_dev);
  1255. if (mode) {
  1256. /* reg17 = 0x21; * 320 */
  1257. /* reg1 = 0x44; */
  1258. /* reg1 = 0x46; (done) */
  1259. } else { /* 640 */
  1260. if (sd->bridge == BRIDGE_SN9C120) {
  1261. reg17 = 0xa2;
  1262. reg1 = 0x44; /* 48 Mhz, video trf eneble */
  1263. } else {
  1264. reg17 = 0x22;
  1265. reg1 = 0x06; /* 24 Mhz, video trf eneble
  1266. * inverse power down */
  1267. }
  1268. }
  1269. break;
  1270. }
  1271. reg_w(gspca_dev, 0xc0, C0, 6);
  1272. reg_w(gspca_dev, 0xca, CA, 4);
  1273. switch (sd->sensor) {
  1274. case SENSOR_OV7630:
  1275. case SENSOR_OV7648:
  1276. case SENSOR_OV7660:
  1277. reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
  1278. break;
  1279. default:
  1280. reg_w(gspca_dev, 0xce, CE, 4);
  1281. /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
  1282. break;
  1283. }
  1284. /* here change size mode 0 -> VGA; 1 -> CIF */
  1285. reg18 = sn9c1xx[0x18] | (mode << 4);
  1286. reg_w1(gspca_dev, 0x18, reg18 | 0x40);
  1287. reg_w(gspca_dev, 0x100, qtable4, 0x40);
  1288. reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40);
  1289. reg_w1(gspca_dev, 0x18, reg18);
  1290. reg_w1(gspca_dev, 0x17, reg17);
  1291. reg_w1(gspca_dev, 0x01, reg1);
  1292. switch (sd->sensor) {
  1293. case SENSOR_MI0360:
  1294. setinfrared(sd);
  1295. /* fall thru */
  1296. case SENSOR_HV7131R:
  1297. case SENSOR_MO4000:
  1298. case SENSOR_OM6802:
  1299. setbrightness(gspca_dev);
  1300. setcontrast(gspca_dev);
  1301. break;
  1302. case SENSOR_OV7630:
  1303. setvflip(sd);
  1304. /* fall thru */
  1305. default: /* OV76xx */
  1306. setbrightcont(gspca_dev);
  1307. break;
  1308. }
  1309. setautogain(gspca_dev);
  1310. return 0;
  1311. }
  1312. static void sd_stopN(struct gspca_dev *gspca_dev)
  1313. {
  1314. struct sd *sd = (struct sd *) gspca_dev;
  1315. static const __u8 stophv7131[] =
  1316. { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
  1317. static const __u8 stopmi0360[] =
  1318. { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
  1319. static const __u8 stopov7648[] =
  1320. { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
  1321. __u8 data;
  1322. const __u8 *sn9c1xx;
  1323. data = 0x0b;
  1324. switch (sd->sensor) {
  1325. case SENSOR_HV7131R:
  1326. i2c_w8(gspca_dev, stophv7131);
  1327. data = 0x2b;
  1328. break;
  1329. case SENSOR_MI0360:
  1330. i2c_w8(gspca_dev, stopmi0360);
  1331. data = 0x29;
  1332. break;
  1333. case SENSOR_OV7648:
  1334. i2c_w8(gspca_dev, stopov7648);
  1335. /* fall thru */
  1336. case SENSOR_OV7630:
  1337. data = 0x29;
  1338. break;
  1339. default:
  1340. /* case SENSOR_MO4000: */
  1341. /* case SENSOR_OV7660: */
  1342. break;
  1343. }
  1344. sn9c1xx = sn_tb[(int) sd->sensor];
  1345. reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
  1346. reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
  1347. reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
  1348. reg_w1(gspca_dev, 0x01, data);
  1349. reg_w1(gspca_dev, 0xf1, 0x00);
  1350. }
  1351. static void do_autogain(struct gspca_dev *gspca_dev)
  1352. {
  1353. struct sd *sd = (struct sd *) gspca_dev;
  1354. int delta;
  1355. int expotimes;
  1356. __u8 luma_mean = 130;
  1357. __u8 luma_delta = 20;
  1358. /* Thanks S., without your advice, autobright should not work :) */
  1359. if (sd->ag_cnt < 0)
  1360. return;
  1361. if (--sd->ag_cnt >= 0)
  1362. return;
  1363. sd->ag_cnt = AG_CNT_START;
  1364. delta = atomic_read(&sd->avg_lum);
  1365. PDEBUG(D_FRAM, "mean lum %d", delta);
  1366. if (delta < luma_mean - luma_delta ||
  1367. delta > luma_mean + luma_delta) {
  1368. switch (sd->sensor) {
  1369. case SENSOR_HV7131R:
  1370. expotimes = sd->exposure >> 8;
  1371. expotimes += (luma_mean - delta) >> 4;
  1372. if (expotimes < 0)
  1373. expotimes = 0;
  1374. sd->exposure = setexposure(gspca_dev,
  1375. (unsigned int) (expotimes << 8));
  1376. break;
  1377. default:
  1378. /* case SENSOR_MO4000: */
  1379. /* case SENSOR_MI0360: */
  1380. /* case SENSOR_OM6802: */
  1381. expotimes = sd->exposure;
  1382. expotimes += (luma_mean - delta) >> 6;
  1383. if (expotimes < 0)
  1384. expotimes = 0;
  1385. sd->exposure = setexposure(gspca_dev,
  1386. (unsigned int) expotimes);
  1387. setcolors(gspca_dev);
  1388. break;
  1389. }
  1390. }
  1391. }
  1392. /* scan the URB packets */
  1393. /* This function is run at interrupt level. */
  1394. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  1395. struct gspca_frame *frame, /* target */
  1396. __u8 *data, /* isoc packet */
  1397. int len) /* iso packet length */
  1398. {
  1399. struct sd *sd = (struct sd *) gspca_dev;
  1400. int sof, avg_lum;
  1401. sof = len - 64;
  1402. if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
  1403. /* end of frame */
  1404. gspca_frame_add(gspca_dev, LAST_PACKET,
  1405. frame, data, sof + 2);
  1406. if (sd->ag_cnt < 0)
  1407. return;
  1408. /* w1 w2 w3 */
  1409. /* w4 w5 w6 */
  1410. /* w7 w8 */
  1411. /* w4 */
  1412. avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
  1413. /* w6 */
  1414. avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
  1415. /* w2 */
  1416. avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
  1417. /* w8 */
  1418. avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
  1419. /* w5 */
  1420. avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
  1421. avg_lum >>= 4;
  1422. atomic_set(&sd->avg_lum, avg_lum);
  1423. return;
  1424. }
  1425. if (gspca_dev->last_packet_type == LAST_PACKET) {
  1426. /* put the JPEG 422 header */
  1427. jpeg_put_header(gspca_dev, frame, sd->qindex, 0x21);
  1428. }
  1429. gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
  1430. }
  1431. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  1432. {
  1433. struct sd *sd = (struct sd *) gspca_dev;
  1434. sd->brightness = val;
  1435. if (gspca_dev->streaming) {
  1436. switch (sd->sensor) {
  1437. case SENSOR_HV7131R:
  1438. case SENSOR_MI0360:
  1439. case SENSOR_MO4000:
  1440. case SENSOR_OM6802:
  1441. setbrightness(gspca_dev);
  1442. break;
  1443. default: /* OV76xx */
  1444. setbrightcont(gspca_dev);
  1445. break;
  1446. }
  1447. }
  1448. return 0;
  1449. }
  1450. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  1451. {
  1452. struct sd *sd = (struct sd *) gspca_dev;
  1453. *val = sd->brightness;
  1454. return 0;
  1455. }
  1456. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  1457. {
  1458. struct sd *sd = (struct sd *) gspca_dev;
  1459. sd->contrast = val;
  1460. if (gspca_dev->streaming) {
  1461. switch (sd->sensor) {
  1462. case SENSOR_HV7131R:
  1463. case SENSOR_MI0360:
  1464. case SENSOR_MO4000:
  1465. case SENSOR_OM6802:
  1466. setcontrast(gspca_dev);
  1467. break;
  1468. default: /* OV76xx */
  1469. setbrightcont(gspca_dev);
  1470. break;
  1471. }
  1472. }
  1473. return 0;
  1474. }
  1475. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  1476. {
  1477. struct sd *sd = (struct sd *) gspca_dev;
  1478. *val = sd->contrast;
  1479. return 0;
  1480. }
  1481. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
  1482. {
  1483. struct sd *sd = (struct sd *) gspca_dev;
  1484. sd->colors = val;
  1485. if (gspca_dev->streaming)
  1486. setcolors(gspca_dev);
  1487. return 0;
  1488. }
  1489. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
  1490. {
  1491. struct sd *sd = (struct sd *) gspca_dev;
  1492. *val = sd->colors;
  1493. return 0;
  1494. }
  1495. static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
  1496. {
  1497. struct sd *sd = (struct sd *) gspca_dev;
  1498. sd->autogain = val;
  1499. if (gspca_dev->streaming)
  1500. setautogain(gspca_dev);
  1501. return 0;
  1502. }
  1503. static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
  1504. {
  1505. struct sd *sd = (struct sd *) gspca_dev;
  1506. *val = sd->autogain;
  1507. return 0;
  1508. }
  1509. static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
  1510. {
  1511. struct sd *sd = (struct sd *) gspca_dev;
  1512. sd->vflip = val;
  1513. if (gspca_dev->streaming)
  1514. setvflip(sd);
  1515. return 0;
  1516. }
  1517. static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
  1518. {
  1519. struct sd *sd = (struct sd *) gspca_dev;
  1520. *val = sd->vflip;
  1521. return 0;
  1522. }
  1523. static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
  1524. {
  1525. struct sd *sd = (struct sd *) gspca_dev;
  1526. sd->infrared = val;
  1527. if (gspca_dev->streaming)
  1528. setinfrared(sd);
  1529. return 0;
  1530. }
  1531. static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
  1532. {
  1533. struct sd *sd = (struct sd *) gspca_dev;
  1534. *val = sd->infrared;
  1535. return 0;
  1536. }
  1537. /* sub-driver description */
  1538. static const struct sd_desc sd_desc = {
  1539. .name = MODULE_NAME,
  1540. .ctrls = sd_ctrls,
  1541. .nctrls = ARRAY_SIZE(sd_ctrls),
  1542. .config = sd_config,
  1543. .init = sd_init,
  1544. .start = sd_start,
  1545. .stopN = sd_stopN,
  1546. .pkt_scan = sd_pkt_scan,
  1547. .dq_callback = do_autogain,
  1548. };
  1549. /* -- module initialisation -- */
  1550. #define BSI(bridge, sensor, i2c_addr) \
  1551. .driver_info = (BRIDGE_ ## bridge << 16) \
  1552. | (SENSOR_ ## sensor << 8) \
  1553. | (i2c_addr)
  1554. static const __devinitdata struct usb_device_id device_table[] = {
  1555. #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
  1556. {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)},
  1557. {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120, OV7660, 0x21)},
  1558. {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)},
  1559. {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)},
  1560. {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)},
  1561. #endif
  1562. {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
  1563. {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
  1564. {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)},
  1565. /* bw600.inf:
  1566. {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */
  1567. /* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x??)}, */
  1568. /* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x??)}, */
  1569. {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)},
  1570. /* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x??)}, */
  1571. {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)},
  1572. /* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6801, 0x??)}, */
  1573. /* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
  1574. {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)},
  1575. /* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
  1576. /* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x??)}, */
  1577. {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)},
  1578. {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)},
  1579. #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
  1580. {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)},
  1581. #endif
  1582. /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */
  1583. /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
  1584. /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
  1585. {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/
  1586. /*bw600.inf:*/
  1587. {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c110?*/
  1588. {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)},
  1589. {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x21)},
  1590. /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */
  1591. #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
  1592. {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)},
  1593. #endif
  1594. {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)},
  1595. {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)},
  1596. #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
  1597. {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)},
  1598. {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
  1599. /* {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x??)}, */
  1600. #endif
  1601. {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, MI0360, 0x5d)},
  1602. {}
  1603. };
  1604. MODULE_DEVICE_TABLE(usb, device_table);
  1605. /* -- device connect -- */
  1606. static int sd_probe(struct usb_interface *intf,
  1607. const struct usb_device_id *id)
  1608. {
  1609. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  1610. THIS_MODULE);
  1611. }
  1612. static struct usb_driver sd_driver = {
  1613. .name = MODULE_NAME,
  1614. .id_table = device_table,
  1615. .probe = sd_probe,
  1616. .disconnect = gspca_disconnect,
  1617. #ifdef CONFIG_PM
  1618. .suspend = gspca_suspend,
  1619. .resume = gspca_resume,
  1620. #endif
  1621. };
  1622. /* -- module insert / remove -- */
  1623. static int __init sd_mod_init(void)
  1624. {
  1625. if (usb_register(&sd_driver) < 0)
  1626. return -1;
  1627. info("registered");
  1628. return 0;
  1629. }
  1630. static void __exit sd_mod_exit(void)
  1631. {
  1632. usb_deregister(&sd_driver);
  1633. info("deregistered");
  1634. }
  1635. module_init(sd_mod_init);
  1636. module_exit(sd_mod_exit);