t613.c 27 KB

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