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. __u16 brightness;
  34. __u8 contrast;
  35. __u8 colors;
  36. __u8 autogain;
  37. __u8 blue;
  38. __u8 red;
  39. __u8 vflip; /* ov7630 only */
  40. __u8 infrared; /* mi0360 only */
  41. __s8 ag_cnt;
  42. #define AG_CNT_START 13
  43. __u8 qindex;
  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->epaddr = 0x01;
  956. cam->cam_mode = vga_mode;
  957. cam->nmodes = ARRAY_SIZE(vga_mode);
  958. sd->bridge = id->driver_info >> 16;
  959. sd->sensor = id->driver_info >> 8;
  960. sd->i2c_base = id->driver_info;
  961. sd->qindex = 4; /* set the quantization table */
  962. sd->brightness = BRIGHTNESS_DEF;
  963. sd->contrast = CONTRAST_DEF;
  964. sd->colors = COLOR_DEF;
  965. sd->blue = BLUE_BALANCE_DEF;
  966. sd->red = RED_BALANCE_DEF;
  967. sd->autogain = AUTOGAIN_DEF;
  968. sd->ag_cnt = -1;
  969. sd->vflip = VFLIP_DEF;
  970. sd->infrared = INFRARED_DEF;
  971. gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
  972. return 0;
  973. }
  974. /* this function is called at probe and resume time */
  975. static int sd_init(struct gspca_dev *gspca_dev)
  976. {
  977. struct sd *sd = (struct sd *) gspca_dev;
  978. __u8 regGpio[] = { 0x29, 0x74 };
  979. __u8 regF1;
  980. /* setup a selector by bridge */
  981. reg_w1(gspca_dev, 0xf1, 0x01);
  982. reg_r(gspca_dev, 0x00, 1);
  983. reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
  984. reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
  985. regF1 = gspca_dev->usb_buf[0];
  986. PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
  987. switch (sd->bridge) {
  988. case BRIDGE_SN9C102P:
  989. if (regF1 != 0x11)
  990. return -ENODEV;
  991. reg_w1(gspca_dev, 0x02, regGpio[1]);
  992. break;
  993. case BRIDGE_SN9C105:
  994. if (regF1 != 0x11)
  995. return -ENODEV;
  996. reg_w(gspca_dev, 0x01, regGpio, 2);
  997. break;
  998. case BRIDGE_SN9C120:
  999. if (regF1 != 0x12)
  1000. return -ENODEV;
  1001. regGpio[1] = 0x70;
  1002. reg_w(gspca_dev, 0x01, regGpio, 2);
  1003. break;
  1004. default:
  1005. /* case BRIDGE_SN9C110: */
  1006. /* case BRIDGE_SN9C325: */
  1007. if (regF1 != 0x12)
  1008. return -ENODEV;
  1009. reg_w1(gspca_dev, 0x02, 0x62);
  1010. break;
  1011. }
  1012. reg_w1(gspca_dev, 0xf1, 0x01);
  1013. return 0;
  1014. }
  1015. static unsigned int setexposure(struct gspca_dev *gspca_dev,
  1016. unsigned int expo)
  1017. {
  1018. struct sd *sd = (struct sd *) gspca_dev;
  1019. static const __u8 doit[] = /* update sensor */
  1020. { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
  1021. static const __u8 sensorgo[] = /* sensor on */
  1022. { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
  1023. static const __u8 gainMo[] =
  1024. { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
  1025. switch (sd->sensor) {
  1026. case SENSOR_HV7131R: {
  1027. __u8 Expodoit[] =
  1028. { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
  1029. Expodoit[3] = expo >> 16;
  1030. Expodoit[4] = expo >> 8;
  1031. Expodoit[5] = expo;
  1032. i2c_w8(gspca_dev, Expodoit);
  1033. break;
  1034. }
  1035. case SENSOR_MI0360: {
  1036. __u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
  1037. { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
  1038. if (expo > 0x0635)
  1039. expo = 0x0635;
  1040. else if (expo < 0x0001)
  1041. expo = 0x0001;
  1042. expoMi[3] = expo >> 8;
  1043. expoMi[4] = expo;
  1044. i2c_w8(gspca_dev, expoMi);
  1045. i2c_w8(gspca_dev, doit);
  1046. i2c_w8(gspca_dev, sensorgo);
  1047. break;
  1048. }
  1049. case SENSOR_MO4000: {
  1050. __u8 expoMof[] =
  1051. { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
  1052. __u8 expoMo10[] =
  1053. { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
  1054. if (expo > 0x1fff)
  1055. expo = 0x1fff;
  1056. else if (expo < 0x0001)
  1057. expo = 0x0001;
  1058. expoMof[3] = (expo & 0x03fc) >> 2;
  1059. i2c_w8(gspca_dev, expoMof);
  1060. expoMo10[3] = ((expo & 0x1c00) >> 10)
  1061. | ((expo & 0x0003) << 4);
  1062. i2c_w8(gspca_dev, expoMo10);
  1063. i2c_w8(gspca_dev, gainMo);
  1064. PDEBUG(D_CONF, "set exposure %d",
  1065. ((expoMo10[3] & 0x07) << 10)
  1066. | (expoMof[3] << 2)
  1067. | ((expoMo10[3] & 0x30) >> 4));
  1068. break;
  1069. }
  1070. case SENSOR_OM6802: {
  1071. __u8 gainOm[] =
  1072. { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
  1073. if (expo > 0x03ff)
  1074. expo = 0x03ff;
  1075. if (expo < 0x0001)
  1076. expo = 0x0001;
  1077. gainOm[3] = expo >> 2;
  1078. i2c_w8(gspca_dev, gainOm);
  1079. reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f);
  1080. PDEBUG(D_CONF, "set exposure %d", gainOm[3]);
  1081. break;
  1082. }
  1083. }
  1084. return expo;
  1085. }
  1086. static void setbrightness(struct gspca_dev *gspca_dev)
  1087. {
  1088. struct sd *sd = (struct sd *) gspca_dev;
  1089. unsigned int expo;
  1090. __u8 k2;
  1091. k2 = ((int) sd->brightness - 0x8000) >> 10;
  1092. switch (sd->sensor) {
  1093. case SENSOR_HV7131R:
  1094. expo = sd->brightness << 4;
  1095. if (expo > 0x002dc6c0)
  1096. expo = 0x002dc6c0;
  1097. else if (expo < 0x02a0)
  1098. expo = 0x02a0;
  1099. sd->exposure = setexposure(gspca_dev, expo);
  1100. break;
  1101. case SENSOR_MI0360:
  1102. case SENSOR_MO4000:
  1103. expo = sd->brightness >> 4;
  1104. sd->exposure = setexposure(gspca_dev, expo);
  1105. break;
  1106. case SENSOR_OM6802:
  1107. expo = sd->brightness >> 6;
  1108. sd->exposure = setexposure(gspca_dev, expo);
  1109. k2 = sd->brightness >> 11;
  1110. break;
  1111. }
  1112. reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
  1113. }
  1114. static void setcontrast(struct gspca_dev *gspca_dev)
  1115. {
  1116. struct sd *sd = (struct sd *) gspca_dev;
  1117. __u8 k2;
  1118. __u8 contrast[6];
  1119. k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
  1120. contrast[0] = (k2 + 1) / 2; /* red */
  1121. contrast[1] = 0;
  1122. contrast[2] = k2; /* green */
  1123. contrast[3] = 0;
  1124. contrast[4] = (k2 + 1) / 5; /* blue */
  1125. contrast[5] = 0;
  1126. reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
  1127. }
  1128. static void setcolors(struct gspca_dev *gspca_dev)
  1129. {
  1130. struct sd *sd = (struct sd *) gspca_dev;
  1131. int i, v;
  1132. __u8 reg8a[12]; /* U & V gains */
  1133. static __s16 uv[6] = { /* same as reg84 in signed decimal */
  1134. -24, -38, 64, /* UR UG UB */
  1135. 62, -51, -9 /* VR VG VB */
  1136. };
  1137. for (i = 0; i < 6; i++) {
  1138. v = uv[i] * sd->colors / COLOR_DEF;
  1139. reg8a[i * 2] = v;
  1140. reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
  1141. }
  1142. reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
  1143. }
  1144. static void setredblue(struct gspca_dev *gspca_dev)
  1145. {
  1146. struct sd *sd = (struct sd *) gspca_dev;
  1147. reg_w1(gspca_dev, 0x05, sd->red);
  1148. /* reg_w1(gspca_dev, 0x07, 32); */
  1149. reg_w1(gspca_dev, 0x06, sd->blue);
  1150. }
  1151. static void setautogain(struct gspca_dev *gspca_dev)
  1152. {
  1153. struct sd *sd = (struct sd *) gspca_dev;
  1154. if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
  1155. return;
  1156. if (sd->autogain)
  1157. sd->ag_cnt = AG_CNT_START;
  1158. else
  1159. sd->ag_cnt = -1;
  1160. }
  1161. static void setvflip(struct sd *sd)
  1162. {
  1163. i2c_w1(&sd->gspca_dev, 0x75, /* COMN */
  1164. sd->vflip ? 0x82 : 0x02);
  1165. }
  1166. static void setinfrared(struct sd *sd)
  1167. {
  1168. /*fixme: different sequence for StarCam Clip and StarCam 370i */
  1169. /* Clip */
  1170. i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
  1171. sd->infrared ? 0x66 : 0x64);
  1172. }
  1173. /* -- start the camera -- */
  1174. static int sd_start(struct gspca_dev *gspca_dev)
  1175. {
  1176. struct sd *sd = (struct sd *) gspca_dev;
  1177. int i;
  1178. __u8 reg1, reg17, reg18;
  1179. const __u8 *sn9c1xx;
  1180. int mode;
  1181. static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
  1182. static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
  1183. static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
  1184. static const __u8 CE_ov76xx[] =
  1185. { 0x32, 0xdd, 0x32, 0xdd };
  1186. sn9c1xx = sn_tb[(int) sd->sensor];
  1187. configure_gpio(gspca_dev, sn9c1xx);
  1188. reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
  1189. reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
  1190. reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
  1191. reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
  1192. reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
  1193. reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
  1194. reg_w1(gspca_dev, 0xd3, 0x50);
  1195. reg_w1(gspca_dev, 0xc6, 0x00);
  1196. reg_w1(gspca_dev, 0xc7, 0x00);
  1197. reg_w1(gspca_dev, 0xc8, 0x50);
  1198. reg_w1(gspca_dev, 0xc9, 0x3c);
  1199. reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
  1200. switch (sd->sensor) {
  1201. case SENSOR_OV7630:
  1202. reg17 = 0xe2;
  1203. break;
  1204. case SENSOR_OV7648:
  1205. reg17 = 0x20;
  1206. break;
  1207. /*jfm: from win trace */
  1208. case SENSOR_OV7660:
  1209. if (sd->bridge == BRIDGE_SN9C120) {
  1210. reg17 = 0xa0;
  1211. break;
  1212. }
  1213. /* fall thru */
  1214. default:
  1215. reg17 = 0x60;
  1216. break;
  1217. }
  1218. reg_w1(gspca_dev, 0x17, reg17);
  1219. /* set reg1 was here */
  1220. reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
  1221. reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
  1222. reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
  1223. reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
  1224. reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def);
  1225. for (i = 0; i < 8; i++)
  1226. reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
  1227. switch (sd->sensor) {
  1228. case SENSOR_OV7648:
  1229. reg_w1(gspca_dev, 0x9a, 0x0a);
  1230. reg_w1(gspca_dev, 0x99, 0x60);
  1231. break;
  1232. case SENSOR_OV7660:
  1233. if (sd->bridge == BRIDGE_SN9C120) {
  1234. reg_w1(gspca_dev, 0x9a, 0x05);
  1235. break;
  1236. }
  1237. /* fall thru */
  1238. default:
  1239. reg_w1(gspca_dev, 0x9a, 0x08);
  1240. reg_w1(gspca_dev, 0x99, 0x59);
  1241. break;
  1242. }
  1243. mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
  1244. if (mode)
  1245. reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
  1246. else
  1247. reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
  1248. reg17 = 0x61; /* 0x:20: enable sensor clock */
  1249. switch (sd->sensor) {
  1250. case SENSOR_HV7131R:
  1251. hv7131R_InitSensor(gspca_dev);
  1252. break;
  1253. case SENSOR_MI0360:
  1254. mi0360_InitSensor(gspca_dev);
  1255. break;
  1256. case SENSOR_MO4000:
  1257. mo4000_InitSensor(gspca_dev);
  1258. if (mode) {
  1259. /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
  1260. reg1 = 0x06; /* clk 24Mz */
  1261. } else {
  1262. reg17 = 0x22; /* 640 MCKSIZE */
  1263. /* reg1 = 0x06; * 640 clk 24Mz (done) */
  1264. }
  1265. break;
  1266. case SENSOR_OM6802:
  1267. om6802_InitSensor(gspca_dev);
  1268. reg17 = 0x64; /* 640 MCKSIZE */
  1269. break;
  1270. case SENSOR_OV7630:
  1271. ov7630_InitSensor(gspca_dev);
  1272. setvflip(sd);
  1273. reg17 = 0xe2;
  1274. reg1 = 0x44;
  1275. break;
  1276. case SENSOR_OV7648:
  1277. ov7648_InitSensor(gspca_dev);
  1278. reg17 = 0x21;
  1279. /* reg1 = 0x42; * 42 - 46? */
  1280. break;
  1281. default:
  1282. /* case SENSOR_OV7660: */
  1283. ov7660_InitSensor(gspca_dev);
  1284. if (sd->bridge == BRIDGE_SN9C120) {
  1285. if (mode) { /* 320x240 - 160x120 */
  1286. reg17 = 0xa2;
  1287. reg1 = 0x44; /* 48 Mhz, video trf eneble */
  1288. }
  1289. } else {
  1290. reg17 = 0x22;
  1291. reg1 = 0x06; /* 24 Mhz, video trf eneble
  1292. * inverse power down */
  1293. }
  1294. break;
  1295. }
  1296. reg_w(gspca_dev, 0xc0, C0, 6);
  1297. reg_w(gspca_dev, 0xca, CA, 4);
  1298. switch (sd->sensor) {
  1299. case SENSOR_OV7630:
  1300. case SENSOR_OV7648:
  1301. case SENSOR_OV7660:
  1302. reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
  1303. break;
  1304. default:
  1305. reg_w(gspca_dev, 0xce, CE, 4);
  1306. /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
  1307. break;
  1308. }
  1309. /* here change size mode 0 -> VGA; 1 -> CIF */
  1310. reg18 = sn9c1xx[0x18] | (mode << 4);
  1311. reg_w1(gspca_dev, 0x18, reg18 | 0x40);
  1312. reg_w(gspca_dev, 0x100, qtable4, 0x40);
  1313. reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40);
  1314. reg_w1(gspca_dev, 0x18, reg18);
  1315. reg_w1(gspca_dev, 0x17, reg17);
  1316. reg_w1(gspca_dev, 0x01, reg1);
  1317. switch (sd->sensor) {
  1318. case SENSOR_MI0360:
  1319. setinfrared(sd);
  1320. break;
  1321. case SENSOR_OV7630:
  1322. setvflip(sd);
  1323. break;
  1324. }
  1325. setbrightness(gspca_dev);
  1326. setcontrast(gspca_dev);
  1327. setautogain(gspca_dev);
  1328. return 0;
  1329. }
  1330. static void sd_stopN(struct gspca_dev *gspca_dev)
  1331. {
  1332. struct sd *sd = (struct sd *) gspca_dev;
  1333. static const __u8 stophv7131[] =
  1334. { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
  1335. static const __u8 stopmi0360[] =
  1336. { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
  1337. static const __u8 stopov7648[] =
  1338. { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
  1339. __u8 data;
  1340. const __u8 *sn9c1xx;
  1341. data = 0x0b;
  1342. switch (sd->sensor) {
  1343. case SENSOR_HV7131R:
  1344. i2c_w8(gspca_dev, stophv7131);
  1345. data = 0x2b;
  1346. break;
  1347. case SENSOR_MI0360:
  1348. i2c_w8(gspca_dev, stopmi0360);
  1349. data = 0x29;
  1350. break;
  1351. case SENSOR_OV7648:
  1352. i2c_w8(gspca_dev, stopov7648);
  1353. /* fall thru */
  1354. case SENSOR_OV7630:
  1355. data = 0x29;
  1356. break;
  1357. default:
  1358. /* case SENSOR_MO4000: */
  1359. /* case SENSOR_OV7660: */
  1360. break;
  1361. }
  1362. sn9c1xx = sn_tb[(int) sd->sensor];
  1363. reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
  1364. reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
  1365. reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
  1366. reg_w1(gspca_dev, 0x01, data);
  1367. reg_w1(gspca_dev, 0xf1, 0x00);
  1368. }
  1369. static void do_autogain(struct gspca_dev *gspca_dev)
  1370. {
  1371. struct sd *sd = (struct sd *) gspca_dev;
  1372. int delta;
  1373. int expotimes;
  1374. __u8 luma_mean = 130;
  1375. __u8 luma_delta = 20;
  1376. /* Thanks S., without your advice, autobright should not work :) */
  1377. if (sd->ag_cnt < 0)
  1378. return;
  1379. if (--sd->ag_cnt >= 0)
  1380. return;
  1381. sd->ag_cnt = AG_CNT_START;
  1382. delta = atomic_read(&sd->avg_lum);
  1383. PDEBUG(D_FRAM, "mean lum %d", delta);
  1384. if (delta < luma_mean - luma_delta ||
  1385. delta > luma_mean + luma_delta) {
  1386. switch (sd->sensor) {
  1387. case SENSOR_HV7131R:
  1388. expotimes = sd->exposure >> 8;
  1389. expotimes += (luma_mean - delta) >> 4;
  1390. if (expotimes < 0)
  1391. expotimes = 0;
  1392. sd->exposure = setexposure(gspca_dev,
  1393. (unsigned int) (expotimes << 8));
  1394. break;
  1395. default:
  1396. /* case SENSOR_MO4000: */
  1397. /* case SENSOR_MI0360: */
  1398. /* case SENSOR_OM6802: */
  1399. expotimes = sd->exposure;
  1400. expotimes += (luma_mean - delta) >> 6;
  1401. if (expotimes < 0)
  1402. expotimes = 0;
  1403. sd->exposure = setexposure(gspca_dev,
  1404. (unsigned int) expotimes);
  1405. setredblue(gspca_dev);
  1406. break;
  1407. }
  1408. }
  1409. }
  1410. /* scan the URB packets */
  1411. /* This function is run at interrupt level. */
  1412. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  1413. struct gspca_frame *frame, /* target */
  1414. __u8 *data, /* isoc packet */
  1415. int len) /* iso packet length */
  1416. {
  1417. struct sd *sd = (struct sd *) gspca_dev;
  1418. int sof, avg_lum;
  1419. sof = len - 64;
  1420. if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
  1421. /* end of frame */
  1422. gspca_frame_add(gspca_dev, LAST_PACKET,
  1423. frame, data, sof + 2);
  1424. if (sd->ag_cnt < 0)
  1425. return;
  1426. /* w1 w2 w3 */
  1427. /* w4 w5 w6 */
  1428. /* w7 w8 */
  1429. /* w4 */
  1430. avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
  1431. /* w6 */
  1432. avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
  1433. /* w2 */
  1434. avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
  1435. /* w8 */
  1436. avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
  1437. /* w5 */
  1438. avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
  1439. avg_lum >>= 4;
  1440. atomic_set(&sd->avg_lum, avg_lum);
  1441. return;
  1442. }
  1443. if (gspca_dev->last_packet_type == LAST_PACKET) {
  1444. /* put the JPEG 422 header */
  1445. jpeg_put_header(gspca_dev, frame, sd->qindex, 0x21);
  1446. }
  1447. gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
  1448. }
  1449. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  1450. {
  1451. struct sd *sd = (struct sd *) gspca_dev;
  1452. sd->brightness = val;
  1453. if (gspca_dev->streaming)
  1454. setbrightness(gspca_dev);
  1455. return 0;
  1456. }
  1457. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  1458. {
  1459. struct sd *sd = (struct sd *) gspca_dev;
  1460. *val = sd->brightness;
  1461. return 0;
  1462. }
  1463. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  1464. {
  1465. struct sd *sd = (struct sd *) gspca_dev;
  1466. sd->contrast = val;
  1467. if (gspca_dev->streaming)
  1468. setcontrast(gspca_dev);
  1469. return 0;
  1470. }
  1471. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  1472. {
  1473. struct sd *sd = (struct sd *) gspca_dev;
  1474. *val = sd->contrast;
  1475. return 0;
  1476. }
  1477. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
  1478. {
  1479. struct sd *sd = (struct sd *) gspca_dev;
  1480. sd->colors = val;
  1481. if (gspca_dev->streaming)
  1482. setcolors(gspca_dev);
  1483. return 0;
  1484. }
  1485. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
  1486. {
  1487. struct sd *sd = (struct sd *) gspca_dev;
  1488. *val = sd->colors;
  1489. return 0;
  1490. }
  1491. static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
  1492. {
  1493. struct sd *sd = (struct sd *) gspca_dev;
  1494. sd->blue = val;
  1495. if (gspca_dev->streaming)
  1496. setredblue(gspca_dev);
  1497. return 0;
  1498. }
  1499. static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
  1500. {
  1501. struct sd *sd = (struct sd *) gspca_dev;
  1502. *val = sd->blue;
  1503. return 0;
  1504. }
  1505. static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
  1506. {
  1507. struct sd *sd = (struct sd *) gspca_dev;
  1508. sd->red = val;
  1509. if (gspca_dev->streaming)
  1510. setredblue(gspca_dev);
  1511. return 0;
  1512. }
  1513. static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
  1514. {
  1515. struct sd *sd = (struct sd *) gspca_dev;
  1516. *val = sd->red;
  1517. return 0;
  1518. }
  1519. static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
  1520. {
  1521. struct sd *sd = (struct sd *) gspca_dev;
  1522. sd->autogain = val;
  1523. if (gspca_dev->streaming)
  1524. setautogain(gspca_dev);
  1525. return 0;
  1526. }
  1527. static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
  1528. {
  1529. struct sd *sd = (struct sd *) gspca_dev;
  1530. *val = sd->autogain;
  1531. return 0;
  1532. }
  1533. static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
  1534. {
  1535. struct sd *sd = (struct sd *) gspca_dev;
  1536. sd->vflip = val;
  1537. if (gspca_dev->streaming)
  1538. setvflip(sd);
  1539. return 0;
  1540. }
  1541. static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
  1542. {
  1543. struct sd *sd = (struct sd *) gspca_dev;
  1544. *val = sd->vflip;
  1545. return 0;
  1546. }
  1547. static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
  1548. {
  1549. struct sd *sd = (struct sd *) gspca_dev;
  1550. sd->infrared = val;
  1551. if (gspca_dev->streaming)
  1552. setinfrared(sd);
  1553. return 0;
  1554. }
  1555. static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
  1556. {
  1557. struct sd *sd = (struct sd *) gspca_dev;
  1558. *val = sd->infrared;
  1559. return 0;
  1560. }
  1561. /* sub-driver description */
  1562. static const struct sd_desc sd_desc = {
  1563. .name = MODULE_NAME,
  1564. .ctrls = sd_ctrls,
  1565. .nctrls = ARRAY_SIZE(sd_ctrls),
  1566. .config = sd_config,
  1567. .init = sd_init,
  1568. .start = sd_start,
  1569. .stopN = sd_stopN,
  1570. .pkt_scan = sd_pkt_scan,
  1571. .dq_callback = do_autogain,
  1572. };
  1573. /* -- module initialisation -- */
  1574. #define BSI(bridge, sensor, i2c_addr) \
  1575. .driver_info = (BRIDGE_ ## bridge << 16) \
  1576. | (SENSOR_ ## sensor << 8) \
  1577. | (i2c_addr)
  1578. static const __devinitdata struct usb_device_id device_table[] = {
  1579. #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
  1580. {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)},
  1581. {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120, OV7660, 0x21)},
  1582. #endif
  1583. {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)},
  1584. {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)},
  1585. #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
  1586. {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)},
  1587. #endif
  1588. {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
  1589. {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
  1590. {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)},
  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);