2 * DVB USB Linux driver for Afatech AF9015 DVB-T USB2.0 receiver
4 * Copyright (C) 2007 Antti Palosaari <crope@iki.fi>
6 * Thanks to Afatech who kindly provided information.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
23 #include <linux/hash.h>
24 #include <linux/regmap.h>
36 #define AF9015_FIRMWARE "/*(DEBLOBBED)*/"
38 #define AF9015_I2C_EEPROM 0x50
39 #define AF9015_I2C_DEMOD 0x1c
40 #define AF9015_USB_TIMEOUT 2000
42 /* EEPROM locations */
43 #define AF9015_EEPROM_IR_MODE 0x18
44 #define AF9015_EEPROM_IR_REMOTE_TYPE 0x34
45 #define AF9015_EEPROM_TS_MODE 0x31
46 #define AF9015_EEPROM_DEMOD2_I2C 0x32
48 #define AF9015_EEPROM_SAW_BW1 0x35
49 #define AF9015_EEPROM_XTAL_TYPE1 0x36
50 #define AF9015_EEPROM_SPEC_INV1 0x37
51 #define AF9015_EEPROM_IF1L 0x38
52 #define AF9015_EEPROM_IF1H 0x39
53 #define AF9015_EEPROM_MT2060_IF1L 0x3a
54 #define AF9015_EEPROM_MT2060_IF1H 0x3b
55 #define AF9015_EEPROM_TUNER_ID1 0x3c
57 #define AF9015_EEPROM_SAW_BW2 0x45
58 #define AF9015_EEPROM_XTAL_TYPE2 0x46
59 #define AF9015_EEPROM_SPEC_INV2 0x47
60 #define AF9015_EEPROM_IF2L 0x48
61 #define AF9015_EEPROM_IF2H 0x49
62 #define AF9015_EEPROM_MT2060_IF2L 0x4a
63 #define AF9015_EEPROM_MT2060_IF2H 0x4b
64 #define AF9015_EEPROM_TUNER_ID2 0x4c
66 #define AF9015_EEPROM_OFFSET (AF9015_EEPROM_SAW_BW2 - AF9015_EEPROM_SAW_BW1)
71 u8 i2c_addr; /* [2] */
74 u8 addr_len; /* [6] */
75 u8 data_len; /* [7] */
81 DOWNLOAD_FIRMWARE = 0x11,
85 READ_WRITE_I2C = 0x22,
88 WRITE_VIRTUAL_MEMORY = 0x26,
95 AF9015_IR_MODE_DISABLED = 0,
99 AF9015_IR_MODE_POLLING, /* just guess */
103 struct af9015_state {
104 struct regmap *regmap;
105 u8 buf[BUF_LEN]; /* bulk USB control message */
112 u8 seq; /* packet sequence number */
115 u16 firmware_checksum;
117 struct af9013_platform_data af9013_pdata[2];
118 struct i2c_client *demod_i2c_client[2];
119 u8 af9013_i2c_addr[2];
120 bool usb_ts_if_configured[2];
122 /* for demod callback override */
123 int (*set_frontend[2]) (struct dvb_frontend *fe);
124 int (*read_status[2]) (struct dvb_frontend *fe, enum fe_status *status);
125 int (*init[2]) (struct dvb_frontend *fe);
126 int (*sleep[2]) (struct dvb_frontend *fe);
127 int (*tuner_init[2]) (struct dvb_frontend *fe);
128 int (*tuner_sleep[2]) (struct dvb_frontend *fe);
129 struct mutex fe_mutex;
133 AF9015_REMOTE_NONE = 0,
134 /* 1 */ AF9015_REMOTE_A_LINK_DTU_M,
135 AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
136 AF9015_REMOTE_MYGICTV_U718,
137 AF9015_REMOTE_DIGITTRADE_DVB_T,
138 /* 5 */ AF9015_REMOTE_AVERMEDIA_KS,