dtt200u.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. /* DVB USB library compliant Linux driver for the WideView/ Yakumo/ Hama/
  2. * Typhoon/ Yuan/ Miglia DVB-T USB2.0 receiver.
  3. *
  4. * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
  5. *
  6. * Thanks to Steve Chang from WideView for providing support for the WT-220U.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the Free
  10. * Software Foundation, version 2.
  11. *
  12. * see Documentation/dvb/README.dvb-usb for more information
  13. */
  14. #include "dtt200u.h"
  15. /* debug */
  16. int dvb_usb_dtt200u_debug;
  17. module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644);
  18. MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS);
  19. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  20. static int dtt200u_power_ctrl(struct dvb_usb_device *d, int onoff)
  21. {
  22. u8 b = SET_INIT;
  23. if (onoff)
  24. dvb_usb_generic_write(d,&b,2);
  25. return 0;
  26. }
  27. static int dtt200u_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  28. {
  29. u8 b_streaming[2] = { SET_STREAMING, onoff };
  30. u8 b_rst_pid = RESET_PID_FILTER;
  31. dvb_usb_generic_write(adap->dev, b_streaming, 2);
  32. if (onoff == 0)
  33. dvb_usb_generic_write(adap->dev, &b_rst_pid, 1);
  34. return 0;
  35. }
  36. static int dtt200u_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
  37. {
  38. u8 b_pid[4];
  39. pid = onoff ? pid : 0;
  40. b_pid[0] = SET_PID_FILTER;
  41. b_pid[1] = index;
  42. b_pid[2] = pid & 0xff;
  43. b_pid[3] = (pid >> 8) & 0x1f;
  44. return dvb_usb_generic_write(adap->dev, b_pid, 4);
  45. }
  46. /* remote control */
  47. /* key list for the tiny remote control (Yakumo, don't know about the others) */
  48. static struct rc_map_table rc_map_dtt200u_table[] = {
  49. { 0x8001, KEY_MUTE },
  50. { 0x8002, KEY_CHANNELDOWN },
  51. { 0x8003, KEY_VOLUMEDOWN },
  52. { 0x8004, KEY_1 },
  53. { 0x8005, KEY_2 },
  54. { 0x8006, KEY_3 },
  55. { 0x8007, KEY_4 },
  56. { 0x8008, KEY_5 },
  57. { 0x8009, KEY_6 },
  58. { 0x800a, KEY_7 },
  59. { 0x800c, KEY_ZOOM },
  60. { 0x800d, KEY_0 },
  61. { 0x800e, KEY_SELECT },
  62. { 0x8012, KEY_POWER },
  63. { 0x801a, KEY_CHANNELUP },
  64. { 0x801b, KEY_8 },
  65. { 0x801e, KEY_VOLUMEUP },
  66. { 0x801f, KEY_9 },
  67. };
  68. static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  69. {
  70. u8 key[5],cmd = GET_RC_CODE;
  71. dvb_usb_generic_rw(d,&cmd,1,key,5,0);
  72. dvb_usb_nec_rc_key_to_event(d,key,event,state);
  73. if (key[0] != 0)
  74. deb_info("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
  75. return 0;
  76. }
  77. static int dtt200u_frontend_attach(struct dvb_usb_adapter *adap)
  78. {
  79. adap->fe = dtt200u_fe_attach(adap->dev);
  80. return 0;
  81. }
  82. static struct dvb_usb_device_properties dtt200u_properties;
  83. static struct dvb_usb_device_properties wt220u_fc_properties;
  84. static struct dvb_usb_device_properties wt220u_properties;
  85. static struct dvb_usb_device_properties wt220u_zl0353_properties;
  86. static struct dvb_usb_device_properties wt220u_miglia_properties;
  87. static int dtt200u_usb_probe(struct usb_interface *intf,
  88. const struct usb_device_id *id)
  89. {
  90. if (0 == dvb_usb_device_init(intf, &dtt200u_properties,
  91. THIS_MODULE, NULL, adapter_nr) ||
  92. 0 == dvb_usb_device_init(intf, &wt220u_properties,
  93. THIS_MODULE, NULL, adapter_nr) ||
  94. 0 == dvb_usb_device_init(intf, &wt220u_fc_properties,
  95. THIS_MODULE, NULL, adapter_nr) ||
  96. 0 == dvb_usb_device_init(intf, &wt220u_zl0353_properties,
  97. THIS_MODULE, NULL, adapter_nr) ||
  98. 0 == dvb_usb_device_init(intf, &wt220u_miglia_properties,
  99. THIS_MODULE, NULL, adapter_nr))
  100. return 0;
  101. return -ENODEV;
  102. }
  103. static struct usb_device_id dtt200u_usb_table [] = {
  104. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) },
  105. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) },
  106. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) },
  107. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) },
  108. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_COLD) },
  109. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_WARM) },
  110. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_FC_COLD) },
  111. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_FC_WARM) },
  112. { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZAP250_COLD) },
  113. { USB_DEVICE(USB_VID_MIGLIA, USB_PID_WT220U_ZAP250_COLD) },
  114. { 0 },
  115. };
  116. MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
  117. static struct dvb_usb_device_properties dtt200u_properties = {
  118. .usb_ctrl = CYPRESS_FX2,
  119. .firmware = "dvb-usb-dtt200u-01.fw",
  120. .num_adapters = 1,
  121. .adapter = {
  122. {
  123. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
  124. .pid_filter_count = 15,
  125. .streaming_ctrl = dtt200u_streaming_ctrl,
  126. .pid_filter = dtt200u_pid_filter,
  127. .frontend_attach = dtt200u_frontend_attach,
  128. /* parameter for the MPEG2-data transfer */
  129. .stream = {
  130. .type = USB_BULK,
  131. .count = 7,
  132. .endpoint = 0x02,
  133. .u = {
  134. .bulk = {
  135. .buffersize = 4096,
  136. }
  137. }
  138. },
  139. }
  140. },
  141. .power_ctrl = dtt200u_power_ctrl,
  142. .rc.legacy = {
  143. .rc_interval = 300,
  144. .rc_map_table = rc_map_dtt200u_table,
  145. .rc_map_size = ARRAY_SIZE(rc_map_dtt200u_table),
  146. .rc_query = dtt200u_rc_query,
  147. },
  148. .generic_bulk_ctrl_endpoint = 0x01,
  149. .num_device_descs = 1,
  150. .devices = {
  151. { .name = "WideView/Yuan/Yakumo/Hama/Typhoon DVB-T USB2.0 (WT-200U)",
  152. .cold_ids = { &dtt200u_usb_table[0], NULL },
  153. .warm_ids = { &dtt200u_usb_table[1], NULL },
  154. },
  155. { NULL },
  156. }
  157. };
  158. static struct dvb_usb_device_properties wt220u_properties = {
  159. .usb_ctrl = CYPRESS_FX2,
  160. .firmware = "dvb-usb-wt220u-02.fw",
  161. .num_adapters = 1,
  162. .adapter = {
  163. {
  164. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
  165. .pid_filter_count = 15,
  166. .streaming_ctrl = dtt200u_streaming_ctrl,
  167. .pid_filter = dtt200u_pid_filter,
  168. .frontend_attach = dtt200u_frontend_attach,
  169. /* parameter for the MPEG2-data transfer */
  170. .stream = {
  171. .type = USB_BULK,
  172. .count = 7,
  173. .endpoint = 0x02,
  174. .u = {
  175. .bulk = {
  176. .buffersize = 4096,
  177. }
  178. }
  179. },
  180. }
  181. },
  182. .power_ctrl = dtt200u_power_ctrl,
  183. .rc.legacy = {
  184. .rc_interval = 300,
  185. .rc_map_table = rc_map_dtt200u_table,
  186. .rc_map_size = ARRAY_SIZE(rc_map_dtt200u_table),
  187. .rc_query = dtt200u_rc_query,
  188. },
  189. .generic_bulk_ctrl_endpoint = 0x01,
  190. .num_device_descs = 1,
  191. .devices = {
  192. { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)",
  193. .cold_ids = { &dtt200u_usb_table[2], &dtt200u_usb_table[8], NULL },
  194. .warm_ids = { &dtt200u_usb_table[3], NULL },
  195. },
  196. { NULL },
  197. }
  198. };
  199. static struct dvb_usb_device_properties wt220u_fc_properties = {
  200. .usb_ctrl = CYPRESS_FX2,
  201. .firmware = "dvb-usb-wt220u-fc03.fw",
  202. .num_adapters = 1,
  203. .adapter = {
  204. {
  205. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
  206. .pid_filter_count = 15,
  207. .streaming_ctrl = dtt200u_streaming_ctrl,
  208. .pid_filter = dtt200u_pid_filter,
  209. .frontend_attach = dtt200u_frontend_attach,
  210. /* parameter for the MPEG2-data transfer */
  211. .stream = {
  212. .type = USB_BULK,
  213. .count = 7,
  214. .endpoint = 0x06,
  215. .u = {
  216. .bulk = {
  217. .buffersize = 4096,
  218. }
  219. }
  220. },
  221. }
  222. },
  223. .power_ctrl = dtt200u_power_ctrl,
  224. .rc.legacy = {
  225. .rc_interval = 300,
  226. .rc_map_table = rc_map_dtt200u_table,
  227. .rc_map_size = ARRAY_SIZE(rc_map_dtt200u_table),
  228. .rc_query = dtt200u_rc_query,
  229. },
  230. .generic_bulk_ctrl_endpoint = 0x01,
  231. .num_device_descs = 1,
  232. .devices = {
  233. { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)",
  234. .cold_ids = { &dtt200u_usb_table[6], NULL },
  235. .warm_ids = { &dtt200u_usb_table[7], NULL },
  236. },
  237. { NULL },
  238. }
  239. };
  240. static struct dvb_usb_device_properties wt220u_zl0353_properties = {
  241. .usb_ctrl = CYPRESS_FX2,
  242. .firmware = "dvb-usb-wt220u-zl0353-01.fw",
  243. .num_adapters = 1,
  244. .adapter = {
  245. {
  246. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
  247. .pid_filter_count = 15,
  248. .streaming_ctrl = dtt200u_streaming_ctrl,
  249. .pid_filter = dtt200u_pid_filter,
  250. .frontend_attach = dtt200u_frontend_attach,
  251. /* parameter for the MPEG2-data transfer */
  252. .stream = {
  253. .type = USB_BULK,
  254. .count = 7,
  255. .endpoint = 0x02,
  256. .u = {
  257. .bulk = {
  258. .buffersize = 4096,
  259. }
  260. }
  261. },
  262. }
  263. },
  264. .power_ctrl = dtt200u_power_ctrl,
  265. .rc.legacy = {
  266. .rc_interval = 300,
  267. .rc_map_table = rc_map_dtt200u_table,
  268. .rc_map_size = ARRAY_SIZE(rc_map_dtt200u_table),
  269. .rc_query = dtt200u_rc_query,
  270. },
  271. .generic_bulk_ctrl_endpoint = 0x01,
  272. .num_device_descs = 1,
  273. .devices = {
  274. { .name = "WideView WT-220U PenType Receiver (based on ZL353)",
  275. .cold_ids = { &dtt200u_usb_table[4], NULL },
  276. .warm_ids = { &dtt200u_usb_table[5], NULL },
  277. },
  278. { NULL },
  279. }
  280. };
  281. static struct dvb_usb_device_properties wt220u_miglia_properties = {
  282. .usb_ctrl = CYPRESS_FX2,
  283. .firmware = "dvb-usb-wt220u-miglia-01.fw",
  284. .num_adapters = 1,
  285. .generic_bulk_ctrl_endpoint = 0x01,
  286. .num_device_descs = 1,
  287. .devices = {
  288. { .name = "WideView WT-220U PenType Receiver (Miglia)",
  289. .cold_ids = { &dtt200u_usb_table[9], NULL },
  290. /* This device turns into WT220U_ZL0353_WARM when fw
  291. has been uploaded */
  292. .warm_ids = { NULL },
  293. },
  294. { NULL },
  295. }
  296. };
  297. /* usb specific object needed to register this driver with the usb subsystem */
  298. static struct usb_driver dtt200u_usb_driver = {
  299. .name = "dvb_usb_dtt200u",
  300. .probe = dtt200u_usb_probe,
  301. .disconnect = dvb_usb_device_exit,
  302. .id_table = dtt200u_usb_table,
  303. };
  304. /* module stuff */
  305. static int __init dtt200u_usb_module_init(void)
  306. {
  307. int result;
  308. if ((result = usb_register(&dtt200u_usb_driver))) {
  309. err("usb_register failed. (%d)",result);
  310. return result;
  311. }
  312. return 0;
  313. }
  314. static void __exit dtt200u_usb_module_exit(void)
  315. {
  316. /* deregister this driver from the USB subsystem */
  317. usb_deregister(&dtt200u_usb_driver);
  318. }
  319. module_init(dtt200u_usb_module_init);
  320. module_exit(dtt200u_usb_module_exit);
  321. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  322. MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon/Club3D/Miglia DVB-T USB2.0 devices");
  323. MODULE_VERSION("1.0");
  324. MODULE_LICENSE("GPL");