sonixj.c 64 KB

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