sunplus.c 42 KB

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