Skip to content

Commit e861d89

Browse files
committed
Merge branch 'media-fixes' (patches from Mauro)
Merge media fixes from Mauro Carvalho Chehab: "This contains two patches fixing problems with my patch series meant to make USB drivers to work again after the DMA on stack changes. The last patch on this series is actually not related to DMA on stack. It solves a longstanding bug affecting module unload, causing module_put() to be called twice. It was reported by the user who reported and tested the issues with the gp8psk driver with the DMA fixup patches. As we're late at -rc cycle, maybe you prefer to not apply it right now. If this is the case, I'll add to the pile of patches for 4.10. Exceptionally this time, I'm sending the patches via e-mail, because I'm on another trip, and won't be able to use the usual procedure until Monday. Also, it is only three patches, and you followed already the discussions about the first one" * emailed patches from Mauro Carvalho Chehab <[email protected]>: gp8psk: Fix DVB frontend attach gp8psk: fix gp8psk_usb_in_op() logic dvb-usb: move data_mutex to struct dvb_usb_device
2 parents acb57b7 + 7a0786c commit e861d89

File tree

14 files changed

+310
-249
lines changed

14 files changed

+310
-249
lines changed

drivers/media/dvb-frontends/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ config DVB_AS102_FE
513513
depends on DVB_CORE
514514
default DVB_AS102
515515

516+
config DVB_GP8PSK_FE
517+
tristate
518+
depends on DVB_CORE
519+
default DVB_USB_GP8PSK
520+
516521
comment "DVB-C (cable) frontends"
517522
depends on DVB_CORE
518523

drivers/media/dvb-frontends/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
121121
obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
122122
obj-$(CONFIG_DVB_AF9033) += af9033.o
123123
obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o
124+
obj-$(CONFIG_DVB_GP8PSK_FE) += gp8psk-fe.o
124125
obj-$(CONFIG_DVB_TC90522) += tc90522.o
125126
obj-$(CONFIG_DVB_HORUS3A) += horus3a.o
126127
obj-$(CONFIG_DVB_ASCOT2E) += ascot2e.o

drivers/media/usb/dvb-usb/gp8psk-fe.c renamed to drivers/media/dvb-frontends/gp8psk-fe.c

Lines changed: 82 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,27 @@
1414
*
1515
* see Documentation/dvb/README.dvb-usb for more information
1616
*/
17-
#include "gp8psk.h"
17+
18+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19+
20+
#include "gp8psk-fe.h"
21+
#include "dvb_frontend.h"
22+
23+
static int debug;
24+
module_param(debug, int, 0644);
25+
MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
26+
27+
#define dprintk(fmt, arg...) do { \
28+
if (debug) \
29+
printk(KERN_DEBUG pr_fmt("%s: " fmt), \
30+
__func__, ##arg); \
31+
} while (0)
1832

