t613.c 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  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, 4)
  29. static const char version[] = "2.1.4";
  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 cam_mode vga_mode_t16[] = {
  225. {V4L2_PIX_FMT_JPEG, 160, 120, 4},
  226. {V4L2_PIX_FMT_JPEG, 176, 144, 3},
  227. {V4L2_PIX_FMT_JPEG, 320, 240, 2},
  228. {V4L2_PIX_FMT_JPEG, 352, 288, 1},
  229. {V4L2_PIX_FMT_JPEG, 640, 480, 0},
  230. };
  231. #define T16_OFFSET_DATA 631
  232. #define MAX_EFFECTS 7
  233. /* easily done by soft, this table could be removed,
  234. * i keep it here just in case */
  235. static const __u8 effects_table[MAX_EFFECTS][6] = {
  236. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x00}, /* Normal */
  237. {0xa8, 0xc8, 0xc6, 0x52, 0xc0, 0x04}, /* Repujar */
  238. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x20}, /* Monochrome */
  239. {0xa8, 0xe8, 0xc6, 0xd2, 0xc0, 0x80}, /* Sepia */
  240. {0xa8, 0xc8, 0xc6, 0x52, 0xc0, 0x02}, /* Croquis */
  241. {0xa8, 0xc8, 0xc6, 0xd2, 0xc0, 0x10}, /* Sun Effect */
  242. {0xa8, 0xc8, 0xc6, 0xd2, 0xc0, 0x40}, /* Negative */
  243. };
  244. static const __u8 gamma_table[MAX_GAMMA][34] = {
  245. {0x90, 0x00, 0x91, 0x3e, 0x92, 0x69, 0x93, 0x85,
  246. 0x94, 0x95, 0x95, 0xa1, 0x96, 0xae, 0x97, 0xb9,
  247. 0x98, 0xc2, 0x99, 0xcb, 0x9a, 0xd4, 0x9b, 0xdb,
  248. 0x9c, 0xe3, 0x9d, 0xea, 0x9e, 0xf1, 0x9f, 0xf8,
  249. 0xa0, 0xff},
  250. {0x90, 0x00, 0x91, 0x33, 0x92, 0x5A, 0x93, 0x75,
  251. 0x94, 0x85, 0x95, 0x93, 0x96, 0xA1, 0x97, 0xAD,
  252. 0x98, 0xB7, 0x99, 0xC2, 0x9A, 0xCB, 0x9B, 0xD4,
  253. 0x9C, 0xDE, 0x9D, 0xE7, 0x9E, 0xF0, 0x9F, 0xF7,
  254. 0xa0, 0xff},
  255. {0x90, 0x00, 0x91, 0x2F, 0x92, 0x51, 0x93, 0x6B,
  256. 0x94, 0x7C, 0x95, 0x8A, 0x96, 0x99, 0x97, 0xA6,
  257. 0x98, 0xB1, 0x99, 0xBC, 0x9A, 0xC6, 0x9B, 0xD0,
  258. 0x9C, 0xDB, 0x9D, 0xE4, 0x9E, 0xED, 0x9F, 0xF6,
  259. 0xa0, 0xff},
  260. {0x90, 0x00, 0x91, 0x29, 0x92, 0x48, 0x93, 0x60,
  261. 0x94, 0x72, 0x95, 0x81, 0x96, 0x90, 0x97, 0x9E,
  262. 0x98, 0xAA, 0x99, 0xB5, 0x9A, 0xBF, 0x9B, 0xCB,
  263. 0x9C, 0xD6, 0x9D, 0xE1, 0x9E, 0xEB, 0x9F, 0xF5,
  264. 0xa0, 0xff},
  265. {0x90, 0x00, 0x91, 0x23, 0x92, 0x3F, 0x93, 0x55,
  266. 0x94, 0x68, 0x95, 0x77, 0x96, 0x86, 0x97, 0x95,
  267. 0x98, 0xA2, 0x99, 0xAD, 0x9A, 0xB9, 0x9B, 0xC6,
  268. 0x9C, 0xD2, 0x9D, 0xDE, 0x9E, 0xE9, 0x9F, 0xF4,
  269. 0xa0, 0xff},
  270. {0x90, 0x00, 0x91, 0x1B, 0x92, 0x33, 0x93, 0x48,
  271. 0x94, 0x59, 0x95, 0x69, 0x96, 0x79, 0x97, 0x87,
  272. 0x98, 0x96, 0x99, 0xA3, 0x9A, 0xB1, 0x9B, 0xBE,
  273. 0x9C, 0xCC, 0x9D, 0xDA, 0x9E, 0xE7, 0x9F, 0xF3,
  274. 0xa0, 0xff},
  275. {0x90, 0x00, 0x91, 0x02, 0x92, 0x10, 0x93, 0x20,
  276. 0x94, 0x32, 0x95, 0x40, 0x96, 0x57, 0x97, 0x67,
  277. 0x98, 0x77, 0x99, 0x88, 0x9a, 0x99, 0x9b, 0xaa,
  278. 0x9c, 0xbb, 0x9d, 0xcc, 0x9e, 0xdd, 0x9f, 0xee,
  279. 0xa0, 0xff},
  280. {0x90, 0x00, 0x91, 0x02, 0x92, 0x14, 0x93, 0x26,
  281. 0x94, 0x38, 0x95, 0x4A, 0x96, 0x60, 0x97, 0x70,
  282. 0x98, 0x80, 0x99, 0x90, 0x9A, 0xA0, 0x9B, 0xB0,
  283. 0x9C, 0xC0, 0x9D, 0xD0, 0x9E, 0xE0, 0x9F, 0xF0,
  284. 0xa0, 0xff},
  285. {0x90, 0x00, 0x91, 0x10, 0x92, 0x22, 0x93, 0x35,
  286. 0x94, 0x47, 0x95, 0x5A, 0x96, 0x69, 0x97, 0x79,
  287. 0x98, 0x88, 0x99, 0x97, 0x9A, 0xA7, 0x9B, 0xB6,
  288. 0x9C, 0xC4, 0x9D, 0xD3, 0x9E, 0xE0, 0x9F, 0xF0,
  289. 0xa0, 0xff},
  290. {0x90, 0x00, 0x91, 0x10, 0x92, 0x26, 0x93, 0x40,
  291. 0x94, 0x54, 0x95, 0x65, 0x96, 0x75, 0x97, 0x84,
  292. 0x98, 0x93, 0x99, 0xa1, 0x9a, 0xb0, 0x9b, 0xbd,
  293. 0x9c, 0xca, 0x9d, 0xd6, 0x9e, 0xe0, 0x9f, 0xf0,
  294. 0xa0, 0xff},
  295. {0x90, 0x00, 0x91, 0x18, 0x92, 0x2B, 0x93, 0x44,
  296. 0x94, 0x60, 0x95, 0x70, 0x96, 0x80, 0x97, 0x8E,
  297. 0x98, 0x9C, 0x99, 0xAA, 0x9A, 0xB7, 0x9B, 0xC4,
  298. 0x9C, 0xD0, 0x9D, 0xD8, 0x9E, 0xE2, 0x9F, 0xF0,
  299. 0xa0, 0xff},
  300. {0x90, 0x00, 0x91, 0x1A, 0x92, 0x34, 0x93, 0x52,
  301. 0x94, 0x66, 0x95, 0x7E, 0x96, 0x8D, 0x97, 0x9B,
  302. 0x98, 0xA8, 0x99, 0xB4, 0x9A, 0xC0, 0x9B, 0xCB,
  303. 0x9C, 0xD6, 0x9D, 0xE1, 0x9E, 0xEB, 0x9F, 0xF5,
  304. 0xa0, 0xff},
  305. {0x90, 0x00, 0x91, 0x3F, 0x92, 0x5A, 0x93, 0x6E,
  306. 0x94, 0x7F, 0x95, 0x8E, 0x96, 0x9C, 0x97, 0xA8,
  307. 0x98, 0xB4, 0x99, 0xBF, 0x9A, 0xC9, 0x9B, 0xD3,
  308. 0x9C, 0xDC, 0x9D, 0xE5, 0x9E, 0xEE, 0x9F, 0xF6,
  309. 0xA0, 0xFF},
  310. {0x90, 0x00, 0x91, 0x54, 0x92, 0x6F, 0x93, 0x83,
  311. 0x94, 0x93, 0x95, 0xA0, 0x96, 0xAD, 0x97, 0xB7,
  312. 0x98, 0xC2, 0x99, 0xCB, 0x9A, 0xD4, 0x9B, 0xDC,
  313. 0x9C, 0xE4, 0x9D, 0xEB, 0x9E, 0xF2, 0x9F, 0xF9,
  314. 0xa0, 0xff},
  315. {0x90, 0x00, 0x91, 0x6E, 0x92, 0x88, 0x93, 0x9A,
  316. 0x94, 0xA8, 0x95, 0xB3, 0x96, 0xBD, 0x97, 0xC6,
  317. 0x98, 0xCF, 0x99, 0xD6, 0x9A, 0xDD, 0x9B, 0xE3,
  318. 0x9C, 0xE9, 0x9D, 0xEF, 0x9E, 0xF4, 0x9F, 0xFA,
  319. 0xa0, 0xff},
  320. {0x90, 0x00, 0x91, 0x93, 0x92, 0xA8, 0x93, 0xB7,
  321. 0x94, 0xC1, 0x95, 0xCA, 0x96, 0xD2, 0x97, 0xD8,
  322. 0x98, 0xDE, 0x99, 0xE3, 0x9A, 0xE8, 0x9B, 0xED,
  323. 0x9C, 0xF1, 0x9D, 0xF5, 0x9E, 0xF8, 0x9F, 0xFC,
  324. 0xA0, 0xFF}
  325. };
  326. static const __u8 tas5130a_sensor_init[][8] = {
  327. {0x62, 0x08, 0x63, 0x70, 0x64, 0x1d, 0x60, 0x09},
  328. {0x62, 0x20, 0x63, 0x01, 0x64, 0x02, 0x60, 0x09},
  329. {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09},
  330. {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09},
  331. {},
  332. };
  333. static void t16RegRead(struct usb_device *dev,
  334. __u16 index, __u8 *buffer, __u16 length)
  335. {
  336. usb_control_msg(dev,
  337. usb_rcvctrlpipe(dev, 0),
  338. 0, /* request */
  339. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  340. 0, /* value */
  341. index, buffer, length, 500);
  342. }
  343. static void t16RegWrite(struct usb_device *dev,
  344. __u16 value,
  345. __u16 index,
  346. const __u8 *buffer, __u16 len)
  347. {
  348. if (buffer == NULL) {
  349. usb_control_msg(dev,
  350. usb_sndctrlpipe(dev, 0),
  351. 0,
  352. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  353. value, index,
  354. NULL, 0, 500);
  355. return;
  356. }
  357. if (len < 16) {
  358. __u8 tmpbuf[16];
  359. memcpy(tmpbuf, buffer, len);
  360. usb_control_msg(dev,
  361. usb_sndctrlpipe(dev, 0),
  362. 0,
  363. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  364. value, index,
  365. tmpbuf, len, 500);
  366. } else {
  367. __u8 *tmpbuf;
  368. tmpbuf = kmalloc(len, GFP_KERNEL);
  369. memcpy(tmpbuf, buffer, len);
  370. usb_control_msg(dev,
  371. usb_sndctrlpipe(dev, 0),
  372. 0,
  373. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  374. value, index,
  375. tmpbuf, len, 500);
  376. kfree(tmpbuf);
  377. }
  378. }
  379. /* this function is called at probe time */
  380. static int sd_config(struct gspca_dev *gspca_dev,
  381. const struct usb_device_id *id)
  382. {
  383. struct sd *sd = (struct sd *) gspca_dev;
  384. struct cam *cam;
  385. cam = &gspca_dev->cam;
  386. cam->dev_name = (char *) id->driver_info;
  387. cam->epaddr = 0x01;
  388. cam->cam_mode = vga_mode_t16;
  389. cam->nmodes = ARRAY_SIZE(vga_mode_t16);
  390. sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
  391. sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
  392. sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
  393. sd->gamma = sd_ctrls[SD_GAMMA].qctrl.default_value;
  394. sd->mirror = sd_ctrls[SD_MIRROR].qctrl.default_value;
  395. sd->freq = sd_ctrls[SD_LIGHTFREQ].qctrl.default_value;
  396. sd->whitebalance = sd_ctrls[SD_WHITE_BALANCE].qctrl.default_value;
  397. sd->sharpness = sd_ctrls[SD_SHARPNESS].qctrl.default_value;
  398. sd->effect = sd_ctrls[SD_EFFECTS].qctrl.default_value;
  399. return 0;
  400. }
  401. static int init_default_parameters(struct gspca_dev *gspca_dev)
  402. {
  403. struct usb_device *dev = gspca_dev->dev;
  404. /* some of this registers are not really neded, because
  405. * they are overriden by setbrigthness, setcontrast, etc,
  406. * but wont hurt anyway, and can help someone with similar webcam
  407. * to see the initial parameters.*/
  408. int i = 0;
  409. __u8 test_byte;
  410. static const __u8 read_indexs[] =
  411. { 0x06, 0x07, 0x0a, 0x0b, 0x66, 0x80, 0x81, 0x8e, 0x8f, 0xa5,
  412. 0xa6, 0xa8, 0xbb, 0xbc, 0xc6, 0x00, 0x00 };
  413. static const __u8 n1[6] =
  414. {0x08, 0x03, 0x09, 0x03, 0x12, 0x04};
  415. static const __u8 n2[2] =
  416. {0x08, 0x00};
  417. static const __u8 nset[6] =
  418. { 0x61, 0x68, 0x62, 0xff, 0x60, 0x07 };
  419. static const __u8 n3[6] =
  420. {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04};
  421. static const __u8 n4[0x46] =
  422. {0x09, 0x01, 0x12, 0x04, 0x66, 0x8a, 0x80, 0x3c,
  423. 0x81, 0x22, 0x84, 0x50, 0x8a, 0x78, 0x8b, 0x68,
  424. 0x8c, 0x88, 0x8e, 0x33, 0x8f, 0x24, 0xaa, 0xb1,
  425. 0xa2, 0x60, 0xa5, 0x30, 0xa6, 0x3a, 0xa8, 0xe8,
  426. 0xae, 0x05, 0xb1, 0x00, 0xbb, 0x04, 0xbc, 0x48,
  427. 0xbe, 0x36, 0xc6, 0x88, 0xe9, 0x00, 0xc5, 0xc0,
  428. 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68,
  429. 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40,
  430. 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46};
  431. static const __u8 nset4[18] = {
  432. 0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 0xe4, 0xa8,
  433. 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8,
  434. 0xe8, 0xe0
  435. };
  436. /* ojo puede ser 0xe6 en vez de 0xe9 */
  437. static const __u8 nset2[20] = {
  438. 0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 0xd4, 0xbb,
  439. 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27,
  440. 0xd8, 0xc8, 0xd9, 0xfc
  441. };
  442. static const __u8 missing[8] =
  443. { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 };
  444. static const __u8 nset3[18] = {
  445. 0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8,
  446. 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8,
  447. 0xcf, 0xe0
  448. };
  449. static const __u8 nset5[4] =
  450. { 0x8f, 0x24, 0xc3, 0x00 }; /* bright */
  451. static const __u8 nset6[34] = {
  452. 0x90, 0x00, 0x91, 0x1c, 0x92, 0x30, 0x93, 0x43, 0x94, 0x54,
  453. 0x95, 0x65, 0x96, 0x75, 0x97, 0x84,
  454. 0x98, 0x93, 0x99, 0xa1, 0x9a, 0xb0, 0x9b, 0xbd, 0x9c, 0xca,
  455. 0x9d, 0xd8, 0x9e, 0xe5, 0x9f, 0xf2,
  456. 0xa0, 0xff
  457. }; /* Gamma */
  458. static const __u8 nset7[4] =
  459. { 0x66, 0xca, 0xa8, 0xf8 }; /* 50/60 Hz */
  460. static const __u8 nset9[4] =
  461. { 0x0b, 0x04, 0x0a, 0x78 };
  462. static const __u8 nset8[6] =
  463. { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 };
  464. static const __u8 nset10[6] =
  465. { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 };
  466. t16RegWrite(dev, 0x01, 0x0000, n1, 0x06);
  467. t16RegWrite(dev, 0x01, 0x0000, nset, 0x06);
  468. t16RegRead(dev, 0x0063, &test_byte, 1);
  469. t16RegWrite(dev, 0x01, 0x0000, n2, 0x02);
  470. while (read_indexs[i] != 0x00) {
  471. t16RegRead(dev, read_indexs[i], &test_byte, 1);
  472. PDEBUG(D_CONF, "Reg 0x%x => 0x%x", read_indexs[i],
  473. test_byte);
  474. i++;
  475. }
  476. t16RegWrite(dev, 0x01, 0x0000, n3, 0x06);
  477. t16RegWrite(dev, 0x01, 0x0000, n4, 0x46);
  478. t16RegRead(dev, 0x0080, &test_byte, 1);
  479. t16RegWrite(dev, 0x00, 0x2c80, NULL, 0x0);
  480. t16RegWrite(dev, 0x01, 0x0000, nset2, 0x14);
  481. t16RegWrite(dev, 0x01, 0x0000, nset3, 0x12);
  482. t16RegWrite(dev, 0x01, 0x0000, nset4, 0x12);
  483. t16RegWrite(dev, 0x00, 0x3880, NULL, 0x0);
  484. t16RegWrite(dev, 0x00, 0x3880, NULL, 0x0);
  485. t16RegWrite(dev, 0x00, 0x338e, NULL, 0x0);
  486. t16RegWrite(dev, 0x01, 0x0000, nset5, 0x04);
  487. t16RegWrite(dev, 0x00, 0x00a9, NULL, 0x0);
  488. t16RegWrite(dev, 0x01, 0x0000, nset6, 0x22);
  489. t16RegWrite(dev, 0x00, 0x86bb, NULL, 0x0);
  490. t16RegWrite(dev, 0x00, 0x4aa6, NULL, 0x0);
  491. t16RegWrite(dev, 0x01, 0x0000, missing, 0x08);
  492. t16RegWrite(dev, 0x00, 0x2087, NULL, 0x0);
  493. t16RegWrite(dev, 0x00, 0x2088, NULL, 0x0);
  494. t16RegWrite(dev, 0x00, 0x2089, NULL, 0x0);
  495. t16RegWrite(dev, 0x01, 0x0000, nset7, 0x04);
  496. t16RegWrite(dev, 0x01, 0x0000, nset10, 0x06);
  497. t16RegWrite(dev, 0x01, 0x0000, nset8, 0x06);
  498. t16RegWrite(dev, 0x01, 0x0000, nset9, 0x04);
  499. t16RegWrite(dev, 0x00, 0x2880, NULL, 0x00);
  500. t16RegWrite(dev, 0x01, 0x0000, nset2, 0x14);
  501. t16RegWrite(dev, 0x01, 0x0000, nset3, 0x12);
  502. t16RegWrite(dev, 0x01, 0x0000, nset4, 0x12);
  503. return 0;
  504. }
  505. static void setbrightness(struct gspca_dev *gspca_dev)
  506. {
  507. struct sd *sd = (struct sd *) gspca_dev;
  508. struct usb_device *dev = gspca_dev->dev;
  509. unsigned int brightness;
  510. __u8 set6[4] = { 0x8f, 0x26, 0xc3, 0x80 };
  511. brightness = sd->brightness;
  512. if (brightness < 7) {
  513. set6[3] = 0x70 - (brightness * 0xa);
  514. } else {
  515. set6[1] = 0x24;
  516. set6[3] = 0x00 + ((brightness - 7) * 0xa);
  517. }
  518. t16RegWrite(dev, 0x01, 0x0000, set6, 4);
  519. }
  520. static void setflip(struct gspca_dev *gspca_dev)
  521. {
  522. struct sd *sd = (struct sd *) gspca_dev;
  523. struct usb_device *dev = gspca_dev->dev;
  524. __u8 flipcmd[8] =
  525. { 0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09 };
  526. if (sd->mirror == 1)
  527. flipcmd[3] = 0x01;
  528. t16RegWrite(dev, 0x01, 0x0000, flipcmd, 8);
  529. }
  530. static void seteffect(struct gspca_dev *gspca_dev)
  531. {
  532. struct sd *sd = (struct sd *) gspca_dev;
  533. struct usb_device *dev = gspca_dev->dev;
  534. t16RegWrite(dev, 0x01, 0x0000, effects_table[sd->effect], 0x06);
  535. if (sd->effect == 1 || sd->effect == 5) {
  536. PDEBUG(D_CONF,
  537. "This effect have been disabled for webcam \"safety\"");
  538. return;
  539. }
  540. if (sd->effect == 1 || sd->effect == 4)
  541. t16RegWrite(dev, 0x00, 0x4aa6, NULL, 0x00);
  542. else
  543. t16RegWrite(dev, 0x00, 0xfaa6, NULL, 0x00);
  544. }
  545. static void setwhitebalance(struct gspca_dev *gspca_dev)
  546. {
  547. struct sd *sd = (struct sd *) gspca_dev;
  548. struct usb_device *dev = gspca_dev->dev;
  549. __u8 white_balance[8] =
  550. { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 };
  551. if (sd->whitebalance == 1)
  552. white_balance[7] = 0x3c;
  553. t16RegWrite(dev, 0x01, 0x0000, white_balance, 8);
  554. }
  555. static void setlightfreq(struct gspca_dev *gspca_dev)
  556. {
  557. struct sd *sd = (struct sd *) gspca_dev;
  558. struct usb_device *dev = gspca_dev->dev;
  559. __u8 freq[4] = { 0x66, 0x40, 0xa8, 0xe8 };
  560. if (sd->freq == 2) /* 60hz */
  561. freq[1] = 0x00;
  562. t16RegWrite(dev, 0x1, 0x0000, freq, 0x4);
  563. }
  564. static void setcontrast(struct gspca_dev *gspca_dev)
  565. {
  566. struct sd *sd = (struct sd *) gspca_dev;
  567. struct usb_device *dev = gspca_dev->dev;
  568. unsigned int contrast = sd->contrast;
  569. __u16 reg_to_write = 0x00;
  570. if (contrast < 7)
  571. reg_to_write = 0x8ea9 - (0x200 * contrast);
  572. else
  573. reg_to_write = (0x00a9 + ((contrast - 7) * 0x200));
  574. t16RegWrite(dev, 0x00, reg_to_write, NULL, 0);
  575. }
  576. static void setcolors(struct gspca_dev *gspca_dev)
  577. {
  578. struct sd *sd = (struct sd *) gspca_dev;
  579. struct usb_device *dev = gspca_dev->dev;
  580. __u16 reg_to_write;
  581. reg_to_write = 0xc0bb + sd->colors * 0x100;
  582. t16RegWrite(dev, 0x00, reg_to_write, NULL, 0);
  583. }
  584. static void setgamma(struct gspca_dev *gspca_dev)
  585. {
  586. }
  587. static void setsharpness(struct gspca_dev *gspca_dev)
  588. {
  589. struct sd *sd = (struct sd *) gspca_dev;
  590. struct usb_device *dev = gspca_dev->dev;
  591. __u16 reg_to_write;
  592. reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness;
  593. t16RegWrite(dev, 0x00, reg_to_write, NULL, 0x00);
  594. }
  595. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  596. {
  597. struct sd *sd = (struct sd *) gspca_dev;
  598. sd->brightness = val;
  599. if (gspca_dev->streaming)
  600. setbrightness(gspca_dev);
  601. return 0;
  602. }
  603. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  604. {
  605. struct sd *sd = (struct sd *) gspca_dev;
  606. *val = sd->brightness;
  607. return *val;
  608. }
  609. static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val)
  610. {
  611. struct sd *sd = (struct sd *) gspca_dev;
  612. sd->whitebalance = val;
  613. if (gspca_dev->streaming)
  614. setwhitebalance(gspca_dev);
  615. return 0;
  616. }
  617. static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val)
  618. {
  619. struct sd *sd = (struct sd *) gspca_dev;
  620. *val = sd->whitebalance;
  621. return *val;
  622. }
  623. static int sd_setflip(struct gspca_dev *gspca_dev, __s32 val)
  624. {
  625. struct sd *sd = (struct sd *) gspca_dev;
  626. sd->mirror = val;
  627. if (gspca_dev->streaming)
  628. setflip(gspca_dev);
  629. return 0;
  630. }
  631. static int sd_getflip(struct gspca_dev *gspca_dev, __s32 *val)
  632. {
  633. struct sd *sd = (struct sd *) gspca_dev;
  634. *val = sd->mirror;
  635. return *val;
  636. }
  637. static int sd_seteffect(struct gspca_dev *gspca_dev, __s32 val)
  638. {
  639. struct sd *sd = (struct sd *) gspca_dev;
  640. sd->effect = val;
  641. if (gspca_dev->streaming)
  642. seteffect(gspca_dev);
  643. return 0;
  644. }
  645. static int sd_geteffect(struct gspca_dev *gspca_dev, __s32 *val)
  646. {
  647. struct sd *sd = (struct sd *) gspca_dev;
  648. *val = sd->effect;
  649. return *val;
  650. }
  651. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  652. {
  653. struct sd *sd = (struct sd *) gspca_dev;
  654. sd->contrast = val;
  655. if (gspca_dev->streaming)
  656. setcontrast(gspca_dev);
  657. return 0;
  658. }
  659. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  660. {
  661. struct sd *sd = (struct sd *) gspca_dev;
  662. *val = sd->contrast;
  663. return *val;
  664. }
  665. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
  666. {
  667. struct sd *sd = (struct sd *) gspca_dev;
  668. sd->colors = val;
  669. if (gspca_dev->streaming)
  670. setcolors(gspca_dev);
  671. return 0;
  672. }
  673. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
  674. {
  675. struct sd *sd = (struct sd *) gspca_dev;
  676. *val = sd->colors;
  677. return 0;
  678. }
  679. static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
  680. {
  681. struct sd *sd = (struct sd *) gspca_dev;
  682. sd->gamma = val;
  683. if (gspca_dev->streaming)
  684. setgamma(gspca_dev);
  685. return 0;
  686. }
  687. static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
  688. {
  689. struct sd *sd = (struct sd *) gspca_dev;
  690. *val = sd->gamma;
  691. return 0;
  692. }
  693. static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
  694. {
  695. struct sd *sd = (struct sd *) gspca_dev;
  696. sd->freq = val;
  697. if (gspca_dev->streaming)
  698. setlightfreq(gspca_dev);
  699. return 0;
  700. }
  701. static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
  702. {
  703. struct sd *sd = (struct sd *) gspca_dev;
  704. *val = sd->freq;
  705. return 0;
  706. }
  707. static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
  708. {
  709. struct sd *sd = (struct sd *) gspca_dev;
  710. sd->sharpness = val;
  711. if (gspca_dev->streaming)
  712. setsharpness(gspca_dev);
  713. return 0;
  714. }
  715. static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
  716. {
  717. struct sd *sd = (struct sd *) gspca_dev;
  718. *val = sd->sharpness;
  719. return 0;
  720. }
  721. /* Low Light set here......*/
  722. static int sd_setlowlight(struct gspca_dev *gspca_dev, __s32 val)
  723. {
  724. struct sd *sd = (struct sd *) gspca_dev;
  725. struct usb_device *dev = gspca_dev->dev;
  726. sd->autogain = val;
  727. if (val != 0)
  728. t16RegWrite(dev, 0x00, 0xf48e, NULL, 0);
  729. else
  730. t16RegWrite(dev, 0x00, 0xb48e, NULL, 0);
  731. return 0;
  732. }
  733. static int sd_getlowlight(struct gspca_dev *gspca_dev, __s32 *val)
  734. {
  735. struct sd *sd = (struct sd *) gspca_dev;
  736. *val = sd->autogain;
  737. return 0;
  738. }
  739. static void sd_start(struct gspca_dev *gspca_dev)
  740. {
  741. struct usb_device *dev = gspca_dev->dev;
  742. int mode;
  743. __u8 test_byte;
  744. static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 };
  745. __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 };
  746. static const __u8 t3[] =
  747. { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06,
  748. 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 };
  749. static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 };
  750. mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. mode;
  751. switch (mode) {
  752. case 1: /* 352x288 */
  753. t2[1] = 0x40;
  754. break;
  755. case 2: /* 320x240 */
  756. t2[1] = 0x10;
  757. break;
  758. case 3: /* 176x144 */
  759. t2[1] = 0x50;
  760. break;
  761. case 4: /* 160x120 */
  762. t2[1] = 0x20;
  763. break;
  764. default: /* 640x480 (0x00) */
  765. break;
  766. }
  767. t16RegWrite(dev, 0x01, 0x0000, tas5130a_sensor_init[0], 0x8);
  768. t16RegWrite(dev, 0x01, 0x0000, tas5130a_sensor_init[1], 0x8);
  769. t16RegWrite(dev, 0x01, 0x0000, tas5130a_sensor_init[2], 0x8);
  770. t16RegWrite(dev, 0x01, 0x0000, tas5130a_sensor_init[3], 0x8);
  771. t16RegWrite(dev, 0x00, 0x3c80, NULL, 0x00);
  772. /* just in case and to keep sync with logs (for mine) */
  773. t16RegWrite(dev, 0x01, 0x0000, tas5130a_sensor_init[3], 0x8);
  774. t16RegWrite(dev, 0x00, 0x3c80, NULL, 0x00);
  775. /* just in case and to keep sync with logs (for mine) */
  776. t16RegWrite(dev, 0x01, 0x0000, t1, 4);
  777. t16RegWrite(dev, 0x01, 0x0000, t2, 6);
  778. t16RegRead(dev, 0x0012, &test_byte, 0x1);
  779. t16RegWrite(dev, 0x01, 0x0000, t3, 0x10);
  780. t16RegWrite(dev, 0x00, 0x0013, NULL, 0x00);
  781. t16RegWrite(dev, 0x01, 0x0000, t4, 0x4);
  782. /* restart on each start, just in case, sometimes regs goes wrong
  783. * when using controls from app */
  784. setbrightness(gspca_dev);
  785. setcontrast(gspca_dev);
  786. setcolors(gspca_dev);
  787. }
  788. static void sd_stopN(struct gspca_dev *gspca_dev)
  789. {
  790. }
  791. static void sd_stop0(struct gspca_dev *gspca_dev)
  792. {
  793. }
  794. static void sd_close(struct gspca_dev *gspca_dev)
  795. {
  796. }
  797. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  798. struct gspca_frame *frame, /* target */
  799. __u8 *data, /* isoc packet */
  800. int len) /* iso packet length */
  801. {
  802. int sof = 0;
  803. static __u8 ffd9[] = { 0xff, 0xd9 };
  804. if (data[0] == 0x5a) {
  805. /* Control Packet, after this came the header again,
  806. * but extra bytes came in the packet before this,
  807. * sometimes an EOF arrives, sometimes not... */
  808. return;
  809. }
  810. if (data[len - 1] == 0xff && data[len] == 0xd9) {
  811. /* Just in case, i have seen packets with the marker,
  812. * other's do not include it... */
  813. data += 2;
  814. len -= 4;
  815. } else if (data[2] == 0xff && data[3] == 0xd8) {
  816. sof = 1;
  817. data += 2;
  818. len -= 2;
  819. } else {
  820. data += 2;
  821. len -= 2;
  822. }
  823. if (sof) {
  824. /* extra bytes....., could be processed too but would be
  825. * a waste of time, right now leave the application and
  826. * libjpeg do it for ourserlves.. */
  827. frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
  828. ffd9, 2);
  829. gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len);
  830. return;
  831. }
  832. gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
  833. }
  834. static int sd_querymenu(struct gspca_dev *gspca_dev,
  835. struct v4l2_querymenu *menu)
  836. {
  837. switch (menu->id) {
  838. case V4L2_CID_POWER_LINE_FREQUENCY:
  839. switch (menu->index) {
  840. case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
  841. strcpy((char *) menu->name, "50 Hz");
  842. return 0;
  843. case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
  844. strcpy((char *) menu->name, "60 Hz");
  845. return 0;
  846. }
  847. break;
  848. case V4L2_CID_EFFECTS:
  849. if ((unsigned) menu->index < ARRAY_SIZE(effects_control)) {
  850. strncpy((char *) menu->name,
  851. effects_control[menu->index], 32);
  852. return 0;
  853. }
  854. break;
  855. }
  856. return -EINVAL;
  857. }
  858. /* this function is called at open time */
  859. static int sd_open(struct gspca_dev *gspca_dev)
  860. {
  861. init_default_parameters(gspca_dev);
  862. return 0;
  863. }
  864. /* sub-driver description */
  865. static const struct sd_desc sd_desc = {
  866. .name = MODULE_NAME,
  867. .ctrls = sd_ctrls,
  868. .nctrls = ARRAY_SIZE(sd_ctrls),
  869. .config = sd_config,
  870. .open = sd_open,
  871. .start = sd_start,
  872. .stopN = sd_stopN,
  873. .stop0 = sd_stop0,
  874. .close = sd_close,
  875. .pkt_scan = sd_pkt_scan,
  876. .querymenu = sd_querymenu,
  877. };
  878. /* -- module initialisation -- */
  879. #define DVNM(name) .driver_info = (kernel_ulong_t) name
  880. static const __devinitdata struct usb_device_id device_table[] = {
  881. {USB_DEVICE(0x17a1, 0x0128), DVNM("XPX Webcam")},
  882. {}
  883. };
  884. MODULE_DEVICE_TABLE(usb, device_table);
  885. /* -- device connect -- */
  886. static int sd_probe(struct usb_interface *intf,
  887. const struct usb_device_id *id)
  888. {
  889. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  890. THIS_MODULE);
  891. }
  892. static struct usb_driver sd_driver = {
  893. .name = MODULE_NAME,
  894. .id_table = device_table,
  895. .probe = sd_probe,
  896. .disconnect = gspca_disconnect,
  897. };
  898. /* -- module insert / remove -- */
  899. static int __init sd_mod_init(void)
  900. {
  901. if (usb_register(&sd_driver) < 0)
  902. return -1;
  903. PDEBUG(D_PROBE, "v%s registered", version);
  904. return 0;
  905. }
  906. static void __exit sd_mod_exit(void)
  907. {
  908. usb_deregister(&sd_driver);
  909. PDEBUG(D_PROBE, "deregistered");
  910. }
  911. module_init(sd_mod_init);
  912. module_exit(sd_mod_exit);