sunplus.c 43 KB

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