1933
struct gp8psk_fe_state {
2034
struct dvb_frontend fe;
21-
struct dvb_usb_device *d;
35+
void *priv;
36+
const struct gp8psk_fe_ops *ops;
37+
bool is_rev1;
2238
u8 lock;
2339
u16 snr;
2440
unsigned long next_status_check;
@@ -29,22 +45,24 @@ static int gp8psk_tuned_to_DCII(struct dvb_frontend *fe)
2945
{
3046
struct gp8psk_fe_state *st = fe->demodulator_priv;
3147
u8 status;
32-
gp8psk_usb_in_op(st->d, GET_8PSK_CONFIG, 0, 0, &status, 1);
48+
49+
st->ops->in(st->priv, GET_8PSK_CONFIG, 0, 0, &status, 1);
3350
return status & bmDCtuned;
3451
}
3552

3653
static int gp8psk_set_tuner_mode(struct dvb_frontend *fe, int mode)
3754
{
38-
struct gp8psk_fe_state *state = fe->demodulator_priv;
39-
return gp8psk_usb_out_op(state->d, SET_8PSK_CONFIG, mode, 0, NULL, 0);
55+
struct gp8psk_fe_state *st = fe->demodulator_priv;
56+
57+
return st->ops->out(st->priv, SET_8PSK_CONFIG, mode, 0, NULL, 0);
4058
}
4159

4260
static int gp8psk_fe_update_status(struct gp8psk_fe_state *st)
4361
{
4462
u8 buf[6];
4563
if (time_after(jiffies,st->next_status_check)) {
46-
gp8psk_usb_in_op(st->d, GET_SIGNAL_LOCK, 0,0,&st->lock,1);
47-
gp8psk_usb_in_op(st->d, GET_SIGNAL_STRENGTH, 0,0,buf,6);
64+
st->ops->in(st->priv, GET_SIGNAL_LOCK, 0, 0, &st->lock, 1);
65+
st->ops->in(st->priv, GET_SIGNAL_STRENGTH, 0, 0, buf, 6);
4866
st->snr = (buf[1]) << 8 | buf[0];
4967
st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;
5068
}
@@ -116,13 +134,12 @@ static int gp8psk_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_front
116134

117135
static int gp8psk_fe_set_frontend(struct dvb_frontend *fe)
118136
{
119-
struct gp8psk_fe_state *state = fe->demodulator_priv;
137+
struct gp8psk_fe_state *st = fe->demodulator_priv;
120138
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
121139
u8 cmd[10];
122140
u32 freq = c->frequency * 1000;
123-
int gp_product_id = le16_to_cpu(state->d->udev->descriptor.idProduct);
124141

125-
deb_fe("%s()\n", __func__);
142+
dprintk("%s()\n", __func__);
126143

127144
cmd[4] = freq & 0xff;
128145
cmd[5] = (freq >> 8) & 0xff;
@@ -136,21 +153,21 @@ static int gp8psk_fe_set_frontend(struct dvb_frontend *fe)
136153
switch (c->delivery_system) {
137154
case SYS_DVBS:
138155
if (c->modulation != QPSK) {
139-
deb_fe("%s: unsupported modulation selected (%d)\n",
156+
dprintk("%s: unsupported modulation selected (%d)\n",
140157
__func__, c->modulation);
141158
return -EOPNOTSUPP;
142159
}
143160
c->fec_inner = FEC_AUTO;
144161
break;
145162
case SYS_DVBS2: /* kept for backwards compatibility */
146-
deb_fe("%s: DVB-S2 delivery system selected\n", __func__);
163+
dprintk("%s: DVB-S2 delivery system selected\n", __func__);
147164
break;
148165
case SYS_TURBO:
149-
deb_fe("%s: Turbo-FEC delivery system selected\n", __func__);
166+
dprintk("%s: Turbo-FEC delivery system selected\n", __func__);
150167
break;
151168

152169
default:
153-
deb_fe("%s: unsupported delivery system selected (%d)\n",
170+
dprintk("%s: unsupported delivery system selected (%d)\n",
154171
__func__, c->delivery_system);
155172
return -EOPNOTSUPP;
156173
}
@@ -161,9 +178,9 @@ static int gp8psk_fe_set_frontend(struct dvb_frontend *fe)
161178
cmd[3] = (c->symbol_rate >> 24) & 0xff;
162179
switch (c->modulation) {
163180
case QPSK:
164-
if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM)
181+
if (st->is_rev1)
165182
if (gp8psk_tuned_to_DCII(fe))
166-
gp8psk_bcm4500_reload(state->d);
183+
st->ops->reload(st->priv);
167184
switch (c->fec_inner) {
168185
case FEC_1_2:
169186
cmd[9] = 0; break;
@@ -207,18 +224,18 @@ static int gp8psk_fe_set_frontend(struct dvb_frontend *fe)
207224
cmd[9] = 0;
208225
break;
209226
default: /* Unknown modulation */
210-
deb_fe("%s: unsupported modulation selected (%d)\n",
227+
dprintk("%s: unsupported modulation selected (%d)\n",
211228
__func__, c->modulation);
212229
return -EOPNOTSUPP;
213230
}
214231

215-
if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM)
232+
if (st->is_rev1)
216233
gp8psk_set_tuner_mode(fe, 0);
217-
gp8psk_usb_out_op(state->d, TUNE_8PSK, 0, 0, cmd, 10);
234+
st->ops->out(st->priv, TUNE_8PSK, 0, 0, cmd, 10);
218235

219-
state->lock = 0;
220-
state->next_status_check = jiffies;
221-
state->status_check_interval = 200;
236+
st->lock = 0;
237+
st->next_status_check = jiffies;
238+
st->status_check_interval = 200;
222239

223240
return 0;
224241
}
@@ -228,9 +245,9 @@ static int gp8psk_fe_send_diseqc_msg (struct dvb_frontend* fe,
228245
{
229246
struct gp8psk_fe_state *st = fe->demodulator_priv;
230247

231-
deb_fe("%s\n",__func__);
248+
dprintk("%s\n", __func__);
232249

233-
if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, m->msg[0], 0,
250+
if (st->ops->out(st->priv, SEND_DISEQC_COMMAND, m->msg[0], 0,
234251
m->msg, m->msg_len)) {
235252
return -EINVAL;
236253
}
@@ -243,12 +260,12 @@ static int gp8psk_fe_send_diseqc_burst(struct dvb_frontend *fe,
243260
struct gp8psk_fe_state *st = fe->demodulator_priv;
244261
u8 cmd;
245262

246-
deb_fe("%s\n",__func__);
263+
dprintk("%s\n", __func__);
247264

248265
/* These commands are certainly wrong */
249266
cmd = (burst == SEC_MINI_A) ? 0x00 : 0x01;
250267

251-
if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, cmd, 0,
268+
if (st->ops->out(st->priv, SEND_DISEQC_COMMAND, cmd, 0,
252269
&cmd, 0)) {
253270
return -EINVAL;
254271
}
@@ -258,10 +275,10 @@ static int gp8psk_fe_send_diseqc_burst(struct dvb_frontend *fe,
258275
static int gp8psk_fe_set_tone(struct dvb_frontend *fe,
259276
enum fe_sec_tone_mode tone)
260277
{
261-
struct gp8psk_fe_state* state = fe->demodulator_priv;
278+
struct gp8psk_fe_state *st = fe->demodulator_priv;
262279

263-
if (gp8psk_usb_out_op(state->d,SET_22KHZ_TONE,
264-
(tone == SEC_TONE_ON), 0, NULL, 0)) {
280+
if (st->ops->out(st->priv, SET_22KHZ_TONE,
281+
(tone == SEC_TONE_ON), 0, NULL, 0)) {
265282
return -EINVAL;
266283
}
267284
return 0;
@@ -270,9 +287,9 @@ static int gp8psk_fe_set_tone(struct dvb_frontend *fe,
270287
static int gp8psk_fe_set_voltage(struct dvb_frontend *fe,
271288
enum fe_sec_voltage voltage)
272289
{
273-
struct gp8psk_fe_state* state = fe->demodulator_priv;
290+
struct gp8psk_fe_state *st = fe->demodulator_priv;
274291

275-
if (gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE,
292+
if (st->ops->out(st->priv, SET_LNB_VOLTAGE,
276293
voltage == SEC_VOLTAGE_18, 0, NULL, 0)) {
277294
return -EINVAL;
278295
}
@@ -281,52 +298,60 @@ static int gp8psk_fe_set_voltage(struct dvb_frontend *fe,
281298

282299
static int gp8psk_fe_enable_high_lnb_voltage(struct dvb_frontend* fe, long onoff)
283300
{
284-
struct gp8psk_fe_state* state = fe->demodulator_priv;
285-
return gp8psk_usb_out_op(state->d, USE_EXTRA_VOLT, onoff, 0,NULL,0);
301+
struct gp8psk_fe_state *st = fe->demodulator_priv;
302+
303+
return st->ops->out(st->priv, USE_EXTRA_VOLT, onoff, 0, NULL, 0);
286304
}
287305

288306
static int gp8psk_fe_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long sw_cmd)
289307
{
290-
struct gp8psk_fe_state* state = fe->demodulator_priv;
308+
struct gp8psk_fe_state *st = fe->demodulator_priv;
291309
u8 cmd = sw_cmd & 0x7f;
292310

293-
if (gp8psk_usb_out_op(state->d,SET_DN_SWITCH, cmd, 0,
294-
NULL, 0)) {
311+
if (st->ops->out(st->priv, SET_DN_SWITCH, cmd, 0, NULL, 0))
295312
return -EINVAL;
296-
}
297-
if (gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE, !!(sw_cmd & 0x80),
298-
0, NULL, 0)) {
313+
314+
if (st->ops->out(st->priv, SET_LNB_VOLTAGE, !!(sw_cmd & 0x80),
315+
0, NULL, 0))
299316
return -EINVAL;
300-
}
301317

302318
return 0;
303319
}
304320

305321
static void gp8psk_fe_release(struct dvb_frontend* fe)
306322
{
307-
struct gp8psk_fe_state *state = fe->demodulator_priv;
308-
kfree(state);
323+
struct gp8psk_fe_state *st = fe->demodulator_priv;
324+
325+
kfree(st);
309326
}
310327

311328
static struct dvb_frontend_ops gp8psk_fe_ops;
312329

313-
struct dvb_frontend * gp8psk_fe_attach(struct dvb_usb_device *d)
330+
struct dvb_frontend *gp8psk_fe_attach(const struct gp8psk_fe_ops *ops,
331+
void *priv, bool is_rev1)
314332
{
315-
struct gp8psk_fe_state *s = kzalloc(sizeof(struct gp8psk_fe_state), GFP_KERNEL);
316-
if (s == NULL)
317-
goto error;
318-
319-
s->d = d;
320-
memcpy(&s->fe.ops, &gp8psk_fe_ops, sizeof(struct dvb_frontend_ops));
321-
s->fe.demodulator_priv = s;
322-
323-
goto success;
324-
error:
325-
return NULL;
326-
success:
327-
return &s->fe;
328-
}
333+
struct gp8psk_fe_state *st;
329334

335+
if (!ops || !ops->in || !ops->out || !ops->reload) {
336+
pr_err("Error! gp8psk-fe ops not defined.\n");
337+
return NULL;
338+
}
339+
340+
st = kzalloc(sizeof(struct gp8psk_fe_state), GFP_KERNEL);
341+
if (!st)
342+
return NULL;
343+
344+
memcpy(&st->fe.ops, &gp8psk_fe_ops, sizeof(struct dvb_frontend_ops));
345+
st->fe.demodulator_priv = st;
346+
st->ops = ops;
347+
st->priv = priv;
348+
st->is_rev1 = is_rev1;
349+
350+
pr_info("Frontend %sattached\n", is_rev1 ? "revision 1 " : "");
351+
352+
return &st->fe;
353+
}
354+
EXPORT_SYMBOL_GPL(gp8psk_fe_attach);
330355

331356
static struct dvb_frontend_ops gp8psk_fe_ops = {
332357
.delsys = { SYS_DVBS },
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* gp8psk_fe driver
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*/
14+
15+
#ifndef GP8PSK_FE_H
16+
#define GP8PSK_FE_H
17+
18+
#include <linux/types.h>
19+
20+
/* gp8psk commands */
21+
22+
#define GET_8PSK_CONFIG 0x80 /* in */
23+
#define SET_8PSK_CONFIG 0x81
24+
#define I2C_WRITE 0x83
25+
#define I2C_READ 0x84
26+
#define ARM_TRANSFER 0x85
27+
#define TUNE_8PSK 0x86
28+
#define GET_SIGNAL_STRENGTH 0x87 /* in */
29+
#define LOAD_BCM4500 0x88
30+
#define BOOT_8PSK 0x89 /* in */
31+
#define START_INTERSIL 0x8A /* in */
32+
#define SET_LNB_VOLTAGE 0x8B
33+
#define SET_22KHZ_TONE 0x8C
34+
#define SEND_DISEQC_COMMAND 0x8D
35+
#define SET_DVB_MODE 0x8E
36+
#define SET_DN_SWITCH 0x8F
37+
#define GET_SIGNAL_LOCK 0x90 /* in */
38+
#define GET_FW_VERS 0x92
39+
#define GET_SERIAL_NUMBER 0x93 /* in */
40+
#define USE_EXTRA_VOLT 0x94
41+
#define GET_FPGA_VERS 0x95
42+
#define CW3K_INIT 0x9d
43+
44+
/* PSK_configuration bits */
45+
#define bm8pskStarted 0x01
46+
#define bm8pskFW_Loaded 0x02
47+
#define bmIntersilOn 0x04
48+
#define bmDVBmode 0x08
49+
#define bm22kHz 0x10
50+
#define bmSEL18V 0x20
51+
#define bmDCtuned 0x40
52+
#define bmArmed 0x80
53+
54+
/* Satellite modulation modes */
55+
#define ADV_MOD_DVB_QPSK 0 /* DVB-S QPSK */
56+
#define ADV_MOD_TURBO_QPSK 1 /* Turbo QPSK */
57+
#define ADV_MOD_TURBO_8PSK 2 /* Turbo 8PSK (also used for Trellis 8PSK) */
58+
#define ADV_MOD_TURBO_16QAM 3 /* Turbo 16QAM (also used for Trellis 8PSK) */
59+
60+
#define ADV_MOD_DCII_C_QPSK 4 /* Digicipher II Combo */
61+
#define ADV_MOD_DCII_I_QPSK 5 /* Digicipher II I-stream */
62+
#define ADV_MOD_DCII_Q_QPSK 6 /* Digicipher II Q-stream */
63+
#define ADV_MOD_DCII_C_OQPSK 7 /* Digicipher II offset QPSK */
64+
#define ADV_MOD_DSS_QPSK 8 /* DSS (DIRECTV) QPSK */
65+
#define ADV_MOD_DVB_BPSK 9 /* DVB-S BPSK */
66+
67+
/* firmware revision id's */
68+
#define GP8PSK_FW_REV1 0x020604
69+
#define GP8PSK_FW_REV2 0x020704
70+
#define GP8PSK_FW_VERS(_fw_vers) \
71+
((_fw_vers)[2]<<0x10 | (_fw_vers)[1]<<0x08 | (_fw_vers)[0])
72+
73+
struct gp8psk_fe_ops {
74+
int (*in)(void *priv, u8 req, u16 value, u16 index, u8 *b, int blen);
75+
int (*out)(void *priv, u8 req, u16 value, u16 index, u8 *b, int blen);
76+
int (*reload)(void *priv);
77+
};
78+
79+
struct dvb_frontend *gp8psk_fe_attach(const struct gp8psk_fe_ops *ops,
80+
void *priv, bool is_rev1);
81+
82+
#endif

drivers/media/usb/dvb-usb/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o
88
dvb-usb-vp702x-objs := vp702x.o vp702x-fe.o
99
obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o
1010

11-
dvb-usb-gp8psk-objs := gp8psk.o gp8psk-fe.o
11+
dvb-usb-gp8psk-objs := gp8psk.o
1212
obj-$(CONFIG_DVB_USB_GP8PSK) += dvb-usb-gp8psk.o
1313

1414
dvb-usb-dtt200u-objs := dtt200u.o dtt200u-fe.o

0 commit comments

Comments
 (0)