diff options
author | Alan Nisota <alannisota@gmail.com> | 2006-05-14 12:23:56 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-25 01:00:32 -0400 |
commit | 9bbe076f364aa7ba8c2e49e417a76d628ffb164c (patch) | |
tree | 895a6b68aadc353156bfc7aa6f9ae70fe1429dcb /drivers/media/dvb | |
parent | 6daa4f86e9a01da6296f4c2bf40f8180a22718a8 (diff) |
V4L/DVB (4029): [PATCH] Genpix 8PSK->USB driver (Take 2)
This is a patch which includes support for the GENPIX 8PSK->USB module. The
board supports QPSK, BPSK and 8PSK decoding (though I don't think it will be
DVB-S2 compliant) With the following patch, the boad is equivalent to a budget
card (no CA Module)
The patch which adds 8psk suppot will follow, but is seperate, as it requires
DVB-S2 support
More info on the board can be found at www.genpix-electronics.com (and they
host the requisite firmwares there as well)
Signed off by: Alan Nisota <alannisota@gmail.com>
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/Kconfig | 9 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/Makefile | 3 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 4 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/gp8psk-fe.c | 272 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/gp8psk.c | 254 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/gp8psk.h | 79 |
6 files changed, 620 insertions, 1 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index e388fb1567d6..5350e963c17b 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -130,6 +130,15 @@ config DVB_USB_VP702X | |||
130 | 130 | ||
131 | DVB-S USB2.0 receivers. | 131 | DVB-S USB2.0 receivers. |
132 | 132 | ||
133 | config DVB_USB_GP8PSK | ||
134 | tristate "GENPIX 8PSK->USB module support" | ||
135 | depends on DVB_USB | ||
136 | help | ||
137 | Say Y here to support the | ||
138 | GENPIX 8psk module | ||
139 | |||
140 | DVB-S USB2.0 receivers. | ||
141 | |||
133 | config DVB_USB_NOVA_T_USB2 | 142 | config DVB_USB_NOVA_T_USB2 |
134 | tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" | 143 | tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" |
135 | depends on DVB_USB | 144 | depends on DVB_USB |
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 2dc9aad9681e..9643f56c7fe9 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile | |||
@@ -7,6 +7,9 @@ obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o | |||
7 | dvb-usb-vp702x-objs = vp702x.o vp702x-fe.o | 7 | dvb-usb-vp702x-objs = vp702x.o vp702x-fe.o |
8 | obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o | 8 | obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o |
9 | 9 | ||
10 | dvb-usb-gp8psk-objs = gp8psk.o gp8psk-fe.o | ||
11 | obj-$(CONFIG_DVB_USB_GP8PSK) += dvb-usb-gp8psk.o | ||
12 | |||
10 | dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o | 13 | dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o |
11 | obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o | 14 | obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o |
12 | 15 | ||
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index cb239049b098..95698918bc11 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #define USB_VID_VISIONPLUS 0x13d3 | 31 | #define USB_VID_VISIONPLUS 0x13d3 |
32 | #define USB_VID_TWINHAN 0x1822 | 32 | #define USB_VID_TWINHAN 0x1822 |
33 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 | 33 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 |
34 | #define USB_VID_GENPIX 0x09c0 | ||
34 | 35 | ||
35 | /* Product IDs */ | 36 | /* Product IDs */ |
36 | #define USB_PID_ADSTECH_USB2_COLD 0xa333 | 37 | #define USB_PID_ADSTECH_USB2_COLD 0xa333 |
@@ -104,5 +105,6 @@ | |||
104 | #define USB_PID_KYE_DVB_T_WARM 0x701f | 105 | #define USB_PID_KYE_DVB_T_WARM 0x701f |
105 | #define USB_PID_PCTV_200E 0x020e | 106 | #define USB_PID_PCTV_200E 0x020e |
106 | #define USB_PID_PCTV_400E 0x020f | 107 | #define USB_PID_PCTV_400E 0x020f |
107 | 108 | #define USB_PID_GENPIX_8PSK_COLD 0x0200 | |
109 | #define USB_PID_GENPIX_8PSK_WARM 0x0201 | ||
108 | #endif | 110 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/gp8psk-fe.c b/drivers/media/dvb/dvb-usb/gp8psk-fe.c new file mode 100644 index 000000000000..6ccbdc9cd772 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/gp8psk-fe.c | |||
@@ -0,0 +1,272 @@ | |||
1 | /* DVB USB compliant Linux driver for the | ||
2 | * - GENPIX 8pks/qpsk USB2.0 DVB-S module | ||
3 | * | ||
4 | * Copyright (C) 2006 Alan Nisota (alannisota@gmail.com) | ||
5 | * | ||
6 | * Thanks to GENPIX for the sample code used to implement this module. | ||
7 | * | ||
8 | * This module is based off the vp7045 and vp702x modules | ||
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 "gp8psk.h" | ||
17 | |||
18 | struct gp8psk_fe_state { | ||
19 | struct dvb_frontend fe; | ||
20 | |||
21 | struct dvb_usb_device *d; | ||
22 | |||
23 | u16 snr; | ||
24 | |||
25 | unsigned long next_snr_check; | ||
26 | }; | ||
27 | |||
28 | static int gp8psk_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) | ||
29 | { | ||
30 | struct gp8psk_fe_state *st = fe->demodulator_priv; | ||
31 | u8 lock; | ||
32 | |||
33 | if (gp8psk_usb_in_op(st->d, GET_SIGNAL_LOCK, 0, 0, &lock,1)) | ||
34 | return -EINVAL; | ||
35 | |||
36 | if (lock) | ||
37 | *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; | ||
38 | else | ||
39 | *status = 0; | ||
40 | |||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | /* not supported by this Frontend */ | ||
45 | static int gp8psk_fe_read_ber(struct dvb_frontend* fe, u32 *ber) | ||
46 | { | ||
47 | (void) fe; | ||
48 | *ber = 0; | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | /* not supported by this Frontend */ | ||
53 | static int gp8psk_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) | ||
54 | { | ||
55 | (void) fe; | ||
56 | *unc = 0; | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | static int gp8psk_fe_read_snr(struct dvb_frontend* fe, u16 *snr) | ||
61 | { | ||
62 | struct gp8psk_fe_state *st = fe->demodulator_priv; | ||
63 | u8 buf[2]; | ||
64 | |||
65 | if (time_after(jiffies,st->next_snr_check)) { | ||
66 | gp8psk_usb_in_op(st->d,GET_SIGNAL_STRENGTH,0,0,buf,2); | ||
67 | *snr = (int)(buf[1]) << 8 | buf[0]; | ||
68 | /* snr is reported in dBu*256 */ | ||
69 | /* snr / 38.4 ~= 100% strength */ | ||
70 | /* snr * 17 returns 100% strength as 65535 */ | ||
71 | if (*snr <= 3855) | ||
72 | *snr = (*snr<<4) + *snr; // snr * 17 | ||
73 | else | ||
74 | *snr = 65535; | ||
75 | st->next_snr_check = jiffies + (10*HZ)/1000; | ||
76 | } else { | ||
77 | *snr = st->snr; | ||
78 | } | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static int gp8psk_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength) | ||
83 | { | ||
84 | return gp8psk_fe_read_snr(fe, strength); | ||
85 | } | ||
86 | |||
87 | static int gp8psk_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) | ||
88 | { | ||
89 | tune->min_delay_ms = 800; | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | static int gp8psk_fe_set_frontend(struct dvb_frontend* fe, | ||
94 | struct dvb_frontend_parameters *fep) | ||
95 | { | ||
96 | struct gp8psk_fe_state *state = fe->demodulator_priv; | ||
97 | u8 cmd[10]; | ||
98 | u32 freq = fep->frequency * 1000; | ||
99 | |||
100 | cmd[4] = freq & 0xff; | ||
101 | cmd[5] = (freq >> 8) & 0xff; | ||
102 | cmd[6] = (freq >> 16) & 0xff; | ||
103 | cmd[7] = (freq >> 24) & 0xff; | ||
104 | |||
105 | switch(fe->ops.info.type) { | ||
106 | case FE_QPSK: | ||
107 | cmd[0] = fep->u.qpsk.symbol_rate & 0xff; | ||
108 | cmd[1] = (fep->u.qpsk.symbol_rate >> 8) & 0xff; | ||
109 | cmd[2] = (fep->u.qpsk.symbol_rate >> 16) & 0xff; | ||
110 | cmd[3] = (fep->u.qpsk.symbol_rate >> 24) & 0xff; | ||
111 | cmd[8] = ADV_MOD_DVB_QPSK; | ||
112 | cmd[9] = 0x03; /*ADV_MOD_FEC_XXX*/ | ||
113 | break; | ||
114 | default: | ||
115 | // other modes are unsuported right now | ||
116 | cmd[0] = 0; | ||
117 | cmd[1] = 0; | ||
118 | cmd[2] = 0; | ||
119 | cmd[3] = 0; | ||
120 | cmd[8] = 0; | ||
121 | cmd[9] = 0; | ||
122 | break; | ||
123 | } | ||
124 | |||
125 | gp8psk_usb_out_op(state->d,TUNE_8PSK,0,0,cmd,10); | ||
126 | |||
127 | state->next_snr_check = jiffies; | ||
128 | |||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | static int gp8psk_fe_get_frontend(struct dvb_frontend* fe, | ||
133 | struct dvb_frontend_parameters *fep) | ||
134 | { | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | |||
139 | static int gp8psk_fe_send_diseqc_msg (struct dvb_frontend* fe, | ||
140 | struct dvb_diseqc_master_cmd *m) | ||
141 | { | ||
142 | struct gp8psk_fe_state *st = fe->demodulator_priv; | ||
143 | |||
144 | deb_fe("%s\n",__FUNCTION__); | ||
145 | |||
146 | if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, m->msg[0], 0, | ||
147 | m->msg, m->msg_len)) { | ||
148 | return -EINVAL; | ||
149 | } | ||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static int gp8psk_fe_send_diseqc_burst (struct dvb_frontend* fe, | ||
154 | fe_sec_mini_cmd_t burst) | ||
155 | { | ||
156 | struct gp8psk_fe_state *st = fe->demodulator_priv; | ||
157 | u8 cmd; | ||
158 | |||
159 | deb_fe("%s\n",__FUNCTION__); | ||
160 | |||
161 | /* These commands are certainly wrong */ | ||
162 | cmd = (burst == SEC_MINI_A) ? 0x00 : 0x01; | ||
163 | |||
164 | if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, cmd, 0, | ||
165 | &cmd, 0)) { | ||
166 | return -EINVAL; | ||
167 | } | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | static int gp8psk_fe_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | ||
172 | { | ||
173 | struct gp8psk_fe_state* state = fe->demodulator_priv; | ||
174 | |||
175 | if (gp8psk_usb_out_op(state->d,SET_22KHZ_TONE, | ||
176 | (tone == SEC_TONE_ON), 0, NULL, 0)) { | ||
177 | return -EINVAL; | ||
178 | } | ||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | static int gp8psk_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage) | ||
183 | { | ||
184 | struct gp8psk_fe_state* state = fe->demodulator_priv; | ||
185 | |||
186 | if (gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE, | ||
187 | voltage == SEC_VOLTAGE_18, 0, NULL, 0)) { | ||
188 | return -EINVAL; | ||
189 | } | ||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | static int gp8psk_fe_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long sw_cmd) | ||
194 | { | ||
195 | struct gp8psk_fe_state* state = fe->demodulator_priv; | ||
196 | u8 cmd = sw_cmd & 0x7f; | ||
197 | |||
198 | if (gp8psk_usb_out_op(state->d,SET_DN_SWITCH, cmd, 0, | ||
199 | NULL, 0)) { | ||
200 | return -EINVAL; | ||
201 | } | ||
202 | if (gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE, !!(sw_cmd & 0x80), | ||
203 | 0, NULL, 0)) { | ||
204 | return -EINVAL; | ||
205 | } | ||
206 | |||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | static void gp8psk_fe_release(struct dvb_frontend* fe) | ||
211 | { | ||
212 | struct gp8psk_fe_state *state = fe->demodulator_priv; | ||
213 | kfree(state); | ||
214 | } | ||
215 | |||
216 | static struct dvb_frontend_ops gp8psk_fe_ops; | ||
217 | |||
218 | struct dvb_frontend * gp8psk_fe_attach(struct dvb_usb_device *d) | ||
219 | { | ||
220 | struct gp8psk_fe_state *s = kzalloc(sizeof(struct gp8psk_fe_state), GFP_KERNEL); | ||
221 | if (s == NULL) | ||
222 | goto error; | ||
223 | |||
224 | s->d = d; | ||
225 | memcpy(&s->fe.ops, &gp8psk_fe_ops, sizeof(struct dvb_frontend_ops)); | ||
226 | s->fe.demodulator_priv = s; | ||
227 | |||
228 | goto success; | ||
229 | error: | ||
230 | return NULL; | ||
231 | success: | ||
232 | return &s->fe; | ||
233 | } | ||
234 | |||
235 | |||
236 | static struct dvb_frontend_ops gp8psk_fe_ops = { | ||
237 | .info = { | ||
238 | .name = "Genpix 8psk-USB DVB-S", | ||
239 | .type = FE_QPSK, | ||
240 | .frequency_min = 950000, | ||
241 | .frequency_max = 2150000, | ||
242 | .frequency_stepsize = 100, | ||
243 | .symbol_rate_min = 1000000, | ||
244 | .symbol_rate_max = 45000000, | ||
245 | .symbol_rate_tolerance = 500, /* ppm */ | ||
246 | .caps = FE_CAN_INVERSION_AUTO | | ||
247 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | | ||
248 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | | ||
249 | FE_CAN_QPSK | ||
250 | }, | ||
251 | |||
252 | .release = gp8psk_fe_release, | ||
253 | |||
254 | .init = NULL, | ||
255 | .sleep = NULL, | ||
256 | |||
257 | .set_frontend = gp8psk_fe_set_frontend, | ||
258 | .get_frontend = gp8psk_fe_get_frontend, | ||
259 | .get_tune_settings = gp8psk_fe_get_tune_settings, | ||
260 | |||
261 | .read_status = gp8psk_fe_read_status, | ||
262 | .read_ber = gp8psk_fe_read_ber, | ||
263 | .read_signal_strength = gp8psk_fe_read_signal_strength, | ||
264 | .read_snr = gp8psk_fe_read_snr, | ||
265 | .read_ucblocks = gp8psk_fe_read_unc_blocks, | ||
266 | |||
267 | .diseqc_send_master_cmd = gp8psk_fe_send_diseqc_msg, | ||
268 | .diseqc_send_burst = gp8psk_fe_send_diseqc_burst, | ||
269 | .set_tone = gp8psk_fe_set_tone, | ||
270 | .set_voltage = gp8psk_fe_set_voltage, | ||
271 | .dishnetwork_send_legacy_command = gp8psk_fe_send_legacy_dish_cmd, | ||
272 | }; | ||
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c new file mode 100644 index 000000000000..d6771cbd262d --- /dev/null +++ b/drivers/media/dvb/dvb-usb/gp8psk.c | |||
@@ -0,0 +1,254 @@ | |||
1 | /* DVB USB compliant Linux driver for the | ||
2 | * - GENPIX 8pks/qpsk USB2.0 DVB-S module | ||
3 | * | ||
4 | * Copyright (C) 2006 Alan Nisota (alannisota@gmail.com) | ||
5 | * | ||
6 | * Thanks to GENPIX for the sample code used to implement this module. | ||
7 | * | ||
8 | * This module is based off the vp7045 and vp702x modules | ||
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 "gp8psk.h" | ||
17 | |||
18 | /* debug */ | ||
19 | static char bcm4500_firmware[] = "dvb-usb-gp8psk-02.fw"; | ||
20 | int dvb_usb_gp8psk_debug; | ||
21 | module_param_named(debug,dvb_usb_gp8psk_debug, int, 0644); | ||
22 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); | ||
23 | |||
24 | int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) | ||
25 | { | ||
26 | int ret = 0,try = 0; | ||
27 | |||
28 | if ((ret = mutex_lock_interruptible(&d->usb_mutex))) | ||
29 | return ret; | ||
30 | |||
31 | while (ret >= 0 && ret != blen && try < 3) { | ||
32 | ret = usb_control_msg(d->udev, | ||
33 | usb_rcvctrlpipe(d->udev,0), | ||
34 | req, | ||
35 | USB_TYPE_VENDOR | USB_DIR_IN, | ||
36 | value,index,b,blen, | ||
37 | 2000); | ||
38 | deb_info("reading number %d (ret: %d)\n",try,ret); | ||
39 | try++; | ||
40 | } | ||
41 | |||
42 | if (ret < 0 || ret != blen) { | ||
43 | warn("usb in operation failed."); | ||
44 | ret = -EIO; | ||
45 | } else | ||
46 | ret = 0; | ||
47 | |||
48 | deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index); | ||
49 | debug_dump(b,blen,deb_xfer); | ||
50 | |||
51 | mutex_unlock(&d->usb_mutex); | ||
52 | |||
53 | return ret; | ||
54 | } | ||
55 | |||
56 | int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, | ||
57 | u16 index, u8 *b, int blen) | ||
58 | { | ||
59 | int ret; | ||
60 | |||
61 | deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); | ||
62 | debug_dump(b,blen,deb_xfer); | ||
63 | |||
64 | if ((ret = mutex_lock_interruptible(&d->usb_mutex))) | ||
65 | return ret; | ||
66 | |||
67 | if (usb_control_msg(d->udev, | ||
68 | usb_sndctrlpipe(d->udev,0), | ||
69 | req, | ||
70 | USB_TYPE_VENDOR | USB_DIR_OUT, | ||
71 | value,index,b,blen, | ||
72 | 2000) != blen) { | ||
73 | warn("usb out operation failed."); | ||
74 | ret = -EIO; | ||
75 | } else | ||
76 | ret = 0; | ||
77 | mutex_unlock(&d->usb_mutex); | ||
78 | |||
79 | return ret; | ||
80 | } | ||
81 | |||
82 | static int gp8psk_load_bcm4500fw(struct dvb_usb_device *d) | ||
83 | { | ||
84 | int ret; | ||
85 | const struct firmware *fw = NULL; | ||
86 | u8 *ptr, *buf; | ||
87 | if ((ret = request_firmware(&fw, bcm4500_firmware, | ||
88 | &d->udev->dev)) != 0) { | ||
89 | err("did not find the bcm4500 firmware file. (%s) " | ||
90 | "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)", | ||
91 | bcm4500_firmware,ret); | ||
92 | return ret; | ||
93 | } | ||
94 | |||
95 | if (gp8psk_usb_out_op(d, LOAD_BCM4500,1,0,NULL, 0)) { | ||
96 | release_firmware(fw); | ||
97 | return -EINVAL; | ||
98 | } | ||
99 | |||
100 | info("downloaidng bcm4500 firmware from file '%s'",bcm4500_firmware); | ||
101 | |||
102 | ptr = fw->data; | ||
103 | buf = (u8 *) kmalloc(512, GFP_KERNEL | GFP_DMA); | ||
104 | |||
105 | while (ptr[0] != 0xff) { | ||
106 | u16 buflen = ptr[0] + 4; | ||
107 | if (ptr + buflen >= fw->data + fw->size) { | ||
108 | err("failed to load bcm4500 firmware."); | ||
109 | release_firmware(fw); | ||
110 | kfree(buf); | ||
111 | return -EINVAL; | ||
112 | } | ||
113 | memcpy(buf, ptr, buflen); | ||
114 | if (dvb_usb_generic_write(d, buf, buflen)) { | ||
115 | err("failed to load bcm4500 firmware."); | ||
116 | release_firmware(fw); | ||
117 | kfree(buf); | ||
118 | return -EIO; | ||
119 | } | ||
120 | ptr += buflen; | ||
121 | } | ||
122 | release_firmware(fw); | ||
123 | kfree(buf); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static int gp8psk_power_ctrl(struct dvb_usb_device *d, int onoff) | ||
128 | { | ||
129 | u8 status, buf; | ||
130 | if (onoff) { | ||
131 | gp8psk_usb_in_op(d, GET_8PSK_CONFIG,0,0,&status,1); | ||
132 | if (! (status & 0x01)) /* started */ | ||
133 | if (gp8psk_usb_in_op(d, BOOT_8PSK, 1, 0, &buf, 1)) | ||
134 | return -EINVAL; | ||
135 | |||
136 | if (! (status & 0x02)) /* BCM4500 firmware loaded */ | ||
137 | if(gp8psk_load_bcm4500fw(d)) | ||
138 | return EINVAL; | ||
139 | |||
140 | if (! (status & 0x04)) /* LNB Power */ | ||
141 | if (gp8psk_usb_in_op(d, START_INTERSIL, 1, 0, | ||
142 | &buf, 1)) | ||
143 | return EINVAL; | ||
144 | |||
145 | /* Set DVB mode */ | ||
146 | if(gp8psk_usb_out_op(d, SET_DVB_MODE, 1, 0, NULL, 0)) | ||
147 | return -EINVAL; | ||
148 | gp8psk_usb_in_op(d, GET_8PSK_CONFIG,0,0,&status,1); | ||
149 | } else { | ||
150 | /* Turn off LNB power */ | ||
151 | if (gp8psk_usb_in_op(d, START_INTERSIL, 0, 0, &buf, 1)) | ||
152 | return EINVAL; | ||
153 | /* Turn off 8psk power */ | ||
154 | if (gp8psk_usb_in_op(d, BOOT_8PSK, 0, 0, &buf, 1)) | ||
155 | return -EINVAL; | ||
156 | |||
157 | } | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | |||
162 | static int gp8psk_streaming_ctrl(struct dvb_usb_device *d, int onoff) | ||
163 | { | ||
164 | return gp8psk_usb_out_op(d, ARM_TRANSFER, onoff, 0 , NULL, 0); | ||
165 | } | ||
166 | |||
167 | static int gp8psk_frontend_attach(struct dvb_usb_device *d) | ||
168 | { | ||
169 | d->fe = gp8psk_fe_attach(d); | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static struct dvb_usb_properties gp8psk_properties; | ||
175 | |||
176 | static int gp8psk_usb_probe(struct usb_interface *intf, | ||
177 | const struct usb_device_id *id) | ||
178 | { | ||
179 | return dvb_usb_device_init(intf,&gp8psk_properties,THIS_MODULE,NULL); | ||
180 | } | ||
181 | |||
182 | static struct usb_device_id gp8psk_usb_table [] = { | ||
183 | { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_8PSK_COLD) }, | ||
184 | { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_8PSK_WARM) }, | ||
185 | { 0 }, | ||
186 | }; | ||
187 | MODULE_DEVICE_TABLE(usb, gp8psk_usb_table); | ||
188 | |||
189 | static struct dvb_usb_properties gp8psk_properties = { | ||
190 | .caps = 0, | ||
191 | |||
192 | .usb_ctrl = CYPRESS_FX2, | ||
193 | .firmware = "dvb-usb-gp8psk-01.fw", | ||
194 | |||
195 | .streaming_ctrl = gp8psk_streaming_ctrl, | ||
196 | .power_ctrl = gp8psk_power_ctrl, | ||
197 | .frontend_attach = gp8psk_frontend_attach, | ||
198 | |||
199 | .generic_bulk_ctrl_endpoint = 0x01, | ||
200 | /* parameter for the MPEG2-data transfer */ | ||
201 | .urb = { | ||
202 | .type = DVB_USB_BULK, | ||
203 | .count = 7, | ||
204 | .endpoint = 0x82, | ||
205 | .u = { | ||
206 | .bulk = { | ||
207 | .buffersize = 8192, | ||
208 | } | ||
209 | } | ||
210 | }, | ||
211 | |||
212 | .num_device_descs = 1, | ||
213 | .devices = { | ||
214 | { .name = "Genpix 8PSK-USB DVB-S USB2.0 receiver", | ||
215 | .cold_ids = { &gp8psk_usb_table[0], NULL }, | ||
216 | .warm_ids = { &gp8psk_usb_table[1], NULL }, | ||
217 | }, | ||
218 | { 0 }, | ||
219 | } | ||
220 | }; | ||
221 | |||
222 | /* usb specific object needed to register this driver with the usb subsystem */ | ||
223 | static struct usb_driver gp8psk_usb_driver = { | ||
224 | .name = "dvb_usb_gp8psk", | ||
225 | .probe = gp8psk_usb_probe, | ||
226 | .disconnect = dvb_usb_device_exit, | ||
227 | .id_table = gp8psk_usb_table, | ||
228 | }; | ||
229 | |||
230 | /* module stuff */ | ||
231 | static int __init gp8psk_usb_module_init(void) | ||
232 | { | ||
233 | int result; | ||
234 | if ((result = usb_register(&gp8psk_usb_driver))) { | ||
235 | err("usb_register failed. (%d)",result); | ||
236 | return result; | ||
237 | } | ||
238 | |||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static void __exit gp8psk_usb_module_exit(void) | ||
243 | { | ||
244 | /* deregister this driver from the USB subsystem */ | ||
245 | usb_deregister(&gp8psk_usb_driver); | ||
246 | } | ||
247 | |||
248 | module_init(gp8psk_usb_module_init); | ||
249 | module_exit(gp8psk_usb_module_exit); | ||
250 | |||
251 | MODULE_AUTHOR("Alan Nisota <alannisota@gamil.com>"); | ||
252 | MODULE_DESCRIPTION("Driver for Genpix 8psk-USB DVB-S USB2.0"); | ||
253 | MODULE_VERSION("1.0"); | ||
254 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.h b/drivers/media/dvb/dvb-usb/gp8psk.h new file mode 100644 index 000000000000..3eba7061011c --- /dev/null +++ b/drivers/media/dvb/dvb-usb/gp8psk.h | |||
@@ -0,0 +1,79 @@ | |||
1 | /* DVB USB compliant Linux driver for the | ||
2 | * - GENPIX 8pks/qpsk USB2.0 DVB-S module | ||
3 | * | ||
4 | * Copyright (C) 2006 Alan Nisota (alannisota@gmail.com) | ||
5 | * | ||
6 | * Thanks to GENPIX for the sample code used to implement this module. | ||
7 | * | ||
8 | * This module is based off the vp7045 and vp702x modules | ||
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 | #ifndef _DVB_USB_GP8PSK_H_ | ||
17 | #define _DVB_USB_GP8PSK_H_ | ||
18 | |||
19 | #define DVB_USB_LOG_PREFIX "gp8psk" | ||
20 | #include "dvb-usb.h" | ||
21 | |||
22 | extern int dvb_usb_gp8psk_debug; | ||
23 | #define deb_info(args...) dprintk(dvb_usb_gp8psk_debug,0x01,args) | ||
24 | #define deb_xfer(args...) dprintk(dvb_usb_gp8psk_debug,0x02,args) | ||
25 | #define deb_rc(args...) dprintk(dvb_usb_gp8psk_debug,0x04,args) | ||
26 | #define deb_fe(args...) dprintk(dvb_usb_gp8psk_debug,0x08,args) | ||
27 | /* gp8psk commands */ | ||
28 | |||
29 | /* Twinhan Vendor requests */ | ||
30 | #define TH_COMMAND_IN 0xC0 | ||
31 | #define TH_COMMAND_OUT 0xC1 | ||
32 | |||
33 | /* command bytes */ | ||
34 | #define GET_8PSK_CONFIG 0x80 | ||
35 | #define SET_8PSK_CONFIG 0x81 | ||
36 | #define ARM_TRANSFER 0x85 | ||
37 | #define TUNE_8PSK 0x86 | ||
38 | #define GET_SIGNAL_STRENGTH 0x87 | ||
39 | #define LOAD_BCM4500 0x88 | ||
40 | #define BOOT_8PSK 0x89 | ||
41 | #define START_INTERSIL 0x8A | ||
42 | #define SET_LNB_VOLTAGE 0x8B | ||
43 | #define SET_22KHZ_TONE 0x8C | ||
44 | #define SEND_DISEQC_COMMAND 0x8D | ||
45 | #define SET_DVB_MODE 0x8E | ||
46 | #define SET_DN_SWITCH 0x8F | ||
47 | #define GET_SIGNAL_LOCK 0x90 | ||
48 | |||
49 | /* Satellite modulation modes */ | ||
50 | #define ADV_MOD_DVB_QPSK 0 /* DVB-S QPSK */ | ||
51 | #define ADV_MOD_TURBO_QPSK 1 /* Turbo QPSK */ | ||
52 | #define ADV_MOD_TURBO_8PSK 2 /* Turbo 8PSK (also used for Trellis 8PSK) */ | ||
53 | #define ADV_MOD_TURBO_16QAM 3 /* Turbo 16QAM (also used for Trellis 8PSK) */ | ||
54 | |||
55 | #define ADV_MOD_DCII_C_QPSK 4 /* Digicipher II Combo */ | ||
56 | #define ADV_MOD_DCII_I_QPSK 5 /* Digicipher II I-stream */ | ||
57 | #define ADV_MOD_DCII_Q_QPSK 6 /* Digicipher II Q-stream */ | ||
58 | #define ADV_MOD_DCII_C_OQPSK 7 /* Digicipher II offset QPSK */ | ||
59 | #define ADV_MOD_DSS_QPSK 8 /* DSS (DIRECTV) QPSK */ | ||
60 | #define ADV_MOD_DVB_BPSK 9 /* DVB-S BPSK */ | ||
61 | |||
62 | #define GET_USB_SPEED 0x07 | ||
63 | #define USB_SPEED_LOW 0 | ||
64 | #define USB_SPEED_FULL 1 | ||
65 | #define USB_SPEED_HIGH 2 | ||
66 | |||
67 | #define RESET_FX2 0x13 | ||
68 | |||
69 | #define FW_VERSION_READ 0x0B | ||
70 | #define VENDOR_STRING_READ 0x0C | ||
71 | #define PRODUCT_STRING_READ 0x0D | ||
72 | #define FW_BCD_VERSION_READ 0x14 | ||
73 | |||
74 | extern struct dvb_frontend * gp8psk_fe_attach(struct dvb_usb_device *d); | ||
75 | extern int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); | ||
76 | extern int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, | ||
77 | u16 index, u8 *b, int blen); | ||
78 | |||
79 | #endif | ||