Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / media / usb / dvb-usb-v2 / af9015.h
blob3a9d9815ab7a2099128de39d4b5d829892b8557b
1 /*
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.
20 #ifndef AF9015_H
21 #define AF9015_H
23 #include <linux/hash.h>
24 #include "dvb_usb.h"
25 #include "af9013.h"
26 #include "dvb-pll.h"
27 #include "mt2060.h"
28 #include "qt1010.h"
29 #include "tda18271.h"
30 #include "mxl5005s.h"
31 #include "mc44s803.h"
32 #include "tda18218.h"
33 #include "mxl5007t.h"
35 #define AF9015_FIRMWARE "dvb-usb-af9015.fw"
37 /* Windows driver uses packet count 21 for USB1.1 and 348 for USB2.0.
38 We use smaller - about 1/4 from the original, 5 and 87. */
39 #define TS_PACKET_SIZE 188
41 #define TS_USB20_PACKET_COUNT 87
42 #define TS_USB20_FRAME_SIZE (TS_PACKET_SIZE*TS_USB20_PACKET_COUNT)
44 #define TS_USB11_PACKET_COUNT 5
45 #define TS_USB11_FRAME_SIZE (TS_PACKET_SIZE*TS_USB11_PACKET_COUNT)
47 #define TS_USB20_MAX_PACKET_SIZE 512
48 #define TS_USB11_MAX_PACKET_SIZE 64
50 #define AF9015_I2C_EEPROM 0x50
51 #define AF9015_I2C_DEMOD 0x1c
52 #define AF9015_USB_TIMEOUT 2000
54 /* EEPROM locations */
55 #define AF9015_EEPROM_IR_MODE 0x18
56 #define AF9015_EEPROM_IR_REMOTE_TYPE 0x34
57 #define AF9015_EEPROM_TS_MODE 0x31
58 #define AF9015_EEPROM_DEMOD2_I2C 0x32
60 #define AF9015_EEPROM_SAW_BW1 0x35
61 #define AF9015_EEPROM_XTAL_TYPE1 0x36
62 #define AF9015_EEPROM_SPEC_INV1 0x37
63 #define AF9015_EEPROM_IF1L 0x38
64 #define AF9015_EEPROM_IF1H 0x39
65 #define AF9015_EEPROM_MT2060_IF1L 0x3a
66 #define AF9015_EEPROM_MT2060_IF1H 0x3b
67 #define AF9015_EEPROM_TUNER_ID1 0x3c
69 #define AF9015_EEPROM_SAW_BW2 0x45
70 #define AF9015_EEPROM_XTAL_TYPE2 0x46
71 #define AF9015_EEPROM_SPEC_INV2 0x47
72 #define AF9015_EEPROM_IF2L 0x48
73 #define AF9015_EEPROM_IF2H 0x49
74 #define AF9015_EEPROM_MT2060_IF2L 0x4a
75 #define AF9015_EEPROM_MT2060_IF2H 0x4b
76 #define AF9015_EEPROM_TUNER_ID2 0x4c
78 #define AF9015_EEPROM_OFFSET (AF9015_EEPROM_SAW_BW2 - AF9015_EEPROM_SAW_BW1)
80 struct req_t {
81 u8 cmd; /* [0] */
82 /* seq */ /* [1] */
83 u8 i2c_addr; /* [2] */
84 u16 addr; /* [3|4] */
85 u8 mbox; /* [5] */
86 u8 addr_len; /* [6] */
87 u8 data_len; /* [7] */
88 u8 *data;
91 enum af9015_cmd {
92 GET_CONFIG = 0x10,
93 DOWNLOAD_FIRMWARE = 0x11,
94 BOOT = 0x13,
95 READ_MEMORY = 0x20,
96 WRITE_MEMORY = 0x21,
97 READ_WRITE_I2C = 0x22,
98 COPY_FIRMWARE = 0x23,
99 RECONNECT_USB = 0x5a,
100 WRITE_VIRTUAL_MEMORY = 0x26,
101 GET_IR_CODE = 0x27,
102 READ_I2C,
103 WRITE_I2C,
106 enum af9015_ir_mode {
107 AF9015_IR_MODE_DISABLED = 0,
108 AF9015_IR_MODE_HID,
109 AF9015_IR_MODE_RLC,
110 AF9015_IR_MODE_RC6,
111 AF9015_IR_MODE_POLLING, /* just guess */
114 #define BUF_LEN 63
115 struct af9015_state {
116 u8 buf[BUF_LEN]; /* bulk USB control message */
117 u8 ir_mode;
118 u8 rc_repeat;
119 u32 rc_keycode;
120 u8 rc_last[4];
121 bool rc_failed;
122 u8 dual_mode;
123 u8 seq; /* packet sequence number */
124 u16 mt2060_if1[2];
125 u16 firmware_size;
126 u16 firmware_checksum;
127 u32 eeprom_sum;
128 struct af9013_config af9013_config[2];
130 /* for demod callback override */
131 int (*set_frontend[2]) (struct dvb_frontend *fe);
132 int (*read_status[2]) (struct dvb_frontend *fe, enum fe_status *status);
133 int (*init[2]) (struct dvb_frontend *fe);
134 int (*sleep[2]) (struct dvb_frontend *fe);
135 int (*tuner_init[2]) (struct dvb_frontend *fe);
136 int (*tuner_sleep[2]) (struct dvb_frontend *fe);
137 struct mutex fe_mutex;
140 enum af9015_remote {
141 AF9015_REMOTE_NONE = 0,
142 /* 1 */ AF9015_REMOTE_A_LINK_DTU_M,
143 AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
144 AF9015_REMOTE_MYGICTV_U718,
145 AF9015_REMOTE_DIGITTRADE_DVB_T,
146 /* 5 */ AF9015_REMOTE_AVERMEDIA_KS,
149 #endif