t613.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  1. /*
  2. *Notes: * t613 + tas5130A
  3. * * Focus to light do not balance well as in win.
  4. * Quality in win is not good, but its kinda better.
  5. * * Fix some "extraneous bytes", most of apps will show the image anyway
  6. * * Gamma table, is there, but its really doing something?
  7. * * 7~8 Fps, its ok, max on win its 10.
  8. * Costantino Leandro
  9. *
  10. * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. */
  26. #define MODULE_NAME "t613"
  27. #include "gspca.h"
  28. #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
  29. static const char version[] = "2.1.7";
  30. #define MAX_GAMMA 0x10 /* 0 to 15 */
  31. /* From LUVCVIEW */
  32. #define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 3)
  33. MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>");
  34. MODULE_DESCRIPTION("GSPCA/T613 (JPEG Compliance) USB Camera Driver");
  35. MODULE_LICENSE("GPL");
  36. struct sd {
  37. struct gspca_dev gspca_dev; /* !! must be the first item */
  38. unsigned char brightness;
  39. unsigned char contrast;
  40. unsigned char colors;
  41. unsigned char autogain;
  42. unsigned char gamma;
  43. unsigned char sharpness;
  44. unsigned char freq;
  45. unsigned char whitebalance;
  46. unsigned char mirror;
  47. unsigned char effect;
  48. };
  49. /* V4L2 controls supported by the driver */
  50. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
  51. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
  52. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
  53. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
  54. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
  55. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
  56. static int sd_setlowlight(struct gspca_dev *gspca_dev, __s32 val);
  57. static int sd_getlowlight(struct gspca_dev *gspca_dev, __s32 *val);
  58. static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
  59. static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
  60. static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
  61. static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
  62. static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
  63. static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
  64. static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val);
  65. static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val);
  66. static int sd_setflip(struct gspca_dev *gspca_dev, __s32 val);
  67. static int sd_getflip(struct gspca_dev *gspca_dev, __s32 *val);
  68. static int sd_seteffect(struct gspca_dev *gspca_dev, __s32 val);
  69. static int sd_geteffect(struct gspca_dev *gspca_dev, __s32 *val);
  70. static int sd_querymenu(struct gspca_dev *gspca_dev,
  71. struct v4l2_querymenu *menu);
  72. static struct ctrl sd_ctrls[] = {
  73. #define SD_BRIGHTNESS 0
  74. {
  75. {
  76. .id = V4L2_CID_BRIGHTNESS,
  77. .type = V4L2_CTRL_TYPE_INTEGER,
  78. .name = "Brightness",
  79. .minimum = 0,
  80. .maximum = 0x0f,
  81. .step = 1,
  82. .default_value = 0x09,
  83. },
  84. .set = sd_setbrightness,
  85. .get = sd_getbrightness,
  86. },
  87. #define SD_CONTRAST 1
  88. {
  89. {
  90. .id = V4L2_CID_CONTRAST,
  91. .type = V4L2_CTRL_TYPE_INTEGER,
  92. .name = "Contrast",
  93. .minimum = 0,
  94. .maximum = 0x0d,
  95. .step = 1,
  96. .default_value = 0x07,
  97. },
  98. .set = sd_setcontrast,
  99. .get = sd_getcontrast,
  100. },
  101. #define SD_COLOR 2
  102. {
  103. {
  104. .id = V4L2_CID_SATURATION,
  105. .type = V4L2_CTRL_TYPE_INTEGER,
  106. .name = "Color",
  107. .minimum = 0,
  108. .maximum = 0x0f,
  109. .step = 1,
  110. .default_value = 0x05,
  111. },
  112. .set = sd_setcolors,
  113. .get = sd_getcolors,
  114. },
  115. #define SD_GAMMA 3
  116. {
  117. {
  118. .id = V4L2_CID_GAMMA, /* (gamma on win) */
  119. .type = V4L2_CTRL_TYPE_INTEGER,
  120. .name = "Gamma (Untested)",
  121. .minimum = 0,
  122. .maximum = MAX_GAMMA,
  123. .step = 1,
  124. .default_value = 0x09,
  125. },
  126. .set = sd_setgamma,
  127. .get = sd_getgamma,
  128. },
  129. #define SD_AUTOGAIN 4
  130. {
  131. {
  132. .id = V4L2_CID_GAIN, /* here, i activate only the lowlight,
  133. * some apps dont bring up the
  134. * backligth_compensation control) */
  135. .type = V4L2_CTRL_TYPE_INTEGER,
  136. .name = "Low Light",
  137. .minimum = 0,
  138. .maximum = 1,
  139. .step = 1,
  140. .default_value = 0x01,
  141. },
  142. .set = sd_setlowlight,
  143. .get = sd_getlowlight,
  144. },
  145. #define SD_MIRROR 5
  146. {
  147. {
  148. .id = V4L2_CID_HFLIP,
  149. .type = V4L2_CTRL_TYPE_BOOLEAN,
  150. .name = "Mirror Image",
  151. .minimum = 0,
  152. .maximum = 1,
  153. .step = 1,
  154. .default_value = 0,
  155. },
  156. .set = sd_setflip,
  157. .get = sd_getflip
  158. },
  159. #define SD_LIGHTFREQ 6
  160. {
  161. {
  162. .id = V4L2_CID_POWER_LINE_FREQUENCY,
  163. .type = V4L2_CTRL_TYPE_MENU,
  164. .name = "Light Frequency Filter",
  165. .minimum = 1, /* 1 -> 0x50, 2->0x60 */
  166. .maximum = 2,
  167. .step = 1,
  168. .default_value = 1,
  169. },
  170. .set = sd_setfreq,
  171. .get = sd_getfreq},
  172. #define SD_WHITE_BALANCE 7
  173. {
  174. {
  175. .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE,
  176. .type = V4L2_CTRL_TYPE_INTEGER,
  177. .name = "White Balance",
  178. .minimum = 0,
  179. .maximum = 1,
  180. .step = 1,
  181. .default_value = 1,
  182. },
  183. .set = sd_setwhitebalance,
  184. .get = sd_getwhitebalance
  185. },
  186. #define SD_SHARPNESS 8 /* (aka definition on win) */
  187. {
  188. {
  189. .id = V4L2_CID_SHARPNESS,
  190. .type = V4L2_CTRL_TYPE_INTEGER,
  191. .name = "Sharpness",
  192. .minimum = 0,
  193. .maximum = MAX_GAMMA, /* 0 to 16 */
  194. .step = 1,
  195. .default_value = 0x06,
  196. },
  197. .set = sd_setsharpness,
  198. .get = sd_getsharpness,
  199. },
  200. #define SD_EFFECTS 9
  201. {
  202. {
  203. .id = V4L2_CID_EFFECTS,
  204. .type = V4L2_CTRL_TYPE_MENU,
  205. .name = "Webcam Effects",
  206. .minimum = 0,
  207. .maximum = 4,
  208. .step = 1,
  209. .default_value = 0,
  210. },
  211. .set = sd_seteffect,
  212. .get = sd_geteffect
  213. },
  214. };
  215. static char *effects_control[] = {
  216. "Normal",
  217. "Emboss", /* disabled */
  218. "Monochrome",
  219. "Sepia",
  220. "Sketch",
  221. "Sun Effect", /* disabled */
  222. "Negative",
  223. };
  224. static struct v4l2_pix_format vga_mode_t16[] = {
  225. {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  226. .bytesperline = 160,
  227. .sizeimage = 160 * 120 * 3 / 8 + 590,
  228. .colorspace = V4L2_COLORSPACE_JPEG,
  229. .priv = 4},
  230. {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  231. .bytesperline = 176,
  232. .sizeimage = 176 * 144 * 3 / 8 + 590,
  233. .colorspace = V4L2_COLORSPACE_JPEG,
  234. .priv = 3},
  235. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  236. .bytesperline = 320,
  237. .sizeimage = 320 * 240 * 3 / 8 + 590,
  238. .colorspace = V4L2_COLORSPACE_JPEG,
  239. .priv = 2},
  240. {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  241. .bytesperline = 352,
  242. .sizeimage = 352 * 288 * 3 / 8 + 590,
  243. .colorspace = V4L2_COLORSPACE_JPEG,
  244. .priv = 1},
  245. {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  246. .bytesperline = 640,
  247. .sizeimage = 640 * 480 * 3 / 8 + 590,
  248. .colorspace = V4L2_COLORSPACE_JPEG,
  249. .priv = 0},
  250. };
  251. #define T16_OFFSET_DATA 631
  252. #define MAX_EFFECTS 7
  253. /* easily done by soft, this table could be removed,
  254. * i keep it here just in case */
  255. static const __u8 effects_table[MAX_EFFECTS][6] = {
  256. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x00}, /* Normal */
  257. {0xa8, 0xc8, 0xc6, 0x52, 0xc0, 0x04}, /* Repujar */
  258. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x20}, /* Monochrome */
  259. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x80}, /* Sepia */
  260. {0xa8, 0xc8, 0xc6, 0x52, 0xc0, 0x02}, /* Croquis */
  261. {0xa8, 0xc8, 0xc6, 0xd2, 0xc0, 0x10}, /* Sun Effect */
  262. {0xa8, 0xc8, 0xc6, 0xd2, 0xc0, 0x40}, /* Negative */
  263. };
  264. static const __u8 gamma_table[MAX_GAMMA][34] = {
  265. {0x90, 0x00, 0x91, 0x3e, 0x92, 0x69, 0x93, 0x85,
  266. 0x94, 0x95, 0x95, 0xa1, 0x96, 0xae, 0x97, 0xb9,
  267. 0x98, 0xc2, 0x99, 0xcb, 0x9a, 0xd4, 0x9b, 0xdb,
  268. 0x9c, 0xe3, 0x9d, 0xea, 0x9e, 0xf1, 0x9f, 0xf8,
  269. 0xa0, 0xff},
  270. {0x90, 0x00, 0x91, 0x33, 0x92, 0x5A, 0x93, 0x75,
  271. 0x94, 0x85, 0x95, 0x93, 0x96, 0xA1, 0x97, 0xAD,
  272. 0x98, 0xB7, 0x99, 0xC2, 0x9A, 0xCB, 0x9B, 0xD4,
  273. 0x9C, 0xDE, 0x9D, 0xE7, 0x9E, 0xF0, 0x9F, 0xF7,
  274. 0xa0, 0xff},
  275. {0x90, 0x00, 0x91, 0x2F, 0x92, 0x51, 0x93, 0x6B,
  276. 0x94, 0x7C, 0x95, 0x8A, 0x96, 0x99, 0x97, 0xA6,
  277. 0x98, 0xB1, 0x99, 0xBC, 0x9A, 0xC6, 0x9B, 0xD0,
  278. 0x9C, 0xDB, 0x9D, 0xE4, 0x9E, 0xED, 0x9F, 0xF6,
  279. 0xa0, 0xff},
  280. {0x90, 0x00, 0x91, 0x29, 0x92, 0x48, 0x93, 0x60,
  281. 0x94, 0x72, 0x95, 0x81, 0x96, 0x90, 0x97, 0x9E,
  282. 0x98, 0xAA, 0x99, 0xB5, 0x9A, 0xBF, 0x9B, 0xCB,
  283. 0x9C, 0xD6, 0x9D, 0xE1, 0x9E, 0xEB, 0x9F, 0xF5,
  284. 0xa0, 0xff},
  285. {0x90, 0x00, 0x91, 0x23, 0x92, 0x3F, 0x93, 0x55,
  286. 0x94, 0x68, 0x95, 0x77, 0x96, 0x86, 0x97, 0x95,
  287. 0x98, 0xA2, 0x99, 0xAD, 0x9A, 0xB9, 0x9B, 0xC6,
  288. 0x9C, 0xD2, 0x9D, 0xDE, 0x9E, 0xE9, 0x9F, 0xF4,
  289. 0xa0, 0xff},
  290. {0x90, 0x00, 0x91, 0x1B, 0x92, 0x33, 0x93, 0x48,
  291. 0x94, 0x59, 0x95, 0x69, 0x96, 0x79, 0x97, 0x87,
  292. 0x98, 0x96, 0x99, 0xA3, 0x9A, 0xB1, 0x9B, 0xBE,
  293. 0x9C, 0xCC, 0x9D, 0xDA, 0x9E, 0xE7, 0x9F, 0xF3,
  294. 0xa0, 0xff},
  295. {0x90, 0x00, 0x91, 0x02, 0x92, 0x10, 0x93, 0x20,
  296. 0x94, 0x32, 0x95, 0x40, 0x96, 0x57, 0x97, 0x67,
  297. 0x98, 0x77, 0x99, 0x88, 0x9a, 0x99, 0x9b, 0xaa,
  298. 0x9c, 0xbb, 0x9d, 0xcc, 0x9e, 0xdd, 0x9f, 0xee,
  299. 0xa0, 0xff},
  300. {0x90, 0x00, 0x91, 0x02, 0x92, 0x14, 0x93, 0x26,
  301. 0x94, 0x38, 0x95, 0x4A, 0x96, 0x60, 0x97, 0x70,
  302. 0x98, 0x80, 0x99, 0x90, 0x9A, 0xA0, 0x9B, 0xB0,
  303. 0x9C, 0xC0, 0x9D, 0xD0, 0x9E, 0xE0, 0x9F, 0xF0,
  304. 0xa0, 0xff},
  305. {0x90, 0x00, 0x91, 0x10, 0x92, 0x22, 0x93, 0x35,
  306. 0x94, 0x47, 0x95, 0x5A, 0x96, 0x69, 0x97, 0x79,
  307. 0x98, 0x88, 0x99, 0x97, 0x9A, 0xA7, 0x9B, 0xB6,
  308. 0x9C, 0xC4, 0x9D, 0xD3, 0x9E, 0xE0, 0x9F, 0xF0,
  309. 0xa0, 0xff},
  310. {0x90, 0x00, 0x91, 0x10, 0x92, 0x26, 0x93, 0x40,
  311. 0x94, 0x54, 0x95, 0x65, 0x96, 0x75, 0x97, 0x84,
  312. 0x98, 0x93, 0x99, 0xa1, 0x9a, 0xb0, 0x9b, 0xbd,
  313. 0x9c, 0xca, 0x9d, 0xd6, 0x9e, 0xe0, 0x9f, 0xf0,
  314. 0xa0, 0xff},
  315. {0x90, 0x00, 0x91, 0x18, 0x92, 0x2B, 0x93, 0x44,
  316. 0x94, 0x60, 0x95, 0x70, 0x96, 0x80, 0x97, 0x8E,
  317. 0x98, 0x9C, 0x99, 0xAA, 0x9A, 0xB7, 0x9B, 0xC4,
  318. 0x9C, 0xD0, 0x9D, 0xD8, 0x9E, 0xE2, 0x9F, 0xF0,
  319. 0xa0, 0xff},
  320. {0x90, 0x00, 0x91, 0x1A, 0x92, 0x34, 0x93, 0x52,
  321. 0x94, 0x66, 0x95, 0x7E, 0x96, 0x8D, 0x97, 0x9B,
  322. 0x98, 0xA8, 0x99, 0xB4, 0x9A, 0xC0, 0x9B, 0xCB,
  323. 0x9C, 0xD6, 0x9D, 0xE1, 0x9E, 0xEB, 0x9F, 0xF5,
  324. 0xa0, 0xff},
  325. {0x90, 0x00, 0x91, 0x3F, 0x92, 0x5A, 0x93, 0x6E,
  326. 0x94, 0x7F, 0x95, 0x8E, 0x96, 0x9C, 0x97, 0xA8,
  327. 0x98, 0xB4, 0x99, 0xBF, 0x9A, 0xC9, 0x9B, 0xD3,
  328. 0x9C, 0xDC, 0x9D, 0xE5, 0x9E, 0xEE, 0x9F, 0xF6,
  329. 0xA0, 0xFF},
  330. {0x90, 0x00, 0x91, 0x54, 0x92, 0x6F, 0x93, 0x83,
  331. 0x94, 0x93, 0x95, 0xA0, 0x96, 0xAD, 0x97, 0xB7,
  332. 0x98, 0xC2, 0x99, 0xCB, 0x9A, 0xD4, 0x9B, 0xDC,
  333. 0x9C, 0xE4, 0x9D, 0xEB, 0x9E, 0xF2, 0x9F, 0xF9,
  334. 0xa0, 0xff},
  335. {0x90, 0x00, 0x91, 0x6E, 0x92, 0x88, 0x93, 0x9A,
  336. 0x94, 0xA8, 0x95, 0xB3, 0x96, 0xBD, 0x97, 0xC6,
  337. 0x98, 0xCF, 0x99, 0xD6, 0x9A, 0xDD, 0x9B, 0xE3,
  338. 0x9C, 0xE9, 0x9D, 0xEF, 0x9E, 0xF4, 0x9F, 0xFA,
  339. 0xa0, 0xff},
  340. {0x90, 0x00, 0x91, 0x93, 0x92, 0xA8, 0x93, 0xB7,
  341. 0x94, 0xC1, 0x95, 0xCA, 0x96, 0xD2, 0x97, 0xD8,
  342. 0x98, 0xDE, 0x99, 0xE3, 0x9A, 0xE8, 0x9B, 0xED,
  343. 0x9C, 0xF1, 0x9D, 0xF5, 0x9E, 0xF8, 0x9F, 0xFC,
  344. 0xA0, 0xFF}
  345. };
  346. static const __u8 tas5130a_sensor_init[][8] = {
  347. {0x62, 0x08, 0x63, 0x70, 0x64, 0x1d, 0x60, 0x09},
  348. {0x62, 0x20, 0x63, 0x01, 0x64, 0x02, 0x60, 0x09},
  349. {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09},
  350. {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09},
  351. {},
  352. };
  353. /* read 1 byte */
  354. static int reg_r_1(struct gspca_dev *gspca_dev,
  355. __u16 index)
  356. {
  357. usb_control_msg(gspca_dev->dev,
  358. usb_rcvctrlpipe(gspca_dev->dev, 0),
  359. 0, /* request */
  360. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  361. 0, /* value */
  362. index,
  363. gspca_dev->usb_buf, 1, 500);
  364. return gspca_dev->usb_buf[0];
  365. }
  366. static void reg_w(struct gspca_dev *gspca_dev,
  367. __u16 value,
  368. __u16 index,
  369. const __u8 *buffer, __u16 len)
  370. {
  371. if (buffer == NULL) {
  372. usb_control_msg(gspca_dev->dev,
  373. usb_sndctrlpipe(gspca_dev->dev, 0),
  374. 0,
  375. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  376. value, index,
  377. NULL, 0, 500);
  378. return;
  379. }
  380. if (len <= sizeof gspca_dev->usb_buf) {
  381. memcpy(gspca_dev->usb_buf, buffer, len);
  382. usb_control_msg(gspca_dev->dev,
  383. usb_sndctrlpipe(gspca_dev->dev, 0),
  384. 0,
  385. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  386. value, index,
  387. gspca_dev->usb_buf, len, 500);
  388. } else {
  389. __u8 *tmpbuf;
  390. tmpbuf = kmalloc(len, GFP_KERNEL);
  391. memcpy(tmpbuf, buffer, len);
  392. usb_control_msg(gspca_dev->dev,
  393. usb_sndctrlpipe(gspca_dev->dev, 0),
  394. 0,
  395. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  396. value, index,
  397. tmpbuf, len, 500);
  398. kfree(tmpbuf);
  399. }
  400. }
  401. /* this function is called at probe time */
  402. static int sd_config(struct gspca_dev *gspca_dev,
  403. const struct usb_device_id *id)
  404. {
  405. struct sd *sd = (struct sd *) gspca_dev;
  406. struct cam *cam;
  407. cam = &gspca_dev->cam;
  408. cam->dev_name = (char *) id->driver_info;
  409. cam->epaddr = 0x01;
  410. cam->cam_mode = vga_mode_t16;
  411. cam->nmodes = ARRAY_SIZE(vga_mode_t16);
  412. sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
  413. sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
  414. sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
  415. sd->gamma = sd_ctrls[SD_GAMMA].qctrl.default_value;
  416. sd->mirror = sd_ctrls[SD_MIRROR].qctrl.default_value;
  417. sd->freq = sd_ctrls[SD_LIGHTFREQ].qctrl.default_value;
  418. sd->whitebalance = sd_ctrls[SD_WHITE_BALANCE].qctrl.default_value;
  419. sd->sharpness = sd_ctrls[SD_SHARPNESS].qctrl.default_value;
  420. sd->effect = sd_ctrls[SD_EFFECTS].qctrl.default_value;
  421. return 0;
  422. }
  423. static int init_default_parameters(struct gspca_dev *gspca_dev)
  424. {
  425. /* some of this registers are not really neded, because
  426. * they are overriden by setbrigthness, setcontrast, etc,
  427. * but wont hurt anyway, and can help someone with similar webcam
  428. * to see the initial parameters.*/
  429. int i = 0;
  430. __u8 test_byte;
  431. static const __u8 read_indexs[] =
  432. { 0x06, 0x07, 0x0a, 0x0b, 0x66, 0x80, 0x81, 0x8e, 0x8f, 0xa5,
  433. 0xa6, 0xa8, 0xbb, 0xbc, 0xc6, 0x00, 0x00 };
  434. static const __u8 n1[6] =
  435. {0x08, 0x03, 0x09, 0x03, 0x12, 0x04};
  436. static const __u8 n2[2] =
  437. {0x08, 0x00};
  438. static const __u8 nset[6] =
  439. { 0x61, 0x68, 0x62, 0xff, 0x60, 0x07 };
  440. static const __u8 n3[6] =
  441. {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04};
  442. static const __u8 n4[0x46] =
  443. {0x09, 0x01, 0x12, 0x04, 0x66, 0x8a, 0x80, 0x3c,
  444. 0x81, 0x22, 0x84, 0x50, 0x8a, 0x78, 0x8b, 0x68,
  445. 0x8c, 0x88, 0x8e, 0x33, 0x8f, 0x24, 0xaa, 0xb1,
  446. 0xa2, 0x60, 0xa5, 0x30, 0xa6, 0x3a, 0xa8, 0xe8,
  447. 0xae, 0x05, 0xb1, 0x00, 0xbb, 0x04, 0xbc, 0x48,
  448. 0xbe, 0x36, 0xc6, 0x88, 0xe9, 0x00, 0xc5, 0xc0,
  449. 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68,
  450. 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40,
  451. 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46};
  452. static const __u8 nset4[18] = {
  453. 0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 0xe4, 0xa8,
  454. 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8,
  455. 0xe8, 0xe0
  456. };
  457. /* ojo puede ser 0xe6 en vez de 0xe9 */
  458. static const __u8 nset2[20] = {
  459. 0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 0xd4, 0xbb,
  460. 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27,
  461. 0xd8, 0xc8, 0xd9, 0xfc
  462. };
  463. static const __u8 missing[8] =
  464. { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 };
  465. static const __u8 nset3[18] = {
  466. 0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8,
  467. 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8,
  468. 0xcf, 0xe0
  469. };
  470. static const __u8 nset5[4] =
  471. { 0x8f, 0x24, 0xc3, 0x00 }; /* bright */
  472. static const __u8 nset6[34] = {
  473. 0x90, 0x00, 0x91, 0x1c, 0x92, 0x30, 0x93, 0x43, 0x94, 0x54,
  474. 0x95, 0x65, 0x96, 0x75, 0x97, 0x84,
  475. 0x98, 0x93, 0x99, 0xa1, 0x9a, 0xb0, 0x9b, 0xbd, 0x9c, 0xca,
  476. 0x9d, 0xd8, 0x9e, 0xe5, 0x9f, 0xf2,
  477. 0xa0, 0xff
  478. }; /* Gamma */
  479. static const __u8 nset7[4] =
  480. { 0x66, 0xca, 0xa8, 0xf8 }; /* 50/60 Hz */
  481. static const __u8 nset9[4] =
  482. { 0x0b, 0x04, 0x0a, 0x78 };
  483. static const __u8 nset8[6] =
  484. { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 };
  485. static const __u8 nset10[6] =
  486. { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 };
  487. reg_w(gspca_dev, 0x01, 0x0000, n1, 0x06);
  488. reg_w(gspca_dev, 0x01, 0x0000, nset, 0x06);
  489. reg_r_1(gspca_dev, 0x0063);
  490. reg_w(gspca_dev, 0x01, 0x0000, n2, 0x02);
  491. while (read_indexs[i] != 0x00) {
  492. test_byte = reg_r_1(gspca_dev, read_indexs[i]);
  493. PDEBUG(D_CONF, "Reg 0x%02x => 0x%02x", read_indexs[i],
  494. test_byte);
  495. i++;
  496. }
  497. reg_w(gspca_dev, 0x01, 0x0000, n3, 0x06);
  498. reg_w(gspca_dev, 0x01, 0x0000, n4, 0x46);
  499. reg_r_1(gspca_dev, 0x0080);
  500. reg_w(gspca_dev, 0x00, 0x2c80, NULL, 0);
  501. reg_w(gspca_dev, 0x01, 0x0000, nset2, 0x14);
  502. reg_w(gspca_dev, 0x01, 0x0000, nset3, 0x12);
  503. reg_w(gspca_dev, 0x01, 0x0000, nset4, 0x12);
  504. reg_w(gspca_dev, 0x00, 0x3880, NULL, 0);
  505. reg_w(gspca_dev, 0x00, 0x3880, NULL, 0);
  506. reg_w(gspca_dev, 0x00, 0x338e, NULL, 0);
  507. reg_w(gspca_dev, 0x01, 0x0000, nset5, 0x04);
  508. reg_w(gspca_dev, 0x00, 0x00a9, NULL, 0);
  509. reg_w(gspca_dev, 0x01, 0x0000, nset6, 0x22);
  510. reg_w(gspca_dev, 0x00, 0x86bb, NULL, 0);
  511. reg_w(gspca_dev, 0x00, 0x4aa6, NULL, 0);
  512. reg_w(gspca_dev, 0x01, 0x0000, missing, 0x08);
  513. reg_w(gspca_dev, 0x00, 0x2087, NULL, 0);
  514. reg_w(gspca_dev, 0x00, 0x2088, NULL, 0);
  515. reg_w(gspca_dev, 0x00, 0x2089, NULL, 0);
  516. reg_w(gspca_dev, 0x01, 0x0000, nset7, 0x04);
  517. reg_w(gspca_dev, 0x01, 0x0000, nset10, 0x06);
  518. reg_w(gspca_dev, 0x01, 0x0000, nset8, 0x06);
  519. reg_w(gspca_dev, 0x01, 0x0000, nset9, 0x04);
  520. reg_w(gspca_dev, 0x00, 0x2880, NULL, 0);
  521. reg_w(gspca_dev, 0x01, 0x0000, nset2, 0x14);
  522. reg_w(gspca_dev, 0x01, 0x0000, nset3, 0x12);
  523. reg_w(gspca_dev, 0x01, 0x0000, nset4, 0x12);
  524. return 0;
  525. }
  526. static void setbrightness(struct gspca_dev *gspca_dev)
  527. {
  528. struct sd *sd = (struct sd *) gspca_dev;
  529. unsigned int brightness;
  530. __u8 set6[4] = { 0x8f, 0x26, 0xc3, 0x80 };
  531. brightness = sd->brightness;
  532. if (brightness < 7) {
  533. set6[3] = 0x70 - (brightness * 0xa);
  534. } else {
  535. set6[1] = 0x24;
  536. set6[3] = 0x00 + ((brightness - 7) * 0xa);
  537. }
  538. reg_w(gspca_dev, 0x01, 0x0000, set6, 4);
  539. }
  540. static void setflip(struct gspca_dev *gspca_dev)
  541. {
  542. struct sd *sd = (struct sd *) gspca_dev;
  543. __u8 flipcmd[8] =
  544. { 0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09 };
  545. if (sd->mirror == 1)
  546. flipcmd[3] = 0x01;
  547. reg_w(gspca_dev, 0x01, 0x0000, flipcmd, 8);
  548. }
  549. static void seteffect(struct gspca_dev *gspca_dev)
  550. {
  551. struct sd *sd = (struct sd *) gspca_dev;
  552. reg_w(gspca_dev, 0x01, 0x0000, effects_table[sd->effect], 0x06);
  553. if (sd->effect == 1 || sd->effect == 5) {
  554. PDEBUG(D_CONF,
  555. "This effect have been disabled for webcam \"safety\"");
  556. return;
  557. }
  558. if (sd->effect == 1 || sd->effect == 4)
  559. reg_w(gspca_dev, 0x00, 0x4aa6, NULL, 0);
  560. else
  561. reg_w(gspca_dev, 0x00, 0xfaa6, NULL, 0);
  562. }
  563. static void setwhitebalance(struct gspca_dev *gspca_dev)
  564. {
  565. struct sd *sd = (struct sd *) gspca_dev;
  566. __u8 white_balance[8] =
  567. { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 };
  568. if (sd->whitebalance == 1)
  569. white_balance[7] = 0x3c;
  570. reg_w(gspca_dev, 0x01, 0x0000, white_balance, 8);
  571. }
  572. static void setlightfreq(struct gspca_dev *gspca_dev)
  573. {
  574. struct sd *sd = (struct sd *) gspca_dev;
  575. __u8 freq[4] = { 0x66, 0x40, 0xa8, 0xe8 };
  576. if (sd->freq == 2) /* 60hz */
  577. freq[1] = 0x00;
  578. reg_w(gspca_dev, 0x1, 0x0000, freq, 0x4);
  579. }
  580. static void setcontrast(struct gspca_dev *gspca_dev)
  581. {
  582. struct sd *sd = (struct sd *) gspca_dev;
  583. unsigned int contrast = sd->contrast;
  584. __u16 reg_to_write = 0x00;
  585. if (contrast < 7)
  586. reg_to_write = 0x8ea9 - (0x200 * contrast);
  587. else
  588. reg_to_write = (0x00a9 + ((contrast - 7) * 0x200));
  589. reg_w(gspca_dev, 0x00, reg_to_write, NULL, 0);
  590. }
  591. static void setcolors(struct gspca_dev *gspca_dev)
  592. {
  593. struct sd *sd = (struct sd *) gspca_dev;
  594. __u16 reg_to_write;
  595. reg_to_write = 0xc0bb + sd->colors * 0x100;
  596. reg_w(gspca_dev, 0x00, reg_to_write, NULL, 0);
  597. }
  598. static void setgamma(struct gspca_dev *gspca_dev)
  599. {
  600. }
  601. static void setsharpness(struct gspca_dev *gspca_dev)
  602. {
  603. struct sd *sd = (struct sd *) gspca_dev;
  604. __u16 reg_to_write;
  605. reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness;
  606. reg_w(gspca_dev, 0x00, reg_to_write, NULL, 0);
  607. }
  608. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  609. {
  610. struct sd *sd = (struct sd *) gspca_dev;
  611. sd->brightness = val;
  612. if (gspca_dev->streaming)
  613. setbrightness(gspca_dev);
  614. return 0;
  615. }
  616. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  617. {
  618. struct sd *sd = (struct sd *) gspca_dev;
  619. *val = sd->brightness;
  620. return *val;
  621. }
  622. static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val)
  623. {
  624. struct sd *sd = (struct sd *) gspca_dev;
  625. sd->whitebalance = val;
  626. if (gspca_dev->streaming)
  627. setwhitebalance(gspca_dev);
  628. return 0;
  629. }
  630. static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val)
  631. {
  632. struct sd *sd = (struct sd *) gspca_dev;
  633. *val = sd->whitebalance;
  634. return *val;
  635. }
  636. static int sd_setflip(struct gspca_dev *gspca_dev, __s32 val)
  637. {
  638. struct sd *sd = (struct sd *) gspca_dev;
  639. sd->mirror = val;
  640. if (gspca_dev->streaming)
  641. setflip(gspca_dev);
  642. return 0;
  643. }
  644. static int sd_getflip(struct gspca_dev *gspca_dev, __s32 *val)
  645. {
  646. struct sd *sd = (struct sd *) gspca_dev;
  647. *val = sd->mirror;
  648. return *val;
  649. }
  650. static int sd_seteffect(struct gspca_dev *gspca_dev, __s32 val)
  651. {
  652. struct sd *sd = (struct sd *) gspca_dev;
  653. sd->effect = val;
  654. if (gspca_dev->streaming)
  655. seteffect(gspca_dev);
  656. return 0;
  657. }
  658. static int sd_geteffect(struct gspca_dev *gspca_dev, __s32 *val)
  659. {
  660. struct sd *sd = (struct sd *) gspca_dev;
  661. *val = sd->effect;
  662. return *val;
  663. }
  664. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  665. {
  666. struct sd *sd = (struct sd *) gspca_dev;
  667. sd->contrast = val;
  668. if (gspca_dev->streaming)
  669. setcontrast(gspca_dev);
  670. return 0;
  671. }
  672. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  673. {
  674. struct sd *sd = (struct sd *) gspca_dev;
  675. *val = sd->contrast;
  676. return *val;
  677. }
  678. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
  679. {
  680. struct sd *sd = (struct sd *) gspca_dev;
  681. sd->colors = val;
  682. if (gspca_dev->streaming)
  683. setcolors(gspca_dev);
  684. return 0;
  685. }
  686. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
  687. {
  688. struct sd *sd = (struct sd *) gspca_dev;
  689. *val = sd->colors;
  690. return 0;
  691. }
  692. static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
  693. {
  694. struct sd *sd = (struct sd *) gspca_dev;
  695. sd->gamma = val;
  696. if (gspca_dev->streaming)
  697. setgamma(gspca_dev);
  698. return 0;
  699. }
  700. static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
  701. {
  702. struct sd *sd = (struct sd *) gspca_dev;
  703. *val = sd->gamma;
  704. return 0;
  705. }
  706. static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
  707. {
  708. struct sd *sd = (struct sd *) gspca_dev;
  709. sd->freq = val;
  710. if (gspca_dev->streaming)
  711. setlightfreq(gspca_dev);
  712. return 0;
  713. }
  714. static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
  715. {
  716. struct sd *sd = (struct sd *) gspca_dev;
  717. *val = sd->freq;
  718. return 0;
  719. }
  720. static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
  721. {
  722. struct sd *sd = (struct sd *) gspca_dev;
  723. sd->sharpness = val;
  724. if (gspca_dev->streaming)
  725. setsharpness(gspca_dev);
  726. return 0;
  727. }
  728. static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
  729. {
  730. struct sd *sd = (struct sd *) gspca_dev;
  731. *val = sd->sharpness;
  732. return 0;
  733. }
  734. /* Low Light set here......*/
  735. static int sd_setlowlight(struct gspca_dev *gspca_dev, __s32 val)
  736. {
  737. struct sd *sd = (struct sd *) gspca_dev;
  738. sd->autogain = val;
  739. if (val != 0)
  740. reg_w(gspca_dev, 0x00, 0xf48e, NULL, 0);
  741. else
  742. reg_w(gspca_dev, 0x00, 0xb48e, NULL, 0);
  743. return 0;
  744. }
  745. static int sd_getlowlight(struct gspca_dev *gspca_dev, __s32 *val)
  746. {
  747. struct sd *sd = (struct sd *) gspca_dev;
  748. *val = sd->autogain;
  749. return 0;
  750. }
  751. static void sd_start(struct gspca_dev *gspca_dev)
  752. {
  753. int mode;
  754. static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 };
  755. __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 };
  756. static const __u8 t3[] =
  757. { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06,
  758. 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 };
  759. static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 };
  760. mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv;
  761. switch (mode) {
  762. case 1: /* 352x288 */
  763. t2[1] = 0x40;
  764. break;
  765. case 2: /* 320x240 */
  766. t2[1] = 0x10;
  767. break;
  768. case 3: /* 176x144 */
  769. t2[1] = 0x50;
  770. break;
  771. case 4: /* 160x120 */
  772. t2[1] = 0x20;
  773. break;
  774. default: /* 640x480 (0x00) */
  775. break;
  776. }
  777. reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[0], 0x8);
  778. reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[1], 0x8);
  779. reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[2], 0x8);
  780. reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[3], 0x8);
  781. reg_w(gspca_dev, 0x00, 0x3c80, NULL, 0);
  782. /* just in case and to keep sync with logs (for mine) */
  783. reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[3], 0x8);
  784. reg_w(gspca_dev, 0x00, 0x3c80, NULL, 0);
  785. /* just in case and to keep sync with logs (for mine) */
  786. reg_w(gspca_dev, 0x01, 0x0000, t1, 4);
  787. reg_w(gspca_dev, 0x01, 0x0000, t2, 6);
  788. reg_r_1(gspca_dev, 0x0012);
  789. reg_w(gspca_dev, 0x01, 0x0000, t3, 0x10);
  790. reg_w(gspca_dev, 0x00, 0x0013, NULL, 0);
  791. reg_w(gspca_dev, 0x01, 0x0000, t4, 0x4);
  792. /* restart on each start, just in case, sometimes regs goes wrong
  793. * when using controls from app */
  794. setbrightness(gspca_dev);
  795. setcontrast(gspca_dev);
  796. setcolors(gspca_dev);
  797. }
  798. static void sd_stopN(struct gspca_dev *gspca_dev)
  799. {
  800. }
  801. static void sd_stop0(struct gspca_dev *gspca_dev)
  802. {
  803. }
  804. static void sd_close(struct gspca_dev *gspca_dev)
  805. {
  806. }
  807. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  808. struct gspca_frame *frame, /* target */
  809. __u8 *data, /* isoc packet */
  810. int len) /* iso packet length */
  811. {
  812. int sof = 0;
  813. static __u8 ffd9[] = { 0xff, 0xd9 };
  814. if (data[0] == 0x5a) {
  815. /* Control Packet, after this came the header again,
  816. * but extra bytes came in the packet before this,
  817. * sometimes an EOF arrives, sometimes not... */
  818. return;
  819. }
  820. if (data[len - 1] == 0xff && data[len] == 0xd9) {
  821. /* Just in case, i have seen packets with the marker,
  822. * other's do not include it... */
  823. data += 2;
  824. len -= 4;
  825. } else if (data[2] == 0xff && data[3] == 0xd8) {
  826. sof = 1;
  827. data += 2;
  828. len -= 2;
  829. } else {
  830. data += 2;
  831. len -= 2;
  832. }
  833. if (sof) {
  834. /* extra bytes....., could be processed too but would be
  835. * a waste of time, right now leave the application and
  836. * libjpeg do it for ourserlves.. */
  837. frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
  838. ffd9, 2);
  839. gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len);
  840. return;
  841. }
  842. gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
  843. }
  844. static int sd_querymenu(struct gspca_dev *gspca_dev,
  845. struct v4l2_querymenu *menu)
  846. {
  847. switch (menu->id) {
  848. case V4L2_CID_POWER_LINE_FREQUENCY:
  849. switch (menu->index) {
  850. case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
  851. strcpy((char *) menu->name, "50 Hz");
  852. return 0;
  853. case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
  854. strcpy((char *) menu->name, "60 Hz");
  855. return 0;
  856. }
  857. break;
  858. case V4L2_CID_EFFECTS:
  859. if ((unsigned) menu->index < ARRAY_SIZE(effects_control)) {
  860. strncpy((char *) menu->name,
  861. effects_control[menu->index], 32);
  862. return 0;
  863. }
  864. break;
  865. }
  866. return -EINVAL;
  867. }
  868. /* this function is called at open time */
  869. static int sd_open(struct gspca_dev *gspca_dev)
  870. {
  871. init_default_parameters(gspca_dev);
  872. return 0;
  873. }
  874. /* sub-driver description */
  875. static const struct sd_desc sd_desc = {
  876. .name = MODULE_NAME,
  877. .ctrls = sd_ctrls,
  878. .nctrls = ARRAY_SIZE(sd_ctrls),
  879. .config = sd_config,
  880. .open = sd_open,
  881. .start = sd_start,
  882. .stopN = sd_stopN,
  883. .stop0 = sd_stop0,
  884. .close = sd_close,
  885. .pkt_scan = sd_pkt_scan,
  886. .querymenu = sd_querymenu,
  887. };
  888. /* -- module initialisation -- */
  889. #define DVNM(name) .driver_info = (kernel_ulong_t) name
  890. static const __devinitdata struct usb_device_id device_table[] = {
  891. {USB_DEVICE(0x17a1, 0x0128), DVNM("XPX Webcam")},
  892. {}
  893. };
  894. MODULE_DEVICE_TABLE(usb, device_table);
  895. /* -- device connect -- */
  896. static int sd_probe(struct usb_interface *intf,
  897. const struct usb_device_id *id)
  898. {
  899. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  900. THIS_MODULE);
  901. }
  902. static struct usb_driver sd_driver = {
  903. .name = MODULE_NAME,
  904. .id_table = device_table,
  905. .probe = sd_probe,
  906. .disconnect = gspca_disconnect,
  907. };
  908. /* -- module insert / remove -- */
  909. static int __init sd_mod_init(void)
  910. {
  911. if (usb_register(&sd_driver) < 0)
  912. return -1;
  913. PDEBUG(D_PROBE, "v%s registered", version);
  914. return 0;
  915. }
  916. static void __exit sd_mod_exit(void)
  917. {
  918. usb_deregister(&sd_driver);
  919. PDEBUG(D_PROBE, "deregistered");
  920. }
  921. module_init(sd_mod_init);
  922. module_exit(sd_mod_exit);