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