sonixj.c 51 KB

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