sonixj.c 74 KB

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