aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig7
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/dtv5100-fe.c147
-rw-r--r--drivers/media/dvb/dvb-usb/dtv5100.c217
-rw-r--r--drivers/media/dvb/dvb-usb/dtv5100.h128
5 files changed, 502 insertions, 0 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 8a54cb48322f..1d9e98cee9e7 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -264,3 +264,10 @@ config DVB_USB_ANYSEE
264 help 264 help
265 Say Y here to support the Anysee E30, Anysee E30 Plus or 265 Say Y here to support the Anysee E30, Anysee E30 Plus or
266 Anysee E30 C Plus DVB USB2.0 receiver. 266 Anysee E30 C Plus DVB USB2.0 receiver.
267
268config DVB_USB_DTV5100
269 tristate "AME DTV-5100 USB2.0 DVB-T support"
270 depends on DVB_USB
271 select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE
272 help
273 Say Y here to support the AME DTV-5100 USB2.0 DVB-T receiver.
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index e206f1ea0027..5e170fba1092 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -67,6 +67,9 @@ obj-$(CONFIG_DVB_USB_ANYSEE) += dvb-usb-anysee.o
67dvb-usb-dw2102-objs = dw2102.o 67dvb-usb-dw2102-objs = dw2102.o
68obj-$(CONFIG_DVB_USB_DW2102) += dvb-usb-dw2102.o 68obj-$(CONFIG_DVB_USB_DW2102) += dvb-usb-dw2102.o
69 69
70dvb-usb-dtv5100-objs = dtv5100.o dtv5100-fe.o
71obj-$(CONFIG_DVB_USB_DTV5100) += dvb-usb-dtv5100.o
72
70EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 73EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
71# due to tuner-xc3028 74# due to tuner-xc3028
72EXTRA_CFLAGS += -Idrivers/media/common/tuners 75EXTRA_CFLAGS += -Idrivers/media/common/tuners
diff --git a/drivers/media/dvb/dvb-usb/dtv5100-fe.c b/drivers/media/dvb/dvb-usb/dtv5100-fe.c
new file mode 100644
index 000000000000..08fe33bcc5d6
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dtv5100-fe.c
@@ -0,0 +1,147 @@
1/*
2 * DVB USB Linux driver for AME DTV-5100 USB2.0 DVB-T
3 *
4 * Copyright (C) 2008 Antoine Jacquet <royale@zerezo.com>
5 * http://royale.zerezo.com/dtv5100/
6 *
7 * Inspired by dvb_dummy_fe.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include "dvb-usb.h"
25#include "qt1010_priv.h"
26
27struct dtv5100_fe_state {
28 struct dvb_frontend frontend;
29};
30
31static int dtv5100_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
32{
33 *status = FE_HAS_SIGNAL
34 | FE_HAS_CARRIER
35 | FE_HAS_VITERBI
36 | FE_HAS_SYNC
37 | FE_HAS_LOCK;
38
39 return 0;
40}
41
42static int dtv5100_fe_read_ber(struct dvb_frontend* fe, u32* ber)
43{
44 *ber = 0;
45 return 0;
46}
47
48static int dtv5100_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
49{
50 *strength = 0;
51 return 0;
52}
53
54static int dtv5100_fe_read_snr(struct dvb_frontend* fe, u16* snr)
55{
56 *snr = 0;
57 return 0;
58}
59
60static int dtv5100_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
61{
62 *ucblocks = 0;
63 return 0;
64}
65
66static int dtv5100_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
67{
68 return 0;
69}
70
71static int dtv5100_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
72{
73 if (fe->ops.tuner_ops.set_params) {
74 fe->ops.tuner_ops.set_params(fe, p);
75 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
76 }
77
78 return 0;
79}
80
81static int dtv5100_fe_sleep(struct dvb_frontend* fe)
82{
83 return 0;
84}
85
86static int dtv5100_fe_init(struct dvb_frontend* fe)
87{
88 return 0;
89}
90
91static void dtv5100_fe_release(struct dvb_frontend* fe)
92{
93 struct dtv5100_fe_state* state = fe->demodulator_priv;
94 kfree(state);
95}
96
97static struct dvb_frontend_ops dtv5100_fe_ops;
98
99struct dvb_frontend* dtv5100_fe_attach(void)
100{
101 struct dtv5100_fe_state* state = NULL;
102
103 /* allocate memory for the internal state */
104 state = kmalloc(sizeof(struct dtv5100_fe_state), GFP_KERNEL);
105 if (state == NULL) goto error;
106
107 /* create dvb_frontend */
108 memcpy(&state->frontend.ops, &dtv5100_fe_ops, sizeof(struct dvb_frontend_ops));
109 state->frontend.demodulator_priv = state;
110 return &state->frontend;
111
112error:
113 kfree(state);
114 return NULL;
115}
116
117static struct dvb_frontend_ops dtv5100_fe_ops = {
118
119 .info = {
120 .name = "Dummy DVB-T",
121 .type = FE_OFDM,
122 .frequency_min = QT1010_MIN_FREQ,
123 .frequency_max = QT1010_MAX_FREQ,
124 .frequency_stepsize = QT1010_STEP,
125 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
126 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
127 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
128 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
129 FE_CAN_TRANSMISSION_MODE_AUTO |
130 FE_CAN_GUARD_INTERVAL_AUTO |
131 FE_CAN_HIERARCHY_AUTO,
132 },
133
134 .release = dtv5100_fe_release,
135
136 .init = dtv5100_fe_init,
137 .sleep = dtv5100_fe_sleep,
138
139 .set_frontend = dtv5100_fe_set_frontend,
140 .get_frontend = dtv5100_fe_get_frontend,
141
142 .read_status = dtv5100_fe_read_status,
143 .read_ber = dtv5100_fe_read_ber,
144 .read_signal_strength = dtv5100_fe_read_signal_strength,
145 .read_snr = dtv5100_fe_read_snr,
146 .read_ucblocks = dtv5100_fe_read_ucblocks,
147};
diff --git a/drivers/media/dvb/dvb-usb/dtv5100.c b/drivers/media/dvb/dvb-usb/dtv5100.c
new file mode 100644
index 000000000000..f89d01755eab
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dtv5100.c
@@ -0,0 +1,217 @@
1/*
2 * DVB USB Linux driver for AME DTV-5100 USB2.0 DVB-T
3 *
4 * Copyright (C) 2008 Antoine Jacquet <royale@zerezo.com>
5 * http://royale.zerezo.com/dtv5100/
6 *
7 * Inspired by gl861.c and au6610.c drivers
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include "dtv5100.h"
25#include "qt1010.h"
26
27/* debug */
28static int dvb_usb_dtv5100_debug;
29module_param_named(debug, dvb_usb_dtv5100_debug, int, 0644);
30MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
31DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
32
33static int dtv5100_read_reg(struct dvb_usb_device *d, u8 addr, u8 reg, u8 *value)
34{
35 return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
36 DTV5100_I2C_READ, USB_TYPE_VENDOR|USB_DIR_IN,
37 0, (addr << 8) + reg, value, 1,
38 DTV5100_USB_TIMEOUT);
39}
40
41static int dtv5100_write_reg(struct dvb_usb_device *d, u8 addr, u8 reg, u8 value)
42{
43 return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
44 DTV5100_I2C_WRITE, USB_TYPE_VENDOR|USB_DIR_OUT,
45 value, (addr << 8) + reg, NULL, 0,
46 DTV5100_USB_TIMEOUT);
47}
48
49/* I2C */
50static int dtv5100_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
51 int num)
52{
53 struct dvb_usb_device *d = i2c_get_adapdata(adap);
54 int i;
55
56 if (num > 2)
57 return -EINVAL;
58
59 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
60 return -EAGAIN;
61
62 for (i = 0; i < num; i++) {
63 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
64 /* write/read request, 2 messages
65 * msg = {
66 * { reg },
67 * { val },
68 * }
69 */
70 if (dtv5100_read_reg(d, msg[i].addr, msg[i].buf[0], msg[i+1].buf) < 0)
71 break;
72 i++;
73 } else {
74 /* write request, 1 message
75 * msg = {
76 * { reg, val },
77 * }
78 */
79 if (dtv5100_write_reg(d, msg[i].addr, msg[i].buf[0], msg[i].buf[1]) < 0)
80 break;
81 }
82 }
83
84 mutex_unlock(&d->i2c_mutex);
85 return i;
86}
87
88static u32 dtv5100_i2c_func(struct i2c_adapter *adapter)
89{
90 return I2C_FUNC_I2C;
91}
92
93static struct i2c_algorithm dtv5100_i2c_algo = {
94 .master_xfer = dtv5100_i2c_xfer,
95 .functionality = dtv5100_i2c_func,
96};
97
98/* Callbacks for DVB USB */
99static int dtv5100_frontend_attach(struct dvb_usb_adapter *adap)
100{
101 adap->fe = dtv5100_fe_attach();
102 return 0;
103}
104
105static struct qt1010_config dtv5100_qt1010_config = {
106 .i2c_address = 0xc4
107};
108
109static int dtv5100_tuner_attach(struct dvb_usb_adapter *adap)
110{
111 return dvb_attach(qt1010_attach,
112 adap->fe, &adap->dev->i2c_adap,
113 &dtv5100_qt1010_config) == NULL ? -ENODEV : 0;
114}
115
116/* DVB USB Driver stuff */
117static struct dvb_usb_device_properties dtv5100_properties;
118
119static int dtv5100_probe(struct usb_interface *intf,
120 const struct usb_device_id *id)
121{
122 int i, ret;
123 struct usb_device *udev = interface_to_usbdev(intf);
124
125 ret = dvb_usb_device_init(intf, &dtv5100_properties,
126 THIS_MODULE, NULL, adapter_nr);
127 if (ret)
128 return ret;
129
130 /* initialize frontend & non qt1010 part? */
131 for (i = 0; dtv5100_init[i].request; i++)
132 {
133 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
134 dtv5100_init[i].request,
135 USB_TYPE_VENDOR|USB_DIR_OUT,
136 dtv5100_init[i].value,
137 dtv5100_init[i].index, NULL, 0,
138 DTV5100_USB_TIMEOUT);
139 if (ret)
140 return ret;
141 }
142
143 return 0;
144}
145
146static struct usb_device_id dtv5100_table [] = {
147 { USB_DEVICE(0x06be, 0xa232) },
148 { } /* Terminating entry */
149};
150MODULE_DEVICE_TABLE(usb, dtv5100_table);
151
152static struct dvb_usb_device_properties dtv5100_properties = {
153 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
154 .usb_ctrl = DEVICE_SPECIFIC,
155
156 .size_of_priv = 0,
157
158 .num_adapters = 1,
159 .adapter = {{
160 .frontend_attach = dtv5100_frontend_attach,
161 .tuner_attach = dtv5100_tuner_attach,
162
163 .stream = {
164 .type = USB_BULK,
165 .count = 8,
166 .endpoint = 0x82,
167 .u = {
168 .bulk = {
169 .buffersize = 4096,
170 }
171 }
172 },
173 } },
174
175 .i2c_algo = &dtv5100_i2c_algo,
176
177 .num_device_descs = 1,
178 .devices = {
179 {
180 .name = "AME DTV-5100 USB2.0 DVB-T",
181 .cold_ids = { NULL },
182 .warm_ids = { &dtv5100_table[0], NULL },
183 },
184 }
185};
186
187static struct usb_driver dtv5100_driver = {
188 .name = "dvb_usb_dtv5100",
189 .probe = dtv5100_probe,
190 .disconnect = dvb_usb_device_exit,
191 .id_table = dtv5100_table,
192};
193
194/* module stuff */
195static int __init dtv5100_module_init(void)
196{
197 int ret;
198
199 ret = usb_register(&dtv5100_driver);
200 if (ret)
201 err("usb_register failed. Error number %d", ret);
202
203 return ret;
204}
205
206static void __exit dtv5100_module_exit(void)
207{
208 /* deregister this driver from the USB subsystem */
209 usb_deregister(&dtv5100_driver);
210}
211
212module_init(dtv5100_module_init);
213module_exit(dtv5100_module_exit);
214
215MODULE_AUTHOR(DRIVER_AUTHOR);
216MODULE_DESCRIPTION(DRIVER_DESC);
217MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dtv5100.h b/drivers/media/dvb/dvb-usb/dtv5100.h
new file mode 100644
index 000000000000..1aadb86f70e6
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dtv5100.h
@@ -0,0 +1,128 @@
1/*
2 * DVB USB Linux driver for AME DTV-5100 USB2.0 DVB-T
3 *
4 * Copyright (C) 2008 Antoine Jacquet <royale@zerezo.com>
5 * http://royale.zerezo.com/dtv5100/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef _DVB_USB_DTV5100_H_
23#define _DVB_USB_DTV5100_H_
24
25#define DVB_USB_LOG_PREFIX "dtv5100"
26#include "dvb-usb.h"
27
28#define DTV5100_USB_TIMEOUT 500
29#define DTV5100_I2C_WRITE 0xc7
30#define DTV5100_I2C_READ 0xc8
31
32#define DRIVER_AUTHOR "Antoine Jacquet, http://royale.zerezo.com/"
33#define DRIVER_DESC "AME DTV-5100 USB2.0 DVB-T"
34
35static struct {
36 u8 request;
37 u8 value;
38 u16 index;
39} dtv5100_init[] = {
40 { 0x000000c5, 0x00000000, 0x00000001 },
41 { 0x000000c5, 0x00000001, 0x00000001 },
42 { 0x000000c0, 0x0000000b, 0x00000050 },
43 { 0x000000c0, 0x00000044, 0x00000051 },
44 { 0x000000c0, 0x00000046, 0x00000052 },
45 { 0x000000c0, 0x00000015, 0x00000053 },
46 { 0x000000c0, 0x0000000f, 0x00000054 },
47 { 0x000000c0, 0x00000080, 0x00000055 },
48 { 0x000000c0, 0x00000001, 0x000000ea },
49 { 0x000000c0, 0x00000000, 0x000000ea },
50 { 0x000000c0, 0x00000075, 0x0000005c },
51 { 0x000000c0, 0x000000a1, 0x0000009c },
52 { 0x000000c0, 0x00000000, 0x0000008e },
53 { 0x000000c0, 0x00000000, 0x00000090 },
54 { 0x000000c0, 0x000000ff, 0x00000091 },
55 { 0x000000c0, 0x000000ff, 0x00000092 },
56 { 0x000000c0, 0x00000000, 0x00000093 },
57 { 0x000000c0, 0x000000ff, 0x00000094 },
58 { 0x000000c0, 0x00000000, 0x00000058 },
59 { 0x000000c0, 0x0000003f, 0x00000095 },
60 { 0x000000c0, 0x0000003f, 0x00000096 },
61 { 0x000000c0, 0x0000000c, 0x0000005a },
62 { 0x000000c0, 0x0000002b, 0x00000056 },
63 { 0x000000c0, 0x00000017, 0x0000005f },
64 { 0x000000c0, 0x00000040, 0x0000005e },
65 { 0x000000c0, 0x00000036, 0x00000064 },
66 { 0x000000c0, 0x00000067, 0x00000065 },
67 { 0x000000c0, 0x000000e5, 0x00000066 },
68 { 0x000000c0, 0x00000073, 0x000000cc },
69 { 0x000000c0, 0x000000cd, 0x0000006c },
70 { 0x000000c0, 0x0000007e, 0x0000006d },
71 { 0x000000c0, 0x00000001, 0x00000071 },
72 { 0x000000c0, 0x00000001, 0x00000070 },
73 /**/
74 { 0x000000c7, 0x00000080, 0x0000c401 },
75 { 0x000000c7, 0x0000003f, 0x0000c402 },
76 { 0x000000c7, 0x00000034, 0x0000c405 }, // 2
77 { 0x000000c7, 0x00000044, 0x0000c406 },
78 { 0x000000c7, 0x00000038, 0x0000c407 }, // 4
79 { 0x000000c7, 0x00000008, 0x0000c408 },
80 { 0x000000c7, 0x0000001c, 0x0000c409 }, // 6
81 { 0x000000c7, 0x0000000d, 0x0000c40a }, // 7
82 { 0x000000c7, 0x00000045, 0x0000c40b }, // 8
83 { 0x000000c7, 0x000000e1, 0x0000c40c },
84 { 0x000000c7, 0x00000078, 0x0000c41a }, // 10
85 { 0x000000c7, 0x00000000, 0x0000c41b },
86 { 0x000000c7, 0x00000089, 0x0000c41c },
87 { 0x000000c7, 0x000000fd, 0x0000c411 }, // 13
88 { 0x000000c7, 0x00000095, 0x0000c412 }, // 14
89 { 0x000000c7, 0x000000d6, 0x0000c422 }, // 15
90 { 0x000000c7, 0x00000000, 0x0000c41e },
91 { 0x000000c7, 0x000000d0, 0x0000c41e },
92 { 0x000000c8, 0x00000000, 0x0000c422 },
93 { 0x000000c7, 0x00000000, 0x0000c41e },
94 { 0x000000c8, 0x00000000, 0x0000c405 },
95 { 0x000000c8, 0x00000000, 0x0000c422 },
96 { 0x000000c7, 0x000000d0, 0x0000c423 },
97 { 0x000000c7, 0x00000000, 0x0000c41e },
98 { 0x000000c7, 0x000000e0, 0x0000c41e },
99 { 0x000000c8, 0x00000000, 0x0000c423 },
100 { 0x000000c8, 0x00000000, 0x0000c423 },
101 { 0x000000c7, 0x00000000, 0x0000c41e },
102 { 0x000000c7, 0x000000d0, 0x0000c424 },
103 { 0x000000c7, 0x00000000, 0x0000c41e },
104 { 0x000000c7, 0x000000f0, 0x0000c41e },
105 { 0x000000c8, 0x00000000, 0x0000c424 },
106 { 0x000000c7, 0x00000000, 0x0000c41e },
107 { 0x000000c7, 0x0000007f, 0x0000c414 },
108 { 0x000000c7, 0x0000007f, 0x0000c415 },
109 { 0x000000c7, 0x00000030, 0x0000c405 },
110 { 0x000000c7, 0x00000000, 0x0000c406 },
111 { 0x000000c7, 0x0000001f, 0x0000c415 },
112 { 0x000000c7, 0x000000ff, 0x0000c416 },
113 { 0x000000c7, 0x000000ff, 0x0000c418 },
114 { 0x000000c7, 0x00000051, 0x0000c41f }, // here
115 { 0x000000c7, 0x00000016, 0x0000c420 }, // here
116 { 0x000000c7, 0x00000053, 0x0000c421 },
117 { 0x000000c7, 0x000000c1, 0x0000c425 }, // here
118 { 0x000000c7, 0x00000014, 0x0000c426 }, // here
119 { 0x000000c7, 0x00000082, 0x0000c400 },
120 { 0x000000c7, 0x00000000, 0x0000c402 },
121 { 0x000000c7, 0x00000000, 0x0000c401 },
122 /**/
123 { } /* Terminating entry */
124};
125
126extern struct dvb_frontend* dtv5100_fe_attach(void);
127
128#endif