0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "dibusb.h"
0014
0015 static int debug;
0016 module_param(debug, int, 0644);
0017 MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS);
0018
0019 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
0020
0021 #define deb_rc(args...) dprintk(debug,0x01,args)
0022
0023 static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
0024 {
0025
0026 return 0;
0027 }
0028
0029
0030 static int a800_identify_state(struct usb_device *udev,
0031 const struct dvb_usb_device_properties *props,
0032 const struct dvb_usb_device_description **desc,
0033 int *cold)
0034 {
0035 *cold = udev->descriptor.iManufacturer != 1;
0036 return 0;
0037 }
0038
0039 static int a800_rc_query(struct dvb_usb_device *d)
0040 {
0041 int ret = 0;
0042 u8 *key = kmalloc(5, GFP_KERNEL);
0043 if (!key)
0044 return -ENOMEM;
0045
0046 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
0047 0x04, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, key, 5,
0048 2000) != 5) {
0049 ret = -ENODEV;
0050 goto out;
0051 }
0052
0053
0054 if (key[0] == 1)
0055 rc_keydown(d->rc_dev, RC_PROTO_NEC,
0056 RC_SCANCODE_NEC(key[1], key[3]), 0);
0057 else if (key[0] == 2)
0058 rc_repeat(d->rc_dev);
0059 out:
0060 kfree(key);
0061 return ret;
0062 }
0063
0064
0065 static struct dvb_usb_device_properties a800_properties;
0066
0067 static int a800_probe(struct usb_interface *intf,
0068 const struct usb_device_id *id)
0069 {
0070 return dvb_usb_device_init(intf, &a800_properties,
0071 THIS_MODULE, NULL, adapter_nr);
0072 }
0073
0074
0075 enum {
0076 AVERMEDIA_DVBT_USB2_COLD,
0077 AVERMEDIA_DVBT_USB2_WARM,
0078 };
0079
0080 static struct usb_device_id a800_table[] = {
0081 DVB_USB_DEV(AVERMEDIA, AVERMEDIA_DVBT_USB2_COLD),
0082 DVB_USB_DEV(AVERMEDIA, AVERMEDIA_DVBT_USB2_WARM),
0083 { }
0084 };
0085
0086 MODULE_DEVICE_TABLE (usb, a800_table);
0087
0088 static struct dvb_usb_device_properties a800_properties = {
0089 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
0090
0091 .usb_ctrl = CYPRESS_FX2,
0092 .firmware = "dvb-usb-avertv-a800-02.fw",
0093
0094 .num_adapters = 1,
0095 .adapter = {
0096 {
0097 .num_frontends = 1,
0098 .fe = {{
0099 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
0100 .pid_filter_count = 32,
0101 .streaming_ctrl = dibusb2_0_streaming_ctrl,
0102 .pid_filter = dibusb_pid_filter,
0103 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
0104
0105 .frontend_attach = dibusb_dib3000mc_frontend_attach,
0106 .tuner_attach = dibusb_dib3000mc_tuner_attach,
0107
0108
0109 .stream = {
0110 .type = USB_BULK,
0111 .count = 7,
0112 .endpoint = 0x06,
0113 .u = {
0114 .bulk = {
0115 .buffersize = 4096,
0116 }
0117 }
0118 },
0119 }},
0120 .size_of_priv = sizeof(struct dibusb_state),
0121 },
0122 },
0123
0124 .power_ctrl = a800_power_ctrl,
0125 .identify_state = a800_identify_state,
0126
0127 .rc.core = {
0128 .rc_interval = DEFAULT_RC_INTERVAL,
0129 .rc_codes = RC_MAP_AVERMEDIA_M135A,
0130 .module_name = KBUILD_MODNAME,
0131 .rc_query = a800_rc_query,
0132 .allowed_protos = RC_PROTO_BIT_NEC,
0133 },
0134
0135 .i2c_algo = &dibusb_i2c_algo,
0136
0137 .generic_bulk_ctrl_endpoint = 0x01,
0138 .num_device_descs = 1,
0139 .devices = {
0140 { "AVerMedia AverTV DVB-T USB 2.0 (A800)",
0141 { &a800_table[AVERMEDIA_DVBT_USB2_COLD], NULL },
0142 { &a800_table[AVERMEDIA_DVBT_USB2_WARM], NULL },
0143 },
0144 }
0145 };
0146
0147 static struct usb_driver a800_driver = {
0148 .name = "dvb_usb_a800",
0149 .probe = a800_probe,
0150 .disconnect = dvb_usb_device_exit,
0151 .id_table = a800_table,
0152 };
0153
0154 module_usb_driver(a800_driver);
0155
0156 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
0157 MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)");
0158 MODULE_VERSION("1.0");
0159 MODULE_LICENSE("GPL");