sonixj.c 53 KB

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