aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAntoine Jacquet <royale@zerezo.com>2008-08-11 18:21:33 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:36:51 -0400
commit60688d5e6e6e2ae62f29762d1e3b2aec2dbd3817 (patch)
treee64abbc907a0c4aa1637db6d60463c8869907964 /drivers
parent8466028be7926679ff794ec2ed7a8938eafba521 (diff)
V4L/DVB (8735): dtv5100: replace dummy frontend by zl10353
Remove the dtv5100-fe.c dummy frontend and replace it by the real frontend for the chipset. Signed-off-by: Antoine Jacquet <royale@zerezo.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile2
-rw-r--r--drivers/media/dvb/dvb-usb/dtv5100-fe.c147
-rw-r--r--drivers/media/dvb/dvb-usb/dtv5100.c94
-rw-r--r--drivers/media/dvb/dvb-usb/dtv5100.h91
4 files changed, 68 insertions, 266 deletions
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 5e170fba1092..116544f4272d 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -67,7 +67,7 @@ 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 70dvb-usb-dtv5100-objs = dtv5100.o
71obj-$(CONFIG_DVB_USB_DTV5100) += dvb-usb-dtv5100.o 71obj-$(CONFIG_DVB_USB_DTV5100) += dvb-usb-dtv5100.o
72 72
73EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 73EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/dvb-usb/dtv5100-fe.c b/drivers/media/dvb/dvb-usb/dtv5100-fe.c
deleted file mode 100644
index 08fe33bcc5d6..000000000000
--- a/drivers/media/dvb/dvb-usb/dtv5100-fe.c
+++ /dev/null
@@ -1,147 +0,0 @@
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
index f89d01755eab..7168a49cecf4 100644
--- a/drivers/media/dvb/dvb-usb/dtv5100.c
+++ b/drivers/media/dvb/dvb-usb/dtv5100.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include "dtv5100.h" 24#include "dtv5100.h"
25#include "zl10353.h"
25#include "qt1010.h" 26#include "qt1010.h"
26 27
27/* debug */ 28/* debug */
@@ -30,25 +31,44 @@ module_param_named(debug, dvb_usb_dtv5100_debug, int, 0644);
30MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); 31MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
31DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 32DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
32 33
33static int dtv5100_read_reg(struct dvb_usb_device *d, u8 addr, u8 reg, u8 *value) 34static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
35 u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
34{ 36{
35 return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), 37 u8 request;
36 DTV5100_I2C_READ, USB_TYPE_VENDOR|USB_DIR_IN, 38 u8 type;
37 0, (addr << 8) + reg, value, 1, 39 u16 value;
38 DTV5100_USB_TIMEOUT); 40 u16 index;
39} 41
42 switch (wlen) {
43 case 1:
44 /* write { reg }, read { value } */
45 request = (addr == DTV5100_DEMOD_ADDR ? DTV5100_DEMOD_READ :
46 DTV5100_TUNER_READ);
47 type = USB_TYPE_VENDOR|USB_DIR_IN;
48 value = 0;
49 break;
50 case 2:
51 /* write { reg, value } */
52 request = (addr == DTV5100_DEMOD_ADDR ? DTV5100_DEMOD_WRITE :
53 DTV5100_TUNER_WRITE);
54 type = USB_TYPE_VENDOR|USB_DIR_OUT;
55 value = wbuf[1];
56 break;
57 default:
58 warn("wlen = %x, aborting.", wlen);
59 return -EINVAL;
60 }
61 index = (addr << 8) + wbuf[0];
40 62
41static int dtv5100_write_reg(struct dvb_usb_device *d, u8 addr, u8 reg, u8 value) 63 msleep(1); /* avoid I2C errors */
42{ 64 return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), request,
43 return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), 65 type, value, index, rbuf, rlen,
44 DTV5100_I2C_WRITE, USB_TYPE_VENDOR|USB_DIR_OUT,
45 value, (addr << 8) + reg, NULL, 0,
46 DTV5100_USB_TIMEOUT); 66 DTV5100_USB_TIMEOUT);
47} 67}
48 68
49/* I2C */ 69/* I2C */
50static int dtv5100_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], 70static int dtv5100_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
51 int num) 71 int num)
52{ 72{
53 struct dvb_usb_device *d = i2c_get_adapdata(adap); 73 struct dvb_usb_device *d = i2c_get_adapdata(adap);
54 int i; 74 int i;
@@ -60,25 +80,16 @@ static int dtv5100_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
60 return -EAGAIN; 80 return -EAGAIN;
61 81
62 for (i = 0; i < num; i++) { 82 for (i = 0; i < num; i++) {
83 /* write/read request */
63 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { 84 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
64 /* write/read request, 2 messages 85 if (dtv5100_i2c_msg(d, msg[i].addr, msg[i].buf,
65 * msg = { 86 msg[i].len, msg[i+1].buf,
66 * { reg }, 87 msg[i+1].len) < 0)
67 * { val },
68 * }
69 */
70 if (dtv5100_read_reg(d, msg[i].addr, msg[i].buf[0], msg[i+1].buf) < 0)
71 break; 88 break;
72 i++; 89 i++;
73 } else { 90 } else if (dtv5100_i2c_msg(d, msg[i].addr, msg[i].buf,
74 /* write request, 1 message 91 msg[i].len, NULL, 0) < 0)
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; 92 break;
81 }
82 } 93 }
83 94
84 mutex_unlock(&d->i2c_mutex); 95 mutex_unlock(&d->i2c_mutex);
@@ -96,14 +107,27 @@ static struct i2c_algorithm dtv5100_i2c_algo = {
96}; 107};
97 108
98/* Callbacks for DVB USB */ 109/* Callbacks for DVB USB */
110static struct zl10353_config dtv5100_zl10353_config = {
111 .demod_address = DTV5100_DEMOD_ADDR,
112 .no_tuner = 1,
113 .parallel_ts = 1,
114};
115
99static int dtv5100_frontend_attach(struct dvb_usb_adapter *adap) 116static int dtv5100_frontend_attach(struct dvb_usb_adapter *adap)
100{ 117{
101 adap->fe = dtv5100_fe_attach(); 118 adap->fe = dvb_attach(zl10353_attach, &dtv5100_zl10353_config,
119 &adap->dev->i2c_adap);
120 if (adap->fe == NULL)
121 return -EIO;
122
123 /* disable i2c gate, or it won't work... is this safe? */
124 adap->fe->ops.i2c_gate_ctrl = NULL;
125
102 return 0; 126 return 0;
103} 127}
104 128
105static struct qt1010_config dtv5100_qt1010_config = { 129static struct qt1010_config dtv5100_qt1010_config = {
106 .i2c_address = 0xc4 130 .i2c_address = DTV5100_TUNER_ADDR
107}; 131};
108 132
109static int dtv5100_tuner_attach(struct dvb_usb_adapter *adap) 133static int dtv5100_tuner_attach(struct dvb_usb_adapter *adap)
@@ -122,12 +146,7 @@ static int dtv5100_probe(struct usb_interface *intf,
122 int i, ret; 146 int i, ret;
123 struct usb_device *udev = interface_to_usbdev(intf); 147 struct usb_device *udev = interface_to_usbdev(intf);
124 148
125 ret = dvb_usb_device_init(intf, &dtv5100_properties, 149 /* initialize non qt1010/zl10353 part? */
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++) 150 for (i = 0; dtv5100_init[i].request; i++)
132 { 151 {
133 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 152 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
@@ -140,6 +159,11 @@ static int dtv5100_probe(struct usb_interface *intf,
140 return ret; 159 return ret;
141 } 160 }
142 161
162 ret = dvb_usb_device_init(intf, &dtv5100_properties,
163 THIS_MODULE, NULL, adapter_nr);
164 if (ret)
165 return ret;
166
143 return 0; 167 return 0;
144} 168}
145 169
diff --git a/drivers/media/dvb/dvb-usb/dtv5100.h b/drivers/media/dvb/dvb-usb/dtv5100.h
index 1aadb86f70e6..e36bf2d5c944 100644
--- a/drivers/media/dvb/dvb-usb/dtv5100.h
+++ b/drivers/media/dvb/dvb-usb/dtv5100.h
@@ -26,8 +26,14 @@
26#include "dvb-usb.h" 26#include "dvb-usb.h"
27 27
28#define DTV5100_USB_TIMEOUT 500 28#define DTV5100_USB_TIMEOUT 500
29#define DTV5100_I2C_WRITE 0xc7 29
30#define DTV5100_I2C_READ 0xc8 30#define DTV5100_DEMOD_ADDR 0x00
31#define DTV5100_DEMOD_WRITE 0xc0
32#define DTV5100_DEMOD_READ 0xc1
33
34#define DTV5100_TUNER_ADDR 0xc4
35#define DTV5100_TUNER_WRITE 0xc7
36#define DTV5100_TUNER_READ 0xc8
31 37
32#define DRIVER_AUTHOR "Antoine Jacquet, http://royale.zerezo.com/" 38#define DRIVER_AUTHOR "Antoine Jacquet, http://royale.zerezo.com/"
33#define DRIVER_DESC "AME DTV-5100 USB2.0 DVB-T" 39#define DRIVER_DESC "AME DTV-5100 USB2.0 DVB-T"
@@ -39,87 +45,6 @@ static struct {
39} dtv5100_init[] = { 45} dtv5100_init[] = {
40 { 0x000000c5, 0x00000000, 0x00000001 }, 46 { 0x000000c5, 0x00000000, 0x00000001 },
41 { 0x000000c5, 0x00000001, 0x00000001 }, 47 { 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 */ 48 { } /* Terminating entry */
124}; 49};
125 50