Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <mchehab@osg.samsung.com>:
gp8psk: Fix DVB frontend attach
gp8psk: fix gp8psk_usb_in_op() logic
dvb-usb: move data_mutex to struct dvb_usb_device

+308 -247
+5
drivers/media/dvb-frontends/Kconfig
··· 513 513 depends on DVB_CORE 514 514 default DVB_AS102 515 515 516 + config DVB_GP8PSK_FE 517 + tristate 518 + depends on DVB_CORE 519 + default DVB_USB_GP8PSK 520 + 516 521 comment "DVB-C (cable) frontends" 517 522 depends on DVB_CORE 518 523
+1
drivers/media/dvb-frontends/Makefile
··· 121 121 obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o 122 122 obj-$(CONFIG_DVB_AF9033) += af9033.o 123 123 obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o 124 + obj-$(CONFIG_DVB_GP8PSK_FE) += gp8psk-fe.o 124 125 obj-$(CONFIG_DVB_TC90522) += tc90522.o 125 126 obj-$(CONFIG_DVB_HORUS3A) += horus3a.o 126 127 obj-$(CONFIG_DVB_ASCOT2E) += ascot2e.o
+82
drivers/media/dvb-frontends/gp8psk-fe.h
··· 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
+1 -1
drivers/media/usb/dvb-usb/Makefile
··· 8 8 dvb-usb-vp702x-objs := vp702x.o vp702x-fe.o 9 9 obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o 10 10 11 - dvb-usb-gp8psk-objs := gp8psk.o gp8psk-fe.o 11 + dvb-usb-gp8psk-objs := gp8psk.o 12 12 obj-$(CONFIG_DVB_USB_GP8PSK) += dvb-usb-gp8psk.o 13 13 14 14 dvb-usb-dtt200u-objs := dtt200u.o dtt200u-fe.o
+10 -23
drivers/media/usb/dvb-usb/af9005.c
··· 53 53 u8 sequence; 54 54 int led_state; 55 55 unsigned char data[256]; 56 - struct mutex data_mutex; 57 56 }; 58 57 59 58 static int af9005_generic_read_write(struct dvb_usb_device *d, u16 reg, ··· 71 72 return -EINVAL; 72 73 } 73 74 74 - mutex_lock(&st->data_mutex); 75 + mutex_lock(&d->data_mutex); 75 76 st->data[0] = 14; /* rest of buffer length low */ 76 77 st->data[1] = 0; /* rest of buffer length high */ 77 78 ··· 139 140 values[i] = st->data[8 + i]; 140 141 141 142 ret: 142 - mutex_unlock(&st->data_mutex); 143 + mutex_unlock(&d->data_mutex); 143 144 return ret; 144 145 145 146 } ··· 480 481 } 481 482 packet_len = wlen + 5; 482 483 483 - mutex_lock(&st->data_mutex); 484 + mutex_lock(&d->data_mutex); 484 485 485 486 st->data[0] = (u8) (packet_len & 0xff); 486 487 st->data[1] = (u8) ((packet_len & 0xff00) >> 8); ··· 511 512 rbuf[i] = st->data[i + 7]; 512 513 } 513 514 514 - mutex_unlock(&st->data_mutex); 515 + mutex_unlock(&d->data_mutex); 515 516 return ret; 516 517 } 517 518 ··· 522 523 u8 seq; 523 524 int ret, i; 524 525 525 - mutex_lock(&st->data_mutex); 526 + mutex_lock(&d->data_mutex); 526 527 527 528 memset(st->data, 0, sizeof(st->data)); 528 529 ··· 558 559 for (i = 0; i < len; i++) 559 560 values[i] = st->data[6 + i]; 560 561 } 561 - mutex_unlock(&st->data_mutex); 562 + mutex_unlock(&d->data_mutex); 562 563 563 564 return ret; 564 565 } ··· 846 847 return 0; 847 848 } 848 849 849 - mutex_lock(&st->data_mutex); 850 + mutex_lock(&d->data_mutex); 850 851 851 852 /* deb_info("rc_query\n"); */ 852 853 st->data[0] = 3; /* rest of packet length low */ ··· 889 890 } 890 891 891 892 ret: 892 - mutex_unlock(&st->data_mutex); 893 + mutex_unlock(&d->data_mutex); 893 894 return ret; 894 895 } 895 896 ··· 1003 1004 static int af9005_usb_probe(struct usb_interface *intf, 1004 1005 const struct usb_device_id *id) 1005 1006 { 1006 - struct dvb_usb_device *d; 1007 - struct af9005_device_state *st; 1008 - int ret; 1009 - 1010 - ret = dvb_usb_device_init(intf, &af9005_properties, 1011 - THIS_MODULE, &d, adapter_nr); 1012 - 1013 - if (ret < 0) 1014 - return ret; 1015 - 1016 - st = d->priv; 1017 - mutex_init(&st->data_mutex); 1018 - 1019 - return 0; 1007 + return dvb_usb_device_init(intf, &af9005_properties, 1008 + THIS_MODULE, NULL, adapter_nr); 1020 1009 } 1021 1010 1022 1011 enum af9005_usb_table_entry {
+10 -23
drivers/media/usb/dvb-usb/cinergyT2-core.c
··· 42 42 struct cinergyt2_state { 43 43 u8 rc_counter; 44 44 unsigned char data[64]; 45 - struct mutex data_mutex; 46 45 }; 47 46 48 47 /* We are missing a release hook with usb_device data */ ··· 55 56 struct cinergyt2_state *st = d->priv; 56 57 int ret; 57 58 58 - mutex_lock(&st->data_mutex); 59 + mutex_lock(&d->data_mutex); 59 60 st->data[0] = CINERGYT2_EP1_CONTROL_STREAM_TRANSFER; 60 61 st->data[1] = enable ? 1 : 0; 61 62 62 63 ret = dvb_usb_generic_rw(d, st->data, 2, st->data, 64, 0); 63 - mutex_unlock(&st->data_mutex); 64 + mutex_unlock(&d->data_mutex); 64 65 65 66 return ret; 66 67 } ··· 70 71 struct cinergyt2_state *st = d->priv; 71 72 int ret; 72 73 73 - mutex_lock(&st->data_mutex); 74 + mutex_lock(&d->data_mutex); 74 75 st->data[0] = CINERGYT2_EP1_SLEEP_MODE; 75 76 st->data[1] = enable ? 0 : 1; 76 77 77 78 ret = dvb_usb_generic_rw(d, st->data, 2, st->data, 3, 0); 78 - mutex_unlock(&st->data_mutex); 79 + mutex_unlock(&d->data_mutex); 79 80 80 81 return ret; 81 82 } ··· 88 89 89 90 adap->fe_adap[0].fe = cinergyt2_fe_attach(adap->dev); 90 91 91 - mutex_lock(&st->data_mutex); 92 + mutex_lock(&d->data_mutex); 92 93 st->data[0] = CINERGYT2_EP1_GET_FIRMWARE_VERSION; 93 94 94 95 ret = dvb_usb_generic_rw(d, st->data, 1, st->data, 3, 0); ··· 96 97 deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep " 97 98 "state info\n"); 98 99 } 99 - mutex_unlock(&st->data_mutex); 100 + mutex_unlock(&d->data_mutex); 100 101 101 102 /* Copy this pointer as we are gonna need it in the release phase */ 102 103 cinergyt2_usb_device = adap->dev; ··· 165 166 166 167 *state = REMOTE_NO_KEY_PRESSED; 167 168 168 - mutex_lock(&st->data_mutex); 169 + mutex_lock(&d->data_mutex); 169 170 st->data[0] = CINERGYT2_EP1_GET_RC_EVENTS; 170 171 171 172 ret = dvb_usb_generic_rw(d, st->data, 1, st->data, 5, 0); ··· 201 202 } 202 203 203 204 ret: 204 - mutex_unlock(&st->data_mutex); 205 + mutex_unlock(&d->data_mutex); 205 206 return ret; 206 207 } 207 208 208 209 static int cinergyt2_usb_probe(struct usb_interface *intf, 209 210 const struct usb_device_id *id) 210 211 { 211 - struct dvb_usb_device *d; 212 - struct cinergyt2_state *st; 213 - int ret; 214 - 215 - ret = dvb_usb_device_init(intf, &cinergyt2_properties, 216 - THIS_MODULE, &d, adapter_nr); 217 - if (ret < 0) 218 - return ret; 219 - 220 - st = d->priv; 221 - mutex_init(&st->data_mutex); 222 - 223 - return 0; 212 + return dvb_usb_device_init(intf, &cinergyt2_properties, 213 + THIS_MODULE, NULL, adapter_nr); 224 214 } 225 - 226 215 227 216 static struct usb_device_id cinergyt2_usb_table[] = { 228 217 { USB_DEVICE(USB_VID_TERRATEC, 0x0038) },
+16 -23
drivers/media/usb/dvb-usb/cxusb.c
··· 68 68 69 69 wo = (rbuf == NULL || rlen == 0); /* write-only */ 70 70 71 - mutex_lock(&st->data_mutex); 71 + mutex_lock(&d->data_mutex); 72 72 st->data[0] = cmd; 73 73 memcpy(&st->data[1], wbuf, wlen); 74 74 if (wo) ··· 77 77 ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, 78 78 rbuf, rlen, 0); 79 79 80 - mutex_unlock(&st->data_mutex); 80 + mutex_unlock(&d->data_mutex); 81 81 return ret; 82 82 } 83 83 ··· 1461 1461 static int cxusb_probe(struct usb_interface *intf, 1462 1462 const struct usb_device_id *id) 1463 1463 { 1464 - struct dvb_usb_device *d; 1465 - struct cxusb_state *st; 1466 - 1467 1464 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties, 1468 - THIS_MODULE, &d, adapter_nr) || 1465 + THIS_MODULE, NULL, adapter_nr) || 1469 1466 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties, 1470 - THIS_MODULE, &d, adapter_nr) || 1467 + THIS_MODULE, NULL, adapter_nr) || 1471 1468 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties, 1472 - THIS_MODULE, &d, adapter_nr) || 1469 + THIS_MODULE, NULL, adapter_nr) || 1473 1470 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties, 1474 - THIS_MODULE, &d, adapter_nr) || 1471 + THIS_MODULE, NULL, adapter_nr) || 1475 1472 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties, 1476 - THIS_MODULE, &d, adapter_nr) || 1473 + THIS_MODULE, NULL, adapter_nr) || 1477 1474 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties, 1478 - THIS_MODULE, &d, adapter_nr) || 1475 + THIS_MODULE, NULL, adapter_nr) || 1479 1476 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties, 1480 - THIS_MODULE, &d, adapter_nr) || 1477 + THIS_MODULE, NULL, adapter_nr) || 1481 1478 0 == dvb_usb_device_init(intf, 1482 1479 &cxusb_bluebird_nano2_needsfirmware_properties, 1483 - THIS_MODULE, &d, adapter_nr) || 1480 + THIS_MODULE, NULL, adapter_nr) || 1484 1481 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties, 1485 - THIS_MODULE, &d, adapter_nr) || 1482 + THIS_MODULE, NULL, adapter_nr) || 1486 1483 0 == dvb_usb_device_init(intf, 1487 1484 &cxusb_bluebird_dualdig4_rev2_properties, 1488 - THIS_MODULE, &d, adapter_nr) || 1485 + THIS_MODULE, NULL, adapter_nr) || 1489 1486 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties, 1490 - THIS_MODULE, &d, adapter_nr) || 1487 + THIS_MODULE, NULL, adapter_nr) || 1491 1488 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties, 1492 - THIS_MODULE, &d, adapter_nr) || 1489 + THIS_MODULE, NULL, adapter_nr) || 1493 1490 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties, 1494 - THIS_MODULE, &d, adapter_nr) || 1495 - 0) { 1496 - st = d->priv; 1497 - mutex_init(&st->data_mutex); 1498 - 1491 + THIS_MODULE, NULL, adapter_nr) || 1492 + 0) 1499 1493 return 0; 1500 - } 1501 1494 1502 1495 return -EINVAL; 1503 1496 }
-1
drivers/media/usb/dvb-usb/cxusb.h
··· 37 37 struct i2c_client *i2c_client_tuner; 38 38 39 39 unsigned char data[MAX_XFER_SIZE]; 40 - struct mutex data_mutex; 41 40 }; 42 41 43 42 #endif
+17 -23
drivers/media/usb/dvb-usb/dtt200u.c
··· 22 22 23 23 struct dtt200u_state { 24 24 unsigned char data[80]; 25 - struct mutex data_mutex; 26 25 }; 27 26 28 27 static int dtt200u_power_ctrl(struct dvb_usb_device *d, int onoff) ··· 29 30 struct dtt200u_state *st = d->priv; 30 31 int ret = 0; 31 32 32 - mutex_lock(&st->data_mutex); 33 + mutex_lock(&d->data_mutex); 33 34 34 35 st->data[0] = SET_INIT; 35 36 36 37 if (onoff) 37 38 ret = dvb_usb_generic_write(d, st->data, 2); 38 39 39 - mutex_unlock(&st->data_mutex); 40 + mutex_unlock(&d->data_mutex); 40 41 return ret; 41 42 } 42 43 43 44 static int dtt200u_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 44 45 { 45 - struct dtt200u_state *st = adap->dev->priv; 46 + struct dvb_usb_device *d = adap->dev; 47 + struct dtt200u_state *st = d->priv; 46 48 int ret; 47 49 48 - mutex_lock(&st->data_mutex); 50 + mutex_lock(&d->data_mutex); 49 51 st->data[0] = SET_STREAMING; 50 52 st->data[1] = onoff; 51 53 ··· 61 61 ret = dvb_usb_generic_write(adap->dev, st->data, 1); 62 62 63 63 ret: 64 - mutex_unlock(&st->data_mutex); 64 + mutex_unlock(&d->data_mutex); 65 65 66 66 return ret; 67 67 } 68 68 69 69 static int dtt200u_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff) 70 70 { 71 - struct dtt200u_state *st = adap->dev->priv; 71 + struct dvb_usb_device *d = adap->dev; 72 + struct dtt200u_state *st = d->priv; 72 73 int ret; 73 74 74 75 pid = onoff ? pid : 0; 75 76 76 - mutex_lock(&st->data_mutex); 77 + mutex_lock(&d->data_mutex); 77 78 st->data[0] = SET_PID_FILTER; 78 79 st->data[1] = index; 79 80 st->data[2] = pid & 0xff; 80 81 st->data[3] = (pid >> 8) & 0x1f; 81 82 82 83 ret = dvb_usb_generic_write(adap->dev, st->data, 4); 83 - mutex_unlock(&st->data_mutex); 84 + mutex_unlock(&d->data_mutex); 84 85 85 86 return ret; 86 87 } ··· 92 91 u32 scancode; 93 92 int ret; 94 93 95 - mutex_lock(&st->data_mutex); 94 + mutex_lock(&d->data_mutex); 96 95 st->data[0] = GET_RC_CODE; 97 96 98 97 ret = dvb_usb_generic_rw(d, st->data, 1, st->data, 5, 0); ··· 127 126 deb_info("st->data: %*ph\n", 5, st->data); 128 127 129 128 ret: 130 - mutex_unlock(&st->data_mutex); 129 + mutex_unlock(&d->data_mutex); 131 130 return ret; 132 131 } 133 132 ··· 146 145 static int dtt200u_usb_probe(struct usb_interface *intf, 147 146 const struct usb_device_id *id) 148 147 { 149 - struct dvb_usb_device *d; 150 - struct dtt200u_state *st; 151 - 152 148 if (0 == dvb_usb_device_init(intf, &dtt200u_properties, 153 - THIS_MODULE, &d, adapter_nr) || 149 + THIS_MODULE, NULL, adapter_nr) || 154 150 0 == dvb_usb_device_init(intf, &wt220u_properties, 155 - THIS_MODULE, &d, adapter_nr) || 151 + THIS_MODULE, NULL, adapter_nr) || 156 152 0 == dvb_usb_device_init(intf, &wt220u_fc_properties, 157 - THIS_MODULE, &d, adapter_nr) || 153 + THIS_MODULE, NULL, adapter_nr) || 158 154 0 == dvb_usb_device_init(intf, &wt220u_zl0353_properties, 159 - THIS_MODULE, &d, adapter_nr) || 155 + THIS_MODULE, NULL, adapter_nr) || 160 156 0 == dvb_usb_device_init(intf, &wt220u_miglia_properties, 161 - THIS_MODULE, &d, adapter_nr)) { 162 - st = d->priv; 163 - mutex_init(&st->data_mutex); 164 - 157 + THIS_MODULE, NULL, adapter_nr)) 165 158 return 0; 166 - } 167 159 168 160 return -ENODEV; 169 161 }
+1
drivers/media/usb/dvb-usb/dvb-usb-init.c
··· 142 142 { 143 143 int ret = 0; 144 144 145 + mutex_init(&d->data_mutex); 145 146 mutex_init(&d->usb_mutex); 146 147 mutex_init(&d->i2c_mutex); 147 148
+7 -2
drivers/media/usb/dvb-usb/dvb-usb.h
··· 404 404 * Powered is in/decremented for each call to modify the state. 405 405 * @udev: pointer to the device's struct usb_device. 406 406 * 407 - * @usb_mutex: semaphore of USB control messages (reading needs two messages) 408 - * @i2c_mutex: semaphore for i2c-transfers 407 + * @data_mutex: mutex to protect the data structure used to store URB data 408 + * @usb_mutex: mutex of USB control messages (reading needs two messages). 409 + * Please notice that this mutex is used internally at the generic 410 + * URB control functions. So, drivers using dvb_usb_generic_rw() and 411 + * derivated functions should not lock it internally. 412 + * @i2c_mutex: mutex for i2c-transfers 409 413 * 410 414 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB 411 415 * ··· 437 433 int powered; 438 434 439 435 /* locking */ 436 + struct mutex data_mutex; 440 437 struct mutex usb_mutex; 441 438 442 439 /* i2c */
+80 -55
drivers/media/usb/dvb-usb/gp8psk-fe.c drivers/media/dvb-frontends/gp8psk-fe.c
··· 14 14 * 15 15 * see Documentation/dvb/README.dvb-usb for more information 16 16 */ 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) 18 32 19 33 struct gp8psk_fe_state { 20 34 struct dvb_frontend fe; 21 - struct dvb_usb_device *d; 35 + void *priv; 36 + const struct gp8psk_fe_ops *ops; 37 + bool is_rev1; 22 38 u8 lock; 23 39 u16 snr; 24 40 unsigned long next_status_check; ··· 45 29 { 46 30 struct gp8psk_fe_state *st = fe->demodulator_priv; 47 31 u8 status; 48 - gp8psk_usb_in_op(st->d, GET_8PSK_CONFIG, 0, 0, &status, 1); 32 + 33 + st->ops->in(st->priv, GET_8PSK_CONFIG, 0, 0, &status, 1); 49 34 return status & bmDCtuned; 50 35 } 51 36 52 37 static int gp8psk_set_tuner_mode(struct dvb_frontend *fe, int mode) 53 38 { 54 - struct gp8psk_fe_state *state = fe->demodulator_priv; 55 - return gp8psk_usb_out_op(state->d, SET_8PSK_CONFIG, mode, 0, NULL, 0); 39 + struct gp8psk_fe_state *st = fe->demodulator_priv; 40 + 41 + return st->ops->out(st->priv, SET_8PSK_CONFIG, mode, 0, NULL, 0); 56 42 } 57 43 58 44 static int gp8psk_fe_update_status(struct gp8psk_fe_state *st) 59 45 { 60 46 u8 buf[6]; 61 47 if (time_after(jiffies,st->next_status_check)) { 62 - gp8psk_usb_in_op(st->d, GET_SIGNAL_LOCK, 0,0,&st->lock,1); 63 - gp8psk_usb_in_op(st->d, GET_SIGNAL_STRENGTH, 0,0,buf,6); 48 + st->ops->in(st->priv, GET_SIGNAL_LOCK, 0, 0, &st->lock, 1); 49 + st->ops->in(st->priv, GET_SIGNAL_STRENGTH, 0, 0, buf, 6); 64 50 st->snr = (buf[1]) << 8 | buf[0]; 65 51 st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; 66 52 } ··· 134 116 135 117 static int gp8psk_fe_set_frontend(struct dvb_frontend *fe) 136 118 { 137 - struct gp8psk_fe_state *state = fe->demodulator_priv; 119 + struct gp8psk_fe_state *st = fe->demodulator_priv; 138 120 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 139 121 u8 cmd[10]; 140 122 u32 freq = c->frequency * 1000; 141 - int gp_product_id = le16_to_cpu(state->d->udev->descriptor.idProduct); 142 123 143 - deb_fe("%s()\n", __func__); 124 + dprintk("%s()\n", __func__); 144 125 145 126 cmd[4] = freq & 0xff; 146 127 cmd[5] = (freq >> 8) & 0xff; ··· 153 136 switch (c->delivery_system) { 154 137 case SYS_DVBS: 155 138 if (c->modulation != QPSK) { 156 - deb_fe("%s: unsupported modulation selected (%d)\n", 139 + dprintk("%s: unsupported modulation selected (%d)\n", 157 140 __func__, c->modulation); 158 141 return -EOPNOTSUPP; 159 142 } 160 143 c->fec_inner = FEC_AUTO; 161 144 break; 162 145 case SYS_DVBS2: /* kept for backwards compatibility */ 163 - deb_fe("%s: DVB-S2 delivery system selected\n", __func__); 146 + dprintk("%s: DVB-S2 delivery system selected\n", __func__); 164 147 break; 165 148 case SYS_TURBO: 166 - deb_fe("%s: Turbo-FEC delivery system selected\n", __func__); 149 + dprintk("%s: Turbo-FEC delivery system selected\n", __func__); 167 150 break; 168 151 169 152 default: 170 - deb_fe("%s: unsupported delivery system selected (%d)\n", 153 + dprintk("%s: unsupported delivery system selected (%d)\n", 171 154 __func__, c->delivery_system); 172 155 return -EOPNOTSUPP; 173 156 } ··· 178 161 cmd[3] = (c->symbol_rate >> 24) & 0xff; 179 162 switch (c->modulation) { 180 163 case QPSK: 181 - if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM) 164 + if (st->is_rev1) 182 165 if (gp8psk_tuned_to_DCII(fe)) 183 - gp8psk_bcm4500_reload(state->d); 166 + st->ops->reload(st->priv); 184 167 switch (c->fec_inner) { 185 168 case FEC_1_2: 186 169 cmd[9] = 0; break; ··· 224 207 cmd[9] = 0; 225 208 break; 226 209 default: /* Unknown modulation */ 227 - deb_fe("%s: unsupported modulation selected (%d)\n", 210 + dprintk("%s: unsupported modulation selected (%d)\n", 228 211 __func__, c->modulation); 229 212 return -EOPNOTSUPP; 230 213 } 231 214 232 - if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM) 215 + if (st->is_rev1) 233 216 gp8psk_set_tuner_mode(fe, 0); 234 - gp8psk_usb_out_op(state->d, TUNE_8PSK, 0, 0, cmd, 10); 217 + st->ops->out(st->priv, TUNE_8PSK, 0, 0, cmd, 10); 235 218 236 - state->lock = 0; 237 - state->next_status_check = jiffies; 238 - state->status_check_interval = 200; 219 + st->lock = 0; 220 + st->next_status_check = jiffies; 221 + st->status_check_interval = 200; 239 222 240 223 return 0; 241 224 } ··· 245 228 { 246 229 struct gp8psk_fe_state *st = fe->demodulator_priv; 247 230 248 - deb_fe("%s\n",__func__); 231 + dprintk("%s\n", __func__); 249 232 250 - if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, m->msg[0], 0, 233 + if (st->ops->out(st->priv, SEND_DISEQC_COMMAND, m->msg[0], 0, 251 234 m->msg, m->msg_len)) { 252 235 return -EINVAL; 253 236 } ··· 260 243 struct gp8psk_fe_state *st = fe->demodulator_priv; 261 244 u8 cmd; 262 245 263 - deb_fe("%s\n",__func__); 246 + dprintk("%s\n", __func__); 264 247 265 248 /* These commands are certainly wrong */ 266 249 cmd = (burst == SEC_MINI_A) ? 0x00 : 0x01; 267 250 268 - if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, cmd, 0, 251 + if (st->ops->out(st->priv, SEND_DISEQC_COMMAND, cmd, 0, 269 252 &cmd, 0)) { 270 253 return -EINVAL; 271 254 } ··· 275 258 static int gp8psk_fe_set_tone(struct dvb_frontend *fe, 276 259 enum fe_sec_tone_mode tone) 277 260 { 278 - struct gp8psk_fe_state* state = fe->demodulator_priv; 261 + struct gp8psk_fe_state *st = fe->demodulator_priv; 279 262 280 - if (gp8psk_usb_out_op(state->d,SET_22KHZ_TONE, 281 - (tone == SEC_TONE_ON), 0, NULL, 0)) { 263 + if (st->ops->out(st->priv, SET_22KHZ_TONE, 264 + (tone == SEC_TONE_ON), 0, NULL, 0)) { 282 265 return -EINVAL; 283 266 } 284 267 return 0; ··· 287 270 static int gp8psk_fe_set_voltage(struct dvb_frontend *fe, 288 271 enum fe_sec_voltage voltage) 289 272 { 290 - struct gp8psk_fe_state* state = fe->demodulator_priv; 273 + struct gp8psk_fe_state *st = fe->demodulator_priv; 291 274 292 - if (gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE, 275 + if (st->ops->out(st->priv, SET_LNB_VOLTAGE, 293 276 voltage == SEC_VOLTAGE_18, 0, NULL, 0)) { 294 277 return -EINVAL; 295 278 } ··· 298 281 299 282 static int gp8psk_fe_enable_high_lnb_voltage(struct dvb_frontend* fe, long onoff) 300 283 { 301 - struct gp8psk_fe_state* state = fe->demodulator_priv; 302 - return gp8psk_usb_out_op(state->d, USE_EXTRA_VOLT, onoff, 0,NULL,0); 284 + struct gp8psk_fe_state *st = fe->demodulator_priv; 285 + 286 + return st->ops->out(st->priv, USE_EXTRA_VOLT, onoff, 0, NULL, 0); 303 287 } 304 288 305 289 static int gp8psk_fe_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long sw_cmd) 306 290 { 307 - struct gp8psk_fe_state* state = fe->demodulator_priv; 291 + struct gp8psk_fe_state *st = fe->demodulator_priv; 308 292 u8 cmd = sw_cmd & 0x7f; 309 293 310 - if (gp8psk_usb_out_op(state->d,SET_DN_SWITCH, cmd, 0, 311 - NULL, 0)) { 294 + if (st->ops->out(st->priv, SET_DN_SWITCH, cmd, 0, NULL, 0)) 312 295 return -EINVAL; 313 - } 314 - if (gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE, !!(sw_cmd & 0x80), 315 - 0, NULL, 0)) { 296 + 297 + if (st->ops->out(st->priv, SET_LNB_VOLTAGE, !!(sw_cmd & 0x80), 298 + 0, NULL, 0)) 316 299 return -EINVAL; 317 - } 318 300 319 301 return 0; 320 302 } 321 303 322 304 static void gp8psk_fe_release(struct dvb_frontend* fe) 323 305 { 324 - struct gp8psk_fe_state *state = fe->demodulator_priv; 325 - kfree(state); 306 + struct gp8psk_fe_state *st = fe->demodulator_priv; 307 + 308 + kfree(st); 326 309 } 327 310 328 311 static struct dvb_frontend_ops gp8psk_fe_ops; 329 312 330 - struct dvb_frontend * gp8psk_fe_attach(struct dvb_usb_device *d) 313 + struct dvb_frontend *gp8psk_fe_attach(const struct gp8psk_fe_ops *ops, 314 + void *priv, bool is_rev1) 331 315 { 332 - struct gp8psk_fe_state *s = kzalloc(sizeof(struct gp8psk_fe_state), GFP_KERNEL); 333 - if (s == NULL) 334 - goto error; 316 + struct gp8psk_fe_state *st; 335 317 336 - s->d = d; 337 - memcpy(&s->fe.ops, &gp8psk_fe_ops, sizeof(struct dvb_frontend_ops)); 338 - s->fe.demodulator_priv = s; 318 + if (!ops || !ops->in || !ops->out || !ops->reload) { 319 + pr_err("Error! gp8psk-fe ops not defined.\n"); 320 + return NULL; 321 + } 339 322 340 - goto success; 341 - error: 342 - return NULL; 343 - success: 344 - return &s->fe; 323 + st = kzalloc(sizeof(struct gp8psk_fe_state), GFP_KERNEL); 324 + if (!st) 325 + return NULL; 326 + 327 + memcpy(&st->fe.ops, &gp8psk_fe_ops, sizeof(struct dvb_frontend_ops)); 328 + st->fe.demodulator_priv = st; 329 + st->ops = ops; 330 + st->priv = priv; 331 + st->is_rev1 = is_rev1; 332 + 333 + pr_info("Frontend %sattached\n", is_rev1 ? "revision 1 " : ""); 334 + 335 + return &st->fe; 345 336 } 346 - 337 + EXPORT_SYMBOL_GPL(gp8psk_fe_attach); 347 338 348 339 static struct dvb_frontend_ops gp8psk_fe_ops = { 349 340 .delsys = { SYS_DVBS },
+78 -33
drivers/media/usb/dvb-usb/gp8psk.c
··· 15 15 * see Documentation/dvb/README.dvb-usb for more information 16 16 */ 17 17 #include "gp8psk.h" 18 + #include "gp8psk-fe.h" 18 19 19 20 /* debug */ 20 21 static char bcm4500_firmware[] = "dvb-usb-gp8psk-02.fw"; ··· 29 28 unsigned char data[80]; 30 29 }; 31 30 32 - static int gp8psk_get_fw_version(struct dvb_usb_device *d, u8 *fw_vers) 33 - { 34 - return (gp8psk_usb_in_op(d, GET_FW_VERS, 0, 0, fw_vers, 6)); 35 - } 36 - 37 - static int gp8psk_get_fpga_version(struct dvb_usb_device *d, u8 *fpga_vers) 38 - { 39 - return (gp8psk_usb_in_op(d, GET_FPGA_VERS, 0, 0, fpga_vers, 1)); 40 - } 41 - 42 - static void gp8psk_info(struct dvb_usb_device *d) 43 - { 44 - u8 fpga_vers, fw_vers[6]; 45 - 46 - if (!gp8psk_get_fw_version(d, fw_vers)) 47 - info("FW Version = %i.%02i.%i (0x%x) Build %4i/%02i/%02i", 48 - fw_vers[2], fw_vers[1], fw_vers[0], GP8PSK_FW_VERS(fw_vers), 49 - 2000 + fw_vers[5], fw_vers[4], fw_vers[3]); 50 - else 51 - info("failed to get FW version"); 52 - 53 - if (!gp8psk_get_fpga_version(d, &fpga_vers)) 54 - info("FPGA Version = %i", fpga_vers); 55 - else 56 - info("failed to get FPGA version"); 57 - } 58 - 59 - int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) 31 + static int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, 32 + u16 index, u8 *b, int blen) 60 33 { 61 34 struct gp8psk_state *st = d->priv; 62 35 int ret = 0,try = 0; ··· 42 67 return ret; 43 68 44 69 while (ret >= 0 && ret != blen && try < 3) { 45 - memcpy(st->data, b, blen); 46 70 ret = usb_control_msg(d->udev, 47 71 usb_rcvctrlpipe(d->udev,0), 48 72 req, ··· 55 81 if (ret < 0 || ret != blen) { 56 82 warn("usb in %d operation failed.", req); 57 83 ret = -EIO; 58 - } else 84 + } else { 59 85 ret = 0; 86 + memcpy(b, st->data, blen); 87 + } 60 88 61 89 deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index); 62 90 debug_dump(b,blen,deb_xfer); ··· 68 92 return ret; 69 93 } 70 94 71 - int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, 95 + static int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, 72 96 u16 index, u8 *b, int blen) 73 97 { 74 98 struct gp8psk_state *st = d->priv; ··· 97 121 mutex_unlock(&d->usb_mutex); 98 122 99 123 return ret; 124 + } 125 + 126 + 127 + static int gp8psk_get_fw_version(struct dvb_usb_device *d, u8 *fw_vers) 128 + { 129 + return gp8psk_usb_in_op(d, GET_FW_VERS, 0, 0, fw_vers, 6); 130 + } 131 + 132 + static int gp8psk_get_fpga_version(struct dvb_usb_device *d, u8 *fpga_vers) 133 + { 134 + return gp8psk_usb_in_op(d, GET_FPGA_VERS, 0, 0, fpga_vers, 1); 135 + } 136 + 137 + static void gp8psk_info(struct dvb_usb_device *d) 138 + { 139 + u8 fpga_vers, fw_vers[6]; 140 + 141 + if (!gp8psk_get_fw_version(d, fw_vers)) 142 + info("FW Version = %i.%02i.%i (0x%x) Build %4i/%02i/%02i", 143 + fw_vers[2], fw_vers[1], fw_vers[0], GP8PSK_FW_VERS(fw_vers), 144 + 2000 + fw_vers[5], fw_vers[4], fw_vers[3]); 145 + else 146 + info("failed to get FW version"); 147 + 148 + if (!gp8psk_get_fpga_version(d, &fpga_vers)) 149 + info("FPGA Version = %i", fpga_vers); 150 + else 151 + info("failed to get FPGA version"); 100 152 } 101 153 102 154 static int gp8psk_load_bcm4500fw(struct dvb_usb_device *d) ··· 229 225 return 0; 230 226 } 231 227 232 - int gp8psk_bcm4500_reload(struct dvb_usb_device *d) 228 + static int gp8psk_bcm4500_reload(struct dvb_usb_device *d) 233 229 { 234 230 u8 buf; 235 231 int gp_product_id = le16_to_cpu(d->udev->descriptor.idProduct); 232 + 233 + deb_xfer("reloading firmware\n"); 234 + 236 235 /* Turn off 8psk power */ 237 236 if (gp8psk_usb_in_op(d, BOOT_8PSK, 0, 0, &buf, 1)) 238 237 return -EINVAL; ··· 254 247 return gp8psk_usb_out_op(adap->dev, ARM_TRANSFER, onoff, 0 , NULL, 0); 255 248 } 256 249 250 + /* Callbacks for gp8psk-fe.c */ 251 + 252 + static int gp8psk_fe_in(void *priv, u8 req, u16 value, 253 + u16 index, u8 *b, int blen) 254 + { 255 + struct dvb_usb_device *d = priv; 256 + 257 + return gp8psk_usb_in_op(d, req, value, index, b, blen); 258 + } 259 + 260 + static int gp8psk_fe_out(void *priv, u8 req, u16 value, 261 + u16 index, u8 *b, int blen) 262 + { 263 + struct dvb_usb_device *d = priv; 264 + 265 + return gp8psk_usb_out_op(d, req, value, index, b, blen); 266 + } 267 + 268 + static int gp8psk_fe_reload(void *priv) 269 + { 270 + struct dvb_usb_device *d = priv; 271 + 272 + return gp8psk_bcm4500_reload(d); 273 + } 274 + 275 + const struct gp8psk_fe_ops gp8psk_fe_ops = { 276 + .in = gp8psk_fe_in, 277 + .out = gp8psk_fe_out, 278 + .reload = gp8psk_fe_reload, 279 + }; 280 + 257 281 static int gp8psk_frontend_attach(struct dvb_usb_adapter *adap) 258 282 { 259 - adap->fe_adap[0].fe = gp8psk_fe_attach(adap->dev); 283 + struct dvb_usb_device *d = adap->dev; 284 + int id = le16_to_cpu(d->udev->descriptor.idProduct); 285 + int is_rev1; 286 + 287 + is_rev1 = (id == USB_PID_GENPIX_8PSK_REV_1_WARM) ? true : false; 288 + 289 + adap->fe_adap[0].fe = dvb_attach(gp8psk_fe_attach, 290 + &gp8psk_fe_ops, d, is_rev1); 260 291 return 0; 261 292 } 262 293
-63
drivers/media/usb/dvb-usb/gp8psk.h
··· 24 24 #define deb_info(args...) dprintk(dvb_usb_gp8psk_debug,0x01,args) 25 25 #define deb_xfer(args...) dprintk(dvb_usb_gp8psk_debug,0x02,args) 26 26 #define deb_rc(args...) dprintk(dvb_usb_gp8psk_debug,0x04,args) 27 - #define deb_fe(args...) dprintk(dvb_usb_gp8psk_debug,0x08,args) 28 - 29 - /* Twinhan Vendor requests */ 30 - #define TH_COMMAND_IN 0xC0 31 - #define TH_COMMAND_OUT 0xC1 32 - 33 - /* gp8psk commands */ 34 - 35 - #define GET_8PSK_CONFIG 0x80 /* in */ 36 - #define SET_8PSK_CONFIG 0x81 37 - #define I2C_WRITE 0x83 38 - #define I2C_READ 0x84 39 - #define ARM_TRANSFER 0x85 40 - #define TUNE_8PSK 0x86 41 - #define GET_SIGNAL_STRENGTH 0x87 /* in */ 42 - #define LOAD_BCM4500 0x88 43 - #define BOOT_8PSK 0x89 /* in */ 44 - #define START_INTERSIL 0x8A /* in */ 45 - #define SET_LNB_VOLTAGE 0x8B 46 - #define SET_22KHZ_TONE 0x8C 47 - #define SEND_DISEQC_COMMAND 0x8D 48 - #define SET_DVB_MODE 0x8E 49 - #define SET_DN_SWITCH 0x8F 50 - #define GET_SIGNAL_LOCK 0x90 /* in */ 51 - #define GET_FW_VERS 0x92 52 - #define GET_SERIAL_NUMBER 0x93 /* in */ 53 - #define USE_EXTRA_VOLT 0x94 54 - #define GET_FPGA_VERS 0x95 55 - #define CW3K_INIT 0x9d 56 - 57 - /* PSK_configuration bits */ 58 - #define bm8pskStarted 0x01 59 - #define bm8pskFW_Loaded 0x02 60 - #define bmIntersilOn 0x04 61 - #define bmDVBmode 0x08 62 - #define bm22kHz 0x10 63 - #define bmSEL18V 0x20 64 - #define bmDCtuned 0x40 65 - #define bmArmed 0x80 66 - 67 - /* Satellite modulation modes */ 68 - #define ADV_MOD_DVB_QPSK 0 /* DVB-S QPSK */ 69 - #define ADV_MOD_TURBO_QPSK 1 /* Turbo QPSK */ 70 - #define ADV_MOD_TURBO_8PSK 2 /* Turbo 8PSK (also used for Trellis 8PSK) */ 71 - #define ADV_MOD_TURBO_16QAM 3 /* Turbo 16QAM (also used for Trellis 8PSK) */ 72 - 73 - #define ADV_MOD_DCII_C_QPSK 4 /* Digicipher II Combo */ 74 - #define ADV_MOD_DCII_I_QPSK 5 /* Digicipher II I-stream */ 75 - #define ADV_MOD_DCII_Q_QPSK 6 /* Digicipher II Q-stream */ 76 - #define ADV_MOD_DCII_C_OQPSK 7 /* Digicipher II offset QPSK */ 77 - #define ADV_MOD_DSS_QPSK 8 /* DSS (DIRECTV) QPSK */ 78 - #define ADV_MOD_DVB_BPSK 9 /* DVB-S BPSK */ 79 27 80 28 #define GET_USB_SPEED 0x07 81 29 ··· 33 85 #define VENDOR_STRING_READ 0x0C 34 86 #define PRODUCT_STRING_READ 0x0D 35 87 #define FW_BCD_VERSION_READ 0x14 36 - 37 - /* firmware revision id's */ 38 - #define GP8PSK_FW_REV1 0x020604 39 - #define GP8PSK_FW_REV2 0x020704 40 - #define GP8PSK_FW_VERS(_fw_vers) ((_fw_vers)[2]<<0x10 | (_fw_vers)[1]<<0x08 | (_fw_vers)[0]) 41 - 42 - extern struct dvb_frontend * gp8psk_fe_attach(struct dvb_usb_device *d); 43 - extern int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); 44 - extern int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, 45 - u16 index, u8 *b, int blen); 46 - extern int gp8psk_bcm4500_reload(struct dvb_usb_device *d); 47 88 48 89 #endif