sonixj.c 52 KB

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