sunplus.c 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674
  1. /*
  2. * Sunplus spca504(abc) spca533 spca536 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 "sunplus"
  22. #include "gspca.h"
  23. #include "jpeg.h"
  24. MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
  25. MODULE_DESCRIPTION("GSPCA/SPCA5xx 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. __u8 packet[ISO_MAX_SIZE + 128];
  31. /* !! no more than 128 ff in an ISO packet */
  32. unsigned char brightness;
  33. unsigned char contrast;
  34. unsigned char colors;
  35. unsigned char autogain;
  36. char qindex;
  37. char bridge;
  38. #define BRIDGE_SPCA504 0
  39. #define BRIDGE_SPCA504B 1
  40. #define BRIDGE_SPCA504C 2
  41. #define BRIDGE_SPCA533 3
  42. #define BRIDGE_SPCA536 4
  43. char subtype;
  44. #define AiptekMiniPenCam13 1
  45. #define LogitechClickSmart420 2
  46. #define LogitechClickSmart820 3
  47. #define MegapixV4 4
  48. };
  49. /* V4L2 controls supported by the driver */
  50. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
  51. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
  52. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
  53. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
  54. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
  55. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
  56. static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
  57. static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
  58. static struct ctrl sd_ctrls[] = {
  59. #define SD_BRIGHTNESS 0
  60. {
  61. {
  62. .id = V4L2_CID_BRIGHTNESS,
  63. .type = V4L2_CTRL_TYPE_INTEGER,
  64. .name = "Brightness",
  65. .minimum = 0,
  66. .maximum = 0xff,
  67. .step = 1,
  68. .default_value = 0,
  69. },
  70. .set = sd_setbrightness,
  71. .get = sd_getbrightness,
  72. },
  73. #define SD_CONTRAST 1
  74. {
  75. {
  76. .id = V4L2_CID_CONTRAST,
  77. .type = V4L2_CTRL_TYPE_INTEGER,
  78. .name = "Contrast",
  79. .minimum = 0,
  80. .maximum = 0xff,
  81. .step = 1,
  82. .default_value = 0x20,
  83. },
  84. .set = sd_setcontrast,
  85. .get = sd_getcontrast,
  86. },
  87. #define SD_COLOR 2
  88. {
  89. {
  90. .id = V4L2_CID_SATURATION,
  91. .type = V4L2_CTRL_TYPE_INTEGER,
  92. .name = "Color",
  93. .minimum = 0,
  94. .maximum = 0xff,
  95. .step = 1,
  96. .default_value = 0x1a,
  97. },
  98. .set = sd_setcolors,
  99. .get = sd_getcolors,
  100. },
  101. #define SD_AUTOGAIN 3
  102. {
  103. {
  104. .id = V4L2_CID_AUTOGAIN,
  105. .type = V4L2_CTRL_TYPE_BOOLEAN,
  106. .name = "Auto Gain",
  107. .minimum = 0,
  108. .maximum = 1,
  109. .step = 1,
  110. .default_value = 1,
  111. },
  112. .set = sd_setautogain,
  113. .get = sd_getautogain,
  114. },
  115. };
  116. static struct v4l2_pix_format vga_mode[] = {
  117. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  118. .bytesperline = 320,
  119. .sizeimage = 320 * 240 * 3 / 8 + 590,
  120. .colorspace = V4L2_COLORSPACE_JPEG,
  121. .priv = 2},
  122. {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  123. .bytesperline = 640,
  124. .sizeimage = 640 * 480 * 3 / 8 + 590,
  125. .colorspace = V4L2_COLORSPACE_JPEG,
  126. .priv = 1},
  127. };
  128. static struct v4l2_pix_format custom_mode[] = {
  129. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  130. .bytesperline = 320,
  131. .sizeimage = 320 * 240 * 3 / 8 + 590,
  132. .colorspace = V4L2_COLORSPACE_JPEG,
  133. .priv = 2},
  134. {464, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  135. .bytesperline = 464,
  136. .sizeimage = 464 * 480 * 3 / 8 + 590,
  137. .colorspace = V4L2_COLORSPACE_JPEG,
  138. .priv = 1},
  139. };
  140. static struct v4l2_pix_format vga_mode2[] = {
  141. {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  142. .bytesperline = 176,
  143. .sizeimage = 176 * 144 * 3 / 8 + 590,
  144. .colorspace = V4L2_COLORSPACE_JPEG,
  145. .priv = 4},
  146. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  147. .bytesperline = 320,
  148. .sizeimage = 320 * 240 * 3 / 8 + 590,
  149. .colorspace = V4L2_COLORSPACE_JPEG,
  150. .priv = 3},
  151. {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  152. .bytesperline = 352,
  153. .sizeimage = 352 * 288 * 3 / 8 + 590,
  154. .colorspace = V4L2_COLORSPACE_JPEG,
  155. .priv = 2},
  156. {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  157. .bytesperline = 640,
  158. .sizeimage = 640 * 480 * 3 / 8 + 590,
  159. .colorspace = V4L2_COLORSPACE_JPEG,
  160. .priv = 1},
  161. };
  162. #define SPCA50X_OFFSET_DATA 10
  163. #define SPCA504_PCCAM600_OFFSET_SNAPSHOT 3
  164. #define SPCA504_PCCAM600_OFFSET_COMPRESS 4
  165. #define SPCA504_PCCAM600_OFFSET_MODE 5
  166. #define SPCA504_PCCAM600_OFFSET_DATA 14
  167. /* Frame packet header offsets for the spca533 */
  168. #define SPCA533_OFFSET_DATA 16
  169. #define SPCA533_OFFSET_FRAMSEQ 15
  170. /* Frame packet header offsets for the spca536 */
  171. #define SPCA536_OFFSET_DATA 4
  172. #define SPCA536_OFFSET_FRAMSEQ 1
  173. /* Initialisation data for the Creative PC-CAM 600 */
  174. static const __u16 spca504_pccam600_init_data[][3] = {
  175. /* {0xa0, 0x0000, 0x0503}, * capture mode */
  176. {0x00, 0x0000, 0x2000},
  177. {0x00, 0x0013, 0x2301},
  178. {0x00, 0x0003, 0x2000},
  179. {0x00, 0x0001, 0x21ac},
  180. {0x00, 0x0001, 0x21a6},
  181. {0x00, 0x0000, 0x21a7}, /* brightness */
  182. {0x00, 0x0020, 0x21a8}, /* contrast */
  183. {0x00, 0x0001, 0x21ac}, /* sat/hue */
  184. {0x00, 0x0000, 0x21ad}, /* hue */
  185. {0x00, 0x001a, 0x21ae}, /* saturation */
  186. {0x00, 0x0002, 0x21a3}, /* gamma */
  187. {0x30, 0x0154, 0x0008},
  188. {0x30, 0x0004, 0x0006},
  189. {0x30, 0x0258, 0x0009},
  190. {0x30, 0x0004, 0x0000},
  191. {0x30, 0x0093, 0x0004},
  192. {0x30, 0x0066, 0x0005},
  193. {0x00, 0x0000, 0x2000},
  194. {0x00, 0x0013, 0x2301},
  195. {0x00, 0x0003, 0x2000},
  196. {0x00, 0x0013, 0x2301},
  197. {0x00, 0x0003, 0x2000},
  198. {}
  199. };
  200. /* Creative PC-CAM 600 specific open data, sent before using the
  201. * generic initialisation data from spca504_open_data.
  202. */
  203. static const __u16 spca504_pccam600_open_data[][3] = {
  204. {0x00, 0x0001, 0x2501},
  205. {0x20, 0x0500, 0x0001}, /* snapshot mode */
  206. {0x00, 0x0003, 0x2880},
  207. {0x00, 0x0001, 0x2881},
  208. {}
  209. };
  210. /* Initialisation data for the logitech clicksmart 420 */
  211. static const __u16 spca504A_clicksmart420_init_data[][3] = {
  212. /* {0xa0, 0x0000, 0x0503}, * capture mode */
  213. {0x00, 0x0000, 0x2000},
  214. {0x00, 0x0013, 0x2301},
  215. {0x00, 0x0003, 0x2000},
  216. {0x00, 0x0001, 0x21ac},
  217. {0x00, 0x0001, 0x21a6},
  218. {0x00, 0x0000, 0x21a7}, /* brightness */
  219. {0x00, 0x0020, 0x21a8}, /* contrast */
  220. {0x00, 0x0001, 0x21ac}, /* sat/hue */
  221. {0x00, 0x0000, 0x21ad}, /* hue */
  222. {0x00, 0x001a, 0x21ae}, /* saturation */
  223. {0x00, 0x0002, 0x21a3}, /* gamma */
  224. {0x30, 0x0004, 0x000a},
  225. {0xb0, 0x0001, 0x0000},
  226. {0x0a1, 0x0080, 0x0001},
  227. {0x30, 0x0049, 0x0000},
  228. {0x30, 0x0060, 0x0005},
  229. {0x0c, 0x0004, 0x0000},
  230. {0x00, 0x0000, 0x0000},
  231. {0x00, 0x0000, 0x2000},
  232. {0x00, 0x0013, 0x2301},
  233. {0x00, 0x0003, 0x2000},
  234. {0x00, 0x0000, 0x2000},
  235. {}
  236. };
  237. /* clicksmart 420 open data ? */
  238. static const __u16 spca504A_clicksmart420_open_data[][3] = {
  239. {0x00, 0x0001, 0x2501},
  240. {0x20, 0x0502, 0x0000},
  241. {0x06, 0x0000, 0x0000},
  242. {0x00, 0x0004, 0x2880},
  243. {0x00, 0x0001, 0x2881},
  244. /* look like setting a qTable */
  245. {0x00, 0x0006, 0x2800},
  246. {0x00, 0x0004, 0x2801},
  247. {0x00, 0x0004, 0x2802},
  248. {0x00, 0x0006, 0x2803},
  249. {0x00, 0x000a, 0x2804},
  250. {0x00, 0x0010, 0x2805},
  251. {0x00, 0x0014, 0x2806},
  252. {0x00, 0x0018, 0x2807},
  253. {0x00, 0x0005, 0x2808},
  254. {0x00, 0x0005, 0x2809},
  255. {0x00, 0x0006, 0x280a},
  256. {0x00, 0x0008, 0x280b},
  257. {0x00, 0x000a, 0x280c},
  258. {0x00, 0x0017, 0x280d},
  259. {0x00, 0x0018, 0x280e},
  260. {0x00, 0x0016, 0x280f},
  261. {0x00, 0x0006, 0x2810},
  262. {0x00, 0x0005, 0x2811},
  263. {0x00, 0x0006, 0x2812},
  264. {0x00, 0x000a, 0x2813},
  265. {0x00, 0x0010, 0x2814},
  266. {0x00, 0x0017, 0x2815},
  267. {0x00, 0x001c, 0x2816},
  268. {0x00, 0x0016, 0x2817},
  269. {0x00, 0x0006, 0x2818},
  270. {0x00, 0x0007, 0x2819},
  271. {0x00, 0x0009, 0x281a},
  272. {0x00, 0x000c, 0x281b},
  273. {0x00, 0x0014, 0x281c},
  274. {0x00, 0x0023, 0x281d},
  275. {0x00, 0x0020, 0x281e},
  276. {0x00, 0x0019, 0x281f},
  277. {0x00, 0x0007, 0x2820},
  278. {0x00, 0x0009, 0x2821},
  279. {0x00, 0x000f, 0x2822},
  280. {0x00, 0x0016, 0x2823},
  281. {0x00, 0x001b, 0x2824},
  282. {0x00, 0x002c, 0x2825},
  283. {0x00, 0x0029, 0x2826},
  284. {0x00, 0x001f, 0x2827},
  285. {0x00, 0x000a, 0x2828},
  286. {0x00, 0x000e, 0x2829},
  287. {0x00, 0x0016, 0x282a},
  288. {0x00, 0x001a, 0x282b},
  289. {0x00, 0x0020, 0x282c},
  290. {0x00, 0x002a, 0x282d},
  291. {0x00, 0x002d, 0x282e},
  292. {0x00, 0x0025, 0x282f},
  293. {0x00, 0x0014, 0x2830},
  294. {0x00, 0x001a, 0x2831},
  295. {0x00, 0x001f, 0x2832},
  296. {0x00, 0x0023, 0x2833},
  297. {0x00, 0x0029, 0x2834},
  298. {0x00, 0x0030, 0x2835},
  299. {0x00, 0x0030, 0x2836},
  300. {0x00, 0x0028, 0x2837},
  301. {0x00, 0x001d, 0x2838},
  302. {0x00, 0x0025, 0x2839},
  303. {0x00, 0x0026, 0x283a},
  304. {0x00, 0x0027, 0x283b},
  305. {0x00, 0x002d, 0x283c},
  306. {0x00, 0x0028, 0x283d},
  307. {0x00, 0x0029, 0x283e},
  308. {0x00, 0x0028, 0x283f},
  309. {0x00, 0x0007, 0x2840},
  310. {0x00, 0x0007, 0x2841},
  311. {0x00, 0x000a, 0x2842},
  312. {0x00, 0x0013, 0x2843},
  313. {0x00, 0x0028, 0x2844},
  314. {0x00, 0x0028, 0x2845},
  315. {0x00, 0x0028, 0x2846},
  316. {0x00, 0x0028, 0x2847},
  317. {0x00, 0x0007, 0x2848},
  318. {0x00, 0x0008, 0x2849},
  319. {0x00, 0x000a, 0x284a},
  320. {0x00, 0x001a, 0x284b},
  321. {0x00, 0x0028, 0x284c},
  322. {0x00, 0x0028, 0x284d},
  323. {0x00, 0x0028, 0x284e},
  324. {0x00, 0x0028, 0x284f},
  325. {0x00, 0x000a, 0x2850},
  326. {0x00, 0x000a, 0x2851},
  327. {0x00, 0x0016, 0x2852},
  328. {0x00, 0x0028, 0x2853},
  329. {0x00, 0x0028, 0x2854},
  330. {0x00, 0x0028, 0x2855},
  331. {0x00, 0x0028, 0x2856},
  332. {0x00, 0x0028, 0x2857},
  333. {0x00, 0x0013, 0x2858},
  334. {0x00, 0x001a, 0x2859},
  335. {0x00, 0x0028, 0x285a},
  336. {0x00, 0x0028, 0x285b},
  337. {0x00, 0x0028, 0x285c},
  338. {0x00, 0x0028, 0x285d},
  339. {0x00, 0x0028, 0x285e},
  340. {0x00, 0x0028, 0x285f},
  341. {0x00, 0x0028, 0x2860},
  342. {0x00, 0x0028, 0x2861},
  343. {0x00, 0x0028, 0x2862},
  344. {0x00, 0x0028, 0x2863},
  345. {0x00, 0x0028, 0x2864},
  346. {0x00, 0x0028, 0x2865},
  347. {0x00, 0x0028, 0x2866},
  348. {0x00, 0x0028, 0x2867},
  349. {0x00, 0x0028, 0x2868},
  350. {0x00, 0x0028, 0x2869},
  351. {0x00, 0x0028, 0x286a},
  352. {0x00, 0x0028, 0x286b},
  353. {0x00, 0x0028, 0x286c},
  354. {0x00, 0x0028, 0x286d},
  355. {0x00, 0x0028, 0x286e},
  356. {0x00, 0x0028, 0x286f},
  357. {0x00, 0x0028, 0x2870},
  358. {0x00, 0x0028, 0x2871},
  359. {0x00, 0x0028, 0x2872},
  360. {0x00, 0x0028, 0x2873},
  361. {0x00, 0x0028, 0x2874},
  362. {0x00, 0x0028, 0x2875},
  363. {0x00, 0x0028, 0x2876},
  364. {0x00, 0x0028, 0x2877},
  365. {0x00, 0x0028, 0x2878},
  366. {0x00, 0x0028, 0x2879},
  367. {0x00, 0x0028, 0x287a},
  368. {0x00, 0x0028, 0x287b},
  369. {0x00, 0x0028, 0x287c},
  370. {0x00, 0x0028, 0x287d},
  371. {0x00, 0x0028, 0x287e},
  372. {0x00, 0x0028, 0x287f},
  373. {0xa0, 0x0000, 0x0503},
  374. {}
  375. };
  376. static const __u8 qtable_creative_pccam[2][64] = {
  377. { /* Q-table Y-components */
  378. 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
  379. 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
  380. 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11,
  381. 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13,
  382. 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17,
  383. 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c,
  384. 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e,
  385. 0x16, 0x1c, 0x1d, 0x1d, 0x22, 0x1e, 0x1f, 0x1e},
  386. { /* Q-table C-components */
  387. 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e,
  388. 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e,
  389. 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  390. 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  391. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  392. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  393. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  394. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
  395. };
  396. /* FIXME: This Q-table is identical to the Creative PC-CAM one,
  397. * except for one byte. Possibly a typo?
  398. * NWG: 18/05/2003.
  399. */
  400. static const __u8 qtable_spca504_default[2][64] = {
  401. { /* Q-table Y-components */
  402. 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
  403. 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
  404. 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11,
  405. 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13,
  406. 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17,
  407. 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c,
  408. 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e,
  409. 0x16, 0x1c, 0x1d, 0x1d, 0x1d /* 0x22 */ , 0x1e, 0x1f, 0x1e,
  410. },
  411. { /* Q-table C-components */
  412. 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e,
  413. 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e,
  414. 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  415. 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  416. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  417. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  418. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  419. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
  420. };
  421. static void reg_r(struct usb_device *dev,
  422. __u16 req,
  423. __u16 index,
  424. __u8 *buffer, __u16 length)
  425. {
  426. usb_control_msg(dev,
  427. usb_rcvctrlpipe(dev, 0),
  428. req,
  429. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  430. 0, /* value */
  431. index, buffer, length,
  432. 500);
  433. }
  434. static void reg_w(struct usb_device *dev,
  435. __u16 req,
  436. __u16 value,
  437. __u16 index,
  438. __u8 *buffer, __u16 length)
  439. {
  440. usb_control_msg(dev,
  441. usb_sndctrlpipe(dev, 0),
  442. req,
  443. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  444. value, index, buffer, length,
  445. 500);
  446. }
  447. /* write req / index / value */
  448. static int reg_w_riv(struct usb_device *dev,
  449. __u16 req, __u16 index, __u16 value)
  450. {
  451. int ret;
  452. ret = usb_control_msg(dev,
  453. usb_sndctrlpipe(dev, 0),
  454. req,
  455. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  456. value, index, NULL, 0, 500);
  457. PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d",
  458. req, index, value, ret);
  459. if (ret < 0)
  460. PDEBUG(D_ERR, "reg write: error %d", ret);
  461. return ret;
  462. }
  463. /* read 1 byte */
  464. static int reg_r_1(struct gspca_dev *gspca_dev,
  465. __u16 value) /* wValue */
  466. {
  467. int ret;
  468. ret = usb_control_msg(gspca_dev->dev,
  469. usb_rcvctrlpipe(gspca_dev->dev, 0),
  470. 0x20, /* request */
  471. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  472. value,
  473. 0, /* index */
  474. gspca_dev->usb_buf, 1,
  475. 500); /* timeout */
  476. if (ret < 0) {
  477. PDEBUG(D_ERR, "reg_r_1 err %d", ret);
  478. return 0;
  479. }
  480. return gspca_dev->usb_buf[0];
  481. }
  482. /* read 1 or 2 bytes - returns < 0 if error */
  483. static int reg_r_12(struct gspca_dev *gspca_dev,
  484. __u16 req, /* bRequest */
  485. __u16 index, /* wIndex */
  486. __u16 length) /* wLength (1 or 2 only) */
  487. {
  488. int ret;
  489. gspca_dev->usb_buf[1] = 0;
  490. ret = usb_control_msg(gspca_dev->dev,
  491. usb_rcvctrlpipe(gspca_dev->dev, 0),
  492. req,
  493. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  494. 0, /* value */
  495. index,
  496. gspca_dev->usb_buf, length,
  497. 500);
  498. if (ret < 0) {
  499. PDEBUG(D_ERR, "reg_read err %d", ret);
  500. return -1;
  501. }
  502. return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0];
  503. }
  504. static int write_vector(struct gspca_dev *gspca_dev,
  505. const __u16 data[][3])
  506. {
  507. struct usb_device *dev = gspca_dev->dev;
  508. int ret, i = 0;
  509. while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) {
  510. ret = reg_w_riv(dev, data[i][0], data[i][2], data[i][1]);
  511. if (ret < 0) {
  512. PDEBUG(D_ERR,
  513. "Register write failed for 0x%x,0x%x,0x%x",
  514. data[i][0], data[i][1], data[i][2]);
  515. return ret;
  516. }
  517. i++;
  518. }
  519. return 0;
  520. }
  521. static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
  522. unsigned int request,
  523. unsigned int ybase,
  524. unsigned int cbase,
  525. const __u8 qtable[2][64])
  526. {
  527. struct usb_device *dev = gspca_dev->dev;
  528. int i, err;
  529. /* loop over y components */
  530. for (i = 0; i < 64; i++) {
  531. err = reg_w_riv(dev, request, ybase + i, qtable[0][i]);
  532. if (err < 0)
  533. return err;
  534. }
  535. /* loop over c components */
  536. for (i = 0; i < 64; i++) {
  537. err = reg_w_riv(dev, request, cbase + i, qtable[1][i]);
  538. if (err < 0)
  539. return err;
  540. }
  541. return 0;
  542. }
  543. static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
  544. __u16 req, __u16 idx, __u16 val)
  545. {
  546. struct usb_device *dev = gspca_dev->dev;
  547. __u8 notdone;
  548. reg_w_riv(dev, req, idx, val);
  549. notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
  550. reg_w_riv(dev, req, idx, val);
  551. PDEBUG(D_FRAM, "before wait 0x%x", notdone);
  552. msleep(200);
  553. notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
  554. PDEBUG(D_FRAM, "after wait 0x%x", notdone);
  555. }
  556. static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
  557. __u16 req,
  558. __u16 idx, __u16 val, __u8 stat, __u8 count)
  559. {
  560. struct usb_device *dev = gspca_dev->dev;
  561. __u8 status;
  562. __u8 endcode;
  563. reg_w_riv(dev, req, idx, val);
  564. status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
  565. endcode = stat;
  566. PDEBUG(D_FRAM, "Status 0x%x Need 0x%x", status, stat);
  567. if (!count)
  568. return;
  569. count = 200;
  570. while (--count > 0) {
  571. msleep(10);
  572. /* gsmart mini2 write a each wait setting 1 ms is enought */
  573. /* reg_w_riv(dev, req, idx, val); */
  574. status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
  575. if (status == endcode) {
  576. PDEBUG(D_FRAM, "status 0x%x after wait 0x%x",
  577. status, 200 - count);
  578. break;
  579. }
  580. }
  581. }
  582. static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
  583. {
  584. int count = 10;
  585. while (--count > 0) {
  586. reg_r(gspca_dev->dev, 0x21, 0, gspca_dev->usb_buf, 1);
  587. if ((gspca_dev->usb_buf[0] & 0x01) == 0)
  588. break;
  589. msleep(10);
  590. }
  591. return gspca_dev->usb_buf[0];
  592. }
  593. static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
  594. {
  595. struct usb_device *dev = gspca_dev->dev;
  596. int count = 50;
  597. while (--count > 0) {
  598. reg_r(dev, 0x21, 1, gspca_dev->usb_buf, 1);
  599. if (gspca_dev->usb_buf[0] != 0) {
  600. gspca_dev->usb_buf[0] = 0;
  601. reg_w(dev, 0x21, 0, 1, gspca_dev->usb_buf, 1);
  602. reg_r(dev, 0x21, 1, gspca_dev->usb_buf, 1);
  603. spca504B_PollingDataReady(gspca_dev);
  604. break;
  605. }
  606. msleep(10);
  607. }
  608. }
  609. static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
  610. {
  611. struct usb_device *dev = gspca_dev->dev;
  612. __u8 *data;
  613. data = kmalloc(64, GFP_KERNEL);
  614. reg_r(dev, 0x20, 0, data, 5);
  615. PDEBUG(D_STREAM, "FirmWare : %d %d %d %d %d ",
  616. data[0], data[1], data[2], data[3], data[4]);
  617. reg_r(dev, 0x23, 0, data, 64);
  618. reg_r(dev, 0x23, 1, data, 64);
  619. kfree(data);
  620. }
  621. static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
  622. {
  623. struct sd *sd = (struct sd *) gspca_dev;
  624. struct usb_device *dev = gspca_dev->dev;
  625. __u8 Size;
  626. __u8 Type;
  627. int rc;
  628. Size = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
  629. Type = 0;
  630. switch (sd->bridge) {
  631. case BRIDGE_SPCA533:
  632. reg_w(dev, 0x31, 0, 0, NULL, 0);
  633. spca504B_WaitCmdStatus(gspca_dev);
  634. rc = spca504B_PollingDataReady(gspca_dev);
  635. spca50x_GetFirmware(gspca_dev);
  636. gspca_dev->usb_buf[0] = 2; /* type */
  637. reg_w(dev, 0x24, 0, 8, gspca_dev->usb_buf, 1);
  638. reg_r(dev, 0x24, 8, gspca_dev->usb_buf, 1);
  639. gspca_dev->usb_buf[0] = Size;
  640. reg_w(dev, 0x25, 0, 4, gspca_dev->usb_buf, 1);
  641. reg_r(dev, 0x25, 4, gspca_dev->usb_buf, 1); /* size */
  642. rc = spca504B_PollingDataReady(gspca_dev);
  643. /* Init the cam width height with some values get on init ? */
  644. reg_w(dev, 0x31, 0, 4, NULL, 0);
  645. spca504B_WaitCmdStatus(gspca_dev);
  646. rc = spca504B_PollingDataReady(gspca_dev);
  647. break;
  648. default:
  649. /* case BRIDGE_SPCA504B: */
  650. /* case BRIDGE_SPCA536: */
  651. gspca_dev->usb_buf[0] = Size;
  652. reg_w(dev, 0x25, 0, 4, gspca_dev->usb_buf, 1);
  653. reg_r(dev, 0x25, 4, gspca_dev->usb_buf, 1); /* size */
  654. Type = 6;
  655. gspca_dev->usb_buf[0] = Type;
  656. reg_w(dev, 0x27, 0, 0, gspca_dev->usb_buf, 1);
  657. reg_r(dev, 0x27, 0, gspca_dev->usb_buf, 1); /* type */
  658. rc = spca504B_PollingDataReady(gspca_dev);
  659. break;
  660. case BRIDGE_SPCA504:
  661. Size += 3;
  662. if (sd->subtype == AiptekMiniPenCam13) {
  663. /* spca504a aiptek */
  664. spca504A_acknowledged_command(gspca_dev,
  665. 0x08, Size, 0,
  666. 0x80 | (Size & 0x0f), 1);
  667. spca504A_acknowledged_command(gspca_dev,
  668. 1, 3, 0, 0x9f, 0);
  669. } else {
  670. spca504_acknowledged_command(gspca_dev, 0x08, Size, 0);
  671. }
  672. break;
  673. case BRIDGE_SPCA504C:
  674. /* capture mode */
  675. reg_w_riv(dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00);
  676. reg_w_riv(dev, 0x20, 0x01, 0x0500 | (Size & 0x0f));
  677. break;
  678. }
  679. }
  680. static void spca504_wait_status(struct gspca_dev *gspca_dev)
  681. {
  682. int cnt;
  683. cnt = 256;
  684. while (--cnt > 0) {
  685. /* With this we get the status, when return 0 it's all ok */
  686. if (reg_r_12(gspca_dev, 0x06, 0x00, 1) == 0)
  687. return;
  688. msleep(10);
  689. }
  690. }
  691. static void spca504B_setQtable(struct gspca_dev *gspca_dev)
  692. {
  693. struct usb_device *dev = gspca_dev->dev;
  694. gspca_dev->usb_buf[0] = 3;
  695. reg_w(dev, 0x26, 0, 0, gspca_dev->usb_buf, 1);
  696. reg_r(dev, 0x26, 0, gspca_dev->usb_buf, 1);
  697. spca504B_PollingDataReady(gspca_dev);
  698. }
  699. static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev)
  700. {
  701. struct sd *sd = (struct sd *) gspca_dev;
  702. struct usb_device *dev = gspca_dev->dev;
  703. int pollreg = 1;
  704. switch (sd->bridge) {
  705. case BRIDGE_SPCA504:
  706. case BRIDGE_SPCA504C:
  707. pollreg = 0;
  708. /* fall thru */
  709. default:
  710. /* case BRIDGE_SPCA533: */
  711. /* case BRIDGE_SPCA504B: */
  712. reg_w(dev, 0, 0, 0x21a7, NULL, 0); /* brightness */
  713. reg_w(dev, 0, 0x20, 0x21a8, NULL, 0); /* contrast */
  714. reg_w(dev, 0, 0, 0x21ad, NULL, 0); /* hue */
  715. reg_w(dev, 0, 1, 0x21ac, NULL, 0); /* sat/hue */
  716. reg_w(dev, 0, 0x20, 0x21ae, NULL, 0); /* saturation */
  717. reg_w(dev, 0, 0, 0x21a3, NULL, 0); /* gamma */
  718. break;
  719. case BRIDGE_SPCA536:
  720. reg_w(dev, 0, 0, 0x20f0, NULL, 0);
  721. reg_w(dev, 0, 0x21, 0x20f1, NULL, 0);
  722. reg_w(dev, 0, 0x40, 0x20f5, NULL, 0);
  723. reg_w(dev, 0, 1, 0x20f4, NULL, 0);
  724. reg_w(dev, 0, 0x40, 0x20f6, NULL, 0);
  725. reg_w(dev, 0, 0, 0x2089, NULL, 0);
  726. break;
  727. }
  728. if (pollreg)
  729. spca504B_PollingDataReady(gspca_dev);
  730. }
  731. /* this function is called at probe time */
  732. static int sd_config(struct gspca_dev *gspca_dev,
  733. const struct usb_device_id *id)
  734. {
  735. struct sd *sd = (struct sd *) gspca_dev;
  736. struct usb_device *dev = gspca_dev->dev;
  737. struct cam *cam;
  738. __u16 vendor;
  739. __u16 product;
  740. __u8 fw;
  741. vendor = id->idVendor;
  742. product = id->idProduct;
  743. switch (vendor) {
  744. case 0x041e: /* Creative cameras */
  745. /* switch (product) { */
  746. /* case 0x400b: */
  747. /* case 0x4012: */
  748. /* case 0x4013: */
  749. /* sd->bridge = BRIDGE_SPCA504C; */
  750. /* break; */
  751. /* } */
  752. break;
  753. case 0x0458: /* Genius KYE cameras */
  754. /* switch (product) { */
  755. /* case 0x7006: */
  756. sd->bridge = BRIDGE_SPCA504B;
  757. /* break; */
  758. /* } */
  759. break;
  760. case 0x0461: /* MicroInnovation */
  761. /* switch (product) { */
  762. /* case 0x0821: */
  763. sd->bridge = BRIDGE_SPCA533;
  764. /* break; */
  765. /* } */
  766. break;
  767. case 0x046d: /* Logitech Labtec */
  768. switch (product) {
  769. case 0x0905:
  770. sd->subtype = LogitechClickSmart820;
  771. sd->bridge = BRIDGE_SPCA533;
  772. break;
  773. case 0x0960:
  774. sd->subtype = LogitechClickSmart420;
  775. sd->bridge = BRIDGE_SPCA504C;
  776. break;
  777. }
  778. break;
  779. case 0x0471: /* Philips */
  780. /* switch (product) { */
  781. /* case 0x0322: */
  782. sd->bridge = BRIDGE_SPCA504B;
  783. /* break; */
  784. /* } */
  785. break;
  786. case 0x04a5: /* Benq */
  787. switch (product) {
  788. case 0x3003:
  789. sd->bridge = BRIDGE_SPCA504B;
  790. break;
  791. case 0x3008:
  792. case 0x300a:
  793. sd->bridge = BRIDGE_SPCA533;
  794. break;
  795. }
  796. break;
  797. case 0x04f1: /* JVC */
  798. /* switch (product) { */
  799. /* case 0x1001: */
  800. sd->bridge = BRIDGE_SPCA504B;
  801. /* break; */
  802. /* } */
  803. break;
  804. case 0x04fc: /* SunPlus */
  805. switch (product) {
  806. case 0x500c:
  807. sd->bridge = BRIDGE_SPCA504B;
  808. break;
  809. case 0x504a:
  810. /* try to get the firmware as some cam answer 2.0.1.2.2
  811. * and should be a spca504b then overwrite that setting */
  812. reg_r(dev, 0x20, 0, gspca_dev->usb_buf, 1);
  813. fw = gspca_dev->usb_buf[0];
  814. if (fw == 1) {
  815. sd->subtype = AiptekMiniPenCam13;
  816. sd->bridge = BRIDGE_SPCA504;
  817. } else if (fw == 2) {
  818. sd->bridge = BRIDGE_SPCA504B;
  819. } else
  820. return -ENODEV;
  821. break;
  822. case 0x504b:
  823. sd->bridge = BRIDGE_SPCA504B;
  824. break;
  825. case 0x5330:
  826. sd->bridge = BRIDGE_SPCA533;
  827. break;
  828. case 0x5360:
  829. sd->bridge = BRIDGE_SPCA536;
  830. break;
  831. case 0xffff:
  832. sd->bridge = BRIDGE_SPCA504B;
  833. break;
  834. }
  835. break;
  836. case 0x052b: /* ?? Megapix */
  837. /* switch (product) { */
  838. /* case 0x1513: */
  839. sd->subtype = MegapixV4;
  840. sd->bridge = BRIDGE_SPCA533;
  841. /* break; */
  842. /* } */
  843. break;
  844. case 0x0546: /* Polaroid */
  845. switch (product) {
  846. case 0x3155:
  847. sd->bridge = BRIDGE_SPCA533;
  848. break;
  849. case 0x3191:
  850. case 0x3273:
  851. sd->bridge = BRIDGE_SPCA504B;
  852. break;
  853. }
  854. break;
  855. case 0x055f: /* Mustek cameras */
  856. switch (product) {
  857. case 0xc211:
  858. sd->bridge = BRIDGE_SPCA536;
  859. break;
  860. case 0xc230:
  861. case 0xc232:
  862. sd->bridge = BRIDGE_SPCA533;
  863. break;
  864. case 0xc360:
  865. sd->bridge = BRIDGE_SPCA536;
  866. break;
  867. case 0xc420:
  868. sd->bridge = BRIDGE_SPCA504;
  869. break;
  870. case 0xc430:
  871. case 0xc440:
  872. sd->bridge = BRIDGE_SPCA533;
  873. break;
  874. case 0xc520:
  875. sd->bridge = BRIDGE_SPCA504;
  876. break;
  877. case 0xc530:
  878. case 0xc540:
  879. case 0xc630:
  880. case 0xc650:
  881. sd->bridge = BRIDGE_SPCA533;
  882. break;
  883. }
  884. break;
  885. case 0x05da: /* Digital Dream cameras */
  886. /* switch (product) { */
  887. /* case 0x1018: */
  888. sd->bridge = BRIDGE_SPCA504B;
  889. /* break; */
  890. /* } */
  891. break;
  892. case 0x06d6: /* Trust */
  893. /* switch (product) { */
  894. /* case 0x0031: */
  895. sd->bridge = BRIDGE_SPCA533; /* SPCA533A */
  896. /* break; */
  897. /* } */
  898. break;
  899. case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
  900. switch (product) {
  901. case 0x1311:
  902. case 0x1314:
  903. case 0x2211:
  904. case 0x2221:
  905. sd->bridge = BRIDGE_SPCA533;
  906. break;
  907. case 0x3261:
  908. case 0x3281:
  909. sd->bridge = BRIDGE_SPCA536;
  910. break;
  911. }
  912. break;
  913. case 0x08ca: /* Aiptek */
  914. switch (product) {
  915. case 0x0104:
  916. case 0x0106:
  917. sd->bridge = BRIDGE_SPCA533;
  918. break;
  919. case 0x2008:
  920. sd->bridge = BRIDGE_SPCA504B;
  921. break;
  922. case 0x2010:
  923. sd->bridge = BRIDGE_SPCA533;
  924. break;
  925. case 0x2016:
  926. case 0x2018:
  927. sd->bridge = BRIDGE_SPCA504B;
  928. break;
  929. case 0x2020:
  930. case 0x2022:
  931. sd->bridge = BRIDGE_SPCA533;
  932. break;
  933. case 0x2024:
  934. sd->bridge = BRIDGE_SPCA536;
  935. break;
  936. case 0x2028:
  937. sd->bridge = BRIDGE_SPCA533;
  938. break;
  939. case 0x2040:
  940. case 0x2042:
  941. case 0x2050:
  942. case 0x2060:
  943. sd->bridge = BRIDGE_SPCA536;
  944. break;
  945. }
  946. break;
  947. case 0x0d64: /* SunPlus */
  948. /* switch (product) { */
  949. /* case 0x0303: */
  950. sd->bridge = BRIDGE_SPCA536;
  951. /* break; */
  952. /* } */
  953. break;
  954. }
  955. cam = &gspca_dev->cam;
  956. cam->dev_name = (char *) id->driver_info;
  957. cam->epaddr = 0x01;
  958. switch (sd->bridge) {
  959. default:
  960. /* case BRIDGE_SPCA504B: */
  961. /* case BRIDGE_SPCA504: */
  962. /* case BRIDGE_SPCA536: */
  963. cam->cam_mode = vga_mode;
  964. cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
  965. break;
  966. case BRIDGE_SPCA533:
  967. cam->cam_mode = custom_mode;
  968. cam->nmodes = sizeof custom_mode / sizeof custom_mode[0];
  969. break;
  970. case BRIDGE_SPCA504C:
  971. cam->cam_mode = vga_mode2;
  972. cam->nmodes = sizeof vga_mode2 / sizeof vga_mode2[0];
  973. break;
  974. }
  975. sd->qindex = 5; /* set the quantization table */
  976. sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
  977. sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
  978. sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
  979. return 0;
  980. }
  981. /* this function is called at open time */
  982. static int sd_open(struct gspca_dev *gspca_dev)
  983. {
  984. struct sd *sd = (struct sd *) gspca_dev;
  985. struct usb_device *dev = gspca_dev->dev;
  986. int rc;
  987. __u8 i;
  988. __u8 info[6];
  989. int err_code;
  990. switch (sd->bridge) {
  991. case BRIDGE_SPCA504B:
  992. reg_w(dev, 0x1d, 0, 0, NULL, 0);
  993. reg_w(dev, 0, 1, 0x2306, NULL, 0);
  994. reg_w(dev, 0, 0, 0x0d04, NULL, 0);
  995. reg_w(dev, 0, 0, 0x2000, NULL, 0);
  996. reg_w(dev, 0, 0x13, 0x2301, NULL, 0);
  997. reg_w(dev, 0, 0, 0x2306, NULL, 0);
  998. /* fall thru */
  999. case BRIDGE_SPCA533:
  1000. rc = spca504B_PollingDataReady(gspca_dev);
  1001. spca50x_GetFirmware(gspca_dev);
  1002. break;
  1003. case BRIDGE_SPCA536:
  1004. spca50x_GetFirmware(gspca_dev);
  1005. reg_r(dev, 0x00, 0x5002, gspca_dev->usb_buf, 1);
  1006. gspca_dev->usb_buf[0] = 0;
  1007. reg_w(dev, 0x24, 0, 0, gspca_dev->usb_buf, 1);
  1008. reg_r(dev, 0x24, 0, gspca_dev->usb_buf, 1);
  1009. rc = spca504B_PollingDataReady(gspca_dev);
  1010. reg_w(dev, 0x34, 0, 0, NULL, 0);
  1011. spca504B_WaitCmdStatus(gspca_dev);
  1012. break;
  1013. case BRIDGE_SPCA504C: /* pccam600 */
  1014. PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)");
  1015. reg_w_riv(dev, 0xe0, 0x0000, 0x0000);
  1016. reg_w_riv(dev, 0xe0, 0x0000, 0x0001); /* reset */
  1017. spca504_wait_status(gspca_dev);
  1018. if (sd->subtype == LogitechClickSmart420)
  1019. write_vector(gspca_dev,
  1020. spca504A_clicksmart420_open_data);
  1021. else
  1022. write_vector(gspca_dev, spca504_pccam600_open_data);
  1023. err_code = spca50x_setup_qtable(gspca_dev,
  1024. 0x00, 0x2800,
  1025. 0x2840, qtable_creative_pccam);
  1026. if (err_code < 0) {
  1027. PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed");
  1028. return err_code;
  1029. }
  1030. break;
  1031. default:
  1032. /* case BRIDGE_SPCA504: */
  1033. PDEBUG(D_STREAM, "Opening SPCA504");
  1034. if (sd->subtype == AiptekMiniPenCam13) {
  1035. /*****************************/
  1036. for (i = 0; i < 6; i++)
  1037. info[i] = reg_r_1(gspca_dev, i);
  1038. PDEBUG(D_STREAM,
  1039. "Read info: %d %d %d %d %d %d."
  1040. " Should be 1,0,2,2,0,0",
  1041. info[0], info[1], info[2],
  1042. info[3], info[4], info[5]);
  1043. /* spca504a aiptek */
  1044. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  1045. spca504A_acknowledged_command(gspca_dev, 0x24,
  1046. 8, 3, 0x9e, 1);
  1047. /* Twice sequencial need status 0xff->0x9e->0x9d */
  1048. spca504A_acknowledged_command(gspca_dev, 0x24,
  1049. 8, 3, 0x9e, 0);
  1050. spca504A_acknowledged_command(gspca_dev, 0x24,
  1051. 0, 0, 0x9d, 1);
  1052. /******************************/
  1053. /* spca504a aiptek */
  1054. spca504A_acknowledged_command(gspca_dev, 0x08,
  1055. 6, 0, 0x86, 1);
  1056. /* reg_write (dev, 0, 0x2000, 0); */
  1057. /* reg_write (dev, 0, 0x2883, 1); */
  1058. /* spca504A_acknowledged_command (gspca_dev, 0x08,
  1059. 6, 0, 0x86, 1); */
  1060. /* spca504A_acknowledged_command (gspca_dev, 0x24,
  1061. 0, 0, 0x9D, 1); */
  1062. reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */
  1063. reg_w_riv(dev, 0x0, 0x2310, 0x05);
  1064. spca504A_acknowledged_command(gspca_dev, 0x01,
  1065. 0x0f, 0, 0xff, 0);
  1066. }
  1067. /* setup qtable */
  1068. reg_w_riv(dev, 0, 0x2000, 0);
  1069. reg_w_riv(dev, 0, 0x2883, 1);
  1070. err_code = spca50x_setup_qtable(gspca_dev,
  1071. 0x00, 0x2800,
  1072. 0x2840,
  1073. qtable_spca504_default);
  1074. if (err_code < 0) {
  1075. PDEBUG(D_ERR, "spca50x_setup_qtable failed");
  1076. return err_code;
  1077. }
  1078. break;
  1079. }
  1080. return 0;
  1081. }
  1082. static void sd_start(struct gspca_dev *gspca_dev)
  1083. {
  1084. struct sd *sd = (struct sd *) gspca_dev;
  1085. struct usb_device *dev = gspca_dev->dev;
  1086. int rc;
  1087. int enable;
  1088. __u8 i;
  1089. __u8 info[6];
  1090. if (sd->bridge == BRIDGE_SPCA504B)
  1091. spca504B_setQtable(gspca_dev);
  1092. spca504B_SetSizeType(gspca_dev);
  1093. switch (sd->bridge) {
  1094. default:
  1095. /* case BRIDGE_SPCA504B: */
  1096. /* case BRIDGE_SPCA533: */
  1097. /* case BRIDGE_SPCA536: */
  1098. if (sd->subtype == MegapixV4 ||
  1099. sd->subtype == LogitechClickSmart820) {
  1100. reg_w(dev, 0xf0, 0, 0, NULL, 0);
  1101. spca504B_WaitCmdStatus(gspca_dev);
  1102. reg_r(dev, 0xf0, 4, NULL, 0);
  1103. spca504B_WaitCmdStatus(gspca_dev);
  1104. } else {
  1105. reg_w(dev, 0x31, 0, 4, NULL, 0);
  1106. spca504B_WaitCmdStatus(gspca_dev);
  1107. rc = spca504B_PollingDataReady(gspca_dev);
  1108. }
  1109. break;
  1110. case BRIDGE_SPCA504:
  1111. if (sd->subtype == AiptekMiniPenCam13) {
  1112. for (i = 0; i < 6; i++)
  1113. info[i] = reg_r_1(gspca_dev, i);
  1114. PDEBUG(D_STREAM,
  1115. "Read info: %d %d %d %d %d %d."
  1116. " Should be 1,0,2,2,0,0",
  1117. info[0], info[1], info[2],
  1118. info[3], info[4], info[5]);
  1119. /* spca504a aiptek */
  1120. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  1121. spca504A_acknowledged_command(gspca_dev, 0x24,
  1122. 8, 3, 0x9e, 1);
  1123. /* Twice sequencial need status 0xff->0x9e->0x9d */
  1124. spca504A_acknowledged_command(gspca_dev, 0x24,
  1125. 8, 3, 0x9e, 0);
  1126. spca504A_acknowledged_command(gspca_dev, 0x24,
  1127. 0, 0, 0x9d, 1);
  1128. } else {
  1129. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  1130. for (i = 0; i < 6; i++)
  1131. info[i] = reg_r_1(gspca_dev, i);
  1132. PDEBUG(D_STREAM,
  1133. "Read info: %d %d %d %d %d %d."
  1134. " Should be 1,0,2,2,0,0",
  1135. info[0], info[1], info[2],
  1136. info[3], info[4], info[5]);
  1137. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  1138. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  1139. }
  1140. spca504B_SetSizeType(gspca_dev);
  1141. reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */
  1142. reg_w_riv(dev, 0x0, 0x2310, 0x05);
  1143. break;
  1144. case BRIDGE_SPCA504C:
  1145. if (sd->subtype == LogitechClickSmart420) {
  1146. write_vector(gspca_dev,
  1147. spca504A_clicksmart420_init_data);
  1148. } else {
  1149. write_vector(gspca_dev, spca504_pccam600_init_data);
  1150. }
  1151. enable = (sd->autogain ? 0x04 : 0x01);
  1152. reg_w_riv(dev, 0x0c, 0x0000, enable); /* auto exposure */
  1153. reg_w_riv(dev, 0xb0, 0x0000, enable); /* auto whiteness */
  1154. /* set default exposure compensation and whiteness balance */
  1155. reg_w_riv(dev, 0x30, 0x0001, 800); /* ~ 20 fps */
  1156. reg_w_riv(dev, 0x30, 0x0002, 1600);
  1157. spca504B_SetSizeType(gspca_dev);
  1158. break;
  1159. }
  1160. sp5xx_initContBrigHueRegisters(gspca_dev);
  1161. }
  1162. static void sd_stopN(struct gspca_dev *gspca_dev)
  1163. {
  1164. struct sd *sd = (struct sd *) gspca_dev;
  1165. struct usb_device *dev = gspca_dev->dev;
  1166. switch (sd->bridge) {
  1167. default:
  1168. /* case BRIDGE_SPCA533: */
  1169. /* case BRIDGE_SPCA536: */
  1170. /* case BRIDGE_SPCA504B: */
  1171. reg_w(dev, 0x31, 0, 0, NULL, 0);
  1172. spca504B_WaitCmdStatus(gspca_dev);
  1173. spca504B_PollingDataReady(gspca_dev);
  1174. break;
  1175. case BRIDGE_SPCA504:
  1176. case BRIDGE_SPCA504C:
  1177. reg_w_riv(dev, 0x00, 0x2000, 0x0000);
  1178. if (sd->subtype == AiptekMiniPenCam13) {
  1179. /* spca504a aiptek */
  1180. /* spca504A_acknowledged_command(gspca_dev, 0x08,
  1181. 6, 0, 0x86, 1); */
  1182. spca504A_acknowledged_command(gspca_dev, 0x24,
  1183. 0x00, 0x00, 0x9d, 1);
  1184. spca504A_acknowledged_command(gspca_dev, 0x01,
  1185. 0x0f, 0x00, 0xff, 1);
  1186. } else {
  1187. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  1188. reg_w_riv(dev, 0x01, 0x000f, 0x00);
  1189. }
  1190. break;
  1191. }
  1192. }
  1193. static void sd_stop0(struct gspca_dev *gspca_dev)
  1194. {
  1195. }
  1196. static void sd_close(struct gspca_dev *gspca_dev)
  1197. {
  1198. }
  1199. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  1200. struct gspca_frame *frame, /* target */
  1201. __u8 *data, /* isoc packet */
  1202. int len) /* iso packet length */
  1203. {
  1204. struct sd *sd = (struct sd *) gspca_dev;
  1205. int i, sof = 0;
  1206. unsigned char *s, *d;
  1207. static unsigned char ffd9[] = {0xff, 0xd9};
  1208. /* frames are jpeg 4.1.1 without 0xff escape */
  1209. switch (sd->bridge) {
  1210. case BRIDGE_SPCA533:
  1211. if (data[0] == 0xff) {
  1212. if (data[1] != 0x01) { /* drop packet */
  1213. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  1214. return;
  1215. }
  1216. sof = 1;
  1217. data += SPCA533_OFFSET_DATA;
  1218. len -= SPCA533_OFFSET_DATA;
  1219. } else {
  1220. data += 1;
  1221. len -= 1;
  1222. }
  1223. break;
  1224. case BRIDGE_SPCA536:
  1225. if (data[0] == 0xff) {
  1226. sof = 1;
  1227. data += SPCA536_OFFSET_DATA;
  1228. len -= SPCA536_OFFSET_DATA;
  1229. } else {
  1230. data += 2;
  1231. len -= 2;
  1232. }
  1233. break;
  1234. default:
  1235. /* case BRIDGE_SPCA504: */
  1236. /* case BRIDGE_SPCA504B: */
  1237. switch (data[0]) {
  1238. case 0xfe: /* start of frame */
  1239. sof = 1;
  1240. data += SPCA50X_OFFSET_DATA;
  1241. len -= SPCA50X_OFFSET_DATA;
  1242. break;
  1243. case 0xff: /* drop packet */
  1244. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  1245. return;
  1246. default:
  1247. data += 1;
  1248. len -= 1;
  1249. break;
  1250. }
  1251. break;
  1252. case BRIDGE_SPCA504C:
  1253. switch (data[0]) {
  1254. case 0xfe: /* start of frame */
  1255. sof = 1;
  1256. data += SPCA504_PCCAM600_OFFSET_DATA;
  1257. len -= SPCA504_PCCAM600_OFFSET_DATA;
  1258. break;
  1259. case 0xff: /* drop packet */
  1260. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  1261. return;
  1262. default:
  1263. data += 1;
  1264. len -= 1;
  1265. break;
  1266. }
  1267. break;
  1268. }
  1269. if (sof) { /* start of frame */
  1270. frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
  1271. ffd9, 2);
  1272. /* put the JPEG header in the new frame */
  1273. jpeg_put_header(gspca_dev, frame,
  1274. ((struct sd *) gspca_dev)->qindex,
  1275. 0x22);
  1276. }
  1277. /* add 0x00 after 0xff */
  1278. for (i = len; --i >= 0; )
  1279. if (data[i] == 0xff)
  1280. break;
  1281. if (i < 0) { /* no 0xff */
  1282. gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
  1283. return;
  1284. }
  1285. s = data;
  1286. d = sd->packet;
  1287. for (i = 0; i < len; i++) {
  1288. *d++ = *s++;
  1289. if (s[-1] == 0xff)
  1290. *d++ = 0x00;
  1291. }
  1292. gspca_frame_add(gspca_dev, INTER_PACKET, frame,
  1293. sd->packet, d - sd->packet);
  1294. }
  1295. static void setbrightness(struct gspca_dev *gspca_dev)
  1296. {
  1297. struct sd *sd = (struct sd *) gspca_dev;
  1298. struct usb_device *dev = gspca_dev->dev;
  1299. switch (sd->bridge) {
  1300. default:
  1301. /* case BRIDGE_SPCA533: */
  1302. /* case BRIDGE_SPCA504B: */
  1303. /* case BRIDGE_SPCA504: */
  1304. /* case BRIDGE_SPCA504C: */
  1305. reg_w_riv(dev, 0x0, 0x21a7, sd->brightness);
  1306. break;
  1307. case BRIDGE_SPCA536:
  1308. reg_w_riv(dev, 0x0, 0x20f0, sd->brightness);
  1309. break;
  1310. }
  1311. }
  1312. static void getbrightness(struct gspca_dev *gspca_dev)
  1313. {
  1314. struct sd *sd = (struct sd *) gspca_dev;
  1315. __u16 brightness = 0;
  1316. switch (sd->bridge) {
  1317. default:
  1318. /* case BRIDGE_SPCA533: */
  1319. /* case BRIDGE_SPCA504B: */
  1320. /* case BRIDGE_SPCA504: */
  1321. /* case BRIDGE_SPCA504C: */
  1322. brightness = reg_r_12(gspca_dev, 0x00, 0x21a7, 2);
  1323. break;
  1324. case BRIDGE_SPCA536:
  1325. brightness = reg_r_12(gspca_dev, 0x00, 0x20f0, 2);
  1326. break;
  1327. }
  1328. sd->brightness = ((brightness & 0xff) - 128) % 255;
  1329. }
  1330. static void setcontrast(struct gspca_dev *gspca_dev)
  1331. {
  1332. struct sd *sd = (struct sd *) gspca_dev;
  1333. struct usb_device *dev = gspca_dev->dev;
  1334. switch (sd->bridge) {
  1335. default:
  1336. /* case BRIDGE_SPCA533: */
  1337. /* case BRIDGE_SPCA504B: */
  1338. /* case BRIDGE_SPCA504: */
  1339. /* case BRIDGE_SPCA504C: */
  1340. reg_w_riv(dev, 0x0, 0x21a8, sd->contrast);
  1341. break;
  1342. case BRIDGE_SPCA536:
  1343. reg_w_riv(dev, 0x0, 0x20f1, sd->contrast);
  1344. break;
  1345. }
  1346. }
  1347. static void getcontrast(struct gspca_dev *gspca_dev)
  1348. {
  1349. struct sd *sd = (struct sd *) gspca_dev;
  1350. switch (sd->bridge) {
  1351. default:
  1352. /* case BRIDGE_SPCA533: */
  1353. /* case BRIDGE_SPCA504B: */
  1354. /* case BRIDGE_SPCA504: */
  1355. /* case BRIDGE_SPCA504C: */
  1356. sd->contrast = reg_r_12(gspca_dev, 0x00, 0x21a8, 2);
  1357. break;
  1358. case BRIDGE_SPCA536:
  1359. sd->contrast = reg_r_12(gspca_dev, 0x00, 0x20f1, 2);
  1360. break;
  1361. }
  1362. }
  1363. static void setcolors(struct gspca_dev *gspca_dev)
  1364. {
  1365. struct sd *sd = (struct sd *) gspca_dev;
  1366. struct usb_device *dev = gspca_dev->dev;
  1367. switch (sd->bridge) {
  1368. default:
  1369. /* case BRIDGE_SPCA533: */
  1370. /* case BRIDGE_SPCA504B: */
  1371. /* case BRIDGE_SPCA504: */
  1372. /* case BRIDGE_SPCA504C: */
  1373. reg_w_riv(dev, 0x0, 0x21ae, sd->colors);
  1374. break;
  1375. case BRIDGE_SPCA536:
  1376. reg_w_riv(dev, 0x0, 0x20f6, sd->colors);
  1377. break;
  1378. }
  1379. }
  1380. static void getcolors(struct gspca_dev *gspca_dev)
  1381. {
  1382. struct sd *sd = (struct sd *) gspca_dev;
  1383. switch (sd->bridge) {
  1384. default:
  1385. /* case BRIDGE_SPCA533: */
  1386. /* case BRIDGE_SPCA504B: */
  1387. /* case BRIDGE_SPCA504: */
  1388. /* case BRIDGE_SPCA504C: */
  1389. sd->colors = reg_r_12(gspca_dev, 0x00, 0x21ae, 2) >> 1;
  1390. break;
  1391. case BRIDGE_SPCA536:
  1392. sd->colors = reg_r_12(gspca_dev, 0x00, 0x20f6, 2) >> 1;
  1393. break;
  1394. }
  1395. }
  1396. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  1397. {
  1398. struct sd *sd = (struct sd *) gspca_dev;
  1399. sd->brightness = val;
  1400. if (gspca_dev->streaming)
  1401. setbrightness(gspca_dev);
  1402. return 0;
  1403. }
  1404. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  1405. {
  1406. struct sd *sd = (struct sd *) gspca_dev;
  1407. getbrightness(gspca_dev);
  1408. *val = sd->brightness;
  1409. return 0;
  1410. }
  1411. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  1412. {
  1413. struct sd *sd = (struct sd *) gspca_dev;
  1414. sd->contrast = val;
  1415. if (gspca_dev->streaming)
  1416. setcontrast(gspca_dev);
  1417. return 0;
  1418. }
  1419. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  1420. {
  1421. struct sd *sd = (struct sd *) gspca_dev;
  1422. getcontrast(gspca_dev);
  1423. *val = sd->contrast;
  1424. return 0;
  1425. }
  1426. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
  1427. {
  1428. struct sd *sd = (struct sd *) gspca_dev;
  1429. sd->colors = val;
  1430. if (gspca_dev->streaming)
  1431. setcolors(gspca_dev);
  1432. return 0;
  1433. }
  1434. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
  1435. {
  1436. struct sd *sd = (struct sd *) gspca_dev;
  1437. getcolors(gspca_dev);
  1438. *val = sd->colors;
  1439. return 0;
  1440. }
  1441. static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
  1442. {
  1443. struct sd *sd = (struct sd *) gspca_dev;
  1444. sd->autogain = val;
  1445. return 0;
  1446. }
  1447. static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
  1448. {
  1449. struct sd *sd = (struct sd *) gspca_dev;
  1450. *val = sd->autogain;
  1451. return 0;
  1452. }
  1453. /* sub-driver description */
  1454. static const struct sd_desc sd_desc = {
  1455. .name = MODULE_NAME,
  1456. .ctrls = sd_ctrls,
  1457. .nctrls = ARRAY_SIZE(sd_ctrls),
  1458. .config = sd_config,
  1459. .open = sd_open,
  1460. .start = sd_start,
  1461. .stopN = sd_stopN,
  1462. .stop0 = sd_stop0,
  1463. .close = sd_close,
  1464. .pkt_scan = sd_pkt_scan,
  1465. };
  1466. /* -- module initialisation -- */
  1467. #define DVNM(name) .driver_info = (kernel_ulong_t) name
  1468. static const __devinitdata struct usb_device_id device_table[] = {
  1469. {USB_DEVICE(0x041e, 0x400b), DVNM("Creative PC-CAM 600")},
  1470. {USB_DEVICE(0x041e, 0x4012), DVNM("PC-Cam350")},
  1471. {USB_DEVICE(0x041e, 0x4013), DVNM("Creative Pccam750")},
  1472. {USB_DEVICE(0x0458, 0x7006), DVNM("Genius Dsc 1.3 Smart")},
  1473. {USB_DEVICE(0x0461, 0x0821), DVNM("Fujifilm MV-1")},
  1474. {USB_DEVICE(0x046d, 0x0905), DVNM("Logitech ClickSmart 820")},
  1475. {USB_DEVICE(0x046d, 0x0960), DVNM("Logitech ClickSmart 420")},
  1476. {USB_DEVICE(0x0471, 0x0322), DVNM("Philips DMVC1300K")},
  1477. {USB_DEVICE(0x04a5, 0x3003), DVNM("Benq DC 1300")},
  1478. {USB_DEVICE(0x04a5, 0x3008), DVNM("Benq DC 1500")},
  1479. {USB_DEVICE(0x04a5, 0x300a), DVNM("Benq DC3410")},
  1480. {USB_DEVICE(0x04f1, 0x1001), DVNM("JVC GC A50")},
  1481. {USB_DEVICE(0x04fc, 0x500c), DVNM("Sunplus CA500C")},
  1482. {USB_DEVICE(0x04fc, 0x504a), DVNM("Aiptek Mini PenCam 1.3")},
  1483. {USB_DEVICE(0x04fc, 0x504b), DVNM("Maxell MaxPocket LE 1.3")},
  1484. {USB_DEVICE(0x04fc, 0x5330), DVNM("Digitrex 2110")},
  1485. {USB_DEVICE(0x04fc, 0x5360), DVNM("Sunplus Generic")},
  1486. {USB_DEVICE(0x04fc, 0xffff), DVNM("Pure DigitalDakota")},
  1487. {USB_DEVICE(0x052b, 0x1513), DVNM("Megapix V4")},
  1488. {USB_DEVICE(0x0546, 0x3155), DVNM("Polaroid PDC3070")},
  1489. {USB_DEVICE(0x0546, 0x3191), DVNM("Polaroid Ion 80")},
  1490. {USB_DEVICE(0x0546, 0x3273), DVNM("Polaroid PDC2030")},
  1491. {USB_DEVICE(0x055f, 0xc211), DVNM("Kowa Bs888e Microcamera")},
  1492. {USB_DEVICE(0x055f, 0xc230), DVNM("Mustek Digicam 330K")},
  1493. {USB_DEVICE(0x055f, 0xc232), DVNM("Mustek MDC3500")},
  1494. {USB_DEVICE(0x055f, 0xc360), DVNM("Mustek DV4000 Mpeg4 ")},
  1495. {USB_DEVICE(0x055f, 0xc420), DVNM("Mustek gSmart Mini 2")},
  1496. {USB_DEVICE(0x055f, 0xc430), DVNM("Mustek Gsmart LCD 2")},
  1497. {USB_DEVICE(0x055f, 0xc440), DVNM("Mustek DV 3000")},
  1498. {USB_DEVICE(0x055f, 0xc520), DVNM("Mustek gSmart Mini 3")},
  1499. {USB_DEVICE(0x055f, 0xc530), DVNM("Mustek Gsmart LCD 3")},
  1500. {USB_DEVICE(0x055f, 0xc540), DVNM("Gsmart D30")},
  1501. {USB_DEVICE(0x055f, 0xc630), DVNM("Mustek MDC4000")},
  1502. {USB_DEVICE(0x055f, 0xc650), DVNM("Mustek MDC5500Z")},
  1503. {USB_DEVICE(0x05da, 0x1018), DVNM("Digital Dream Enigma 1.3")},
  1504. {USB_DEVICE(0x06d6, 0x0031), DVNM("Trust 610 LCD PowerC@m Zoom")},
  1505. {USB_DEVICE(0x0733, 0x1311), DVNM("Digital Dream Epsilon 1.3")},
  1506. {USB_DEVICE(0x0733, 0x1314), DVNM("Mercury 2.1MEG Deluxe Classic Cam")},
  1507. {USB_DEVICE(0x0733, 0x2211), DVNM("Jenoptik jdc 21 LCD")},
  1508. {USB_DEVICE(0x0733, 0x2221), DVNM("Mercury Digital Pro 3.1p")},
  1509. {USB_DEVICE(0x0733, 0x3261), DVNM("Concord 3045 spca536a")},
  1510. {USB_DEVICE(0x0733, 0x3281), DVNM("Cyberpix S550V")},
  1511. {USB_DEVICE(0x08ca, 0x0104), DVNM("Aiptek PocketDVII 1.3")},
  1512. {USB_DEVICE(0x08ca, 0x0106), DVNM("Aiptek Pocket DV3100+")},
  1513. {USB_DEVICE(0x08ca, 0x2008), DVNM("Aiptek Mini PenCam 2 M")},
  1514. {USB_DEVICE(0x08ca, 0x2010), DVNM("Aiptek PocketCam 3M")},
  1515. {USB_DEVICE(0x08ca, 0x2016), DVNM("Aiptek PocketCam 2 Mega")},
  1516. {USB_DEVICE(0x08ca, 0x2018), DVNM("Aiptek Pencam SD 2M")},
  1517. {USB_DEVICE(0x08ca, 0x2020), DVNM("Aiptek Slim 3000F")},
  1518. {USB_DEVICE(0x08ca, 0x2022), DVNM("Aiptek Slim 3200")},
  1519. {USB_DEVICE(0x08ca, 0x2024), DVNM("Aiptek DV3500 Mpeg4 ")},
  1520. {USB_DEVICE(0x08ca, 0x2028), DVNM("Aiptek PocketCam4M")},
  1521. {USB_DEVICE(0x08ca, 0x2040), DVNM("Aiptek PocketDV4100M")},
  1522. {USB_DEVICE(0x08ca, 0x2042), DVNM("Aiptek PocketDV5100")},
  1523. {USB_DEVICE(0x08ca, 0x2050), DVNM("Medion MD 41437")},
  1524. {USB_DEVICE(0x08ca, 0x2060), DVNM("Aiptek PocketDV5300")},
  1525. {USB_DEVICE(0x0d64, 0x0303), DVNM("Sunplus FashionCam DXG")},
  1526. {}
  1527. };
  1528. MODULE_DEVICE_TABLE(usb, device_table);
  1529. /* -- device connect -- */
  1530. static int sd_probe(struct usb_interface *intf,
  1531. const struct usb_device_id *id)
  1532. {
  1533. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  1534. THIS_MODULE);
  1535. }
  1536. static struct usb_driver sd_driver = {
  1537. .name = MODULE_NAME,
  1538. .id_table = device_table,
  1539. .probe = sd_probe,
  1540. .disconnect = gspca_disconnect,
  1541. };
  1542. /* -- module insert / remove -- */
  1543. static int __init sd_mod_init(void)
  1544. {
  1545. if (usb_register(&sd_driver) < 0)
  1546. return -1;
  1547. PDEBUG(D_PROBE, "registered");
  1548. return 0;
  1549. }
  1550. static void __exit sd_mod_exit(void)
  1551. {
  1552. usb_deregister(&sd_driver);
  1553. PDEBUG(D_PROBE, "deregistered");
  1554. }
  1555. module_init(sd_mod_init);
  1556. module_exit(sd_mod_exit);