dtt200u.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* DVB USB library compliant Linux driver for the Yakumo/Hama/Typhoon DVB-T
  2. * USB2.0 receiver.
  3. *
  4. * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation, version 2.
  9. *
  10. * see Documentation/dvb/README.dvb-usb for more information
  11. */
  12. #include "dtt200u.h"
  13. /* debug */
  14. int dvb_usb_dtt200u_debug;
  15. module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644);
  16. MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS);
  17. static int dtt200u_streaming_ctrl(struct dvb_usb_device *d, int onoff)
  18. {
  19. u8 b_streaming[2] = { SET_TS_CTRL, onoff };
  20. u8 b_rst_pid = RESET_PID_FILTER;
  21. dvb_usb_generic_write(d,b_streaming,2);
  22. if (!onoff)
  23. dvb_usb_generic_write(d,&b_rst_pid,1);
  24. return 0;
  25. }
  26. static int dtt200u_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff)
  27. {
  28. u8 b_pid[4];
  29. pid = onoff ? pid : 0;
  30. b_pid[0] = SET_PID_FILTER;
  31. b_pid[1] = index;
  32. b_pid[2] = pid & 0xff;
  33. b_pid[3] = (pid >> 8) & 0xff;
  34. return dvb_usb_generic_write(d,b_pid,4);
  35. }
  36. /* remote control */
  37. /* key list for the tiny remote control (Yakumo, don't know about the others) */
  38. static struct dvb_usb_rc_key dtt200u_rc_keys[] = {
  39. { 0x80, 0x01, KEY_MUTE },
  40. { 0x80, 0x02, KEY_CHANNELDOWN },
  41. { 0x80, 0x03, KEY_VOLUMEDOWN },
  42. { 0x80, 0x04, KEY_1 },
  43. { 0x80, 0x05, KEY_2 },
  44. { 0x80, 0x06, KEY_3 },
  45. { 0x80, 0x07, KEY_4 },
  46. { 0x80, 0x08, KEY_5 },
  47. { 0x80, 0x09, KEY_6 },
  48. { 0x80, 0x0a, KEY_7 },
  49. { 0x00, 0x0c, KEY_ZOOM },
  50. { 0x80, 0x0d, KEY_0 },
  51. { 0x00, 0x0e, KEY_SELECT },
  52. { 0x80, 0x12, KEY_POWER },
  53. { 0x80, 0x1a, KEY_CHANNELUP },
  54. { 0x80, 0x1b, KEY_8 },
  55. { 0x80, 0x1e, KEY_VOLUMEUP },
  56. { 0x80, 0x1f, KEY_9 },
  57. };
  58. static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  59. {
  60. u8 key[5],cmd = GET_RC_KEY;
  61. dvb_usb_generic_rw(d,&cmd,1,key,5,0);
  62. dvb_usb_nec_rc_key_to_event(d,key,event,state);
  63. if (key[0] != 0)
  64. deb_info("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
  65. return 0;
  66. }
  67. static int dtt200u_frontend_attach(struct dvb_usb_device *d)
  68. {
  69. d->fe = dtt200u_fe_attach(d);
  70. return 0;
  71. }
  72. static struct dvb_usb_properties dtt200u_properties;
  73. static int dtt200u_usb_probe(struct usb_interface *intf,
  74. const struct usb_device_id *id)
  75. {
  76. return dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE);
  77. }
  78. static struct usb_device_id dtt200u_usb_table [] = {
  79. { USB_DEVICE(USB_VID_AVERMEDIA_UNK, USB_PID_DTT200U_COLD) },
  80. { USB_DEVICE(USB_VID_AVERMEDIA_UNK, USB_PID_DTT200U_WARM) },
  81. { 0 },
  82. };
  83. MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
  84. static struct dvb_usb_properties dtt200u_properties = {
  85. .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
  86. .pid_filter_count = 255, /* It is a guess, but there are at least 10 */
  87. .usb_ctrl = CYPRESS_FX2,
  88. .firmware = "dvb-usb-dtt200u-01.fw",
  89. .streaming_ctrl = dtt200u_streaming_ctrl,
  90. .pid_filter = dtt200u_pid_filter,
  91. .frontend_attach = dtt200u_frontend_attach,
  92. .rc_interval = 200,
  93. .rc_key_map = dtt200u_rc_keys,
  94. .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
  95. .rc_query = dtt200u_rc_query,
  96. .generic_bulk_ctrl_endpoint = 0x01,
  97. /* parameter for the MPEG2-data transfer */
  98. .urb = {
  99. .type = DVB_USB_BULK,
  100. .count = 7,
  101. .endpoint = 0x02,
  102. .u = {
  103. .bulk = {
  104. .buffersize = 4096,
  105. }
  106. }
  107. },
  108. .num_device_descs = 1,
  109. .devices = {
  110. { .name = "Yakumo/Hama/Typhoon DVB-T USB2.0)",
  111. .cold_ids = { &dtt200u_usb_table[0], &dtt200u_usb_table[2] },
  112. .warm_ids = { &dtt200u_usb_table[1], NULL },
  113. },
  114. { 0 },
  115. }
  116. };
  117. /* usb specific object needed to register this driver with the usb subsystem */
  118. static struct usb_driver dtt200u_usb_driver = {
  119. .owner = THIS_MODULE,
  120. .name = "Yakumo/Hama/Typhoon DVB-T USB2.0",
  121. .probe = dtt200u_usb_probe,
  122. .disconnect = dvb_usb_device_exit,
  123. .id_table = dtt200u_usb_table,
  124. };
  125. /* module stuff */
  126. static int __init dtt200u_usb_module_init(void)
  127. {
  128. int result;
  129. if ((result = usb_register(&dtt200u_usb_driver))) {
  130. err("usb_register failed. (%d)",result);
  131. return result;
  132. }
  133. return 0;
  134. }
  135. static void __exit dtt200u_usb_module_exit(void)
  136. {
  137. /* deregister this driver from the USB subsystem */
  138. usb_deregister(&dtt200u_usb_driver);
  139. }
  140. module_init(dtt200u_usb_module_init);
  141. module_exit(dtt200u_usb_module_exit);
  142. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  143. MODULE_DESCRIPTION("Driver for the Yakumo/Hama/Typhoon DVB-T USB2.0 device");
  144. MODULE_VERSION("1.0");
  145. MODULE_LICENSE("GPL");