dtt200u.c 9.4 KB

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