sonixj.c 53 KB

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