sonixj.c 49 KB

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