1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include "dibusb.h"
17
18static int debug;
19module_param(debug, int, 0644);
20MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS);
21
22DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
23
24#define deb_rc(args...) dprintk(debug,0x01,args)
25
26static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
27{
28
29 return 0;
30}
31
32
33static int a800_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
34 struct dvb_usb_device_description **desc, int *cold)
35{
36 *cold = udev->descriptor.iManufacturer != 1;
37 return 0;
38}
39
40static struct dvb_usb_rc_key a800_rc_keys[] = {
41 { 0x0201, KEY_PROG1 },
42 { 0x0200, KEY_POWER },
43 { 0x0205, KEY_1 },
44 { 0x0206, KEY_2 },
45 { 0x0207, KEY_3 },
46 { 0x0209, KEY_4 },
47 { 0x020a, KEY_5 },
48 { 0x020b, KEY_6 },
49 { 0x020d, KEY_7 },
50 { 0x020e, KEY_8 },
51 { 0x020f, KEY_9 },
52 { 0x0212, KEY_LEFT },
53 { 0x0211, KEY_0 },
54 { 0x0213, KEY_RIGHT },
55 { 0x0217, KEY_PROG2 },
56 { 0x0210, KEY_PROG3 },
57 { 0x021e, KEY_VOLUMEDOWN },
58 { 0x020c, KEY_ZOOM },
59 { 0x021f, KEY_VOLUMEUP },
60 { 0x0214, KEY_MUTE },
61 { 0x0208, KEY_AUDIO },
62 { 0x0219, KEY_RECORD },
63 { 0x0218, KEY_PLAY },
64 { 0x021b, KEY_STOP },
65 { 0x021a, KEY_PLAYPAUSE },
66 { 0x021d, KEY_BACK },
67 { 0x021c, KEY_FORWARD },
68 { 0x0203, KEY_TEXT },
69 { 0x0204, KEY_EPG },
70 { 0x0215, KEY_MENU },
71
72 { 0x0303, KEY_CHANNELUP },
73 { 0x0302, KEY_CHANNELDOWN },
74 { 0x0301, KEY_FIRST },
75 { 0x0300, KEY_LAST },
76
77};
78
79static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
80{
81 u8 key[5];
82 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
83 0x04, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, key, 5,
84 2000) != 5)
85 return -ENODEV;
86
87
88 dvb_usb_nec_rc_key_to_event(d,key,event,state);
89 if (key[0] != 0)
90 deb_rc("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
91 return 0;
92}
93
94
95static struct dvb_usb_device_properties a800_properties;
96
97static int a800_probe(struct usb_interface *intf,
98 const struct usb_device_id *id)
99{
100 return dvb_usb_device_init(intf, &a800_properties,
101 THIS_MODULE, NULL, adapter_nr);
102}
103
104
105static struct usb_device_id a800_table [] = {
106 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_DVBT_USB2_COLD) },
107 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_DVBT_USB2_WARM) },
108 { }
109};
110MODULE_DEVICE_TABLE (usb, a800_table);
111
112static struct dvb_usb_device_properties a800_properties = {
113 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
114
115 .usb_ctrl = CYPRESS_FX2,
116 .firmware = "dvb-usb-avertv-a800-02.fw",
117
118 .num_adapters = 1,
119 .adapter = {
120 {
121 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
122 .pid_filter_count = 32,
123 .streaming_ctrl = dibusb2_0_streaming_ctrl,
124 .pid_filter = dibusb_pid_filter,
125 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
126
127 .frontend_attach = dibusb_dib3000mc_frontend_attach,
128 .tuner_attach = dibusb_dib3000mc_tuner_attach,
129
130
131 .stream = {
132 .type = USB_BULK,
133 .count = 7,
134 .endpoint = 0x06,
135 .u = {
136 .bulk = {
137 .buffersize = 4096,
138 }
139 }
140 },
141
142 .size_of_priv = sizeof(struct dibusb_state),
143 },
144 },
145
146 .power_ctrl = a800_power_ctrl,
147 .identify_state = a800_identify_state,
148
149 .rc_interval = DEFAULT_RC_INTERVAL,
150 .rc_key_map = a800_rc_keys,
151 .rc_key_map_size = ARRAY_SIZE(a800_rc_keys),
152 .rc_query = a800_rc_query,
153
154 .i2c_algo = &dibusb_i2c_algo,
155
156 .generic_bulk_ctrl_endpoint = 0x01,
157 .num_device_descs = 1,
158 .devices = {
159 { "AVerMedia AverTV DVB-T USB 2.0 (A800)",
160 { &a800_table[0], NULL },
161 { &a800_table[1], NULL },
162 },
163 }
164};
165
166static struct usb_driver a800_driver = {
167 .name = "dvb_usb_a800",
168 .probe = a800_probe,
169 .disconnect = dvb_usb_device_exit,
170 .id_table = a800_table,
171};
172
173
174static int __init a800_module_init(void)
175{
176 int result;
177 if ((result = usb_register(&a800_driver))) {
178 err("usb_register failed. Error number %d",result);
179 return result;
180 }
181
182 return 0;
183}
184
185static void __exit a800_module_exit(void)
186{
187
188 usb_deregister(&a800_driver);
189}
190
191module_init (a800_module_init);
192module_exit (a800_module_exit);
193
194MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
195MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)");
196MODULE_VERSION("1.0");
197MODULE_LICENSE("GPL");
198