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/dvb_demux.c11
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c25
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c14
-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.c51
-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.h9
-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/vp702x.c12
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c12
-rw-r--r--drivers/media/dvb/firewire/firedtv-avc.c2
-rw-r--r--drivers/media/dvb/frontends/atbm8830_priv.h2
-rw-r--r--drivers/media/dvb/frontends/au8522_decoder.c7
-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.c2
-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.c34
-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.c328
-rw-r--r--drivers/media/dvb/ngene/ngene-core.c518
-rw-r--r--drivers/media/dvb/ngene/ngene-dvb.c172
-rw-r--r--drivers/media/dvb/ngene/ngene-i2c.c179
-rw-r--r--drivers/media/dvb/ngene/ngene.h30
-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/budget-ci.c52
-rw-r--r--drivers/media/dvb/ttpci/budget.c47
63 files changed, 1604 insertions, 987 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..b762e561a6d5 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 = NULL;
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/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..6932def4d266 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -95,6 +95,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. 95 * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
96 */ 96 */
97 97
98#define DVB_FE_NO_EXIT 0
99#define DVB_FE_NORMAL_EXIT 1
100#define DVB_FE_DEVICE_REMOVED 2
101
98static DEFINE_MUTEX(frontend_mutex); 102static DEFINE_MUTEX(frontend_mutex);
99 103
100struct dvb_frontend_private { 104struct dvb_frontend_private {
@@ -497,7 +501,7 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
497{ 501{
498 struct dvb_frontend_private *fepriv = fe->frontend_priv; 502 struct dvb_frontend_private *fepriv = fe->frontend_priv;
499 503
500 if (fepriv->exit) 504 if (fepriv->exit != DVB_FE_NO_EXIT)
501 return 1; 505 return 1;
502 506
503 if (fepriv->dvbdev->writers == 1) 507 if (fepriv->dvbdev->writers == 1)
@@ -559,7 +563,7 @@ restart:
559 563
560 if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) { 564 if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) {
561 /* got signal or quitting */ 565 /* got signal or quitting */
562 fepriv->exit = 1; 566 fepriv->exit = DVB_FE_NORMAL_EXIT;
563 break; 567 break;
564 } 568 }
565 569
@@ -673,7 +677,10 @@ restart:
673 } 677 }
674 678
675 fepriv->thread = NULL; 679 fepriv->thread = NULL;
676 fepriv->exit = 0; 680 if (kthread_should_stop())
681 fepriv->exit = DVB_FE_DEVICE_REMOVED;
682 else
683 fepriv->exit = DVB_FE_NO_EXIT;
677 mb(); 684 mb();
678 685
679 dvb_frontend_wakeup(fe); 686 dvb_frontend_wakeup(fe);
@@ -686,7 +693,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
686 693
687 dprintk ("%s\n", __func__); 694 dprintk ("%s\n", __func__);
688 695
689 fepriv->exit = 1; 696 fepriv->exit = DVB_FE_NORMAL_EXIT;
690 mb(); 697 mb();
691 698
692 if (!fepriv->thread) 699 if (!fepriv->thread)
@@ -755,7 +762,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
755 dprintk ("%s\n", __func__); 762 dprintk ("%s\n", __func__);
756 763
757 if (fepriv->thread) { 764 if (fepriv->thread) {
758 if (!fepriv->exit) 765 if (fepriv->exit == DVB_FE_NO_EXIT)
759 return 0; 766 return 0;
760 else 767 else
761 dvb_frontend_stop (fe); 768 dvb_frontend_stop (fe);
@@ -767,7 +774,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
767 return -EINTR; 774 return -EINTR;
768 775
769 fepriv->state = FESTATE_IDLE; 776 fepriv->state = FESTATE_IDLE;
770 fepriv->exit = 0; 777 fepriv->exit = DVB_FE_NO_EXIT;
771 fepriv->thread = NULL; 778 fepriv->thread = NULL;
772 mb(); 779 mb();
773 780
@@ -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 &&
@@ -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);
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 441c0642b30a..cccea412088b 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -1109,14 +1109,14 @@ static int dvb_net_feed_stop(struct net_device *dev)
1109} 1109}
1110 1110
1111 1111
1112static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc) 1112static int dvb_set_mc_filter(struct net_device *dev, unsigned char *addr)
1113{ 1113{
1114 struct dvb_net_priv *priv = netdev_priv(dev); 1114 struct dvb_net_priv *priv = netdev_priv(dev);
1115 1115
1116 if (priv->multi_num == DVB_NET_MULTICAST_MAX) 1116 if (priv->multi_num == DVB_NET_MULTICAST_MAX)
1117 return -ENOMEM; 1117 return -ENOMEM;
1118 1118
1119 memcpy(priv->multi_macs[priv->multi_num], mc->dmi_addr, 6); 1119 memcpy(priv->multi_macs[priv->multi_num], addr, ETH_ALEN);
1120 1120
1121 priv->multi_num++; 1121 priv->multi_num++;
1122 return 0; 1122 return 0;
@@ -1140,8 +1140,7 @@ static void wq_set_multicast_list (struct work_struct *work)
1140 dprintk("%s: allmulti mode\n", dev->name); 1140 dprintk("%s: allmulti mode\n", dev->name);
1141 priv->rx_mode = RX_MODE_ALL_MULTI; 1141 priv->rx_mode = RX_MODE_ALL_MULTI;
1142 } else if (!netdev_mc_empty(dev)) { 1142 } else if (!netdev_mc_empty(dev)) {
1143 int mci; 1143 struct netdev_hw_addr *ha;
1144 struct dev_mc_list *mc;
1145 1144
1146 dprintk("%s: set_mc_list, %d entries\n", 1145 dprintk("%s: set_mc_list, %d entries\n",
1147 dev->name, netdev_mc_count(dev)); 1146 dev->name, netdev_mc_count(dev));
@@ -1149,11 +1148,8 @@ static void wq_set_multicast_list (struct work_struct *work)
1149 priv->rx_mode = RX_MODE_MULTI; 1148 priv->rx_mode = RX_MODE_MULTI;
1150 priv->multi_num = 0; 1149 priv->multi_num = 0;
1151 1150
1152 for (mci = 0, mc=dev->mc_list; 1151 netdev_for_each_mc_addr(ha, dev)
1153 mci < netdev_mc_count(dev); 1152 dvb_set_mc_filter(dev, ha->addr);
1154 mc = mc->next, mci++) {
1155 dvb_set_mc_filter(dev, mc);
1156 }
1157 } 1153 }
1158 1154
1159 netif_addr_unlock_bh(dev); 1155 netif_addr_unlock_bh(dev);
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..0eb490889162 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,9 @@ 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 return -ENODEV;
1030 1031
1031 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, 1032 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1032 &cxusb_dualdig4_rev2_config); 1033 &cxusb_dualdig4_rev2_config);
@@ -1449,8 +1450,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1449 .i2c_algo = &cxusb_i2c_algo, 1450 .i2c_algo = &cxusb_i2c_algo,
1450 1451
1451 .rc_interval = 100, 1452 .rc_interval = 100,
1452 .rc_key_map = dvico_portable_rc_keys, 1453 .rc_key_map = ir_codes_dvico_portable_table,
1453 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1454 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1454 .rc_query = cxusb_rc_query, 1455 .rc_query = cxusb_rc_query,
1455 1456
1456 .generic_bulk_ctrl_endpoint = 0x01, 1457 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1500,8 +1501,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1500 .i2c_algo = &cxusb_i2c_algo, 1501 .i2c_algo = &cxusb_i2c_algo,
1501 1502
1502 .rc_interval = 150, 1503 .rc_interval = 150,
1503 .rc_key_map = dvico_mce_rc_keys, 1504 .rc_key_map = ir_codes_dvico_mce_table,
1504 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), 1505 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1505 .rc_query = cxusb_rc_query, 1506 .rc_query = cxusb_rc_query,
1506 1507
1507 .generic_bulk_ctrl_endpoint = 0x01, 1508 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1559,8 +1560,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1559 .i2c_algo = &cxusb_i2c_algo, 1560 .i2c_algo = &cxusb_i2c_algo,
1560 1561
1561 .rc_interval = 100, 1562 .rc_interval = 100,
1562 .rc_key_map = dvico_portable_rc_keys, 1563 .rc_key_map = ir_codes_dvico_portable_table,
1563 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1564 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1564 .rc_query = cxusb_rc_query, 1565 .rc_query = cxusb_rc_query,
1565 1566
1566 .generic_bulk_ctrl_endpoint = 0x01, 1567 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1609,8 +1610,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1609 .i2c_algo = &cxusb_i2c_algo, 1610 .i2c_algo = &cxusb_i2c_algo,
1610 1611
1611 .rc_interval = 100, 1612 .rc_interval = 100,
1612 .rc_key_map = dvico_portable_rc_keys, 1613 .rc_key_map = ir_codes_dvico_portable_table,
1613 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1614 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1614 .rc_query = cxusb_rc_query, 1615 .rc_query = cxusb_rc_query,
1615 1616
1616 .generic_bulk_ctrl_endpoint = 0x01, 1617 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1658,8 +1659,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1658 .generic_bulk_ctrl_endpoint = 0x01, 1659 .generic_bulk_ctrl_endpoint = 0x01,
1659 1660
1660 .rc_interval = 100, 1661 .rc_interval = 100,
1661 .rc_key_map = dvico_mce_rc_keys, 1662 .rc_key_map = ir_codes_dvico_mce_table,
1662 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), 1663 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1663 .rc_query = cxusb_bluebird2_rc_query, 1664 .rc_query = cxusb_bluebird2_rc_query,
1664 1665
1665 .num_device_descs = 1, 1666 .num_device_descs = 1,
@@ -1706,8 +1707,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1706 .generic_bulk_ctrl_endpoint = 0x01, 1707 .generic_bulk_ctrl_endpoint = 0x01,
1707 1708
1708 .rc_interval = 100, 1709 .rc_interval = 100,
1709 .rc_key_map = dvico_portable_rc_keys, 1710 .rc_key_map = ir_codes_dvico_portable_table,
1710 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1711 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1711 .rc_query = cxusb_bluebird2_rc_query, 1712 .rc_query = cxusb_bluebird2_rc_query,
1712 1713
1713 .num_device_descs = 1, 1714 .num_device_descs = 1,
@@ -1756,8 +1757,8 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_prope
1756 .generic_bulk_ctrl_endpoint = 0x01, 1757 .generic_bulk_ctrl_endpoint = 0x01,
1757 1758
1758 .rc_interval = 100, 1759 .rc_interval = 100,
1759 .rc_key_map = dvico_portable_rc_keys, 1760 .rc_key_map = ir_codes_dvico_portable_table,
1760 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), 1761 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1761 .rc_query = cxusb_rc_query, 1762 .rc_query = cxusb_rc_query,
1762 1763
1763 .num_device_descs = 1, 1764 .num_device_descs = 1,
@@ -1847,8 +1848,8 @@ struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
1847 .generic_bulk_ctrl_endpoint = 0x01, 1848 .generic_bulk_ctrl_endpoint = 0x01,
1848 1849
1849 .rc_interval = 100, 1850 .rc_interval = 100,
1850 .rc_key_map = dvico_mce_rc_keys, 1851 .rc_key_map = ir_codes_dvico_mce_table,
1851 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), 1852 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1852 .rc_query = cxusb_rc_query, 1853 .rc_query = cxusb_rc_query,
1853 1854
1854 .num_device_descs = 1, 1855 .num_device_descs = 1,
@@ -1895,8 +1896,8 @@ static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
1895 .generic_bulk_ctrl_endpoint = 0x01, 1896 .generic_bulk_ctrl_endpoint = 0x01,
1896 1897
1897 .rc_interval = 100, 1898 .rc_interval = 100,
1898 .rc_key_map = d680_dmb_rc_keys, 1899 .rc_key_map = ir_codes_d680_dmb_table,
1899 .rc_key_map_size = ARRAY_SIZE(d680_dmb_rc_keys), 1900 .rc_key_map_size = ARRAY_SIZE(ir_codes_d680_dmb_table),
1900 .rc_query = cxusb_d680_dmb_rc_query, 1901 .rc_query = cxusb_d680_dmb_rc_query,
1901 1902
1902 .num_device_descs = 1, 1903 .num_device_descs = 1,
@@ -1944,8 +1945,8 @@ static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
1944 .generic_bulk_ctrl_endpoint = 0x01, 1945 .generic_bulk_ctrl_endpoint = 0x01,
1945 1946
1946 .rc_interval = 100, 1947 .rc_interval = 100,
1947 .rc_key_map = d680_dmb_rc_keys, 1948 .rc_key_map = ir_codes_d680_dmb_table,
1948 .rc_key_map_size = ARRAY_SIZE(d680_dmb_rc_keys), 1949 .rc_key_map_size = ARRAY_SIZE(ir_codes_d680_dmb_table),
1949 .rc_query = cxusb_d680_dmb_rc_query, 1950 .rc_query = cxusb_d680_dmb_rc_query,
1950 1951
1951 .num_device_descs = 1, 1952 .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..085c4e457e0e 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
@@ -288,6 +290,7 @@
288#define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807 290#define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807
289#define USB_PID_SONY_PLAYTV 0x0003 291#define USB_PID_SONY_PLAYTV 0x0003
290#define USB_PID_MYGICA_D689 0xd811 292#define USB_PID_MYGICA_D689 0xd811
293#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011
291#define USB_PID_ELGATO_EYETV_DTT 0x0021 294#define USB_PID_ELGATO_EYETV_DTT 0x0021
292#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020 295#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020
293#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000 296#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000
@@ -296,6 +299,8 @@
296#define USB_PID_TVWAY_PLUS 0x0002 299#define USB_PID_TVWAY_PLUS 0x0002
297#define USB_PID_SVEON_STV20 0xe39d 300#define USB_PID_SVEON_STV20 0xe39d
298#define USB_PID_AZUREWAVE_AZ6027 0x3275 301#define USB_PID_AZUREWAVE_AZ6027 0x3275
299#define USB_PID_TERRATEC_DVBS2CI 0x3275 302#define USB_PID_TERRATEC_DVBS2CI_V1 0x10a4
300#define USB_PID_TECHNISAT_USB2_HDCI 0x0002 303#define USB_PID_TERRATEC_DVBS2CI_V2 0x10ac
304#define USB_PID_TECHNISAT_USB2_HDCI_V1 0x0001
305#define USB_PID_TECHNISAT_USB2_HDCI_V2 0x0002
301#endif 306#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/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-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/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..68dba3a4b4da 100644
--- a/drivers/media/dvb/frontends/au8522_decoder.c
+++ b/drivers/media/dvb/frontends/au8522_decoder.c
@@ -664,6 +664,13 @@ static int au8522_reset(struct v4l2_subdev *sd, u32 val)
664{ 664{
665 struct au8522_state *state = to_state(sd); 665 struct au8522_state *state = to_state(sd);
666 666
667 state->operational_mode = AU8522_ANALOG_MODE;
668
669 /* Clear out any state associated with the digital side of the
670 chip, so that when it gets powered back up it won't think
671 that it is already tuned */
672 state->current_frequency = 0;
673
667 au8522_writereg(state, 0xa4, 1 << 5); 674 au8522_writereg(state, 0xa4, 1 << 5);
668 675
669 return 0; 676 return 0;
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..78001e8bcdb7 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 }
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..42591ce1aaad 100644
--- a/drivers/media/dvb/frontends/stv6110x.c
+++ b/drivers/media/dvb/frontends/stv6110x.c
@@ -338,14 +338,12 @@ static struct dvb_tuner_ops stv6110x_ops = {
338 .frequency_max = 2150000, 338 .frequency_max = 2150000,
339 .frequency_step = 0, 339 .frequency_step = 0,
340 }, 340 },
341
342 .init = stv6110x_init,
343 .sleep = stv6110x_sleep,
344 .release = stv6110x_release 341 .release = stv6110x_release
345}; 342};
346 343
347static struct stv6110x_devctl stv6110x_ctl = { 344static struct stv6110x_devctl stv6110x_ctl = {
348 .tuner_init = stv6110x_init, 345 .tuner_init = stv6110x_init,
346 .tuner_sleep = stv6110x_sleep,
349 .tuner_set_mode = stv6110x_set_mode, 347 .tuner_set_mode = stv6110x_set_mode,
350 .tuner_set_frequency = stv6110x_set_frequency, 348 .tuner_set_frequency = stv6110x_set_frequency,
351 .tuner_get_frequency = stv6110x_get_frequency, 349 .tuner_get_frequency = stv6110x_get_frequency,
@@ -363,11 +361,10 @@ struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
363{ 361{
364 struct stv6110x_state *stv6110x; 362 struct stv6110x_state *stv6110x;
365 u8 default_regs[] = {0x07, 0x11, 0xdc, 0x85, 0x17, 0x01, 0xe6, 0x1e}; 363 u8 default_regs[] = {0x07, 0x11, 0xdc, 0x85, 0x17, 0x01, 0xe6, 0x1e};
366 int ret;
367 364
368 stv6110x = kzalloc(sizeof (struct stv6110x_state), GFP_KERNEL); 365 stv6110x = kzalloc(sizeof (struct stv6110x_state), GFP_KERNEL);
369 if (stv6110x == NULL) 366 if (!stv6110x)
370 goto error; 367 return NULL;
371 368
372 stv6110x->i2c = i2c; 369 stv6110x->i2c = i2c;
373 stv6110x->config = config; 370 stv6110x->config = config;
@@ -392,34 +389,11 @@ struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
392 break; 389 break;
393 } 390 }
394 391
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; 392 fe->tuner_priv = stv6110x;
415 fe->ops.tuner_ops = stv6110x_ops; 393 fe->ops.tuner_ops = stv6110x_ops;
416 394
417 printk("%s: Attaching STV6110x \n", __func__); 395 printk(KERN_INFO "%s: Attaching STV6110x\n", __func__);
418 return stv6110x->devctl; 396 return stv6110x->devctl;
419
420error:
421 kfree(stv6110x);
422 return NULL;
423} 397}
424EXPORT_SYMBOL(stv6110x_attach); 398EXPORT_SYMBOL(stv6110x_attach);
425 399
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..692c3e226e83
--- /dev/null
+++ b/drivers/media/dvb/ngene/ngene-cards.c
@@ -0,0 +1,328 @@
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_m780 = {
221 .type = NGENE_APP,
222 .name = "Aver M780 ATSC/QAM-B",
223
224 /* Channel 0 is analog, which is currently unsupported */
225 .io_type = { NGENE_IO_NONE, NGENE_IO_TSIN },
226 .demod_attach = { NULL, demod_attach_lg330x },
227
228 /* Ensure these are NULL else the frame will call them (as funcs) */
229 .tuner_attach = { 0, 0, 0, 0 },
230 .fe_config = { NULL, &aver_m780 },
231 .avf = { 0 },
232
233 /* A custom electrical interface config for the demod to bridge */
234 .tsf = { 4, 4 },
235 .fw_version = 15,
236};
237
238/****************************************************************************/
239
240
241
242/****************************************************************************/
243/* PCI Subsystem ID *********************************************************/
244/****************************************************************************/
245
246#define NGENE_ID(_subvend, _subdev, _driverdata) { \
247 .vendor = NGENE_VID, .device = NGENE_PID, \
248 .subvendor = _subvend, .subdevice = _subdev, \
249 .driver_data = (unsigned long) &_driverdata }
250
251/****************************************************************************/
252
253static const struct pci_device_id ngene_id_tbl[] __devinitdata = {
254 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2),
255 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2),
256 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2),
257 NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2),
258 NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5),
259 NGENE_ID(0x1461, 0x062e, ngene_info_m780),
260 {0}
261};
262MODULE_DEVICE_TABLE(pci, ngene_id_tbl);
263
264/****************************************************************************/
265/* Init/Exit ****************************************************************/
266/****************************************************************************/
267
268static pci_ers_result_t ngene_error_detected(struct pci_dev *dev,
269 enum pci_channel_state state)
270{
271 printk(KERN_ERR DEVICE_NAME ": PCI error\n");
272 if (state == pci_channel_io_perm_failure)
273 return PCI_ERS_RESULT_DISCONNECT;
274 if (state == pci_channel_io_frozen)
275 return PCI_ERS_RESULT_NEED_RESET;
276 return PCI_ERS_RESULT_CAN_RECOVER;
277}
278
279static pci_ers_result_t ngene_link_reset(struct pci_dev *dev)
280{
281 printk(KERN_INFO DEVICE_NAME ": link reset\n");
282 return 0;
283}
284
285static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev)
286{
287 printk(KERN_INFO DEVICE_NAME ": slot reset\n");
288 return 0;
289}
290
291static void ngene_resume(struct pci_dev *dev)
292{
293 printk(KERN_INFO DEVICE_NAME ": resume\n");
294}
295
296static struct pci_error_handlers ngene_errors = {
297 .error_detected = ngene_error_detected,
298 .link_reset = ngene_link_reset,
299 .slot_reset = ngene_slot_reset,
300 .resume = ngene_resume,
301};
302
303static struct pci_driver ngene_pci_driver = {
304 .name = "ngene",
305 .id_table = ngene_id_tbl,
306 .probe = ngene_probe,
307 .remove = __devexit_p(ngene_remove),
308 .err_handler = &ngene_errors,
309};
310
311static __init int module_init_ngene(void)
312{
313 printk(KERN_INFO
314 "nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n");
315 return pci_register_driver(&ngene_pci_driver);
316}
317
318static __exit void module_exit_ngene(void)
319{
320 pci_unregister_driver(&ngene_pci_driver);
321}
322
323module_init(module_init_ngene);
324module_exit(module_exit_ngene);
325
326MODULE_DESCRIPTION("nGene");
327MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel");
328MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ngene/ngene-core.c b/drivers/media/dvb/ngene/ngene-core.c
index 645e8b8a7137..c8b4dfa0ab5f 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.");
@@ -63,8 +57,6 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
63 57
64#define dprintk if (debug) printk 58#define dprintk if (debug) printk
65 59
66#define DEVICE_NAME "ngene"
67
68#define ngwriteb(dat, adr) writeb((dat), (char *)(dev->iomem + (adr))) 60#define ngwriteb(dat, adr) writeb((dat), (char *)(dev->iomem + (adr)))
69#define ngwritel(dat, adr) writel((dat), (char *)(dev->iomem + (adr))) 61#define ngwritel(dat, adr) writel((dat), (char *)(dev->iomem + (adr)))
70#define ngwriteb(dat, adr) writeb((dat), (char *)(dev->iomem + (adr))) 62#define ngwriteb(dat, adr) writeb((dat), (char *)(dev->iomem + (adr)))
@@ -352,7 +344,7 @@ static int ngene_command_mutex(struct ngene *dev, struct ngene_command *com)
352 return 0; 344 return 0;
353} 345}
354 346
355static int ngene_command(struct ngene *dev, struct ngene_command *com) 347int ngene_command(struct ngene *dev, struct ngene_command *com)
356{ 348{
357 int result; 349 int result;
358 350
@@ -363,55 +355,6 @@ static int ngene_command(struct ngene *dev, struct ngene_command *com)
363} 355}
364 356
365 357
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, 358static int ngene_command_load_firmware(struct ngene *dev,
416 u8 *ngene_fw, u32 size) 359 u8 *ngene_fw, u32 size)
417{ 360{
@@ -477,7 +420,7 @@ static int ngene_command_config_free_buf(struct ngene *dev, u8 *config)
477 return 0; 420 return 0;
478} 421}
479 422
480static int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level) 423int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level)
481{ 424{
482 struct ngene_command com; 425 struct ngene_command com;
483 426
@@ -514,11 +457,12 @@ static int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level)
514 457
515/****************************************************************************/ 458/****************************************************************************/
516 459
517static u8 TSFeatureDecoderSetup[8 * 4] = { 460static u8 TSFeatureDecoderSetup[8 * 5] = {
518 0x42, 0x00, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, 461 0x42, 0x00, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00,
519 0x40, 0x06, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* DRXH */ 462 0x40, 0x06, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* DRXH */
520 0x71, 0x07, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* DRXHser */ 463 0x71, 0x07, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* DRXHser */
521 0x72, 0x06, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* S2ser */ 464 0x72, 0x06, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* S2ser */
465 0x40, 0x07, 0x00, 0x02, 0x02, 0xbc, 0x00, 0x00, /* LGDT3303 */
522}; 466};
523 467
524/* Set NGENE I2S Config to 16 bit packed */ 468/* Set NGENE I2S Config to 16 bit packed */
@@ -559,7 +503,7 @@ static u8 ITUFeatureDecoderSetup[8] = {
559 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x04, 0x00 503 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x04, 0x00
560}; 504};
561 505
562static void FillTSBuffer(void *Buffer, int Length, u32 Flags) 506void FillTSBuffer(void *Buffer, int Length, u32 Flags)
563{ 507{
564 u32 *ptr = Buffer; 508 u32 *ptr = Buffer;
565 509
@@ -772,144 +716,7 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
772 return 0; 716 return 0;
773} 717}
774 718
775 719void 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{ 720{
914 u8 control = 0, mode = 0, flags = 0; 721 u8 control = 0, mode = 0, flags = 0;
915 struct ngene *dev = chan->dev; 722 struct ngene *dev = chan->dev;
@@ -970,85 +777,12 @@ static void set_transfer(struct ngene_channel *chan, int state)
970 state); 777 state);
971 if (!state) { 778 if (!state) {
972 spin_lock_irq(&chan->state_lock); 779 spin_lock_irq(&chan->state_lock);
973 chan->pBufferExchange = 0; 780 chan->pBufferExchange = NULL;
974 dvb_ringbuffer_flush(&dev->tsout_rbuf); 781 dvb_ringbuffer_flush(&dev->tsout_rbuf);
975 spin_unlock_irq(&chan->state_lock); 782 spin_unlock_irq(&chan->state_lock);
976 } 783 }
977} 784}
978 785
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 786
1053/****************************************************************************/ 787/****************************************************************************/
1054/* nGene hardware init and release functions ********************************/ 788/* nGene hardware init and release functions ********************************/
@@ -1094,8 +828,8 @@ static void free_idlebuffer(struct ngene *dev,
1094 return; 828 return;
1095 free_ringbuffer(dev, rb); 829 free_ringbuffer(dev, rb);
1096 for (j = 0; j < tb->NumBuffers; j++, Cur = Cur->Next) { 830 for (j = 0; j < tb->NumBuffers; j++, Cur = Cur->Next) {
1097 Cur->Buffer2 = 0; 831 Cur->Buffer2 = NULL;
1098 Cur->scList2 = 0; 832 Cur->scList2 = NULL;
1099 Cur->ngeneBuffer.Address_of_first_entry_2 = 0; 833 Cur->ngeneBuffer.Address_of_first_entry_2 = 0;
1100 Cur->ngeneBuffer.Number_of_entries_2 = 0; 834 Cur->ngeneBuffer.Number_of_entries_2 = 0;
1101 } 835 }
@@ -1141,7 +875,7 @@ static int create_ring_buffer(struct pci_dev *pci_dev,
1141 u64 PARingBufferNext; 875 u64 PARingBufferNext;
1142 struct SBufferHeader *Cur, *Next; 876 struct SBufferHeader *Cur, *Next;
1143 877
1144 descr->Head = 0; 878 descr->Head = NULL;
1145 descr->MemSize = 0; 879 descr->MemSize = 0;
1146 descr->PAHead = 0; 880 descr->PAHead = 0;
1147 descr->NumBuffers = 0; 881 descr->NumBuffers = 0;
@@ -1633,69 +1367,6 @@ fail:
1633 1367
1634 1368
1635 1369
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 1370
1700/****************************************************************************/ 1371/****************************************************************************/
1701/****************************************************************************/ 1372/****************************************************************************/
@@ -1719,7 +1390,7 @@ static void release_channel(struct ngene_channel *chan)
1719 if (chan->fe) { 1390 if (chan->fe) {
1720 dvb_unregister_frontend(chan->fe); 1391 dvb_unregister_frontend(chan->fe);
1721 dvb_frontend_detach(chan->fe); 1392 dvb_frontend_detach(chan->fe);
1722 chan->fe = 0; 1393 chan->fe = NULL;
1723 } 1394 }
1724 dvbdemux->dmx.close(&dvbdemux->dmx); 1395 dvbdemux->dmx.close(&dvbdemux->dmx);
1725 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, 1396 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx,
@@ -1751,7 +1422,7 @@ static int init_channel(struct ngene_channel *chan)
1751 if (io & (NGENE_IO_TSIN | NGENE_IO_TSOUT)) { 1422 if (io & (NGENE_IO_TSIN | NGENE_IO_TSOUT)) {
1752 if (nr >= STREAM_AUDIOIN1) 1423 if (nr >= STREAM_AUDIOIN1)
1753 chan->DataFormatFlags = DF_SWAP32; 1424 chan->DataFormatFlags = DF_SWAP32;
1754 if (nr == 0 || !one_adapter) { 1425 if (nr == 0 || !one_adapter || dev->first_adapter == NULL) {
1755 adapter = &dev->adapter[nr]; 1426 adapter = &dev->adapter[nr];
1756 ret = dvb_register_adapter(adapter, "nGene", 1427 ret = dvb_register_adapter(adapter, "nGene",
1757 THIS_MODULE, 1428 THIS_MODULE,
@@ -1759,8 +1430,10 @@ static int init_channel(struct ngene_channel *chan)
1759 adapter_nr); 1430 adapter_nr);
1760 if (ret < 0) 1431 if (ret < 0)
1761 return ret; 1432 return ret;
1433 if (dev->first_adapter == NULL)
1434 dev->first_adapter = adapter;
1762 } else { 1435 } else {
1763 adapter = &dev->adapter[0]; 1436 adapter = dev->first_adapter;
1764 } 1437 }
1765 1438
1766 ret = my_dvb_dmx_ts_card_init(dvbdemux, "SW demux", 1439 ret = my_dvb_dmx_ts_card_init(dvbdemux, "SW demux",
@@ -1797,6 +1470,7 @@ static int init_channels(struct ngene *dev)
1797 int i, j; 1470 int i, j;
1798 1471
1799 for (i = 0; i < MAX_STREAM; i++) { 1472 for (i = 0; i < MAX_STREAM; i++) {
1473 dev->channel[i].number = i;
1800 if (init_channel(&dev->channel[i]) < 0) { 1474 if (init_channel(&dev->channel[i]) < 0) {
1801 for (j = i - 1; j >= 0; j--) 1475 for (j = i - 1; j >= 0; j--)
1802 release_channel(&dev->channel[j]); 1476 release_channel(&dev->channel[j]);
@@ -1810,7 +1484,7 @@ static int init_channels(struct ngene *dev)
1810/* device probe/remove calls ************************************************/ 1484/* device probe/remove calls ************************************************/
1811/****************************************************************************/ 1485/****************************************************************************/
1812 1486
1813static void __devexit ngene_remove(struct pci_dev *pdev) 1487void __devexit ngene_remove(struct pci_dev *pdev)
1814{ 1488{
1815 struct ngene *dev = (struct ngene *)pci_get_drvdata(pdev); 1489 struct ngene *dev = (struct ngene *)pci_get_drvdata(pdev);
1816 int i; 1490 int i;
@@ -1820,12 +1494,12 @@ static void __devexit ngene_remove(struct pci_dev *pdev)
1820 release_channel(&dev->channel[i]); 1494 release_channel(&dev->channel[i]);
1821 ngene_stop(dev); 1495 ngene_stop(dev);
1822 ngene_release_buffers(dev); 1496 ngene_release_buffers(dev);
1823 pci_set_drvdata(pdev, 0); 1497 pci_set_drvdata(pdev, NULL);
1824 pci_disable_device(pdev); 1498 pci_disable_device(pdev);
1825} 1499}
1826 1500
1827static int __devinit ngene_probe(struct pci_dev *pci_dev, 1501int __devinit ngene_probe(struct pci_dev *pci_dev,
1828 const struct pci_device_id *id) 1502 const struct pci_device_id *id)
1829{ 1503{
1830 struct ngene *dev; 1504 struct ngene *dev;
1831 int stat = 0; 1505 int stat = 0;
@@ -1868,156 +1542,6 @@ fail1:
1868 ngene_release_buffers(dev); 1542 ngene_release_buffers(dev);
1869fail0: 1543fail0:
1870 pci_disable_device(pci_dev); 1544 pci_disable_device(pci_dev);
1871 pci_set_drvdata(pci_dev, 0); 1545 pci_set_drvdata(pci_dev, NULL);
1872 return stat; 1546 return stat;
1873} 1547}
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..96013eb353cd
--- /dev/null
+++ b/drivers/media/dvb/ngene/ngene-dvb.c
@@ -0,0 +1,172 @@
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/version.h>
41#include <linux/byteorder/generic.h>
42#include <linux/firmware.h>
43#include <linux/vmalloc.h>
44
45#include "ngene.h"
46
47#define COMMAND_TIMEOUT_WORKAROUND
48
49
50/****************************************************************************/
51/* COMMAND API interface ****************************************************/
52/****************************************************************************/
53
54/****************************************************************************/
55/* DVB functions and API interface ******************************************/
56/****************************************************************************/
57
58static void swap_buffer(u32 *p, u32 len)
59{
60 while (len) {
61 *p = swab32(*p);
62 p++;
63 len -= 4;
64 }
65}
66
67void *tsin_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags)
68{
69 struct ngene_channel *chan = priv;
70
71
72#ifdef COMMAND_TIMEOUT_WORKAROUND
73 if (chan->users > 0)
74#endif
75 dvb_dmx_swfilter(&chan->demux, buf, len);
76 return NULL;
77}
78
79u8 fill_ts[188] = { 0x47, 0x1f, 0xff, 0x10 };
80
81void *tsout_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags)
82{
83 struct ngene_channel *chan = priv;
84 struct ngene *dev = chan->dev;
85 u32 alen;
86
87 alen = dvb_ringbuffer_avail(&dev->tsout_rbuf);
88 alen -= alen % 188;
89
90 if (alen < len)
91 FillTSBuffer(buf + alen, len - alen, flags);
92 else
93 alen = len;
94 dvb_ringbuffer_read(&dev->tsout_rbuf, buf, alen);
95 if (flags & DF_SWAP32)
96 swap_buffer((u32 *)buf, alen);
97 wake_up_interruptible(&dev->tsout_rbuf.queue);
98 return buf;
99}
100
101
102
103int ngene_start_feed(struct dvb_demux_feed *dvbdmxfeed)
104{
105 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
106 struct ngene_channel *chan = dvbdmx->priv;
107
108 if (chan->users == 0) {
109#ifdef COMMAND_TIMEOUT_WORKAROUND
110 if (!chan->running)
111#endif
112 set_transfer(chan, 1);
113 /* msleep(10); */
114 }
115
116 return ++chan->users;
117}
118
119int ngene_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
120{
121 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
122 struct ngene_channel *chan = dvbdmx->priv;
123
124 if (--chan->users)
125 return chan->users;
126
127#ifndef COMMAND_TIMEOUT_WORKAROUND
128 set_transfer(chan, 0);
129#endif
130
131 return 0;
132}
133
134int my_dvb_dmx_ts_card_init(struct dvb_demux *dvbdemux, char *id,
135 int (*start_feed)(struct dvb_demux_feed *),
136 int (*stop_feed)(struct dvb_demux_feed *),
137 void *priv)
138{
139 dvbdemux->priv = priv;
140
141 dvbdemux->filternum = 256;
142 dvbdemux->feednum = 256;
143 dvbdemux->start_feed = start_feed;
144 dvbdemux->stop_feed = stop_feed;
145 dvbdemux->write_to_decoder = NULL;
146 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING |
147 DMX_SECTION_FILTERING |
148 DMX_MEMORY_BASED_FILTERING);
149 return dvb_dmx_init(dvbdemux);
150}
151
152int my_dvb_dmxdev_ts_card_init(struct dmxdev *dmxdev,
153 struct dvb_demux *dvbdemux,
154 struct dmx_frontend *hw_frontend,
155 struct dmx_frontend *mem_frontend,
156 struct dvb_adapter *dvb_adapter)
157{
158 int ret;
159
160 dmxdev->filternum = 256;
161 dmxdev->demux = &dvbdemux->dmx;
162 dmxdev->capabilities = 0;
163 ret = dvb_dmxdev_init(dmxdev, dvb_adapter);
164 if (ret < 0)
165 return ret;
166
167 hw_frontend->source = DMX_FRONTEND_0;
168 dvbdemux->dmx.add_frontend(&dvbdemux->dmx, hw_frontend);
169 mem_frontend->source = DMX_MEMORY_FE;
170 dvbdemux->dmx.add_frontend(&dvbdemux->dmx, mem_frontend);
171 return dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, hw_frontend);
172}
diff --git a/drivers/media/dvb/ngene/ngene-i2c.c b/drivers/media/dvb/ngene/ngene-i2c.c
new file mode 100644
index 000000000000..2ef54ca6badd
--- /dev/null
+++ b/drivers/media/dvb/ngene/ngene-i2c.c
@@ -0,0 +1,179 @@
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/version.h>
43#include <linux/byteorder/generic.h>
44#include <linux/firmware.h>
45#include <linux/vmalloc.h>
46
47#include "ngene.h"
48
49/* Firmware command for i2c operations */
50static int ngene_command_i2c_read(struct ngene *dev, u8 adr,
51 u8 *out, u8 outlen, u8 *in, u8 inlen, int flag)
52{
53 struct ngene_command com;
54
55 com.cmd.hdr.Opcode = CMD_I2C_READ;
56 com.cmd.hdr.Length = outlen + 3;
57 com.cmd.I2CRead.Device = adr << 1;
58 memcpy(com.cmd.I2CRead.Data, out, outlen);
59 com.cmd.I2CRead.Data[outlen] = inlen;
60 com.cmd.I2CRead.Data[outlen + 1] = 0;
61 com.in_len = outlen + 3;
62 com.out_len = inlen + 1;
63
64 if (ngene_command(dev, &com) < 0)
65 return -EIO;
66
67 if ((com.cmd.raw8[0] >> 1) != adr)
68 return -EIO;
69
70 if (flag)
71 memcpy(in, com.cmd.raw8, inlen + 1);
72 else
73 memcpy(in, com.cmd.raw8 + 1, inlen);
74 return 0;
75}
76
77static int ngene_command_i2c_write(struct ngene *dev, u8 adr,
78 u8 *out, u8 outlen)
79{
80 struct ngene_command com;
81
82
83 com.cmd.hdr.Opcode = CMD_I2C_WRITE;
84 com.cmd.hdr.Length = outlen + 1;
85 com.cmd.I2CRead.Device = adr << 1;
86 memcpy(com.cmd.I2CRead.Data, out, outlen);
87 com.in_len = outlen + 1;
88 com.out_len = 1;
89
90 if (ngene_command(dev, &com) < 0)
91 return -EIO;
92
93 if (com.cmd.raw8[0] == 1)
94 return -EIO;
95
96 return 0;
97}
98
99static void ngene_i2c_set_bus(struct ngene *dev, int bus)
100{
101 if (!(dev->card_info->i2c_access & 2))
102 return;
103 if (dev->i2c_current_bus == bus)
104 return;
105
106 switch (bus) {
107 case 0:
108 ngene_command_gpio_set(dev, 3, 0);
109 ngene_command_gpio_set(dev, 2, 1);
110 break;
111
112 case 1:
113 ngene_command_gpio_set(dev, 2, 0);
114 ngene_command_gpio_set(dev, 3, 1);
115 break;
116 }
117 dev->i2c_current_bus = bus;
118}
119
120static int ngene_i2c_master_xfer(struct i2c_adapter *adapter,
121 struct i2c_msg msg[], int num)
122{
123 struct ngene_channel *chan =
124 (struct ngene_channel *)i2c_get_adapdata(adapter);
125 struct ngene *dev = chan->dev;
126
127 down(&dev->i2c_switch_mutex);
128 ngene_i2c_set_bus(dev, chan->number);
129
130 if (num == 2 && msg[1].flags & I2C_M_RD && !(msg[0].flags & I2C_M_RD))
131 if (!ngene_command_i2c_read(dev, msg[0].addr,
132 msg[0].buf, msg[0].len,
133 msg[1].buf, msg[1].len, 0))
134 goto done;
135
136 if (num == 1 && !(msg[0].flags & I2C_M_RD))
137 if (!ngene_command_i2c_write(dev, msg[0].addr,
138 msg[0].buf, msg[0].len))
139 goto done;
140 if (num == 1 && (msg[0].flags & I2C_M_RD))
141 if (!ngene_command_i2c_read(dev, msg[0].addr, NULL, 0,
142 msg[0].buf, msg[0].len, 0))
143 goto done;
144
145 up(&dev->i2c_switch_mutex);
146 return -EIO;
147
148done:
149 up(&dev->i2c_switch_mutex);
150 return num;
151}
152
153
154static u32 ngene_i2c_functionality(struct i2c_adapter *adap)
155{
156 return I2C_FUNC_SMBUS_EMUL;
157}
158
159static struct i2c_algorithm ngene_i2c_algo = {
160 .master_xfer = ngene_i2c_master_xfer,
161 .functionality = ngene_i2c_functionality,
162};
163
164int ngene_i2c_init(struct ngene *dev, int dev_nr)
165{
166 struct i2c_adapter *adap = &(dev->channel[dev_nr].i2c_adapter);
167
168 i2c_set_adapdata(adap, &(dev->channel[dev_nr]));
169 adap->class = I2C_CLASS_TV_DIGITAL | I2C_CLASS_TV_ANALOG;
170
171 strcpy(adap->name, "nGene");
172
173 adap->algo = &ngene_i2c_algo;
174 adap->algo_data = (void *)&(dev->channel[dev_nr]);
175 adap->dev.parent = &dev->pci_dev->dev;
176
177 return i2c_add_adapter(adap);
178}
179
diff --git a/drivers/media/dvb/ngene/ngene.h b/drivers/media/dvb/ngene/ngene.h
index a7eb29846310..676fcbb79026 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
@@ -752,6 +754,7 @@ struct ngene {
752 spinlock_t cmd_lock; 754 spinlock_t cmd_lock;
753 755
754 struct dvb_adapter adapter[MAX_STREAM]; 756 struct dvb_adapter adapter[MAX_STREAM];
757 struct dvb_adapter *first_adapter; /* "one_adapter" modprobe opt */
755 struct ngene_channel channel[MAX_STREAM]; 758 struct ngene_channel channel[MAX_STREAM];
756 759
757 struct ngene_info *card_info; 760 struct ngene_info *card_info;
@@ -853,6 +856,33 @@ struct ngene_buffer {
853#endif 856#endif
854 857
855 858
859/* Provided by ngene-core.c */
860int __devinit ngene_probe(struct pci_dev *pci_dev,
861 const struct pci_device_id *id);
862void __devexit ngene_remove(struct pci_dev *pdev);
863int ngene_command(struct ngene *dev, struct ngene_command *com);
864int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level);
865void set_transfer(struct ngene_channel *chan, int state);
866void FillTSBuffer(void *Buffer, int Length, u32 Flags);
867
868/* Provided by ngene-i2c.c */
869int ngene_i2c_init(struct ngene *dev, int dev_nr);
870
871/* Provided by ngene-dvb.c */
872void *tsout_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags);
873void *tsin_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags);
874int ngene_start_feed(struct dvb_demux_feed *dvbdmxfeed);
875int ngene_stop_feed(struct dvb_demux_feed *dvbdmxfeed);
876int my_dvb_dmx_ts_card_init(struct dvb_demux *dvbdemux, char *id,
877 int (*start_feed)(struct dvb_demux_feed *),
878 int (*stop_feed)(struct dvb_demux_feed *),
879 void *priv);
880int my_dvb_dmxdev_ts_card_init(struct dmxdev *dmxdev,
881 struct dvb_demux *dvbdemux,
882 struct dmx_frontend *hw_frontend,
883 struct dmx_frontend *mem_frontend,
884 struct dvb_adapter *dvb_adapter);
885
856#endif 886#endif
857 887
858/* LocalWords: Endif 888/* 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/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 49c2a817a06f..461714396331 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,7 +208,7 @@ 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;
@@ -239,22 +217,15 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
239 case 0x1017: 217 case 0x1017:
240 case 0x101a: 218 case 0x101a:
241 /* for the Technotrend 1500 bundled remote */ 219 /* for the Technotrend 1500 bundled remote */
242 ir_codes = &ir_codes_tt_1500_table; 220 ir_codes = RC_MAP_TT_1500;
243 break; 221 break;
244 default: 222 default:
245 /* unknown remote */ 223 /* unknown remote */
246 ir_codes = &ir_codes_budget_ci_old_table; 224 ir_codes = RC_MAP_BUDGET_CI_OLD;
247 break; 225 break;
248 } 226 }
249 227
250 ir_input_init(input_dev, &budget_ci->ir.state, IR_TYPE_RC5); 228 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) { 229 if (error) {
259 printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error); 230 printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
260 return error; 231 return error;
@@ -282,9 +253,6 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)
282 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 253 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
283 tasklet_kill(&budget_ci->ir.msp430_irq_tasklet); 254 tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
284 255
285 del_timer_sync(&dev->timer);
286 ir_input_nokey(dev, &budget_ci->ir.state);
287
288 ir_input_unregister(dev); 256 ir_input_unregister(dev);
289} 257}
290 258
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;