a800.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* DVB USB framework compliant Linux driver for the AVerMedia AverTV DVB-T
  2. * USB2.0 (A800) DVB-T receiver.
  3. *
  4. * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
  5. *
  6. * Thanks to
  7. * - AVerMedia who kindly provided information and
  8. * - Glen Harris who suffered from my mistakes during development.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the Free
  12. * Software Foundation, version 2.
  13. *
  14. * see Documentation/dvb/README.dvb-usb for more information
  15. */
  16. #include "dibusb.h"
  17. static int debug;
  18. module_param(debug, int, 0644);
  19. MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS);
  20. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  21. #define deb_rc(args...) dprintk(debug,0x01,args)
  22. static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
  23. {
  24. /* do nothing for the AVerMedia */
  25. return 0;
  26. }
  27. /* assure to put cold to 0 for iManufacturer == 1 */
  28. static int a800_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
  29. struct dvb_usb_device_description **desc, int *cold)
  30. {
  31. *cold = udev->descriptor.iManufacturer != 1;
  32. return 0;
  33. }
  34. static struct rc_map_table rc_map_a800_table[] = {
  35. { 0x0201, KEY_MODE }, /* SOURCE */
  36. { 0x0200, KEY_POWER2 }, /* POWER */
  37. { 0x0205, KEY_1 }, /* 1 */
  38. { 0x0206, KEY_2 }, /* 2 */
  39. { 0x0207, KEY_3 }, /* 3 */
  40. { 0x0209, KEY_4 }, /* 4 */
  41. { 0x020a, KEY_5 }, /* 5 */
  42. { 0x020b, KEY_6 }, /* 6 */
  43. { 0x020d, KEY_7 }, /* 7 */
  44. { 0x020e, KEY_8 }, /* 8 */
  45. { 0x020f, KEY_9 }, /* 9 */
  46. { 0x0212, KEY_LEFT }, /* L / DISPLAY */
  47. { 0x0211, KEY_0 }, /* 0 */
  48. { 0x0213, KEY_RIGHT }, /* R / CH RTN */
  49. { 0x0217, KEY_CAMERA }, /* SNAP SHOT */
  50. { 0x0210, KEY_LAST }, /* 16-CH PREV */
  51. { 0x021e, KEY_VOLUMEDOWN }, /* VOL DOWN */
  52. { 0x020c, KEY_ZOOM }, /* FULL SCREEN */
  53. { 0x021f, KEY_VOLUMEUP }, /* VOL UP */
  54. { 0x0214, KEY_MUTE }, /* MUTE */
  55. { 0x0208, KEY_AUDIO }, /* AUDIO */
  56. { 0x0219, KEY_RECORD }, /* RECORD */
  57. { 0x0218, KEY_PLAY }, /* PLAY */
  58. { 0x021b, KEY_STOP }, /* STOP */
  59. { 0x021a, KEY_PLAYPAUSE }, /* TIMESHIFT / PAUSE */
  60. { 0x021d, KEY_BACK }, /* << / RED */
  61. { 0x021c, KEY_FORWARD }, /* >> / YELLOW */
  62. { 0x0203, KEY_TEXT }, /* TELETEXT */
  63. { 0x0204, KEY_EPG }, /* EPG */
  64. { 0x0215, KEY_MENU }, /* MENU */
  65. { 0x0303, KEY_CHANNELUP }, /* CH UP */
  66. { 0x0302, KEY_CHANNELDOWN }, /* CH DOWN */
  67. { 0x0301, KEY_FIRST }, /* |<< / GREEN */
  68. { 0x0300, KEY_LAST }, /* >>| / BLUE */
  69. };
  70. static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  71. {
  72. int ret;
  73. u8 *key = kmalloc(5, GFP_KERNEL);
  74. if (!key)
  75. return -ENOMEM;
  76. if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
  77. 0x04, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, key, 5,
  78. 2000) != 5) {
  79. ret = -ENODEV;
  80. goto out;
  81. }
  82. /* call the universal NEC remote processor, to find out the key's state and event */
  83. dvb_usb_nec_rc_key_to_event(d,key,event,state);
  84. if (key[0] != 0)
  85. deb_rc("key: %*ph\n", 5, key);
  86. ret = 0;
  87. out:
  88. kfree(key);
  89. return ret;
  90. }
  91. /* USB Driver stuff */
  92. static struct dvb_usb_device_properties a800_properties;
  93. static int a800_probe(struct usb_interface *intf,
  94. const struct usb_device_id *id)
  95. {
  96. return dvb_usb_device_init(intf, &a800_properties,
  97. THIS_MODULE, NULL, adapter_nr);
  98. }
  99. /* do not change the order of the ID table */
  100. static struct usb_device_id a800_table [] = {
  101. /* 00 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_DVBT_USB2_COLD) },
  102. /* 01 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_DVBT_USB2_WARM) },
  103. { } /* Terminating entry */
  104. };
  105. MODULE_DEVICE_TABLE (usb, a800_table);
  106. static struct dvb_usb_device_properties a800_properties = {
  107. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  108. .usb_ctrl = CYPRESS_FX2,
  109. .firmware = "dvb-usb-avertv-a800-02.fw",
  110. .num_adapters = 1,
  111. .adapter = {
  112. {
  113. .num_frontends = 1,
  114. .fe = {{
  115. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  116. .pid_filter_count = 32,
  117. .streaming_ctrl = dibusb2_0_streaming_ctrl,
  118. .pid_filter = dibusb_pid_filter,
  119. .pid_filter_ctrl = dibusb_pid_filter_ctrl,
  120. .frontend_attach = dibusb_dib3000mc_frontend_attach,
  121. .tuner_attach = dibusb_dib3000mc_tuner_attach,
  122. /* parameter for the MPEG2-data transfer */
  123. .stream = {
  124. .type = USB_BULK,
  125. .count = 7,
  126. .endpoint = 0x06,
  127. .u = {
  128. .bulk = {
  129. .buffersize = 4096,
  130. }
  131. }
  132. },
  133. }},
  134. .size_of_priv = sizeof(struct dibusb_state),
  135. },
  136. },
  137. .power_ctrl = a800_power_ctrl,
  138. .identify_state = a800_identify_state,
  139. .rc.legacy = {
  140. .rc_interval = DEFAULT_RC_INTERVAL,
  141. .rc_map_table = rc_map_a800_table,
  142. .rc_map_size = ARRAY_SIZE(rc_map_a800_table),
  143. .rc_query = a800_rc_query,
  144. },
  145. .i2c_algo = &dibusb_i2c_algo,
  146. .generic_bulk_ctrl_endpoint = 0x01,
  147. .num_device_descs = 1,
  148. .devices = {
  149. { "AVerMedia AverTV DVB-T USB 2.0 (A800)",
  150. { &a800_table[0], NULL },
  151. { &a800_table[1], NULL },
  152. },
  153. }
  154. };
  155. static struct usb_driver a800_driver = {
  156. .name = "dvb_usb_a800",
  157. .probe = a800_probe,
  158. .disconnect = dvb_usb_device_exit,
  159. .id_table = a800_table,
  160. };
  161. module_usb_driver(a800_driver);
  162. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  163. MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)");
  164. MODULE_VERSION("1.0");
  165. MODULE_LICENSE("GPL");