sunplus.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675
  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 0x2060:
  944. sd->bridge = BRIDGE_SPCA536;
  945. break;
  946. }
  947. break;
  948. case 0x0d64: /* SunPlus */
  949. /* switch (product) { */
  950. /* case 0x0303: */
  951. sd->bridge = BRIDGE_SPCA536;
  952. /* break; */
  953. /* } */
  954. break;
  955. }
  956. cam = &gspca_dev->cam;
  957. cam->dev_name = (char *) id->driver_info;
  958. cam->epaddr = 0x01;
  959. switch (sd->bridge) {
  960. default:
  961. /* case BRIDGE_SPCA504B: */
  962. /* case BRIDGE_SPCA504: */
  963. /* case BRIDGE_SPCA536: */
  964. cam->cam_mode = vga_mode;
  965. cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
  966. break;
  967. case BRIDGE_SPCA533:
  968. cam->cam_mode = custom_mode;
  969. cam->nmodes = sizeof custom_mode / sizeof custom_mode[0];
  970. break;
  971. case BRIDGE_SPCA504C:
  972. cam->cam_mode = vga_mode2;
  973. cam->nmodes = sizeof vga_mode2 / sizeof vga_mode2[0];
  974. break;
  975. }
  976. sd->qindex = 5; /* set the quantization table */
  977. sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
  978. sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
  979. sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
  980. return 0;
  981. }
  982. /* this function is called at open time */
  983. static int sd_open(struct gspca_dev *gspca_dev)
  984. {
  985. struct sd *sd = (struct sd *) gspca_dev;
  986. struct usb_device *dev = gspca_dev->dev;
  987. int rc;
  988. __u8 i;
  989. __u8 info[6];
  990. int err_code;
  991. switch (sd->bridge) {
  992. case BRIDGE_SPCA504B:
  993. reg_w(dev, 0x1d, 0, 0, NULL, 0);
  994. reg_w(dev, 0, 1, 0x2306, NULL, 0);
  995. reg_w(dev, 0, 0, 0x0d04, NULL, 0);
  996. reg_w(dev, 0, 0, 0x2000, NULL, 0);
  997. reg_w(dev, 0, 0x13, 0x2301, NULL, 0);
  998. reg_w(dev, 0, 0, 0x2306, NULL, 0);
  999. /* fall thru */
  1000. case BRIDGE_SPCA533:
  1001. rc = spca504B_PollingDataReady(gspca_dev);
  1002. spca50x_GetFirmware(gspca_dev);
  1003. break;
  1004. case BRIDGE_SPCA536:
  1005. spca50x_GetFirmware(gspca_dev);
  1006. reg_r(dev, 0x00, 0x5002, gspca_dev->usb_buf, 1);
  1007. gspca_dev->usb_buf[0] = 0;
  1008. reg_w(dev, 0x24, 0, 0, gspca_dev->usb_buf, 1);
  1009. reg_r(dev, 0x24, 0, gspca_dev->usb_buf, 1);
  1010. rc = spca504B_PollingDataReady(gspca_dev);
  1011. reg_w(dev, 0x34, 0, 0, NULL, 0);
  1012. spca504B_WaitCmdStatus(gspca_dev);
  1013. break;
  1014. case BRIDGE_SPCA504C: /* pccam600 */
  1015. PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)");
  1016. reg_w_riv(dev, 0xe0, 0x0000, 0x0000);
  1017. reg_w_riv(dev, 0xe0, 0x0000, 0x0001); /* reset */
  1018. spca504_wait_status(gspca_dev);
  1019. if (sd->subtype == LogitechClickSmart420)
  1020. write_vector(gspca_dev,
  1021. spca504A_clicksmart420_open_data);
  1022. else
  1023. write_vector(gspca_dev, spca504_pccam600_open_data);
  1024. err_code = spca50x_setup_qtable(gspca_dev,
  1025. 0x00, 0x2800,
  1026. 0x2840, qtable_creative_pccam);
  1027. if (err_code < 0) {
  1028. PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed");
  1029. return err_code;
  1030. }
  1031. break;
  1032. default:
  1033. /* case BRIDGE_SPCA504: */
  1034. PDEBUG(D_STREAM, "Opening SPCA504");
  1035. if (sd->subtype == AiptekMiniPenCam13) {
  1036. /*****************************/
  1037. for (i = 0; i < 6; i++)
  1038. info[i] = reg_r_1(gspca_dev, i);
  1039. PDEBUG(D_STREAM,
  1040. "Read info: %d %d %d %d %d %d."
  1041. " Should be 1,0,2,2,0,0",
  1042. info[0], info[1], info[2],
  1043. info[3], info[4], info[5]);
  1044. /* spca504a aiptek */
  1045. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  1046. spca504A_acknowledged_command(gspca_dev, 0x24,
  1047. 8, 3, 0x9e, 1);
  1048. /* Twice sequencial need status 0xff->0x9e->0x9d */
  1049. spca504A_acknowledged_command(gspca_dev, 0x24,
  1050. 8, 3, 0x9e, 0);
  1051. spca504A_acknowledged_command(gspca_dev, 0x24,
  1052. 0, 0, 0x9d, 1);
  1053. /******************************/
  1054. /* spca504a aiptek */
  1055. spca504A_acknowledged_command(gspca_dev, 0x08,
  1056. 6, 0, 0x86, 1);
  1057. /* reg_write (dev, 0, 0x2000, 0); */
  1058. /* reg_write (dev, 0, 0x2883, 1); */
  1059. /* spca504A_acknowledged_command (gspca_dev, 0x08,
  1060. 6, 0, 0x86, 1); */
  1061. /* spca504A_acknowledged_command (gspca_dev, 0x24,
  1062. 0, 0, 0x9D, 1); */
  1063. reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */
  1064. reg_w_riv(dev, 0x0, 0x2310, 0x05);
  1065. spca504A_acknowledged_command(gspca_dev, 0x01,
  1066. 0x0f, 0, 0xff, 0);
  1067. }
  1068. /* setup qtable */
  1069. reg_w_riv(dev, 0, 0x2000, 0);
  1070. reg_w_riv(dev, 0, 0x2883, 1);
  1071. err_code = spca50x_setup_qtable(gspca_dev,
  1072. 0x00, 0x2800,
  1073. 0x2840,
  1074. qtable_spca504_default);
  1075. if (err_code < 0) {
  1076. PDEBUG(D_ERR, "spca50x_setup_qtable failed");
  1077. return err_code;
  1078. }
  1079. break;
  1080. }
  1081. return 0;
  1082. }
  1083. static void sd_start(struct gspca_dev *gspca_dev)
  1084. {
  1085. struct sd *sd = (struct sd *) gspca_dev;
  1086. struct usb_device *dev = gspca_dev->dev;
  1087. int rc;
  1088. int enable;
  1089. __u8 i;
  1090. __u8 info[6];
  1091. if (sd->bridge == BRIDGE_SPCA504B)
  1092. spca504B_setQtable(gspca_dev);
  1093. spca504B_SetSizeType(gspca_dev);
  1094. switch (sd->bridge) {
  1095. default:
  1096. /* case BRIDGE_SPCA504B: */
  1097. /* case BRIDGE_SPCA533: */
  1098. /* case BRIDGE_SPCA536: */
  1099. if (sd->subtype == MegapixV4 ||
  1100. sd->subtype == LogitechClickSmart820) {
  1101. reg_w(dev, 0xf0, 0, 0, NULL, 0);
  1102. spca504B_WaitCmdStatus(gspca_dev);
  1103. reg_r(dev, 0xf0, 4, NULL, 0);
  1104. spca504B_WaitCmdStatus(gspca_dev);
  1105. } else {
  1106. reg_w(dev, 0x31, 0, 4, NULL, 0);
  1107. spca504B_WaitCmdStatus(gspca_dev);
  1108. rc = spca504B_PollingDataReady(gspca_dev);
  1109. }
  1110. break;
  1111. case BRIDGE_SPCA504:
  1112. if (sd->subtype == AiptekMiniPenCam13) {
  1113. for (i = 0; i < 6; i++)
  1114. info[i] = reg_r_1(gspca_dev, i);
  1115. PDEBUG(D_STREAM,
  1116. "Read info: %d %d %d %d %d %d."
  1117. " Should be 1,0,2,2,0,0",
  1118. info[0], info[1], info[2],
  1119. info[3], info[4], info[5]);
  1120. /* spca504a aiptek */
  1121. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  1122. spca504A_acknowledged_command(gspca_dev, 0x24,
  1123. 8, 3, 0x9e, 1);
  1124. /* Twice sequencial need status 0xff->0x9e->0x9d */
  1125. spca504A_acknowledged_command(gspca_dev, 0x24,
  1126. 8, 3, 0x9e, 0);
  1127. spca504A_acknowledged_command(gspca_dev, 0x24,
  1128. 0, 0, 0x9d, 1);
  1129. } else {
  1130. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  1131. for (i = 0; i < 6; i++)
  1132. info[i] = reg_r_1(gspca_dev, i);
  1133. PDEBUG(D_STREAM,
  1134. "Read info: %d %d %d %d %d %d."
  1135. " Should be 1,0,2,2,0,0",
  1136. info[0], info[1], info[2],
  1137. info[3], info[4], info[5]);
  1138. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  1139. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  1140. }
  1141. spca504B_SetSizeType(gspca_dev);
  1142. reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */
  1143. reg_w_riv(dev, 0x0, 0x2310, 0x05);
  1144. break;
  1145. case BRIDGE_SPCA504C:
  1146. if (sd->subtype == LogitechClickSmart420) {
  1147. write_vector(gspca_dev,
  1148. spca504A_clicksmart420_init_data);
  1149. } else {
  1150. write_vector(gspca_dev, spca504_pccam600_init_data);
  1151. }
  1152. enable = (sd->autogain ? 0x04 : 0x01);
  1153. reg_w_riv(dev, 0x0c, 0x0000, enable); /* auto exposure */
  1154. reg_w_riv(dev, 0xb0, 0x0000, enable); /* auto whiteness */
  1155. /* set default exposure compensation and whiteness balance */
  1156. reg_w_riv(dev, 0x30, 0x0001, 800); /* ~ 20 fps */
  1157. reg_w_riv(dev, 0x30, 0x0002, 1600);
  1158. spca504B_SetSizeType(gspca_dev);
  1159. break;
  1160. }
  1161. sp5xx_initContBrigHueRegisters(gspca_dev);
  1162. }
  1163. static void sd_stopN(struct gspca_dev *gspca_dev)
  1164. {
  1165. struct sd *sd = (struct sd *) gspca_dev;
  1166. struct usb_device *dev = gspca_dev->dev;
  1167. switch (sd->bridge) {
  1168. default:
  1169. /* case BRIDGE_SPCA533: */
  1170. /* case BRIDGE_SPCA536: */
  1171. /* case BRIDGE_SPCA504B: */
  1172. reg_w(dev, 0x31, 0, 0, NULL, 0);
  1173. spca504B_WaitCmdStatus(gspca_dev);
  1174. spca504B_PollingDataReady(gspca_dev);
  1175. break;
  1176. case BRIDGE_SPCA504:
  1177. case BRIDGE_SPCA504C:
  1178. reg_w_riv(dev, 0x00, 0x2000, 0x0000);
  1179. if (sd->subtype == AiptekMiniPenCam13) {
  1180. /* spca504a aiptek */
  1181. /* spca504A_acknowledged_command(gspca_dev, 0x08,
  1182. 6, 0, 0x86, 1); */
  1183. spca504A_acknowledged_command(gspca_dev, 0x24,
  1184. 0x00, 0x00, 0x9d, 1);
  1185. spca504A_acknowledged_command(gspca_dev, 0x01,
  1186. 0x0f, 0x00, 0xff, 1);
  1187. } else {
  1188. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  1189. reg_w_riv(dev, 0x01, 0x000f, 0x00);
  1190. }
  1191. break;
  1192. }
  1193. }
  1194. static void sd_stop0(struct gspca_dev *gspca_dev)
  1195. {
  1196. }
  1197. static void sd_close(struct gspca_dev *gspca_dev)
  1198. {
  1199. }
  1200. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  1201. struct gspca_frame *frame, /* target */
  1202. __u8 *data, /* isoc packet */
  1203. int len) /* iso packet length */
  1204. {
  1205. struct sd *sd = (struct sd *) gspca_dev;
  1206. int i, sof = 0;
  1207. unsigned char *s, *d;
  1208. static unsigned char ffd9[] = {0xff, 0xd9};
  1209. /* frames are jpeg 4.1.1 without 0xff escape */
  1210. switch (sd->bridge) {
  1211. case BRIDGE_SPCA533:
  1212. if (data[0] == 0xff) {
  1213. if (data[1] != 0x01) { /* drop packet */
  1214. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  1215. return;
  1216. }
  1217. sof = 1;
  1218. data += SPCA533_OFFSET_DATA;
  1219. len -= SPCA533_OFFSET_DATA;
  1220. } else {
  1221. data += 1;
  1222. len -= 1;
  1223. }
  1224. break;
  1225. case BRIDGE_SPCA536:
  1226. if (data[0] == 0xff) {
  1227. sof = 1;
  1228. data += SPCA536_OFFSET_DATA;
  1229. len -= SPCA536_OFFSET_DATA;
  1230. } else {
  1231. data += 2;
  1232. len -= 2;
  1233. }
  1234. break;
  1235. default:
  1236. /* case BRIDGE_SPCA504: */
  1237. /* case BRIDGE_SPCA504B: */
  1238. switch (data[0]) {
  1239. case 0xfe: /* start of frame */
  1240. sof = 1;
  1241. data += SPCA50X_OFFSET_DATA;
  1242. len -= SPCA50X_OFFSET_DATA;
  1243. break;
  1244. case 0xff: /* drop packet */
  1245. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  1246. return;
  1247. default:
  1248. data += 1;
  1249. len -= 1;
  1250. break;
  1251. }
  1252. break;
  1253. case BRIDGE_SPCA504C:
  1254. switch (data[0]) {
  1255. case 0xfe: /* start of frame */
  1256. sof = 1;
  1257. data += SPCA504_PCCAM600_OFFSET_DATA;
  1258. len -= SPCA504_PCCAM600_OFFSET_DATA;
  1259. break;
  1260. case 0xff: /* drop packet */
  1261. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  1262. return;
  1263. default:
  1264. data += 1;
  1265. len -= 1;
  1266. break;
  1267. }
  1268. break;
  1269. }
  1270. if (sof) { /* start of frame */
  1271. frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
  1272. ffd9, 2);
  1273. /* put the JPEG header in the new frame */
  1274. jpeg_put_header(gspca_dev, frame,
  1275. ((struct sd *) gspca_dev)->qindex,
  1276. 0x22);
  1277. }
  1278. /* add 0x00 after 0xff */
  1279. for (i = len; --i >= 0; )
  1280. if (data[i] == 0xff)
  1281. break;
  1282. if (i < 0) { /* no 0xff */
  1283. gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
  1284. return;
  1285. }
  1286. s = data;
  1287. d = sd->packet;
  1288. for (i = 0; i < len; i++) {
  1289. *d++ = *s++;
  1290. if (s[-1] == 0xff)
  1291. *d++ = 0x00;
  1292. }
  1293. gspca_frame_add(gspca_dev, INTER_PACKET, frame,
  1294. sd->packet, d - sd->packet);
  1295. }
  1296. static void setbrightness(struct gspca_dev *gspca_dev)
  1297. {
  1298. struct sd *sd = (struct sd *) gspca_dev;
  1299. struct usb_device *dev = gspca_dev->dev;
  1300. switch (sd->bridge) {
  1301. default:
  1302. /* case BRIDGE_SPCA533: */
  1303. /* case BRIDGE_SPCA504B: */
  1304. /* case BRIDGE_SPCA504: */
  1305. /* case BRIDGE_SPCA504C: */
  1306. reg_w_riv(dev, 0x0, 0x21a7, sd->brightness);
  1307. break;
  1308. case BRIDGE_SPCA536:
  1309. reg_w_riv(dev, 0x0, 0x20f0, sd->brightness);
  1310. break;
  1311. }
  1312. }
  1313. static void getbrightness(struct gspca_dev *gspca_dev)
  1314. {
  1315. struct sd *sd = (struct sd *) gspca_dev;
  1316. __u16 brightness = 0;
  1317. switch (sd->bridge) {
  1318. default:
  1319. /* case BRIDGE_SPCA533: */
  1320. /* case BRIDGE_SPCA504B: */
  1321. /* case BRIDGE_SPCA504: */
  1322. /* case BRIDGE_SPCA504C: */
  1323. brightness = reg_r_12(gspca_dev, 0x00, 0x21a7, 2);
  1324. break;
  1325. case BRIDGE_SPCA536:
  1326. brightness = reg_r_12(gspca_dev, 0x00, 0x20f0, 2);
  1327. break;
  1328. }
  1329. sd->brightness = ((brightness & 0xff) - 128) % 255;
  1330. }
  1331. static void setcontrast(struct gspca_dev *gspca_dev)
  1332. {
  1333. struct sd *sd = (struct sd *) gspca_dev;
  1334. struct usb_device *dev = gspca_dev->dev;
  1335. switch (sd->bridge) {
  1336. default:
  1337. /* case BRIDGE_SPCA533: */
  1338. /* case BRIDGE_SPCA504B: */
  1339. /* case BRIDGE_SPCA504: */
  1340. /* case BRIDGE_SPCA504C: */
  1341. reg_w_riv(dev, 0x0, 0x21a8, sd->contrast);
  1342. break;
  1343. case BRIDGE_SPCA536:
  1344. reg_w_riv(dev, 0x0, 0x20f1, sd->contrast);
  1345. break;
  1346. }
  1347. }
  1348. static void getcontrast(struct gspca_dev *gspca_dev)
  1349. {
  1350. struct sd *sd = (struct sd *) gspca_dev;
  1351. switch (sd->bridge) {
  1352. default:
  1353. /* case BRIDGE_SPCA533: */
  1354. /* case BRIDGE_SPCA504B: */
  1355. /* case BRIDGE_SPCA504: */
  1356. /* case BRIDGE_SPCA504C: */
  1357. sd->contrast = reg_r_12(gspca_dev, 0x00, 0x21a8, 2);
  1358. break;
  1359. case BRIDGE_SPCA536:
  1360. sd->contrast = reg_r_12(gspca_dev, 0x00, 0x20f1, 2);
  1361. break;
  1362. }
  1363. }
  1364. static void setcolors(struct gspca_dev *gspca_dev)
  1365. {
  1366. struct sd *sd = (struct sd *) gspca_dev;
  1367. struct usb_device *dev = gspca_dev->dev;
  1368. switch (sd->bridge) {
  1369. default:
  1370. /* case BRIDGE_SPCA533: */
  1371. /* case BRIDGE_SPCA504B: */
  1372. /* case BRIDGE_SPCA504: */
  1373. /* case BRIDGE_SPCA504C: */
  1374. reg_w_riv(dev, 0x0, 0x21ae, sd->colors);
  1375. break;
  1376. case BRIDGE_SPCA536:
  1377. reg_w_riv(dev, 0x0, 0x20f6, sd->colors);
  1378. break;
  1379. }
  1380. }
  1381. static void getcolors(struct gspca_dev *gspca_dev)
  1382. {
  1383. struct sd *sd = (struct sd *) gspca_dev;
  1384. switch (sd->bridge) {
  1385. default:
  1386. /* case BRIDGE_SPCA533: */
  1387. /* case BRIDGE_SPCA504B: */
  1388. /* case BRIDGE_SPCA504: */
  1389. /* case BRIDGE_SPCA504C: */
  1390. sd->colors = reg_r_12(gspca_dev, 0x00, 0x21ae, 2) >> 1;
  1391. break;
  1392. case BRIDGE_SPCA536:
  1393. sd->colors = reg_r_12(gspca_dev, 0x00, 0x20f6, 2) >> 1;
  1394. break;
  1395. }
  1396. }
  1397. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  1398. {
  1399. struct sd *sd = (struct sd *) gspca_dev;
  1400. sd->brightness = val;
  1401. if (gspca_dev->streaming)
  1402. setbrightness(gspca_dev);
  1403. return 0;
  1404. }
  1405. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  1406. {
  1407. struct sd *sd = (struct sd *) gspca_dev;
  1408. getbrightness(gspca_dev);
  1409. *val = sd->brightness;
  1410. return 0;
  1411. }
  1412. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  1413. {
  1414. struct sd *sd = (struct sd *) gspca_dev;
  1415. sd->contrast = val;
  1416. if (gspca_dev->streaming)
  1417. setcontrast(gspca_dev);
  1418. return 0;
  1419. }
  1420. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  1421. {
  1422. struct sd *sd = (struct sd *) gspca_dev;
  1423. getcontrast(gspca_dev);
  1424. *val = sd->contrast;
  1425. return 0;
  1426. }
  1427. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
  1428. {
  1429. struct sd *sd = (struct sd *) gspca_dev;
  1430. sd->colors = val;
  1431. if (gspca_dev->streaming)
  1432. setcolors(gspca_dev);
  1433. return 0;
  1434. }
  1435. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
  1436. {
  1437. struct sd *sd = (struct sd *) gspca_dev;
  1438. getcolors(gspca_dev);
  1439. *val = sd->colors;
  1440. return 0;
  1441. }
  1442. static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
  1443. {
  1444. struct sd *sd = (struct sd *) gspca_dev;
  1445. sd->autogain = val;
  1446. return 0;
  1447. }
  1448. static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
  1449. {
  1450. struct sd *sd = (struct sd *) gspca_dev;
  1451. *val = sd->autogain;
  1452. return 0;
  1453. }
  1454. /* sub-driver description */
  1455. static const struct sd_desc sd_desc = {
  1456. .name = MODULE_NAME,
  1457. .ctrls = sd_ctrls,
  1458. .nctrls = ARRAY_SIZE(sd_ctrls),
  1459. .config = sd_config,
  1460. .open = sd_open,
  1461. .start = sd_start,
  1462. .stopN = sd_stopN,
  1463. .stop0 = sd_stop0,
  1464. .close = sd_close,
  1465. .pkt_scan = sd_pkt_scan,
  1466. };
  1467. /* -- module initialisation -- */
  1468. #define DVNM(name) .driver_info = (kernel_ulong_t) name
  1469. static const __devinitdata struct usb_device_id device_table[] = {
  1470. {USB_DEVICE(0x041e, 0x400b), DVNM("Creative PC-CAM 600")},
  1471. {USB_DEVICE(0x041e, 0x4012), DVNM("PC-Cam350")},
  1472. {USB_DEVICE(0x041e, 0x4013), DVNM("Creative Pccam750")},
  1473. {USB_DEVICE(0x0458, 0x7006), DVNM("Genius Dsc 1.3 Smart")},
  1474. {USB_DEVICE(0x0461, 0x0821), DVNM("Fujifilm MV-1")},
  1475. {USB_DEVICE(0x046d, 0x0905), DVNM("Logitech ClickSmart 820")},
  1476. {USB_DEVICE(0x046d, 0x0960), DVNM("Logitech ClickSmart 420")},
  1477. {USB_DEVICE(0x0471, 0x0322), DVNM("Philips DMVC1300K")},
  1478. {USB_DEVICE(0x04a5, 0x3003), DVNM("Benq DC 1300")},
  1479. {USB_DEVICE(0x04a5, 0x3008), DVNM("Benq DC 1500")},
  1480. {USB_DEVICE(0x04a5, 0x300a), DVNM("Benq DC3410")},
  1481. {USB_DEVICE(0x04f1, 0x1001), DVNM("JVC GC A50")},
  1482. {USB_DEVICE(0x04fc, 0x500c), DVNM("Sunplus CA500C")},
  1483. {USB_DEVICE(0x04fc, 0x504a), DVNM("Aiptek Mini PenCam 1.3")},
  1484. {USB_DEVICE(0x04fc, 0x504b), DVNM("Maxell MaxPocket LE 1.3")},
  1485. {USB_DEVICE(0x04fc, 0x5330), DVNM("Digitrex 2110")},
  1486. {USB_DEVICE(0x04fc, 0x5360), DVNM("Sunplus Generic")},
  1487. {USB_DEVICE(0x04fc, 0xffff), DVNM("Pure DigitalDakota")},
  1488. {USB_DEVICE(0x052b, 0x1513), DVNM("Megapix V4")},
  1489. {USB_DEVICE(0x0546, 0x3155), DVNM("Polaroid PDC3070")},
  1490. {USB_DEVICE(0x0546, 0x3191), DVNM("Polaroid Ion 80")},
  1491. {USB_DEVICE(0x0546, 0x3273), DVNM("Polaroid PDC2030")},
  1492. {USB_DEVICE(0x055f, 0xc211), DVNM("Kowa Bs888e Microcamera")},
  1493. {USB_DEVICE(0x055f, 0xc230), DVNM("Mustek Digicam 330K")},
  1494. {USB_DEVICE(0x055f, 0xc232), DVNM("Mustek MDC3500")},
  1495. {USB_DEVICE(0x055f, 0xc360), DVNM("Mustek DV4000 Mpeg4 ")},
  1496. {USB_DEVICE(0x055f, 0xc420), DVNM("Mustek gSmart Mini 2")},
  1497. {USB_DEVICE(0x055f, 0xc430), DVNM("Mustek Gsmart LCD 2")},
  1498. {USB_DEVICE(0x055f, 0xc440), DVNM("Mustek DV 3000")},
  1499. {USB_DEVICE(0x055f, 0xc520), DVNM("Mustek gSmart Mini 3")},
  1500. {USB_DEVICE(0x055f, 0xc530), DVNM("Mustek Gsmart LCD 3")},
  1501. {USB_DEVICE(0x055f, 0xc540), DVNM("Gsmart D30")},
  1502. {USB_DEVICE(0x055f, 0xc630), DVNM("Mustek MDC4000")},
  1503. {USB_DEVICE(0x055f, 0xc650), DVNM("Mustek MDC5500Z")},
  1504. {USB_DEVICE(0x05da, 0x1018), DVNM("Digital Dream Enigma 1.3")},
  1505. {USB_DEVICE(0x06d6, 0x0031), DVNM("Trust 610 LCD PowerC@m Zoom")},
  1506. {USB_DEVICE(0x0733, 0x1311), DVNM("Digital Dream Epsilon 1.3")},
  1507. {USB_DEVICE(0x0733, 0x1314), DVNM("Mercury 2.1MEG Deluxe Classic Cam")},
  1508. {USB_DEVICE(0x0733, 0x2211), DVNM("Jenoptik jdc 21 LCD")},
  1509. {USB_DEVICE(0x0733, 0x2221), DVNM("Mercury Digital Pro 3.1p")},
  1510. {USB_DEVICE(0x0733, 0x3261), DVNM("Concord 3045 spca536a")},
  1511. {USB_DEVICE(0x0733, 0x3281), DVNM("Cyberpix S550V")},
  1512. {USB_DEVICE(0x08ca, 0x0104), DVNM("Aiptek PocketDVII 1.3")},
  1513. {USB_DEVICE(0x08ca, 0x0106), DVNM("Aiptek Pocket DV3100+")},
  1514. {USB_DEVICE(0x08ca, 0x2008), DVNM("Aiptek Mini PenCam 2 M")},
  1515. {USB_DEVICE(0x08ca, 0x2010), DVNM("Aiptek PocketCam 3M")},
  1516. {USB_DEVICE(0x08ca, 0x2016), DVNM("Aiptek PocketCam 2 Mega")},
  1517. {USB_DEVICE(0x08ca, 0x2018), DVNM("Aiptek Pencam SD 2M")},
  1518. {USB_DEVICE(0x08ca, 0x2020), DVNM("Aiptek Slim 3000F")},
  1519. {USB_DEVICE(0x08ca, 0x2022), DVNM("Aiptek Slim 3200")},
  1520. {USB_DEVICE(0x08ca, 0x2024), DVNM("Aiptek DV3500 Mpeg4 ")},
  1521. {USB_DEVICE(0x08ca, 0x2028), DVNM("Aiptek PocketCam4M")},
  1522. {USB_DEVICE(0x08ca, 0x2040), DVNM("Aiptek PocketDV4100M")},
  1523. {USB_DEVICE(0x08ca, 0x2042), DVNM("Aiptek PocketDV5100")},
  1524. {USB_DEVICE(0x08ca, 0x2060), DVNM("Aiptek PocketDV5300")},
  1525. {USB_DEVICE(0x0d64, 0x0303), DVNM("Sunplus FashionCam DXG")},
  1526. {}
  1527. };
  1528. MODULE_DEVICE_TABLE(usb, device_table);
  1529. /* -- device connect -- */
  1530. static int sd_probe(struct usb_interface *intf,
  1531. const struct usb_device_id *id)
  1532. {
  1533. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  1534. THIS_MODULE);
  1535. }
  1536. static struct usb_driver sd_driver = {
  1537. .name = MODULE_NAME,
  1538. .id_table = device_table,
  1539. .probe = sd_probe,
  1540. .disconnect = gspca_disconnect,
  1541. };
  1542. /* -- module insert / remove -- */
  1543. static int __init sd_mod_init(void)
  1544. {
  1545. if (usb_register(&sd_driver) < 0)
  1546. return -1;
  1547. PDEBUG(D_PROBE, "v%s registered", version);
  1548. return 0;
  1549. }
  1550. static void __exit sd_mod_exit(void)
  1551. {
  1552. usb_deregister(&sd_driver);
  1553. PDEBUG(D_PROBE, "deregistered");
  1554. }
  1555. module_init(sd_mod_init);
  1556. module_exit(sd_mod_exit);