aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/bt8xx/dst.c2
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c25
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c31
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c17
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c11
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c55
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c41
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c17
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.h11
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig4
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c6
-rw-r--r--drivers/media/dvb/dvb-usb/af9005-remote.c16
-rw-r--r--drivers/media/dvb/dvb-usb/af9005.c8
-rw-r--r--drivers/media/dvb/dvb-usb/af9005.h4
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c43
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.h18
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c6
-rw-r--r--drivers/media/dvb/dvb-usb/az6027.c114
-rw-r--r--drivers/media/dvb/dvb-usb/cinergyT2-core.c6
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c53
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c100
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mb.c8
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mc.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb.h2
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c6
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.c18
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h10
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h7
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.c44
-rw-r--r--drivers/media/dvb/dvb-usb/friio-fe.c2
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk.c4
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c18
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c18
-rw-r--r--drivers/media/dvb/dvb-usb/opera1.c16
-rw-r--r--drivers/media/dvb/dvb-usb/ttusb2.c95
-rw-r--r--drivers/media/dvb/dvb-usb/usb-urb.c7
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.c12
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c12
-rw-r--r--drivers/media/dvb/firewire/firedtv-1394.c2
-rw-r--r--drivers/media/dvb/firewire/firedtv-avc.c2
-rw-r--r--drivers/media/dvb/firewire/firedtv-ci.c5
-rw-r--r--drivers/media/dvb/firewire/firedtv-fw.c4
-rw-r--r--drivers/media/dvb/frontends/atbm8830_priv.h2
-rw-r--r--drivers/media/dvb/frontends/au8522_decoder.c33
-rw-r--r--drivers/media/dvb/frontends/au8522_dig.c26
-rw-r--r--drivers/media/dvb/frontends/au8522_priv.h5
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c35
-rw-r--r--drivers/media/dvb/frontends/dib7000p.c36
-rw-r--r--drivers/media/dvb/frontends/dib8000.h1
-rw-r--r--drivers/media/dvb/frontends/ds3000.c7
-rw-r--r--drivers/media/dvb/frontends/stv0900_core.c16
-rw-r--r--drivers/media/dvb/frontends/stv090x.c94
-rw-r--r--drivers/media/dvb/frontends/stv090x.h1
-rw-r--r--drivers/media/dvb/frontends/stv6110x.c39
-rw-r--r--drivers/media/dvb/frontends/stv6110x.h1
-rw-r--r--drivers/media/dvb/mantis/mantis_input.c4
-rw-r--r--drivers/media/dvb/mantis/mantis_vp1041.c10
-rw-r--r--drivers/media/dvb/ngene/Kconfig2
-rw-r--r--drivers/media/dvb/ngene/Makefile4
-rw-r--r--drivers/media/dvb/ngene/ngene-cards.c343
-rw-r--r--drivers/media/dvb/ngene/ngene-core.c598
-rw-r--r--drivers/media/dvb/ngene/ngene-dvb.c163
-rw-r--r--drivers/media/dvb/ngene/ngene-i2c.c178
-rw-r--r--drivers/media/dvb/ngene/ngene.h33
-rw-r--r--drivers/media/dvb/pt1/pt1.c271
-rw-r--r--drivers/media/dvb/pt1/va1j5jf8007s.c32
-rw-r--r--drivers/media/dvb/pt1/va1j5jf8007s.h8
-rw-r--r--drivers/media/dvb/pt1/va1j5jf8007t.c31
-rw-r--r--drivers/media/dvb/pt1/va1j5jf8007t.h8
-rw-r--r--drivers/media/dvb/ttpci/Kconfig5
-rw-r--r--drivers/media/dvb/ttpci/av7110.c4
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c8
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c5
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c53
-rw-r--r--drivers/media/dvb/ttpci/budget.c47
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c6
78 files changed, 1877 insertions, 1120 deletions
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 8b0cde38984d..248a2a9d8416 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -930,7 +930,6 @@ static int dst_fw_ver(struct dst_state *state)
930 dprintk(verbose, DST_INFO, 1, "Unsupported Command"); 930 dprintk(verbose, DST_INFO, 1, "Unsupported Command");
931 return -1; 931 return -1;
932 } 932 }
933 memset(&state->fw_version, '\0', 8);
934 memcpy(&state->fw_version, &state->rxbuffer, 8); 933 memcpy(&state->fw_version, &state->rxbuffer, 8);
935 dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x", 934 dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x",
936 state->fw_version[0] >> 4, state->fw_version[0] & 0x0f, 935 state->fw_version[0] >> 4, state->fw_version[0] & 0x0f,
@@ -1053,7 +1052,6 @@ static int dst_get_tuner_info(struct dst_state *state)
1053 goto force; 1052 goto force;
1054 } 1053 }
1055 } 1054 }
1056 memset(&state->board_info, '\0', 8);
1057 memcpy(&state->board_info, &state->rxbuffer, 8); 1055 memcpy(&state->board_info, &state->rxbuffer, 8);
1058 if (state->type_flags & DST_TYPE_HAS_MULTI_FE) { 1056 if (state->type_flags & DST_TYPE_HAS_MULTI_FE) {
1059 dprintk(verbose, DST_ERROR, 1, "DST type has TS=188"); 1057 dprintk(verbose, DST_ERROR, 1, "DST type has TS=188");
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index b6d46961a99e..bca07c0bcd01 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -28,7 +28,7 @@
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <media/ir-common.h> 31#include <media/ir-core.h>
32 32
33#include "demux.h" 33#include "demux.h"
34#include "dmxdev.h" 34#include "dmxdev.h"
@@ -46,6 +46,8 @@
46#include "z0194a.h" 46#include "z0194a.h"
47#include "ds3000.h" 47#include "ds3000.h"
48 48
49#define MODULE_NAME "dm1105"
50
49#define UNSET (-1U) 51#define UNSET (-1U)
50 52
51#define DM1105_BOARD_NOAUTO UNSET 53#define DM1105_BOARD_NOAUTO UNSET
@@ -265,7 +267,6 @@ static void dm1105_card_list(struct pci_dev *pci)
265/* infrared remote control */ 267/* infrared remote control */
266struct infrared { 268struct infrared {
267 struct input_dev *input_dev; 269 struct input_dev *input_dev;
268 struct ir_input_state ir;
269 char input_phys[32]; 270 char input_phys[32];
270 struct work_struct work; 271 struct work_struct work;
271 u32 ir_command; 272 u32 ir_command;
@@ -531,8 +532,7 @@ static void dm1105_emit_key(struct work_struct *work)
531 532
532 data = (ircom >> 8) & 0x7f; 533 data = (ircom >> 8) & 0x7f;
533 534
534 ir_input_keydown(ir->input_dev, &ir->ir, data); 535 ir_keydown(ir->input_dev, data, 0);
535 ir_input_nokey(ir->input_dev, &ir->ir);
536} 536}
537 537
538/* work handler */ 538/* work handler */
@@ -594,8 +594,7 @@ static irqreturn_t dm1105_irq(int irq, void *dev_id)
594int __devinit dm1105_ir_init(struct dm1105_dev *dm1105) 594int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
595{ 595{
596 struct input_dev *input_dev; 596 struct input_dev *input_dev;
597 struct ir_scancode_table *ir_codes = &ir_codes_dm1105_nec_table; 597 char *ir_codes = RC_MAP_DM1105_NEC;
598 u64 ir_type = IR_TYPE_OTHER;
599 int err = -ENOMEM; 598 int err = -ENOMEM;
600 599
601 input_dev = input_allocate_device(); 600 input_dev = input_allocate_device();
@@ -606,12 +605,6 @@ int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
606 snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys), 605 snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
607 "pci-%s/ir0", pci_name(dm1105->pdev)); 606 "pci-%s/ir0", pci_name(dm1105->pdev));
608 607
609 err = ir_input_init(input_dev, &dm1105->ir.ir, ir_type);
610 if (err < 0) {
611 input_free_device(input_dev);
612 return err;
613 }
614
615 input_dev->name = "DVB on-card IR receiver"; 608 input_dev->name = "DVB on-card IR receiver";
616 input_dev->phys = dm1105->ir.input_phys; 609 input_dev->phys = dm1105->ir.input_phys;
617 input_dev->id.bustype = BUS_PCI; 610 input_dev->id.bustype = BUS_PCI;
@@ -628,9 +621,13 @@ int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
628 621
629 INIT_WORK(&dm1105->ir.work, dm1105_emit_key); 622 INIT_WORK(&dm1105->ir.work, dm1105_emit_key);
630 623
631 err = ir_input_register(input_dev, ir_codes, NULL); 624 err = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
625 if (err < 0) {
626 input_free_device(input_dev);
627 return err;
628 }
632 629
633 return err; 630 return 0;
634} 631}
635 632
636void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105) 633void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105)
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 9ddc57909d49..425862ffb285 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -25,6 +25,7 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/smp_lock.h>
28#include <linux/poll.h> 29#include <linux/poll.h>
29#include <linux/ioctl.h> 30#include <linux/ioctl.h>
30#include <linux/wait.h> 31#include <linux/wait.h>
@@ -963,7 +964,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count,
963 return ret; 964 return ret;
964} 965}
965 966
966static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, 967static int dvb_demux_do_ioctl(struct file *file,
967 unsigned int cmd, void *parg) 968 unsigned int cmd, void *parg)
968{ 969{
969 struct dmxdev_filter *dmxdevfilter = file->private_data; 970 struct dmxdev_filter *dmxdevfilter = file->private_data;
@@ -1084,10 +1085,16 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
1084 return ret; 1085 return ret;
1085} 1086}
1086 1087
1087static int dvb_demux_ioctl(struct inode *inode, struct file *file, 1088static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
1088 unsigned int cmd, unsigned long arg) 1089 unsigned long arg)
1089{ 1090{
1090 return dvb_usercopy(inode, file, cmd, arg, dvb_demux_do_ioctl); 1091 int ret;
1092
1093 lock_kernel();
1094 ret = dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
1095 unlock_kernel();
1096
1097 return ret;
1091} 1098}
1092 1099
1093static unsigned int dvb_demux_poll(struct file *file, poll_table *wait) 1100static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
@@ -1139,7 +1146,7 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
1139static const struct file_operations dvb_demux_fops = { 1146static const struct file_operations dvb_demux_fops = {
1140 .owner = THIS_MODULE, 1147 .owner = THIS_MODULE,
1141 .read = dvb_demux_read, 1148 .read = dvb_demux_read,
1142 .ioctl = dvb_demux_ioctl, 1149 .unlocked_ioctl = dvb_demux_ioctl,
1143 .open = dvb_demux_open, 1150 .open = dvb_demux_open,
1144 .release = dvb_demux_release, 1151 .release = dvb_demux_release,
1145 .poll = dvb_demux_poll, 1152 .poll = dvb_demux_poll,
@@ -1152,7 +1159,7 @@ static struct dvb_device dvbdev_demux = {
1152 .fops = &dvb_demux_fops 1159 .fops = &dvb_demux_fops
1153}; 1160};
1154 1161
1155static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, 1162static int dvb_dvr_do_ioctl(struct file *file,
1156 unsigned int cmd, void *parg) 1163 unsigned int cmd, void *parg)
1157{ 1164{
1158 struct dvb_device *dvbdev = file->private_data; 1165 struct dvb_device *dvbdev = file->private_data;
@@ -1176,10 +1183,16 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
1176 return ret; 1183 return ret;
1177} 1184}
1178 1185
1179static int dvb_dvr_ioctl(struct inode *inode, struct file *file, 1186static long dvb_dvr_ioctl(struct file *file,
1180 unsigned int cmd, unsigned long arg) 1187 unsigned int cmd, unsigned long arg)
1181{ 1188{
1182 return dvb_usercopy(inode, file, cmd, arg, dvb_dvr_do_ioctl); 1189 int ret;
1190
1191 lock_kernel();
1192 ret = dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
1193 unlock_kernel();
1194
1195 return ret;
1183} 1196}
1184 1197
1185static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait) 1198static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
@@ -1208,7 +1221,7 @@ static const struct file_operations dvb_dvr_fops = {
1208 .owner = THIS_MODULE, 1221 .owner = THIS_MODULE,
1209 .read = dvb_dvr_read, 1222 .read = dvb_dvr_read,
1210 .write = dvb_dvr_write, 1223 .write = dvb_dvr_write,
1211 .ioctl = dvb_dvr_ioctl, 1224 .unlocked_ioctl = dvb_dvr_ioctl,
1212 .open = dvb_dvr_open, 1225 .open = dvb_dvr_open,
1213 .release = dvb_dvr_release, 1226 .release = dvb_dvr_release,
1214 .poll = dvb_dvr_poll, 1227 .poll = dvb_dvr_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index cb22da53bfb0..ef259a0718ac 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -36,6 +36,7 @@
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/smp_lock.h>
39#include <linux/kthread.h> 40#include <linux/kthread.h>
40 41
41#include "dvb_ca_en50221.h" 42#include "dvb_ca_en50221.h"
@@ -1181,7 +1182,7 @@ static int dvb_ca_en50221_thread(void *data)
1181 * 1182 *
1182 * @return 0 on success, <0 on error. 1183 * @return 0 on success, <0 on error.
1183 */ 1184 */
1184static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file, 1185static int dvb_ca_en50221_io_do_ioctl(struct file *file,
1185 unsigned int cmd, void *parg) 1186 unsigned int cmd, void *parg)
1186{ 1187{
1187 struct dvb_device *dvbdev = file->private_data; 1188 struct dvb_device *dvbdev = file->private_data;
@@ -1255,10 +1256,16 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
1255 * 1256 *
1256 * @return 0 on success, <0 on error. 1257 * @return 0 on success, <0 on error.
1257 */ 1258 */
1258static int dvb_ca_en50221_io_ioctl(struct inode *inode, struct file *file, 1259static long dvb_ca_en50221_io_ioctl(struct file *file,
1259 unsigned int cmd, unsigned long arg) 1260 unsigned int cmd, unsigned long arg)
1260{ 1261{
1261 return dvb_usercopy(inode, file, cmd, arg, dvb_ca_en50221_io_do_ioctl); 1262 int ret;
1263
1264 lock_kernel();
1265 ret = dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
1266 unlock_kernel();
1267
1268 return ret;
1262} 1269}
1263 1270
1264 1271
@@ -1611,7 +1618,7 @@ static const struct file_operations dvb_ca_fops = {
1611 .owner = THIS_MODULE, 1618 .owner = THIS_MODULE,
1612 .read = dvb_ca_en50221_io_read, 1619 .read = dvb_ca_en50221_io_read,
1613 .write = dvb_ca_en50221_io_write, 1620 .write = dvb_ca_en50221_io_write,
1614 .ioctl = dvb_ca_en50221_io_ioctl, 1621 .unlocked_ioctl = dvb_ca_en50221_io_ioctl,
1615 .open = dvb_ca_en50221_io_open, 1622 .open = dvb_ca_en50221_io_open,
1616 .release = dvb_ca_en50221_io_release, 1623 .release = dvb_ca_en50221_io_release,
1617 .poll = dvb_ca_en50221_io_poll, 1624 .poll = dvb_ca_en50221_io_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index 67f189b7aa1f..977ddba3e235 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -426,7 +426,7 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
426 }; 426 };
427 }; 427 };
428 428
429 if (demux->cnt_storage) { 429 if (demux->cnt_storage && dvb_demux_tscheck) {
430 /* check pkt counter */ 430 /* check pkt counter */
431 if (pid < MAX_PID) { 431 if (pid < MAX_PID) {
432 if (buf[1] & 0x80) 432 if (buf[1] & 0x80)
@@ -1248,12 +1248,9 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
1248 dvbdemux->feed[i].index = i; 1248 dvbdemux->feed[i].index = i;
1249 } 1249 }
1250 1250
1251 if (dvb_demux_tscheck) { 1251 dvbdemux->cnt_storage = vmalloc(MAX_PID + 1);
1252 dvbdemux->cnt_storage = vmalloc(MAX_PID + 1); 1252 if (!dvbdemux->cnt_storage)
1253 1253 printk(KERN_WARNING "Couldn't allocate memory for TS/TEI check. Disabling it\n");
1254 if (!dvbdemux->cnt_storage)
1255 printk(KERN_WARNING "Couldn't allocate memory for TS/TEI check. Disabling it\n");
1256 }
1257 1254
1258 INIT_LIST_HEAD(&dvbdemux->frontend_list); 1255 INIT_LIST_HEAD(&dvbdemux->frontend_list);
1259 1256
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 55ea260572bf..44ae89ecef94 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -36,6 +36,7 @@
36#include <linux/list.h> 36#include <linux/list.h>
37#include <linux/freezer.h> 37#include <linux/freezer.h>
38#include <linux/jiffies.h> 38#include <linux/jiffies.h>
39#include <linux/smp_lock.h>
39#include <linux/kthread.h> 40#include <linux/kthread.h>
40#include <asm/processor.h> 41#include <asm/processor.h>
41 42
@@ -95,6 +96,10 @@ MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open(
95 * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again. 96 * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
96 */ 97 */
97 98
99#define DVB_FE_NO_EXIT 0
100#define DVB_FE_NORMAL_EXIT 1
101#define DVB_FE_DEVICE_REMOVED 2
102
98static DEFINE_MUTEX(frontend_mutex); 103static DEFINE_MUTEX(frontend_mutex);
99 104
100struct dvb_frontend_private { 105struct dvb_frontend_private {
@@ -497,7 +502,7 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
497{ 502{
498 struct dvb_frontend_private *fepriv = fe->frontend_priv; 503 struct dvb_frontend_private *fepriv = fe->frontend_priv;
499 504
500 if (fepriv->exit) 505 if (fepriv->exit != DVB_FE_NO_EXIT)
501 return 1; 506 return 1;
502 507
503 if (fepriv->dvbdev->writers == 1) 508 if (fepriv->dvbdev->writers == 1)
@@ -559,7 +564,7 @@ restart:
559 564
560 if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) { 565 if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) {
561 /* got signal or quitting */ 566 /* got signal or quitting */
562 fepriv->exit = 1; 567 fepriv->exit = DVB_FE_NORMAL_EXIT;
563 break; 568 break;
564 } 569 }
565 570
@@ -673,7 +678,10 @@ restart:
673 } 678 }
674 679
675 fepriv->thread = NULL; 680 fepriv->thread = NULL;
676 fepriv->exit = 0; 681 if (kthread_should_stop())
682 fepriv->exit = DVB_FE_DEVICE_REMOVED;
683 else
684 fepriv->exit = DVB_FE_NO_EXIT;
677 mb(); 685 mb();
678 686
679 dvb_frontend_wakeup(fe); 687 dvb_frontend_wakeup(fe);
@@ -686,7 +694,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
686 694
687 dprintk ("%s\n", __func__); 695 dprintk ("%s\n", __func__);
688 696
689 fepriv->exit = 1; 697 fepriv->exit = DVB_FE_NORMAL_EXIT;
690 mb(); 698 mb();
691 699
692 if (!fepriv->thread) 700 if (!fepriv->thread)
@@ -755,7 +763,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
755 dprintk ("%s\n", __func__); 763 dprintk ("%s\n", __func__);
756 764
757 if (fepriv->thread) { 765 if (fepriv->thread) {
758 if (!fepriv->exit) 766 if (fepriv->exit == DVB_FE_NO_EXIT)
759 return 0; 767 return 0;
760 else 768 else
761 dvb_frontend_stop (fe); 769 dvb_frontend_stop (fe);
@@ -767,7 +775,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
767 return -EINTR; 775 return -EINTR;
768 776
769 fepriv->state = FESTATE_IDLE; 777 fepriv->state = FESTATE_IDLE;
770 fepriv->exit = 0; 778 fepriv->exit = DVB_FE_NO_EXIT;
771 fepriv->thread = NULL; 779 fepriv->thread = NULL;
772 mb(); 780 mb();
773 781
@@ -1188,14 +1196,14 @@ static void dtv_property_cache_submit(struct dvb_frontend *fe)
1188 } 1196 }
1189} 1197}
1190 1198
1191static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file, 1199static int dvb_frontend_ioctl_legacy(struct file *file,
1192 unsigned int cmd, void *parg); 1200 unsigned int cmd, void *parg);
1193static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file, 1201static int dvb_frontend_ioctl_properties(struct file *file,
1194 unsigned int cmd, void *parg); 1202 unsigned int cmd, void *parg);
1195 1203
1196static int dtv_property_process_get(struct dvb_frontend *fe, 1204static int dtv_property_process_get(struct dvb_frontend *fe,
1197 struct dtv_property *tvp, 1205 struct dtv_property *tvp,
1198 struct inode *inode, struct file *file) 1206 struct file *file)
1199{ 1207{
1200 int r = 0; 1208 int r = 0;
1201 1209
@@ -1328,7 +1336,6 @@ static int dtv_property_process_get(struct dvb_frontend *fe,
1328 1336
1329static int dtv_property_process_set(struct dvb_frontend *fe, 1337static int dtv_property_process_set(struct dvb_frontend *fe,
1330 struct dtv_property *tvp, 1338 struct dtv_property *tvp,
1331 struct inode *inode,
1332 struct file *file) 1339 struct file *file)
1333{ 1340{
1334 int r = 0; 1341 int r = 0;
@@ -1359,7 +1366,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1359 dprintk("%s() Finalised property cache\n", __func__); 1366 dprintk("%s() Finalised property cache\n", __func__);
1360 dtv_property_cache_submit(fe); 1367 dtv_property_cache_submit(fe);
1361 1368
1362 r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND, 1369 r |= dvb_frontend_ioctl_legacy(file, FE_SET_FRONTEND,
1363 &fepriv->parameters); 1370 &fepriv->parameters);
1364 break; 1371 break;
1365 case DTV_FREQUENCY: 1372 case DTV_FREQUENCY:
@@ -1391,12 +1398,12 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1391 break; 1398 break;
1392 case DTV_VOLTAGE: 1399 case DTV_VOLTAGE:
1393 fe->dtv_property_cache.voltage = tvp->u.data; 1400 fe->dtv_property_cache.voltage = tvp->u.data;
1394 r = dvb_frontend_ioctl_legacy(inode, file, FE_SET_VOLTAGE, 1401 r = dvb_frontend_ioctl_legacy(file, FE_SET_VOLTAGE,
1395 (void *)fe->dtv_property_cache.voltage); 1402 (void *)fe->dtv_property_cache.voltage);
1396 break; 1403 break;
1397 case DTV_TONE: 1404 case DTV_TONE:
1398 fe->dtv_property_cache.sectone = tvp->u.data; 1405 fe->dtv_property_cache.sectone = tvp->u.data;
1399 r = dvb_frontend_ioctl_legacy(inode, file, FE_SET_TONE, 1406 r = dvb_frontend_ioctl_legacy(file, FE_SET_TONE,
1400 (void *)fe->dtv_property_cache.sectone); 1407 (void *)fe->dtv_property_cache.sectone);
1401 break; 1408 break;
1402 case DTV_CODE_RATE_HP: 1409 case DTV_CODE_RATE_HP:
@@ -1480,7 +1487,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1480 return r; 1487 return r;
1481} 1488}
1482 1489
1483static int dvb_frontend_ioctl(struct inode *inode, struct file *file, 1490static int dvb_frontend_ioctl(struct file *file,
1484 unsigned int cmd, void *parg) 1491 unsigned int cmd, void *parg)
1485{ 1492{
1486 struct dvb_device *dvbdev = file->private_data; 1493 struct dvb_device *dvbdev = file->private_data;
@@ -1490,7 +1497,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
1490 1497
1491 dprintk("%s (%d)\n", __func__, _IOC_NR(cmd)); 1498 dprintk("%s (%d)\n", __func__, _IOC_NR(cmd));
1492 1499
1493 if (fepriv->exit) 1500 if (fepriv->exit != DVB_FE_NO_EXIT)
1494 return -ENODEV; 1501 return -ENODEV;
1495 1502
1496 if ((file->f_flags & O_ACCMODE) == O_RDONLY && 1503 if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
@@ -1502,17 +1509,17 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
1502 return -ERESTARTSYS; 1509 return -ERESTARTSYS;
1503 1510
1504 if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY)) 1511 if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY))
1505 err = dvb_frontend_ioctl_properties(inode, file, cmd, parg); 1512 err = dvb_frontend_ioctl_properties(file, cmd, parg);
1506 else { 1513 else {
1507 fe->dtv_property_cache.state = DTV_UNDEFINED; 1514 fe->dtv_property_cache.state = DTV_UNDEFINED;
1508 err = dvb_frontend_ioctl_legacy(inode, file, cmd, parg); 1515 err = dvb_frontend_ioctl_legacy(file, cmd, parg);
1509 } 1516 }
1510 1517
1511 up(&fepriv->sem); 1518 up(&fepriv->sem);
1512 return err; 1519 return err;
1513} 1520}
1514 1521
1515static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file, 1522static int dvb_frontend_ioctl_properties(struct file *file,
1516 unsigned int cmd, void *parg) 1523 unsigned int cmd, void *parg)
1517{ 1524{
1518 struct dvb_device *dvbdev = file->private_data; 1525 struct dvb_device *dvbdev = file->private_data;
@@ -1548,7 +1555,7 @@ static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
1548 } 1555 }
1549 1556
1550 for (i = 0; i < tvps->num; i++) { 1557 for (i = 0; i < tvps->num; i++) {
1551 (tvp + i)->result = dtv_property_process_set(fe, tvp + i, inode, file); 1558 (tvp + i)->result = dtv_property_process_set(fe, tvp + i, file);
1552 err |= (tvp + i)->result; 1559 err |= (tvp + i)->result;
1553 } 1560 }
1554 1561
@@ -1580,7 +1587,7 @@ static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
1580 } 1587 }
1581 1588
1582 for (i = 0; i < tvps->num; i++) { 1589 for (i = 0; i < tvps->num; i++) {
1583 (tvp + i)->result = dtv_property_process_get(fe, tvp + i, inode, file); 1590 (tvp + i)->result = dtv_property_process_get(fe, tvp + i, file);
1584 err |= (tvp + i)->result; 1591 err |= (tvp + i)->result;
1585 } 1592 }
1586 1593
@@ -1597,7 +1604,7 @@ out:
1597 return err; 1604 return err;
1598} 1605}
1599 1606
1600static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file, 1607static int dvb_frontend_ioctl_legacy(struct file *file,
1601 unsigned int cmd, void *parg) 1608 unsigned int cmd, void *parg)
1602{ 1609{
1603 struct dvb_device *dvbdev = file->private_data; 1610 struct dvb_device *dvbdev = file->private_data;
@@ -1916,6 +1923,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
1916 int ret; 1923 int ret;
1917 1924
1918 dprintk ("%s\n", __func__); 1925 dprintk ("%s\n", __func__);
1926 if (fepriv->exit == DVB_FE_DEVICE_REMOVED)
1927 return -ENODEV;
1919 1928
1920 if (adapter->mfe_shared) { 1929 if (adapter->mfe_shared) {
1921 mutex_lock (&adapter->mfe_lock); 1930 mutex_lock (&adapter->mfe_lock);
@@ -2008,7 +2017,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
2008 ret = dvb_generic_release (inode, file); 2017 ret = dvb_generic_release (inode, file);
2009 2018
2010 if (dvbdev->users == -1) { 2019 if (dvbdev->users == -1) {
2011 if (fepriv->exit == 1) { 2020 if (fepriv->exit != DVB_FE_NO_EXIT) {
2012 fops_put(file->f_op); 2021 fops_put(file->f_op);
2013 file->f_op = NULL; 2022 file->f_op = NULL;
2014 wake_up(&dvbdev->wait_queue); 2023 wake_up(&dvbdev->wait_queue);
@@ -2022,7 +2031,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
2022 2031
2023static const struct file_operations dvb_frontend_fops = { 2032static const struct file_operations dvb_frontend_fops = {
2024 .owner = THIS_MODULE, 2033 .owner = THIS_MODULE,
2025 .ioctl = dvb_generic_ioctl, 2034 .unlocked_ioctl = dvb_generic_ioctl,
2026 .poll = dvb_frontend_poll, 2035 .poll = dvb_frontend_poll,
2027 .open = dvb_frontend_open, 2036 .open = dvb_frontend_open,
2028 .release = dvb_frontend_release 2037 .release = dvb_frontend_release
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 441c0642b30a..6c3a8a06ccab 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -59,6 +59,7 @@
59#include <linux/netdevice.h> 59#include <linux/netdevice.h>
60#include <linux/etherdevice.h> 60#include <linux/etherdevice.h>
61#include <linux/dvb/net.h> 61#include <linux/dvb/net.h>
62#include <linux/smp_lock.h>
62#include <linux/uio.h> 63#include <linux/uio.h>
63#include <asm/uaccess.h> 64#include <asm/uaccess.h>
64#include <linux/crc32.h> 65#include <linux/crc32.h>
@@ -350,6 +351,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
350 const u8 *ts, *ts_end, *from_where = NULL; 351 const u8 *ts, *ts_end, *from_where = NULL;
351 u8 ts_remain = 0, how_much = 0, new_ts = 1; 352 u8 ts_remain = 0, how_much = 0, new_ts = 1;
352 struct ethhdr *ethh = NULL; 353 struct ethhdr *ethh = NULL;
354 bool error = false;
353 355
354#ifdef ULE_DEBUG 356#ifdef ULE_DEBUG
355 /* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */ 357 /* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */
@@ -459,10 +461,16 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
459 461
460 /* Drop partly decoded SNDU, reset state, resync on PUSI. */ 462 /* Drop partly decoded SNDU, reset state, resync on PUSI. */
461 if (priv->ule_skb) { 463 if (priv->ule_skb) {
462 dev_kfree_skb( priv->ule_skb ); 464 error = true;
465 dev_kfree_skb(priv->ule_skb);
466 }
467
468 if (error || priv->ule_sndu_remain) {
463 dev->stats.rx_errors++; 469 dev->stats.rx_errors++;
464 dev->stats.rx_frame_errors++; 470 dev->stats.rx_frame_errors++;
471 error = false;
465 } 472 }
473
466 reset_ule(priv); 474 reset_ule(priv);
467 priv->need_pusi = 1; 475 priv->need_pusi = 1;
468 continue; 476 continue;
@@ -534,6 +542,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
534 from_where += 2; 542 from_where += 2;
535 } 543 }
536 544
545 priv->ule_sndu_remain = priv->ule_sndu_len + 2;
537 /* 546 /*
538 * State of current TS: 547 * State of current TS:
539 * ts_remain (remaining bytes in the current TS cell) 548 * ts_remain (remaining bytes in the current TS cell)
@@ -543,6 +552,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
543 */ 552 */
544 switch (ts_remain) { 553 switch (ts_remain) {
545 case 1: 554 case 1:
555 priv->ule_sndu_remain--;
546 priv->ule_sndu_type = from_where[0] << 8; 556 priv->ule_sndu_type = from_where[0] << 8;
547 priv->ule_sndu_type_1 = 1; /* first byte of ule_type is set. */ 557 priv->ule_sndu_type_1 = 1; /* first byte of ule_type is set. */
548 ts_remain -= 1; from_where += 1; 558 ts_remain -= 1; from_where += 1;
@@ -556,6 +566,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
556 default: /* complete ULE header is present in current TS. */ 566 default: /* complete ULE header is present in current TS. */
557 /* Extract ULE type field. */ 567 /* Extract ULE type field. */
558 if (priv->ule_sndu_type_1) { 568 if (priv->ule_sndu_type_1) {
569 priv->ule_sndu_type_1 = 0;
559 priv->ule_sndu_type |= from_where[0]; 570 priv->ule_sndu_type |= from_where[0];
560 from_where += 1; /* points to payload start. */ 571 from_where += 1; /* points to payload start. */
561 ts_remain -= 1; 572 ts_remain -= 1;
@@ -1109,14 +1120,14 @@ static int dvb_net_feed_stop(struct net_device *dev)
1109} 1120}
1110 1121
1111 1122
1112static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc) 1123static int dvb_set_mc_filter(struct net_device *dev, unsigned char *addr)
1113{ 1124{
1114 struct dvb_net_priv *priv = netdev_priv(dev); 1125 struct dvb_net_priv *priv = netdev_priv(dev);
1115 1126
1116 if (priv->multi_num == DVB_NET_MULTICAST_MAX) 1127 if (priv->multi_num == DVB_NET_MULTICAST_MAX)
1117 return -ENOMEM; 1128 return -ENOMEM;
1118 1129
1119 memcpy(priv->multi_macs[priv->multi_num], mc->dmi_addr, 6); 1130 memcpy(priv->multi_macs[priv->multi_num], addr, ETH_ALEN);
1120 1131
1121 priv->multi_num++; 1132 priv->multi_num++;
1122 return 0; 1133 return 0;
@@ -1140,8 +1151,7 @@ static void wq_set_multicast_list (struct work_struct *work)
1140 dprintk("%s: allmulti mode\n", dev->name); 1151 dprintk("%s: allmulti mode\n", dev->name);
1141 priv->rx_mode = RX_MODE_ALL_MULTI; 1152 priv->rx_mode = RX_MODE_ALL_MULTI;
1142 } else if (!netdev_mc_empty(dev)) { 1153 } else if (!netdev_mc_empty(dev)) {
1143 int mci; 1154 struct netdev_hw_addr *ha;
1144 struct dev_mc_list *mc;
1145 1155
1146 dprintk("%s: set_mc_list, %d entries\n", 1156 dprintk("%s: set_mc_list, %d entries\n",
1147 dev->name, netdev_mc_count(dev)); 1157 dev->name, netdev_mc_count(dev));
@@ -1149,11 +1159,8 @@ static void wq_set_multicast_list (struct work_struct *work)
1149 priv->rx_mode = RX_MODE_MULTI; 1159 priv->rx_mode = RX_MODE_MULTI;
1150 priv->multi_num = 0; 1160 priv->multi_num = 0;
1151 1161
1152 for (mci = 0, mc=dev->mc_list; 1162 netdev_for_each_mc_addr(ha, dev)
1153 mci < netdev_mc_count(dev); 1163 dvb_set_mc_filter(dev, ha->addr);
1154 mc = mc->next, mci++) {
1155 dvb_set_mc_filter(dev, mc);
1156 }
1157 } 1164 }
1158 1165
1159 netif_addr_unlock_bh(dev); 1166 netif_addr_unlock_bh(dev);
@@ -1333,7 +1340,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned long num)
1333 return 0; 1340 return 0;
1334} 1341}
1335 1342
1336static int dvb_net_do_ioctl(struct inode *inode, struct file *file, 1343static int dvb_net_do_ioctl(struct file *file,
1337 unsigned int cmd, void *parg) 1344 unsigned int cmd, void *parg)
1338{ 1345{
1339 struct dvb_device *dvbdev = file->private_data; 1346 struct dvb_device *dvbdev = file->private_data;
@@ -1435,10 +1442,16 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
1435 return 0; 1442 return 0;
1436} 1443}
1437 1444
1438static int dvb_net_ioctl(struct inode *inode, struct file *file, 1445static long dvb_net_ioctl(struct file *file,
1439 unsigned int cmd, unsigned long arg) 1446 unsigned int cmd, unsigned long arg)
1440{ 1447{
1441 return dvb_usercopy(inode, file, cmd, arg, dvb_net_do_ioctl); 1448 int ret;
1449
1450 lock_kernel();
1451 ret = dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
1452 unlock_kernel();
1453
1454 return ret;
1442} 1455}
1443 1456
1444static int dvb_net_close(struct inode *inode, struct file *file) 1457static int dvb_net_close(struct inode *inode, struct file *file)
@@ -1459,7 +1472,7 @@ static int dvb_net_close(struct inode *inode, struct file *file)
1459 1472
1460static const struct file_operations dvb_net_fops = { 1473static const struct file_operations dvb_net_fops = {
1461 .owner = THIS_MODULE, 1474 .owner = THIS_MODULE,
1462 .ioctl = dvb_net_ioctl, 1475 .unlocked_ioctl = dvb_net_ioctl,
1463 .open = dvb_generic_open, 1476 .open = dvb_generic_open,
1464 .release = dvb_net_close, 1477 .release = dvb_net_close,
1465}; 1478};
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 94159b90f733..b915c39d782f 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -154,10 +154,11 @@ int dvb_generic_release(struct inode *inode, struct file *file)
154EXPORT_SYMBOL(dvb_generic_release); 154EXPORT_SYMBOL(dvb_generic_release);
155 155
156 156
157int dvb_generic_ioctl(struct inode *inode, struct file *file, 157long dvb_generic_ioctl(struct file *file,
158 unsigned int cmd, unsigned long arg) 158 unsigned int cmd, unsigned long arg)
159{ 159{
160 struct dvb_device *dvbdev = file->private_data; 160 struct dvb_device *dvbdev = file->private_data;
161 int ret;
161 162
162 if (!dvbdev) 163 if (!dvbdev)
163 return -ENODEV; 164 return -ENODEV;
@@ -165,7 +166,11 @@ int dvb_generic_ioctl(struct inode *inode, struct file *file,
165 if (!dvbdev->kernel_ioctl) 166 if (!dvbdev->kernel_ioctl)
166 return -EINVAL; 167 return -EINVAL;
167 168
168 return dvb_usercopy (inode, file, cmd, arg, dvbdev->kernel_ioctl); 169 lock_kernel();
170 ret = dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
171 unlock_kernel();
172
173 return ret;
169} 174}
170EXPORT_SYMBOL(dvb_generic_ioctl); 175EXPORT_SYMBOL(dvb_generic_ioctl);
171 176
@@ -377,9 +382,9 @@ EXPORT_SYMBOL(dvb_unregister_adapter);
377 define this as video_usercopy(). this will introduce a dependecy 382 define this as video_usercopy(). this will introduce a dependecy
378 to the v4l "videodev.o" module, which is unnecessary for some 383 to the v4l "videodev.o" module, which is unnecessary for some
379 cards (ie. the budget dvb-cards don't need the v4l module...) */ 384 cards (ie. the budget dvb-cards don't need the v4l module...) */
380int dvb_usercopy(struct inode *inode, struct file *file, 385int dvb_usercopy(struct file *file,
381 unsigned int cmd, unsigned long arg, 386 unsigned int cmd, unsigned long arg,
382 int (*func)(struct inode *inode, struct file *file, 387 int (*func)(struct file *file,
383 unsigned int cmd, void *arg)) 388 unsigned int cmd, void *arg))
384{ 389{
385 char sbuf[128]; 390 char sbuf[128];
@@ -416,7 +421,7 @@ int dvb_usercopy(struct inode *inode, struct file *file,
416 } 421 }
417 422
418 /* call driver */ 423 /* call driver */
419 if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD) 424 if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD)
420 err = -EINVAL; 425 err = -EINVAL;
421 426
422 if (err < 0) 427 if (err < 0)
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index f7b499d4a3c0..fcc6ae98745e 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -116,8 +116,7 @@ struct dvb_device {
116 116
117 wait_queue_head_t wait_queue; 117 wait_queue_head_t wait_queue;
118 /* don't really need those !? -- FIXME: use video_usercopy */ 118 /* don't really need those !? -- FIXME: use video_usercopy */
119 int (*kernel_ioctl)(struct inode *inode, struct file *file, 119 int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);
120 unsigned int cmd, void *arg);
121 120
122 void *priv; 121 void *priv;
123}; 122};
@@ -138,17 +137,15 @@ extern void dvb_unregister_device (struct dvb_device *dvbdev);
138 137
139extern int dvb_generic_open (struct inode *inode, struct file *file); 138extern int dvb_generic_open (struct inode *inode, struct file *file);
140extern int dvb_generic_release (struct inode *inode, struct file *file); 139extern int dvb_generic_release (struct inode *inode, struct file *file);
141extern int dvb_generic_ioctl (struct inode *inode, struct file *file, 140extern long dvb_generic_ioctl (struct file *file,
142 unsigned int cmd, unsigned long arg); 141 unsigned int cmd, unsigned long arg);
143 142
144/* we don't mess with video_usercopy() any more, 143/* we don't mess with video_usercopy() any more,
145we simply define out own dvb_usercopy(), which will hopefully become 144we simply define out own dvb_usercopy(), which will hopefully become
146generic_usercopy() someday... */ 145generic_usercopy() someday... */
147 146
148extern int dvb_usercopy(struct inode *inode, struct file *file, 147extern int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
149 unsigned int cmd, unsigned long arg, 148 int (*func)(struct file *file, unsigned int cmd, void *arg));
150 int (*func)(struct inode *inode, struct file *file,
151 unsigned int cmd, void *arg));
152 149
153/** generic DVB attach function. */ 150/** generic DVB attach function. */
154#ifdef CONFIG_MEDIA_ATTACH 151#ifdef CONFIG_MEDIA_ATTACH
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index e5f91f16ffa4..553b48ac1919 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -76,6 +76,7 @@ config DVB_USB_DIB0700
76 select DVB_S5H1411 if !DVB_FE_CUSTOMISE 76 select DVB_S5H1411 if !DVB_FE_CUSTOMISE
77 select DVB_LGDT3305 if !DVB_FE_CUSTOMISE 77 select DVB_LGDT3305 if !DVB_FE_CUSTOMISE
78 select DVB_TUNER_DIB0070 if !DVB_FE_CUSTOMISE 78 select DVB_TUNER_DIB0070 if !DVB_FE_CUSTOMISE
79 select DVB_TUNER_DIB0090 if !DVB_FE_CUSTOMISE
79 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE 80 select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE
80 select MEDIA_TUNER_MT2266 if !MEDIA_TUNER_CUSTOMISE 81 select MEDIA_TUNER_MT2266 if !MEDIA_TUNER_CUSTOMISE
81 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE 82 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE
@@ -134,6 +135,7 @@ config DVB_USB_M920X
134 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 135 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
135 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE 136 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE
136 select MEDIA_TUNER_TDA827X if !MEDIA_TUNER_CUSTOMISE 137 select MEDIA_TUNER_TDA827X if !MEDIA_TUNER_CUSTOMISE
138 select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMISE
137 help 139 help
138 Say Y here to support the MSI Mega Sky 580 USB2.0 DVB-T receiver. 140 Say Y here to support the MSI Mega Sky 580 USB2.0 DVB-T receiver.
139 Currently, only devices with a product id of 141 Currently, only devices with a product id of
@@ -264,7 +266,7 @@ config DVB_USB_DW2102
264 select DVB_STB6000 if !DVB_FE_CUSTOMISE 266 select DVB_STB6000 if !DVB_FE_CUSTOMISE
265 select DVB_CX24116 if !DVB_FE_CUSTOMISE 267 select DVB_CX24116 if !DVB_FE_CUSTOMISE
266 select DVB_SI21XX if !DVB_FE_CUSTOMISE 268 select DVB_SI21XX if !DVB_FE_CUSTOMISE
267 select DVB_TDA10021 if !DVB_FE_CUSTOMISE 269 select DVB_TDA10023 if !DVB_FE_CUSTOMISE
268 select DVB_MT312 if !DVB_FE_CUSTOMISE 270 select DVB_MT312 if !DVB_FE_CUSTOMISE
269 select DVB_ZL10039 if !DVB_FE_CUSTOMISE 271 select DVB_ZL10039 if !DVB_FE_CUSTOMISE
270 select DVB_DS3000 if !DVB_FE_CUSTOMISE 272 select DVB_DS3000 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
index 6247239982e9..b6cbb1dfc5f1 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -37,7 +37,7 @@ static int a800_identify_state(struct usb_device *udev, struct dvb_usb_device_pr
37 return 0; 37 return 0;
38} 38}
39 39
40static struct dvb_usb_rc_key a800_rc_keys[] = { 40static struct dvb_usb_rc_key ir_codes_a800_table[] = {
41 { 0x0201, KEY_PROG1 }, /* SOURCE */ 41 { 0x0201, KEY_PROG1 }, /* SOURCE */
42 { 0x0200, KEY_POWER }, /* POWER */ 42 { 0x0200, KEY_POWER }, /* POWER */
43 { 0x0205, KEY_1 }, /* 1 */ 43 { 0x0205, KEY_1 }, /* 1 */
@@ -147,8 +147,8 @@ static struct dvb_usb_device_properties a800_properties = {
147 .identify_state = a800_identify_state, 147 .identify_state = a800_identify_state,
148 148
149 .rc_interval = DEFAULT_RC_INTERVAL, 149 .rc_interval = DEFAULT_RC_INTERVAL,
150 .rc_key_map = a800_rc_keys, 150 .rc_key_map = ir_codes_a800_table,
151 .rc_key_map_size = ARRAY_SIZE(a800_rc_keys), 151 .rc_key_map_size = ARRAY_SIZE(ir_codes_a800_table),
152 .rc_query = a800_rc_query, 152 .rc_query = a800_rc_query,
153 153
154 .i2c_algo = &dibusb_i2c_algo, 154 .i2c_algo = &dibusb_i2c_algo,
diff --git a/drivers/media/dvb/dvb-usb/af9005-remote.c b/drivers/media/dvb/dvb-usb/af9005-remote.c
index f4379c650a19..b41fa873b04d 100644
--- a/drivers/media/dvb/dvb-usb/af9005-remote.c
+++ b/drivers/media/dvb/dvb-usb/af9005-remote.c
@@ -33,7 +33,7 @@ MODULE_PARM_DESC(debug,
33 33
34#define deb_decode(args...) dprintk(dvb_usb_af9005_remote_debug,0x01,args) 34#define deb_decode(args...) dprintk(dvb_usb_af9005_remote_debug,0x01,args)
35 35
36struct dvb_usb_rc_key af9005_rc_keys[] = { 36struct dvb_usb_rc_key ir_codes_af9005_table[] = {
37 37
38 {0x01b7, KEY_POWER}, 38 {0x01b7, KEY_POWER},
39 {0x01a7, KEY_VOLUMEUP}, 39 {0x01a7, KEY_VOLUMEUP},
@@ -74,7 +74,7 @@ struct dvb_usb_rc_key af9005_rc_keys[] = {
74 {0x00d5, KEY_GOTO}, /* marked jump on the remote */ 74 {0x00d5, KEY_GOTO}, /* marked jump on the remote */
75}; 75};
76 76
77int af9005_rc_keys_size = ARRAY_SIZE(af9005_rc_keys); 77int ir_codes_af9005_table_size = ARRAY_SIZE(ir_codes_af9005_table);
78 78
79static int repeatable_keys[] = { 79static int repeatable_keys[] = {
80 KEY_VOLUMEUP, 80 KEY_VOLUMEUP,
@@ -130,10 +130,10 @@ int af9005_rc_decode(struct dvb_usb_device *d, u8 * data, int len, u32 * event,
130 deb_decode("code != inverted code\n"); 130 deb_decode("code != inverted code\n");
131 return 0; 131 return 0;
132 } 132 }
133 for (i = 0; i < af9005_rc_keys_size; i++) { 133 for (i = 0; i < ir_codes_af9005_table_size; i++) {
134 if (rc5_custom(&af9005_rc_keys[i]) == cust 134 if (rc5_custom(&ir_codes_af9005_table[i]) == cust
135 && rc5_data(&af9005_rc_keys[i]) == dat) { 135 && rc5_data(&ir_codes_af9005_table[i]) == dat) {
136 *event = af9005_rc_keys[i].event; 136 *event = ir_codes_af9005_table[i].event;
137 *state = REMOTE_KEY_PRESSED; 137 *state = REMOTE_KEY_PRESSED;
138 deb_decode 138 deb_decode
139 ("key pressed, event %x\n", *event); 139 ("key pressed, event %x\n", *event);
@@ -146,8 +146,8 @@ int af9005_rc_decode(struct dvb_usb_device *d, u8 * data, int len, u32 * event,
146 return 0; 146 return 0;
147} 147}
148 148
149EXPORT_SYMBOL(af9005_rc_keys); 149EXPORT_SYMBOL(ir_codes_af9005_table);
150EXPORT_SYMBOL(af9005_rc_keys_size); 150EXPORT_SYMBOL(ir_codes_af9005_table_size);
151EXPORT_SYMBOL(af9005_rc_decode); 151EXPORT_SYMBOL(af9005_rc_decode);
152 152
153MODULE_AUTHOR("Luca Olivetti <luca@ventoso.org>"); 153MODULE_AUTHOR("Luca Olivetti <luca@ventoso.org>");
diff --git a/drivers/media/dvb/dvb-usb/af9005.c b/drivers/media/dvb/dvb-usb/af9005.c
index ca5a0a4d2a47..cfd6107d5349 100644
--- a/drivers/media/dvb/dvb-usb/af9005.c
+++ b/drivers/media/dvb/dvb-usb/af9005.c
@@ -1109,8 +1109,8 @@ static int __init af9005_usb_module_init(void)
1109 return result; 1109 return result;
1110 } 1110 }
1111 rc_decode = symbol_request(af9005_rc_decode); 1111 rc_decode = symbol_request(af9005_rc_decode);
1112 rc_keys = symbol_request(af9005_rc_keys); 1112 rc_keys = symbol_request(ir_codes_af9005_table);
1113 rc_keys_size = symbol_request(af9005_rc_keys_size); 1113 rc_keys_size = symbol_request(ir_codes_af9005_table_size);
1114 if (rc_decode == NULL || rc_keys == NULL || rc_keys_size == NULL) { 1114 if (rc_decode == NULL || rc_keys == NULL || rc_keys_size == NULL) {
1115 err("af9005_rc_decode function not found, disabling remote"); 1115 err("af9005_rc_decode function not found, disabling remote");
1116 af9005_properties.rc_query = NULL; 1116 af9005_properties.rc_query = NULL;
@@ -1128,9 +1128,9 @@ static void __exit af9005_usb_module_exit(void)
1128 if (rc_decode != NULL) 1128 if (rc_decode != NULL)
1129 symbol_put(af9005_rc_decode); 1129 symbol_put(af9005_rc_decode);
1130 if (rc_keys != NULL) 1130 if (rc_keys != NULL)
1131 symbol_put(af9005_rc_keys); 1131 symbol_put(ir_codes_af9005_table);
1132 if (rc_keys_size != NULL) 1132 if (rc_keys_size != NULL)
1133 symbol_put(af9005_rc_keys_size); 1133 symbol_put(ir_codes_af9005_table_size);
1134 /* deregister this driver from the USB subsystem */ 1134 /* deregister this driver from the USB subsystem */
1135 usb_deregister(&af9005_usb_driver); 1135 usb_deregister(&af9005_usb_driver);
1136} 1136}
diff --git a/drivers/media/dvb/dvb-usb/af9005.h b/drivers/media/dvb/dvb-usb/af9005.h
index 0bc48a012187..088e7083a39b 100644
--- a/drivers/media/dvb/dvb-usb/af9005.h
+++ b/drivers/media/dvb/dvb-usb/af9005.h
@@ -3490,7 +3490,7 @@ extern u8 regmask[8];
3490/* remote control decoder */ 3490/* remote control decoder */
3491extern int af9005_rc_decode(struct dvb_usb_device *d, u8 * data, int len, 3491extern int af9005_rc_decode(struct dvb_usb_device *d, u8 * data, int len,
3492 u32 * event, int *state); 3492 u32 * event, int *state);
3493extern struct dvb_usb_rc_key af9005_rc_keys[]; 3493extern struct dvb_usb_rc_key ir_codes_af9005_table[];
3494extern int af9005_rc_keys_size; 3494extern int ir_codes_af9005_table_size;
3495 3495
3496#endif 3496#endif
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 74d94e45324d..66c7c3ea7990 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -752,19 +752,19 @@ static const struct af9015_setup *af9015_setup_match(unsigned int id,
752 752
753static const struct af9015_setup af9015_setup_modparam[] = { 753static const struct af9015_setup af9015_setup_modparam[] = {
754 { AF9015_REMOTE_A_LINK_DTU_M, 754 { AF9015_REMOTE_A_LINK_DTU_M,
755 af9015_rc_keys_a_link, ARRAY_SIZE(af9015_rc_keys_a_link), 755 ir_codes_af9015_table_a_link, ARRAY_SIZE(ir_codes_af9015_table_a_link),
756 af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) }, 756 af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) },
757 { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, 757 { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
758 af9015_rc_keys_msi, ARRAY_SIZE(af9015_rc_keys_msi), 758 ir_codes_af9015_table_msi, ARRAY_SIZE(ir_codes_af9015_table_msi),
759 af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) }, 759 af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) },
760 { AF9015_REMOTE_MYGICTV_U718, 760 { AF9015_REMOTE_MYGICTV_U718,
761 af9015_rc_keys_mygictv, ARRAY_SIZE(af9015_rc_keys_mygictv), 761 ir_codes_af9015_table_mygictv, ARRAY_SIZE(ir_codes_af9015_table_mygictv),
762 af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) }, 762 af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) },
763 { AF9015_REMOTE_DIGITTRADE_DVB_T, 763 { AF9015_REMOTE_DIGITTRADE_DVB_T,
764 af9015_rc_keys_digittrade, ARRAY_SIZE(af9015_rc_keys_digittrade), 764 ir_codes_af9015_table_digittrade, ARRAY_SIZE(ir_codes_af9015_table_digittrade),
765 af9015_ir_table_digittrade, ARRAY_SIZE(af9015_ir_table_digittrade) }, 765 af9015_ir_table_digittrade, ARRAY_SIZE(af9015_ir_table_digittrade) },
766 { AF9015_REMOTE_AVERMEDIA_KS, 766 { AF9015_REMOTE_AVERMEDIA_KS,
767 af9015_rc_keys_avermedia, ARRAY_SIZE(af9015_rc_keys_avermedia), 767 ir_codes_af9015_table_avermedia, ARRAY_SIZE(ir_codes_af9015_table_avermedia),
768 af9015_ir_table_avermedia_ks, ARRAY_SIZE(af9015_ir_table_avermedia_ks) }, 768 af9015_ir_table_avermedia_ks, ARRAY_SIZE(af9015_ir_table_avermedia_ks) },
769 { } 769 { }
770}; 770};
@@ -772,32 +772,32 @@ static const struct af9015_setup af9015_setup_modparam[] = {
772/* don't add new entries here anymore, use hashes instead */ 772/* don't add new entries here anymore, use hashes instead */
773static const struct af9015_setup af9015_setup_usbids[] = { 773static const struct af9015_setup af9015_setup_usbids[] = {
774 { USB_VID_LEADTEK, 774 { USB_VID_LEADTEK,
775 af9015_rc_keys_leadtek, ARRAY_SIZE(af9015_rc_keys_leadtek), 775 ir_codes_af9015_table_leadtek, ARRAY_SIZE(ir_codes_af9015_table_leadtek),
776 af9015_ir_table_leadtek, ARRAY_SIZE(af9015_ir_table_leadtek) }, 776 af9015_ir_table_leadtek, ARRAY_SIZE(af9015_ir_table_leadtek) },
777 { USB_VID_VISIONPLUS, 777 { USB_VID_VISIONPLUS,
778 af9015_rc_keys_twinhan, ARRAY_SIZE(af9015_rc_keys_twinhan), 778 ir_codes_af9015_table_twinhan, ARRAY_SIZE(ir_codes_af9015_table_twinhan),
779 af9015_ir_table_twinhan, ARRAY_SIZE(af9015_ir_table_twinhan) }, 779 af9015_ir_table_twinhan, ARRAY_SIZE(af9015_ir_table_twinhan) },
780 { USB_VID_KWORLD_2, /* TODO: use correct rc keys */ 780 { USB_VID_KWORLD_2, /* TODO: use correct rc keys */
781 af9015_rc_keys_twinhan, ARRAY_SIZE(af9015_rc_keys_twinhan), 781 ir_codes_af9015_table_twinhan, ARRAY_SIZE(ir_codes_af9015_table_twinhan),
782 af9015_ir_table_kworld, ARRAY_SIZE(af9015_ir_table_kworld) }, 782 af9015_ir_table_kworld, ARRAY_SIZE(af9015_ir_table_kworld) },
783 { USB_VID_AVERMEDIA, 783 { USB_VID_AVERMEDIA,
784 af9015_rc_keys_avermedia, ARRAY_SIZE(af9015_rc_keys_avermedia), 784 ir_codes_af9015_table_avermedia, ARRAY_SIZE(ir_codes_af9015_table_avermedia),
785 af9015_ir_table_avermedia, ARRAY_SIZE(af9015_ir_table_avermedia) }, 785 af9015_ir_table_avermedia, ARRAY_SIZE(af9015_ir_table_avermedia) },
786 { USB_VID_MSI_2, 786 { USB_VID_MSI_2,
787 af9015_rc_keys_msi_digivox_iii, ARRAY_SIZE(af9015_rc_keys_msi_digivox_iii), 787 ir_codes_af9015_table_msi_digivox_iii, ARRAY_SIZE(ir_codes_af9015_table_msi_digivox_iii),
788 af9015_ir_table_msi_digivox_iii, ARRAY_SIZE(af9015_ir_table_msi_digivox_iii) }, 788 af9015_ir_table_msi_digivox_iii, ARRAY_SIZE(af9015_ir_table_msi_digivox_iii) },
789 { } 789 { }
790}; 790};
791 791
792static const struct af9015_setup af9015_setup_hashes[] = { 792static const struct af9015_setup af9015_setup_hashes[] = {
793 { 0xb8feb708, 793 { 0xb8feb708,
794 af9015_rc_keys_msi, ARRAY_SIZE(af9015_rc_keys_msi), 794 ir_codes_af9015_table_msi, ARRAY_SIZE(ir_codes_af9015_table_msi),
795 af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) }, 795 af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) },
796 { 0xa3703d00, 796 { 0xa3703d00,
797 af9015_rc_keys_a_link, ARRAY_SIZE(af9015_rc_keys_a_link), 797 ir_codes_af9015_table_a_link, ARRAY_SIZE(ir_codes_af9015_table_a_link),
798 af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) }, 798 af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) },
799 { 0x9b7dc64e, 799 { 0x9b7dc64e,
800 af9015_rc_keys_mygictv, ARRAY_SIZE(af9015_rc_keys_mygictv), 800 ir_codes_af9015_table_mygictv, ARRAY_SIZE(ir_codes_af9015_table_mygictv),
801 af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) }, 801 af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) },
802 { } 802 { }
803}; 803};
@@ -836,8 +836,8 @@ static void af9015_set_remote_config(struct usb_device *udev,
836 } else if (udev->descriptor.idProduct == 836 } else if (udev->descriptor.idProduct ==
837 cpu_to_le16(USB_PID_TREKSTOR_DVBT)) { 837 cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
838 table = &(const struct af9015_setup){ 0, 838 table = &(const struct af9015_setup){ 0,
839 af9015_rc_keys_trekstor, 839 ir_codes_af9015_table_trekstor,
840 ARRAY_SIZE(af9015_rc_keys_trekstor), 840 ARRAY_SIZE(ir_codes_af9015_table_trekstor),
841 af9015_ir_table_trekstor, 841 af9015_ir_table_trekstor,
842 ARRAY_SIZE(af9015_ir_table_trekstor) 842 ARRAY_SIZE(af9015_ir_table_trekstor)
843 }; 843 };
@@ -1297,6 +1297,8 @@ static struct usb_device_id af9015_usb_table[] = {
1297 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV20)}, 1297 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV20)},
1298 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_TINYTWIN_2)}, 1298 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_TINYTWIN_2)},
1299 {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV2000DS)}, 1299 {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV2000DS)},
1300/* 30 */{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB383_T)},
1301 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_4)},
1300 {0}, 1302 {0},
1301}; 1303};
1302MODULE_DEVICE_TABLE(usb, af9015_usb_table); 1304MODULE_DEVICE_TABLE(usb, af9015_usb_table);
@@ -1500,7 +1502,8 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1500 "(VS-DVB-T 395U)", 1502 "(VS-DVB-T 395U)",
1501 .cold_ids = {&af9015_usb_table[16], 1503 .cold_ids = {&af9015_usb_table[16],
1502 &af9015_usb_table[17], 1504 &af9015_usb_table[17],
1503 &af9015_usb_table[18], NULL}, 1505 &af9015_usb_table[18],
1506 &af9015_usb_table[31], NULL},
1504 .warm_ids = {NULL}, 1507 .warm_ids = {NULL},
1505 }, 1508 },
1506 { 1509 {
@@ -1569,7 +1572,7 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1569 1572
1570 .i2c_algo = &af9015_i2c_algo, 1573 .i2c_algo = &af9015_i2c_algo,
1571 1574
1572 .num_device_descs = 7, /* max 9 */ 1575 .num_device_descs = 8, /* max 9 */
1573 .devices = { 1576 .devices = {
1574 { 1577 {
1575 .name = "AverMedia AVerTV Volar GPS 805 (A805)", 1578 .name = "AverMedia AVerTV Volar GPS 805 (A805)",
@@ -1608,6 +1611,12 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1608 .cold_ids = {&af9015_usb_table[29], NULL}, 1611 .cold_ids = {&af9015_usb_table[29], NULL},
1609 .warm_ids = {NULL}, 1612 .warm_ids = {NULL},
1610 }, 1613 },
1614 {
1615 .name = "KWorld USB DVB-T Stick Mobile " \
1616 "(UB383-T)",
1617 .cold_ids = {&af9015_usb_table[30], NULL},
1618 .warm_ids = {NULL},
1619 },
1611 } 1620 }
1612 }, 1621 },
1613}; 1622};
diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h
index ef36b1831490..63b2a4907b7e 100644
--- a/drivers/media/dvb/dvb-usb/af9015.h
+++ b/drivers/media/dvb/dvb-usb/af9015.h
@@ -123,7 +123,7 @@ enum af9015_remote {
123 123
124/* LeadTek - Y04G0051 */ 124/* LeadTek - Y04G0051 */
125/* Leadtek WinFast DTV Dongle Gold */ 125/* Leadtek WinFast DTV Dongle Gold */
126static struct dvb_usb_rc_key af9015_rc_keys_leadtek[] = { 126static struct dvb_usb_rc_key ir_codes_af9015_table_leadtek[] = {
127 { 0x001e, KEY_1 }, 127 { 0x001e, KEY_1 },
128 { 0x001f, KEY_2 }, 128 { 0x001f, KEY_2 },
129 { 0x0020, KEY_3 }, 129 { 0x0020, KEY_3 },
@@ -227,7 +227,7 @@ static u8 af9015_ir_table_leadtek[] = {
227}; 227};
228 228
229/* TwinHan AzureWave AD-TU700(704J) */ 229/* TwinHan AzureWave AD-TU700(704J) */
230static struct dvb_usb_rc_key af9015_rc_keys_twinhan[] = { 230static struct dvb_usb_rc_key ir_codes_af9015_table_twinhan[] = {
231 { 0x053f, KEY_POWER }, 231 { 0x053f, KEY_POWER },
232 { 0x0019, KEY_FAVORITES }, /* Favorite List */ 232 { 0x0019, KEY_FAVORITES }, /* Favorite List */
233 { 0x0004, KEY_TEXT }, /* Teletext */ 233 { 0x0004, KEY_TEXT }, /* Teletext */
@@ -338,7 +338,7 @@ static u8 af9015_ir_table_twinhan[] = {
338}; 338};
339 339
340/* A-Link DTU(m) */ 340/* A-Link DTU(m) */
341static struct dvb_usb_rc_key af9015_rc_keys_a_link[] = { 341static struct dvb_usb_rc_key ir_codes_af9015_table_a_link[] = {
342 { 0x001e, KEY_1 }, 342 { 0x001e, KEY_1 },
343 { 0x001f, KEY_2 }, 343 { 0x001f, KEY_2 },
344 { 0x0020, KEY_3 }, 344 { 0x0020, KEY_3 },
@@ -381,7 +381,7 @@ static u8 af9015_ir_table_a_link[] = {
381}; 381};
382 382
383/* MSI DIGIVOX mini II V3.0 */ 383/* MSI DIGIVOX mini II V3.0 */
384static struct dvb_usb_rc_key af9015_rc_keys_msi[] = { 384static struct dvb_usb_rc_key ir_codes_af9015_table_msi[] = {
385 { 0x001e, KEY_1 }, 385 { 0x001e, KEY_1 },
386 { 0x001f, KEY_2 }, 386 { 0x001f, KEY_2 },
387 { 0x0020, KEY_3 }, 387 { 0x0020, KEY_3 },
@@ -424,7 +424,7 @@ static u8 af9015_ir_table_msi[] = {
424}; 424};
425 425
426/* MYGICTV U718 */ 426/* MYGICTV U718 */
427static struct dvb_usb_rc_key af9015_rc_keys_mygictv[] = { 427static struct dvb_usb_rc_key ir_codes_af9015_table_mygictv[] = {
428 { 0x003d, KEY_SWITCHVIDEOMODE }, 428 { 0x003d, KEY_SWITCHVIDEOMODE },
429 /* TV / AV */ 429 /* TV / AV */
430 { 0x0545, KEY_POWER }, 430 { 0x0545, KEY_POWER },
@@ -550,7 +550,7 @@ static u8 af9015_ir_table_kworld[] = {
550}; 550};
551 551
552/* AverMedia Volar X */ 552/* AverMedia Volar X */
553static struct dvb_usb_rc_key af9015_rc_keys_avermedia[] = { 553static struct dvb_usb_rc_key ir_codes_af9015_table_avermedia[] = {
554 { 0x053d, KEY_PROG1 }, /* SOURCE */ 554 { 0x053d, KEY_PROG1 }, /* SOURCE */
555 { 0x0512, KEY_POWER }, /* POWER */ 555 { 0x0512, KEY_POWER }, /* POWER */
556 { 0x051e, KEY_1 }, /* 1 */ 556 { 0x051e, KEY_1 }, /* 1 */
@@ -656,7 +656,7 @@ static u8 af9015_ir_table_avermedia_ks[] = {
656}; 656};
657 657
658/* Digittrade DVB-T USB Stick */ 658/* Digittrade DVB-T USB Stick */
659static struct dvb_usb_rc_key af9015_rc_keys_digittrade[] = { 659static struct dvb_usb_rc_key ir_codes_af9015_table_digittrade[] = {
660 { 0x010f, KEY_LAST }, /* RETURN */ 660 { 0x010f, KEY_LAST }, /* RETURN */
661 { 0x0517, KEY_TEXT }, /* TELETEXT */ 661 { 0x0517, KEY_TEXT }, /* TELETEXT */
662 { 0x0108, KEY_EPG }, /* EPG */ 662 { 0x0108, KEY_EPG }, /* EPG */
@@ -719,7 +719,7 @@ static u8 af9015_ir_table_digittrade[] = {
719}; 719};
720 720
721/* TREKSTOR DVB-T USB Stick */ 721/* TREKSTOR DVB-T USB Stick */
722static struct dvb_usb_rc_key af9015_rc_keys_trekstor[] = { 722static struct dvb_usb_rc_key ir_codes_af9015_table_trekstor[] = {
723 { 0x0704, KEY_AGAIN }, /* Home */ 723 { 0x0704, KEY_AGAIN }, /* Home */
724 { 0x0705, KEY_MUTE }, /* Mute */ 724 { 0x0705, KEY_MUTE }, /* Mute */
725 { 0x0706, KEY_UP }, /* Up */ 725 { 0x0706, KEY_UP }, /* Up */
@@ -782,7 +782,7 @@ static u8 af9015_ir_table_trekstor[] = {
782}; 782};
783 783
784/* MSI DIGIVOX mini III */ 784/* MSI DIGIVOX mini III */
785static struct dvb_usb_rc_key af9015_rc_keys_msi_digivox_iii[] = { 785static struct dvb_usb_rc_key ir_codes_af9015_table_msi_digivox_iii[] = {
786 { 0x0713, KEY_POWER }, /* [red power button] */ 786 { 0x0713, KEY_POWER }, /* [red power button] */
787 { 0x073b, KEY_VIDEO }, /* Source */ 787 { 0x073b, KEY_VIDEO }, /* Source */
788 { 0x073e, KEY_ZOOM }, /* Zoom */ 788 { 0x073e, KEY_ZOOM }, /* Zoom */
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index bb69f3719f9a..faca1ad88a67 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -399,7 +399,7 @@ static int anysee_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
399 return 0; 399 return 0;
400} 400}
401 401
402static struct dvb_usb_rc_key anysee_rc_keys[] = { 402static struct dvb_usb_rc_key ir_codes_anysee_table[] = {
403 { 0x0100, KEY_0 }, 403 { 0x0100, KEY_0 },
404 { 0x0101, KEY_1 }, 404 { 0x0101, KEY_1 },
405 { 0x0102, KEY_2 }, 405 { 0x0102, KEY_2 },
@@ -518,8 +518,8 @@ static struct dvb_usb_device_properties anysee_properties = {
518 } 518 }
519 }, 519 },
520 520
521 .rc_key_map = anysee_rc_keys, 521 .rc_key_map = ir_codes_anysee_table,
522 .rc_key_map_size = ARRAY_SIZE(anysee_rc_keys), 522 .rc_key_map_size = ARRAY_SIZE(ir_codes_anysee_table),
523 .rc_query = anysee_rc_query, 523 .rc_query = anysee_rc_query,
524 .rc_interval = 200, /* windows driver uses 500ms */ 524 .rc_interval = 200, /* windows driver uses 500ms */
525 525
diff --git a/drivers/media/dvb/dvb-usb/az6027.c b/drivers/media/dvb/dvb-usb/az6027.c
index d7290b2c0913..6681ac1c56e3 100644
--- a/drivers/media/dvb/dvb-usb/az6027.c
+++ b/drivers/media/dvb/dvb-usb/az6027.c
@@ -125,12 +125,12 @@ static const struct stb0899_s1_reg az6027_stb0899_s1_init_3[] = {
125 { STB0899_RCOMPC , 0xc9 }, 125 { STB0899_RCOMPC , 0xc9 },
126 { STB0899_AGC1CN , 0x01 }, 126 { STB0899_AGC1CN , 0x01 },
127 { STB0899_AGC1REF , 0x10 }, 127 { STB0899_AGC1REF , 0x10 },
128 { STB0899_RTC , 0x23 }, 128 { STB0899_RTC , 0x23 },
129 { STB0899_TMGCFG , 0x4e }, 129 { STB0899_TMGCFG , 0x4e },
130 { STB0899_AGC2REF , 0x34 }, 130 { STB0899_AGC2REF , 0x34 },
131 { STB0899_TLSR , 0x84 }, 131 { STB0899_TLSR , 0x84 },
132 { STB0899_CFD , 0xf7 }, 132 { STB0899_CFD , 0xf7 },
133 { STB0899_ACLC , 0x87 }, 133 { STB0899_ACLC , 0x87 },
134 { STB0899_BCLC , 0x94 }, 134 { STB0899_BCLC , 0x94 },
135 { STB0899_EQON , 0x41 }, 135 { STB0899_EQON , 0x41 },
136 { STB0899_LDT , 0xf1 }, 136 { STB0899_LDT , 0xf1 },
@@ -183,10 +183,10 @@ static const struct stb0899_s1_reg az6027_stb0899_s1_init_3[] = {
183 { STB0899_ECNT3M , 0x0a }, 183 { STB0899_ECNT3M , 0x0a },
184 { STB0899_ECNT3L , 0xad }, 184 { STB0899_ECNT3L , 0xad },
185 { STB0899_FECAUTO1 , 0x06 }, 185 { STB0899_FECAUTO1 , 0x06 },
186 { STB0899_FECM , 0x01 }, 186 { STB0899_FECM , 0x01 },
187 { STB0899_VTH12 , 0xb0 }, 187 { STB0899_VTH12 , 0xb0 },
188 { STB0899_VTH23 , 0x7a }, 188 { STB0899_VTH23 , 0x7a },
189 { STB0899_VTH34 , 0x58 }, 189 { STB0899_VTH34 , 0x58 },
190 { STB0899_VTH56 , 0x38 }, 190 { STB0899_VTH56 , 0x38 },
191 { STB0899_VTH67 , 0x34 }, 191 { STB0899_VTH67 , 0x34 },
192 { STB0899_VTH78 , 0x24 }, 192 { STB0899_VTH78 , 0x24 },
@@ -195,7 +195,7 @@ static const struct stb0899_s1_reg az6027_stb0899_s1_init_3[] = {
195 { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */ 195 { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */
196 { STB0899_TSULC , 0x42 }, 196 { STB0899_TSULC , 0x42 },
197 { STB0899_RSLLC , 0x41 }, 197 { STB0899_RSLLC , 0x41 },
198 { STB0899_TSLPL , 0x12 }, 198 { STB0899_TSLPL , 0x12 },
199 { STB0899_TSCFGH , 0x0c }, 199 { STB0899_TSCFGH , 0x0c },
200 { STB0899_TSCFGM , 0x00 }, 200 { STB0899_TSCFGM , 0x00 },
201 { STB0899_TSCFGL , 0x00 }, 201 { STB0899_TSCFGL , 0x00 },
@@ -386,7 +386,7 @@ static int az6027_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
386} 386}
387 387
388/* keys for the enclosed remote control */ 388/* keys for the enclosed remote control */
389static struct dvb_usb_rc_key az6027_rc_keys[] = { 389static struct dvb_usb_rc_key ir_codes_az6027_table[] = {
390 { 0x01, KEY_1 }, 390 { 0x01, KEY_1 },
391 { 0x02, KEY_2 }, 391 { 0x02, KEY_2 },
392}; 392};
@@ -417,11 +417,15 @@ static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca,
417 u16 value; 417 u16 value;
418 u16 index; 418 u16 index;
419 int blen; 419 int blen;
420 u8 b[12]; 420 u8 *b;
421 421
422 if (slot != 0) 422 if (slot != 0)
423 return -EINVAL; 423 return -EINVAL;
424 424
425 b = kmalloc(12, GFP_KERNEL);
426 if (!b)
427 return -ENOMEM;
428
425 mutex_lock(&state->ca_mutex); 429 mutex_lock(&state->ca_mutex);
426 430
427 req = 0xC1; 431 req = 0xC1;
@@ -438,6 +442,7 @@ static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca,
438 } 442 }
439 443
440 mutex_unlock(&state->ca_mutex); 444 mutex_unlock(&state->ca_mutex);
445 kfree(b);
441 return ret; 446 return ret;
442} 447}
443 448
@@ -485,11 +490,15 @@ static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca,
485 u16 value; 490 u16 value;
486 u16 index; 491 u16 index;
487 int blen; 492 int blen;
488 u8 b[12]; 493 u8 *b;
489 494
490 if (slot != 0) 495 if (slot != 0)
491 return -EINVAL; 496 return -EINVAL;
492 497
498 b = kmalloc(12, GFP_KERNEL);
499 if (!b)
500 return -ENOMEM;
501
493 mutex_lock(&state->ca_mutex); 502 mutex_lock(&state->ca_mutex);
494 503
495 req = 0xC3; 504 req = 0xC3;
@@ -510,6 +519,7 @@ static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca,
510 } 519 }
511 520
512 mutex_unlock(&state->ca_mutex); 521 mutex_unlock(&state->ca_mutex);
522 kfree(b);
513 return ret; 523 return ret;
514} 524}
515 525
@@ -556,7 +566,11 @@ static int CI_CamReady(struct dvb_ca_en50221 *ca, int slot)
556 u16 value; 566 u16 value;
557 u16 index; 567 u16 index;
558 int blen; 568 int blen;
559 u8 b[12]; 569 u8 *b;
570
571 b = kmalloc(12, GFP_KERNEL);
572 if (!b)
573 return -ENOMEM;
560 574
561 req = 0xC8; 575 req = 0xC8;
562 value = 0; 576 value = 0;
@@ -570,6 +584,7 @@ static int CI_CamReady(struct dvb_ca_en50221 *ca, int slot)
570 } else{ 584 } else{
571 ret = b[0]; 585 ret = b[0];
572 } 586 }
587 kfree(b);
573 return ret; 588 return ret;
574} 589}
575 590
@@ -667,8 +682,11 @@ static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int o
667 u16 value; 682 u16 value;
668 u16 index; 683 u16 index;
669 int blen; 684 int blen;
670 u8 b[12]; 685 u8 *b;
671 686
687 b = kmalloc(12, GFP_KERNEL);
688 if (!b)
689 return -ENOMEM;
672 mutex_lock(&state->ca_mutex); 690 mutex_lock(&state->ca_mutex);
673 691
674 req = 0xC5; 692 req = 0xC5;
@@ -683,15 +701,13 @@ static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int o
683 } else 701 } else
684 ret = 0; 702 ret = 0;
685 703
686 if (b[0] == 0) { 704 if (!ret && b[0] == 1) {
687 ret = 0;
688
689 } else if (b[0] == 1) {
690 ret = DVB_CA_EN50221_POLL_CAM_PRESENT | 705 ret = DVB_CA_EN50221_POLL_CAM_PRESENT |
691 DVB_CA_EN50221_POLL_CAM_READY; 706 DVB_CA_EN50221_POLL_CAM_READY;
692 } 707 }
693 708
694 mutex_unlock(&state->ca_mutex); 709 mutex_unlock(&state->ca_mutex);
710 kfree(b);
695 return ret; 711 return ret;
696} 712}
697 713
@@ -943,10 +959,16 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
943 u16 value; 959 u16 value;
944 int length; 960 int length;
945 u8 req; 961 u8 req;
946 u8 data[256]; 962 u8 *data;
947 963
948 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 964 data = kmalloc(256, GFP_KERNEL);
965 if (!data)
966 return -ENOMEM;
967
968 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) {
969 kfree(data);
949 return -EAGAIN; 970 return -EAGAIN;
971 }
950 972
951 if (num > 2) 973 if (num > 2)
952 warn("more than 2 i2c messages at a time is not handled yet. TODO."); 974 warn("more than 2 i2c messages at a time is not handled yet. TODO.");
@@ -976,17 +998,14 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
976 i++; 998 i++;
977 } else { 999 } else {
978 1000
979 if (msg[i].addr == 0xd0) { 1001 /* demod 16bit addr */
980 /* demod 16bit addr */ 1002 req = 0xBD;
981 req = 0xBD; 1003 index = (((msg[i].buf[0] << 8) & 0xff00) | (msg[i].buf[1] & 0x00ff));
982 index = (((msg[i].buf[0] << 8) & 0xff00) | (msg[i].buf[1] & 0x00ff)); 1004 value = msg[i].addr + (2 << 8);
983 value = msg[i].addr + (2 << 8); 1005 length = msg[i].len - 2;
984 length = msg[i].len - 2; 1006 len = msg[i].len - 2;
985 len = msg[i].len - 2; 1007 for (j = 0; j < len; j++)
986 for (j = 0; j < len; j++) 1008 data[j] = msg[i].buf[j + 2];
987 data[j] = msg[i].buf[j + 2];
988
989 }
990 az6027_usb_out_op(d, req, value, index, data, length); 1009 az6027_usb_out_op(d, req, value, index, data, length);
991 } 1010 }
992 } 1011 }
@@ -1019,6 +1038,7 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
1019 } 1038 }
1020 } 1039 }
1021 mutex_unlock(&d->i2c_mutex); 1040 mutex_unlock(&d->i2c_mutex);
1041 kfree(data);
1022 1042
1023 return i; 1043 return i;
1024} 1044}
@@ -1039,8 +1059,14 @@ int az6027_identify_state(struct usb_device *udev,
1039 struct dvb_usb_device_description **desc, 1059 struct dvb_usb_device_description **desc,
1040 int *cold) 1060 int *cold)
1041{ 1061{
1042 u8 b[16]; 1062 u8 *b;
1043 s16 ret = usb_control_msg(udev, 1063 s16 ret;
1064
1065 b = kmalloc(16, GFP_KERNEL);
1066 if (!b)
1067 return -ENOMEM;
1068
1069 ret = usb_control_msg(udev,
1044 usb_rcvctrlpipe(udev, 0), 1070 usb_rcvctrlpipe(udev, 0),
1045 0xb7, 1071 0xb7,
1046 USB_TYPE_VENDOR | USB_DIR_IN, 1072 USB_TYPE_VENDOR | USB_DIR_IN,
@@ -1051,7 +1077,7 @@ int az6027_identify_state(struct usb_device *udev,
1051 USB_CTRL_GET_TIMEOUT); 1077 USB_CTRL_GET_TIMEOUT);
1052 1078
1053 *cold = ret <= 0; 1079 *cold = ret <= 0;
1054 1080 kfree(b);
1055 deb_info("cold: %d\n", *cold); 1081 deb_info("cold: %d\n", *cold);
1056 return 0; 1082 return 0;
1057} 1083}
@@ -1059,8 +1085,10 @@ int az6027_identify_state(struct usb_device *udev,
1059 1085
1060static struct usb_device_id az6027_usb_table[] = { 1086static struct usb_device_id az6027_usb_table[] = {
1061 { USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_AZ6027) }, 1087 { USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_AZ6027) },
1062 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_DVBS2CI) }, 1088 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_DVBS2CI_V1) },
1063 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_USB2_HDCI) }, 1089 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_DVBS2CI_V2) },
1090 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_USB2_HDCI_V1) },
1091 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_USB2_HDCI_V2) },
1064 { }, 1092 { },
1065}; 1093};
1066 1094
@@ -1097,18 +1125,34 @@ static struct dvb_usb_device_properties az6027_properties = {
1097 .power_ctrl = az6027_power_ctrl, 1125 .power_ctrl = az6027_power_ctrl,
1098 .read_mac_address = az6027_read_mac_addr, 1126 .read_mac_address = az6027_read_mac_addr,
1099 */ 1127 */
1100 .rc_key_map = az6027_rc_keys, 1128 .rc_key_map = ir_codes_az6027_table,
1101 .rc_key_map_size = ARRAY_SIZE(az6027_rc_keys), 1129 .rc_key_map_size = ARRAY_SIZE(ir_codes_az6027_table),
1102 .rc_interval = 400, 1130 .rc_interval = 400,
1103 .rc_query = az6027_rc_query, 1131 .rc_query = az6027_rc_query,
1104 .i2c_algo = &az6027_i2c_algo, 1132 .i2c_algo = &az6027_i2c_algo,
1105 1133
1106 .num_device_descs = 1, 1134 .num_device_descs = 5,
1107 .devices = { 1135 .devices = {
1108 { 1136 {
1109 .name = "AZUREWAVE DVB-S/S2 USB2.0 (AZ6027)", 1137 .name = "AZUREWAVE DVB-S/S2 USB2.0 (AZ6027)",
1110 .cold_ids = { &az6027_usb_table[0], NULL }, 1138 .cold_ids = { &az6027_usb_table[0], NULL },
1111 .warm_ids = { NULL }, 1139 .warm_ids = { NULL },
1140 }, {
1141 .name = "TERRATEC S7",
1142 .cold_ids = { &az6027_usb_table[1], NULL },
1143 .warm_ids = { NULL },
1144 }, {
1145 .name = "TERRATEC S7 MKII",
1146 .cold_ids = { &az6027_usb_table[2], NULL },
1147 .warm_ids = { NULL },
1148 }, {
1149 .name = "Technisat SkyStar USB 2 HD CI",
1150 .cold_ids = { &az6027_usb_table[3], NULL },
1151 .warm_ids = { NULL },
1152 }, {
1153 .name = "Technisat SkyStar USB 2 HD CI",
1154 .cold_ids = { &az6027_usb_table[4], NULL },
1155 .warm_ids = { NULL },
1112 }, 1156 },
1113 { NULL }, 1157 { NULL },
1114 } 1158 }
diff --git a/drivers/media/dvb/dvb-usb/cinergyT2-core.c b/drivers/media/dvb/dvb-usb/cinergyT2-core.c
index e37ac4d48602..5a9c14bdc980 100644
--- a/drivers/media/dvb/dvb-usb/cinergyT2-core.c
+++ b/drivers/media/dvb/dvb-usb/cinergyT2-core.c
@@ -84,7 +84,7 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
84 return 0; 84 return 0;
85} 85}
86 86
87static struct dvb_usb_rc_key cinergyt2_rc_keys[] = { 87static struct dvb_usb_rc_key ir_codes_cinergyt2_table[] = {
88 { 0x0401, KEY_POWER }, 88 { 0x0401, KEY_POWER },
89 { 0x0402, KEY_1 }, 89 { 0x0402, KEY_1 },
90 { 0x0403, KEY_2 }, 90 { 0x0403, KEY_2 },
@@ -218,8 +218,8 @@ static struct dvb_usb_device_properties cinergyt2_properties = {
218 .power_ctrl = cinergyt2_power_ctrl, 218 .power_ctrl = cinergyt2_power_ctrl,
219 219
220 .rc_interval = 50, 220 .rc_interval = 50,
221 .rc_key_map = cinergyt2_rc_keys, 221 .rc_key_map = ir_codes_cinergyt2_table,
222 .rc_key_map_size = ARRAY_SIZE(cinergyt2_rc_keys), 222 .rc_key_map_size = ARRAY_SIZE(ir_codes_cinergyt2_table),
223 .rc_query = cinergyt2_rc_query, 223 .rc_query = cinergyt2_rc_query,
224 224
225 .generic_bulk_ctrl_endpoint = 1, 225 .generic_bulk_ctrl_endpoint = 1,
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index 960376da7d59..11e9e85dac86 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -461,7 +461,7 @@ static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
461 return 0; 461 return 0;
462} 462}
463 463
464static struct dvb_usb_rc_key dvico_mce_rc_keys[] = { 464static struct dvb_usb_rc_key ir_codes_dvico_mce_table[] = {
465 { 0xfe02, KEY_TV }, 465 { 0xfe02, KEY_TV },
466 { 0xfe0e, KEY_MP3 }, 466 { 0xfe0e, KEY_MP3 },
467 { 0xfe1a, KEY_DVD }, 467 { 0xfe1a, KEY_DVD },
@@ -509,7 +509,7 @@ static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
509 { 0xfe4e, KEY_POWER }, 509 { 0xfe4e, KEY_POWER },
510}; 510};
511 511
512static struct dvb_usb_rc_key dvico_portable_rc_keys[] = { 512static struct dvb_usb_rc_key ir_codes_dvico_portable_table[] = {
513 { 0xfc02, KEY_SETUP }, /* Profile */ 513 { 0xfc02, KEY_SETUP }, /* Profile */
514 { 0xfc43, KEY_POWER2 }, 514 { 0xfc43, KEY_POWER2 },
515 { 0xfc06, KEY_EPG }, 515 { 0xfc06, KEY_EPG },
@@ -548,7 +548,7 @@ static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
548 { 0xfc00, KEY_UNKNOWN }, /* HD */ 548 { 0xfc00, KEY_UNKNOWN }, /* HD */
549}; 549};
550 550
551static struct dvb_usb_rc_key d680_dmb_rc_keys[] = { 551static struct dvb_usb_rc_key ir_codes_d680_dmb_table[] = {
552 { 0x0038, KEY_UNKNOWN }, /* TV/AV */ 552 { 0x0038, KEY_UNKNOWN }, /* TV/AV */
553 { 0x080c, KEY_ZOOM }, 553 { 0x080c, KEY_ZOOM },
554 { 0x0800, KEY_0 }, 554 { 0x0800, KEY_0 },
@@ -1025,8 +1025,11 @@ static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
1025 1025
1026 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); 1026 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1027 1027
1028 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 1028 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1029 &cxusb_dualdig4_rev2_config); 1029 &cxusb_dualdig4_rev2_config) < 0) {
1030 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
1031 return -ENODEV;
1032 }
1030 1033
1031 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, 1034 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1032 &cxusb_dualdig4_rev2_config); 1035 &cxusb_dualdig4_rev2_config);
@@ -1449,8 +1452,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1449 .i2c_algo = &cxusb_i2c_algo, 1452 .i2c_algo = &cxusb_i2c_algo,
1450 1453
1451 .rc_interval = 100, 1454 .rc_interval = 100,
1452 .rc_key_map = dvico_portable_rc_keys, 1455 .rc_key_map = ir_codes_dvico_portable_table,
1453 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1456 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1454 .rc_query = cxusb_rc_query, 1457 .rc_query = cxusb_rc_query,
1455 1458
1456 .generic_bulk_ctrl_endpoint = 0x01, 1459 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1500,8 +1503,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1500 .i2c_algo = &cxusb_i2c_algo, 1503 .i2c_algo = &cxusb_i2c_algo,
1501 1504
1502 .rc_interval = 150, 1505 .rc_interval = 150,
1503 .rc_key_map = dvico_mce_rc_keys, 1506 .rc_key_map = ir_codes_dvico_mce_table,
1504 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), 1507 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1505 .rc_query = cxusb_rc_query, 1508 .rc_query = cxusb_rc_query,
1506 1509
1507 .generic_bulk_ctrl_endpoint = 0x01, 1510 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1559,8 +1562,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1559 .i2c_algo = &cxusb_i2c_algo, 1562 .i2c_algo = &cxusb_i2c_algo,
1560 1563
1561 .rc_interval = 100, 1564 .rc_interval = 100,
1562 .rc_key_map = dvico_portable_rc_keys, 1565 .rc_key_map = ir_codes_dvico_portable_table,
1563 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1566 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1564 .rc_query = cxusb_rc_query, 1567 .rc_query = cxusb_rc_query,
1565 1568
1566 .generic_bulk_ctrl_endpoint = 0x01, 1569 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1609,8 +1612,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1609 .i2c_algo = &cxusb_i2c_algo, 1612 .i2c_algo = &cxusb_i2c_algo,
1610 1613
1611 .rc_interval = 100, 1614 .rc_interval = 100,
1612 .rc_key_map = dvico_portable_rc_keys, 1615 .rc_key_map = ir_codes_dvico_portable_table,
1613 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1616 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1614 .rc_query = cxusb_rc_query, 1617 .rc_query = cxusb_rc_query,
1615 1618
1616 .generic_bulk_ctrl_endpoint = 0x01, 1619 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1658,8 +1661,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1658 .generic_bulk_ctrl_endpoint = 0x01, 1661 .generic_bulk_ctrl_endpoint = 0x01,
1659 1662
1660 .rc_interval = 100, 1663 .rc_interval = 100,
1661 .rc_key_map = dvico_mce_rc_keys, 1664 .rc_key_map = ir_codes_dvico_mce_table,
1662 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), 1665 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1663 .rc_query = cxusb_bluebird2_rc_query, 1666 .rc_query = cxusb_bluebird2_rc_query,
1664 1667
1665 .num_device_descs = 1, 1668 .num_device_descs = 1,
@@ -1706,8 +1709,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1706 .generic_bulk_ctrl_endpoint = 0x01, 1709 .generic_bulk_ctrl_endpoint = 0x01,
1707 1710
1708 .rc_interval = 100, 1711 .rc_interval = 100,
1709 .rc_key_map = dvico_portable_rc_keys, 1712 .rc_key_map = ir_codes_dvico_portable_table,
1710 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1713 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1711 .rc_query = cxusb_bluebird2_rc_query, 1714 .rc_query = cxusb_bluebird2_rc_query,
1712 1715
1713 .num_device_descs = 1, 1716 .num_device_descs = 1,
@@ -1756,8 +1759,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_prope
1756 .generic_bulk_ctrl_endpoint = 0x01, 1759 .generic_bulk_ctrl_endpoint = 0x01,
1757 1760
1758 .rc_interval = 100, 1761 .rc_interval = 100,
1759 .rc_key_map = dvico_portable_rc_keys, 1762 .rc_key_map = ir_codes_dvico_portable_table,
1760 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1763 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1761 .rc_query = cxusb_rc_query, 1764 .rc_query = cxusb_rc_query,
1762 1765
1763 .num_device_descs = 1, 1766 .num_device_descs = 1,
@@ -1847,8 +1850,8 @@ struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
1847 .generic_bulk_ctrl_endpoint = 0x01, 1850 .generic_bulk_ctrl_endpoint = 0x01,
1848 1851
1849 .rc_interval = 100, 1852 .rc_interval = 100,
1850 .rc_key_map = dvico_mce_rc_keys, 1853 .rc_key_map = ir_codes_dvico_mce_table,
1851 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), 1854 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1852 .rc_query = cxusb_rc_query, 1855 .rc_query = cxusb_rc_query,
1853 1856
1854 .num_device_descs = 1, 1857 .num_device_descs = 1,
@@ -1895,8 +1898,8 @@ static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
1895 .generic_bulk_ctrl_endpoint = 0x01, 1898 .generic_bulk_ctrl_endpoint = 0x01,
1896 1899
1897 .rc_interval = 100, 1900 .rc_interval = 100,
1898 .rc_key_map = d680_dmb_rc_keys, 1901 .rc_key_map = ir_codes_d680_dmb_table,
1899 .rc_key_map_size = ARRAY_SIZE(d680_dmb_rc_keys), 1902 .rc_key_map_size = ARRAY_SIZE(ir_codes_d680_dmb_table),
1900 .rc_query = cxusb_d680_dmb_rc_query, 1903 .rc_query = cxusb_d680_dmb_rc_query,
1901 1904
1902 .num_device_descs = 1, 1905 .num_device_descs = 1,
@@ -1944,8 +1947,8 @@ static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
1944 .generic_bulk_ctrl_endpoint = 0x01, 1947 .generic_bulk_ctrl_endpoint = 0x01,
1945 1948
1946 .rc_interval = 100, 1949 .rc_interval = 100,
1947 .rc_key_map = d680_dmb_rc_keys, 1950 .rc_key_map = ir_codes_d680_dmb_table,
1948 .rc_key_map_size = ARRAY_SIZE(d680_dmb_rc_keys), 1951 .rc_key_map_size = ARRAY_SIZE(ir_codes_d680_dmb_table),
1949 .rc_query = cxusb_d680_dmb_rc_query, 1952 .rc_query = cxusb_d680_dmb_rc_query,
1950 1953
1951 .num_device_descs = 1, 1954 .num_device_descs = 1,
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 34eab05afc6c..800800a9649e 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -562,7 +562,7 @@ static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
562 return 0; 562 return 0;
563} 563}
564 564
565static struct dvb_usb_rc_key dib0700_rc_keys[] = { 565static struct dvb_usb_rc_key ir_codes_dib0700_table[] = {
566 /* Key codes for the tiny Pinnacle remote*/ 566 /* Key codes for the tiny Pinnacle remote*/
567 { 0x0700, KEY_MUTE }, 567 { 0x0700, KEY_MUTE },
568 { 0x0701, KEY_MENU }, /* Pinnacle logo */ 568 { 0x0701, KEY_MENU }, /* Pinnacle logo */
@@ -794,6 +794,43 @@ static struct dvb_usb_rc_key dib0700_rc_keys[] = {
794 { 0x7a13, KEY_VOLUMEDOWN }, 794 { 0x7a13, KEY_VOLUMEDOWN },
795 { 0x7a40, KEY_POWER }, 795 { 0x7a40, KEY_POWER },
796 { 0x7a41, KEY_MUTE }, 796 { 0x7a41, KEY_MUTE },
797
798 /* Key codes for the Elgato EyeTV Diversity silver remote,
799 set dvb_usb_dib0700_ir_proto=0 */
800 { 0x4501, KEY_POWER },
801 { 0x4502, KEY_MUTE },
802 { 0x4503, KEY_1 },
803 { 0x4504, KEY_2 },
804 { 0x4505, KEY_3 },
805 { 0x4506, KEY_4 },
806 { 0x4507, KEY_5 },
807 { 0x4508, KEY_6 },
808 { 0x4509, KEY_7 },
809 { 0x450a, KEY_8 },
810 { 0x450b, KEY_9 },
811 { 0x450c, KEY_LAST },
812 { 0x450d, KEY_0 },
813 { 0x450e, KEY_ENTER },
814 { 0x450f, KEY_RED },
815 { 0x4510, KEY_CHANNELUP },
816 { 0x4511, KEY_GREEN },
817 { 0x4512, KEY_VOLUMEDOWN },
818 { 0x4513, KEY_OK },
819 { 0x4514, KEY_VOLUMEUP },
820 { 0x4515, KEY_YELLOW },
821 { 0x4516, KEY_CHANNELDOWN },
822 { 0x4517, KEY_BLUE },
823 { 0x4518, KEY_LEFT }, /* Skip backwards */
824 { 0x4519, KEY_PLAYPAUSE },
825 { 0x451a, KEY_RIGHT }, /* Skip forward */
826 { 0x451b, KEY_REWIND },
827 { 0x451c, KEY_L }, /* Live */
828 { 0x451d, KEY_FASTFORWARD },
829 { 0x451e, KEY_STOP }, /* 'Reveal' for Teletext */
830 { 0x451f, KEY_MENU }, /* KEY_TEXT for Teletext */
831 { 0x4540, KEY_RECORD }, /* Font 'Size' for Teletext */
832 { 0x4541, KEY_SCREEN }, /* Full screen toggle, 'Hold' for Teletext */
833 { 0x4542, KEY_SELECT }, /* Select video input, 'Select' for Teletext */
797}; 834};
798 835
799/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */ 836/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
@@ -2049,6 +2086,7 @@ struct usb_device_id dib0700_usb_id_table[] = {
2049/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) }, 2086/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
2050 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, 2087 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
2051 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) }, 2088 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
2089 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
2052 { 0 } /* Terminating entry */ 2090 { 0 } /* Terminating entry */
2053}; 2091};
2054MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 2092MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -2131,8 +2169,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2131 }, 2169 },
2132 2170
2133 .rc_interval = DEFAULT_RC_INTERVAL, 2171 .rc_interval = DEFAULT_RC_INTERVAL,
2134 .rc_key_map = dib0700_rc_keys, 2172 .rc_key_map = ir_codes_dib0700_table,
2135 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2173 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2136 .rc_query = dib0700_rc_query 2174 .rc_query = dib0700_rc_query
2137 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2175 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2138 2176
@@ -2160,8 +2198,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2160 }, 2198 },
2161 2199
2162 .rc_interval = DEFAULT_RC_INTERVAL, 2200 .rc_interval = DEFAULT_RC_INTERVAL,
2163 .rc_key_map = dib0700_rc_keys, 2201 .rc_key_map = ir_codes_dib0700_table,
2164 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2202 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2165 .rc_query = dib0700_rc_query 2203 .rc_query = dib0700_rc_query
2166 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2204 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2167 2205
@@ -2214,8 +2252,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2214 }, 2252 },
2215 2253
2216 .rc_interval = DEFAULT_RC_INTERVAL, 2254 .rc_interval = DEFAULT_RC_INTERVAL,
2217 .rc_key_map = dib0700_rc_keys, 2255 .rc_key_map = ir_codes_dib0700_table,
2218 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2256 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2219 .rc_query = dib0700_rc_query 2257 .rc_query = dib0700_rc_query
2220 2258
2221 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2259 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -2251,8 +2289,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2251 }, 2289 },
2252 2290
2253 .rc_interval = DEFAULT_RC_INTERVAL, 2291 .rc_interval = DEFAULT_RC_INTERVAL,
2254 .rc_key_map = dib0700_rc_keys, 2292 .rc_key_map = ir_codes_dib0700_table,
2255 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2293 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2256 .rc_query = dib0700_rc_query 2294 .rc_query = dib0700_rc_query
2257 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2295 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2258 2296
@@ -2321,8 +2359,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2321 }, 2359 },
2322 2360
2323 .rc_interval = DEFAULT_RC_INTERVAL, 2361 .rc_interval = DEFAULT_RC_INTERVAL,
2324 .rc_key_map = dib0700_rc_keys, 2362 .rc_key_map = ir_codes_dib0700_table,
2325 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2363 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2326 .rc_query = dib0700_rc_query 2364 .rc_query = dib0700_rc_query
2327 2365
2328 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2366 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -2360,8 +2398,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2360 }, 2398 },
2361 2399
2362 .rc_interval = DEFAULT_RC_INTERVAL, 2400 .rc_interval = DEFAULT_RC_INTERVAL,
2363 .rc_key_map = dib0700_rc_keys, 2401 .rc_key_map = ir_codes_dib0700_table,
2364 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2402 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2365 .rc_query = dib0700_rc_query 2403 .rc_query = dib0700_rc_query
2366 2404
2367 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2405 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -2393,7 +2431,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2393 } 2431 }
2394 }, 2432 },
2395 2433
2396 .num_device_descs = 6, 2434 .num_device_descs = 7,
2397 .devices = { 2435 .devices = {
2398 { "DiBcom STK7070PD reference design", 2436 { "DiBcom STK7070PD reference design",
2399 { &dib0700_usb_id_table[17], NULL }, 2437 { &dib0700_usb_id_table[17], NULL },
@@ -2419,11 +2457,15 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2419 { "Sony PlayTV", 2457 { "Sony PlayTV",
2420 { &dib0700_usb_id_table[44], NULL }, 2458 { &dib0700_usb_id_table[44], NULL },
2421 { NULL }, 2459 { NULL },
2422 } 2460 },
2461 { "Elgato EyeTV Diversity",
2462 { &dib0700_usb_id_table[68], NULL },
2463 { NULL },
2464 },
2423 }, 2465 },
2424 .rc_interval = DEFAULT_RC_INTERVAL, 2466 .rc_interval = DEFAULT_RC_INTERVAL,
2425 .rc_key_map = dib0700_rc_keys, 2467 .rc_key_map = ir_codes_dib0700_table,
2426 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2468 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2427 .rc_query = dib0700_rc_query 2469 .rc_query = dib0700_rc_query
2428 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2470 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2429 2471
@@ -2484,8 +2526,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2484 }, 2526 },
2485 }, 2527 },
2486 .rc_interval = DEFAULT_RC_INTERVAL, 2528 .rc_interval = DEFAULT_RC_INTERVAL,
2487 .rc_key_map = dib0700_rc_keys, 2529 .rc_key_map = ir_codes_dib0700_table,
2488 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2530 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2489 .rc_query = dib0700_rc_query 2531 .rc_query = dib0700_rc_query
2490 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2532 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2491 .num_adapters = 1, 2533 .num_adapters = 1,
@@ -2513,8 +2555,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2513 }, 2555 },
2514 }, 2556 },
2515 .rc_interval = DEFAULT_RC_INTERVAL, 2557 .rc_interval = DEFAULT_RC_INTERVAL,
2516 .rc_key_map = dib0700_rc_keys, 2558 .rc_key_map = ir_codes_dib0700_table,
2517 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2559 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2518 .rc_query = dib0700_rc_query 2560 .rc_query = dib0700_rc_query
2519 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2561 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2520 .num_adapters = 1, 2562 .num_adapters = 1,
@@ -2574,8 +2616,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2574 }, 2616 },
2575 }, 2617 },
2576 .rc_interval = DEFAULT_RC_INTERVAL, 2618 .rc_interval = DEFAULT_RC_INTERVAL,
2577 .rc_key_map = dib0700_rc_keys, 2619 .rc_key_map = ir_codes_dib0700_table,
2578 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2620 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2579 .rc_query = dib0700_rc_query 2621 .rc_query = dib0700_rc_query
2580 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2622 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2581 .num_adapters = 1, 2623 .num_adapters = 1,
@@ -2612,8 +2654,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2612 }, 2654 },
2613 2655
2614 .rc_interval = DEFAULT_RC_INTERVAL, 2656 .rc_interval = DEFAULT_RC_INTERVAL,
2615 .rc_key_map = dib0700_rc_keys, 2657 .rc_key_map = ir_codes_dib0700_table,
2616 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2658 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2617 .rc_query = dib0700_rc_query 2659 .rc_query = dib0700_rc_query
2618 2660
2619 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2661 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -2656,8 +2698,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2656 }, 2698 },
2657 2699
2658 .rc_interval = DEFAULT_RC_INTERVAL, 2700 .rc_interval = DEFAULT_RC_INTERVAL,
2659 .rc_key_map = dib0700_rc_keys, 2701 .rc_key_map = ir_codes_dib0700_table,
2660 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2702 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2661 .rc_query = dib0700_rc_query 2703 .rc_query = dib0700_rc_query
2662 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2704 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2663 .num_adapters = 1, 2705 .num_adapters = 1,
@@ -2687,8 +2729,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2687 }, 2729 },
2688 2730
2689 .rc_interval = DEFAULT_RC_INTERVAL, 2731 .rc_interval = DEFAULT_RC_INTERVAL,
2690 .rc_key_map = dib0700_rc_keys, 2732 .rc_key_map = ir_codes_dib0700_table,
2691 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2733 .rc_key_map_size = ARRAY_SIZE(ir_codes_dib0700_table),
2692 .rc_query = dib0700_rc_query 2734 .rc_query = dib0700_rc_query
2693 }, 2735 },
2694}; 2736};
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 9143b5631e88..bc08bc0b723c 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -327,7 +327,7 @@ EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach);
327/* 327/*
328 * common remote control stuff 328 * common remote control stuff
329 */ 329 */
330struct dvb_usb_rc_key dibusb_rc_keys[] = { 330struct dvb_usb_rc_key ir_codes_dibusb_table[] = {
331 /* Key codes for the little Artec T1/Twinhan/HAMA/ remote. */ 331 /* Key codes for the little Artec T1/Twinhan/HAMA/ remote. */
332 { 0x0016, KEY_POWER }, 332 { 0x0016, KEY_POWER },
333 { 0x0010, KEY_MUTE }, 333 { 0x0010, KEY_MUTE },
@@ -456,7 +456,7 @@ struct dvb_usb_rc_key dibusb_rc_keys[] = {
456 { 0x804e, KEY_ENTER }, 456 { 0x804e, KEY_ENTER },
457 { 0x804f, KEY_VOLUMEDOWN }, 457 { 0x804f, KEY_VOLUMEDOWN },
458}; 458};
459EXPORT_SYMBOL(dibusb_rc_keys); 459EXPORT_SYMBOL(ir_codes_dibusb_table);
460 460
461int dibusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 461int dibusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
462{ 462{
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c
index 5c0126dc1ff9..eb2e6f050fbe 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mb.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c
@@ -212,7 +212,7 @@ static struct dvb_usb_device_properties dibusb1_1_properties = {
212 .power_ctrl = dibusb_power_ctrl, 212 .power_ctrl = dibusb_power_ctrl,
213 213
214 .rc_interval = DEFAULT_RC_INTERVAL, 214 .rc_interval = DEFAULT_RC_INTERVAL,
215 .rc_key_map = dibusb_rc_keys, 215 .rc_key_map = ir_codes_dibusb_table,
216 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ 216 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
217 .rc_query = dibusb_rc_query, 217 .rc_query = dibusb_rc_query,
218 218
@@ -296,7 +296,7 @@ static struct dvb_usb_device_properties dibusb1_1_an2235_properties = {
296 .power_ctrl = dibusb_power_ctrl, 296 .power_ctrl = dibusb_power_ctrl,
297 297
298 .rc_interval = DEFAULT_RC_INTERVAL, 298 .rc_interval = DEFAULT_RC_INTERVAL,
299 .rc_key_map = dibusb_rc_keys, 299 .rc_key_map = ir_codes_dibusb_table,
300 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ 300 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
301 .rc_query = dibusb_rc_query, 301 .rc_query = dibusb_rc_query,
302 302
@@ -360,7 +360,7 @@ static struct dvb_usb_device_properties dibusb2_0b_properties = {
360 .power_ctrl = dibusb2_0_power_ctrl, 360 .power_ctrl = dibusb2_0_power_ctrl,
361 361
362 .rc_interval = DEFAULT_RC_INTERVAL, 362 .rc_interval = DEFAULT_RC_INTERVAL,
363 .rc_key_map = dibusb_rc_keys, 363 .rc_key_map = ir_codes_dibusb_table,
364 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ 364 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
365 .rc_query = dibusb_rc_query, 365 .rc_query = dibusb_rc_query,
366 366
@@ -417,7 +417,7 @@ static struct dvb_usb_device_properties artec_t1_usb2_properties = {
417 .power_ctrl = dibusb2_0_power_ctrl, 417 .power_ctrl = dibusb2_0_power_ctrl,
418 418
419 .rc_interval = DEFAULT_RC_INTERVAL, 419 .rc_interval = DEFAULT_RC_INTERVAL,
420 .rc_key_map = dibusb_rc_keys, 420 .rc_key_map = ir_codes_dibusb_table,
421 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ 421 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
422 .rc_query = dibusb_rc_query, 422 .rc_query = dibusb_rc_query,
423 423
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
index a05b9f875663..588308eb6638 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c
@@ -82,7 +82,7 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
82 .power_ctrl = dibusb2_0_power_ctrl, 82 .power_ctrl = dibusb2_0_power_ctrl,
83 83
84 .rc_interval = DEFAULT_RC_INTERVAL, 84 .rc_interval = DEFAULT_RC_INTERVAL,
85 .rc_key_map = dibusb_rc_keys, 85 .rc_key_map = ir_codes_dibusb_table,
86 .rc_key_map_size = 111, /* FIXME */ 86 .rc_key_map_size = 111, /* FIXME */
87 .rc_query = dibusb_rc_query, 87 .rc_query = dibusb_rc_query,
88 88
diff --git a/drivers/media/dvb/dvb-usb/dibusb.h b/drivers/media/dvb/dvb-usb/dibusb.h
index 8e847aa73ba1..3d50ac59088f 100644
--- a/drivers/media/dvb/dvb-usb/dibusb.h
+++ b/drivers/media/dvb/dvb-usb/dibusb.h
@@ -124,7 +124,7 @@ extern int dibusb2_0_power_ctrl(struct dvb_usb_device *, int);
124#define DEFAULT_RC_INTERVAL 150 124#define DEFAULT_RC_INTERVAL 150
125//#define DEFAULT_RC_INTERVAL 100000 125//#define DEFAULT_RC_INTERVAL 100000
126 126
127extern struct dvb_usb_rc_key dibusb_rc_keys[]; 127extern struct dvb_usb_rc_key ir_codes_dibusb_table[];
128extern int dibusb_rc_query(struct dvb_usb_device *, u32 *, int *); 128extern int dibusb_rc_query(struct dvb_usb_device *, u32 *, int *);
129extern int dibusb_read_eeprom_byte(struct dvb_usb_device *, u8, u8 *); 129extern int dibusb_read_eeprom_byte(struct dvb_usb_device *, u8, u8 *);
130 130
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index 955147d00756..e826077094fa 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -161,7 +161,7 @@ static int digitv_tuner_attach(struct dvb_usb_adapter *adap)
161 return 0; 161 return 0;
162} 162}
163 163
164static struct dvb_usb_rc_key digitv_rc_keys[] = { 164static struct dvb_usb_rc_key ir_codes_digitv_table[] = {
165 { 0x5f55, KEY_0 }, 165 { 0x5f55, KEY_0 },
166 { 0x6f55, KEY_1 }, 166 { 0x6f55, KEY_1 },
167 { 0x9f55, KEY_2 }, 167 { 0x9f55, KEY_2 },
@@ -311,8 +311,8 @@ static struct dvb_usb_device_properties digitv_properties = {
311 .identify_state = digitv_identify_state, 311 .identify_state = digitv_identify_state,
312 312
313 .rc_interval = 1000, 313 .rc_interval = 1000,
314 .rc_key_map = digitv_rc_keys, 314 .rc_key_map = ir_codes_digitv_table,
315 .rc_key_map_size = ARRAY_SIZE(digitv_rc_keys), 315 .rc_key_map_size = ARRAY_SIZE(ir_codes_digitv_table),
316 .rc_query = digitv_rc_query, 316 .rc_query = digitv_rc_query,
317 317
318 .i2c_algo = &digitv_i2c_algo, 318 .i2c_algo = &digitv_i2c_algo,
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c
index a1b12b01cbe4..f57e59044d4d 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u.c
@@ -57,7 +57,7 @@ static int dtt200u_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
57 57
58/* remote control */ 58/* remote control */
59/* key list for the tiny remote control (Yakumo, don't know about the others) */ 59/* key list for the tiny remote control (Yakumo, don't know about the others) */
60static struct dvb_usb_rc_key dtt200u_rc_keys[] = { 60static struct dvb_usb_rc_key ir_codes_dtt200u_table[] = {
61 { 0x8001, KEY_MUTE }, 61 { 0x8001, KEY_MUTE },
62 { 0x8002, KEY_CHANNELDOWN }, 62 { 0x8002, KEY_CHANNELDOWN },
63 { 0x8003, KEY_VOLUMEDOWN }, 63 { 0x8003, KEY_VOLUMEDOWN },
@@ -162,8 +162,8 @@ static struct dvb_usb_device_properties dtt200u_properties = {
162 .power_ctrl = dtt200u_power_ctrl, 162 .power_ctrl = dtt200u_power_ctrl,
163 163
164 .rc_interval = 300, 164 .rc_interval = 300,
165 .rc_key_map = dtt200u_rc_keys, 165 .rc_key_map = ir_codes_dtt200u_table,
166 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), 166 .rc_key_map_size = ARRAY_SIZE(ir_codes_dtt200u_table),
167 .rc_query = dtt200u_rc_query, 167 .rc_query = dtt200u_rc_query,
168 168
169 .generic_bulk_ctrl_endpoint = 0x01, 169 .generic_bulk_ctrl_endpoint = 0x01,
@@ -207,8 +207,8 @@ static struct dvb_usb_device_properties wt220u_properties = {
207 .power_ctrl = dtt200u_power_ctrl, 207 .power_ctrl = dtt200u_power_ctrl,
208 208
209 .rc_interval = 300, 209 .rc_interval = 300,
210 .rc_key_map = dtt200u_rc_keys, 210 .rc_key_map = ir_codes_dtt200u_table,
211 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), 211 .rc_key_map_size = ARRAY_SIZE(ir_codes_dtt200u_table),
212 .rc_query = dtt200u_rc_query, 212 .rc_query = dtt200u_rc_query,
213 213
214 .generic_bulk_ctrl_endpoint = 0x01, 214 .generic_bulk_ctrl_endpoint = 0x01,
@@ -252,8 +252,8 @@ static struct dvb_usb_device_properties wt220u_fc_properties = {
252 .power_ctrl = dtt200u_power_ctrl, 252 .power_ctrl = dtt200u_power_ctrl,
253 253
254 .rc_interval = 300, 254 .rc_interval = 300,
255 .rc_key_map = dtt200u_rc_keys, 255 .rc_key_map = ir_codes_dtt200u_table,
256 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), 256 .rc_key_map_size = ARRAY_SIZE(ir_codes_dtt200u_table),
257 .rc_query = dtt200u_rc_query, 257 .rc_query = dtt200u_rc_query,
258 258
259 .generic_bulk_ctrl_endpoint = 0x01, 259 .generic_bulk_ctrl_endpoint = 0x01,
@@ -297,8 +297,8 @@ static struct dvb_usb_device_properties wt220u_zl0353_properties = {
297 .power_ctrl = dtt200u_power_ctrl, 297 .power_ctrl = dtt200u_power_ctrl,
298 298
299 .rc_interval = 300, 299 .rc_interval = 300,
300 .rc_key_map = dtt200u_rc_keys, 300 .rc_key_map = ir_codes_dtt200u_table,
301 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), 301 .rc_key_map_size = ARRAY_SIZE(ir_codes_dtt200u_table),
302 .rc_query = dtt200u_rc_query, 302 .rc_query = dtt200u_rc_query,
303 303
304 .generic_bulk_ctrl_endpoint = 0x01, 304 .generic_bulk_ctrl_endpoint = 0x01,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index ae8b57acfe05..b4afe6f8ed19 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -124,9 +124,11 @@
124#define USB_PID_KWORLD_395U 0xe396 124#define USB_PID_KWORLD_395U 0xe396
125#define USB_PID_KWORLD_395U_2 0xe39b 125#define USB_PID_KWORLD_395U_2 0xe39b
126#define USB_PID_KWORLD_395U_3 0xe395 126#define USB_PID_KWORLD_395U_3 0xe395
127#define USB_PID_KWORLD_395U_4 0xe39a
127#define USB_PID_KWORLD_MC810 0xc810 128#define USB_PID_KWORLD_MC810 0xc810
128#define USB_PID_KWORLD_PC160_2T 0xc160 129#define USB_PID_KWORLD_PC160_2T 0xc160
129#define USB_PID_KWORLD_PC160_T 0xc161 130#define USB_PID_KWORLD_PC160_T 0xc161
131#define USB_PID_KWORLD_UB383_T 0xe383
130#define USB_PID_KWORLD_VSTREAM_COLD 0x17de 132#define USB_PID_KWORLD_VSTREAM_COLD 0x17de
131#define USB_PID_KWORLD_VSTREAM_WARM 0x17df 133#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
132#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055 134#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055
@@ -196,6 +198,7 @@
196#define USB_PID_AVERMEDIA_A850 0x850a 198#define USB_PID_AVERMEDIA_A850 0x850a
197#define USB_PID_AVERMEDIA_A805 0xa805 199#define USB_PID_AVERMEDIA_A805 0xa805
198#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 200#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006
201#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
199#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a 202#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
200#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081 203#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
201#define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058 204#define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058
@@ -288,6 +291,7 @@
288#define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807 291#define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807
289#define USB_PID_SONY_PLAYTV 0x0003 292#define USB_PID_SONY_PLAYTV 0x0003
290#define USB_PID_MYGICA_D689 0xd811 293#define USB_PID_MYGICA_D689 0xd811
294#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011
291#define USB_PID_ELGATO_EYETV_DTT 0x0021 295#define USB_PID_ELGATO_EYETV_DTT 0x0021
292#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020 296#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020
293#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000 297#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000
@@ -296,6 +300,8 @@
296#define USB_PID_TVWAY_PLUS 0x0002 300#define USB_PID_TVWAY_PLUS 0x0002
297#define USB_PID_SVEON_STV20 0xe39d 301#define USB_PID_SVEON_STV20 0xe39d
298#define USB_PID_AZUREWAVE_AZ6027 0x3275 302#define USB_PID_AZUREWAVE_AZ6027 0x3275
299#define USB_PID_TERRATEC_DVBS2CI 0x3275 303#define USB_PID_TERRATEC_DVBS2CI_V1 0x10a4
300#define USB_PID_TECHNISAT_USB2_HDCI 0x0002 304#define USB_PID_TERRATEC_DVBS2CI_V2 0x10ac
305#define USB_PID_TECHNISAT_USB2_HDCI_V1 0x0001
306#define USB_PID_TECHNISAT_USB2_HDCI_V2 0x0002
301#endif 307#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
index 6fe71c6745eb..bb46ba6a3573 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
@@ -42,6 +42,8 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
42 msleep(delay_ms); 42 msleep(delay_ms);
43 43
44 ret = usb_bulk_msg(d->udev,usb_rcvbulkpipe(d->udev, 44 ret = usb_bulk_msg(d->udev,usb_rcvbulkpipe(d->udev,
45 d->props.generic_bulk_ctrl_endpoint_response ?
46 d->props.generic_bulk_ctrl_endpoint_response :
45 d->props.generic_bulk_ctrl_endpoint),rbuf,rlen,&actlen, 47 d->props.generic_bulk_ctrl_endpoint),rbuf,rlen,&actlen,
46 2000); 48 2000);
47 49
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 0143aef19ecd..4a9f676087bf 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -198,6 +198,12 @@ struct dvb_usb_adapter_properties {
198 * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write- 198 * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write-
199 * helper functions. 199 * helper functions.
200 * 200 *
201 * @generic_bulk_ctrl_endpoint_response: some DVB USB devices use a separate
202 * endpoint for responses to control messages sent with bulk transfers via
203 * the generic_bulk_ctrl_endpoint. When this is non-zero, this will be used
204 * instead of the generic_bulk_ctrl_endpoint when reading usb responses in
205 * the dvb_usb_generic_rw helper function.
206 *
201 * @num_device_descs: number of struct dvb_usb_device_description in @devices 207 * @num_device_descs: number of struct dvb_usb_device_description in @devices
202 * @devices: array of struct dvb_usb_device_description compatibles with these 208 * @devices: array of struct dvb_usb_device_description compatibles with these
203 * properties. 209 * properties.
@@ -239,6 +245,7 @@ struct dvb_usb_device_properties {
239 struct i2c_algorithm *i2c_algo; 245 struct i2c_algorithm *i2c_algo;
240 246
241 int generic_bulk_ctrl_endpoint; 247 int generic_bulk_ctrl_endpoint;
248 int generic_bulk_ctrl_endpoint_response;
242 249
243 int num_device_descs; 250 int num_device_descs;
244 struct dvb_usb_device_description devices[12]; 251 struct dvb_usb_device_description devices[12];
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
index accc65509b07..e8fb85380672 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -73,7 +73,7 @@
73 "Please see linux/Documentation/dvb/ for more details " \ 73 "Please see linux/Documentation/dvb/ for more details " \
74 "on firmware-problems." 74 "on firmware-problems."
75 75
76struct dvb_usb_rc_keys_table { 76struct ir_codes_dvb_usb_table_table {
77 struct dvb_usb_rc_key *rc_keys; 77 struct dvb_usb_rc_key *rc_keys;
78 int rc_keys_size; 78 int rc_keys_size;
79}; 79};
@@ -948,7 +948,7 @@ static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
948 return 0; 948 return 0;
949} 949}
950 950
951static struct dvb_usb_rc_key dw210x_rc_keys[] = { 951static struct dvb_usb_rc_key ir_codes_dw210x_table[] = {
952 { 0xf80a, KEY_Q }, /*power*/ 952 { 0xf80a, KEY_Q }, /*power*/
953 { 0xf80c, KEY_M }, /*mute*/ 953 { 0xf80c, KEY_M }, /*mute*/
954 { 0xf811, KEY_1 }, 954 { 0xf811, KEY_1 },
@@ -982,7 +982,7 @@ static struct dvb_usb_rc_key dw210x_rc_keys[] = {
982 { 0xf81b, KEY_B }, /*recall*/ 982 { 0xf81b, KEY_B }, /*recall*/
983}; 983};
984 984
985static struct dvb_usb_rc_key tevii_rc_keys[] = { 985static struct dvb_usb_rc_key ir_codes_tevii_table[] = {
986 { 0xf80a, KEY_POWER }, 986 { 0xf80a, KEY_POWER },
987 { 0xf80c, KEY_MUTE }, 987 { 0xf80c, KEY_MUTE },
988 { 0xf811, KEY_1 }, 988 { 0xf811, KEY_1 },
@@ -1032,7 +1032,7 @@ static struct dvb_usb_rc_key tevii_rc_keys[] = {
1032 { 0xf858, KEY_SWITCHVIDEOMODE }, 1032 { 0xf858, KEY_SWITCHVIDEOMODE },
1033}; 1033};
1034 1034
1035static struct dvb_usb_rc_key tbs_rc_keys[] = { 1035static struct dvb_usb_rc_key ir_codes_tbs_table[] = {
1036 { 0xf884, KEY_POWER }, 1036 { 0xf884, KEY_POWER },
1037 { 0xf894, KEY_MUTE }, 1037 { 0xf894, KEY_MUTE },
1038 { 0xf887, KEY_1 }, 1038 { 0xf887, KEY_1 },
@@ -1067,10 +1067,10 @@ static struct dvb_usb_rc_key tbs_rc_keys[] = {
1067 { 0xf89b, KEY_MODE } 1067 { 0xf89b, KEY_MODE }
1068}; 1068};
1069 1069
1070static struct dvb_usb_rc_keys_table keys_tables[] = { 1070static struct ir_codes_dvb_usb_table_table keys_tables[] = {
1071 { dw210x_rc_keys, ARRAY_SIZE(dw210x_rc_keys) }, 1071 { ir_codes_dw210x_table, ARRAY_SIZE(ir_codes_dw210x_table) },
1072 { tevii_rc_keys, ARRAY_SIZE(tevii_rc_keys) }, 1072 { ir_codes_tevii_table, ARRAY_SIZE(ir_codes_tevii_table) },
1073 { tbs_rc_keys, ARRAY_SIZE(tbs_rc_keys) }, 1073 { ir_codes_tbs_table, ARRAY_SIZE(ir_codes_tbs_table) },
1074}; 1074};
1075 1075
1076static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 1076static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
@@ -1185,14 +1185,14 @@ static int dw2102_load_firmware(struct usb_device *dev,
1185 /* init registers */ 1185 /* init registers */
1186 switch (dev->descriptor.idProduct) { 1186 switch (dev->descriptor.idProduct) {
1187 case USB_PID_PROF_1100: 1187 case USB_PID_PROF_1100:
1188 s6x0_properties.rc_key_map = tbs_rc_keys; 1188 s6x0_properties.rc_key_map = ir_codes_tbs_table;
1189 s6x0_properties.rc_key_map_size = 1189 s6x0_properties.rc_key_map_size =
1190 ARRAY_SIZE(tbs_rc_keys); 1190 ARRAY_SIZE(ir_codes_tbs_table);
1191 break; 1191 break;
1192 case USB_PID_TEVII_S650: 1192 case USB_PID_TEVII_S650:
1193 dw2104_properties.rc_key_map = tevii_rc_keys; 1193 dw2104_properties.rc_key_map = ir_codes_tevii_table;
1194 dw2104_properties.rc_key_map_size = 1194 dw2104_properties.rc_key_map_size =
1195 ARRAY_SIZE(tevii_rc_keys); 1195 ARRAY_SIZE(ir_codes_tevii_table);
1196 case USB_PID_DW2104: 1196 case USB_PID_DW2104:
1197 reset = 1; 1197 reset = 1;
1198 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, 1198 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
@@ -1255,8 +1255,8 @@ static struct dvb_usb_device_properties dw2102_properties = {
1255 .no_reconnect = 1, 1255 .no_reconnect = 1,
1256 1256
1257 .i2c_algo = &dw2102_serit_i2c_algo, 1257 .i2c_algo = &dw2102_serit_i2c_algo,
1258 .rc_key_map = dw210x_rc_keys, 1258 .rc_key_map = ir_codes_dw210x_table,
1259 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys), 1259 .rc_key_map_size = ARRAY_SIZE(ir_codes_dw210x_table),
1260 .rc_interval = 150, 1260 .rc_interval = 150,
1261 .rc_query = dw2102_rc_query, 1261 .rc_query = dw2102_rc_query,
1262 1262
@@ -1306,8 +1306,8 @@ static struct dvb_usb_device_properties dw2104_properties = {
1306 .no_reconnect = 1, 1306 .no_reconnect = 1,
1307 1307
1308 .i2c_algo = &dw2104_i2c_algo, 1308 .i2c_algo = &dw2104_i2c_algo,
1309 .rc_key_map = dw210x_rc_keys, 1309 .rc_key_map = ir_codes_dw210x_table,
1310 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys), 1310 .rc_key_map_size = ARRAY_SIZE(ir_codes_dw210x_table),
1311 .rc_interval = 150, 1311 .rc_interval = 150,
1312 .rc_query = dw2102_rc_query, 1312 .rc_query = dw2102_rc_query,
1313 1313
@@ -1353,8 +1353,8 @@ static struct dvb_usb_device_properties dw3101_properties = {
1353 .no_reconnect = 1, 1353 .no_reconnect = 1,
1354 1354
1355 .i2c_algo = &dw3101_i2c_algo, 1355 .i2c_algo = &dw3101_i2c_algo,
1356 .rc_key_map = dw210x_rc_keys, 1356 .rc_key_map = ir_codes_dw210x_table,
1357 .rc_key_map_size = ARRAY_SIZE(dw210x_rc_keys), 1357 .rc_key_map_size = ARRAY_SIZE(ir_codes_dw210x_table),
1358 .rc_interval = 150, 1358 .rc_interval = 150,
1359 .rc_query = dw2102_rc_query, 1359 .rc_query = dw2102_rc_query,
1360 1360
@@ -1396,8 +1396,8 @@ static struct dvb_usb_device_properties s6x0_properties = {
1396 .no_reconnect = 1, 1396 .no_reconnect = 1,
1397 1397
1398 .i2c_algo = &s6x0_i2c_algo, 1398 .i2c_algo = &s6x0_i2c_algo,
1399 .rc_key_map = tevii_rc_keys, 1399 .rc_key_map = ir_codes_tevii_table,
1400 .rc_key_map_size = ARRAY_SIZE(tevii_rc_keys), 1400 .rc_key_map_size = ARRAY_SIZE(ir_codes_tevii_table),
1401 .rc_interval = 150, 1401 .rc_interval = 150,
1402 .rc_query = dw2102_rc_query, 1402 .rc_query = dw2102_rc_query,
1403 1403
@@ -1459,8 +1459,8 @@ static int dw2102_probe(struct usb_interface *intf,
1459 /* fill only different fields */ 1459 /* fill only different fields */
1460 p7500->firmware = "dvb-usb-p7500.fw"; 1460 p7500->firmware = "dvb-usb-p7500.fw";
1461 p7500->devices[0] = d7500; 1461 p7500->devices[0] = d7500;
1462 p7500->rc_key_map = tbs_rc_keys; 1462 p7500->rc_key_map = ir_codes_tbs_table;
1463 p7500->rc_key_map_size = ARRAY_SIZE(tbs_rc_keys); 1463 p7500->rc_key_map_size = ARRAY_SIZE(ir_codes_tbs_table);
1464 p7500->adapter->frontend_attach = prof_7500_frontend_attach; 1464 p7500->adapter->frontend_attach = prof_7500_frontend_attach;
1465 1465
1466 if (0 == dvb_usb_device_init(intf, &dw2102_properties, 1466 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
diff --git a/drivers/media/dvb/dvb-usb/friio-fe.c b/drivers/media/dvb/dvb-usb/friio-fe.c
index d14bd227b502..93c21ddd0b77 100644
--- a/drivers/media/dvb/dvb-usb/friio-fe.c
+++ b/drivers/media/dvb/dvb-usb/friio-fe.c
@@ -300,7 +300,7 @@ static int jdvbt90502_set_frontend(struct dvb_frontend *fe,
300 struct dvb_frontend_parameters *p) 300 struct dvb_frontend_parameters *p)
301{ 301{
302 /** 302 /**
303 * NOTE: ignore all the paramters except frequency. 303 * NOTE: ignore all the parameters except frequency.
304 * others should be fixed to the proper value for ISDB-T, 304 * others should be fixed to the proper value for ISDB-T,
305 * but don't check here. 305 * but don't check here.
306 */ 306 */
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c
index afb444db43ad..45106ac49674 100644
--- a/drivers/media/dvb/dvb-usb/gp8psk.c
+++ b/drivers/media/dvb/dvb-usb/gp8psk.c
@@ -105,6 +105,10 @@ static int gp8psk_load_bcm4500fw(struct dvb_usb_device *d)
105 105
106 ptr = fw->data; 106 ptr = fw->data;
107 buf = kmalloc(64, GFP_KERNEL | GFP_DMA); 107 buf = kmalloc(64, GFP_KERNEL | GFP_DMA);
108 if (!buf) {
109 ret = -ENOMEM;
110 goto out_rel_fw;
111 }
108 112
109 while (ptr[0] != 0xff) { 113 while (ptr[0] != 0xff) {
110 u16 buflen = ptr[0] + 4; 114 u16 buflen = ptr[0] + 4;
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index 737ffa36ac9c..c211fef45fc3 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -589,7 +589,7 @@ static struct m920x_inits pinnacle310e_init[] = {
589}; 589};
590 590
591/* ir keymaps */ 591/* ir keymaps */
592static struct dvb_usb_rc_key megasky_rc_keys [] = { 592static struct dvb_usb_rc_key ir_codes_megasky_table [] = {
593 { 0x0012, KEY_POWER }, 593 { 0x0012, KEY_POWER },
594 { 0x001e, KEY_CYCLEWINDOWS }, /* min/max */ 594 { 0x001e, KEY_CYCLEWINDOWS }, /* min/max */
595 { 0x0002, KEY_CHANNELUP }, 595 { 0x0002, KEY_CHANNELUP },
@@ -608,7 +608,7 @@ static struct dvb_usb_rc_key megasky_rc_keys [] = {
608 { 0x000e, KEY_COFFEE }, /* "MTS" */ 608 { 0x000e, KEY_COFFEE }, /* "MTS" */
609}; 609};
610 610
611static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = { 611static struct dvb_usb_rc_key ir_codes_tvwalkertwin_table [] = {
612 { 0x0001, KEY_ZOOM }, /* Full Screen */ 612 { 0x0001, KEY_ZOOM }, /* Full Screen */
613 { 0x0002, KEY_CAMERA }, /* snapshot */ 613 { 0x0002, KEY_CAMERA }, /* snapshot */
614 { 0x0003, KEY_MUTE }, 614 { 0x0003, KEY_MUTE },
@@ -628,7 +628,7 @@ static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
628 { 0x001e, KEY_VOLUMEUP }, 628 { 0x001e, KEY_VOLUMEUP },
629}; 629};
630 630
631static struct dvb_usb_rc_key pinnacle310e_rc_keys[] = { 631static struct dvb_usb_rc_key ir_codes_pinnacle310e_table[] = {
632 { 0x16, KEY_POWER }, 632 { 0x16, KEY_POWER },
633 { 0x17, KEY_FAVORITES }, 633 { 0x17, KEY_FAVORITES },
634 { 0x0f, KEY_TEXT }, 634 { 0x0f, KEY_TEXT },
@@ -785,8 +785,8 @@ static struct dvb_usb_device_properties megasky_properties = {
785 .download_firmware = m920x_firmware_download, 785 .download_firmware = m920x_firmware_download,
786 786
787 .rc_interval = 100, 787 .rc_interval = 100,
788 .rc_key_map = megasky_rc_keys, 788 .rc_key_map = ir_codes_megasky_table,
789 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys), 789 .rc_key_map_size = ARRAY_SIZE(ir_codes_megasky_table),
790 .rc_query = m920x_rc_query, 790 .rc_query = m920x_rc_query,
791 791
792 .size_of_priv = sizeof(struct m920x_state), 792 .size_of_priv = sizeof(struct m920x_state),
@@ -886,8 +886,8 @@ static struct dvb_usb_device_properties tvwalkertwin_properties = {
886 .download_firmware = m920x_firmware_download, 886 .download_firmware = m920x_firmware_download,
887 887
888 .rc_interval = 100, 888 .rc_interval = 100,
889 .rc_key_map = tvwalkertwin_rc_keys, 889 .rc_key_map = ir_codes_tvwalkertwin_table,
890 .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys), 890 .rc_key_map_size = ARRAY_SIZE(ir_codes_tvwalkertwin_table),
891 .rc_query = m920x_rc_query, 891 .rc_query = m920x_rc_query,
892 892
893 .size_of_priv = sizeof(struct m920x_state), 893 .size_of_priv = sizeof(struct m920x_state),
@@ -993,8 +993,8 @@ static struct dvb_usb_device_properties pinnacle_pctv310e_properties = {
993 .download_firmware = NULL, 993 .download_firmware = NULL,
994 994
995 .rc_interval = 100, 995 .rc_interval = 100,
996 .rc_key_map = pinnacle310e_rc_keys, 996 .rc_key_map = ir_codes_pinnacle310e_table,
997 .rc_key_map_size = ARRAY_SIZE(pinnacle310e_rc_keys), 997 .rc_key_map_size = ARRAY_SIZE(ir_codes_pinnacle310e_table),
998 .rc_query = m920x_rc_query, 998 .rc_query = m920x_rc_query,
999 999
1000 .size_of_priv = sizeof(struct m920x_state), 1000 .size_of_priv = sizeof(struct m920x_state),
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index b41d66ef8325..d195a587cc65 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -21,7 +21,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
21#define deb_ee(args...) dprintk(debug,0x02,args) 21#define deb_ee(args...) dprintk(debug,0x02,args)
22 22
23/* Hauppauge NOVA-T USB2 keys */ 23/* Hauppauge NOVA-T USB2 keys */
24static struct dvb_usb_rc_key haupp_rc_keys [] = { 24static struct dvb_usb_rc_key ir_codes_haupp_table [] = {
25 { 0x1e00, KEY_0 }, 25 { 0x1e00, KEY_0 },
26 { 0x1e01, KEY_1 }, 26 { 0x1e01, KEY_1 },
27 { 0x1e02, KEY_2 }, 27 { 0x1e02, KEY_2 },
@@ -91,14 +91,14 @@ static int nova_t_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
91 91
92 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle); 92 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle);
93 93
94 for (i = 0; i < ARRAY_SIZE(haupp_rc_keys); i++) { 94 for (i = 0; i < ARRAY_SIZE(ir_codes_haupp_table); i++) {
95 if (rc5_data(&haupp_rc_keys[i]) == data && 95 if (rc5_data(&ir_codes_haupp_table[i]) == data &&
96 rc5_custom(&haupp_rc_keys[i]) == custom) { 96 rc5_custom(&ir_codes_haupp_table[i]) == custom) {
97 97
98 deb_rc("c: %x, d: %x\n", rc5_data(&haupp_rc_keys[i]), 98 deb_rc("c: %x, d: %x\n", rc5_data(&ir_codes_haupp_table[i]),
99 rc5_custom(&haupp_rc_keys[i])); 99 rc5_custom(&ir_codes_haupp_table[i]));
100 100
101 *event = haupp_rc_keys[i].event; 101 *event = ir_codes_haupp_table[i].event;
102 *state = REMOTE_KEY_PRESSED; 102 *state = REMOTE_KEY_PRESSED;
103 if (st->old_toggle == toggle) { 103 if (st->old_toggle == toggle) {
104 if (st->last_repeat_count++ < 2) 104 if (st->last_repeat_count++ < 2)
@@ -196,8 +196,8 @@ static struct dvb_usb_device_properties nova_t_properties = {
196 .read_mac_address = nova_t_read_mac_address, 196 .read_mac_address = nova_t_read_mac_address,
197 197
198 .rc_interval = 100, 198 .rc_interval = 100,
199 .rc_key_map = haupp_rc_keys, 199 .rc_key_map = ir_codes_haupp_table,
200 .rc_key_map_size = ARRAY_SIZE(haupp_rc_keys), 200 .rc_key_map_size = ARRAY_SIZE(ir_codes_haupp_table),
201 .rc_query = nova_t_rc_query, 201 .rc_query = nova_t_rc_query,
202 202
203 .i2c_algo = &dibusb_i2c_algo, 203 .i2c_algo = &dibusb_i2c_algo,
diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c
index 830557696ae6..dfb81ff1d9a7 100644
--- a/drivers/media/dvb/dvb-usb/opera1.c
+++ b/drivers/media/dvb/dvb-usb/opera1.c
@@ -35,7 +35,7 @@
35struct opera1_state { 35struct opera1_state {
36 u32 last_key_pressed; 36 u32 last_key_pressed;
37}; 37};
38struct opera_rc_keys { 38struct ir_codes_opera_table {
39 u32 keycode; 39 u32 keycode;
40 u32 event; 40 u32 event;
41}; 41};
@@ -331,7 +331,7 @@ static int opera1_pid_filter_control(struct dvb_usb_adapter *adap, int onoff)
331 return 0; 331 return 0;
332} 332}
333 333
334static struct dvb_usb_rc_key opera1_rc_keys[] = { 334static struct dvb_usb_rc_key ir_codes_opera1_table[] = {
335 {0x5fa0, KEY_1}, 335 {0x5fa0, KEY_1},
336 {0x51af, KEY_2}, 336 {0x51af, KEY_2},
337 {0x5da2, KEY_3}, 337 {0x5da2, KEY_3},
@@ -404,12 +404,12 @@ static int opera1_rc_query(struct dvb_usb_device *dev, u32 * event, int *state)
404 404
405 send_key = (send_key & 0xffff) | 0x0100; 405 send_key = (send_key & 0xffff) | 0x0100;
406 406
407 for (i = 0; i < ARRAY_SIZE(opera1_rc_keys); i++) { 407 for (i = 0; i < ARRAY_SIZE(ir_codes_opera1_table); i++) {
408 if (rc5_scan(&opera1_rc_keys[i]) == (send_key & 0xffff)) { 408 if (rc5_scan(&ir_codes_opera1_table[i]) == (send_key & 0xffff)) {
409 *state = REMOTE_KEY_PRESSED; 409 *state = REMOTE_KEY_PRESSED;
410 *event = opera1_rc_keys[i].event; 410 *event = ir_codes_opera1_table[i].event;
411 opst->last_key_pressed = 411 opst->last_key_pressed =
412 opera1_rc_keys[i].event; 412 ir_codes_opera1_table[i].event;
413 break; 413 break;
414 } 414 }
415 opst->last_key_pressed = 0; 415 opst->last_key_pressed = 0;
@@ -498,8 +498,8 @@ static struct dvb_usb_device_properties opera1_properties = {
498 .power_ctrl = opera1_power_ctrl, 498 .power_ctrl = opera1_power_ctrl,
499 .i2c_algo = &opera1_i2c_algo, 499 .i2c_algo = &opera1_i2c_algo,
500 500
501 .rc_key_map = opera1_rc_keys, 501 .rc_key_map = ir_codes_opera1_table,
502 .rc_key_map_size = ARRAY_SIZE(opera1_rc_keys), 502 .rc_key_map_size = ARRAY_SIZE(ir_codes_opera1_table),
503 .rc_interval = 200, 503 .rc_interval = 200,
504 .rc_query = opera1_rc_query, 504 .rc_query = opera1_rc_query,
505 .read_mac_address = opera1_read_mac_address, 505 .read_mac_address = opera1_read_mac_address,
diff --git a/drivers/media/dvb/dvb-usb/ttusb2.c b/drivers/media/dvb/dvb-usb/ttusb2.c
index 20ca9d9ee99b..a6de489a6a39 100644
--- a/drivers/media/dvb/dvb-usb/ttusb2.c
+++ b/drivers/media/dvb/dvb-usb/ttusb2.c
@@ -29,6 +29,8 @@
29 29
30#include "tda826x.h" 30#include "tda826x.h"
31#include "tda10086.h" 31#include "tda10086.h"
32#include "tda1002x.h"
33#include "tda827x.h"
32#include "lnbp21.h" 34#include "lnbp21.h"
33 35
34/* debug */ 36/* debug */
@@ -150,7 +152,17 @@ static struct tda10086_config tda10086_config = {
150 .xtal_freq = TDA10086_XTAL_16M, 152 .xtal_freq = TDA10086_XTAL_16M,
151}; 153};
152 154
153static int ttusb2_frontend_attach(struct dvb_usb_adapter *adap) 155static struct tda10023_config tda10023_config = {
156 .demod_address = 0x0c,
157 .invert = 0,
158 .xtal = 16000000,
159 .pll_m = 11,
160 .pll_p = 3,
161 .pll_n = 1,
162 .deltaf = 0xa511,
163};
164
165static int ttusb2_frontend_tda10086_attach(struct dvb_usb_adapter *adap)
154{ 166{
155 if (usb_set_interface(adap->dev->udev,0,3) < 0) 167 if (usb_set_interface(adap->dev->udev,0,3) < 0)
156 err("set interface to alts=3 failed"); 168 err("set interface to alts=3 failed");
@@ -163,7 +175,27 @@ static int ttusb2_frontend_attach(struct dvb_usb_adapter *adap)
163 return 0; 175 return 0;
164} 176}
165 177
166static int ttusb2_tuner_attach(struct dvb_usb_adapter *adap) 178static int ttusb2_frontend_tda10023_attach(struct dvb_usb_adapter *adap)
179{
180 if (usb_set_interface(adap->dev->udev, 0, 3) < 0)
181 err("set interface to alts=3 failed");
182 if ((adap->fe = dvb_attach(tda10023_attach, &tda10023_config, &adap->dev->i2c_adap, 0x48)) == NULL) {
183 deb_info("TDA10023 attach failed\n");
184 return -ENODEV;
185 }
186 return 0;
187}
188
189static int ttusb2_tuner_tda827x_attach(struct dvb_usb_adapter *adap)
190{
191 if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL) {
192 printk(KERN_ERR "%s: No tda827x found!\n", __func__);
193 return -ENODEV;
194 }
195 return 0;
196}
197
198static int ttusb2_tuner_tda826x_attach(struct dvb_usb_adapter *adap)
167{ 199{
168 if (dvb_attach(tda826x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, 0) == NULL) { 200 if (dvb_attach(tda826x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, 0) == NULL) {
169 deb_info("TDA8263 attach failed\n"); 201 deb_info("TDA8263 attach failed\n");
@@ -180,6 +212,7 @@ static int ttusb2_tuner_attach(struct dvb_usb_adapter *adap)
180/* DVB USB Driver stuff */ 212/* DVB USB Driver stuff */
181static struct dvb_usb_device_properties ttusb2_properties; 213static struct dvb_usb_device_properties ttusb2_properties;
182static struct dvb_usb_device_properties ttusb2_properties_s2400; 214static struct dvb_usb_device_properties ttusb2_properties_s2400;
215static struct dvb_usb_device_properties ttusb2_properties_ct3650;
183 216
184static int ttusb2_probe(struct usb_interface *intf, 217static int ttusb2_probe(struct usb_interface *intf,
185 const struct usb_device_id *id) 218 const struct usb_device_id *id)
@@ -187,6 +220,8 @@ static int ttusb2_probe(struct usb_interface *intf,
187 if (0 == dvb_usb_device_init(intf, &ttusb2_properties, 220 if (0 == dvb_usb_device_init(intf, &ttusb2_properties,
188 THIS_MODULE, NULL, adapter_nr) || 221 THIS_MODULE, NULL, adapter_nr) ||
189 0 == dvb_usb_device_init(intf, &ttusb2_properties_s2400, 222 0 == dvb_usb_device_init(intf, &ttusb2_properties_s2400,
223 THIS_MODULE, NULL, adapter_nr) ||
224 0 == dvb_usb_device_init(intf, &ttusb2_properties_ct3650,
190 THIS_MODULE, NULL, adapter_nr)) 225 THIS_MODULE, NULL, adapter_nr))
191 return 0; 226 return 0;
192 return -ENODEV; 227 return -ENODEV;
@@ -197,6 +232,8 @@ static struct usb_device_id ttusb2_table [] = {
197 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_450E) }, 232 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_450E) },
198 { USB_DEVICE(USB_VID_TECHNOTREND, 233 { USB_DEVICE(USB_VID_TECHNOTREND,
199 USB_PID_TECHNOTREND_CONNECT_S2400) }, 234 USB_PID_TECHNOTREND_CONNECT_S2400) },
235 { USB_DEVICE(USB_VID_TECHNOTREND,
236 USB_PID_TECHNOTREND_CONNECT_CT3650) },
200 {} /* Terminating entry */ 237 {} /* Terminating entry */
201}; 238};
202MODULE_DEVICE_TABLE (usb, ttusb2_table); 239MODULE_DEVICE_TABLE (usb, ttusb2_table);
@@ -214,8 +251,8 @@ static struct dvb_usb_device_properties ttusb2_properties = {
214 { 251 {
215 .streaming_ctrl = NULL, // ttusb2_streaming_ctrl, 252 .streaming_ctrl = NULL, // ttusb2_streaming_ctrl,
216 253
217 .frontend_attach = ttusb2_frontend_attach, 254 .frontend_attach = ttusb2_frontend_tda10086_attach,
218 .tuner_attach = ttusb2_tuner_attach, 255 .tuner_attach = ttusb2_tuner_tda826x_attach,
219 256
220 /* parameter for the MPEG2-data transfer */ 257 /* parameter for the MPEG2-data transfer */
221 .stream = { 258 .stream = {
@@ -266,8 +303,8 @@ static struct dvb_usb_device_properties ttusb2_properties_s2400 = {
266 { 303 {
267 .streaming_ctrl = NULL, 304 .streaming_ctrl = NULL,
268 305
269 .frontend_attach = ttusb2_frontend_attach, 306 .frontend_attach = ttusb2_frontend_tda10086_attach,
270 .tuner_attach = ttusb2_tuner_attach, 307 .tuner_attach = ttusb2_tuner_tda826x_attach,
271 308
272 /* parameter for the MPEG2-data transfer */ 309 /* parameter for the MPEG2-data transfer */
273 .stream = { 310 .stream = {
@@ -301,6 +338,52 @@ static struct dvb_usb_device_properties ttusb2_properties_s2400 = {
301 } 338 }
302}; 339};
303 340
341static struct dvb_usb_device_properties ttusb2_properties_ct3650 = {
342 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
343
344 .usb_ctrl = CYPRESS_FX2,
345
346 .size_of_priv = sizeof(struct ttusb2_state),
347
348 .num_adapters = 1,
349 .adapter = {
350 {
351 .streaming_ctrl = NULL,
352
353 .frontend_attach = ttusb2_frontend_tda10023_attach,
354 .tuner_attach = ttusb2_tuner_tda827x_attach,
355
356 /* parameter for the MPEG2-data transfer */
357 .stream = {
358 .type = USB_ISOC,
359 .count = 5,
360 .endpoint = 0x02,
361 .u = {
362 .isoc = {
363 .framesperurb = 4,
364 .framesize = 940,
365 .interval = 1,
366 }
367 }
368 }
369 },
370 },
371
372 .power_ctrl = ttusb2_power_ctrl,
373 .identify_state = ttusb2_identify_state,
374
375 .i2c_algo = &ttusb2_i2c_algo,
376
377 .generic_bulk_ctrl_endpoint = 0x01,
378
379 .num_device_descs = 1,
380 .devices = {
381 { "Technotrend TT-connect CT-3650",
382 .warm_ids = { &ttusb2_table[3], NULL },
383 },
384 }
385};
386
304static struct usb_driver ttusb2_driver = { 387static struct usb_driver ttusb2_driver = {
305 .name = "dvb_usb_ttusb2", 388 .name = "dvb_usb_ttusb2",
306 .probe = ttusb2_probe, 389 .probe = ttusb2_probe,
diff --git a/drivers/media/dvb/dvb-usb/usb-urb.c b/drivers/media/dvb/dvb-usb/usb-urb.c
index f9702e3756b6..86d68933b6b4 100644
--- a/drivers/media/dvb/dvb-usb/usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/usb-urb.c
@@ -96,8 +96,9 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream)
96 while (stream->buf_num) { 96 while (stream->buf_num) {
97 stream->buf_num--; 97 stream->buf_num--;
98 deb_mem("freeing buffer %d\n",stream->buf_num); 98 deb_mem("freeing buffer %d\n",stream->buf_num);
99 usb_buffer_free(stream->udev, stream->buf_size, 99 usb_free_coherent(stream->udev, stream->buf_size,
100 stream->buf_list[stream->buf_num], stream->dma_addr[stream->buf_num]); 100 stream->buf_list[stream->buf_num],
101 stream->dma_addr[stream->buf_num]);
101 } 102 }
102 } 103 }
103 104
@@ -116,7 +117,7 @@ static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num,
116 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { 117 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
117 deb_mem("allocating buffer %d\n",stream->buf_num); 118 deb_mem("allocating buffer %d\n",stream->buf_num);
118 if (( stream->buf_list[stream->buf_num] = 119 if (( stream->buf_list[stream->buf_num] =
119 usb_buffer_alloc(stream->udev, size, GFP_ATOMIC, 120 usb_alloc_coherent(stream->udev, size, GFP_ATOMIC,
120 &stream->dma_addr[stream->buf_num]) ) == NULL) { 121 &stream->dma_addr[stream->buf_num]) ) == NULL) {
121 deb_mem("not enough memory for urb-buffer allocation.\n"); 122 deb_mem("not enough memory for urb-buffer allocation.\n");
122 usb_free_stream_buffers(stream); 123 usb_free_stream_buffers(stream);
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c
index ef4e37d9c5ff..4d332451653b 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.c
+++ b/drivers/media/dvb/dvb-usb/vp702x.c
@@ -174,7 +174,7 @@ static int vp702x_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
174} 174}
175 175
176/* keys for the enclosed remote control */ 176/* keys for the enclosed remote control */
177static struct dvb_usb_rc_key vp702x_rc_keys[] = { 177static struct dvb_usb_rc_key ir_codes_vp702x_table[] = {
178 { 0x0001, KEY_1 }, 178 { 0x0001, KEY_1 },
179 { 0x0002, KEY_2 }, 179 { 0x0002, KEY_2 },
180}; 180};
@@ -197,10 +197,10 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
197 return 0; 197 return 0;
198 } 198 }
199 199
200 for (i = 0; i < ARRAY_SIZE(vp702x_rc_keys); i++) 200 for (i = 0; i < ARRAY_SIZE(ir_codes_vp702x_table); i++)
201 if (rc5_custom(&vp702x_rc_keys[i]) == key[1]) { 201 if (rc5_custom(&ir_codes_vp702x_table[i]) == key[1]) {
202 *state = REMOTE_KEY_PRESSED; 202 *state = REMOTE_KEY_PRESSED;
203 *event = vp702x_rc_keys[i].event; 203 *event = ir_codes_vp702x_table[i].event;
204 break; 204 break;
205 } 205 }
206 return 0; 206 return 0;
@@ -283,8 +283,8 @@ static struct dvb_usb_device_properties vp702x_properties = {
283 }, 283 },
284 .read_mac_address = vp702x_read_mac_addr, 284 .read_mac_address = vp702x_read_mac_addr,
285 285
286 .rc_key_map = vp702x_rc_keys, 286 .rc_key_map = ir_codes_vp702x_table,
287 .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys), 287 .rc_key_map_size = ARRAY_SIZE(ir_codes_vp702x_table),
288 .rc_interval = 400, 288 .rc_interval = 400,
289 .rc_query = vp702x_rc_query, 289 .rc_query = vp702x_rc_query,
290 290
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
index a59faa27912a..036893fa4480 100644
--- a/drivers/media/dvb/dvb-usb/vp7045.c
+++ b/drivers/media/dvb/dvb-usb/vp7045.c
@@ -99,7 +99,7 @@ static int vp7045_power_ctrl(struct dvb_usb_device *d, int onoff)
99 99
100/* The keymapping struct. Somehow this should be loaded to the driver, but 100/* The keymapping struct. Somehow this should be loaded to the driver, but
101 * currently it is hardcoded. */ 101 * currently it is hardcoded. */
102static struct dvb_usb_rc_key vp7045_rc_keys[] = { 102static struct dvb_usb_rc_key ir_codes_vp7045_table[] = {
103 { 0x0016, KEY_POWER }, 103 { 0x0016, KEY_POWER },
104 { 0x0010, KEY_MUTE }, 104 { 0x0010, KEY_MUTE },
105 { 0x0003, KEY_1 }, 105 { 0x0003, KEY_1 },
@@ -165,10 +165,10 @@ static int vp7045_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
165 return 0; 165 return 0;
166 } 166 }
167 167
168 for (i = 0; i < ARRAY_SIZE(vp7045_rc_keys); i++) 168 for (i = 0; i < ARRAY_SIZE(ir_codes_vp7045_table); i++)
169 if (rc5_data(&vp7045_rc_keys[i]) == key) { 169 if (rc5_data(&ir_codes_vp7045_table[i]) == key) {
170 *state = REMOTE_KEY_PRESSED; 170 *state = REMOTE_KEY_PRESSED;
171 *event = vp7045_rc_keys[i].event; 171 *event = ir_codes_vp7045_table[i].event;
172 break; 172 break;
173 } 173 }
174 return 0; 174 return 0;
@@ -260,8 +260,8 @@ static struct dvb_usb_device_properties vp7045_properties = {
260 .read_mac_address = vp7045_read_mac_addr, 260 .read_mac_address = vp7045_read_mac_addr,
261 261
262 .rc_interval = 400, 262 .rc_interval = 400,
263 .rc_key_map = vp7045_rc_keys, 263 .rc_key_map = ir_codes_vp7045_table,
264 .rc_key_map_size = ARRAY_SIZE(vp7045_rc_keys), 264 .rc_key_map_size = ARRAY_SIZE(ir_codes_vp7045_table),
265 .rc_query = vp7045_rc_query, 265 .rc_query = vp7045_rc_query,
266 266
267 .num_device_descs = 2, 267 .num_device_descs = 2,
diff --git a/drivers/media/dvb/firewire/firedtv-1394.c b/drivers/media/dvb/firewire/firedtv-1394.c
index 26333b4f4d3e..b34ca7afb0e6 100644
--- a/drivers/media/dvb/firewire/firedtv-1394.c
+++ b/drivers/media/dvb/firewire/firedtv-1394.c
@@ -58,7 +58,7 @@ static void rawiso_activity_cb(struct hpsb_iso *iso)
58 num = hpsb_iso_n_ready(iso); 58 num = hpsb_iso_n_ready(iso);
59 59
60 if (!fdtv) { 60 if (!fdtv) {
61 dev_err(fdtv->device, "received at unknown iso channel\n"); 61 pr_err("received at unknown iso channel\n");
62 goto out; 62 goto out;
63 } 63 }
64 64
diff --git a/drivers/media/dvb/firewire/firedtv-avc.c b/drivers/media/dvb/firewire/firedtv-avc.c
index 1b31bebc27d6..28294af752db 100644
--- a/drivers/media/dvb/firewire/firedtv-avc.c
+++ b/drivers/media/dvb/firewire/firedtv-avc.c
@@ -1096,7 +1096,7 @@ int avc_ca_pmt(struct firedtv *fdtv, char *msg, int length)
1096 1096
1097 c->operand[15] = msg[1]; /* Program number */ 1097 c->operand[15] = msg[1]; /* Program number */
1098 c->operand[16] = msg[2]; 1098 c->operand[16] = msg[2];
1099 c->operand[17] = 0x01; /* Version number=0 + current/next=1 */ 1099 c->operand[17] = msg[3]; /* Version number and current/next */
1100 c->operand[18] = 0x00; /* Section number=0 */ 1100 c->operand[18] = 0x00; /* Section number=0 */
1101 c->operand[19] = 0x00; /* Last section number=0 */ 1101 c->operand[19] = 0x00; /* Last section number=0 */
1102 c->operand[20] = 0x1f; /* PCR_PID=1FFF */ 1102 c->operand[20] = 0x1f; /* PCR_PID=1FFF */
diff --git a/drivers/media/dvb/firewire/firedtv-ci.c b/drivers/media/dvb/firewire/firedtv-ci.c
index 853e04b7cb36..d3c2cf60de76 100644
--- a/drivers/media/dvb/firewire/firedtv-ci.c
+++ b/drivers/media/dvb/firewire/firedtv-ci.c
@@ -175,8 +175,7 @@ static int fdtv_ca_send_msg(struct firedtv *fdtv, void *arg)
175 return err; 175 return err;
176} 176}
177 177
178static int fdtv_ca_ioctl(struct inode *inode, struct file *file, 178static int fdtv_ca_ioctl(struct file *file, unsigned int cmd, void *arg)
179 unsigned int cmd, void *arg)
180{ 179{
181 struct dvb_device *dvbdev = file->private_data; 180 struct dvb_device *dvbdev = file->private_data;
182 struct firedtv *fdtv = dvbdev->priv; 181 struct firedtv *fdtv = dvbdev->priv;
@@ -217,7 +216,7 @@ static unsigned int fdtv_ca_io_poll(struct file *file, poll_table *wait)
217 216
218static const struct file_operations fdtv_ca_fops = { 217static const struct file_operations fdtv_ca_fops = {
219 .owner = THIS_MODULE, 218 .owner = THIS_MODULE,
220 .ioctl = dvb_generic_ioctl, 219 .unlocked_ioctl = dvb_generic_ioctl,
221 .open = dvb_generic_open, 220 .open = dvb_generic_open,
222 .release = dvb_generic_release, 221 .release = dvb_generic_release,
223 .poll = fdtv_ca_io_poll, 222 .poll = fdtv_ca_io_poll,
diff --git a/drivers/media/dvb/firewire/firedtv-fw.c b/drivers/media/dvb/firewire/firedtv-fw.c
index 75afe4f81e33..7424b0493f9d 100644
--- a/drivers/media/dvb/firewire/firedtv-fw.c
+++ b/drivers/media/dvb/firewire/firedtv-fw.c
@@ -194,8 +194,8 @@ static const struct firedtv_backend backend = {
194 194
195static void handle_fcp(struct fw_card *card, struct fw_request *request, 195static void handle_fcp(struct fw_card *card, struct fw_request *request,
196 int tcode, int destination, int source, int generation, 196 int tcode, int destination, int source, int generation,
197 int speed, unsigned long long offset, 197 unsigned long long offset, void *payload, size_t length,
198 void *payload, size_t length, void *callback_data) 198 void *callback_data)
199{ 199{
200 struct firedtv *f, *fdtv = NULL; 200 struct firedtv *f, *fdtv = NULL;
201 struct fw_device *device; 201 struct fw_device *device;
diff --git a/drivers/media/dvb/frontends/atbm8830_priv.h b/drivers/media/dvb/frontends/atbm8830_priv.h
index ce960f76092a..d460058d497e 100644
--- a/drivers/media/dvb/frontends/atbm8830_priv.h
+++ b/drivers/media/dvb/frontends/atbm8830_priv.h
@@ -18,7 +18,7 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#ifndef __ATBM8830_PRIV_H 22#ifndef __ATBM8830_PRIV_H
23#define __ATBM8830_PRIV_H 23#define __ATBM8830_PRIV_H
24 24
diff --git a/drivers/media/dvb/frontends/au8522_decoder.c b/drivers/media/dvb/frontends/au8522_decoder.c
index 24268ef2753d..29cdbfe36852 100644
--- a/drivers/media/dvb/frontends/au8522_decoder.c
+++ b/drivers/media/dvb/frontends/au8522_decoder.c
@@ -567,30 +567,6 @@ static int au8522_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
567 567
568/* ----------------------------------------------------------------------- */ 568/* ----------------------------------------------------------------------- */
569 569
570static int au8522_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
571{
572 switch (fmt->type) {
573 default:
574 return -EINVAL;
575 }
576 return 0;
577}
578
579static int au8522_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
580{
581 switch (fmt->type) {
582 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
583 /* Not yet implemented */
584 break;
585 default:
586 return -EINVAL;
587 }
588
589 return 0;
590}
591
592/* ----------------------------------------------------------------------- */
593
594#ifdef CONFIG_VIDEO_ADV_DEBUG 570#ifdef CONFIG_VIDEO_ADV_DEBUG
595static int au8522_g_register(struct v4l2_subdev *sd, 571static int au8522_g_register(struct v4l2_subdev *sd,
596 struct v4l2_dbg_register *reg) 572 struct v4l2_dbg_register *reg)
@@ -664,6 +640,13 @@ static int au8522_reset(struct v4l2_subdev *sd, u32 val)
664{ 640{
665 struct au8522_state *state = to_state(sd); 641 struct au8522_state *state = to_state(sd);
666 642
643 state->operational_mode = AU8522_ANALOG_MODE;
644
645 /* Clear out any state associated with the digital side of the
646 chip, so that when it gets powered back up it won't think
647 that it is already tuned */
648 state->current_frequency = 0;
649
667 au8522_writereg(state, 0xa4, 1 << 5); 650 au8522_writereg(state, 0xa4, 1 << 5);
668 651
669 return 0; 652 return 0;
@@ -765,8 +748,6 @@ static const struct v4l2_subdev_audio_ops au8522_audio_ops = {
765 748
766static const struct v4l2_subdev_video_ops au8522_video_ops = { 749static const struct v4l2_subdev_video_ops au8522_video_ops = {
767 .s_routing = au8522_s_video_routing, 750 .s_routing = au8522_s_video_routing,
768 .g_fmt = au8522_g_fmt,
769 .s_fmt = au8522_s_fmt,
770 .s_stream = au8522_s_stream, 751 .s_stream = au8522_s_stream,
771}; 752};
772 753
diff --git a/drivers/media/dvb/frontends/au8522_dig.c b/drivers/media/dvb/frontends/au8522_dig.c
index a1fed0fa8ed4..65f6a36dfb21 100644
--- a/drivers/media/dvb/frontends/au8522_dig.c
+++ b/drivers/media/dvb/frontends/au8522_dig.c
@@ -84,6 +84,14 @@ static int au8522_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
84 84
85 dprintk("%s(%d)\n", __func__, enable); 85 dprintk("%s(%d)\n", __func__, enable);
86 86
87 if (state->operational_mode == AU8522_ANALOG_MODE) {
88 /* We're being asked to manage the gate even though we're
89 not in digital mode. This can occur if we get switched
90 over to analog mode before the dvb_frontend kernel thread
91 has completely shutdown */
92 return 0;
93 }
94
87 if (enable) 95 if (enable)
88 return au8522_writereg(state, 0x106, 1); 96 return au8522_writereg(state, 0x106, 1);
89 else 97 else
@@ -608,6 +616,13 @@ int au8522_init(struct dvb_frontend *fe)
608 struct au8522_state *state = fe->demodulator_priv; 616 struct au8522_state *state = fe->demodulator_priv;
609 dprintk("%s()\n", __func__); 617 dprintk("%s()\n", __func__);
610 618
619 state->operational_mode = AU8522_DIGITAL_MODE;
620
621 /* Clear out any state associated with the digital side of the
622 chip, so that when it gets powered back up it won't think
623 that it is already tuned */
624 state->current_frequency = 0;
625
611 au8522_writereg(state, 0xa4, 1 << 5); 626 au8522_writereg(state, 0xa4, 1 << 5);
612 627
613 au8522_i2c_gate_ctrl(fe, 1); 628 au8522_i2c_gate_ctrl(fe, 1);
@@ -704,6 +719,15 @@ int au8522_sleep(struct dvb_frontend *fe)
704 struct au8522_state *state = fe->demodulator_priv; 719 struct au8522_state *state = fe->demodulator_priv;
705 dprintk("%s()\n", __func__); 720 dprintk("%s()\n", __func__);
706 721
722 /* Only power down if the digital side is currently using the chip */
723 if (state->operational_mode == AU8522_ANALOG_MODE) {
724 /* We're not in one of the expected power modes, which means
725 that the DVB thread is probably telling us to go to sleep
726 even though the analog frontend has already started using
727 the chip. So ignore the request */
728 return 0;
729 }
730
707 /* turn off led */ 731 /* turn off led */
708 au8522_led_ctrl(state, 0); 732 au8522_led_ctrl(state, 0);
709 733
@@ -932,6 +956,8 @@ struct dvb_frontend *au8522_attach(const struct au8522_config *config,
932 /* setup the state */ 956 /* setup the state */
933 state->config = config; 957 state->config = config;
934 state->i2c = i2c; 958 state->i2c = i2c;
959 state->operational_mode = AU8522_DIGITAL_MODE;
960
935 /* create dvb_frontend */ 961 /* create dvb_frontend */
936 memcpy(&state->frontend.ops, &au8522_ops, 962 memcpy(&state->frontend.ops, &au8522_ops,
937 sizeof(struct dvb_frontend_ops)); 963 sizeof(struct dvb_frontend_ops));
diff --git a/drivers/media/dvb/frontends/au8522_priv.h b/drivers/media/dvb/frontends/au8522_priv.h
index c74c4e72fe91..609cf04bc312 100644
--- a/drivers/media/dvb/frontends/au8522_priv.h
+++ b/drivers/media/dvb/frontends/au8522_priv.h
@@ -34,10 +34,15 @@
34#include "au8522.h" 34#include "au8522.h"
35#include "tuner-i2c.h" 35#include "tuner-i2c.h"
36 36
37#define AU8522_ANALOG_MODE 0
38#define AU8522_DIGITAL_MODE 1
39
37struct au8522_state { 40struct au8522_state {
38 struct i2c_client *c; 41 struct i2c_client *c;
39 struct i2c_adapter *i2c; 42 struct i2c_adapter *i2c;
40 43
44 u8 operational_mode;
45
41 /* Used for sharing of the state between analog and digital mode */ 46 /* Used for sharing of the state between analog and digital mode */
42 struct tuner_i2c_props i2c_props; 47 struct tuner_i2c_props i2c_props;
43 struct list_head hybrid_tuner_instance_list; 48 struct list_head hybrid_tuner_instance_list;
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index 40a099810279..afad252abf41 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -814,42 +814,51 @@ EXPORT_SYMBOL(dib3000mc_set_config);
814 814
815int dib3000mc_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib3000mc_config cfg[]) 815int dib3000mc_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib3000mc_config cfg[])
816{ 816{
817 struct dib3000mc_state st = { .i2c_adap = i2c }; 817 struct dib3000mc_state *dmcst;
818 int k; 818 int k;
819 u8 new_addr; 819 u8 new_addr;
820 820
821 static u8 DIB3000MC_I2C_ADDRESS[] = {20,22,24,26}; 821 static u8 DIB3000MC_I2C_ADDRESS[] = {20,22,24,26};
822 822
823 dmcst = kzalloc(sizeof(struct dib3000mc_state), GFP_KERNEL);
824 if (dmcst == NULL)
825 return -ENODEV;
826
827 dmcst->i2c_adap = i2c;
828
823 for (k = no_of_demods-1; k >= 0; k--) { 829 for (k = no_of_demods-1; k >= 0; k--) {
824 st.cfg = &cfg[k]; 830 dmcst->cfg = &cfg[k];
825 831
826 /* designated i2c address */ 832 /* designated i2c address */
827 new_addr = DIB3000MC_I2C_ADDRESS[k]; 833 new_addr = DIB3000MC_I2C_ADDRESS[k];
828 st.i2c_addr = new_addr; 834 dmcst->i2c_addr = new_addr;
829 if (dib3000mc_identify(&st) != 0) { 835 if (dib3000mc_identify(dmcst) != 0) {
830 st.i2c_addr = default_addr; 836 dmcst->i2c_addr = default_addr;
831 if (dib3000mc_identify(&st) != 0) { 837 if (dib3000mc_identify(dmcst) != 0) {
832 dprintk("-E- DiB3000P/MC #%d: not identified\n", k); 838 dprintk("-E- DiB3000P/MC #%d: not identified\n", k);
839 kfree(dmcst);
833 return -ENODEV; 840 return -ENODEV;
834 } 841 }
835 } 842 }
836 843
837 dib3000mc_set_output_mode(&st, OUTMODE_MPEG2_PAR_CONT_CLK); 844 dib3000mc_set_output_mode(dmcst, OUTMODE_MPEG2_PAR_CONT_CLK);
838 845
839 // set new i2c address and force divstr (Bit 1) to value 0 (Bit 0) 846 // set new i2c address and force divstr (Bit 1) to value 0 (Bit 0)
840 dib3000mc_write_word(&st, 1024, (new_addr << 3) | 0x1); 847 dib3000mc_write_word(dmcst, 1024, (new_addr << 3) | 0x1);
841 st.i2c_addr = new_addr; 848 dmcst->i2c_addr = new_addr;
842 } 849 }
843 850
844 for (k = 0; k < no_of_demods; k++) { 851 for (k = 0; k < no_of_demods; k++) {
845 st.cfg = &cfg[k]; 852 dmcst->cfg = &cfg[k];
846 st.i2c_addr = DIB3000MC_I2C_ADDRESS[k]; 853 dmcst->i2c_addr = DIB3000MC_I2C_ADDRESS[k];
847 854
848 dib3000mc_write_word(&st, 1024, st.i2c_addr << 3); 855 dib3000mc_write_word(dmcst, 1024, dmcst->i2c_addr << 3);
849 856
850 /* turn off data output */ 857 /* turn off data output */
851 dib3000mc_set_output_mode(&st, OUTMODE_HIGH_Z); 858 dib3000mc_set_output_mode(dmcst, OUTMODE_HIGH_Z);
852 } 859 }
860
861 kfree(dmcst);
853 return 0; 862 return 0;
854} 863}
855EXPORT_SYMBOL(dib3000mc_i2c_enumeration); 864EXPORT_SYMBOL(dib3000mc_i2c_enumeration);
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c
index 85468a45c344..2e28b973dfd3 100644
--- a/drivers/media/dvb/frontends/dib7000p.c
+++ b/drivers/media/dvb/frontends/dib7000p.c
@@ -1324,46 +1324,54 @@ EXPORT_SYMBOL(dib7000p_pid_filter);
1324 1324
1325int dib7000p_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib7000p_config cfg[]) 1325int dib7000p_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib7000p_config cfg[])
1326{ 1326{
1327 struct dib7000p_state st = { .i2c_adap = i2c }; 1327 struct dib7000p_state *dpst;
1328 int k = 0; 1328 int k = 0;
1329 u8 new_addr = 0; 1329 u8 new_addr = 0;
1330 1330
1331 dpst = kzalloc(sizeof(struct dib7000p_state), GFP_KERNEL);
1332 if (!dpst)
1333 return -ENOMEM;
1334
1335 dpst->i2c_adap = i2c;
1336
1331 for (k = no_of_demods-1; k >= 0; k--) { 1337 for (k = no_of_demods-1; k >= 0; k--) {
1332 st.cfg = cfg[k]; 1338 dpst->cfg = cfg[k];
1333 1339
1334 /* designated i2c address */ 1340 /* designated i2c address */
1335 new_addr = (0x40 + k) << 1; 1341 new_addr = (0x40 + k) << 1;
1336 st.i2c_addr = new_addr; 1342 dpst->i2c_addr = new_addr;
1337 dib7000p_write_word(&st, 1287, 0x0003); /* sram lead in, rdy */ 1343 dib7000p_write_word(dpst, 1287, 0x0003); /* sram lead in, rdy */
1338 if (dib7000p_identify(&st) != 0) { 1344 if (dib7000p_identify(dpst) != 0) {
1339 st.i2c_addr = default_addr; 1345 dpst->i2c_addr = default_addr;
1340 dib7000p_write_word(&st, 1287, 0x0003); /* sram lead in, rdy */ 1346 dib7000p_write_word(dpst, 1287, 0x0003); /* sram lead in, rdy */
1341 if (dib7000p_identify(&st) != 0) { 1347 if (dib7000p_identify(dpst) != 0) {
1342 dprintk("DiB7000P #%d: not identified\n", k); 1348 dprintk("DiB7000P #%d: not identified\n", k);
1349 kfree(dpst);
1343 return -EIO; 1350 return -EIO;
1344 } 1351 }
1345 } 1352 }
1346 1353
1347 /* start diversity to pull_down div_str - just for i2c-enumeration */ 1354 /* start diversity to pull_down div_str - just for i2c-enumeration */
1348 dib7000p_set_output_mode(&st, OUTMODE_DIVERSITY); 1355 dib7000p_set_output_mode(dpst, OUTMODE_DIVERSITY);
1349 1356
1350 /* set new i2c address and force divstart */ 1357 /* set new i2c address and force divstart */
1351 dib7000p_write_word(&st, 1285, (new_addr << 2) | 0x2); 1358 dib7000p_write_word(dpst, 1285, (new_addr << 2) | 0x2);
1352 1359
1353 dprintk("IC %d initialized (to i2c_address 0x%x)", k, new_addr); 1360 dprintk("IC %d initialized (to i2c_address 0x%x)", k, new_addr);
1354 } 1361 }
1355 1362
1356 for (k = 0; k < no_of_demods; k++) { 1363 for (k = 0; k < no_of_demods; k++) {
1357 st.cfg = cfg[k]; 1364 dpst->cfg = cfg[k];
1358 st.i2c_addr = (0x40 + k) << 1; 1365 dpst->i2c_addr = (0x40 + k) << 1;
1359 1366
1360 // unforce divstr 1367 // unforce divstr
1361 dib7000p_write_word(&st, 1285, st.i2c_addr << 2); 1368 dib7000p_write_word(dpst, 1285, dpst->i2c_addr << 2);
1362 1369
1363 /* deactivate div - it was just for i2c-enumeration */ 1370 /* deactivate div - it was just for i2c-enumeration */
1364 dib7000p_set_output_mode(&st, OUTMODE_HIGH_Z); 1371 dib7000p_set_output_mode(dpst, OUTMODE_HIGH_Z);
1365 } 1372 }
1366 1373
1374 kfree(dpst);
1367 return 0; 1375 return 0;
1368} 1376}
1369EXPORT_SYMBOL(dib7000p_i2c_enumeration); 1377EXPORT_SYMBOL(dib7000p_i2c_enumeration);
diff --git a/drivers/media/dvb/frontends/dib8000.h b/drivers/media/dvb/frontends/dib8000.h
index b1ee20799639..e0a9ded11df4 100644
--- a/drivers/media/dvb/frontends/dib8000.h
+++ b/drivers/media/dvb/frontends/dib8000.h
@@ -109,6 +109,7 @@ static inline void dib8000_pwm_agc_reset(struct dvb_frontend *fe)
109static inline s32 dib8000_get_adc_power(struct dvb_frontend *fe, u8 mode) 109static inline s32 dib8000_get_adc_power(struct dvb_frontend *fe, u8 mode)
110{ 110{
111 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 111 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
112 return 0;
112} 113}
113#endif 114#endif
114 115
diff --git a/drivers/media/dvb/frontends/ds3000.c b/drivers/media/dvb/frontends/ds3000.c
index cff3535566fe..fc61d9230db8 100644
--- a/drivers/media/dvb/frontends/ds3000.c
+++ b/drivers/media/dvb/frontends/ds3000.c
@@ -719,7 +719,7 @@ static int ds3000_read_snr(struct dvb_frontend *fe, u16 *snr)
719 (ds3000_readreg(state, 0x8d) << 4); 719 (ds3000_readreg(state, 0x8d) << 4);
720 dvbs2_signal_reading = ds3000_readreg(state, 0x8e); 720 dvbs2_signal_reading = ds3000_readreg(state, 0x8e);
721 tmp = dvbs2_signal_reading * dvbs2_signal_reading >> 1; 721 tmp = dvbs2_signal_reading * dvbs2_signal_reading >> 1;
722 if (dvbs2_signal_reading == 0) { 722 if (tmp == 0) {
723 *snr = 0x0000; 723 *snr = 0x0000;
724 return 0; 724 return 0;
725 } 725 }
@@ -969,15 +969,12 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
969 dprintk("%s\n", __func__); 969 dprintk("%s\n", __func__);
970 970
971 /* allocate memory for the internal state */ 971 /* allocate memory for the internal state */
972 state = kmalloc(sizeof(struct ds3000_state), GFP_KERNEL); 972 state = kzalloc(sizeof(struct ds3000_state), GFP_KERNEL);
973 if (state == NULL) { 973 if (state == NULL) {
974 printk(KERN_ERR "Unable to kmalloc\n"); 974 printk(KERN_ERR "Unable to kmalloc\n");
975 goto error2; 975 goto error2;
976 } 976 }
977 977
978 /* setup the state */
979 memset(state, 0, sizeof(struct ds3000_state));
980
981 state->config = config; 978 state->config = config;
982 state->i2c = i2c; 979 state->i2c = i2c;
983 state->prevUCBS2 = 0; 980 state->prevUCBS2 = 0;
diff --git a/drivers/media/dvb/frontends/stv0900_core.c b/drivers/media/dvb/frontends/stv0900_core.c
index 01f8f1f802fd..4f5e7d3a0e61 100644
--- a/drivers/media/dvb/frontends/stv0900_core.c
+++ b/drivers/media/dvb/frontends/stv0900_core.c
@@ -1583,7 +1583,7 @@ static enum dvbfe_search stv0900_search(struct dvb_frontend *fe,
1583 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1583 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1584 1584
1585 struct stv0900_search_params p_search; 1585 struct stv0900_search_params p_search;
1586 struct stv0900_signal_info p_result; 1586 struct stv0900_signal_info p_result = intp->result[demod];
1587 1587
1588 enum fe_stv0900_error error = STV0900_NO_ERROR; 1588 enum fe_stv0900_error error = STV0900_NO_ERROR;
1589 1589
@@ -1842,6 +1842,19 @@ static void stv0900_release(struct dvb_frontend *fe)
1842 kfree(state); 1842 kfree(state);
1843} 1843}
1844 1844
1845static int stv0900_get_frontend(struct dvb_frontend *fe,
1846 struct dvb_frontend_parameters *p)
1847{
1848 struct stv0900_state *state = fe->demodulator_priv;
1849 struct stv0900_internal *intp = state->internal;
1850 enum fe_stv0900_demod_num demod = state->demod;
1851 struct stv0900_signal_info p_result = intp->result[demod];
1852
1853 p->frequency = p_result.locked ? p_result.frequency : 0;
1854 p->u.qpsk.symbol_rate = p_result.locked ? p_result.symbol_rate : 0;
1855 return 0;
1856}
1857
1845static struct dvb_frontend_ops stv0900_ops = { 1858static struct dvb_frontend_ops stv0900_ops = {
1846 1859
1847 .info = { 1860 .info = {
@@ -1862,6 +1875,7 @@ static struct dvb_frontend_ops stv0900_ops = {
1862 }, 1875 },
1863 .release = stv0900_release, 1876 .release = stv0900_release,
1864 .init = stv0900_init, 1877 .init = stv0900_init,
1878 .get_frontend = stv0900_get_frontend,
1865 .get_frontend_algo = stv0900_frontend_algo, 1879 .get_frontend_algo = stv0900_frontend_algo,
1866 .i2c_gate_ctrl = stv0900_i2c_gate_ctrl, 1880 .i2c_gate_ctrl = stv0900_i2c_gate_ctrl,
1867 .diseqc_send_master_cmd = stv0900_send_master_cmd, 1881 .diseqc_send_master_cmd = stv0900_send_master_cmd,
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c
index 96972804f4ad..425e7a43ae19 100644
--- a/drivers/media/dvb/frontends/stv090x.c
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -754,11 +754,19 @@ static int stv090x_write_reg(struct stv090x_state *state, unsigned int reg, u8 d
754 return stv090x_write_regs(state, reg, &data, 1); 754 return stv090x_write_regs(state, reg, &data, 1);
755} 755}
756 756
757static int stv090x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 757static int stv090x_i2c_gate_ctrl(struct stv090x_state *state, int enable)
758{ 758{
759 struct stv090x_state *state = fe->demodulator_priv;
760 u32 reg; 759 u32 reg;
761 760
761 /*
762 * NOTE! A lock is used as a FSM to control the state in which
763 * access is serialized between two tuners on the same demod.
764 * This has nothing to do with a lock to protect a critical section
765 * which may in some other cases be confused with protecting I/O
766 * access to the demodulator gate.
767 * In case of any error, the lock is unlocked and exit within the
768 * relevant operations themselves.
769 */
762 if (enable) 770 if (enable)
763 mutex_lock(&state->internal->tuner_lock); 771 mutex_lock(&state->internal->tuner_lock);
764 772
@@ -1778,7 +1786,7 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
1778 freq -= cur_step * car_step; 1786 freq -= cur_step * car_step;
1779 1787
1780 /* Setup tuner */ 1788 /* Setup tuner */
1781 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 1789 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
1782 goto err; 1790 goto err;
1783 1791
1784 if (state->config->tuner_set_frequency) { 1792 if (state->config->tuner_set_frequency) {
@@ -1791,12 +1799,12 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
1791 goto err_gateoff; 1799 goto err_gateoff;
1792 } 1800 }
1793 1801
1794 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 1802 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
1795 goto err; 1803 goto err;
1796 1804
1797 msleep(50); 1805 msleep(50);
1798 1806
1799 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 1807 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
1800 goto err; 1808 goto err;
1801 1809
1802 if (state->config->tuner_get_status) { 1810 if (state->config->tuner_get_status) {
@@ -1809,7 +1817,7 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
1809 else 1817 else
1810 dprintk(FE_DEBUG, 1, "Tuner unlocked"); 1818 dprintk(FE_DEBUG, 1, "Tuner unlocked");
1811 1819
1812 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 1820 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
1813 goto err; 1821 goto err;
1814 1822
1815 } 1823 }
@@ -1822,7 +1830,7 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
1822 return srate_coarse; 1830 return srate_coarse;
1823 1831
1824err_gateoff: 1832err_gateoff:
1825 stv090x_i2c_gate_ctrl(fe, 0); 1833 stv090x_i2c_gate_ctrl(state, 0);
1826err: 1834err:
1827 dprintk(FE_ERROR, 1, "I/O error"); 1835 dprintk(FE_ERROR, 1, "I/O error");
1828 return -1; 1836 return -1;
@@ -2167,7 +2175,7 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd)
2167 freq -= cur_step * car_step; 2175 freq -= cur_step * car_step;
2168 2176
2169 /* Setup tuner */ 2177 /* Setup tuner */
2170 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 2178 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
2171 goto err; 2179 goto err;
2172 2180
2173 if (state->config->tuner_set_frequency) { 2181 if (state->config->tuner_set_frequency) {
@@ -2180,12 +2188,12 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd)
2180 goto err_gateoff; 2188 goto err_gateoff;
2181 } 2189 }
2182 2190
2183 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 2191 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
2184 goto err; 2192 goto err;
2185 2193
2186 msleep(50); 2194 msleep(50);
2187 2195
2188 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 2196 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
2189 goto err; 2197 goto err;
2190 2198
2191 if (state->config->tuner_get_status) { 2199 if (state->config->tuner_get_status) {
@@ -2198,7 +2206,7 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd)
2198 else 2206 else
2199 dprintk(FE_DEBUG, 1, "Tuner unlocked"); 2207 dprintk(FE_DEBUG, 1, "Tuner unlocked");
2200 2208
2201 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 2209 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
2202 goto err; 2210 goto err;
2203 2211
2204 STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c); 2212 STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c);
@@ -2222,7 +2230,7 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd)
2222 return lock; 2230 return lock;
2223 2231
2224err_gateoff: 2232err_gateoff:
2225 stv090x_i2c_gate_ctrl(fe, 0); 2233 stv090x_i2c_gate_ctrl(state, 0);
2226err: 2234err:
2227 dprintk(FE_ERROR, 1, "I/O error"); 2235 dprintk(FE_ERROR, 1, "I/O error");
2228 return -1; 2236 return -1;
@@ -2591,7 +2599,7 @@ static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *st
2591 } 2599 }
2592 state->delsys = stv090x_get_std(state); 2600 state->delsys = stv090x_get_std(state);
2593 2601
2594 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 2602 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
2595 goto err; 2603 goto err;
2596 2604
2597 if (state->config->tuner_get_frequency) { 2605 if (state->config->tuner_get_frequency) {
@@ -2599,7 +2607,7 @@ static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *st
2599 goto err_gateoff; 2607 goto err_gateoff;
2600 } 2608 }
2601 2609
2602 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 2610 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
2603 goto err; 2611 goto err;
2604 2612
2605 offst_freq = stv090x_get_car_freq(state, state->internal->mclk) / 1000; 2613 offst_freq = stv090x_get_car_freq(state, state->internal->mclk) / 1000;
@@ -2619,7 +2627,7 @@ static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *st
2619 2627
2620 if ((state->algo == STV090x_BLIND_SEARCH) || (state->srate < 10000000)) { 2628 if ((state->algo == STV090x_BLIND_SEARCH) || (state->srate < 10000000)) {
2621 2629
2622 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 2630 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
2623 goto err; 2631 goto err;
2624 2632
2625 if (state->config->tuner_get_frequency) { 2633 if (state->config->tuner_get_frequency) {
@@ -2627,7 +2635,7 @@ static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *st
2627 goto err_gateoff; 2635 goto err_gateoff;
2628 } 2636 }
2629 2637
2630 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 2638 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
2631 goto err; 2639 goto err;
2632 2640
2633 if (abs(offst_freq) <= ((state->search_range / 2000) + 500)) 2641 if (abs(offst_freq) <= ((state->search_range / 2000) + 500))
@@ -2646,7 +2654,7 @@ static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *st
2646 return STV090x_OUTOFRANGE; 2654 return STV090x_OUTOFRANGE;
2647 2655
2648err_gateoff: 2656err_gateoff:
2649 stv090x_i2c_gate_ctrl(fe, 0); 2657 stv090x_i2c_gate_ctrl(state, 0);
2650err: 2658err:
2651 dprintk(FE_ERROR, 1, "I/O error"); 2659 dprintk(FE_ERROR, 1, "I/O error");
2652 return -1; 2660 return -1;
@@ -3000,7 +3008,7 @@ static int stv090x_optimize_track(struct stv090x_state *state)
3000 3008
3001 if (state->algo != STV090x_WARM_SEARCH) { 3009 if (state->algo != STV090x_WARM_SEARCH) {
3002 3010
3003 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 3011 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
3004 goto err; 3012 goto err;
3005 3013
3006 if (state->config->tuner_set_bandwidth) { 3014 if (state->config->tuner_set_bandwidth) {
@@ -3008,7 +3016,7 @@ static int stv090x_optimize_track(struct stv090x_state *state)
3008 goto err_gateoff; 3016 goto err_gateoff;
3009 } 3017 }
3010 3018
3011 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 3019 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
3012 goto err; 3020 goto err;
3013 3021
3014 } 3022 }
@@ -3059,7 +3067,7 @@ static int stv090x_optimize_track(struct stv090x_state *state)
3059 return 0; 3067 return 0;
3060 3068
3061err_gateoff: 3069err_gateoff:
3062 stv090x_i2c_gate_ctrl(fe, 0); 3070 stv090x_i2c_gate_ctrl(state, 0);
3063err: 3071err:
3064 dprintk(FE_ERROR, 1, "I/O error"); 3072 dprintk(FE_ERROR, 1, "I/O error");
3065 return -1; 3073 return -1;
@@ -3235,7 +3243,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state)
3235 } 3243 }
3236 3244
3237 /* Setup tuner */ 3245 /* Setup tuner */
3238 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 3246 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
3239 goto err; 3247 goto err;
3240 3248
3241 if (state->config->tuner_set_bbgain) { 3249 if (state->config->tuner_set_bbgain) {
@@ -3256,17 +3264,17 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state)
3256 goto err_gateoff; 3264 goto err_gateoff;
3257 } 3265 }
3258 3266
3259 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 3267 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
3260 goto err; 3268 goto err;
3261 3269
3262 msleep(50); 3270 msleep(50);
3263 3271
3264 if (state->config->tuner_get_status) { 3272 if (state->config->tuner_get_status) {
3265 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 3273 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
3266 goto err; 3274 goto err;
3267 if (state->config->tuner_get_status(fe, &reg) < 0) 3275 if (state->config->tuner_get_status(fe, &reg) < 0)
3268 goto err_gateoff; 3276 goto err_gateoff;
3269 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 3277 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
3270 goto err; 3278 goto err;
3271 3279
3272 if (reg) 3280 if (reg)
@@ -3400,7 +3408,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state)
3400 return signal_state; 3408 return signal_state;
3401 3409
3402err_gateoff: 3410err_gateoff:
3403 stv090x_i2c_gate_ctrl(fe, 0); 3411 stv090x_i2c_gate_ctrl(state, 0);
3404err: 3412err:
3405 dprintk(FE_ERROR, 1, "I/O error"); 3413 dprintk(FE_ERROR, 1, "I/O error");
3406 return -1; 3414 return -1;
@@ -3839,6 +3847,17 @@ static int stv090x_sleep(struct dvb_frontend *fe)
3839 struct stv090x_state *state = fe->demodulator_priv; 3847 struct stv090x_state *state = fe->demodulator_priv;
3840 u32 reg; 3848 u32 reg;
3841 3849
3850 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
3851 goto err;
3852
3853 if (state->config->tuner_sleep) {
3854 if (state->config->tuner_sleep(fe) < 0)
3855 goto err_gateoff;
3856 }
3857
3858 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
3859 goto err;
3860
3842 dprintk(FE_DEBUG, 1, "Set %s to sleep", 3861 dprintk(FE_DEBUG, 1, "Set %s to sleep",
3843 state->device == STV0900 ? "STV0900" : "STV0903"); 3862 state->device == STV0900 ? "STV0900" : "STV0903");
3844 3863
@@ -3853,6 +3872,9 @@ static int stv090x_sleep(struct dvb_frontend *fe)
3853 goto err; 3872 goto err;
3854 3873
3855 return 0; 3874 return 0;
3875
3876err_gateoff:
3877 stv090x_i2c_gate_ctrl(state, 0);
3856err: 3878err:
3857 dprintk(FE_ERROR, 1, "I/O error"); 3879 dprintk(FE_ERROR, 1, "I/O error");
3858 return -1; 3880 return -1;
@@ -4311,6 +4333,20 @@ static int stv090x_init(struct dvb_frontend *fe)
4311 u32 reg; 4333 u32 reg;
4312 4334
4313 if (state->internal->mclk == 0) { 4335 if (state->internal->mclk == 0) {
4336 /* call tuner init to configure the tuner's clock output
4337 divider directly before setting up the master clock of
4338 the stv090x. */
4339 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
4340 goto err;
4341
4342 if (config->tuner_init) {
4343 if (config->tuner_init(fe) < 0)
4344 goto err_gateoff;
4345 }
4346
4347 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
4348 goto err;
4349
4314 stv090x_set_mclk(state, 135000000, config->xtal); /* 135 Mhz */ 4350 stv090x_set_mclk(state, 135000000, config->xtal); /* 135 Mhz */
4315 msleep(5); 4351 msleep(5);
4316 if (stv090x_write_reg(state, STV090x_SYNTCTRL, 4352 if (stv090x_write_reg(state, STV090x_SYNTCTRL,
@@ -4336,7 +4372,7 @@ static int stv090x_init(struct dvb_frontend *fe)
4336 if (STV090x_WRITE_DEMOD(state, DEMOD, reg) < 0) 4372 if (STV090x_WRITE_DEMOD(state, DEMOD, reg) < 0)
4337 goto err; 4373 goto err;
4338 4374
4339 if (stv090x_i2c_gate_ctrl(fe, 1) < 0) 4375 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
4340 goto err; 4376 goto err;
4341 4377
4342 if (config->tuner_set_mode) { 4378 if (config->tuner_set_mode) {
@@ -4349,7 +4385,7 @@ static int stv090x_init(struct dvb_frontend *fe)
4349 goto err_gateoff; 4385 goto err_gateoff;
4350 } 4386 }
4351 4387
4352 if (stv090x_i2c_gate_ctrl(fe, 0) < 0) 4388 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
4353 goto err; 4389 goto err;
4354 4390
4355 if (stv090x_set_tspath(state) < 0) 4391 if (stv090x_set_tspath(state) < 0)
@@ -4358,7 +4394,7 @@ static int stv090x_init(struct dvb_frontend *fe)
4358 return 0; 4394 return 0;
4359 4395
4360err_gateoff: 4396err_gateoff:
4361 stv090x_i2c_gate_ctrl(fe, 0); 4397 stv090x_i2c_gate_ctrl(state, 0);
4362err: 4398err:
4363 dprintk(FE_ERROR, 1, "I/O error"); 4399 dprintk(FE_ERROR, 1, "I/O error");
4364 return -1; 4400 return -1;
@@ -4503,8 +4539,6 @@ static struct dvb_frontend_ops stv090x_ops = {
4503 .sleep = stv090x_sleep, 4539 .sleep = stv090x_sleep,
4504 .get_frontend_algo = stv090x_frontend_algo, 4540 .get_frontend_algo = stv090x_frontend_algo,
4505 4541
4506 .i2c_gate_ctrl = stv090x_i2c_gate_ctrl,
4507
4508 .diseqc_send_master_cmd = stv090x_send_diseqc_msg, 4542 .diseqc_send_master_cmd = stv090x_send_diseqc_msg,
4509 .diseqc_send_burst = stv090x_send_diseqc_burst, 4543 .diseqc_send_burst = stv090x_send_diseqc_burst,
4510 .diseqc_recv_slave_reply = stv090x_recv_slave_reply, 4544 .diseqc_recv_slave_reply = stv090x_recv_slave_reply,
diff --git a/drivers/media/dvb/frontends/stv090x.h b/drivers/media/dvb/frontends/stv090x.h
index 30f01a6902ac..dd1b93ae4e9d 100644
--- a/drivers/media/dvb/frontends/stv090x.h
+++ b/drivers/media/dvb/frontends/stv090x.h
@@ -87,6 +87,7 @@ struct stv090x_config {
87 bool diseqc_envelope_mode; 87 bool diseqc_envelope_mode;
88 88
89 int (*tuner_init) (struct dvb_frontend *fe); 89 int (*tuner_init) (struct dvb_frontend *fe);
90 int (*tuner_sleep) (struct dvb_frontend *fe);
90 int (*tuner_set_mode) (struct dvb_frontend *fe, enum tuner_mode mode); 91 int (*tuner_set_mode) (struct dvb_frontend *fe, enum tuner_mode mode);
91 int (*tuner_set_frequency) (struct dvb_frontend *fe, u32 frequency); 92 int (*tuner_set_frequency) (struct dvb_frontend *fe, u32 frequency);
92 int (*tuner_get_frequency) (struct dvb_frontend *fe, u32 *frequency); 93 int (*tuner_get_frequency) (struct dvb_frontend *fe, u32 *frequency);
diff --git a/drivers/media/dvb/frontends/stv6110x.c b/drivers/media/dvb/frontends/stv6110x.c
index dea4245f077c..f36cab12bdc7 100644
--- a/drivers/media/dvb/frontends/stv6110x.c
+++ b/drivers/media/dvb/frontends/stv6110x.c
@@ -303,7 +303,10 @@ static int stv6110x_set_mode(struct dvb_frontend *fe, enum tuner_mode mode)
303 303
304static int stv6110x_sleep(struct dvb_frontend *fe) 304static int stv6110x_sleep(struct dvb_frontend *fe)
305{ 305{
306 return stv6110x_set_mode(fe, TUNER_SLEEP); 306 if (fe->tuner_priv)
307 return stv6110x_set_mode(fe, TUNER_SLEEP);
308
309 return 0;
307} 310}
308 311
309static int stv6110x_get_status(struct dvb_frontend *fe, u32 *status) 312static int stv6110x_get_status(struct dvb_frontend *fe, u32 *status)
@@ -338,14 +341,12 @@ static struct dvb_tuner_ops stv6110x_ops = {
338 .frequency_max = 2150000, 341 .frequency_max = 2150000,
339 .frequency_step = 0, 342 .frequency_step = 0,
340 }, 343 },
341
342 .init = stv6110x_init,
343 .sleep = stv6110x_sleep,
344 .release = stv6110x_release 344 .release = stv6110x_release
345}; 345};
346 346
347static struct stv6110x_devctl stv6110x_ctl = { 347static struct stv6110x_devctl stv6110x_ctl = {
348 .tuner_init = stv6110x_init, 348 .tuner_init = stv6110x_init,
349 .tuner_sleep = stv6110x_sleep,
349 .tuner_set_mode = stv6110x_set_mode, 350 .tuner_set_mode = stv6110x_set_mode,
350 .tuner_set_frequency = stv6110x_set_frequency, 351 .tuner_set_frequency = stv6110x_set_frequency,
351 .tuner_get_frequency = stv6110x_get_frequency, 352 .tuner_get_frequency = stv6110x_get_frequency,
@@ -363,11 +364,10 @@ struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
363{ 364{
364 struct stv6110x_state *stv6110x; 365 struct stv6110x_state *stv6110x;
365 u8 default_regs[] = {0x07, 0x11, 0xdc, 0x85, 0x17, 0x01, 0xe6, 0x1e}; 366 u8 default_regs[] = {0x07, 0x11, 0xdc, 0x85, 0x17, 0x01, 0xe6, 0x1e};
366 int ret;
367 367
368 stv6110x = kzalloc(sizeof (struct stv6110x_state), GFP_KERNEL); 368 stv6110x = kzalloc(sizeof (struct stv6110x_state), GFP_KERNEL);
369 if (stv6110x == NULL) 369 if (!stv6110x)
370 goto error; 370 return NULL;
371 371
372 stv6110x->i2c = i2c; 372 stv6110x->i2c = i2c;
373 stv6110x->config = config; 373 stv6110x->config = config;
@@ -392,34 +392,11 @@ struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
392 break; 392 break;
393 } 393 }
394 394
395 if (fe->ops.i2c_gate_ctrl) {
396 ret = fe->ops.i2c_gate_ctrl(fe, 1);
397 if (ret < 0)
398 goto error;
399 }
400
401 ret = stv6110x_write_regs(stv6110x, 0, stv6110x->regs,
402 ARRAY_SIZE(stv6110x->regs));
403 if (ret < 0) {
404 dprintk(FE_ERROR, 1, "Initialization failed");
405 goto error;
406 }
407
408 if (fe->ops.i2c_gate_ctrl) {
409 ret = fe->ops.i2c_gate_ctrl(fe, 0);
410 if (ret < 0)
411 goto error;
412 }
413
414 fe->tuner_priv = stv6110x; 395 fe->tuner_priv = stv6110x;
415 fe->ops.tuner_ops = stv6110x_ops; 396 fe->ops.tuner_ops = stv6110x_ops;
416 397
417 printk("%s: Attaching STV6110x \n", __func__); 398 printk(KERN_INFO "%s: Attaching STV6110x\n", __func__);
418 return stv6110x->devctl; 399 return stv6110x->devctl;
419
420error:
421 kfree(stv6110x);
422 return NULL;
423} 400}
424EXPORT_SYMBOL(stv6110x_attach); 401EXPORT_SYMBOL(stv6110x_attach);
425 402
diff --git a/drivers/media/dvb/frontends/stv6110x.h b/drivers/media/dvb/frontends/stv6110x.h
index 2429ae6d7847..47516753929a 100644
--- a/drivers/media/dvb/frontends/stv6110x.h
+++ b/drivers/media/dvb/frontends/stv6110x.h
@@ -40,6 +40,7 @@ enum tuner_status {
40 40
41struct stv6110x_devctl { 41struct stv6110x_devctl {
42 int (*tuner_init) (struct dvb_frontend *fe); 42 int (*tuner_init) (struct dvb_frontend *fe);
43 int (*tuner_sleep) (struct dvb_frontend *fe);
43 int (*tuner_set_mode) (struct dvb_frontend *fe, enum tuner_mode mode); 44 int (*tuner_set_mode) (struct dvb_frontend *fe, enum tuner_mode mode);
44 int (*tuner_set_frequency) (struct dvb_frontend *fe, u32 frequency); 45 int (*tuner_set_frequency) (struct dvb_frontend *fe, u32 frequency);
45 int (*tuner_get_frequency) (struct dvb_frontend *fe, u32 *frequency); 46 int (*tuner_get_frequency) (struct dvb_frontend *fe, u32 *frequency);
diff --git a/drivers/media/dvb/mantis/mantis_input.c b/drivers/media/dvb/mantis/mantis_input.c
index 4675a3b53c7d..3d4e4663220c 100644
--- a/drivers/media/dvb/mantis/mantis_input.c
+++ b/drivers/media/dvb/mantis/mantis_input.c
@@ -32,6 +32,8 @@
32#include "mantis_reg.h" 32#include "mantis_reg.h"
33#include "mantis_uart.h" 33#include "mantis_uart.h"
34 34
35#define MODULE_NAME "mantis_core"
36
35static struct ir_scancode mantis_ir_table[] = { 37static struct ir_scancode mantis_ir_table[] = {
36 { 0x29, KEY_POWER }, 38 { 0x29, KEY_POWER },
37 { 0x28, KEY_FAVORITES }, 39 { 0x28, KEY_FAVORITES },
@@ -126,7 +128,7 @@ int mantis_input_init(struct mantis_pci *mantis)
126 rc->id.version = 1; 128 rc->id.version = 1;
127 rc->dev = mantis->pdev->dev; 129 rc->dev = mantis->pdev->dev;
128 130
129 err = ir_input_register(rc, &ir_mantis, NULL); 131 err = __ir_input_register(rc, &ir_mantis, NULL, MODULE_NAME);
130 if (err) { 132 if (err) {
131 dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err); 133 dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
132 input_free_device(rc); 134 input_free_device(rc);
diff --git a/drivers/media/dvb/mantis/mantis_vp1041.c b/drivers/media/dvb/mantis/mantis_vp1041.c
index 515346dd31d0..d1aa2bc0c155 100644
--- a/drivers/media/dvb/mantis/mantis_vp1041.c
+++ b/drivers/media/dvb/mantis/mantis_vp1041.c
@@ -136,12 +136,12 @@ static const struct stb0899_s1_reg vp1041_stb0899_s1_init_3[] = {
136 { STB0899_RCOMPC , 0xc9 }, 136 { STB0899_RCOMPC , 0xc9 },
137 { STB0899_AGC1CN , 0x01 }, 137 { STB0899_AGC1CN , 0x01 },
138 { STB0899_AGC1REF , 0x10 }, 138 { STB0899_AGC1REF , 0x10 },
139 { STB0899_RTC , 0x23 }, 139 { STB0899_RTC , 0x23 },
140 { STB0899_TMGCFG , 0x4e }, 140 { STB0899_TMGCFG , 0x4e },
141 { STB0899_AGC2REF , 0x34 }, 141 { STB0899_AGC2REF , 0x34 },
142 { STB0899_TLSR , 0x84 }, 142 { STB0899_TLSR , 0x84 },
143 { STB0899_CFD , 0xf7 }, 143 { STB0899_CFD , 0xf7 },
144 { STB0899_ACLC , 0x87 }, 144 { STB0899_ACLC , 0x87 },
145 { STB0899_BCLC , 0x94 }, 145 { STB0899_BCLC , 0x94 },
146 { STB0899_EQON , 0x41 }, 146 { STB0899_EQON , 0x41 },
147 { STB0899_LDT , 0xf1 }, 147 { STB0899_LDT , 0xf1 },
@@ -194,10 +194,10 @@ static const struct stb0899_s1_reg vp1041_stb0899_s1_init_3[] = {
194 { STB0899_ECNT3M , 0x0a }, 194 { STB0899_ECNT3M , 0x0a },
195 { STB0899_ECNT3L , 0xad }, 195 { STB0899_ECNT3L , 0xad },
196 { STB0899_FECAUTO1 , 0x06 }, 196 { STB0899_FECAUTO1 , 0x06 },
197 { STB0899_FECM , 0x01 }, 197 { STB0899_FECM , 0x01 },
198 { STB0899_VTH12 , 0xb0 }, 198 { STB0899_VTH12 , 0xb0 },
199 { STB0899_VTH23 , 0x7a }, 199 { STB0899_VTH23 , 0x7a },
200 { STB0899_VTH34 , 0x58 }, 200 { STB0899_VTH34 , 0x58 },
201 { STB0899_VTH56 , 0x38 }, 201 { STB0899_VTH56 , 0x38 },
202 { STB0899_VTH67 , 0x34 }, 202 { STB0899_VTH67 , 0x34 },
203 { STB0899_VTH78 , 0x24 }, 203 { STB0899_VTH78 , 0x24 },
@@ -206,7 +206,7 @@ static const struct stb0899_s1_reg vp1041_stb0899_s1_init_3[] = {
206 { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */ 206 { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */
207 { STB0899_TSULC , 0x42 }, 207 { STB0899_TSULC , 0x42 },
208 { STB0899_RSLLC , 0x41 }, 208 { STB0899_RSLLC , 0x41 },
209 { STB0899_TSLPL , 0x12 }, 209 { STB0899_TSLPL , 0x12 },
210 { STB0899_TSCFGH , 0x0c }, 210 { STB0899_TSCFGH , 0x0c },
211 { STB0899_TSCFGM , 0x00 }, 211 { STB0899_TSCFGM , 0x00 },
212 { STB0899_TSCFGL , 0x00 }, 212 { STB0899_TSCFGL , 0x00 },
diff --git a/drivers/media/dvb/ngene/Kconfig b/drivers/media/dvb/ngene/Kconfig
index 3ec8e6fcbb1d..cec242b7c00d 100644
--- a/drivers/media/dvb/ngene/Kconfig
+++ b/drivers/media/dvb/ngene/Kconfig
@@ -4,6 +4,8 @@ config DVB_NGENE
4 select DVB_LNBP21 if !DVB_FE_CUSTOMISE 4 select DVB_LNBP21 if !DVB_FE_CUSTOMISE
5 select DVB_STV6110x if !DVB_FE_CUSTOMISE 5 select DVB_STV6110x if !DVB_FE_CUSTOMISE
6 select DVB_STV090x if !DVB_FE_CUSTOMISE 6 select DVB_STV090x if !DVB_FE_CUSTOMISE
7 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
8 select MEDIA_TUNER_MT2131 if !MEDIA_TUNER_CUSTOMISE
7 ---help--- 9 ---help---
8 Support for Micronas PCI express cards with nGene bridge. 10 Support for Micronas PCI express cards with nGene bridge.
9 11
diff --git a/drivers/media/dvb/ngene/Makefile b/drivers/media/dvb/ngene/Makefile
index 40435cad4819..0608aabb14ee 100644
--- a/drivers/media/dvb/ngene/Makefile
+++ b/drivers/media/dvb/ngene/Makefile
@@ -2,10 +2,10 @@
2# Makefile for the nGene device driver 2# Makefile for the nGene device driver
3# 3#
4 4
5ngene-objs := ngene-core.o 5ngene-objs := ngene-core.o ngene-i2c.o ngene-cards.o ngene-dvb.o
6 6
7obj-$(CONFIG_DVB_NGENE) += ngene.o 7obj-$(CONFIG_DVB_NGENE) += ngene.o
8 8
9EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ 9EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/
10EXTRA_CFLAGS += -Idrivers/media/dvb/frontends/ 10EXTRA_CFLAGS += -Idrivers/media/dvb/frontends/
11 11EXTRA_CFLAGS += -Idrivers/media/common/tuners/
diff --git a/drivers/media/dvb/ngene/ngene-cards.c b/drivers/media/dvb/ngene/ngene-cards.c
new file mode 100644
index 000000000000..4692a41ad95b
--- /dev/null
+++ b/drivers/media/dvb/ngene/ngene-cards.c
@@ -0,0 +1,343 @@
1/*
2 * ngene-cards.c: nGene PCIe bridge driver - card specific info
3 *
4 * Copyright (C) 2005-2007 Micronas
5 *
6 * Copyright (C) 2008-2009 Ralph Metzler <rjkm@metzlerbros.de>
7 * Modifications for new nGene firmware,
8 * support for EEPROM-copying,
9 * support for new dual DVB-S2 card prototype
10 *
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * version 2 only, as published by the Free Software Foundation.
15 *
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * 02110-1301, USA
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 */
29
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/pci.h>
33#include <linux/pci_ids.h>
34
35#include "ngene.h"
36
37/* demods/tuners */
38#include "stv6110x.h"
39#include "stv090x.h"
40#include "lnbh24.h"
41#include "lgdt330x.h"
42#include "mt2131.h"
43
44
45/****************************************************************************/
46/* Demod/tuner attachment ***************************************************/
47/****************************************************************************/
48
49static int tuner_attach_stv6110(struct ngene_channel *chan)
50{
51 struct stv090x_config *feconf = (struct stv090x_config *)
52 chan->dev->card_info->fe_config[chan->number];
53 struct stv6110x_config *tunerconf = (struct stv6110x_config *)
54 chan->dev->card_info->tuner_config[chan->number];
55 struct stv6110x_devctl *ctl;
56
57 ctl = dvb_attach(stv6110x_attach, chan->fe, tunerconf,
58 &chan->i2c_adapter);
59 if (ctl == NULL) {
60 printk(KERN_ERR DEVICE_NAME ": No STV6110X found!\n");
61 return -ENODEV;
62 }
63
64 feconf->tuner_init = ctl->tuner_init;
65 feconf->tuner_set_mode = ctl->tuner_set_mode;
66 feconf->tuner_set_frequency = ctl->tuner_set_frequency;
67 feconf->tuner_get_frequency = ctl->tuner_get_frequency;
68 feconf->tuner_set_bandwidth = ctl->tuner_set_bandwidth;
69 feconf->tuner_get_bandwidth = ctl->tuner_get_bandwidth;
70 feconf->tuner_set_bbgain = ctl->tuner_set_bbgain;
71 feconf->tuner_get_bbgain = ctl->tuner_get_bbgain;
72 feconf->tuner_set_refclk = ctl->tuner_set_refclk;
73 feconf->tuner_get_status = ctl->tuner_get_status;
74
75 return 0;
76}
77
78
79static int demod_attach_stv0900(struct ngene_channel *chan)
80{
81 struct stv090x_config *feconf = (struct stv090x_config *)
82 chan->dev->card_info->fe_config[chan->number];
83
84 chan->fe = dvb_attach(stv090x_attach,
85 feconf,
86 &chan->i2c_adapter,
87 chan->number == 0 ? STV090x_DEMODULATOR_0 :
88 STV090x_DEMODULATOR_1);
89 if (chan->fe == NULL) {
90 printk(KERN_ERR DEVICE_NAME ": No STV0900 found!\n");
91 return -ENODEV;
92 }
93
94 if (!dvb_attach(lnbh24_attach, chan->fe, &chan->i2c_adapter, 0,
95 0, chan->dev->card_info->lnb[chan->number])) {
96 printk(KERN_ERR DEVICE_NAME ": No LNBH24 found!\n");
97 dvb_frontend_detach(chan->fe);
98 return -ENODEV;
99 }
100
101 return 0;
102}
103
104static struct lgdt330x_config aver_m780 = {
105 .demod_address = 0xb2 >> 1,
106 .demod_chip = LGDT3303,
107 .serial_mpeg = 0x00, /* PARALLEL */
108 .clock_polarity_flip = 1,
109};
110
111static struct mt2131_config m780_tunerconfig = {
112 0xc0 >> 1
113};
114
115/* A single func to attach the demo and tuner, rather than
116 * use two sep funcs like the current design mandates.
117 */
118static int demod_attach_lg330x(struct ngene_channel *chan)
119{
120 chan->fe = dvb_attach(lgdt330x_attach, &aver_m780, &chan->i2c_adapter);
121 if (chan->fe == NULL) {
122 printk(KERN_ERR DEVICE_NAME ": No LGDT330x found!\n");
123 return -ENODEV;
124 }
125
126 dvb_attach(mt2131_attach, chan->fe, &chan->i2c_adapter,
127 &m780_tunerconfig, 0);
128
129 return (chan->fe) ? 0 : -ENODEV;
130}
131
132/****************************************************************************/
133/* Switch control (I2C gates, etc.) *****************************************/
134/****************************************************************************/
135
136
137static struct stv090x_config fe_cineS2 = {
138 .device = STV0900,
139 .demod_mode = STV090x_DUAL,
140 .clk_mode = STV090x_CLK_EXT,
141
142 .xtal = 27000000,
143 .address = 0x68,
144
145 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
146 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
147
148 .repeater_level = STV090x_RPTLEVEL_16,
149
150 .adc1_range = STV090x_ADC_1Vpp,
151 .adc2_range = STV090x_ADC_1Vpp,
152
153 .diseqc_envelope_mode = true,
154};
155
156static struct stv6110x_config tuner_cineS2_0 = {
157 .addr = 0x60,
158 .refclk = 27000000,
159 .clk_div = 1,
160};
161
162static struct stv6110x_config tuner_cineS2_1 = {
163 .addr = 0x63,
164 .refclk = 27000000,
165 .clk_div = 1,
166};
167
168static struct ngene_info ngene_info_cineS2 = {
169 .type = NGENE_SIDEWINDER,
170 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner",
171 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
172 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
173 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
174 .fe_config = {&fe_cineS2, &fe_cineS2},
175 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
176 .lnb = {0x0b, 0x08},
177 .tsf = {3, 3},
178 .fw_version = 15,
179};
180
181static struct ngene_info ngene_info_satixS2 = {
182 .type = NGENE_SIDEWINDER,
183 .name = "Mystique SaTiX-S2 Dual",
184 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
185 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
186 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
187 .fe_config = {&fe_cineS2, &fe_cineS2},
188 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
189 .lnb = {0x0b, 0x08},
190 .tsf = {3, 3},
191 .fw_version = 15,
192};
193
194static struct ngene_info ngene_info_satixS2v2 = {
195 .type = NGENE_SIDEWINDER,
196 .name = "Mystique SaTiX-S2 Dual (v2)",
197 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
198 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
199 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
200 .fe_config = {&fe_cineS2, &fe_cineS2},
201 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
202 .lnb = {0x0a, 0x08},
203 .tsf = {3, 3},
204 .fw_version = 15,
205};
206
207static struct ngene_info ngene_info_cineS2v5 = {
208 .type = NGENE_SIDEWINDER,
209 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner (v5)",
210 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
211 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
212 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
213 .fe_config = {&fe_cineS2, &fe_cineS2},
214 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
215 .lnb = {0x0a, 0x08},
216 .tsf = {3, 3},
217 .fw_version = 15,
218};
219
220static struct ngene_info ngene_info_duoFlexS2 = {
221 .type = NGENE_SIDEWINDER,
222 .name = "Digital Devices DuoFlex S2 miniPCIe",
223 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
224 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
225 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
226 .fe_config = {&fe_cineS2, &fe_cineS2},
227 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
228 .lnb = {0x0a, 0x08},
229 .tsf = {3, 3},
230 .fw_version = 15,
231};
232
233static struct ngene_info ngene_info_m780 = {
234 .type = NGENE_APP,
235 .name = "Aver M780 ATSC/QAM-B",
236
237 /* Channel 0 is analog, which is currently unsupported */
238 .io_type = { NGENE_IO_NONE, NGENE_IO_TSIN },
239 .demod_attach = { NULL, demod_attach_lg330x },
240
241 /* Ensure these are NULL else the frame will call them (as funcs) */
242 .tuner_attach = { 0, 0, 0, 0 },
243 .fe_config = { NULL, &aver_m780 },
244 .avf = { 0 },
245
246 /* A custom electrical interface config for the demod to bridge */
247 .tsf = { 4, 4 },
248 .fw_version = 15,
249};
250
251/****************************************************************************/
252
253
254
255/****************************************************************************/
256/* PCI Subsystem ID *********************************************************/
257/****************************************************************************/
258
259#define NGENE_ID(_subvend, _subdev, _driverdata) { \
260 .vendor = NGENE_VID, .device = NGENE_PID, \
261 .subvendor = _subvend, .subdevice = _subdev, \
262 .driver_data = (unsigned long) &_driverdata }
263
264/****************************************************************************/
265
266static const struct pci_device_id ngene_id_tbl[] __devinitdata = {
267 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2),
268 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2),
269 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2),
270 NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2),
271 NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5),
272 NGENE_ID(0x18c3, 0xdd10, ngene_info_duoFlexS2),
273 NGENE_ID(0x18c3, 0xdd20, ngene_info_duoFlexS2),
274 NGENE_ID(0x1461, 0x062e, ngene_info_m780),
275 {0}
276};
277MODULE_DEVICE_TABLE(pci, ngene_id_tbl);
278
279/****************************************************************************/
280/* Init/Exit ****************************************************************/
281/****************************************************************************/
282
283static pci_ers_result_t ngene_error_detected(struct pci_dev *dev,
284 enum pci_channel_state state)
285{
286 printk(KERN_ERR DEVICE_NAME ": PCI error\n");
287 if (state == pci_channel_io_perm_failure)
288 return PCI_ERS_RESULT_DISCONNECT;
289 if (state == pci_channel_io_frozen)
290 return PCI_ERS_RESULT_NEED_RESET;
291 return PCI_ERS_RESULT_CAN_RECOVER;
292}
293
294static pci_ers_result_t ngene_link_reset(struct pci_dev *dev)
295{
296 printk(KERN_INFO DEVICE_NAME ": link reset\n");
297 return 0;
298}
299
300static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev)
301{
302 printk(KERN_INFO DEVICE_NAME ": slot reset\n");
303 return 0;
304}
305
306static void ngene_resume(struct pci_dev *dev)
307{
308 printk(KERN_INFO DEVICE_NAME ": resume\n");
309}
310
311static struct pci_error_handlers ngene_errors = {
312 .error_detected = ngene_error_detected,
313 .link_reset = ngene_link_reset,
314 .slot_reset = ngene_slot_reset,
315 .resume = ngene_resume,
316};
317
318static struct pci_driver ngene_pci_driver = {
319 .name = "ngene",
320 .id_table = ngene_id_tbl,
321 .probe = ngene_probe,
322 .remove = __devexit_p(ngene_remove),
323 .err_handler = &ngene_errors,
324};
325
326static __init int module_init_ngene(void)
327{
328 printk(KERN_INFO
329 "nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n");
330 return pci_register_driver(&ngene_pci_driver);
331}
332
333static __exit void module_exit_ngene(void)
334{
335 pci_unregister_driver(&ngene_pci_driver);
336}
337
338module_init(module_init_ngene);
339module_exit(module_exit_ngene);
340
341MODULE_DESCRIPTION("nGene");
342MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel");
343MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ngene/ngene-core.c b/drivers/media/dvb/ngene/ngene-core.c
index 645e8b8a7137..4caeb163a666 100644
--- a/drivers/media/dvb/ngene/ngene-core.c
+++ b/drivers/media/dvb/ngene/ngene-core.c
@@ -34,20 +34,14 @@
34#include <linux/io.h> 34#include <linux/io.h>
35#include <asm/div64.h> 35#include <asm/div64.h>
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/pci_ids.h>
38#include <linux/smp_lock.h> 37#include <linux/smp_lock.h>
39#include <linux/timer.h> 38#include <linux/timer.h>
40#include <linux/version.h>
41#include <linux/byteorder/generic.h> 39#include <linux/byteorder/generic.h>
42#include <linux/firmware.h> 40#include <linux/firmware.h>
43#include <linux/vmalloc.h> 41#include <linux/vmalloc.h>
44 42
45#include "ngene.h" 43#include "ngene.h"
46 44
47#include "stv6110x.h"
48#include "stv090x.h"
49#include "lnbh24.h"
50
51static int one_adapter = 1; 45static int one_adapter = 1;
52module_param(one_adapter, int, 0444); 46module_param(one_adapter, int, 0444);
53MODULE_PARM_DESC(one_adapter, "Use only one adapter."); 47MODULE_PARM_DESC(one_adapter, "Use only one adapter.");
@@ -59,12 +53,8 @@ MODULE_PARM_DESC(debug, "Print debugging information.");
59 53
60DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 54DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
61 55
62#define COMMAND_TIMEOUT_WORKAROUND
63
64#define dprintk if (debug) printk 56#define dprintk if (debug) printk
65 57
66#define DEVICE_NAME "ngene"
67
68#define ngwriteb(dat, adr) writeb((dat), (char *)(dev->iomem + (adr))) 58#define ngwriteb(dat, adr) writeb((dat), (char *)(dev->iomem + (adr)))
69#define ngwritel(dat, adr) writel((dat), (char *)(dev->iomem + (adr))) 59#define ngwritel(dat, adr) writel((dat), (char *)(dev->iomem + (adr)))
70#define ngwriteb(dat, adr) writeb((dat), (char *)(dev->iomem + (adr))) 60#define ngwriteb(dat, adr) writeb((dat), (char *)(dev->iomem + (adr)))
@@ -155,24 +145,24 @@ static void demux_tasklet(unsigned long data)
155 } else { 145 } else {
156 if (chan->HWState == HWSTATE_RUN) { 146 if (chan->HWState == HWSTATE_RUN) {
157 u32 Flags = 0; 147 u32 Flags = 0;
148 IBufferExchange *exch1 = chan->pBufferExchange;
149 IBufferExchange *exch2 = chan->pBufferExchange2;
158 if (Cur->ngeneBuffer.SR.Flags & 0x01) 150 if (Cur->ngeneBuffer.SR.Flags & 0x01)
159 Flags |= BEF_EVEN_FIELD; 151 Flags |= BEF_EVEN_FIELD;
160 if (Cur->ngeneBuffer.SR.Flags & 0x20) 152 if (Cur->ngeneBuffer.SR.Flags & 0x20)
161 Flags |= BEF_OVERFLOW; 153 Flags |= BEF_OVERFLOW;
162 if (chan->pBufferExchange) 154 spin_unlock_irq(&chan->state_lock);
163 chan->pBufferExchange(chan, 155 if (exch1)
164 Cur->Buffer1, 156 exch1(chan, Cur->Buffer1,
165 chan-> 157 chan->Capture1Length,
166 Capture1Length, 158 Cur->ngeneBuffer.SR.Clock,
167 Cur->ngeneBuffer. 159 Flags);
168 SR.Clock, Flags); 160 if (exch2)
169 if (chan->pBufferExchange2) 161 exch2(chan, Cur->Buffer2,
170 chan->pBufferExchange2(chan, 162 chan->Capture2Length,
171 Cur->Buffer2, 163 Cur->ngeneBuffer.SR.Clock,
172 chan-> 164 Flags);
173 Capture2Length, 165 spin_lock_irq(&chan->state_lock);
174 Cur->ngeneBuffer.
175 SR.Clock, Flags);
176 } else if (chan->HWState != HWSTATE_STOP) 166 } else if (chan->HWState != HWSTATE_STOP)
177 chan->HWState = HWSTATE_RUN; 167 chan->HWState = HWSTATE_RUN;
178 } 168 }
@@ -352,7 +342,7 @@ static int ngene_command_mutex(struct ngene *dev, struct ngene_command *com)
352 return 0; 342 return 0;
353} 343}
354 344
355static int ngene_command(struct ngene *dev, struct ngene_command *com) 345int ngene_command(struct ngene *dev, struct ngene_command *com)
356{ 346{
357 int result; 347 int result;
358 348
@@ -363,55 +353,6 @@ static int ngene_command(struct ngene *dev, struct ngene_command *com)
363} 353}
364 354
365 355
366static int ngene_command_i2c_read(struct ngene *dev, u8 adr,
367 u8 *out, u8 outlen, u8 *in, u8 inlen, int flag)
368{
369 struct ngene_command com;
370
371 com.cmd.hdr.Opcode = CMD_I2C_READ;
372 com.cmd.hdr.Length = outlen + 3;
373 com.cmd.I2CRead.Device = adr << 1;
374 memcpy(com.cmd.I2CRead.Data, out, outlen);
375 com.cmd.I2CRead.Data[outlen] = inlen;
376 com.cmd.I2CRead.Data[outlen + 1] = 0;
377 com.in_len = outlen + 3;
378 com.out_len = inlen + 1;
379
380 if (ngene_command(dev, &com) < 0)
381 return -EIO;
382
383 if ((com.cmd.raw8[0] >> 1) != adr)
384 return -EIO;
385
386 if (flag)
387 memcpy(in, com.cmd.raw8, inlen + 1);
388 else
389 memcpy(in, com.cmd.raw8 + 1, inlen);
390 return 0;
391}
392
393static int ngene_command_i2c_write(struct ngene *dev, u8 adr,
394 u8 *out, u8 outlen)
395{
396 struct ngene_command com;
397
398
399 com.cmd.hdr.Opcode = CMD_I2C_WRITE;
400 com.cmd.hdr.Length = outlen + 1;
401 com.cmd.I2CRead.Device = adr << 1;
402 memcpy(com.cmd.I2CRead.Data, out, outlen);
403 com.in_len = outlen + 1;
404 com.out_len = 1;
405
406 if (ngene_command(dev, &com) < 0)
407 return -EIO;
408
409 if (com.cmd.raw8[0] == 1)
410 return -EIO;
411
412 return 0;
413}
414
415static int ngene_command_load_firmware(struct ngene *dev, 356static int ngene_command_load_firmware(struct ngene *dev,
416 u8 *ngene_fw, u32 size) 357 u8 *ngene_fw, u32 size)
417{ 358{
@@ -477,7 +418,7 @@ static int ngene_command_config_free_buf(struct ngene *dev, u8 *config)
477 return 0; 418 return 0;
478} 419}
479 420
480static int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level) 421int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level)
481{ 422{
482 struct ngene_command com; 423 struct ngene_command com;
483 424
@@ -514,11 +455,12 @@ static int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level)
514 455
515/****************************************************************************/ 456/****************************************************************************/
516 457
517static u8 TSFeatureDecoderSetup[8 * 4] = { 458static u8 TSFeatureDecoderSetup[8 * 5] = {
518 0x42, 0x00, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, 459 0x42, 0x00, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00,
519 0x40, 0x06, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* DRXH */ 460 0x40, 0x06, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* DRXH */
520 0x71, 0x07, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* DRXHser */ 461 0x71, 0x07, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* DRXHser */
521 0x72, 0x06, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* S2ser */ 462 0x72, 0x06, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* S2ser */
463 0x40, 0x07, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* LGDT3303 */
522}; 464};
523 465
524/* Set NGENE I2S Config to 16 bit packed */ 466/* Set NGENE I2S Config to 16 bit packed */
@@ -559,7 +501,7 @@ static u8 ITUFeatureDecoderSetup[8] = {
559 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x04, 0x00 501 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x04, 0x00
560}; 502};
561 503
562static void FillTSBuffer(void *Buffer, int Length, u32 Flags) 504void FillTSBuffer(void *Buffer, int Length, u32 Flags)
563{ 505{
564 u32 *ptr = Buffer; 506 u32 *ptr = Buffer;
565 507
@@ -628,11 +570,7 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
628 u16 BsSPI = ((stream & 1) ? 0x9800 : 0x9700); 570 u16 BsSPI = ((stream & 1) ? 0x9800 : 0x9700);
629 u16 BsSDO = 0x9B00; 571 u16 BsSDO = 0x9B00;
630 572
631 /* down(&dev->stream_mutex); */ 573 down(&dev->stream_mutex);
632 while (down_trylock(&dev->stream_mutex)) {
633 printk(KERN_INFO DEVICE_NAME ": SC locked\n");
634 msleep(1);
635 }
636 memset(&com, 0, sizeof(com)); 574 memset(&com, 0, sizeof(com));
637 com.cmd.hdr.Opcode = CMD_CONTROL; 575 com.cmd.hdr.Opcode = CMD_CONTROL;
638 com.cmd.hdr.Length = sizeof(struct FW_STREAM_CONTROL) - 2; 576 com.cmd.hdr.Length = sizeof(struct FW_STREAM_CONTROL) - 2;
@@ -772,144 +710,7 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
772 return 0; 710 return 0;
773} 711}
774 712
775 713void set_transfer(struct ngene_channel *chan, int state)
776/****************************************************************************/
777/* I2C **********************************************************************/
778/****************************************************************************/
779
780static void ngene_i2c_set_bus(struct ngene *dev, int bus)
781{
782 if (!(dev->card_info->i2c_access & 2))
783 return;
784 if (dev->i2c_current_bus == bus)
785 return;
786
787 switch (bus) {
788 case 0:
789 ngene_command_gpio_set(dev, 3, 0);
790 ngene_command_gpio_set(dev, 2, 1);
791 break;
792
793 case 1:
794 ngene_command_gpio_set(dev, 2, 0);
795 ngene_command_gpio_set(dev, 3, 1);
796 break;
797 }
798 dev->i2c_current_bus = bus;
799}
800
801static int ngene_i2c_master_xfer(struct i2c_adapter *adapter,
802 struct i2c_msg msg[], int num)
803{
804 struct ngene_channel *chan =
805 (struct ngene_channel *)i2c_get_adapdata(adapter);
806 struct ngene *dev = chan->dev;
807
808 down(&dev->i2c_switch_mutex);
809 ngene_i2c_set_bus(dev, chan->number);
810
811 if (num == 2 && msg[1].flags & I2C_M_RD && !(msg[0].flags & I2C_M_RD))
812 if (!ngene_command_i2c_read(dev, msg[0].addr,
813 msg[0].buf, msg[0].len,
814 msg[1].buf, msg[1].len, 0))
815 goto done;
816
817 if (num == 1 && !(msg[0].flags & I2C_M_RD))
818 if (!ngene_command_i2c_write(dev, msg[0].addr,
819 msg[0].buf, msg[0].len))
820 goto done;
821 if (num == 1 && (msg[0].flags & I2C_M_RD))
822 if (!ngene_command_i2c_read(dev, msg[0].addr, 0, 0,
823 msg[0].buf, msg[0].len, 0))
824 goto done;
825
826 up(&dev->i2c_switch_mutex);
827 return -EIO;
828
829done:
830 up(&dev->i2c_switch_mutex);
831 return num;
832}
833
834
835static u32 ngene_i2c_functionality(struct i2c_adapter *adap)
836{
837 return I2C_FUNC_SMBUS_EMUL;
838}
839
840static struct i2c_algorithm ngene_i2c_algo = {
841 .master_xfer = ngene_i2c_master_xfer,
842 .functionality = ngene_i2c_functionality,
843};
844
845static int ngene_i2c_init(struct ngene *dev, int dev_nr)
846{
847 struct i2c_adapter *adap = &(dev->channel[dev_nr].i2c_adapter);
848
849 i2c_set_adapdata(adap, &(dev->channel[dev_nr]));
850 adap->class = I2C_CLASS_TV_DIGITAL | I2C_CLASS_TV_ANALOG;
851
852 strcpy(adap->name, "nGene");
853
854 adap->algo = &ngene_i2c_algo;
855 adap->algo_data = (void *)&(dev->channel[dev_nr]);
856 adap->dev.parent = &dev->pci_dev->dev;
857
858 return i2c_add_adapter(adap);
859}
860
861
862/****************************************************************************/
863/* DVB functions and API interface ******************************************/
864/****************************************************************************/
865
866static void swap_buffer(u32 *p, u32 len)
867{
868 while (len) {
869 *p = swab32(*p);
870 p++;
871 len -= 4;
872 }
873}
874
875
876static void *tsin_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags)
877{
878 struct ngene_channel *chan = priv;
879
880
881#ifdef COMMAND_TIMEOUT_WORKAROUND
882 if (chan->users > 0)
883#endif
884 dvb_dmx_swfilter(&chan->demux, buf, len);
885 return 0;
886}
887
888u8 fill_ts[188] = { 0x47, 0x1f, 0xff, 0x10 };
889
890static void *tsout_exchange(void *priv, void *buf, u32 len,
891 u32 clock, u32 flags)
892{
893 struct ngene_channel *chan = priv;
894 struct ngene *dev = chan->dev;
895 u32 alen;
896
897 alen = dvb_ringbuffer_avail(&dev->tsout_rbuf);
898 alen -= alen % 188;
899
900 if (alen < len)
901 FillTSBuffer(buf + alen, len - alen, flags);
902 else
903 alen = len;
904 dvb_ringbuffer_read(&dev->tsout_rbuf, buf, alen);
905 if (flags & DF_SWAP32)
906 swap_buffer((u32 *)buf, alen);
907 wake_up_interruptible(&dev->tsout_rbuf.queue);
908 return buf;
909}
910
911
912static void set_transfer(struct ngene_channel *chan, int state)
913{ 714{
914 u8 control = 0, mode = 0, flags = 0; 715 u8 control = 0, mode = 0, flags = 0;
915 struct ngene *dev = chan->dev; 716 struct ngene *dev = chan->dev;
@@ -970,85 +771,12 @@ static void set_transfer(struct ngene_channel *chan, int state)
970 state); 771 state);
971 if (!state) { 772 if (!state) {
972 spin_lock_irq(&chan->state_lock); 773 spin_lock_irq(&chan->state_lock);
973 chan->pBufferExchange = 0; 774 chan->pBufferExchange = NULL;
974 dvb_ringbuffer_flush(&dev->tsout_rbuf); 775 dvb_ringbuffer_flush(&dev->tsout_rbuf);
975 spin_unlock_irq(&chan->state_lock); 776 spin_unlock_irq(&chan->state_lock);
976 } 777 }
977} 778}
978 779
979static int ngene_start_feed(struct dvb_demux_feed *dvbdmxfeed)
980{
981 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
982 struct ngene_channel *chan = dvbdmx->priv;
983
984 if (chan->users == 0) {
985#ifdef COMMAND_TIMEOUT_WORKAROUND
986 if (!chan->running)
987#endif
988 set_transfer(chan, 1);
989 /* msleep(10); */
990 }
991
992 return ++chan->users;
993}
994
995static int ngene_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
996{
997 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
998 struct ngene_channel *chan = dvbdmx->priv;
999
1000 if (--chan->users)
1001 return chan->users;
1002
1003#ifndef COMMAND_TIMEOUT_WORKAROUND
1004 set_transfer(chan, 0);
1005#endif
1006
1007 return 0;
1008}
1009
1010
1011
1012static int my_dvb_dmx_ts_card_init(struct dvb_demux *dvbdemux, char *id,
1013 int (*start_feed)(struct dvb_demux_feed *),
1014 int (*stop_feed)(struct dvb_demux_feed *),
1015 void *priv)
1016{
1017 dvbdemux->priv = priv;
1018
1019 dvbdemux->filternum = 256;
1020 dvbdemux->feednum = 256;
1021 dvbdemux->start_feed = start_feed;
1022 dvbdemux->stop_feed = stop_feed;
1023 dvbdemux->write_to_decoder = 0;
1024 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING |
1025 DMX_SECTION_FILTERING |
1026 DMX_MEMORY_BASED_FILTERING);
1027 return dvb_dmx_init(dvbdemux);
1028}
1029
1030static int my_dvb_dmxdev_ts_card_init(struct dmxdev *dmxdev,
1031 struct dvb_demux *dvbdemux,
1032 struct dmx_frontend *hw_frontend,
1033 struct dmx_frontend *mem_frontend,
1034 struct dvb_adapter *dvb_adapter)
1035{
1036 int ret;
1037
1038 dmxdev->filternum = 256;
1039 dmxdev->demux = &dvbdemux->dmx;
1040 dmxdev->capabilities = 0;
1041 ret = dvb_dmxdev_init(dmxdev, dvb_adapter);
1042 if (ret < 0)
1043 return ret;
1044
1045 hw_frontend->source = DMX_FRONTEND_0;
1046 dvbdemux->dmx.add_frontend(&dvbdemux->dmx, hw_frontend);
1047 mem_frontend->source = DMX_MEMORY_FE;
1048 dvbdemux->dmx.add_frontend(&dvbdemux->dmx, mem_frontend);
1049 return dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, hw_frontend);
1050}
1051
1052 780
1053/****************************************************************************/ 781/****************************************************************************/
1054/* nGene hardware init and release functions ********************************/ 782/* nGene hardware init and release functions ********************************/
@@ -1094,8 +822,8 @@ static void free_idlebuffer(struct ngene *dev,
1094 return; 822 return;
1095 free_ringbuffer(dev, rb); 823 free_ringbuffer(dev, rb);
1096 for (j = 0; j < tb->NumBuffers; j++, Cur = Cur->Next) { 824 for (j = 0; j < tb->NumBuffers; j++, Cur = Cur->Next) {
1097 Cur->Buffer2 = 0; 825 Cur->Buffer2 = NULL;
1098 Cur->scList2 = 0; 826 Cur->scList2 = NULL;
1099 Cur->ngeneBuffer.Address_of_first_entry_2 = 0; 827 Cur->ngeneBuffer.Address_of_first_entry_2 = 0;
1100 Cur->ngeneBuffer.Number_of_entries_2 = 0; 828 Cur->ngeneBuffer.Number_of_entries_2 = 0;
1101 } 829 }
@@ -1141,7 +869,7 @@ static int create_ring_buffer(struct pci_dev *pci_dev,
1141 u64 PARingBufferNext; 869 u64 PARingBufferNext;
1142 struct SBufferHeader *Cur, *Next; 870 struct SBufferHeader *Cur, *Next;
1143 871
1144 descr->Head = 0; 872 descr->Head = NULL;
1145 descr->MemSize = 0; 873 descr->MemSize = 0;
1146 descr->PAHead = 0; 874 descr->PAHead = 0;
1147 descr->NumBuffers = 0; 875 descr->NumBuffers = 0;
@@ -1518,14 +1246,17 @@ static int ngene_load_firm(struct ngene *dev)
1518 version = 15; 1246 version = 15;
1519 size = 23466; 1247 size = 23466;
1520 fw_name = "ngene_15.fw"; 1248 fw_name = "ngene_15.fw";
1249 dev->cmd_timeout_workaround = true;
1521 break; 1250 break;
1522 case 16: 1251 case 16:
1523 size = 23498; 1252 size = 23498;
1524 fw_name = "ngene_16.fw"; 1253 fw_name = "ngene_16.fw";
1254 dev->cmd_timeout_workaround = true;
1525 break; 1255 break;
1526 case 17: 1256 case 17:
1527 size = 24446; 1257 size = 24446;
1528 fw_name = "ngene_17.fw"; 1258 fw_name = "ngene_17.fw";
1259 dev->cmd_timeout_workaround = true;
1529 break; 1260 break;
1530 } 1261 }
1531 1262
@@ -1565,11 +1296,16 @@ static void ngene_stop(struct ngene *dev)
1565 ngwritel(0, NGENE_EVENT); 1296 ngwritel(0, NGENE_EVENT);
1566 ngwritel(0, NGENE_EVENT_HI); 1297 ngwritel(0, NGENE_EVENT_HI);
1567 free_irq(dev->pci_dev->irq, dev); 1298 free_irq(dev->pci_dev->irq, dev);
1299#ifdef CONFIG_PCI_MSI
1300 if (dev->msi_enabled)
1301 pci_disable_msi(dev->pci_dev);
1302#endif
1568} 1303}
1569 1304
1570static int ngene_start(struct ngene *dev) 1305static int ngene_start(struct ngene *dev)
1571{ 1306{
1572 int stat; 1307 int stat;
1308 unsigned long flags;
1573 int i; 1309 int i;
1574 1310
1575 pci_set_master(dev->pci_dev); 1311 pci_set_master(dev->pci_dev);
@@ -1599,6 +1335,28 @@ static int ngene_start(struct ngene *dev)
1599 if (stat < 0) 1335 if (stat < 0)
1600 goto fail; 1336 goto fail;
1601 1337
1338#ifdef CONFIG_PCI_MSI
1339 /* enable MSI if kernel and card support it */
1340 if (pci_msi_enabled() && dev->card_info->msi_supported) {
1341 ngwritel(0, NGENE_INT_ENABLE);
1342 free_irq(dev->pci_dev->irq, dev);
1343 stat = pci_enable_msi(dev->pci_dev);
1344 if (stat) {
1345 printk(KERN_INFO DEVICE_NAME
1346 ": MSI not available\n");
1347 flags = IRQF_SHARED;
1348 } else {
1349 flags = 0;
1350 dev->msi_enabled = true;
1351 }
1352 stat = request_irq(dev->pci_dev->irq, irq_handler,
1353 flags, "nGene", dev);
1354 if (stat < 0)
1355 goto fail2;
1356 ngwritel(1, NGENE_INT_ENABLE);
1357 }
1358#endif
1359
1602 stat = ngene_i2c_init(dev, 0); 1360 stat = ngene_i2c_init(dev, 0);
1603 if (stat < 0) 1361 if (stat < 0)
1604 goto fail; 1362 goto fail;
@@ -1624,78 +1382,23 @@ static int ngene_start(struct ngene *dev)
1624 bconf = BUFFER_CONFIG_3333; 1382 bconf = BUFFER_CONFIG_3333;
1625 stat = ngene_command_config_buf(dev, bconf); 1383 stat = ngene_command_config_buf(dev, bconf);
1626 } 1384 }
1627 return stat; 1385 if (!stat)
1386 return stat;
1387
1388 /* otherwise error: fall through */
1628fail: 1389fail:
1629 ngwritel(0, NGENE_INT_ENABLE); 1390 ngwritel(0, NGENE_INT_ENABLE);
1630 free_irq(dev->pci_dev->irq, dev); 1391 free_irq(dev->pci_dev->irq, dev);
1392#ifdef CONFIG_PCI_MSI
1393fail2:
1394 if (dev->msi_enabled)
1395 pci_disable_msi(dev->pci_dev);
1396#endif
1631 return stat; 1397 return stat;
1632} 1398}
1633 1399
1634 1400
1635 1401
1636/****************************************************************************/
1637/* Switch control (I2C gates, etc.) *****************************************/
1638/****************************************************************************/
1639
1640
1641/****************************************************************************/
1642/* Demod/tuner attachment ***************************************************/
1643/****************************************************************************/
1644
1645static int tuner_attach_stv6110(struct ngene_channel *chan)
1646{
1647 struct stv090x_config *feconf = (struct stv090x_config *)
1648 chan->dev->card_info->fe_config[chan->number];
1649 struct stv6110x_config *tunerconf = (struct stv6110x_config *)
1650 chan->dev->card_info->tuner_config[chan->number];
1651 struct stv6110x_devctl *ctl;
1652
1653 ctl = dvb_attach(stv6110x_attach, chan->fe, tunerconf,
1654 &chan->i2c_adapter);
1655 if (ctl == NULL) {
1656 printk(KERN_ERR DEVICE_NAME ": No STV6110X found!\n");
1657 return -ENODEV;
1658 }
1659
1660 feconf->tuner_init = ctl->tuner_init;
1661 feconf->tuner_set_mode = ctl->tuner_set_mode;
1662 feconf->tuner_set_frequency = ctl->tuner_set_frequency;
1663 feconf->tuner_get_frequency = ctl->tuner_get_frequency;
1664 feconf->tuner_set_bandwidth = ctl->tuner_set_bandwidth;
1665 feconf->tuner_get_bandwidth = ctl->tuner_get_bandwidth;
1666 feconf->tuner_set_bbgain = ctl->tuner_set_bbgain;
1667 feconf->tuner_get_bbgain = ctl->tuner_get_bbgain;
1668 feconf->tuner_set_refclk = ctl->tuner_set_refclk;
1669 feconf->tuner_get_status = ctl->tuner_get_status;
1670
1671 return 0;
1672}
1673
1674
1675static int demod_attach_stv0900(struct ngene_channel *chan)
1676{
1677 struct stv090x_config *feconf = (struct stv090x_config *)
1678 chan->dev->card_info->fe_config[chan->number];
1679
1680 chan->fe = dvb_attach(stv090x_attach,
1681 feconf,
1682 &chan->i2c_adapter,
1683 chan->number == 0 ? STV090x_DEMODULATOR_0 :
1684 STV090x_DEMODULATOR_1);
1685 if (chan->fe == NULL) {
1686 printk(KERN_ERR DEVICE_NAME ": No STV0900 found!\n");
1687 return -ENODEV;
1688 }
1689
1690 if (!dvb_attach(lnbh24_attach, chan->fe, &chan->i2c_adapter, 0,
1691 0, chan->dev->card_info->lnb[chan->number])) {
1692 printk(KERN_ERR DEVICE_NAME ": No LNBH24 found!\n");
1693 dvb_frontend_detach(chan->fe);
1694 return -ENODEV;
1695 }
1696
1697 return 0;
1698}
1699 1402
1700/****************************************************************************/ 1403/****************************************************************************/
1701/****************************************************************************/ 1404/****************************************************************************/
@@ -1708,10 +1411,8 @@ static void release_channel(struct ngene_channel *chan)
1708 struct ngene_info *ni = dev->card_info; 1411 struct ngene_info *ni = dev->card_info;
1709 int io = ni->io_type[chan->number]; 1412 int io = ni->io_type[chan->number];
1710 1413
1711#ifdef COMMAND_TIMEOUT_WORKAROUND 1414 if (chan->dev->cmd_timeout_workaround && chan->running)
1712 if (chan->running)
1713 set_transfer(chan, 0); 1415 set_transfer(chan, 0);
1714#endif
1715 1416
1716 tasklet_kill(&chan->demux_tasklet); 1417 tasklet_kill(&chan->demux_tasklet);
1717 1418
@@ -1719,7 +1420,7 @@ static void release_channel(struct ngene_channel *chan)
1719 if (chan->fe) { 1420 if (chan->fe) {
1720 dvb_unregister_frontend(chan->fe); 1421 dvb_unregister_frontend(chan->fe);
1721 dvb_frontend_detach(chan->fe); 1422 dvb_frontend_detach(chan->fe);
1722 chan->fe = 0; 1423 chan->fe = NULL;
1723 } 1424 }
1724 dvbdemux->dmx.close(&dvbdemux->dmx); 1425 dvbdemux->dmx.close(&dvbdemux->dmx);
1725 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, 1426 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx,
@@ -1751,7 +1452,7 @@ static int init_channel(struct ngene_channel *chan)
1751 if (io & (NGENE_IO_TSIN | NGENE_IO_TSOUT)) { 1452 if (io & (NGENE_IO_TSIN | NGENE_IO_TSOUT)) {
1752 if (nr >= STREAM_AUDIOIN1) 1453 if (nr >= STREAM_AUDIOIN1)
1753 chan->DataFormatFlags = DF_SWAP32; 1454 chan->DataFormatFlags = DF_SWAP32;
1754 if (nr == 0 || !one_adapter) { 1455 if (nr == 0 || !one_adapter || dev->first_adapter == NULL) {
1755 adapter = &dev->adapter[nr]; 1456 adapter = &dev->adapter[nr];
1756 ret = dvb_register_adapter(adapter, "nGene", 1457 ret = dvb_register_adapter(adapter, "nGene",
1757 THIS_MODULE, 1458 THIS_MODULE,
@@ -1759,8 +1460,10 @@ static int init_channel(struct ngene_channel *chan)
1759 adapter_nr); 1460 adapter_nr);
1760 if (ret < 0) 1461 if (ret < 0)
1761 return ret; 1462 return ret;
1463 if (dev->first_adapter == NULL)
1464 dev->first_adapter = adapter;
1762 } else { 1465 } else {
1763 adapter = &dev->adapter[0]; 1466 adapter = dev->first_adapter;
1764 } 1467 }
1765 1468
1766 ret = my_dvb_dmx_ts_card_init(dvbdemux, "SW demux", 1469 ret = my_dvb_dmx_ts_card_init(dvbdemux, "SW demux",
@@ -1797,6 +1500,7 @@ static int init_channels(struct ngene *dev)
1797 int i, j; 1500 int i, j;
1798 1501
1799 for (i = 0; i < MAX_STREAM; i++) { 1502 for (i = 0; i < MAX_STREAM; i++) {
1503 dev->channel[i].number = i;
1800 if (init_channel(&dev->channel[i]) < 0) { 1504 if (init_channel(&dev->channel[i]) < 0) {
1801 for (j = i - 1; j >= 0; j--) 1505 for (j = i - 1; j >= 0; j--)
1802 release_channel(&dev->channel[j]); 1506 release_channel(&dev->channel[j]);
@@ -1810,7 +1514,7 @@ static int init_channels(struct ngene *dev)
1810/* device probe/remove calls ************************************************/ 1514/* device probe/remove calls ************************************************/
1811/****************************************************************************/ 1515/****************************************************************************/
1812 1516
1813static void __devexit ngene_remove(struct pci_dev *pdev) 1517void __devexit ngene_remove(struct pci_dev *pdev)
1814{ 1518{
1815 struct ngene *dev = (struct ngene *)pci_get_drvdata(pdev); 1519 struct ngene *dev = (struct ngene *)pci_get_drvdata(pdev);
1816 int i; 1520 int i;
@@ -1820,12 +1524,12 @@ static void __devexit ngene_remove(struct pci_dev *pdev)
1820 release_channel(&dev->channel[i]); 1524 release_channel(&dev->channel[i]);
1821 ngene_stop(dev); 1525 ngene_stop(dev);
1822 ngene_release_buffers(dev); 1526 ngene_release_buffers(dev);
1823 pci_set_drvdata(pdev, 0); 1527 pci_set_drvdata(pdev, NULL);
1824 pci_disable_device(pdev); 1528 pci_disable_device(pdev);
1825} 1529}
1826 1530
1827static int __devinit ngene_probe(struct pci_dev *pci_dev, 1531int __devinit ngene_probe(struct pci_dev *pci_dev,
1828 const struct pci_device_id *id) 1532 const struct pci_device_id *id)
1829{ 1533{
1830 struct ngene *dev; 1534 struct ngene *dev;
1831 int stat = 0; 1535 int stat = 0;
@@ -1868,156 +1572,6 @@ fail1:
1868 ngene_release_buffers(dev); 1572 ngene_release_buffers(dev);
1869fail0: 1573fail0:
1870 pci_disable_device(pci_dev); 1574 pci_disable_device(pci_dev);
1871 pci_set_drvdata(pci_dev, 0); 1575 pci_set_drvdata(pci_dev, NULL);
1872 return stat; 1576 return stat;
1873} 1577}
1874
1875/****************************************************************************/
1876/* Card configs *************************************************************/
1877/****************************************************************************/
1878
1879static struct stv090x_config fe_cineS2 = {
1880 .device = STV0900,
1881 .demod_mode = STV090x_DUAL,
1882 .clk_mode = STV090x_CLK_EXT,
1883
1884 .xtal = 27000000,
1885 .address = 0x68,
1886
1887 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
1888 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
1889
1890 .repeater_level = STV090x_RPTLEVEL_16,
1891
1892 .adc1_range = STV090x_ADC_1Vpp,
1893 .adc2_range = STV090x_ADC_1Vpp,
1894
1895 .diseqc_envelope_mode = true,
1896};
1897
1898static struct stv6110x_config tuner_cineS2_0 = {
1899 .addr = 0x60,
1900 .refclk = 27000000,
1901 .clk_div = 1,
1902};
1903
1904static struct stv6110x_config tuner_cineS2_1 = {
1905 .addr = 0x63,
1906 .refclk = 27000000,
1907 .clk_div = 1,
1908};
1909
1910static struct ngene_info ngene_info_cineS2 = {
1911 .type = NGENE_SIDEWINDER,
1912 .name = "Linux4Media cineS2 DVB-S2 Twin Tuner",
1913 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
1914 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
1915 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
1916 .fe_config = {&fe_cineS2, &fe_cineS2},
1917 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
1918 .lnb = {0x0b, 0x08},
1919 .tsf = {3, 3},
1920 .fw_version = 15,
1921};
1922
1923static struct ngene_info ngene_info_satixs2 = {
1924 .type = NGENE_SIDEWINDER,
1925 .name = "Mystique SaTiX-S2 Dual",
1926 .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN},
1927 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
1928 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
1929 .fe_config = {&fe_cineS2, &fe_cineS2},
1930 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
1931 .lnb = {0x0b, 0x08},
1932 .tsf = {3, 3},
1933 .fw_version = 15,
1934};
1935
1936/****************************************************************************/
1937
1938
1939
1940/****************************************************************************/
1941/* PCI Subsystem ID *********************************************************/
1942/****************************************************************************/
1943
1944#define NGENE_ID(_subvend, _subdev, _driverdata) { \
1945 .vendor = NGENE_VID, .device = NGENE_PID, \
1946 .subvendor = _subvend, .subdevice = _subdev, \
1947 .driver_data = (unsigned long) &_driverdata }
1948
1949/****************************************************************************/
1950
1951static const struct pci_device_id ngene_id_tbl[] __devinitdata = {
1952 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2),
1953 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2),
1954 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixs2),
1955 {0}
1956};
1957MODULE_DEVICE_TABLE(pci, ngene_id_tbl);
1958
1959/****************************************************************************/
1960/* Init/Exit ****************************************************************/
1961/****************************************************************************/
1962
1963static pci_ers_result_t ngene_error_detected(struct pci_dev *dev,
1964 enum pci_channel_state state)
1965{
1966 printk(KERN_ERR DEVICE_NAME ": PCI error\n");
1967 if (state == pci_channel_io_perm_failure)
1968 return PCI_ERS_RESULT_DISCONNECT;
1969 if (state == pci_channel_io_frozen)
1970 return PCI_ERS_RESULT_NEED_RESET;
1971 return PCI_ERS_RESULT_CAN_RECOVER;
1972}
1973
1974static pci_ers_result_t ngene_link_reset(struct pci_dev *dev)
1975{
1976 printk(KERN_INFO DEVICE_NAME ": link reset\n");
1977 return 0;
1978}
1979
1980static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev)
1981{
1982 printk(KERN_INFO DEVICE_NAME ": slot reset\n");
1983 return 0;
1984}
1985
1986static void ngene_resume(struct pci_dev *dev)
1987{
1988 printk(KERN_INFO DEVICE_NAME ": resume\n");
1989}
1990
1991static struct pci_error_handlers ngene_errors = {
1992 .error_detected = ngene_error_detected,
1993 .link_reset = ngene_link_reset,
1994 .slot_reset = ngene_slot_reset,
1995 .resume = ngene_resume,
1996};
1997
1998static struct pci_driver ngene_pci_driver = {
1999 .name = "ngene",
2000 .id_table = ngene_id_tbl,
2001 .probe = ngene_probe,
2002 .remove = __devexit_p(ngene_remove),
2003 .err_handler = &ngene_errors,
2004};
2005
2006static __init int module_init_ngene(void)
2007{
2008 printk(KERN_INFO
2009 "nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n");
2010 return pci_register_driver(&ngene_pci_driver);
2011}
2012
2013static __exit void module_exit_ngene(void)
2014{
2015 pci_unregister_driver(&ngene_pci_driver);
2016}
2017
2018module_init(module_init_ngene);
2019module_exit(module_exit_ngene);
2020
2021MODULE_DESCRIPTION("nGene");
2022MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel");
2023MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ngene/ngene-dvb.c b/drivers/media/dvb/ngene/ngene-dvb.c
new file mode 100644
index 000000000000..48f980b21d66
--- /dev/null
+++ b/drivers/media/dvb/ngene/ngene-dvb.c
@@ -0,0 +1,163 @@
1/*
2 * ngene-dvb.c: nGene PCIe bridge driver - DVB functions
3 *
4 * Copyright (C) 2005-2007 Micronas
5 *
6 * Copyright (C) 2008-2009 Ralph Metzler <rjkm@metzlerbros.de>
7 * Modifications for new nGene firmware,
8 * support for EEPROM-copying,
9 * support for new dual DVB-S2 card prototype
10 *
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * version 2 only, as published by the Free Software Foundation.
15 *
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * 02110-1301, USA
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 */
29
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/delay.h>
33#include <linux/slab.h>
34#include <linux/poll.h>
35#include <linux/io.h>
36#include <asm/div64.h>
37#include <linux/pci.h>
38#include <linux/smp_lock.h>
39#include <linux/timer.h>
40#include <linux/byteorder/generic.h>
41#include <linux/firmware.h>
42#include <linux/vmalloc.h>
43
44#include "ngene.h"
45
46
47/****************************************************************************/
48/* COMMAND API interface ****************************************************/
49/****************************************************************************/
50
51/****************************************************************************/
52/* DVB functions and API interface ******************************************/
53/****************************************************************************/
54
55static void swap_buffer(u32 *p, u32 len)
56{
57 while (len) {
58 *p = swab32(*p);
59 p++;
60 len -= 4;
61 }
62}
63
64void *tsin_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags)
65{
66 struct ngene_channel *chan = priv;
67
68
69 if (chan->users > 0)
70 dvb_dmx_swfilter(&chan->demux, buf, len);
71 return NULL;
72}
73
74u8 fill_ts[188] = { 0x47, 0x1f, 0xff, 0x10 };
75
76void *tsout_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags)
77{
78 struct ngene_channel *chan = priv;
79 struct ngene *dev = chan->dev;
80 u32 alen;
81
82 alen = dvb_ringbuffer_avail(&dev->tsout_rbuf);
83 alen -= alen % 188;
84
85 if (alen < len)
86 FillTSBuffer(buf + alen, len - alen, flags);
87 else
88 alen = len;
89 dvb_ringbuffer_read(&dev->tsout_rbuf, buf, alen);
90 if (flags & DF_SWAP32)
91 swap_buffer((u32 *)buf, alen);
92 wake_up_interruptible(&dev->tsout_rbuf.queue);
93 return buf;
94}
95
96
97
98int ngene_start_feed(struct dvb_demux_feed *dvbdmxfeed)
99{
100 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
101 struct ngene_channel *chan = dvbdmx->priv;
102
103 if (chan->users == 0) {
104 if (!chan->dev->cmd_timeout_workaround || !chan->running)
105 set_transfer(chan, 1);
106 }
107
108 return ++chan->users;
109}
110
111int ngene_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
112{
113 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
114 struct ngene_channel *chan = dvbdmx->priv;
115
116 if (--chan->users)
117 return chan->users;
118
119 if (!chan->dev->cmd_timeout_workaround)
120 set_transfer(chan, 0);
121
122 return 0;
123}
124
125int my_dvb_dmx_ts_card_init(struct dvb_demux *dvbdemux, char *id,
126 int (*start_feed)(struct dvb_demux_feed *),
127 int (*stop_feed)(struct dvb_demux_feed *),
128 void *priv)
129{
130 dvbdemux->priv = priv;
131
132 dvbdemux->filternum = 256;
133 dvbdemux->feednum = 256;
134 dvbdemux->start_feed = start_feed;
135 dvbdemux->stop_feed = stop_feed;
136 dvbdemux->write_to_decoder = NULL;
137 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING |
138 DMX_SECTION_FILTERING |
139 DMX_MEMORY_BASED_FILTERING);
140 return dvb_dmx_init(dvbdemux);
141}
142
143int my_dvb_dmxdev_ts_card_init(struct dmxdev *dmxdev,
144 struct dvb_demux *dvbdemux,
145 struct dmx_frontend *hw_frontend,
146 struct dmx_frontend *mem_frontend,
147 struct dvb_adapter *dvb_adapter)
148{
149 int ret;
150
151 dmxdev->filternum = 256;
152 dmxdev->demux = &dvbdemux->dmx;
153 dmxdev->capabilities = 0;
154 ret = dvb_dmxdev_init(dmxdev, dvb_adapter);
155 if (ret < 0)
156 return ret;
157
158 hw_frontend->source = DMX_FRONTEND_0;
159 dvbdemux->dmx.add_frontend(&dvbdemux->dmx, hw_frontend);
160 mem_frontend->source = DMX_MEMORY_FE;
161 dvbdemux->dmx.add_frontend(&dvbdemux->dmx, mem_frontend);
162 return dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, hw_frontend);
163}
diff --git a/drivers/media/dvb/ngene/ngene-i2c.c b/drivers/media/dvb/ngene/ngene-i2c.c
new file mode 100644
index 000000000000..477fe0aade86
--- /dev/null
+++ b/drivers/media/dvb/ngene/ngene-i2c.c
@@ -0,0 +1,178 @@
1/*
2 * ngene-i2c.c: nGene PCIe bridge driver i2c functions
3 *
4 * Copyright (C) 2005-2007 Micronas
5 *
6 * Copyright (C) 2008-2009 Ralph Metzler <rjkm@metzlerbros.de>
7 * Modifications for new nGene firmware,
8 * support for EEPROM-copying,
9 * support for new dual DVB-S2 card prototype
10 *
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * version 2 only, as published by the Free Software Foundation.
15 *
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * 02110-1301, USA
27 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 */
29
30/* FIXME - some of these can probably be removed */
31#include <linux/module.h>
32#include <linux/init.h>
33#include <linux/delay.h>
34#include <linux/slab.h>
35#include <linux/poll.h>
36#include <linux/io.h>
37#include <asm/div64.h>
38#include <linux/pci.h>
39#include <linux/pci_ids.h>
40#include <linux/smp_lock.h>
41#include <linux/timer.h>
42#include <linux/byteorder/generic.h>
43#include <linux/firmware.h>
44#include <linux/vmalloc.h>
45
46#include "ngene.h"
47
48/* Firmware command for i2c operations */
49static int ngene_command_i2c_read(struct ngene *dev, u8 adr,
50 u8 *out, u8 outlen, u8 *in, u8 inlen, int flag)
51{
52 struct ngene_command com;
53
54 com.cmd.hdr.Opcode = CMD_I2C_READ;
55 com.cmd.hdr.Length = outlen + 3;
56 com.cmd.I2CRead.Device = adr << 1;
57 memcpy(com.cmd.I2CRead.Data, out, outlen);
58 com.cmd.I2CRead.Data[outlen] = inlen;
59 com.cmd.I2CRead.Data[outlen + 1] = 0;
60 com.in_len = outlen + 3;
61 com.out_len = inlen + 1;
62
63 if (ngene_command(dev, &com) < 0)
64 return -EIO;
65
66 if ((com.cmd.raw8[0] >> 1) != adr)
67 return -EIO;
68
69 if (flag)
70 memcpy(in, com.cmd.raw8, inlen + 1);
71 else
72 memcpy(in, com.cmd.raw8 + 1, inlen);
73 return 0;
74}
75
76static int ngene_command_i2c_write(struct ngene *dev, u8 adr,
77 u8 *out, u8 outlen)
78{
79 struct ngene_command com;
80
81
82 com.cmd.hdr.Opcode = CMD_I2C_WRITE;
83 com.cmd.hdr.Length = outlen + 1;
84 com.cmd.I2CRead.Device = adr << 1;
85 memcpy(com.cmd.I2CRead.Data, out, outlen);
86 com.in_len = outlen + 1;
87 com.out_len = 1;
88
89 if (ngene_command(dev, &com) < 0)
90 return -EIO;
91
92 if (com.cmd.raw8[0] == 1)
93 return -EIO;
94
95 return 0;
96}
97
98static void ngene_i2c_set_bus(struct ngene *dev, int bus)
99{
100 if (!(dev->card_info->i2c_access & 2))
101 return;
102 if (dev->i2c_current_bus == bus)
103 return;
104
105 switch (bus) {
106 case 0:
107 ngene_command_gpio_set(dev, 3, 0);
108 ngene_command_gpio_set(dev, 2, 1);
109 break;
110
111 case 1:
112 ngene_command_gpio_set(dev, 2, 0);
113 ngene_command_gpio_set(dev, 3, 1);
114 break;
115 }
116 dev->i2c_current_bus = bus;
117}
118
119static int ngene_i2c_master_xfer(struct i2c_adapter *adapter,
120 struct i2c_msg msg[], int num)
121{
122 struct ngene_channel *chan =
123 (struct ngene_channel *)i2c_get_adapdata(adapter);
124 struct ngene *dev = chan->dev;
125
126 down(&dev->i2c_switch_mutex);
127 ngene_i2c_set_bus(dev, chan->number);
128
129 if (num == 2 && msg[1].flags & I2C_M_RD && !(msg[0].flags & I2C_M_RD))
130 if (!ngene_command_i2c_read(dev, msg[0].addr,
131 msg[0].buf, msg[0].len,
132 msg[1].buf, msg[1].len, 0))
133 goto done;
134
135 if (num == 1 && !(msg[0].flags & I2C_M_RD))
136 if (!ngene_command_i2c_write(dev, msg[0].addr,
137 msg[0].buf, msg[0].len))
138 goto done;
139 if (num == 1 && (msg[0].flags & I2C_M_RD))
140 if (!ngene_command_i2c_read(dev, msg[0].addr, NULL, 0,
141 msg[0].buf, msg[0].len, 0))
142 goto done;
143
144 up(&dev->i2c_switch_mutex);
145 return -EIO;
146
147done:
148 up(&dev->i2c_switch_mutex);
149 return num;
150}
151
152
153static u32 ngene_i2c_functionality(struct i2c_adapter *adap)
154{
155 return I2C_FUNC_SMBUS_EMUL;
156}
157
158static struct i2c_algorithm ngene_i2c_algo = {
159 .master_xfer = ngene_i2c_master_xfer,
160 .functionality = ngene_i2c_functionality,
161};
162
163int ngene_i2c_init(struct ngene *dev, int dev_nr)
164{
165 struct i2c_adapter *adap = &(dev->channel[dev_nr].i2c_adapter);
166
167 i2c_set_adapdata(adap, &(dev->channel[dev_nr]));
168 adap->class = I2C_CLASS_TV_DIGITAL | I2C_CLASS_TV_ANALOG;
169
170 strcpy(adap->name, "nGene");
171
172 adap->algo = &ngene_i2c_algo;
173 adap->algo_data = (void *)&(dev->channel[dev_nr]);
174 adap->dev.parent = &dev->pci_dev->dev;
175
176 return i2c_add_adapter(adap);
177}
178
diff --git a/drivers/media/dvb/ngene/ngene.h b/drivers/media/dvb/ngene/ngene.h
index a7eb29846310..8fb4200f83f8 100644
--- a/drivers/media/dvb/ngene/ngene.h
+++ b/drivers/media/dvb/ngene/ngene.h
@@ -39,6 +39,8 @@
39#include "dvb_frontend.h" 39#include "dvb_frontend.h"
40#include "dvb_ringbuffer.h" 40#include "dvb_ringbuffer.h"
41 41
42#define DEVICE_NAME "ngene"
43
42#define NGENE_VID 0x18c3 44#define NGENE_VID 0x18c3
43#define NGENE_PID 0x0720 45#define NGENE_PID 0x0720
44 46
@@ -723,6 +725,8 @@ struct ngene {
723 u32 device_version; 725 u32 device_version;
724 u32 fw_interface_version; 726 u32 fw_interface_version;
725 u32 icounts; 727 u32 icounts;
728 bool msi_enabled;
729 bool cmd_timeout_workaround;
726 730
727 u8 *CmdDoneByte; 731 u8 *CmdDoneByte;
728 int BootFirmware; 732 int BootFirmware;
@@ -752,6 +756,7 @@ struct ngene {
752 spinlock_t cmd_lock; 756 spinlock_t cmd_lock;
753 757
754 struct dvb_adapter adapter[MAX_STREAM]; 758 struct dvb_adapter adapter[MAX_STREAM];
759 struct dvb_adapter *first_adapter; /* "one_adapter" modprobe opt */
755 struct ngene_channel channel[MAX_STREAM]; 760 struct ngene_channel channel[MAX_STREAM];
756 761
757 struct ngene_info *card_info; 762 struct ngene_info *card_info;
@@ -794,6 +799,7 @@ struct ngene_info {
794#define NGENE_VBOX_V2 7 799#define NGENE_VBOX_V2 7
795 800
796 int fw_version; 801 int fw_version;
802 bool msi_supported;
797 char *name; 803 char *name;
798 804
799 int io_type[MAX_STREAM]; 805 int io_type[MAX_STREAM];
@@ -853,6 +859,33 @@ struct ngene_buffer {
853#endif 859#endif
854 860
855 861
862/* Provided by ngene-core.c */
863int __devinit ngene_probe(struct pci_dev *pci_dev,
864 const struct pci_device_id *id);
865void __devexit ngene_remove(struct pci_dev *pdev);
866int ngene_command(struct ngene *dev, struct ngene_command *com);
867int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level);
868void set_transfer(struct ngene_channel *chan, int state);
869void FillTSBuffer(void *Buffer, int Length, u32 Flags);
870
871/* Provided by ngene-i2c.c */
872int ngene_i2c_init(struct ngene *dev, int dev_nr);
873
874/* Provided by ngene-dvb.c */
875void *tsout_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags);
876void *tsin_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags);
877int ngene_start_feed(struct dvb_demux_feed *dvbdmxfeed);
878int ngene_stop_feed(struct dvb_demux_feed *dvbdmxfeed);
879int my_dvb_dmx_ts_card_init(struct dvb_demux *dvbdemux, char *id,
880 int (*start_feed)(struct dvb_demux_feed *),
881 int (*stop_feed)(struct dvb_demux_feed *),
882 void *priv);
883int my_dvb_dmxdev_ts_card_init(struct dmxdev *dmxdev,
884 struct dvb_demux *dvbdemux,
885 struct dmx_frontend *hw_frontend,
886 struct dmx_frontend *mem_frontend,
887 struct dvb_adapter *dvb_adapter);
888
856#endif 889#endif
857 890
858/* LocalWords: Endif 891/* LocalWords: Endif
diff --git a/drivers/media/dvb/pt1/pt1.c b/drivers/media/dvb/pt1/pt1.c
index 6aded234aa61..69ad94934ec2 100644
--- a/drivers/media/dvb/pt1/pt1.c
+++ b/drivers/media/dvb/pt1/pt1.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * driver for Earthsoft PT1 2 * driver for Earthsoft PT1/PT2
3 * 3 *
4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info> 4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info>
5 * 5 *
@@ -77,6 +77,10 @@ struct pt1 {
77 struct pt1_adapter *adaps[PT1_NR_ADAPS]; 77 struct pt1_adapter *adaps[PT1_NR_ADAPS];
78 struct pt1_table *tables; 78 struct pt1_table *tables;
79 struct task_struct *kthread; 79 struct task_struct *kthread;
80
81 struct mutex lock;
82 int power;
83 int reset;
80}; 84};
81 85
82struct pt1_adapter { 86struct pt1_adapter {
@@ -95,6 +99,11 @@ struct pt1_adapter {
95 struct dvb_frontend *fe; 99 struct dvb_frontend *fe;
96 int (*orig_set_voltage)(struct dvb_frontend *fe, 100 int (*orig_set_voltage)(struct dvb_frontend *fe,
97 fe_sec_voltage_t voltage); 101 fe_sec_voltage_t voltage);
102 int (*orig_sleep)(struct dvb_frontend *fe);
103 int (*orig_init)(struct dvb_frontend *fe);
104
105 fe_sec_voltage_t voltage;
106 int sleep;
98}; 107};
99 108
100#define pt1_printk(level, pt1, format, arg...) \ 109#define pt1_printk(level, pt1, format, arg...) \
@@ -219,8 +228,10 @@ static int pt1_do_enable_ram(struct pt1 *pt1)
219static int pt1_enable_ram(struct pt1 *pt1) 228static int pt1_enable_ram(struct pt1 *pt1)
220{ 229{
221 int i, ret; 230 int i, ret;
231 int phase;
222 schedule_timeout_uninterruptible((HZ + 999) / 1000); 232 schedule_timeout_uninterruptible((HZ + 999) / 1000);
223 for (i = 0; i < 10; i++) { 233 phase = pt1->pdev->device == 0x211a ? 128 : 166;
234 for (i = 0; i < phase; i++) {
224 ret = pt1_do_enable_ram(pt1); 235 ret = pt1_do_enable_ram(pt1);
225 if (ret < 0) 236 if (ret < 0)
226 return ret; 237 return ret;
@@ -485,33 +496,47 @@ static int pt1_stop_feed(struct dvb_demux_feed *feed)
485} 496}
486 497
487static void 498static void
488pt1_set_power(struct pt1 *pt1, int power, int lnb, int reset) 499pt1_update_power(struct pt1 *pt1)
489{ 500{
490 pt1_write_reg(pt1, 1, power | lnb << 1 | !reset << 3); 501 int bits;
502 int i;
503 struct pt1_adapter *adap;
504 static const int sleep_bits[] = {
505 1 << 4,
506 1 << 6 | 1 << 7,
507 1 << 5,
508 1 << 6 | 1 << 8,
509 };
510
511 bits = pt1->power | !pt1->reset << 3;
512 mutex_lock(&pt1->lock);
513 for (i = 0; i < PT1_NR_ADAPS; i++) {
514 adap = pt1->adaps[i];
515 switch (adap->voltage) {
516 case SEC_VOLTAGE_13: /* actually 11V */
517 bits |= 1 << 1;
518 break;
519 case SEC_VOLTAGE_18: /* actually 15V */
520 bits |= 1 << 1 | 1 << 2;
521 break;
522 default:
523 break;
524 }
525
526 /* XXX: The bits should be changed depending on adap->sleep. */
527 bits |= sleep_bits[i];
528 }
529 pt1_write_reg(pt1, 1, bits);
530 mutex_unlock(&pt1->lock);
491} 531}
492 532
493static int pt1_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 533static int pt1_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
494{ 534{
495 struct pt1_adapter *adap; 535 struct pt1_adapter *adap;
496 int lnb;
497 536
498 adap = container_of(fe->dvb, struct pt1_adapter, adap); 537 adap = container_of(fe->dvb, struct pt1_adapter, adap);
499 538 adap->voltage = voltage;
500 switch (voltage) { 539 pt1_update_power(adap->pt1);
501 case SEC_VOLTAGE_13: /* actually 11V */
502 lnb = 2;
503 break;
504 case SEC_VOLTAGE_18: /* actually 15V */
505 lnb = 3;
506 break;
507 case SEC_VOLTAGE_OFF:
508 lnb = 0;
509 break;
510 default:
511 return -EINVAL;
512 }
513
514 pt1_set_power(adap->pt1, 1, lnb, 0);
515 540
516 if (adap->orig_set_voltage) 541 if (adap->orig_set_voltage)
517 return adap->orig_set_voltage(fe, voltage); 542 return adap->orig_set_voltage(fe, voltage);
@@ -519,9 +544,37 @@ static int pt1_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
519 return 0; 544 return 0;
520} 545}
521 546
547static int pt1_sleep(struct dvb_frontend *fe)
548{
549 struct pt1_adapter *adap;
550
551 adap = container_of(fe->dvb, struct pt1_adapter, adap);
552 adap->sleep = 1;
553 pt1_update_power(adap->pt1);
554
555 if (adap->orig_sleep)
556 return adap->orig_sleep(fe);
557 else
558 return 0;
559}
560
561static int pt1_wakeup(struct dvb_frontend *fe)
562{
563 struct pt1_adapter *adap;
564
565 adap = container_of(fe->dvb, struct pt1_adapter, adap);
566 adap->sleep = 0;
567 pt1_update_power(adap->pt1);
568 schedule_timeout_uninterruptible((HZ + 999) / 1000);
569
570 if (adap->orig_init)
571 return adap->orig_init(fe);
572 else
573 return 0;
574}
575
522static void pt1_free_adapter(struct pt1_adapter *adap) 576static void pt1_free_adapter(struct pt1_adapter *adap)
523{ 577{
524 dvb_unregister_frontend(adap->fe);
525 dvb_net_release(&adap->net); 578 dvb_net_release(&adap->net);
526 adap->demux.dmx.close(&adap->demux.dmx); 579 adap->demux.dmx.close(&adap->demux.dmx);
527 dvb_dmxdev_release(&adap->dmxdev); 580 dvb_dmxdev_release(&adap->dmxdev);
@@ -534,7 +587,7 @@ static void pt1_free_adapter(struct pt1_adapter *adap)
534DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 587DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
535 588
536static struct pt1_adapter * 589static struct pt1_adapter *
537pt1_alloc_adapter(struct pt1 *pt1, struct dvb_frontend *fe) 590pt1_alloc_adapter(struct pt1 *pt1)
538{ 591{
539 struct pt1_adapter *adap; 592 struct pt1_adapter *adap;
540 void *buf; 593 void *buf;
@@ -551,8 +604,8 @@ pt1_alloc_adapter(struct pt1 *pt1, struct dvb_frontend *fe)
551 604
552 adap->pt1 = pt1; 605 adap->pt1 = pt1;
553 606
554 adap->orig_set_voltage = fe->ops.set_voltage; 607 adap->voltage = SEC_VOLTAGE_OFF;
555 fe->ops.set_voltage = pt1_set_voltage; 608 adap->sleep = 1;
556 609
557 buf = (u8 *)__get_free_page(GFP_KERNEL); 610 buf = (u8 *)__get_free_page(GFP_KERNEL);
558 if (!buf) { 611 if (!buf) {
@@ -593,17 +646,8 @@ pt1_alloc_adapter(struct pt1 *pt1, struct dvb_frontend *fe)
593 646
594 dvb_net_init(dvb_adap, &adap->net, &demux->dmx); 647 dvb_net_init(dvb_adap, &adap->net, &demux->dmx);
595 648
596 ret = dvb_register_frontend(dvb_adap, fe);
597 if (ret < 0)
598 goto err_net_release;
599 adap->fe = fe;
600
601 return adap; 649 return adap;
602 650
603err_net_release:
604 dvb_net_release(&adap->net);
605 adap->demux.dmx.close(&adap->demux.dmx);
606 dvb_dmxdev_release(&adap->dmxdev);
607err_dmx_release: 651err_dmx_release:
608 dvb_dmx_release(demux); 652 dvb_dmx_release(demux);
609err_unregister_adapter: 653err_unregister_adapter:
@@ -623,6 +667,62 @@ static void pt1_cleanup_adapters(struct pt1 *pt1)
623 pt1_free_adapter(pt1->adaps[i]); 667 pt1_free_adapter(pt1->adaps[i]);
624} 668}
625 669
670static int pt1_init_adapters(struct pt1 *pt1)
671{
672 int i;
673 struct pt1_adapter *adap;
674 int ret;
675
676 for (i = 0; i < PT1_NR_ADAPS; i++) {
677 adap = pt1_alloc_adapter(pt1);
678 if (IS_ERR(adap)) {
679 ret = PTR_ERR(adap);
680 goto err;
681 }
682
683 adap->index = i;
684 pt1->adaps[i] = adap;
685 }
686 return 0;
687
688err:
689 while (i--)
690 pt1_free_adapter(pt1->adaps[i]);
691
692 return ret;
693}
694
695static void pt1_cleanup_frontend(struct pt1_adapter *adap)
696{
697 dvb_unregister_frontend(adap->fe);
698}
699
700static int pt1_init_frontend(struct pt1_adapter *adap, struct dvb_frontend *fe)
701{
702 int ret;
703
704 adap->orig_set_voltage = fe->ops.set_voltage;
705 adap->orig_sleep = fe->ops.sleep;
706 adap->orig_init = fe->ops.init;
707 fe->ops.set_voltage = pt1_set_voltage;
708 fe->ops.sleep = pt1_sleep;
709 fe->ops.init = pt1_wakeup;
710
711 ret = dvb_register_frontend(&adap->adap, fe);
712 if (ret < 0)
713 return ret;
714
715 adap->fe = fe;
716 return 0;
717}
718
719static void pt1_cleanup_frontends(struct pt1 *pt1)
720{
721 int i;
722 for (i = 0; i < PT1_NR_ADAPS; i++)
723 pt1_cleanup_frontend(pt1->adaps[i]);
724}
725
626struct pt1_config { 726struct pt1_config {
627 struct va1j5jf8007s_config va1j5jf8007s_config; 727 struct va1j5jf8007s_config va1j5jf8007s_config;
628 struct va1j5jf8007t_config va1j5jf8007t_config; 728 struct va1j5jf8007t_config va1j5jf8007t_config;
@@ -630,29 +730,63 @@ struct pt1_config {
630 730
631static const struct pt1_config pt1_configs[2] = { 731static const struct pt1_config pt1_configs[2] = {
632 { 732 {
633 { .demod_address = 0x1b }, 733 {
634 { .demod_address = 0x1a }, 734 .demod_address = 0x1b,
735 .frequency = VA1J5JF8007S_20MHZ,
736 },
737 {
738 .demod_address = 0x1a,
739 .frequency = VA1J5JF8007T_20MHZ,
740 },
635 }, { 741 }, {
636 { .demod_address = 0x19 }, 742 {
637 { .demod_address = 0x18 }, 743 .demod_address = 0x19,
744 .frequency = VA1J5JF8007S_20MHZ,
745 },
746 {
747 .demod_address = 0x18,
748 .frequency = VA1J5JF8007T_20MHZ,
749 },
638 }, 750 },
639}; 751};
640 752
641static int pt1_init_adapters(struct pt1 *pt1) 753static const struct pt1_config pt2_configs[2] = {
754 {
755 {
756 .demod_address = 0x1b,
757 .frequency = VA1J5JF8007S_25MHZ,
758 },
759 {
760 .demod_address = 0x1a,
761 .frequency = VA1J5JF8007T_25MHZ,
762 },
763 }, {
764 {
765 .demod_address = 0x19,
766 .frequency = VA1J5JF8007S_25MHZ,
767 },
768 {
769 .demod_address = 0x18,
770 .frequency = VA1J5JF8007T_25MHZ,
771 },
772 },
773};
774
775static int pt1_init_frontends(struct pt1 *pt1)
642{ 776{
643 int i, j; 777 int i, j;
644 struct i2c_adapter *i2c_adap; 778 struct i2c_adapter *i2c_adap;
645 const struct pt1_config *config; 779 const struct pt1_config *configs, *config;
646 struct dvb_frontend *fe[4]; 780 struct dvb_frontend *fe[4];
647 struct pt1_adapter *adap;
648 int ret; 781 int ret;
649 782
650 i = 0; 783 i = 0;
651 j = 0; 784 j = 0;
652 785
653 i2c_adap = &pt1->i2c_adap; 786 i2c_adap = &pt1->i2c_adap;
787 configs = pt1->pdev->device == 0x211a ? pt1_configs : pt2_configs;
654 do { 788 do {
655 config = &pt1_configs[i / 2]; 789 config = &configs[i / 2];
656 790
657 fe[i] = va1j5jf8007s_attach(&config->va1j5jf8007s_config, 791 fe[i] = va1j5jf8007s_attach(&config->va1j5jf8007s_config,
658 i2c_adap); 792 i2c_adap);
@@ -681,11 +815,9 @@ static int pt1_init_adapters(struct pt1 *pt1)
681 } while (i < 4); 815 } while (i < 4);
682 816
683 do { 817 do {
684 adap = pt1_alloc_adapter(pt1, fe[j]); 818 ret = pt1_init_frontend(pt1->adaps[j], fe[j]);
685 if (IS_ERR(adap)) 819 if (ret < 0)
686 goto err; 820 goto err;
687 adap->index = j;
688 pt1->adaps[j] = adap;
689 } while (++j < 4); 821 } while (++j < 4);
690 822
691 return 0; 823 return 0;
@@ -695,7 +827,7 @@ err:
695 fe[i]->ops.release(fe[i]); 827 fe[i]->ops.release(fe[i]);
696 828
697 while (j--) 829 while (j--)
698 pt1_free_adapter(pt1->adaps[j]); 830 dvb_unregister_frontend(fe[j]);
699 831
700 return ret; 832 return ret;
701} 833}
@@ -890,9 +1022,12 @@ static void __devexit pt1_remove(struct pci_dev *pdev)
890 1022
891 kthread_stop(pt1->kthread); 1023 kthread_stop(pt1->kthread);
892 pt1_cleanup_tables(pt1); 1024 pt1_cleanup_tables(pt1);
893 pt1_cleanup_adapters(pt1); 1025 pt1_cleanup_frontends(pt1);
894 pt1_disable_ram(pt1); 1026 pt1_disable_ram(pt1);
895 pt1_set_power(pt1, 0, 0, 1); 1027 pt1->power = 0;
1028 pt1->reset = 1;
1029 pt1_update_power(pt1);
1030 pt1_cleanup_adapters(pt1);
896 i2c_del_adapter(&pt1->i2c_adap); 1031 i2c_del_adapter(&pt1->i2c_adap);
897 pci_set_drvdata(pdev, NULL); 1032 pci_set_drvdata(pdev, NULL);
898 kfree(pt1); 1033 kfree(pt1);
@@ -936,10 +1071,21 @@ pt1_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
936 goto err_pci_iounmap; 1071 goto err_pci_iounmap;
937 } 1072 }
938 1073
1074 mutex_init(&pt1->lock);
939 pt1->pdev = pdev; 1075 pt1->pdev = pdev;
940 pt1->regs = regs; 1076 pt1->regs = regs;
941 pci_set_drvdata(pdev, pt1); 1077 pci_set_drvdata(pdev, pt1);
942 1078
1079 ret = pt1_init_adapters(pt1);
1080 if (ret < 0)
1081 goto err_kfree;
1082
1083 mutex_init(&pt1->lock);
1084
1085 pt1->power = 0;
1086 pt1->reset = 1;
1087 pt1_update_power(pt1);
1088
943 i2c_adap = &pt1->i2c_adap; 1089 i2c_adap = &pt1->i2c_adap;
944 i2c_adap->class = I2C_CLASS_TV_DIGITAL; 1090 i2c_adap->class = I2C_CLASS_TV_DIGITAL;
945 i2c_adap->algo = &pt1_i2c_algo; 1091 i2c_adap->algo = &pt1_i2c_algo;
@@ -948,9 +1094,7 @@ pt1_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
948 i2c_set_adapdata(i2c_adap, pt1); 1094 i2c_set_adapdata(i2c_adap, pt1);
949 ret = i2c_add_adapter(i2c_adap); 1095 ret = i2c_add_adapter(i2c_adap);
950 if (ret < 0) 1096 if (ret < 0)
951 goto err_kfree; 1097 goto err_pt1_cleanup_adapters;
952
953 pt1_set_power(pt1, 0, 0, 1);
954 1098
955 pt1_i2c_init(pt1); 1099 pt1_i2c_init(pt1);
956 pt1_i2c_wait(pt1); 1100 pt1_i2c_wait(pt1);
@@ -979,19 +1123,21 @@ pt1_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
979 1123
980 pt1_init_streams(pt1); 1124 pt1_init_streams(pt1);
981 1125
982 pt1_set_power(pt1, 1, 0, 1); 1126 pt1->power = 1;
1127 pt1_update_power(pt1);
983 schedule_timeout_uninterruptible((HZ + 49) / 50); 1128 schedule_timeout_uninterruptible((HZ + 49) / 50);
984 1129
985 pt1_set_power(pt1, 1, 0, 0); 1130 pt1->reset = 0;
1131 pt1_update_power(pt1);
986 schedule_timeout_uninterruptible((HZ + 999) / 1000); 1132 schedule_timeout_uninterruptible((HZ + 999) / 1000);
987 1133
988 ret = pt1_init_adapters(pt1); 1134 ret = pt1_init_frontends(pt1);
989 if (ret < 0) 1135 if (ret < 0)
990 goto err_pt1_disable_ram; 1136 goto err_pt1_disable_ram;
991 1137
992 ret = pt1_init_tables(pt1); 1138 ret = pt1_init_tables(pt1);
993 if (ret < 0) 1139 if (ret < 0)
994 goto err_pt1_cleanup_adapters; 1140 goto err_pt1_cleanup_frontends;
995 1141
996 kthread = kthread_run(pt1_thread, pt1, "pt1"); 1142 kthread = kthread_run(pt1_thread, pt1, "pt1");
997 if (IS_ERR(kthread)) { 1143 if (IS_ERR(kthread)) {
@@ -1004,11 +1150,15 @@ pt1_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1004 1150
1005err_pt1_cleanup_tables: 1151err_pt1_cleanup_tables:
1006 pt1_cleanup_tables(pt1); 1152 pt1_cleanup_tables(pt1);
1007err_pt1_cleanup_adapters: 1153err_pt1_cleanup_frontends:
1008 pt1_cleanup_adapters(pt1); 1154 pt1_cleanup_frontends(pt1);
1009err_pt1_disable_ram: 1155err_pt1_disable_ram:
1010 pt1_disable_ram(pt1); 1156 pt1_disable_ram(pt1);
1011 pt1_set_power(pt1, 0, 0, 1); 1157 pt1->power = 0;
1158 pt1->reset = 1;
1159 pt1_update_power(pt1);
1160err_pt1_cleanup_adapters:
1161 pt1_cleanup_adapters(pt1);
1012err_i2c_del_adapter: 1162err_i2c_del_adapter:
1013 i2c_del_adapter(i2c_adap); 1163 i2c_del_adapter(i2c_adap);
1014err_kfree: 1164err_kfree:
@@ -1027,6 +1177,7 @@ err:
1027 1177
1028static struct pci_device_id pt1_id_table[] = { 1178static struct pci_device_id pt1_id_table[] = {
1029 { PCI_DEVICE(0x10ee, 0x211a) }, 1179 { PCI_DEVICE(0x10ee, 0x211a) },
1180 { PCI_DEVICE(0x10ee, 0x222a) },
1030 { }, 1181 { },
1031}; 1182};
1032MODULE_DEVICE_TABLE(pci, pt1_id_table); 1183MODULE_DEVICE_TABLE(pci, pt1_id_table);
@@ -1054,5 +1205,5 @@ module_init(pt1_init);
1054module_exit(pt1_cleanup); 1205module_exit(pt1_cleanup);
1055 1206
1056MODULE_AUTHOR("Takahito HIRANO <hiranotaka@zng.info>"); 1207MODULE_AUTHOR("Takahito HIRANO <hiranotaka@zng.info>");
1057MODULE_DESCRIPTION("Earthsoft PT1 Driver"); 1208MODULE_DESCRIPTION("Earthsoft PT1/PT2 Driver");
1058MODULE_LICENSE("GPL"); 1209MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/pt1/va1j5jf8007s.c b/drivers/media/dvb/pt1/va1j5jf8007s.c
index fc6594996e79..451641c0c1d2 100644
--- a/drivers/media/dvb/pt1/va1j5jf8007s.c
+++ b/drivers/media/dvb/pt1/va1j5jf8007s.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * ISDB-S driver for VA1J5JF8007 2 * ISDB-S driver for VA1J5JF8007/VA1J5JF8011
3 * 3 *
4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info> 4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info>
5 * 5 *
@@ -580,7 +580,7 @@ static void va1j5jf8007s_release(struct dvb_frontend *fe)
580 580
581static struct dvb_frontend_ops va1j5jf8007s_ops = { 581static struct dvb_frontend_ops va1j5jf8007s_ops = {
582 .info = { 582 .info = {
583 .name = "VA1J5JF8007 ISDB-S", 583 .name = "VA1J5JF8007/VA1J5JF8011 ISDB-S",
584 .type = FE_QPSK, 584 .type = FE_QPSK,
585 .frequency_min = 950000, 585 .frequency_min = 950000,
586 .frequency_max = 2150000, 586 .frequency_max = 2150000,
@@ -628,28 +628,50 @@ static int va1j5jf8007s_prepare_1(struct va1j5jf8007s_state *state)
628 return 0; 628 return 0;
629} 629}
630 630
631static const u8 va1j5jf8007s_prepare_bufs[][2] = { 631static const u8 va1j5jf8007s_20mhz_prepare_bufs[][2] = {
632 {0x04, 0x02}, {0x0d, 0x55}, {0x11, 0x40}, {0x13, 0x80}, {0x17, 0x01}, 632 {0x04, 0x02}, {0x0d, 0x55}, {0x11, 0x40}, {0x13, 0x80}, {0x17, 0x01},
633 {0x1c, 0x0a}, {0x1d, 0xaa}, {0x1e, 0x20}, {0x1f, 0x88}, {0x51, 0xb0}, 633 {0x1c, 0x0a}, {0x1d, 0xaa}, {0x1e, 0x20}, {0x1f, 0x88}, {0x51, 0xb0},
634 {0x52, 0x89}, {0x53, 0xb3}, {0x5a, 0x2d}, {0x5b, 0xd3}, {0x85, 0x69}, 634 {0x52, 0x89}, {0x53, 0xb3}, {0x5a, 0x2d}, {0x5b, 0xd3}, {0x85, 0x69},
635 {0x87, 0x04}, {0x8e, 0x02}, {0xa3, 0xf7}, {0xa5, 0xc0}, 635 {0x87, 0x04}, {0x8e, 0x02}, {0xa3, 0xf7}, {0xa5, 0xc0},
636}; 636};
637 637
638static const u8 va1j5jf8007s_25mhz_prepare_bufs[][2] = {
639 {0x04, 0x02}, {0x11, 0x40}, {0x13, 0x80}, {0x17, 0x01}, {0x1c, 0x0a},
640 {0x1d, 0xaa}, {0x1e, 0x20}, {0x1f, 0x88}, {0x51, 0xb0}, {0x52, 0x89},
641 {0x53, 0xb3}, {0x5a, 0x2d}, {0x5b, 0xd3}, {0x85, 0x69}, {0x87, 0x04},
642 {0x8e, 0x26}, {0xa3, 0xf7}, {0xa5, 0xc0},
643};
644
638static int va1j5jf8007s_prepare_2(struct va1j5jf8007s_state *state) 645static int va1j5jf8007s_prepare_2(struct va1j5jf8007s_state *state)
639{ 646{
647 const u8 (*bufs)[2];
648 int size;
640 u8 addr; 649 u8 addr;
641 u8 buf[2]; 650 u8 buf[2];
642 struct i2c_msg msg; 651 struct i2c_msg msg;
643 int i; 652 int i;
644 653
654 switch (state->config->frequency) {
655 case VA1J5JF8007S_20MHZ:
656 bufs = va1j5jf8007s_20mhz_prepare_bufs;
657 size = ARRAY_SIZE(va1j5jf8007s_20mhz_prepare_bufs);
658 break;
659 case VA1J5JF8007S_25MHZ:
660 bufs = va1j5jf8007s_25mhz_prepare_bufs;
661 size = ARRAY_SIZE(va1j5jf8007s_25mhz_prepare_bufs);
662 break;
663 default:
664 return -EINVAL;
665 }
666
645 addr = state->config->demod_address; 667 addr = state->config->demod_address;
646 668
647 msg.addr = addr; 669 msg.addr = addr;
648 msg.flags = 0; 670 msg.flags = 0;
649 msg.len = 2; 671 msg.len = 2;
650 msg.buf = buf; 672 msg.buf = buf;
651 for (i = 0; i < ARRAY_SIZE(va1j5jf8007s_prepare_bufs); i++) { 673 for (i = 0; i < size; i++) {
652 memcpy(buf, va1j5jf8007s_prepare_bufs[i], sizeof(buf)); 674 memcpy(buf, bufs[i], sizeof(buf));
653 if (i2c_transfer(state->adap, &msg, 1) != 1) 675 if (i2c_transfer(state->adap, &msg, 1) != 1)
654 return -EREMOTEIO; 676 return -EREMOTEIO;
655 } 677 }
diff --git a/drivers/media/dvb/pt1/va1j5jf8007s.h b/drivers/media/dvb/pt1/va1j5jf8007s.h
index aa228a816353..b7d6f05a0e02 100644
--- a/drivers/media/dvb/pt1/va1j5jf8007s.h
+++ b/drivers/media/dvb/pt1/va1j5jf8007s.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * ISDB-S driver for VA1J5JF8007 2 * ISDB-S driver for VA1J5JF8007/VA1J5JF8011
3 * 3 *
4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info> 4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info>
5 * 5 *
@@ -24,8 +24,14 @@
24#ifndef VA1J5JF8007S_H 24#ifndef VA1J5JF8007S_H
25#define VA1J5JF8007S_H 25#define VA1J5JF8007S_H
26 26
27enum va1j5jf8007s_frequency {
28 VA1J5JF8007S_20MHZ,
29 VA1J5JF8007S_25MHZ,
30};
31
27struct va1j5jf8007s_config { 32struct va1j5jf8007s_config {
28 u8 demod_address; 33 u8 demod_address;
34 enum va1j5jf8007s_frequency frequency;
29}; 35};
30 36
31struct i2c_adapter; 37struct i2c_adapter;
diff --git a/drivers/media/dvb/pt1/va1j5jf8007t.c b/drivers/media/dvb/pt1/va1j5jf8007t.c
index 3db4f3e34e8f..0f085c3e571b 100644
--- a/drivers/media/dvb/pt1/va1j5jf8007t.c
+++ b/drivers/media/dvb/pt1/va1j5jf8007t.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * ISDB-T driver for VA1J5JF8007 2 * ISDB-T driver for VA1J5JF8007/VA1J5JF8011
3 * 3 *
4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info> 4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info>
5 * 5 *
@@ -429,7 +429,7 @@ static void va1j5jf8007t_release(struct dvb_frontend *fe)
429 429
430static struct dvb_frontend_ops va1j5jf8007t_ops = { 430static struct dvb_frontend_ops va1j5jf8007t_ops = {
431 .info = { 431 .info = {
432 .name = "VA1J5JF8007 ISDB-T", 432 .name = "VA1J5JF8007/VA1J5JF8011 ISDB-T",
433 .type = FE_OFDM, 433 .type = FE_OFDM,
434 .frequency_min = 90000000, 434 .frequency_min = 90000000,
435 .frequency_max = 770000000, 435 .frequency_max = 770000000,
@@ -448,29 +448,50 @@ static struct dvb_frontend_ops va1j5jf8007t_ops = {
448 .release = va1j5jf8007t_release, 448 .release = va1j5jf8007t_release,
449}; 449};
450 450
451static const u8 va1j5jf8007t_prepare_bufs[][2] = { 451static const u8 va1j5jf8007t_20mhz_prepare_bufs[][2] = {
452 {0x03, 0x90}, {0x14, 0x8f}, {0x1c, 0x2a}, {0x1d, 0xa8}, {0x1e, 0xa2}, 452 {0x03, 0x90}, {0x14, 0x8f}, {0x1c, 0x2a}, {0x1d, 0xa8}, {0x1e, 0xa2},
453 {0x22, 0x83}, {0x31, 0x0d}, {0x32, 0xe0}, {0x39, 0xd3}, {0x3a, 0x00}, 453 {0x22, 0x83}, {0x31, 0x0d}, {0x32, 0xe0}, {0x39, 0xd3}, {0x3a, 0x00},
454 {0x5c, 0x40}, {0x5f, 0x80}, {0x75, 0x02}, {0x76, 0x4e}, {0x77, 0x03}, 454 {0x5c, 0x40}, {0x5f, 0x80}, {0x75, 0x02}, {0x76, 0x4e}, {0x77, 0x03},
455 {0xef, 0x01} 455 {0xef, 0x01}
456}; 456};
457 457
458static const u8 va1j5jf8007t_25mhz_prepare_bufs[][2] = {
459 {0x03, 0x90}, {0x1c, 0x2a}, {0x1d, 0xa8}, {0x1e, 0xa2}, {0x22, 0x83},
460 {0x3a, 0x00}, {0x5c, 0x40}, {0x5f, 0x80}, {0x75, 0x0a}, {0x76, 0x4c},
461 {0x77, 0x03}, {0xef, 0x01}
462};
463
458int va1j5jf8007t_prepare(struct dvb_frontend *fe) 464int va1j5jf8007t_prepare(struct dvb_frontend *fe)
459{ 465{
460 struct va1j5jf8007t_state *state; 466 struct va1j5jf8007t_state *state;
467 const u8 (*bufs)[2];
468 int size;
461 u8 buf[2]; 469 u8 buf[2];
462 struct i2c_msg msg; 470 struct i2c_msg msg;
463 int i; 471 int i;
464 472
465 state = fe->demodulator_priv; 473 state = fe->demodulator_priv;
466 474
475 switch (state->config->frequency) {
476 case VA1J5JF8007T_20MHZ:
477 bufs = va1j5jf8007t_20mhz_prepare_bufs;
478 size = ARRAY_SIZE(va1j5jf8007t_20mhz_prepare_bufs);
479 break;
480 case VA1J5JF8007T_25MHZ:
481 bufs = va1j5jf8007t_25mhz_prepare_bufs;
482 size = ARRAY_SIZE(va1j5jf8007t_25mhz_prepare_bufs);
483 break;
484 default:
485 return -EINVAL;
486 }
487
467 msg.addr = state->config->demod_address; 488 msg.addr = state->config->demod_address;
468 msg.flags = 0; 489 msg.flags = 0;
469 msg.len = sizeof(buf); 490 msg.len = sizeof(buf);
470 msg.buf = buf; 491 msg.buf = buf;
471 492
472 for (i = 0; i < ARRAY_SIZE(va1j5jf8007t_prepare_bufs); i++) { 493 for (i = 0; i < size; i++) {
473 memcpy(buf, va1j5jf8007t_prepare_bufs[i], sizeof(buf)); 494 memcpy(buf, bufs[i], sizeof(buf));
474 if (i2c_transfer(state->adap, &msg, 1) != 1) 495 if (i2c_transfer(state->adap, &msg, 1) != 1)
475 return -EREMOTEIO; 496 return -EREMOTEIO;
476 } 497 }
diff --git a/drivers/media/dvb/pt1/va1j5jf8007t.h b/drivers/media/dvb/pt1/va1j5jf8007t.h
index ed49906f7769..2903be519ef5 100644
--- a/drivers/media/dvb/pt1/va1j5jf8007t.h
+++ b/drivers/media/dvb/pt1/va1j5jf8007t.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * ISDB-T driver for VA1J5JF8007 2 * ISDB-T driver for VA1J5JF8007/VA1J5JF8011
3 * 3 *
4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info> 4 * Copyright (C) 2009 HIRANO Takahito <hiranotaka@zng.info>
5 * 5 *
@@ -24,8 +24,14 @@
24#ifndef VA1J5JF8007T_H 24#ifndef VA1J5JF8007T_H
25#define VA1J5JF8007T_H 25#define VA1J5JF8007T_H
26 26
27enum va1j5jf8007t_frequency {
28 VA1J5JF8007T_20MHZ,
29 VA1J5JF8007T_25MHZ,
30};
31
27struct va1j5jf8007t_config { 32struct va1j5jf8007t_config {
28 u8 demod_address; 33 u8 demod_address;
34 enum va1j5jf8007t_frequency frequency;
29}; 35};
30 36
31struct i2c_adapter; 37struct i2c_adapter;
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index d8d4214fd65f..32a7ec65ec42 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -68,13 +68,14 @@ config DVB_BUDGET
68 select DVB_VES1820 if !DVB_FE_CUSTOMISE 68 select DVB_VES1820 if !DVB_FE_CUSTOMISE
69 select DVB_L64781 if !DVB_FE_CUSTOMISE 69 select DVB_L64781 if !DVB_FE_CUSTOMISE
70 select DVB_TDA8083 if !DVB_FE_CUSTOMISE 70 select DVB_TDA8083 if !DVB_FE_CUSTOMISE
71 select DVB_TDA10021 if !DVB_FE_CUSTOMISE
72 select DVB_TDA10023 if !DVB_FE_CUSTOMISE
73 select DVB_S5H1420 if !DVB_FE_CUSTOMISE 71 select DVB_S5H1420 if !DVB_FE_CUSTOMISE
74 select DVB_TDA10086 if !DVB_FE_CUSTOMISE 72 select DVB_TDA10086 if !DVB_FE_CUSTOMISE
75 select DVB_TDA826X if !DVB_FE_CUSTOMISE 73 select DVB_TDA826X if !DVB_FE_CUSTOMISE
76 select DVB_LNBP21 if !DVB_FE_CUSTOMISE 74 select DVB_LNBP21 if !DVB_FE_CUSTOMISE
77 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 75 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
76 select DVB_ISL6423 if !DVB_FE_CUSTOMISE
77 select DVB_STV090x if !DVB_FE_CUSTOMISE
78 select DVB_STV6110x if !DVB_FE_CUSTOMISE
78 help 79 help
79 Support for simple SAA7146 based DVB cards (so called Budget- 80 Support for simple SAA7146 based DVB cards (so called Budget-
80 or Nova-PCI cards) without onboard MPEG2 decoder, and without 81 or Nova-PCI cards) without onboard MPEG2 decoder, and without
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 38915591c6e5..a6be529eec5c 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -708,7 +708,7 @@ static void gpioirq(unsigned long cookie)
708 708
709 709
710#ifdef CONFIG_DVB_AV7110_OSD 710#ifdef CONFIG_DVB_AV7110_OSD
711static int dvb_osd_ioctl(struct inode *inode, struct file *file, 711static int dvb_osd_ioctl(struct file *file,
712 unsigned int cmd, void *parg) 712 unsigned int cmd, void *parg)
713{ 713{
714 struct dvb_device *dvbdev = file->private_data; 714 struct dvb_device *dvbdev = file->private_data;
@@ -727,7 +727,7 @@ static int dvb_osd_ioctl(struct inode *inode, struct file *file,
727 727
728static const struct file_operations dvb_osd_fops = { 728static const struct file_operations dvb_osd_fops = {
729 .owner = THIS_MODULE, 729 .owner = THIS_MODULE,
730 .ioctl = dvb_generic_ioctl, 730 .unlocked_ioctl = dvb_generic_ioctl,
731 .open = dvb_generic_open, 731 .open = dvb_generic_open,
732 .release = dvb_generic_release, 732 .release = dvb_generic_release,
733}; 733};
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 53884814161c..13efba942dac 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1089,7 +1089,7 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len
1089} 1089}
1090 1090
1091 1091
1092static int dvb_video_ioctl(struct inode *inode, struct file *file, 1092static int dvb_video_ioctl(struct file *file,
1093 unsigned int cmd, void *parg) 1093 unsigned int cmd, void *parg)
1094{ 1094{
1095 struct dvb_device *dvbdev = file->private_data; 1095 struct dvb_device *dvbdev = file->private_data;
@@ -1297,7 +1297,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1297 return ret; 1297 return ret;
1298} 1298}
1299 1299
1300static int dvb_audio_ioctl(struct inode *inode, struct file *file, 1300static int dvb_audio_ioctl(struct file *file,
1301 unsigned int cmd, void *parg) 1301 unsigned int cmd, void *parg)
1302{ 1302{
1303 struct dvb_device *dvbdev = file->private_data; 1303 struct dvb_device *dvbdev = file->private_data;
@@ -1517,7 +1517,7 @@ static int dvb_audio_release(struct inode *inode, struct file *file)
1517static const struct file_operations dvb_video_fops = { 1517static const struct file_operations dvb_video_fops = {
1518 .owner = THIS_MODULE, 1518 .owner = THIS_MODULE,
1519 .write = dvb_video_write, 1519 .write = dvb_video_write,
1520 .ioctl = dvb_generic_ioctl, 1520 .unlocked_ioctl = dvb_generic_ioctl,
1521 .open = dvb_video_open, 1521 .open = dvb_video_open,
1522 .release = dvb_video_release, 1522 .release = dvb_video_release,
1523 .poll = dvb_video_poll, 1523 .poll = dvb_video_poll,
@@ -1535,7 +1535,7 @@ static struct dvb_device dvbdev_video = {
1535static const struct file_operations dvb_audio_fops = { 1535static const struct file_operations dvb_audio_fops = {
1536 .owner = THIS_MODULE, 1536 .owner = THIS_MODULE,
1537 .write = dvb_audio_write, 1537 .write = dvb_audio_write,
1538 .ioctl = dvb_generic_ioctl, 1538 .unlocked_ioctl = dvb_generic_ioctl,
1539 .open = dvb_audio_open, 1539 .open = dvb_audio_open,
1540 .release = dvb_audio_release, 1540 .release = dvb_audio_release,
1541 .poll = dvb_audio_poll, 1541 .poll = dvb_audio_poll,
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index ac7779c45c5b..4eba35a018e3 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -248,8 +248,7 @@ static unsigned int dvb_ca_poll (struct file *file, poll_table *wait)
248 return mask; 248 return mask;
249} 249}
250 250
251static int dvb_ca_ioctl(struct inode *inode, struct file *file, 251static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
252 unsigned int cmd, void *parg)
253{ 252{
254 struct dvb_device *dvbdev = file->private_data; 253 struct dvb_device *dvbdev = file->private_data;
255 struct av7110 *av7110 = dvbdev->priv; 254 struct av7110 *av7110 = dvbdev->priv;
@@ -350,7 +349,7 @@ static const struct file_operations dvb_ca_fops = {
350 .owner = THIS_MODULE, 349 .owner = THIS_MODULE,
351 .read = dvb_ca_read, 350 .read = dvb_ca_read,
352 .write = dvb_ca_write, 351 .write = dvb_ca_write,
353 .ioctl = dvb_generic_ioctl, 352 .unlocked_ioctl = dvb_generic_ioctl,
354 .open = dvb_ca_open, 353 .open = dvb_ca_open,
355 .release = dvb_generic_release, 354 .release = dvb_generic_release,
356 .poll = dvb_ca_poll, 355 .poll = dvb_ca_poll,
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 49c2a817a06f..13ac9e3ab121 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -35,7 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/input.h> 36#include <linux/input.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <media/ir-common.h> 38#include <media/ir-core.h>
39 39
40#include "budget.h" 40#include "budget.h"
41 41
@@ -54,6 +54,8 @@
54#include "tda1002x.h" 54#include "tda1002x.h"
55#include "tda827x.h" 55#include "tda827x.h"
56 56
57#define MODULE_NAME "budget_ci"
58
57/* 59/*
58 * Regarding DEBIADDR_IR: 60 * Regarding DEBIADDR_IR:
59 * Some CI modules hang if random addresses are read. 61 * Some CI modules hang if random addresses are read.
@@ -80,12 +82,6 @@
80#define SLOTSTATUS_READY 8 82#define SLOTSTATUS_READY 8
81#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY) 83#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
82 84
83/*
84 * Milliseconds during which a key is regarded as pressed.
85 * If an identical command arrives within this time, the timer will start over.
86 */
87#define IR_KEYPRESS_TIMEOUT 250
88
89/* RC5 device wildcard */ 85/* RC5 device wildcard */
90#define IR_DEVICE_ANY 255 86#define IR_DEVICE_ANY 255
91 87
@@ -102,12 +98,9 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
102struct budget_ci_ir { 98struct budget_ci_ir {
103 struct input_dev *dev; 99 struct input_dev *dev;
104 struct tasklet_struct msp430_irq_tasklet; 100 struct tasklet_struct msp430_irq_tasklet;
105 struct timer_list timer_keyup;
106 char name[72]; /* 40 + 32 for (struct saa7146_dev).name */ 101 char name[72]; /* 40 + 32 for (struct saa7146_dev).name */
107 char phys[32]; 102 char phys[32];
108 struct ir_input_state state;
109 int rc5_device; 103 int rc5_device;
110 u32 last_raw;
111 u32 ir_key; 104 u32 ir_key;
112 bool have_command; 105 bool have_command;
113}; 106};
@@ -122,18 +115,11 @@ struct budget_ci {
122 u8 tuner_pll_address; /* used for philips_tdm1316l configs */ 115 u8 tuner_pll_address; /* used for philips_tdm1316l configs */
123}; 116};
124 117
125static void msp430_ir_keyup(unsigned long data)
126{
127 struct budget_ci_ir *ir = (struct budget_ci_ir *) data;
128 ir_input_nokey(ir->dev, &ir->state);
129}
130
131static void msp430_ir_interrupt(unsigned long data) 118static void msp430_ir_interrupt(unsigned long data)
132{ 119{
133 struct budget_ci *budget_ci = (struct budget_ci *) data; 120 struct budget_ci *budget_ci = (struct budget_ci *) data;
134 struct input_dev *dev = budget_ci->ir.dev; 121 struct input_dev *dev = budget_ci->ir.dev;
135 u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; 122 u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
136 u32 raw;
137 123
138 /* 124 /*
139 * The msp430 chip can generate two different bytes, command and device 125 * The msp430 chip can generate two different bytes, command and device
@@ -169,20 +155,12 @@ static void msp430_ir_interrupt(unsigned long data)
169 return; 155 return;
170 budget_ci->ir.have_command = false; 156 budget_ci->ir.have_command = false;
171 157
158 /* FIXME: We should generate complete scancodes with device info */
172 if (budget_ci->ir.rc5_device != IR_DEVICE_ANY && 159 if (budget_ci->ir.rc5_device != IR_DEVICE_ANY &&
173 budget_ci->ir.rc5_device != (command & 0x1f)) 160 budget_ci->ir.rc5_device != (command & 0x1f))
174 return; 161 return;
175 162
176 /* Is this a repeated key sequence? (same device, command, toggle) */ 163 ir_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0);
177 raw = budget_ci->ir.ir_key | (command << 8);
178 if (budget_ci->ir.last_raw != raw || !timer_pending(&budget_ci->ir.timer_keyup)) {
179 ir_input_nokey(dev, &budget_ci->ir.state);
180 ir_input_keydown(dev, &budget_ci->ir.state,
181 budget_ci->ir.ir_key);
182 budget_ci->ir.last_raw = raw;
183 }
184
185 mod_timer(&budget_ci->ir.timer_keyup, jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT));
186} 164}
187 165
188static int msp430_ir_init(struct budget_ci *budget_ci) 166static int msp430_ir_init(struct budget_ci *budget_ci)
@@ -190,7 +168,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
190 struct saa7146_dev *saa = budget_ci->budget.dev; 168 struct saa7146_dev *saa = budget_ci->budget.dev;
191 struct input_dev *input_dev = budget_ci->ir.dev; 169 struct input_dev *input_dev = budget_ci->ir.dev;
192 int error; 170 int error;
193 struct ir_scancode_table *ir_codes; 171 char *ir_codes = NULL;
194 172
195 173
196 budget_ci->ir.dev = input_dev = input_allocate_device(); 174 budget_ci->ir.dev = input_dev = input_allocate_device();
@@ -230,31 +208,25 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
230 case 0x1011: 208 case 0x1011:
231 case 0x1012: 209 case 0x1012:
232 /* The hauppauge keymap is a superset of these remotes */ 210 /* The hauppauge keymap is a superset of these remotes */
233 ir_codes = &ir_codes_hauppauge_new_table; 211 ir_codes = RC_MAP_HAUPPAUGE_NEW;
234 212
235 if (rc5_device < 0) 213 if (rc5_device < 0)
236 budget_ci->ir.rc5_device = 0x1f; 214 budget_ci->ir.rc5_device = 0x1f;
237 break; 215 break;
238 case 0x1010: 216 case 0x1010:
239 case 0x1017: 217 case 0x1017:
218 case 0x1019:
240 case 0x101a: 219 case 0x101a:
241 /* for the Technotrend 1500 bundled remote */ 220 /* for the Technotrend 1500 bundled remote */
242 ir_codes = &ir_codes_tt_1500_table; 221 ir_codes = RC_MAP_TT_1500;
243 break; 222 break;
244 default: 223 default:
245 /* unknown remote */ 224 /* unknown remote */
246 ir_codes = &ir_codes_budget_ci_old_table; 225 ir_codes = RC_MAP_BUDGET_CI_OLD;
247 break; 226 break;
248 } 227 }
249 228
250 ir_input_init(input_dev, &budget_ci->ir.state, IR_TYPE_RC5); 229 error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
251
252 /* initialise the key-up timeout handler */
253 init_timer(&budget_ci->ir.timer_keyup);
254 budget_ci->ir.timer_keyup.function = msp430_ir_keyup;
255 budget_ci->ir.timer_keyup.data = (unsigned long) &budget_ci->ir;
256 budget_ci->ir.last_raw = 0xffff; /* An impossible value */
257 error = ir_input_register(input_dev, ir_codes, NULL);
258 if (error) { 230 if (error) {
259 printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error); 231 printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
260 return error; 232 return error;
@@ -282,9 +254,6 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)
282 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 254 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
283 tasklet_kill(&budget_ci->ir.msp430_irq_tasklet); 255 tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
284 256
285 del_timer_sync(&dev->timer);
286 ir_input_nokey(dev, &budget_ci->ir.state);
287
288 ir_input_unregister(dev); 257 ir_input_unregister(dev);
289} 258}
290 259
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 1500210c06cf..874a10a9d493 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -442,6 +442,7 @@ static struct stv090x_config tt1600_stv090x_config = {
442 .repeater_level = STV090x_RPTLEVEL_16, 442 .repeater_level = STV090x_RPTLEVEL_16,
443 443
444 .tuner_init = NULL, 444 .tuner_init = NULL,
445 .tuner_sleep = NULL,
445 .tuner_set_mode = NULL, 446 .tuner_set_mode = NULL,
446 .tuner_set_frequency = NULL, 447 .tuner_set_frequency = NULL,
447 .tuner_get_frequency = NULL, 448 .tuner_get_frequency = NULL,
@@ -627,22 +628,36 @@ static void frontend_init(struct budget *budget)
627 &tt1600_stv6110x_config, 628 &tt1600_stv6110x_config,
628 &budget->i2c_adap); 629 &budget->i2c_adap);
629 630
630 tt1600_stv090x_config.tuner_init = ctl->tuner_init; 631 if (ctl) {
631 tt1600_stv090x_config.tuner_set_mode = ctl->tuner_set_mode; 632 tt1600_stv090x_config.tuner_init = ctl->tuner_init;
632 tt1600_stv090x_config.tuner_set_frequency = ctl->tuner_set_frequency; 633 tt1600_stv090x_config.tuner_sleep = ctl->tuner_sleep;
633 tt1600_stv090x_config.tuner_get_frequency = ctl->tuner_get_frequency; 634 tt1600_stv090x_config.tuner_set_mode = ctl->tuner_set_mode;
634 tt1600_stv090x_config.tuner_set_bandwidth = ctl->tuner_set_bandwidth; 635 tt1600_stv090x_config.tuner_set_frequency = ctl->tuner_set_frequency;
635 tt1600_stv090x_config.tuner_get_bandwidth = ctl->tuner_get_bandwidth; 636 tt1600_stv090x_config.tuner_get_frequency = ctl->tuner_get_frequency;
636 tt1600_stv090x_config.tuner_set_bbgain = ctl->tuner_set_bbgain; 637 tt1600_stv090x_config.tuner_set_bandwidth = ctl->tuner_set_bandwidth;
637 tt1600_stv090x_config.tuner_get_bbgain = ctl->tuner_get_bbgain; 638 tt1600_stv090x_config.tuner_get_bandwidth = ctl->tuner_get_bandwidth;
638 tt1600_stv090x_config.tuner_set_refclk = ctl->tuner_set_refclk; 639 tt1600_stv090x_config.tuner_set_bbgain = ctl->tuner_set_bbgain;
639 tt1600_stv090x_config.tuner_get_status = ctl->tuner_get_status; 640 tt1600_stv090x_config.tuner_get_bbgain = ctl->tuner_get_bbgain;
640 641 tt1600_stv090x_config.tuner_set_refclk = ctl->tuner_set_refclk;
641 dvb_attach(isl6423_attach, 642 tt1600_stv090x_config.tuner_get_status = ctl->tuner_get_status;
642 budget->dvb_frontend, 643
643 &budget->i2c_adap, 644 /* call the init function once to initialize
644 &tt1600_isl6423_config); 645 tuner's clock output divider and demod's
645 646 master clock */
647 if (budget->dvb_frontend->ops.init)
648 budget->dvb_frontend->ops.init(budget->dvb_frontend);
649
650 if (dvb_attach(isl6423_attach,
651 budget->dvb_frontend,
652 &budget->i2c_adap,
653 &tt1600_isl6423_config) == NULL) {
654 printk(KERN_ERR "%s: No Intersil ISL6423 found!\n", __func__);
655 goto error_out;
656 }
657 } else {
658 printk(KERN_ERR "%s: No STV6110(A) Silicon Tuner found!\n", __func__);
659 goto error_out;
660 }
646 } 661 }
647 } 662 }
648 break; 663 break;
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 53baccbab17f..fe1b8037b247 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1257,7 +1257,7 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1257 if(!dec->irq_urb) { 1257 if(!dec->irq_urb) {
1258 return -ENOMEM; 1258 return -ENOMEM;
1259 } 1259 }
1260 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE, 1260 dec->irq_buffer = usb_alloc_coherent(dec->udev,IRQ_PACKET_SIZE,
1261 GFP_ATOMIC, &dec->irq_dma_handle); 1261 GFP_ATOMIC, &dec->irq_dma_handle);
1262 if(!dec->irq_buffer) { 1262 if(!dec->irq_buffer) {
1263 usb_free_urb(dec->irq_urb); 1263 usb_free_urb(dec->irq_urb);
@@ -1550,8 +1550,8 @@ static void ttusb_dec_exit_rc(struct ttusb_dec *dec)
1550 1550
1551 usb_free_urb(dec->irq_urb); 1551 usb_free_urb(dec->irq_urb);
1552 1552
1553 usb_buffer_free(dec->udev,IRQ_PACKET_SIZE, 1553 usb_free_coherent(dec->udev,IRQ_PACKET_SIZE,
1554 dec->irq_buffer, dec->irq_dma_handle); 1554 dec->irq_buffer, dec->irq_dma_handle);
1555 1555
1556 if (dec->rc_input_dev) { 1556 if (dec->rc_input_dev) {
1557 input_unregister_device(dec->rc_input_dev); 1557 input_unregister_device(dec->rc_input_dev);