dtt200u.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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: %*ph\n", 5, key);
  75. return 0;
  76. }
  77. static int dtt200u_frontend_attach(struct dvb_usb_adapter *adap)
  78. {
  79. adap->fe_adap[0].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. .num_frontends = 1,
  124. .fe = {{
  125. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
  126. .pid_filter_count = 15,
  127. .streaming_ctrl = dtt200u_streaming_ctrl,
  128. .pid_filter = dtt200u_pid_filter,
  129. .frontend_attach = dtt200u_frontend_attach,
  130. /* parameter for the MPEG2-data transfer */
  131. .stream = {
  132. .type = USB_BULK,
  133. .count = 7,
  134. .endpoint = 0x02,
  135. .u = {
  136. .bulk = {
  137. .buffersize = 4096,
  138. }
  139. }
  140. },
  141. }},
  142. }
  143. },
  144. .power_ctrl = dtt200u_power_ctrl,
  145. .rc.legacy = {
  146. .rc_interval = 300,
  147. .rc_map_table = rc_map_dtt200u_table,
  148. .rc_map_size = ARRAY_SIZE(rc_map_dtt200u_table),
  149. .rc_query = dtt200u_rc_query,
  150. },
  151. .generic_bulk_ctrl_endpoint = 0x01,
  152. .num_device_descs = 1,
  153. .devices = {
  154. { .name = "WideView/Yuan/Yakumo/Hama/Typhoon DVB-T USB2.0 (WT-200U)",
  155. .cold_ids = { &dtt200u_usb_table[0], NULL },
  156. .warm_ids = { &dtt200u_usb_table[1], NULL },
  157. },
  158. { NULL },
  159. }
  160. };
  161. static struct dvb_usb_device_properties wt220u_properties = {
  162. .usb_ctrl = CYPRESS_FX2,
  163. .firmware = "dvb-usb-wt220u-02.fw",
  164. .num_adapters = 1,
  165. .adapter = {
  166. {
  167. .num_frontends = 1,
  168. .fe = {{
  169. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
  170. .pid_filter_count = 15,
  171. .streaming_ctrl = dtt200u_streaming_ctrl,
  172. .pid_filter = dtt200u_pid_filter,
  173. .frontend_attach = dtt200u_frontend_attach,
  174. /* parameter for the MPEG2-data transfer */
  175. .stream = {
  176. .type = USB_BULK,
  177. .count = 7,
  178. .endpoint = 0x02,
  179. .u = {
  180. .bulk = {
  181. .buffersize = 4096,
  182. }
  183. }
  184. },
  185. }},
  186. }
  187. },
  188. .power_ctrl = dtt200u_power_ctrl,
  189. .rc.legacy = {
  190. .rc_interval = 300,
  191. .rc_map_table = rc_map_dtt200u_table,
  192. .rc_map_size = ARRAY_SIZE(rc_map_dtt200u_table),
  193. .rc_query = dtt200u_rc_query,
  194. },
  195. .generic_bulk_ctrl_endpoint = 0x01,
  196. .num_device_descs = 1,
  197. .devices = {
  198. { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)",
  199. .cold_ids = { &dtt200u_usb_table[2], &dtt200u_usb_table[8], NULL },
  200. .warm_ids = { &dtt200u_usb_table[3], NULL },
  201. },
  202. { NULL },
  203. }
  204. };
  205. static struct dvb_usb_device_properties wt220u_fc_properties = {
  206. .usb_ctrl = CYPRESS_FX2,
  207. .firmware = "dvb-usb-wt220u-fc03.fw",
  208. .num_adapters = 1,
  209. .adapter = {
  210. {
  211. .num_frontends = 1,
  212. .fe = {{
  213. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
  214. .pid_filter_count = 15,
  215. .streaming_ctrl = dtt200u_streaming_ctrl,
  216. .pid_filter = dtt200u_pid_filter,
  217. .frontend_attach = dtt200u_frontend_attach,
  218. /* parameter for the MPEG2-data transfer */
  219. .stream = {
  220. .type = USB_BULK,
  221. .count = 7,
  222. .endpoint = 0x06,
  223. .u = {
  224. .bulk = {
  225. .buffersize = 4096,
  226. }
  227. }
  228. },
  229. }},
  230. }
  231. },
  232. .power_ctrl = dtt200u_power_ctrl,
  233. .rc.legacy = {
  234. .rc_interval = 300,
  235. .rc_map_table = rc_map_dtt200u_table,
  236. .rc_map_size = ARRAY_SIZE(rc_map_dtt200u_table),
  237. .rc_query = dtt200u_rc_query,
  238. },
  239. .generic_bulk_ctrl_endpoint = 0x01,
  240. .num_device_descs = 1,
  241. .devices = {
  242. { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)",
  243. .cold_ids = { &dtt200u_usb_table[6], NULL },
  244. .warm_ids = { &dtt200u_usb_table[7], NULL },
  245. },
  246. { NULL },
  247. }
  248. };
  249. static struct dvb_usb_device_properties wt220u_zl0353_properties = {
  250. .usb_ctrl = CYPRESS_FX2,
  251. .firmware = "dvb-usb-wt220u-zl0353-01.fw",
  252. .num_adapters = 1,
  253. .adapter = {
  254. {
  255. .num_frontends = 1,
  256. .fe = {{
  257. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
  258. .pid_filter_count = 15,
  259. .streaming_ctrl = dtt200u_streaming_ctrl,
  260. .pid_filter = dtt200u_pid_filter,
  261. .frontend_attach = dtt200u_frontend_attach,
  262. /* parameter for the MPEG2-data transfer */
  263. .stream = {
  264. .type = USB_BULK,
  265. .count = 7,
  266. .endpoint = 0x02,
  267. .u = {
  268. .bulk = {
  269. .buffersize = 4096,
  270. }
  271. }
  272. },
  273. }},
  274. }
  275. },
  276. .power_ctrl = dtt200u_power_ctrl,
  277. .rc.legacy = {
  278. .rc_interval = 300,
  279. .rc_map_table = rc_map_dtt200u_table,
  280. .rc_map_size = ARRAY_SIZE(rc_map_dtt200u_table),
  281. .rc_query = dtt200u_rc_query,
  282. },
  283. .generic_bulk_ctrl_endpoint = 0x01,
  284. .num_device_descs = 1,
  285. .devices = {
  286. { .name = "WideView WT-220U PenType Receiver (based on ZL353)",
  287. .cold_ids = { &dtt200u_usb_table[4], NULL },
  288. .warm_ids = { &dtt200u_usb_table[5], NULL },
  289. },
  290. { NULL },
  291. }
  292. };
  293. static struct dvb_usb_device_properties wt220u_miglia_properties = {
  294. .usb_ctrl = CYPRESS_FX2,
  295. .firmware = "dvb-usb-wt220u-miglia-01.fw",
  296. .num_adapters = 1,
  297. .generic_bulk_ctrl_endpoint = 0x01,
  298. .num_device_descs = 1,
  299. .devices = {
  300. { .name = "WideView WT-220U PenType Receiver (Miglia)",
  301. .cold_ids = { &dtt200u_usb_table[9], NULL },
  302. /* This device turns into WT220U_ZL0353_WARM when fw
  303. has been uploaded */
  304. .warm_ids = { NULL },
  305. },
  306. { NULL },
  307. }
  308. };
  309. /* usb specific object needed to register this driver with the usb subsystem */
  310. static struct usb_driver dtt200u_usb_driver = {
  311. .name = "dvb_usb_dtt200u",
  312. .probe = dtt200u_usb_probe,
  313. .disconnect = dvb_usb_device_exit,
  314. .id_table = dtt200u_usb_table,
  315. };
  316. module_usb_driver(dtt200u_usb_driver);
  317. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  318. MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon/Club3D/Miglia DVB-T USB2.0 devices");
  319. MODULE_VERSION("1.0");
  320. MODULE_LICENSE("GPL");