aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/gp8psk-fe.c
diff options
context:
space:
mode:
authorAlan Nisota <alannisota@gmail.com>2007-08-18 16:52:35 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:05:22 -0400
commit458b634cd86968032171a4d6db5c89a772ff0348 (patch)
tree420b1a0933457e5910f2bcee542cc77e4aef5ee3 /drivers/media/dvb/dvb-usb/gp8psk-fe.c
parentfa40b2237ab6ed239967f76432438080232b88fe (diff)
V4L/DVB (6037): Updated GenPix USB driver
There are now 4 different versions of the GENPIX USB adapter. The newest 'Skywalker' models are fully self-contained, and need no additional hardware to be used. A very reliable DVB-S card even without using any of the alternate modulatations (which this kernel module does not currently support) The following patch adds support for all 4 versions of the genpix adapter (www.genpix-electronics.com). 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/dvb-usb/gp8psk-fe.c')
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk-fe.c84
1 files changed, 51 insertions, 33 deletions
diff --git a/drivers/media/dvb/dvb-usb/gp8psk-fe.c b/drivers/media/dvb/dvb-usb/gp8psk-fe.c
index 6ccbdc9cd772..e37142d9271a 100644
--- a/drivers/media/dvb/dvb-usb/gp8psk-fe.c
+++ b/drivers/media/dvb/dvb-usb/gp8psk-fe.c
@@ -1,7 +1,8 @@
1/* DVB USB compliant Linux driver for the 1/* DVB USB compliant Linux driver for the
2 * - GENPIX 8pks/qpsk USB2.0 DVB-S module 2 * - GENPIX 8pks/qpsk/DCII USB2.0 DVB-S module
3 * 3 *
4 * Copyright (C) 2006 Alan Nisota (alannisota@gmail.com) 4 * Copyright (C) 2006,2007 Alan Nisota (alannisota@gmail.com)
5 * Copyright (C) 2006,2007 Genpix Electronics (genpix@genpix-electronics.com)
5 * 6 *
6 * Thanks to GENPIX for the sample code used to implement this module. 7 * Thanks to GENPIX for the sample code used to implement this module.
7 * 8 *
@@ -17,27 +18,39 @@
17 18
18struct gp8psk_fe_state { 19struct gp8psk_fe_state {
19 struct dvb_frontend fe; 20 struct dvb_frontend fe;
20
21 struct dvb_usb_device *d; 21 struct dvb_usb_device *d;
22 22 u8 lock;
23 u16 snr; 23 u16 snr;
24 24 unsigned long next_status_check;
25 unsigned long next_snr_check; 25 unsigned long status_check_interval;
26}; 26};
27 27
28static int gp8psk_fe_update_status(struct gp8psk_fe_state *st)
29{
30 u8 buf[6];
31 if (time_after(jiffies,st->next_status_check)) {
32 gp8psk_usb_in_op(st->d, GET_SIGNAL_LOCK, 0,0,&st->lock,1);
33 gp8psk_usb_in_op(st->d, GET_SIGNAL_STRENGTH, 0,0,buf,6);
34 st->snr = (buf[1]) << 8 | buf[0];
35 st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;
36 }
37 return 0;
38}
39
28static int gp8psk_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) 40static int gp8psk_fe_read_status(struct dvb_frontend* fe, fe_status_t *status)
29{ 41{
30 struct gp8psk_fe_state *st = fe->demodulator_priv; 42 struct gp8psk_fe_state *st = fe->demodulator_priv;
31 u8 lock; 43 gp8psk_fe_update_status(st);
32 44
33 if (gp8psk_usb_in_op(st->d, GET_SIGNAL_LOCK, 0, 0, &lock,1)) 45 if (st->lock)
34 return -EINVAL;
35
36 if (lock)
37 *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; 46 *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER;
38 else 47 else
39 *status = 0; 48 *status = 0;
40 49
50 if (*status & FE_HAS_LOCK)
51 st->status_check_interval = 1000;
52 else
53 st->status_check_interval = 100;
41 return 0; 54 return 0;
42} 55}
43 56
@@ -60,33 +73,29 @@ static int gp8psk_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
60static int gp8psk_fe_read_snr(struct dvb_frontend* fe, u16 *snr) 73static int gp8psk_fe_read_snr(struct dvb_frontend* fe, u16 *snr)
61{ 74{
62 struct gp8psk_fe_state *st = fe->demodulator_priv; 75 struct gp8psk_fe_state *st = fe->demodulator_priv;
63 u8 buf[2]; 76 gp8psk_fe_update_status(st);
64 77 /* snr is reported in dBu*256 */
65 if (time_after(jiffies,st->next_snr_check)) { 78 *snr = st->snr;
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; 79 return 0;
80} 80}
81 81
82static int gp8psk_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength) 82static int gp8psk_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
83{ 83{
84 return gp8psk_fe_read_snr(fe, strength); 84 struct gp8psk_fe_state *st = fe->demodulator_priv;
85 gp8psk_fe_update_status(st);
86 /* snr is reported in dBu*256 */
87 /* snr / 38.4 ~= 100% strength */
88 /* snr * 17 returns 100% strength as 65535 */
89 if (st->snr > 0xf00)
90 *strength = 0xffff;
91 else
92 *strength = (st->snr << 4) + st->snr; /* snr*17 */
93 return 0;
85} 94}
86 95
87static int gp8psk_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) 96static int gp8psk_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
88{ 97{
89 tune->min_delay_ms = 800; 98 tune->min_delay_ms = 200;
90 return 0; 99 return 0;
91} 100}
92 101
@@ -124,7 +133,9 @@ static int gp8psk_fe_set_frontend(struct dvb_frontend* fe,
124 133
125 gp8psk_usb_out_op(state->d,TUNE_8PSK,0,0,cmd,10); 134 gp8psk_usb_out_op(state->d,TUNE_8PSK,0,0,cmd,10);
126 135
127 state->next_snr_check = jiffies; 136 state->lock = 0;
137 state->next_status_check = jiffies;
138 state->status_check_interval = 200;
128 139
129 return 0; 140 return 0;
130} 141}
@@ -190,6 +201,12 @@ static int gp8psk_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t volt
190 return 0; 201 return 0;
191} 202}
192 203
204static int gp8psk_fe_enable_high_lnb_voltage(struct dvb_frontend* fe, long onoff)
205{
206 struct gp8psk_fe_state* state = fe->demodulator_priv;
207 return gp8psk_usb_out_op(state->d, USE_EXTRA_VOLT, onoff, 0,NULL,0);
208}
209
193static int gp8psk_fe_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long sw_cmd) 210static int gp8psk_fe_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long sw_cmd)
194{ 211{
195 struct gp8psk_fe_state* state = fe->demodulator_priv; 212 struct gp8psk_fe_state* state = fe->demodulator_priv;
@@ -235,10 +252,10 @@ success:
235 252
236static struct dvb_frontend_ops gp8psk_fe_ops = { 253static struct dvb_frontend_ops gp8psk_fe_ops = {
237 .info = { 254 .info = {
238 .name = "Genpix 8psk-USB DVB-S", 255 .name = "Genpix 8psk-to-USB2 DVB-S",
239 .type = FE_QPSK, 256 .type = FE_QPSK,
240 .frequency_min = 950000, 257 .frequency_min = 800000,
241 .frequency_max = 2150000, 258 .frequency_max = 2250000,
242 .frequency_stepsize = 100, 259 .frequency_stepsize = 100,
243 .symbol_rate_min = 1000000, 260 .symbol_rate_min = 1000000,
244 .symbol_rate_max = 45000000, 261 .symbol_rate_max = 45000000,
@@ -269,4 +286,5 @@ static struct dvb_frontend_ops gp8psk_fe_ops = {
269 .set_tone = gp8psk_fe_set_tone, 286 .set_tone = gp8psk_fe_set_tone,
270 .set_voltage = gp8psk_fe_set_voltage, 287 .set_voltage = gp8psk_fe_set_voltage,
271 .dishnetwork_send_legacy_command = gp8psk_fe_send_legacy_dish_cmd, 288 .dishnetwork_send_legacy_command = gp8psk_fe_send_legacy_dish_cmd,
289 .enable_high_lnb_voltage = gp8psk_fe_enable_high_lnb_voltage
272}; 290};