blob: dc8c8784caa8a8c46e36886acdcbff6e8f3eeb1e [file] [log] [blame]
Johannes Stezenbach776338e2005-06-23 22:02:35 -07001/* 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
18static int debug;
19module_param(debug, int, 0644);
20MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS);
Janne Grunau78e92002008-04-09 19:13:13 -030021
22DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
23
Johannes Stezenbach776338e2005-06-23 22:02:35 -070024#define deb_rc(args...) dprintk(debug,0x01,args)
25
26static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
27{
28 /* do nothing for the AVerMedia */
29 return 0;
30}
31
Klaus Frahma2c00a02006-07-29 18:49:36 -030032/* assure to put cold to 0 for iManufacturer == 1 */
Patrick Boettcher4d43e132006-09-30 06:53:48 -030033static int a800_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
34 struct dvb_usb_device_description **desc, int *cold)
Klaus Frahma2c00a02006-07-29 18:49:36 -030035{
36 *cold = udev->descriptor.iManufacturer != 1;
37 return 0;
38}
39
Johannes Stezenbach776338e2005-06-23 22:02:35 -070040static struct dvb_usb_rc_key a800_rc_keys[] = {
41 { 0x02, 0x01, KEY_PROG1 }, /* SOURCE */
42 { 0x02, 0x00, KEY_POWER }, /* POWER */
43 { 0x02, 0x05, KEY_1 }, /* 1 */
44 { 0x02, 0x06, KEY_2 }, /* 2 */
45 { 0x02, 0x07, KEY_3 }, /* 3 */
46 { 0x02, 0x09, KEY_4 }, /* 4 */
47 { 0x02, 0x0a, KEY_5 }, /* 5 */
48 { 0x02, 0x0b, KEY_6 }, /* 6 */
49 { 0x02, 0x0d, KEY_7 }, /* 7 */
50 { 0x02, 0x0e, KEY_8 }, /* 8 */
51 { 0x02, 0x0f, KEY_9 }, /* 9 */
52 { 0x02, 0x12, KEY_LEFT }, /* L / DISPLAY */
53 { 0x02, 0x11, KEY_0 }, /* 0 */
54 { 0x02, 0x13, KEY_RIGHT }, /* R / CH RTN */
55 { 0x02, 0x17, KEY_PROG2 }, /* SNAP SHOT */
56 { 0x02, 0x10, KEY_PROG3 }, /* 16-CH PREV */
Johannes Stezenbach776338e2005-06-23 22:02:35 -070057 { 0x02, 0x1e, KEY_VOLUMEDOWN }, /* VOL DOWN */
58 { 0x02, 0x0c, KEY_ZOOM }, /* FULL SCREEN */
59 { 0x02, 0x1f, KEY_VOLUMEUP }, /* VOL UP */
Johannes Stezenbach776338e2005-06-23 22:02:35 -070060 { 0x02, 0x14, KEY_MUTE }, /* MUTE */
61 { 0x02, 0x08, KEY_AUDIO }, /* AUDIO */
62 { 0x02, 0x19, KEY_RECORD }, /* RECORD */
63 { 0x02, 0x18, KEY_PLAY }, /* PLAY */
64 { 0x02, 0x1b, KEY_STOP }, /* STOP */
65 { 0x02, 0x1a, KEY_PLAYPAUSE }, /* TIMESHIFT / PAUSE */
66 { 0x02, 0x1d, KEY_BACK }, /* << / RED */
67 { 0x02, 0x1c, KEY_FORWARD }, /* >> / YELLOW */
68 { 0x02, 0x03, KEY_TEXT }, /* TELETEXT */
Johannes Stezenbach776338e2005-06-23 22:02:35 -070069 { 0x02, 0x04, KEY_EPG }, /* EPG */
70 { 0x02, 0x15, KEY_MENU }, /* MENU */
Andrew Hodgson58769a52005-07-07 17:58:26 -070071
72 { 0x03, 0x03, KEY_CHANNELUP }, /* CH UP */
73 { 0x03, 0x02, KEY_CHANNELDOWN }, /* CH DOWN */
74 { 0x03, 0x01, KEY_FIRST }, /* |<< / GREEN */
75 { 0x03, 0x00, KEY_LAST }, /* >>| / BLUE */
76
Johannes Stezenbach776338e2005-06-23 22:02:35 -070077};
78
Adrian Bunk15ac8e62005-12-01 00:51:53 -080079static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
Johannes Stezenbach776338e2005-06-23 22:02:35 -070080{
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,
Andrew Hodgson58769a52005-07-07 17:58:26 -070084 2000) != 5)
Johannes Stezenbach776338e2005-06-23 22:02:35 -070085 return -ENODEV;
86
87 /* call the universal NEC remote processor, to find out the key's state and event */
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/* USB Driver stuff */
Patrick Boettcher4d43e132006-09-30 06:53:48 -030095static struct dvb_usb_device_properties a800_properties;
Johannes Stezenbach776338e2005-06-23 22:02:35 -070096
97static int a800_probe(struct usb_interface *intf,
98 const struct usb_device_id *id)
99{
Janne Grunau78e92002008-04-09 19:13:13 -0300100 return dvb_usb_device_init(intf, &a800_properties,
101 THIS_MODULE, NULL, adapter_nr);
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700102}
103
104/* do not change the order of the ID table */
105static struct usb_device_id a800_table [] = {
106/* 00 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_DVBT_USB2_COLD) },
107/* 01 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_DVBT_USB2_WARM) },
108 { } /* Terminating entry */
109};
110MODULE_DEVICE_TABLE (usb, a800_table);
111
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300112static struct dvb_usb_device_properties a800_properties = {
113 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700114
115 .usb_ctrl = CYPRESS_FX2,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700116 .firmware = "dvb-usb-avertv-a800-02.fw",
117
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300118 .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,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300123 .streaming_ctrl = dibusb2_0_streaming_ctrl,
124 .pid_filter = dibusb_pid_filter,
125 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300126
Patrick Boettcher01451e72006-10-13 11:34:46 -0300127 .frontend_attach = dibusb_dib3000mc_frontend_attach,
128 .tuner_attach = dibusb_dib3000mc_tuner_attach,
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300129
Patrick Boettcher01451e72006-10-13 11:34:46 -0300130 /* parameter for the MPEG2-data transfer */
131 .stream = {
132 .type = USB_BULK,
133 .count = 7,
134 .endpoint = 0x06,
135 .u = {
136 .bulk = {
137 .buffersize = 4096,
138 }
139 }
140 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300141
142 .size_of_priv = sizeof(struct dibusb_state),
143 },
144 },
145
146 .power_ctrl = a800_power_ctrl,
Klaus Frahma2c00a02006-07-29 18:49:36 -0300147 .identify_state = a800_identify_state,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700148
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,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700157 .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 = {
Patrick Boettcher63b5c1c2005-07-07 17:58:30 -0700167 .name = "dvb_usb_a800",
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700168 .probe = a800_probe,
169 .disconnect = dvb_usb_device_exit,
170 .id_table = a800_table,
171};
172
173/* module stuff */
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 /* deregister this driver from the USB subsystem */
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");