t613.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. /*
  2. * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. *Notes: * t613 + tas5130A
  19. * * Focus to light do not balance well as in win.
  20. * Quality in win is not good, but its kinda better.
  21. * * Fix some "extraneous bytes", most of apps will show the image anyway
  22. * * Gamma table, is there, but its really doing something?
  23. * * 7~8 Fps, its ok, max on win its 10.
  24. * Costantino Leandro
  25. */
  26. #define MODULE_NAME "t613"
  27. #include "gspca.h"
  28. #define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 0)
  29. MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>");
  30. MODULE_DESCRIPTION("GSPCA/T613 (JPEG Compliance) USB Camera Driver");
  31. MODULE_LICENSE("GPL");
  32. struct sd {
  33. struct gspca_dev gspca_dev; /* !! must be the first item */
  34. unsigned char brightness;
  35. unsigned char contrast;
  36. unsigned char colors;
  37. unsigned char autogain;
  38. unsigned char gamma;
  39. unsigned char sharpness;
  40. unsigned char freq;
  41. unsigned char whitebalance;
  42. unsigned char mirror;
  43. unsigned char effect;
  44. __u8 sensor;
  45. #define SENSOR_TAS5130A 0
  46. #define SENSOR_OTHER 1
  47. };
  48. /* V4L2 controls supported by the driver */
  49. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
  50. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
  51. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
  52. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
  53. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
  54. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
  55. static int sd_setlowlight(struct gspca_dev *gspca_dev, __s32 val);
  56. static int sd_getlowlight(struct gspca_dev *gspca_dev, __s32 *val);
  57. static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
  58. static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
  59. static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
  60. static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
  61. static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
  62. static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
  63. static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val);
  64. static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val);
  65. static int sd_setflip(struct gspca_dev *gspca_dev, __s32 val);
  66. static int sd_getflip(struct gspca_dev *gspca_dev, __s32 *val);
  67. static int sd_seteffect(struct gspca_dev *gspca_dev, __s32 val);
  68. static int sd_geteffect(struct gspca_dev *gspca_dev, __s32 *val);
  69. static int sd_querymenu(struct gspca_dev *gspca_dev,
  70. struct v4l2_querymenu *menu);
  71. static struct ctrl sd_ctrls[] = {
  72. #define SD_BRIGHTNESS 0
  73. {
  74. {
  75. .id = V4L2_CID_BRIGHTNESS,
  76. .type = V4L2_CTRL_TYPE_INTEGER,
  77. .name = "Brightness",
  78. .minimum = 0,
  79. .maximum = 14,
  80. .step = 1,
  81. .default_value = 8,
  82. },
  83. .set = sd_setbrightness,
  84. .get = sd_getbrightness,
  85. },
  86. #define SD_CONTRAST 1
  87. {
  88. {
  89. .id = V4L2_CID_CONTRAST,
  90. .type = V4L2_CTRL_TYPE_INTEGER,
  91. .name = "Contrast",
  92. .minimum = 0,
  93. .maximum = 0x0d,
  94. .step = 1,
  95. .default_value = 0x07,
  96. },
  97. .set = sd_setcontrast,
  98. .get = sd_getcontrast,
  99. },
  100. #define SD_COLOR 2
  101. {
  102. {
  103. .id = V4L2_CID_SATURATION,
  104. .type = V4L2_CTRL_TYPE_INTEGER,
  105. .name = "Color",
  106. .minimum = 0,
  107. .maximum = 0x0f,
  108. .step = 1,
  109. .default_value = 0x05,
  110. },
  111. .set = sd_setcolors,
  112. .get = sd_getcolors,
  113. },
  114. #define GAMMA_MAX 16
  115. #define GAMMA_DEF 10
  116. {
  117. {
  118. .id = V4L2_CID_GAMMA, /* (gamma on win) */
  119. .type = V4L2_CTRL_TYPE_INTEGER,
  120. .name = "Gamma",
  121. .minimum = 0,
  122. .maximum = GAMMA_MAX - 1,
  123. .step = 1,
  124. .default_value = GAMMA_DEF,
  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 = 15,
  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 * 4 / 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 MAX_EFFECTS 7
  252. /* easily done by soft, this table could be removed,
  253. * i keep it here just in case */
  254. static const __u8 effects_table[MAX_EFFECTS][6] = {
  255. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x00}, /* Normal */
  256. {0xa8, 0xc8, 0xc6, 0x52, 0xc0, 0x04}, /* Repujar */
  257. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x20}, /* Monochrome */
  258. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x80}, /* Sepia */
  259. {0xa8, 0xc8, 0xc6, 0x52, 0xc0, 0x02}, /* Croquis */
  260. {0xa8, 0xc8, 0xc6, 0xd2, 0xc0, 0x10}, /* Sun Effect */
  261. {0xa8, 0xc8, 0xc6, 0xd2, 0xc0, 0x40}, /* Negative */
  262. };
  263. static const __u8 gamma_table[GAMMA_MAX][34] = {
  264. {0x90, 0x00, 0x91, 0x3e, 0x92, 0x69, 0x93, 0x85, /* 0 */
  265. 0x94, 0x95, 0x95, 0xa1, 0x96, 0xae, 0x97, 0xb9,
  266. 0x98, 0xc2, 0x99, 0xcb, 0x9a, 0xd4, 0x9b, 0xdb,
  267. 0x9c, 0xe3, 0x9d, 0xea, 0x9e, 0xf1, 0x9f, 0xf8,
  268. 0xa0, 0xff},
  269. {0x90, 0x00, 0x91, 0x33, 0x92, 0x5a, 0x93, 0x75, /* 1 */
  270. 0x94, 0x85, 0x95, 0x93, 0x96, 0xa1, 0x97, 0xad,
  271. 0x98, 0xb7, 0x99, 0xc2, 0x9a, 0xcb, 0x9b, 0xd4,
  272. 0x9c, 0xde, 0x9D, 0xe7, 0x9e, 0xf0, 0x9f, 0xf7,
  273. 0xa0, 0xff},
  274. {0x90, 0x00, 0x91, 0x2f, 0x92, 0x51, 0x93, 0x6b, /* 2 */
  275. 0x94, 0x7c, 0x95, 0x8a, 0x96, 0x99, 0x97, 0xa6,
  276. 0x98, 0xb1, 0x99, 0xbc, 0x9a, 0xc6, 0x9b, 0xd0,
  277. 0x9c, 0xdb, 0x9d, 0xe4, 0x9e, 0xed, 0x9f, 0xf6,
  278. 0xa0, 0xff},
  279. {0x90, 0x00, 0x91, 0x29, 0x92, 0x48, 0x93, 0x60, /* 3 */
  280. 0x94, 0x72, 0x95, 0x81, 0x96, 0x90, 0x97, 0x9e,
  281. 0x98, 0xaa, 0x99, 0xb5, 0x9a, 0xbf, 0x9b, 0xcb,
  282. 0x9c, 0xd6, 0x9d, 0xe1, 0x9e, 0xeb, 0x9f, 0xf5,
  283. 0xa0, 0xff},
  284. {0x90, 0x00, 0x91, 0x23, 0x92, 0x3f, 0x93, 0x55, /* 4 */
  285. 0x94, 0x68, 0x95, 0x77, 0x96, 0x86, 0x97, 0x95,
  286. 0x98, 0xa2, 0x99, 0xad, 0x9a, 0xb9, 0x9b, 0xc6,
  287. 0x9c, 0xd2, 0x9d, 0xde, 0x9e, 0xe9, 0x9f, 0xf4,
  288. 0xa0, 0xff},
  289. {0x90, 0x00, 0x91, 0x1b, 0x92, 0x33, 0x93, 0x48, /* 5 */
  290. 0x94, 0x59, 0x95, 0x69, 0x96, 0x79, 0x97, 0x87,
  291. 0x98, 0x96, 0x99, 0xa3, 0x9a, 0xb1, 0x9b, 0xbe,
  292. 0x9c, 0xcc, 0x9d, 0xda, 0x9e, 0xe7, 0x9f, 0xf3,
  293. 0xa0, 0xff},
  294. {0x90, 0x00, 0x91, 0x02, 0x92, 0x10, 0x93, 0x20, /* 6 */
  295. 0x94, 0x32, 0x95, 0x40, 0x96, 0x57, 0x97, 0x67,
  296. 0x98, 0x77, 0x99, 0x88, 0x9a, 0x99, 0x9b, 0xaa,
  297. 0x9c, 0xbb, 0x9d, 0xcc, 0x9e, 0xdd, 0x9f, 0xee,
  298. 0xa0, 0xff},
  299. {0x90, 0x00, 0x91, 0x02, 0x92, 0x14, 0x93, 0x26, /* 7 */
  300. 0x94, 0x38, 0x95, 0x4a, 0x96, 0x60, 0x97, 0x70,
  301. 0x98, 0x80, 0x99, 0x90, 0x9a, 0xa0, 0x9b, 0xb0,
  302. 0x9c, 0xc0, 0x9D, 0xd0, 0x9e, 0xe0, 0x9f, 0xf0,
  303. 0xa0, 0xff},
  304. {0x90, 0x00, 0x91, 0x10, 0x92, 0x22, 0x93, 0x35, /* 8 */
  305. 0x94, 0x47, 0x95, 0x5a, 0x96, 0x69, 0x97, 0x79,
  306. 0x98, 0x88, 0x99, 0x97, 0x9a, 0xa7, 0x9b, 0xb6,
  307. 0x9c, 0xc4, 0x9d, 0xd3, 0x9e, 0xe0, 0x9f, 0xf0,
  308. 0xa0, 0xff},
  309. {0x90, 0x00, 0x91, 0x10, 0x92, 0x26, 0x93, 0x40, /* 9 */
  310. 0x94, 0x54, 0x95, 0x65, 0x96, 0x75, 0x97, 0x84,
  311. 0x98, 0x93, 0x99, 0xa1, 0x9a, 0xb0, 0x9b, 0xbd,
  312. 0x9c, 0xca, 0x9d, 0xd6, 0x9e, 0xe0, 0x9f, 0xf0,
  313. 0xa0, 0xff},
  314. {0x90, 0x00, 0x91, 0x18, 0x92, 0x2b, 0x93, 0x44, /* 10 */
  315. 0x94, 0x60, 0x95, 0x70, 0x96, 0x80, 0x97, 0x8e,
  316. 0x98, 0x9c, 0x99, 0xaa, 0x9a, 0xb7, 0x9b, 0xc4,
  317. 0x9c, 0xd0, 0x9d, 0xd8, 0x9e, 0xe2, 0x9f, 0xf0,
  318. 0xa0, 0xff},
  319. {0x90, 0x00, 0x91, 0x1a, 0x92, 0x34, 0x93, 0x52, /* 11 */
  320. 0x94, 0x66, 0x95, 0x7e, 0x96, 0x8D, 0x97, 0x9B,
  321. 0x98, 0xa8, 0x99, 0xb4, 0x9a, 0xc0, 0x9b, 0xcb,
  322. 0x9c, 0xd6, 0x9d, 0xe1, 0x9e, 0xeb, 0x9f, 0xf5,
  323. 0xa0, 0xff},
  324. {0x90, 0x00, 0x91, 0x3f, 0x92, 0x5a, 0x93, 0x6e, /* 12 */
  325. 0x94, 0x7f, 0x95, 0x8e, 0x96, 0x9c, 0x97, 0xa8,
  326. 0x98, 0xb4, 0x99, 0xbf, 0x9a, 0xc9, 0x9b, 0xd3,
  327. 0x9c, 0xdc, 0x9d, 0xe5, 0x9e, 0xee, 0x9f, 0xf6,
  328. 0xa0, 0xff},
  329. {0x90, 0x00, 0x91, 0x54, 0x92, 0x6f, 0x93, 0x83, /* 13 */
  330. 0x94, 0x93, 0x95, 0xa0, 0x96, 0xad, 0x97, 0xb7,
  331. 0x98, 0xc2, 0x99, 0xcb, 0x9a, 0xd4, 0x9b, 0xdc,
  332. 0x9c, 0xe4, 0x9d, 0xeb, 0x9e, 0xf2, 0x9f, 0xf9,
  333. 0xa0, 0xff},
  334. {0x90, 0x00, 0x91, 0x6e, 0x92, 0x88, 0x93, 0x9a, /* 14 */
  335. 0x94, 0xa8, 0x95, 0xb3, 0x96, 0xbd, 0x97, 0xc6,
  336. 0x98, 0xcf, 0x99, 0xd6, 0x9a, 0xdd, 0x9b, 0xe3,
  337. 0x9c, 0xe9, 0x9d, 0xef, 0x9e, 0xf4, 0x9f, 0xfa,
  338. 0xa0, 0xff},
  339. {0x90, 0x00, 0x91, 0x93, 0x92, 0xa8, 0x93, 0xb7, /* 15 */
  340. 0x94, 0xc1, 0x95, 0xca, 0x96, 0xd2, 0x97, 0xd8,
  341. 0x98, 0xde, 0x99, 0xe3, 0x9a, 0xe8, 0x9b, 0xed,
  342. 0x9c, 0xf1, 0x9d, 0xf5, 0x9e, 0xf8, 0x9f, 0xfc,
  343. 0xa0, 0xff}
  344. };
  345. static const __u8 tas5130a_sensor_init[][8] = {
  346. {0x62, 0x08, 0x63, 0x70, 0x64, 0x1d, 0x60, 0x09},
  347. {0x62, 0x20, 0x63, 0x01, 0x64, 0x02, 0x60, 0x09},
  348. {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09},
  349. {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09},
  350. {},
  351. };
  352. /* read 1 byte */
  353. static int reg_r(struct gspca_dev *gspca_dev,
  354. __u16 index)
  355. {
  356. usb_control_msg(gspca_dev->dev,
  357. usb_rcvctrlpipe(gspca_dev->dev, 0),
  358. 0, /* request */
  359. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  360. 0, /* value */
  361. index,
  362. gspca_dev->usb_buf, 1, 500);
  363. return gspca_dev->usb_buf[0];
  364. }
  365. static void reg_w(struct gspca_dev *gspca_dev,
  366. __u16 index)
  367. {
  368. usb_control_msg(gspca_dev->dev,
  369. usb_sndctrlpipe(gspca_dev->dev, 0),
  370. 0,
  371. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  372. 0, index,
  373. NULL, 0, 500);
  374. }
  375. static void i2c_w(struct gspca_dev *gspca_dev,
  376. const __u8 *buffer, __u16 len)
  377. {
  378. if (len <= USB_BUF_SZ) {
  379. memcpy(gspca_dev->usb_buf, buffer, len);
  380. usb_control_msg(gspca_dev->dev,
  381. usb_sndctrlpipe(gspca_dev->dev, 0),
  382. 0,
  383. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  384. 0x01, 0,
  385. gspca_dev->usb_buf, len, 500);
  386. } else {
  387. __u8 *tmpbuf;
  388. tmpbuf = kmalloc(len, GFP_KERNEL);
  389. memcpy(tmpbuf, buffer, len);
  390. usb_control_msg(gspca_dev->dev,
  391. usb_sndctrlpipe(gspca_dev->dev, 0),
  392. 0,
  393. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  394. 0x01, 0,
  395. tmpbuf, len, 500);
  396. kfree(tmpbuf);
  397. }
  398. }
  399. static void other_sensor_init(struct gspca_dev *gspca_dev)
  400. {
  401. int i;
  402. const __u8 *p;
  403. __u8 byte;
  404. __u8 val[6] = {0x62, 0, 0x64, 0, 0x60, 0x05};
  405. static const __u8 sensor_init[] = {
  406. 0xdf, 0x6d,
  407. 0xdd, 0x18,
  408. 0x5a, 0xe0,
  409. 0x5c, 0x07,
  410. 0x5d, 0xb0,
  411. 0x5e, 0x1e,
  412. 0x60, 0x71,
  413. 0xef, 0x00,
  414. 0xe9, 0x00,
  415. 0xea, 0x00,
  416. 0x90, 0x24,
  417. 0x91, 0xb2,
  418. 0x82, 0x32,
  419. 0xfd, 0x00,
  420. 0xfd, 0x01,
  421. 0xfd, 0x41,
  422. 0x00 /* table end */
  423. };
  424. p = sensor_init;
  425. while (*p != 0) {
  426. val[1] = *p++;
  427. val[3] = *p++;
  428. if (*p == 0)
  429. reg_w(gspca_dev, 0x3c80);
  430. i2c_w(gspca_dev, val, sizeof val);
  431. i = 4;
  432. while (--i >= 0) {
  433. msleep(15);
  434. byte = reg_r(gspca_dev, 0x60);
  435. if (!(byte & 0x01))
  436. break;
  437. }
  438. }
  439. reg_w(gspca_dev, 0x3c80);
  440. }
  441. /* this function is called at probe time */
  442. static int sd_config(struct gspca_dev *gspca_dev,
  443. const struct usb_device_id *id)
  444. {
  445. struct sd *sd = (struct sd *) gspca_dev;
  446. struct cam *cam;
  447. cam = &gspca_dev->cam;
  448. cam->epaddr = 0x01;
  449. cam->cam_mode = vga_mode_t16;
  450. cam->nmodes = ARRAY_SIZE(vga_mode_t16);
  451. sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
  452. sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
  453. sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
  454. sd->gamma = GAMMA_DEF;
  455. sd->mirror = sd_ctrls[SD_MIRROR].qctrl.default_value;
  456. sd->freq = sd_ctrls[SD_LIGHTFREQ].qctrl.default_value;
  457. sd->whitebalance = sd_ctrls[SD_WHITE_BALANCE].qctrl.default_value;
  458. sd->sharpness = sd_ctrls[SD_SHARPNESS].qctrl.default_value;
  459. sd->effect = sd_ctrls[SD_EFFECTS].qctrl.default_value;
  460. return 0;
  461. }
  462. static void setgamma(struct gspca_dev *gspca_dev)
  463. {
  464. struct sd *sd = (struct sd *) gspca_dev;
  465. PDEBUG(D_CONF, "Gamma: %d", sd->gamma);
  466. i2c_w(gspca_dev, gamma_table[sd->gamma], sizeof gamma_table[0]);
  467. }
  468. /* this function is called at probe and resume time */
  469. static int sd_init(struct gspca_dev *gspca_dev)
  470. {
  471. /* some of this registers are not really neded, because
  472. * they are overriden by setbrigthness, setcontrast, etc,
  473. * but wont hurt anyway, and can help someone with similar webcam
  474. * to see the initial parameters.*/
  475. struct sd *sd = (struct sd *) gspca_dev;
  476. int i;
  477. __u8 byte, test_byte;
  478. static const __u8 read_indexs[] =
  479. { 0x06, 0x07, 0x0a, 0x0b, 0x66, 0x80, 0x81, 0x8e, 0x8f, 0xa5,
  480. 0xa6, 0xa8, 0xbb, 0xbc, 0xc6, 0x00, 0x00 };
  481. static const __u8 n1[] =
  482. {0x08, 0x03, 0x09, 0x03, 0x12, 0x04};
  483. static const __u8 n2[] =
  484. {0x08, 0x00};
  485. static const __u8 nset[] =
  486. { 0x61, 0x68, 0x62, 0xff, 0x60, 0x07 };
  487. static const __u8 n3[] =
  488. {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04};
  489. static const __u8 n4[] =
  490. {0x09, 0x01, 0x12, 0x04, 0x66, 0x8a, 0x80, 0x3c,
  491. 0x81, 0x22, 0x84, 0x50, 0x8a, 0x78, 0x8b, 0x68,
  492. 0x8c, 0x88, 0x8e, 0x33, 0x8f, 0x24, 0xaa, 0xb1,
  493. 0xa2, 0x60, 0xa5, 0x30, 0xa6, 0x3a, 0xa8, 0xe8,
  494. 0xae, 0x05, 0xb1, 0x00, 0xbb, 0x04, 0xbc, 0x48,
  495. 0xbe, 0x36, 0xc6, 0x88, 0xe9, 0x00, 0xc5, 0xc0,
  496. 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68,
  497. 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40,
  498. 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46};
  499. static const __u8 nset4[] = {
  500. 0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 0xe4, 0xa8,
  501. 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8,
  502. 0xe8, 0xe0
  503. };
  504. /* ojo puede ser 0xe6 en vez de 0xe9 */
  505. static const __u8 nset2[] = {
  506. 0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 0xd4, 0xbb,
  507. 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27,
  508. 0xd8, 0xc8, 0xd9, 0xfc
  509. };
  510. static const __u8 missing[] =
  511. { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 };
  512. static const __u8 nset3[] = {
  513. 0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8,
  514. 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8,
  515. 0xcf, 0xe0
  516. };
  517. static const __u8 nset5[] =
  518. { 0x8f, 0x24, 0xc3, 0x00 }; /* bright */
  519. static const __u8 nset7[4] =
  520. { 0x66, 0xca, 0xa8, 0xf8 }; /* 50/60 Hz */
  521. static const __u8 nset9[4] =
  522. { 0x0b, 0x04, 0x0a, 0x78 };
  523. static const __u8 nset8[6] =
  524. { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 };
  525. static const __u8 nset10[6] =
  526. { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 };
  527. byte = reg_r(gspca_dev, 0x06);
  528. test_byte = reg_r(gspca_dev, 0x07);
  529. if (byte == 0x08 && test_byte == 0x07) {
  530. PDEBUG(D_CONF, "other sensor");
  531. sd->sensor = SENSOR_OTHER;
  532. } else {
  533. PDEBUG(D_CONF, "sensor %02x %02x", byte, test_byte);
  534. sd->sensor = SENSOR_TAS5130A;
  535. }
  536. i2c_w(gspca_dev, n1, sizeof n1);
  537. test_byte = 0;
  538. i = 5;
  539. while (--i >= 0) {
  540. i2c_w(gspca_dev, nset, sizeof nset);
  541. msleep(5);
  542. test_byte = reg_r(gspca_dev, 0x0063);
  543. msleep(100);
  544. if (test_byte == 0x17)
  545. break; /* OK */
  546. }
  547. if (i < 0) {
  548. err("Bad sensor reset %02x", test_byte);
  549. /* return -EIO; */
  550. /*fixme: test - continue */
  551. }
  552. i2c_w(gspca_dev, n2, sizeof n2);
  553. i = 0;
  554. while (read_indexs[i] != 0x00) {
  555. test_byte = reg_r(gspca_dev, read_indexs[i]);
  556. PDEBUG(D_STREAM, "Reg 0x%02x = 0x%02x", read_indexs[i],
  557. test_byte);
  558. i++;
  559. }
  560. i2c_w(gspca_dev, n3, sizeof n3);
  561. i2c_w(gspca_dev, n4, sizeof n4);
  562. reg_r(gspca_dev, 0x0080);
  563. reg_w(gspca_dev, 0x2c80);
  564. i2c_w(gspca_dev, nset2, sizeof nset2);
  565. i2c_w(gspca_dev, nset3, sizeof nset3);
  566. i2c_w(gspca_dev, nset4, sizeof nset4);
  567. reg_w(gspca_dev, 0x3880);
  568. reg_w(gspca_dev, 0x3880);
  569. reg_w(gspca_dev, 0x338e);
  570. i2c_w(gspca_dev, nset5, sizeof nset5);
  571. reg_w(gspca_dev, 0x00a9);
  572. setgamma(gspca_dev);
  573. reg_w(gspca_dev, 0x86bb);
  574. reg_w(gspca_dev, 0x4aa6);
  575. i2c_w(gspca_dev, missing, sizeof missing);
  576. reg_w(gspca_dev, 0x2087);
  577. reg_w(gspca_dev, 0x2088);
  578. reg_w(gspca_dev, 0x2089);
  579. i2c_w(gspca_dev, nset7, sizeof nset7);
  580. i2c_w(gspca_dev, nset10, sizeof nset10);
  581. i2c_w(gspca_dev, nset8, sizeof nset8);
  582. i2c_w(gspca_dev, nset9, sizeof nset9);
  583. reg_w(gspca_dev, 0x2880);
  584. i2c_w(gspca_dev, nset2, sizeof nset2);
  585. i2c_w(gspca_dev, nset3, sizeof nset3);
  586. i2c_w(gspca_dev, nset4, sizeof nset4);
  587. return 0;
  588. }
  589. static void setbrightness(struct gspca_dev *gspca_dev)
  590. {
  591. struct sd *sd = (struct sd *) gspca_dev;
  592. unsigned int brightness;
  593. __u8 set6[4] = { 0x8f, 0x26, 0xc3, 0x00 };
  594. brightness = sd->brightness;
  595. if (brightness < 7) {
  596. set6[3] = 0x70 - brightness * 0x10;
  597. } else {
  598. set6[1] = 0x24;
  599. set6[3] = 0x00 + ((brightness - 7) * 0x10);
  600. }
  601. i2c_w(gspca_dev, set6, sizeof set6);
  602. }
  603. static void setflip(struct gspca_dev *gspca_dev)
  604. {
  605. struct sd *sd = (struct sd *) gspca_dev;
  606. __u8 flipcmd[8] =
  607. {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09};
  608. if (sd->mirror)
  609. flipcmd[3] = 0x01;
  610. i2c_w(gspca_dev, flipcmd, sizeof flipcmd);
  611. }
  612. static void seteffect(struct gspca_dev *gspca_dev)
  613. {
  614. struct sd *sd = (struct sd *) gspca_dev;
  615. i2c_w(gspca_dev, effects_table[sd->effect], sizeof effects_table[0]);
  616. if (sd->effect == 1 || sd->effect == 5) {
  617. PDEBUG(D_CONF,
  618. "This effect have been disabled for webcam \"safety\"");
  619. return;
  620. }
  621. if (sd->effect == 1 || sd->effect == 4)
  622. reg_w(gspca_dev, 0x4aa6);
  623. else
  624. reg_w(gspca_dev, 0xfaa6);
  625. }
  626. static void setwhitebalance(struct gspca_dev *gspca_dev)
  627. {
  628. struct sd *sd = (struct sd *) gspca_dev;
  629. __u8 white_balance[8] =
  630. { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 };
  631. if (sd->whitebalance == 1)
  632. white_balance[7] = 0x3c;
  633. i2c_w(gspca_dev, white_balance, sizeof white_balance);
  634. }
  635. static void setlightfreq(struct gspca_dev *gspca_dev)
  636. {
  637. struct sd *sd = (struct sd *) gspca_dev;
  638. __u8 freq[4] = { 0x66, 0x40, 0xa8, 0xe8 };
  639. if (sd->freq == 2) /* 60hz */
  640. freq[1] = 0x00;
  641. i2c_w(gspca_dev, freq, sizeof freq);
  642. }
  643. static void setcontrast(struct gspca_dev *gspca_dev)
  644. {
  645. struct sd *sd = (struct sd *) gspca_dev;
  646. unsigned int contrast = sd->contrast;
  647. __u16 reg_to_write;
  648. if (contrast < 7)
  649. reg_to_write = 0x8ea9 - (0x200 * contrast);
  650. else
  651. reg_to_write = (0x00a9 + ((contrast - 7) * 0x200));
  652. reg_w(gspca_dev, reg_to_write);
  653. }
  654. static void setcolors(struct gspca_dev *gspca_dev)
  655. {
  656. struct sd *sd = (struct sd *) gspca_dev;
  657. __u16 reg_to_write;
  658. reg_to_write = 0xc0bb + sd->colors * 0x100;
  659. reg_w(gspca_dev, reg_to_write);
  660. }
  661. static void setsharpness(struct gspca_dev *gspca_dev)
  662. {
  663. struct sd *sd = (struct sd *) gspca_dev;
  664. __u16 reg_to_write;
  665. reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness;
  666. reg_w(gspca_dev, reg_to_write);
  667. }
  668. static int sd_start(struct gspca_dev *gspca_dev)
  669. {
  670. struct sd *sd = (struct sd *) gspca_dev;
  671. int i, mode;
  672. static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 };
  673. __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 };
  674. static const __u8 t3[] =
  675. { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06,
  676. 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 };
  677. static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 };
  678. mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv;
  679. switch (mode) {
  680. case 1: /* 352x288 */
  681. t2[1] = 0x40;
  682. break;
  683. case 2: /* 320x240 */
  684. t2[1] = 0x10;
  685. break;
  686. case 3: /* 176x144 */
  687. t2[1] = 0x50;
  688. break;
  689. case 4: /* 160x120 */
  690. t2[1] = 0x20;
  691. break;
  692. default: /* 640x480 (0x00) */
  693. break;
  694. }
  695. if (sd->sensor == SENSOR_TAS5130A) {
  696. i = 0;
  697. while (tas5130a_sensor_init[i][0] != 0) {
  698. i2c_w(gspca_dev, tas5130a_sensor_init[i],
  699. sizeof tas5130a_sensor_init[0]);
  700. i++;
  701. }
  702. reg_w(gspca_dev, 0x3c80);
  703. /* just in case and to keep sync with logs (for mine) */
  704. i2c_w(gspca_dev, tas5130a_sensor_init[3],
  705. sizeof tas5130a_sensor_init[0]);
  706. reg_w(gspca_dev, 0x3c80);
  707. } else {
  708. other_sensor_init(gspca_dev);
  709. }
  710. /* just in case and to keep sync with logs (for mine) */
  711. i2c_w(gspca_dev, t1, sizeof t1);
  712. i2c_w(gspca_dev, t2, sizeof t2);
  713. reg_r(gspca_dev, 0x0012);
  714. i2c_w(gspca_dev, t3, sizeof t3);
  715. reg_w(gspca_dev, 0x0013);
  716. i2c_w(gspca_dev, t4, sizeof t4);
  717. /* restart on each start, just in case, sometimes regs goes wrong
  718. * when using controls from app */
  719. setbrightness(gspca_dev);
  720. setcontrast(gspca_dev);
  721. setcolors(gspca_dev);
  722. return 0;
  723. }
  724. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  725. struct gspca_frame *frame, /* target */
  726. __u8 *data, /* isoc packet */
  727. int len) /* iso packet length */
  728. {
  729. static __u8 ffd9[] = { 0xff, 0xd9 };
  730. if (data[0] == 0x5a) {
  731. /* Control Packet, after this came the header again,
  732. * but extra bytes came in the packet before this,
  733. * sometimes an EOF arrives, sometimes not... */
  734. return;
  735. }
  736. data += 2;
  737. len -= 2;
  738. if (data[0] == 0xff && data[1] == 0xd8) {
  739. /* extra bytes....., could be processed too but would be
  740. * a waste of time, right now leave the application and
  741. * libjpeg do it for ourserlves.. */
  742. frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
  743. ffd9, 2);
  744. gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len);
  745. return;
  746. }
  747. if (data[len - 2] == 0xff && data[len - 1] == 0xd9) {
  748. /* Just in case, i have seen packets with the marker,
  749. * other's do not include it... */
  750. len -= 2;
  751. }
  752. gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
  753. }
  754. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  755. {
  756. struct sd *sd = (struct sd *) gspca_dev;
  757. sd->brightness = val;
  758. if (gspca_dev->streaming)
  759. setbrightness(gspca_dev);
  760. return 0;
  761. }
  762. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  763. {
  764. struct sd *sd = (struct sd *) gspca_dev;
  765. *val = sd->brightness;
  766. return *val;
  767. }
  768. static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val)
  769. {
  770. struct sd *sd = (struct sd *) gspca_dev;
  771. sd->whitebalance = val;
  772. if (gspca_dev->streaming)
  773. setwhitebalance(gspca_dev);
  774. return 0;
  775. }
  776. static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val)
  777. {
  778. struct sd *sd = (struct sd *) gspca_dev;
  779. *val = sd->whitebalance;
  780. return *val;
  781. }
  782. static int sd_setflip(struct gspca_dev *gspca_dev, __s32 val)
  783. {
  784. struct sd *sd = (struct sd *) gspca_dev;
  785. sd->mirror = val;
  786. if (gspca_dev->streaming)
  787. setflip(gspca_dev);
  788. return 0;
  789. }
  790. static int sd_getflip(struct gspca_dev *gspca_dev, __s32 *val)
  791. {
  792. struct sd *sd = (struct sd *) gspca_dev;
  793. *val = sd->mirror;
  794. return *val;
  795. }
  796. static int sd_seteffect(struct gspca_dev *gspca_dev, __s32 val)
  797. {
  798. struct sd *sd = (struct sd *) gspca_dev;
  799. sd->effect = val;
  800. if (gspca_dev->streaming)
  801. seteffect(gspca_dev);
  802. return 0;
  803. }
  804. static int sd_geteffect(struct gspca_dev *gspca_dev, __s32 *val)
  805. {
  806. struct sd *sd = (struct sd *) gspca_dev;
  807. *val = sd->effect;
  808. return *val;
  809. }
  810. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  811. {
  812. struct sd *sd = (struct sd *) gspca_dev;
  813. sd->contrast = val;
  814. if (gspca_dev->streaming)
  815. setcontrast(gspca_dev);
  816. return 0;
  817. }
  818. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  819. {
  820. struct sd *sd = (struct sd *) gspca_dev;
  821. *val = sd->contrast;
  822. return *val;
  823. }
  824. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
  825. {
  826. struct sd *sd = (struct sd *) gspca_dev;
  827. sd->colors = val;
  828. if (gspca_dev->streaming)
  829. setcolors(gspca_dev);
  830. return 0;
  831. }
  832. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
  833. {
  834. struct sd *sd = (struct sd *) gspca_dev;
  835. *val = sd->colors;
  836. return 0;
  837. }
  838. static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
  839. {
  840. struct sd *sd = (struct sd *) gspca_dev;
  841. sd->gamma = val;
  842. if (gspca_dev->streaming)
  843. setgamma(gspca_dev);
  844. return 0;
  845. }
  846. static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
  847. {
  848. struct sd *sd = (struct sd *) gspca_dev;
  849. *val = sd->gamma;
  850. return 0;
  851. }
  852. static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
  853. {
  854. struct sd *sd = (struct sd *) gspca_dev;
  855. sd->freq = val;
  856. if (gspca_dev->streaming)
  857. setlightfreq(gspca_dev);
  858. return 0;
  859. }
  860. static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
  861. {
  862. struct sd *sd = (struct sd *) gspca_dev;
  863. *val = sd->freq;
  864. return 0;
  865. }
  866. static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
  867. {
  868. struct sd *sd = (struct sd *) gspca_dev;
  869. sd->sharpness = val;
  870. if (gspca_dev->streaming)
  871. setsharpness(gspca_dev);
  872. return 0;
  873. }
  874. static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
  875. {
  876. struct sd *sd = (struct sd *) gspca_dev;
  877. *val = sd->sharpness;
  878. return 0;
  879. }
  880. /* Low Light set here......*/
  881. static int sd_setlowlight(struct gspca_dev *gspca_dev, __s32 val)
  882. {
  883. struct sd *sd = (struct sd *) gspca_dev;
  884. sd->autogain = val;
  885. if (val != 0)
  886. reg_w(gspca_dev, 0xf48e);
  887. else
  888. reg_w(gspca_dev, 0xb48e);
  889. return 0;
  890. }
  891. static int sd_getlowlight(struct gspca_dev *gspca_dev, __s32 *val)
  892. {
  893. struct sd *sd = (struct sd *) gspca_dev;
  894. *val = sd->autogain;
  895. return 0;
  896. }
  897. static int sd_querymenu(struct gspca_dev *gspca_dev,
  898. struct v4l2_querymenu *menu)
  899. {
  900. switch (menu->id) {
  901. case V4L2_CID_POWER_LINE_FREQUENCY:
  902. switch (menu->index) {
  903. case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
  904. strcpy((char *) menu->name, "50 Hz");
  905. return 0;
  906. case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
  907. strcpy((char *) menu->name, "60 Hz");
  908. return 0;
  909. }
  910. break;
  911. case V4L2_CID_EFFECTS:
  912. if ((unsigned) menu->index < ARRAY_SIZE(effects_control)) {
  913. strncpy((char *) menu->name,
  914. effects_control[menu->index], 32);
  915. return 0;
  916. }
  917. break;
  918. }
  919. return -EINVAL;
  920. }
  921. /* sub-driver description */
  922. static const struct sd_desc sd_desc = {
  923. .name = MODULE_NAME,
  924. .ctrls = sd_ctrls,
  925. .nctrls = ARRAY_SIZE(sd_ctrls),
  926. .config = sd_config,
  927. .init = sd_init,
  928. .start = sd_start,
  929. .pkt_scan = sd_pkt_scan,
  930. .querymenu = sd_querymenu,
  931. };
  932. /* -- module initialisation -- */
  933. static const __devinitdata struct usb_device_id device_table[] = {
  934. {USB_DEVICE(0x17a1, 0x0128)},
  935. {}
  936. };
  937. MODULE_DEVICE_TABLE(usb, device_table);
  938. /* -- device connect -- */
  939. static int sd_probe(struct usb_interface *intf,
  940. const struct usb_device_id *id)
  941. {
  942. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  943. THIS_MODULE);
  944. }
  945. static struct usb_driver sd_driver = {
  946. .name = MODULE_NAME,
  947. .id_table = device_table,
  948. .probe = sd_probe,
  949. .disconnect = gspca_disconnect,
  950. #ifdef CONFIG_PM
  951. .suspend = gspca_suspend,
  952. .resume = gspca_resume,
  953. #endif
  954. };
  955. /* -- module insert / remove -- */
  956. static int __init sd_mod_init(void)
  957. {
  958. if (usb_register(&sd_driver) < 0)
  959. return -1;
  960. PDEBUG(D_PROBE, "registered");
  961. return 0;
  962. }
  963. static void __exit sd_mod_exit(void)
  964. {
  965. usb_deregister(&sd_driver);
  966. PDEBUG(D_PROBE, "deregistered");
  967. }
  968. module_init(sd_mod_init);
  969. module_exit(sd_mod_exit);