aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-28 12:35:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-28 12:35:11 -0400
commit0851668fdd97e526b2a41f794b785c204dd3d3e0 (patch)
tree4ef7c20a8be8393006c6fe9627eb29dd30877d61 /drivers/media/dvb
parent00ebb6382b8d9c7c15b5f8ad230670d8161d38dd (diff)
parent7655e594945289b418af39f6669fea4666a7b520 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (505 commits) [media] af9015: Fix max I2C message size when used with tda18271 [media] IR: initialize ir_raw_event in few more drivers [media] Guard a divide in v4l1 compat layer [media] imon: fix nomouse modprobe option [media] imon: remove redundant change_protocol call [media] imon: fix my egregious brown paper bag w/rdev/idev split [media] cafe_ccic: Configure ov7670 correctly [media] ov7670: allow configuration of image size, clock speed, and I/O method [media] af9015: support for DigitalNow TinyTwin v3 [1f4d:9016] [media] af9015: map DigitalNow TinyTwin v2 remote [media] DigitalNow TinyTwin remote controller [media] af9015: RC fixes and improvements videodev2.h.xml: Update to reflect the latest changes at videodev2.h [media] v4l: document new Bayer and monochrome pixel formats [media] DocBook/v4l: Add missing formats used on gspca cpia1 and sn9c2028 [media] firedtv: add parameter to fake ca_system_ids in CA_INFO [media] tm6000: fix a macro coding style issue tm6000: Remove some ugly debug code [media] Nova-S-Plus audio line input [media] [RFC,1/1] V4L2: Use new CAP bits in existing RDS capable drivers ...
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c3
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c1
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c4
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h2
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig12
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c394
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.h735
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c87
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-i2c.c1
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h6
-rw-r--r--drivers/media/dvb/dvb-usb/friio-fe.c2
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk-fe.c4
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk.c9
-rw-r--r--drivers/media/dvb/dvb-usb/lmedm04.c1088
-rw-r--r--drivers/media/dvb/dvb-usb/lmedm04.h173
-rw-r--r--drivers/media/dvb/firewire/firedtv-avc.c61
-rw-r--r--drivers/media/dvb/firewire/firedtv-fe.c36
-rw-r--r--drivers/media/dvb/frontends/Kconfig24
-rw-r--r--drivers/media/dvb/frontends/Makefile3
-rw-r--r--drivers/media/dvb/frontends/af9013.c251
-rw-r--r--drivers/media/dvb/frontends/af9013.h1
-rw-r--r--drivers/media/dvb/frontends/af9013_priv.h60
-rw-r--r--drivers/media/dvb/frontends/au8522_decoder.c27
-rw-r--r--drivers/media/dvb/frontends/cx22702.c123
-rw-r--r--drivers/media/dvb/frontends/cx24110.c2
-rw-r--r--drivers/media/dvb/frontends/cx24123.c1
-rw-r--r--drivers/media/dvb/frontends/dibx000_common.c1
-rw-r--r--drivers/media/dvb/frontends/drx397xD.c2
-rw-r--r--drivers/media/dvb/frontends/ix2505v.c323
-rw-r--r--drivers/media/dvb/frontends/ix2505v.h64
-rw-r--r--drivers/media/dvb/frontends/lgdt3304.c380
-rw-r--r--drivers/media/dvb/frontends/lgdt3304.h45
-rw-r--r--drivers/media/dvb/frontends/lgs8gxx.c2
-rw-r--r--drivers/media/dvb/frontends/mt352.c2
-rw-r--r--drivers/media/dvb/frontends/mt352.h2
-rw-r--r--drivers/media/dvb/frontends/s5h1420.c1
-rw-r--r--drivers/media/dvb/frontends/s5h1432.c415
-rw-r--r--drivers/media/dvb/frontends/s5h1432.h91
-rw-r--r--drivers/media/dvb/frontends/si21xx.c2
-rw-r--r--drivers/media/dvb/frontends/stb6100.c2
-rw-r--r--drivers/media/dvb/frontends/stb6100.h4
-rw-r--r--drivers/media/dvb/frontends/stv0288.c25
-rw-r--r--drivers/media/dvb/frontends/stv0299.c2
-rw-r--r--drivers/media/dvb/frontends/stv0299.h2
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c2
-rw-r--r--drivers/media/dvb/frontends/zl10353.c2
-rw-r--r--drivers/media/dvb/mantis/mantis_core.c5
-rw-r--r--drivers/media/dvb/mantis/mantis_i2c.c1
-rw-r--r--drivers/media/dvb/mantis/mantis_ioc.c9
-rw-r--r--drivers/media/dvb/ngene/ngene-i2c.c1
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c1
-rw-r--r--drivers/media/dvb/pt1/pt1.c1
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c3
-rw-r--r--drivers/media/dvb/siano/smsir.c2
-rw-r--r--drivers/media/dvb/ttpci/av7110.c3
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c5
-rw-r--r--drivers/media/dvb/ttpci/budget-core.c2
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c1
59 files changed, 2760 insertions, 1756 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
index fd1df2352764..965d5eb33752 100644
--- a/drivers/media/dvb/b2c2/flexcop-i2c.c
+++ b/drivers/media/dvb/b2c2/flexcop-i2c.c
@@ -245,9 +245,6 @@ int flexcop_i2c_init(struct flexcop_device *fc)
245 i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]); 245 i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]);
246 i2c_set_adapdata(&fc->fc_i2c_adap[2].i2c_adap, &fc->fc_i2c_adap[2]); 246 i2c_set_adapdata(&fc->fc_i2c_adap[2].i2c_adap, &fc->fc_i2c_adap[2]);
247 247
248 fc->fc_i2c_adap[0].i2c_adap.class =
249 fc->fc_i2c_adap[1].i2c_adap.class =
250 fc->fc_i2c_adap[2].i2c_adap.class = I2C_CLASS_TV_DIGITAL;
251 fc->fc_i2c_adap[0].i2c_adap.algo = 248 fc->fc_i2c_adap[0].i2c_adap.algo =
252 fc->fc_i2c_adap[1].i2c_adap.algo = 249 fc->fc_i2c_adap[1].i2c_adap.algo =
253 fc->fc_i2c_adap[2].i2c_adap.algo = &flexcop_algo; 250 fc->fc_i2c_adap[2].i2c_adap.algo = &flexcop_algo;
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index bca07c0bcd01..5d404f1bf036 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -862,7 +862,6 @@ static int __devinit dm1105_probe(struct pci_dev *pdev,
862 i2c_set_adapdata(&dev->i2c_adap, dev); 862 i2c_set_adapdata(&dev->i2c_adap, dev);
863 strcpy(dev->i2c_adap.name, DRIVER_NAME); 863 strcpy(dev->i2c_adap.name, DRIVER_NAME);
864 dev->i2c_adap.owner = THIS_MODULE; 864 dev->i2c_adap.owner = THIS_MODULE;
865 dev->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
866 dev->i2c_adap.dev.parent = &pdev->dev; 865 dev->i2c_adap.dev.parent = &pdev->dev;
867 dev->i2c_adap.algo = &dm1105_algo; 866 dev->i2c_adap.algo = &dm1105_algo;
868 dev->i2c_adap.algo_data = dev; 867 dev->i2c_adap.algo_data = dev;
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 970c9b8882d4..1589d5a5cb46 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -702,7 +702,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
702 702
703 kthread_stop(fepriv->thread); 703 kthread_stop(fepriv->thread);
704 704
705 init_MUTEX (&fepriv->sem); 705 sema_init(&fepriv->sem, 1);
706 fepriv->state = FESTATE_IDLE; 706 fepriv->state = FESTATE_IDLE;
707 707
708 /* paranoia check in case a signal arrived */ 708 /* paranoia check in case a signal arrived */
@@ -2062,7 +2062,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
2062 } 2062 }
2063 fepriv = fe->frontend_priv; 2063 fepriv = fe->frontend_priv;
2064 2064
2065 init_MUTEX (&fepriv->sem); 2065 sema_init(&fepriv->sem, 1);
2066 init_waitqueue_head (&fepriv->wait_queue); 2066 init_waitqueue_head (&fepriv->wait_queue);
2067 init_waitqueue_head (&fepriv->events.wait_queue); 2067 init_waitqueue_head (&fepriv->events.wait_queue);
2068 mutex_init(&fepriv->events.mtx); 2068 mutex_init(&fepriv->events.mtx);
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
index bf0e6bed28dd..f9f19be77181 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -260,7 +260,7 @@ struct dvb_frontend_ops {
260 int (*init)(struct dvb_frontend* fe); 260 int (*init)(struct dvb_frontend* fe);
261 int (*sleep)(struct dvb_frontend* fe); 261 int (*sleep)(struct dvb_frontend* fe);
262 262
263 int (*write)(struct dvb_frontend* fe, u8* buf, int len); 263 int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
264 264
265 /* if this is set, it overrides the default swzigzag */ 265 /* if this is set, it overrides the default swzigzag */
266 int (*tune)(struct dvb_frontend* fe, 266 int (*tune)(struct dvb_frontend* fe,
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index fdc19bba2128..2525d3b3c88d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -314,6 +314,8 @@ config DVB_USB_AF9015
314 select MEDIA_TUNER_TDA18271 if !MEDIA_TUNER_CUSTOMISE 314 select MEDIA_TUNER_TDA18271 if !MEDIA_TUNER_CUSTOMISE
315 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE 315 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE
316 select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE 316 select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE
317 select MEDIA_TUNER_TDA18218 if !MEDIA_TUNER_CUSTOMISE
318 select MEDIA_TUNER_MXL5007T if !MEDIA_TUNER_CUSTOMISE
317 help 319 help
318 Say Y here to support the Afatech AF9015 based DVB-T USB2.0 receiver 320 Say Y here to support the Afatech AF9015 based DVB-T USB2.0 receiver
319 321
@@ -346,3 +348,13 @@ config DVB_USB_AZ6027
346 select DVB_STB6100 if !DVB_FE_CUSTOMISE 348 select DVB_STB6100 if !DVB_FE_CUSTOMISE
347 help 349 help
348 Say Y here to support the AZ6027 device 350 Say Y here to support the AZ6027 device
351
352config DVB_USB_LME2510
353 tristate "LME DM04/QQBOX DVB-S USB2.0 support"
354 depends on DVB_USB
355 select DVB_TDA10086 if !DVB_FE_CUSTOMISE
356 select DVB_TDA826X if !DVB_FE_CUSTOMISE
357 select DVB_STV0288 if !DVB_FE_CUSTOMISE
358 select DVB_IX2505V if !DVB_FE_CUSTOMISE
359 help
360 Say Y here to support the LME DM04/QQBOX DVB-S USB2.0 .
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 1a192453b0e7..5b1d12f2d591 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -88,6 +88,9 @@ obj-$(CONFIG_DVB_USB_EC168) += dvb-usb-ec168.o
88dvb-usb-az6027-objs = az6027.o 88dvb-usb-az6027-objs = az6027.o
89obj-$(CONFIG_DVB_USB_AZ6027) += dvb-usb-az6027.o 89obj-$(CONFIG_DVB_USB_AZ6027) += dvb-usb-az6027.o
90 90
91dvb-usb-lmedm04-objs = lmedm04.o
92obj-$(CONFIG_DVB_USB_LME2510) += dvb-usb-lmedm04.o
93
91EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 94EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
92# due to tuner-xc3028 95# due to tuner-xc3028
93EXTRA_CFLAGS += -Idrivers/media/common/tuners 96EXTRA_CFLAGS += -Idrivers/media/common/tuners
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index ea1ed3b4592a..31c0a0ed39f5 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -31,6 +31,8 @@
31#include "tda18271.h" 31#include "tda18271.h"
32#include "mxl5005s.h" 32#include "mxl5005s.h"
33#include "mc44s803.h" 33#include "mc44s803.h"
34#include "tda18218.h"
35#include "mxl5007t.h"
34 36
35static int dvb_usb_af9015_debug; 37static int dvb_usb_af9015_debug;
36module_param_named(debug, dvb_usb_af9015_debug, int, 0644); 38module_param_named(debug, dvb_usb_af9015_debug, int, 0644);
@@ -205,12 +207,18 @@ static int af9015_write_reg(struct dvb_usb_device *d, u16 addr, u8 val)
205 return af9015_write_regs(d, addr, &val, 1); 207 return af9015_write_regs(d, addr, &val, 1);
206} 208}
207 209
208static int af9015_read_reg(struct dvb_usb_device *d, u16 addr, u8 *val) 210static int af9015_read_regs(struct dvb_usb_device *d, u16 addr, u8 *val, u8 len)
209{ 211{
210 struct req_t req = {READ_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, 1, val}; 212 struct req_t req = {READ_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, len,
213 val};
211 return af9015_ctrl_msg(d, &req); 214 return af9015_ctrl_msg(d, &req);
212} 215}
213 216
217static int af9015_read_reg(struct dvb_usb_device *d, u16 addr, u8 *val)
218{
219 return af9015_read_regs(d, addr, val, 1);
220}
221
214static int af9015_write_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg, 222static int af9015_write_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg,
215 u8 val) 223 u8 val)
216{ 224{
@@ -241,7 +249,7 @@ static int af9015_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
241 struct dvb_usb_device *d = i2c_get_adapdata(adap); 249 struct dvb_usb_device *d = i2c_get_adapdata(adap);
242 int ret = 0, i = 0; 250 int ret = 0, i = 0;
243 u16 addr; 251 u16 addr;
244 u8 mbox, addr_len; 252 u8 uninitialized_var(mbox), addr_len;
245 struct req_t req; 253 struct req_t req;
246 254
247/* TODO: implement bus lock 255/* TODO: implement bus lock
@@ -280,7 +288,7 @@ Due to that the only way to select correct tuner is use demodulator I2C-gate.
280 } else { 288 } else {
281 addr = msg[i].buf[0]; 289 addr = msg[i].buf[0];
282 addr_len = 1; 290 addr_len = 1;
283 mbox = 0; 291 /* mbox is don't care in that case */
284 } 292 }
285 293
286 if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { 294 if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
@@ -494,7 +502,8 @@ static int af9015_copy_firmware(struct dvb_usb_device *d)
494 /* wait 2nd demodulator ready */ 502 /* wait 2nd demodulator ready */
495 msleep(100); 503 msleep(100);
496 504
497 ret = af9015_read_reg_i2c(d, 0x3a, 0x98be, &val); 505 ret = af9015_read_reg_i2c(d,
506 af9015_af9013_config[1].demod_address, 0x98be, &val);
498 if (ret) 507 if (ret)
499 goto error; 508 goto error;
500 else 509 else
@@ -597,37 +606,6 @@ free:
597 return ret; 606 return ret;
598} 607}
599 608
600static int af9015_download_ir_table(struct dvb_usb_device *d)
601{
602 int i, packets = 0, ret;
603 u16 addr = 0x9a56; /* ir-table start address */
604 struct req_t req = {WRITE_MEMORY, 0, 0, 0, 0, 1, NULL};
605 u8 *data = NULL;
606 deb_info("%s:\n", __func__);
607
608 data = af9015_config.ir_table;
609 packets = af9015_config.ir_table_size;
610
611 /* no remote */
612 if (!packets)
613 goto exit;
614
615 /* load remote ir-table */
616 for (i = 0; i < packets; i++) {
617 req.addr = addr + i;
618 req.data = &data[i];
619 ret = af9015_ctrl_msg(d, &req);
620 if (ret) {
621 err("ir-table download failed at packet %d with " \
622 "code %d", i, ret);
623 return ret;
624 }
625 }
626
627exit:
628 return 0;
629}
630
631static int af9015_init(struct dvb_usb_device *d) 609static int af9015_init(struct dvb_usb_device *d)
632{ 610{
633 int ret; 611 int ret;
@@ -637,10 +615,6 @@ static int af9015_init(struct dvb_usb_device *d)
637 if (ret) 615 if (ret)
638 goto error; 616 goto error;
639 617
640 ret = af9015_download_ir_table(d);
641 if (ret)
642 goto error;
643
644error: 618error:
645 return ret; 619 return ret;
646} 620}
@@ -733,125 +707,102 @@ error:
733 return ret; 707 return ret;
734} 708}
735 709
736struct af9015_setup { 710struct af9015_rc_setup {
737 unsigned int id; 711 unsigned int id;
738 struct ir_scancode *rc_key_map; 712 char *rc_codes;
739 unsigned int rc_key_map_size;
740 u8 *ir_table;
741 unsigned int ir_table_size;
742}; 713};
743 714
744static const struct af9015_setup *af9015_setup_match(unsigned int id, 715static char *af9015_rc_setup_match(unsigned int id,
745 const struct af9015_setup *table) 716 const struct af9015_rc_setup *table)
746{ 717{
747 for (; table->rc_key_map; table++) 718 for (; table->rc_codes; table++)
748 if (table->id == id) 719 if (table->id == id)
749 return table; 720 return table->rc_codes;
750 return NULL; 721 return NULL;
751} 722}
752 723
753static const struct af9015_setup af9015_setup_modparam[] = { 724static const struct af9015_rc_setup af9015_rc_setup_modparam[] = {
754 { AF9015_REMOTE_A_LINK_DTU_M, 725 { AF9015_REMOTE_A_LINK_DTU_M, RC_MAP_ALINK_DTU_M },
755 ir_codes_af9015_table_a_link, ARRAY_SIZE(ir_codes_af9015_table_a_link), 726 { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, RC_MAP_MSI_DIGIVOX_II },
756 af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) }, 727 { AF9015_REMOTE_MYGICTV_U718, RC_MAP_TOTAL_MEDIA_IN_HAND },
757 { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, 728 { AF9015_REMOTE_DIGITTRADE_DVB_T, RC_MAP_DIGITTRADE },
758 ir_codes_af9015_table_msi, ARRAY_SIZE(ir_codes_af9015_table_msi), 729 { AF9015_REMOTE_AVERMEDIA_KS, RC_MAP_AVERMEDIA_RM_KS },
759 af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) },
760 { AF9015_REMOTE_MYGICTV_U718,
761 ir_codes_af9015_table_mygictv, ARRAY_SIZE(ir_codes_af9015_table_mygictv),
762 af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) },
763 { AF9015_REMOTE_DIGITTRADE_DVB_T,
764 ir_codes_af9015_table_digittrade, ARRAY_SIZE(ir_codes_af9015_table_digittrade),
765 af9015_ir_table_digittrade, ARRAY_SIZE(af9015_ir_table_digittrade) },
766 { AF9015_REMOTE_AVERMEDIA_KS,
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) },
769 { } 730 { }
770}; 731};
771 732
772/* don't add new entries here anymore, use hashes instead */ 733static const struct af9015_rc_setup af9015_rc_setup_hashes[] = {
773static const struct af9015_setup af9015_setup_usbids[] = { 734 { 0xb8feb708, RC_MAP_MSI_DIGIVOX_II },
774 { USB_VID_LEADTEK, 735 { 0xa3703d00, RC_MAP_ALINK_DTU_M },
775 ir_codes_af9015_table_leadtek, ARRAY_SIZE(ir_codes_af9015_table_leadtek), 736 { 0x9b7dc64e, RC_MAP_TOTAL_MEDIA_IN_HAND }, /* MYGICTV U718 */
776 af9015_ir_table_leadtek, ARRAY_SIZE(af9015_ir_table_leadtek) },
777 { USB_VID_VISIONPLUS,
778 ir_codes_af9015_table_twinhan, ARRAY_SIZE(ir_codes_af9015_table_twinhan),
779 af9015_ir_table_twinhan, ARRAY_SIZE(af9015_ir_table_twinhan) },
780 { USB_VID_KWORLD_2, /* TODO: use correct rc keys */
781 ir_codes_af9015_table_twinhan, ARRAY_SIZE(ir_codes_af9015_table_twinhan),
782 af9015_ir_table_kworld, ARRAY_SIZE(af9015_ir_table_kworld) },
783 { USB_VID_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) },
786 { USB_VID_MSI_2,
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) },
789 { } 737 { }
790}; 738};
791 739
792static const struct af9015_setup af9015_setup_hashes[] = { 740static const struct af9015_rc_setup af9015_rc_setup_usbids[] = {
793 { 0xb8feb708, 741 { (USB_VID_TERRATEC << 16) + USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC,
794 ir_codes_af9015_table_msi, ARRAY_SIZE(ir_codes_af9015_table_msi), 742 RC_MAP_TERRATEC_SLIM },
795 af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) }, 743 { (USB_VID_VISIONPLUS << 16) + USB_PID_AZUREWAVE_AD_TU700,
796 { 0xa3703d00, 744 RC_MAP_AZUREWAVE_AD_TU700 },
797 ir_codes_af9015_table_a_link, ARRAY_SIZE(ir_codes_af9015_table_a_link), 745 { (USB_VID_VISIONPLUS << 16) + USB_PID_TINYTWIN,
798 af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) }, 746 RC_MAP_AZUREWAVE_AD_TU700 },
799 { 0x9b7dc64e, 747 { (USB_VID_MSI_2 << 16) + USB_PID_MSI_DIGI_VOX_MINI_III,
800 ir_codes_af9015_table_mygictv, ARRAY_SIZE(ir_codes_af9015_table_mygictv), 748 RC_MAP_MSI_DIGIVOX_III },
801 af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) }, 749 { (USB_VID_LEADTEK << 16) + USB_PID_WINFAST_DTV_DONGLE_GOLD,
750 RC_MAP_LEADTEK_Y04G0051 },
751 { (USB_VID_AVERMEDIA << 16) + USB_PID_AVERMEDIA_VOLAR_X,
752 RC_MAP_AVERMEDIA_M135A },
753 { (USB_VID_AFATECH << 16) + USB_PID_TREKSTOR_DVBT,
754 RC_MAP_TREKSTOR },
755 { (USB_VID_KWORLD_2 << 16) + USB_PID_TINYTWIN_2,
756 RC_MAP_DIGITALNOW_TINYTWIN },
757 { (USB_VID_GTEK << 16) + USB_PID_TINYTWIN_3,
758 RC_MAP_DIGITALNOW_TINYTWIN },
802 { } 759 { }
803}; 760};
804 761
805static void af9015_set_remote_config(struct usb_device *udev, 762static void af9015_set_remote_config(struct usb_device *udev,
806 struct dvb_usb_device_properties *props) 763 struct dvb_usb_device_properties *props)
807{ 764{
808 const struct af9015_setup *table = NULL; 765 u16 vid = le16_to_cpu(udev->descriptor.idVendor);
809 766 u16 pid = le16_to_cpu(udev->descriptor.idProduct);
810 if (dvb_usb_af9015_remote) { 767
811 /* load remote defined as module param */ 768 /* try to load remote based module param */
812 table = af9015_setup_match(dvb_usb_af9015_remote, 769 props->rc.core.rc_codes = af9015_rc_setup_match(
813 af9015_setup_modparam); 770 dvb_usb_af9015_remote, af9015_rc_setup_modparam);
814 } else { 771
815 u16 vendor = le16_to_cpu(udev->descriptor.idVendor); 772 /* try to load remote based eeprom hash */
816 773 if (!props->rc.core.rc_codes)
817 table = af9015_setup_match(af9015_config.eeprom_sum, 774 props->rc.core.rc_codes = af9015_rc_setup_match(
818 af9015_setup_hashes); 775 af9015_config.eeprom_sum, af9015_rc_setup_hashes);
819 776
820 if (!table && vendor == USB_VID_AFATECH) { 777 /* try to load remote based USB ID */
821 /* Check USB manufacturer and product strings and try 778 if (!props->rc.core.rc_codes)
822 to determine correct remote in case of chip vendor 779 props->rc.core.rc_codes = af9015_rc_setup_match(
823 reference IDs are used. 780 (vid << 16) + pid, af9015_rc_setup_usbids);
824 DO NOT ADD ANYTHING NEW HERE. Use hashes instead. 781
825 */ 782 /* try to load remote based USB iManufacturer string */
826 char manufacturer[10]; 783 if (!props->rc.core.rc_codes && vid == USB_VID_AFATECH) {
827 memset(manufacturer, 0, sizeof(manufacturer)); 784 /* Check USB manufacturer and product strings and try
828 usb_string(udev, udev->descriptor.iManufacturer, 785 to determine correct remote in case of chip vendor
829 manufacturer, sizeof(manufacturer)); 786 reference IDs are used.
830 if (!strcmp("MSI", manufacturer)) { 787 DO NOT ADD ANYTHING NEW HERE. Use hashes instead. */
831 /* iManufacturer 1 MSI 788 char manufacturer[10];
832 iProduct 2 MSI K-VOX */ 789 memset(manufacturer, 0, sizeof(manufacturer));
833 table = af9015_setup_match( 790 usb_string(udev, udev->descriptor.iManufacturer,
834 AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, 791 manufacturer, sizeof(manufacturer));
835 af9015_setup_modparam); 792 if (!strcmp("MSI", manufacturer)) {
836 } else if (udev->descriptor.idProduct == 793 /* iManufacturer 1 MSI
837 cpu_to_le16(USB_PID_TREKSTOR_DVBT)) { 794 iProduct 2 MSI K-VOX */
838 table = &(const struct af9015_setup){ 0, 795 props->rc.core.rc_codes = af9015_rc_setup_match(
839 ir_codes_af9015_table_trekstor, 796 AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
840 ARRAY_SIZE(ir_codes_af9015_table_trekstor), 797 af9015_rc_setup_modparam);
841 af9015_ir_table_trekstor, 798 }
842 ARRAY_SIZE(af9015_ir_table_trekstor)
843 };
844 }
845 } else if (!table)
846 table = af9015_setup_match(vendor, af9015_setup_usbids);
847 } 799 }
848 800
849 if (table) { 801 /* finally load "empty" just for leaving IR receiver enabled */
850 props->rc.legacy.rc_key_map = table->rc_key_map; 802 if (!props->rc.core.rc_codes)
851 props->rc.legacy.rc_key_map_size = table->rc_key_map_size; 803 props->rc.core.rc_codes = RC_MAP_EMPTY;
852 af9015_config.ir_table = table->ir_table; 804
853 af9015_config.ir_table_size = table->ir_table_size; 805 return;
854 }
855} 806}
856 807
857static int af9015_read_config(struct usb_device *udev) 808static int af9015_read_config(struct usb_device *udev)
@@ -877,10 +828,9 @@ static int af9015_read_config(struct usb_device *udev)
877 828
878 deb_info("%s: IR mode:%d\n", __func__, val); 829 deb_info("%s: IR mode:%d\n", __func__, val);
879 for (i = 0; i < af9015_properties_count; i++) { 830 for (i = 0; i < af9015_properties_count; i++) {
880 if (val == AF9015_IR_MODE_DISABLED) { 831 if (val == AF9015_IR_MODE_DISABLED)
881 af9015_properties[i].rc.legacy.rc_key_map = NULL; 832 af9015_properties[i].rc.core.rc_codes = NULL;
882 af9015_properties[i].rc.legacy.rc_key_map_size = 0; 833 else
883 } else
884 af9015_set_remote_config(udev, &af9015_properties[i]); 834 af9015_set_remote_config(udev, &af9015_properties[i]);
885 } 835 }
886 836
@@ -992,20 +942,19 @@ static int af9015_read_config(struct usb_device *udev)
992 case AF9013_TUNER_MT2060_2: 942 case AF9013_TUNER_MT2060_2:
993 case AF9013_TUNER_TDA18271: 943 case AF9013_TUNER_TDA18271:
994 case AF9013_TUNER_QT1010A: 944 case AF9013_TUNER_QT1010A:
945 case AF9013_TUNER_TDA18218:
995 af9015_af9013_config[i].rf_spec_inv = 1; 946 af9015_af9013_config[i].rf_spec_inv = 1;
996 break; 947 break;
997 case AF9013_TUNER_MXL5003D: 948 case AF9013_TUNER_MXL5003D:
998 case AF9013_TUNER_MXL5005D: 949 case AF9013_TUNER_MXL5005D:
999 case AF9013_TUNER_MXL5005R: 950 case AF9013_TUNER_MXL5005R:
951 case AF9013_TUNER_MXL5007T:
1000 af9015_af9013_config[i].rf_spec_inv = 0; 952 af9015_af9013_config[i].rf_spec_inv = 0;
1001 break; 953 break;
1002 case AF9013_TUNER_MC44S803: 954 case AF9013_TUNER_MC44S803:
1003 af9015_af9013_config[i].gpio[1] = AF9013_GPIO_LO; 955 af9015_af9013_config[i].gpio[1] = AF9013_GPIO_LO;
1004 af9015_af9013_config[i].rf_spec_inv = 1; 956 af9015_af9013_config[i].rf_spec_inv = 1;
1005 break; 957 break;
1006 case AF9013_TUNER_TDA18218:
1007 warn("tuner NXP TDA18218 not supported yet");
1008 return -ENODEV;
1009 default: 958 default:
1010 warn("tuner id:%d not supported, please report!", val); 959 warn("tuner id:%d not supported, please report!", val);
1011 return -ENODEV; 960 return -ENODEV;
@@ -1020,9 +969,13 @@ error:
1020 err("eeprom read failed:%d", ret); 969 err("eeprom read failed:%d", ret);
1021 970
1022 /* AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM 971 /* AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM
1023 content :-( Override some wrong values here. */ 972 content :-( Override some wrong values here. Ditto for the
973 AVerTV Red HD+ (A850T) device. */
1024 if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_AVERMEDIA && 974 if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_AVERMEDIA &&
1025 le16_to_cpu(udev->descriptor.idProduct) == USB_PID_AVERMEDIA_A850) { 975 ((le16_to_cpu(udev->descriptor.idProduct) ==
976 USB_PID_AVERMEDIA_A850) ||
977 (le16_to_cpu(udev->descriptor.idProduct) ==
978 USB_PID_AVERMEDIA_A850T))) {
1026 deb_info("%s: AverMedia A850: overriding config\n", __func__); 979 deb_info("%s: AverMedia A850: overriding config\n", __func__);
1027 /* disable dual mode */ 980 /* disable dual mode */
1028 af9015_config.dual_mode = 0; 981 af9015_config.dual_mode = 0;
@@ -1059,36 +1012,53 @@ static int af9015_identify_state(struct usb_device *udev,
1059 return ret; 1012 return ret;
1060} 1013}
1061 1014
1062static int af9015_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 1015static int af9015_rc_query(struct dvb_usb_device *d)
1063{ 1016{
1064 u8 buf[8]; 1017 struct af9015_state *priv = d->priv;
1065 struct req_t req = {GET_IR_CODE, 0, 0, 0, 0, sizeof(buf), buf}; 1018 int ret;
1066 struct ir_scancode *keymap = d->props.rc.legacy.rc_key_map; 1019 u8 buf[16];
1067 int i, ret;
1068
1069 memset(buf, 0, sizeof(buf));
1070 1020
1071 ret = af9015_ctrl_msg(d, &req); 1021 /* read registers needed to detect remote controller code */
1022 ret = af9015_read_regs(d, 0x98d9, buf, sizeof(buf));
1072 if (ret) 1023 if (ret)
1073 return ret; 1024 goto error;
1074 1025
1075 *event = 0; 1026 if (buf[14] || buf[15]) {
1076 *state = REMOTE_NO_KEY_PRESSED; 1027 deb_rc("%s: key pressed %02x %02x %02x %02x\n", __func__,
1028 buf[12], buf[13], buf[14], buf[15]);
1077 1029
1078 for (i = 0; i < d->props.rc.legacy.rc_key_map_size; i++) { 1030 /* clean IR code from mem */
1079 if (!buf[1] && rc5_custom(&keymap[i]) == buf[0] && 1031 ret = af9015_write_regs(d, 0x98e5, "\x00\x00\x00\x00", 4);
1080 rc5_data(&keymap[i]) == buf[2]) { 1032 if (ret)
1081 *event = keymap[i].keycode; 1033 goto error;
1082 *state = REMOTE_KEY_PRESSED; 1034
1083 break; 1035 if (buf[14] == (u8) ~buf[15]) {
1036 if (buf[12] == (u8) ~buf[13]) {
1037 /* NEC */
1038 priv->rc_keycode = buf[12] << 8 | buf[14];
1039 } else {
1040 /* NEC extended*/
1041 priv->rc_keycode = buf[12] << 16 |
1042 buf[13] << 8 | buf[14];
1043 }
1044 ir_keydown(d->rc_input_dev, priv->rc_keycode, 0);
1045 } else {
1046 priv->rc_keycode = 0; /* clear just for sure */
1084 } 1047 }
1048 } else if (priv->rc_repeat != buf[6] || buf[0]) {
1049 deb_rc("%s: key repeated\n", __func__);
1050 ir_keydown(d->rc_input_dev, priv->rc_keycode, 0);
1051 } else {
1052 deb_rc("%s: no key press\n", __func__);
1085 } 1053 }
1086 if (!buf[1])
1087 deb_rc("%s: %02x %02x %02x %02x %02x %02x %02x %02x\n",
1088 __func__, buf[0], buf[1], buf[2], buf[3], buf[4],
1089 buf[5], buf[6], buf[7]);
1090 1054
1091 return 0; 1055 priv->rc_repeat = buf[6];
1056
1057error:
1058 if (ret)
1059 err("%s: failed:%d", __func__, ret);
1060
1061 return ret;
1092} 1062}
1093 1063
1094/* init 2nd I2C adapter */ 1064/* init 2nd I2C adapter */
@@ -1100,11 +1070,6 @@ static int af9015_i2c_init(struct dvb_usb_device *d)
1100 1070
1101 strncpy(state->i2c_adap.name, d->desc->name, 1071 strncpy(state->i2c_adap.name, d->desc->name,
1102 sizeof(state->i2c_adap.name)); 1072 sizeof(state->i2c_adap.name));
1103#ifdef I2C_ADAP_CLASS_TV_DIGITAL
1104 state->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL,
1105#else
1106 state->i2c_adap.class = I2C_CLASS_TV_DIGITAL,
1107#endif
1108 state->i2c_adap.algo = d->props.i2c_algo; 1073 state->i2c_adap.algo = d->props.i2c_algo;
1109 state->i2c_adap.algo_data = NULL; 1074 state->i2c_adap.algo_data = NULL;
1110 state->i2c_adap.dev.parent = &d->udev->dev; 1075 state->i2c_adap.dev.parent = &d->udev->dev;
@@ -1166,7 +1131,7 @@ static struct qt1010_config af9015_qt1010_config = {
1166 1131
1167static struct tda18271_config af9015_tda18271_config = { 1132static struct tda18271_config af9015_tda18271_config = {
1168 .gate = TDA18271_GATE_DIGITAL, 1133 .gate = TDA18271_GATE_DIGITAL,
1169 .small_i2c = 1, 1134 .small_i2c = TDA18271_16_BYTE_CHUNK_INIT,
1170}; 1135};
1171 1136
1172static struct mxl5005s_config af9015_mxl5003_config = { 1137static struct mxl5005s_config af9015_mxl5003_config = {
@@ -1208,12 +1173,22 @@ static struct mc44s803_config af9015_mc44s803_config = {
1208 .dig_out = 1, 1173 .dig_out = 1,
1209}; 1174};
1210 1175
1176static struct tda18218_config af9015_tda18218_config = {
1177 .i2c_address = 0xc0,
1178 .i2c_wr_max = 21, /* max wr bytes AF9015 I2C adap can handle at once */
1179};
1180
1181static struct mxl5007t_config af9015_mxl5007t_config = {
1182 .xtal_freq_hz = MxL_XTAL_24_MHZ,
1183 .if_freq_hz = MxL_IF_4_57_MHZ,
1184};
1185
1211static int af9015_tuner_attach(struct dvb_usb_adapter *adap) 1186static int af9015_tuner_attach(struct dvb_usb_adapter *adap)
1212{ 1187{
1213 struct af9015_state *state = adap->dev->priv; 1188 struct af9015_state *state = adap->dev->priv;
1214 struct i2c_adapter *i2c_adap; 1189 struct i2c_adapter *i2c_adap;
1215 int ret; 1190 int ret;
1216 deb_info("%s: \n", __func__); 1191 deb_info("%s:\n", __func__);
1217 1192
1218 /* select I2C adapter */ 1193 /* select I2C adapter */
1219 if (adap->id == 0) 1194 if (adap->id == 0)
@@ -1238,6 +1213,10 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap)
1238 ret = dvb_attach(tda18271_attach, adap->fe, 0xc0, i2c_adap, 1213 ret = dvb_attach(tda18271_attach, adap->fe, 0xc0, i2c_adap,
1239 &af9015_tda18271_config) == NULL ? -ENODEV : 0; 1214 &af9015_tda18271_config) == NULL ? -ENODEV : 0;
1240 break; 1215 break;
1216 case AF9013_TUNER_TDA18218:
1217 ret = dvb_attach(tda18218_attach, adap->fe, i2c_adap,
1218 &af9015_tda18218_config) == NULL ? -ENODEV : 0;
1219 break;
1241 case AF9013_TUNER_MXL5003D: 1220 case AF9013_TUNER_MXL5003D:
1242 ret = dvb_attach(mxl5005s_attach, adap->fe, i2c_adap, 1221 ret = dvb_attach(mxl5005s_attach, adap->fe, i2c_adap,
1243 &af9015_mxl5003_config) == NULL ? -ENODEV : 0; 1222 &af9015_mxl5003_config) == NULL ? -ENODEV : 0;
@@ -1255,6 +1234,10 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap)
1255 ret = dvb_attach(mc44s803_attach, adap->fe, i2c_adap, 1234 ret = dvb_attach(mc44s803_attach, adap->fe, i2c_adap,
1256 &af9015_mc44s803_config) == NULL ? -ENODEV : 0; 1235 &af9015_mc44s803_config) == NULL ? -ENODEV : 0;
1257 break; 1236 break;
1237 case AF9013_TUNER_MXL5007T:
1238 ret = dvb_attach(mxl5007t_attach, adap->fe, i2c_adap,
1239 0xc0, &af9015_mxl5007t_config) == NULL ? -ENODEV : 0;
1240 break;
1258 case AF9013_TUNER_UNKNOWN: 1241 case AF9013_TUNER_UNKNOWN:
1259 default: 1242 default:
1260 ret = -ENODEV; 1243 ret = -ENODEV;
@@ -1300,10 +1283,16 @@ static struct usb_device_id af9015_usb_table[] = {
1300/* 30 */{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB383_T)}, 1283/* 30 */{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB383_T)},
1301 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_4)}, 1284 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_4)},
1302 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A815M)}, 1285 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A815M)},
1286 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_RC)},
1287 {USB_DEVICE(USB_VID_TERRATEC,
1288 USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC)},
1289/* 35 */{USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850T)},
1290 {USB_DEVICE(USB_VID_GTEK, USB_PID_TINYTWIN_3)},
1303 {0}, 1291 {0},
1304}; 1292};
1305MODULE_DEVICE_TABLE(usb, af9015_usb_table); 1293MODULE_DEVICE_TABLE(usb, af9015_usb_table);
1306 1294
1295#define AF9015_RC_INTERVAL 500
1307static struct dvb_usb_device_properties af9015_properties[] = { 1296static struct dvb_usb_device_properties af9015_properties[] = {
1308 { 1297 {
1309 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1298 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
@@ -1354,14 +1343,19 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1354 1343
1355 .identify_state = af9015_identify_state, 1344 .identify_state = af9015_identify_state,
1356 1345
1357 .rc.legacy = { 1346 .rc.core = {
1347 .protocol = IR_TYPE_NEC,
1348 .module_name = "af9015",
1358 .rc_query = af9015_rc_query, 1349 .rc_query = af9015_rc_query,
1359 .rc_interval = 150, 1350 .rc_interval = AF9015_RC_INTERVAL,
1351 .rc_props = {
1352 .allowed_protos = IR_TYPE_NEC,
1353 },
1360 }, 1354 },
1361 1355
1362 .i2c_algo = &af9015_i2c_algo, 1356 .i2c_algo = &af9015_i2c_algo,
1363 1357
1364 .num_device_descs = 9, /* max 9 */ 1358 .num_device_descs = 12, /* check max from dvb-usb.h */
1365 .devices = { 1359 .devices = {
1366 { 1360 {
1367 .name = "Afatech AF9015 DVB-T USB2.0 stick", 1361 .name = "Afatech AF9015 DVB-T USB2.0 stick",
@@ -1389,7 +1383,8 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1389 { 1383 {
1390 .name = "DigitalNow TinyTwin DVB-T Receiver", 1384 .name = "DigitalNow TinyTwin DVB-T Receiver",
1391 .cold_ids = {&af9015_usb_table[5], 1385 .cold_ids = {&af9015_usb_table[5],
1392 &af9015_usb_table[28], NULL}, 1386 &af9015_usb_table[28],
1387 &af9015_usb_table[36], NULL},
1393 .warm_ids = {NULL}, 1388 .warm_ids = {NULL},
1394 }, 1389 },
1395 { 1390 {
@@ -1413,6 +1408,21 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1413 .cold_ids = {&af9015_usb_table[9], NULL}, 1408 .cold_ids = {&af9015_usb_table[9], NULL},
1414 .warm_ids = {NULL}, 1409 .warm_ids = {NULL},
1415 }, 1410 },
1411 {
1412 .name = "TerraTec Cinergy T Stick RC",
1413 .cold_ids = {&af9015_usb_table[33], NULL},
1414 .warm_ids = {NULL},
1415 },
1416 {
1417 .name = "TerraTec Cinergy T Stick Dual RC",
1418 .cold_ids = {&af9015_usb_table[34], NULL},
1419 .warm_ids = {NULL},
1420 },
1421 {
1422 .name = "AverMedia AVerTV Red HD+ (A850T)",
1423 .cold_ids = {&af9015_usb_table[35], NULL},
1424 .warm_ids = {NULL},
1425 },
1416 } 1426 }
1417 }, { 1427 }, {
1418 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1428 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
@@ -1463,14 +1473,19 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1463 1473
1464 .identify_state = af9015_identify_state, 1474 .identify_state = af9015_identify_state,
1465 1475
1466 .rc.legacy = { 1476 .rc.core = {
1477 .protocol = IR_TYPE_NEC,
1478 .module_name = "af9015",
1467 .rc_query = af9015_rc_query, 1479 .rc_query = af9015_rc_query,
1468 .rc_interval = 150, 1480 .rc_interval = AF9015_RC_INTERVAL,
1481 .rc_props = {
1482 .allowed_protos = IR_TYPE_NEC,
1483 },
1469 }, 1484 },
1470 1485
1471 .i2c_algo = &af9015_i2c_algo, 1486 .i2c_algo = &af9015_i2c_algo,
1472 1487
1473 .num_device_descs = 9, /* max 9 */ 1488 .num_device_descs = 9, /* check max from dvb-usb.h */
1474 .devices = { 1489 .devices = {
1475 { 1490 {
1476 .name = "Xtensions XD-380", 1491 .name = "Xtensions XD-380",
@@ -1572,14 +1587,19 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1572 1587
1573 .identify_state = af9015_identify_state, 1588 .identify_state = af9015_identify_state,
1574 1589
1575 .rc.legacy = { 1590 .rc.core = {
1591 .protocol = IR_TYPE_NEC,
1592 .module_name = "af9015",
1576 .rc_query = af9015_rc_query, 1593 .rc_query = af9015_rc_query,
1577 .rc_interval = 150, 1594 .rc_interval = AF9015_RC_INTERVAL,
1595 .rc_props = {
1596 .allowed_protos = IR_TYPE_NEC,
1597 },
1578 }, 1598 },
1579 1599
1580 .i2c_algo = &af9015_i2c_algo, 1600 .i2c_algo = &af9015_i2c_algo,
1581 1601
1582 .num_device_descs = 9, /* max 9 */ 1602 .num_device_descs = 9, /* check max from dvb-usb.h */
1583 .devices = { 1603 .devices = {
1584 { 1604 {
1585 .name = "AverMedia AVerTV Volar GPS 805 (A805)", 1605 .name = "AverMedia AVerTV Volar GPS 805 (A805)",
@@ -1672,7 +1692,7 @@ static int af9015_usb_probe(struct usb_interface *intf,
1672static void af9015_i2c_exit(struct dvb_usb_device *d) 1692static void af9015_i2c_exit(struct dvb_usb_device *d)
1673{ 1693{
1674 struct af9015_state *state = d->priv; 1694 struct af9015_state *state = d->priv;
1675 deb_info("%s: \n", __func__); 1695 deb_info("%s:\n", __func__);
1676 1696
1677 /* remove 2nd I2C adapter */ 1697 /* remove 2nd I2C adapter */
1678 if (d->state & DVB_USB_STATE_I2C) 1698 if (d->state & DVB_USB_STATE_I2C)
@@ -1682,7 +1702,7 @@ static void af9015_i2c_exit(struct dvb_usb_device *d)
1682static void af9015_usb_device_exit(struct usb_interface *intf) 1702static void af9015_usb_device_exit(struct usb_interface *intf)
1683{ 1703{
1684 struct dvb_usb_device *d = usb_get_intfdata(intf); 1704 struct dvb_usb_device *d = usb_get_intfdata(intf);
1685 deb_info("%s: \n", __func__); 1705 deb_info("%s:\n", __func__);
1686 1706
1687 /* remove 2nd I2C adapter */ 1707 /* remove 2nd I2C adapter */
1688 if (d != NULL && d->desc != NULL) 1708 if (d != NULL && d->desc != NULL)
diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h
index c8e9349742ee..f20cfa6ed690 100644
--- a/drivers/media/dvb/dvb-usb/af9015.h
+++ b/drivers/media/dvb/dvb-usb/af9015.h
@@ -100,6 +100,8 @@ enum af9015_ir_mode {
100 100
101struct af9015_state { 101struct af9015_state {
102 struct i2c_adapter i2c_adap; /* I2C adapter for 2nd FE */ 102 struct i2c_adapter i2c_adap; /* I2C adapter for 2nd FE */
103 u8 rc_repeat;
104 u32 rc_keycode;
103}; 105};
104 106
105struct af9015_config { 107struct af9015_config {
@@ -108,8 +110,6 @@ struct af9015_config {
108 u16 firmware_size; 110 u16 firmware_size;
109 u16 firmware_checksum; 111 u16 firmware_checksum;
110 u32 eeprom_sum; 112 u32 eeprom_sum;
111 u8 *ir_table;
112 u16 ir_table_size;
113}; 113};
114 114
115enum af9015_remote { 115enum af9015_remote {
@@ -121,735 +121,4 @@ enum af9015_remote {
121/* 5 */ AF9015_REMOTE_AVERMEDIA_KS, 121/* 5 */ AF9015_REMOTE_AVERMEDIA_KS,
122}; 122};
123 123
124/* LeadTek - Y04G0051 */
125/* Leadtek WinFast DTV Dongle Gold */
126static struct ir_scancode ir_codes_af9015_table_leadtek[] = {
127 { 0x001e, KEY_1 },
128 { 0x001f, KEY_2 },
129 { 0x0020, KEY_3 },
130 { 0x0021, KEY_4 },
131 { 0x0022, KEY_5 },
132 { 0x0023, KEY_6 },
133 { 0x0024, KEY_7 },
134 { 0x0025, KEY_8 },
135 { 0x0026, KEY_9 },
136 { 0x0027, KEY_0 },
137 { 0x0028, KEY_OK },
138 { 0x004f, KEY_RIGHT },
139 { 0x0050, KEY_LEFT },
140 { 0x0051, KEY_DOWN },
141 { 0x0052, KEY_UP },
142 { 0x011a, KEY_POWER2 },
143 { 0x04b4, KEY_TV },
144 { 0x04b3, KEY_RED },
145 { 0x04b2, KEY_GREEN },
146 { 0x04b1, KEY_YELLOW },
147 { 0x04b0, KEY_BLUE },
148 { 0x003d, KEY_TEXT },
149 { 0x0113, KEY_SLEEP },
150 { 0x0010, KEY_MUTE },
151 { 0x0105, KEY_ESC },
152 { 0x0009, KEY_SCREEN },
153 { 0x010f, KEY_MENU },
154 { 0x003f, KEY_CHANNEL },
155 { 0x0013, KEY_REWIND },
156 { 0x0012, KEY_PLAY },
157 { 0x0011, KEY_FASTFORWARD },
158 { 0x0005, KEY_PREVIOUS },
159 { 0x0029, KEY_STOP },
160 { 0x002b, KEY_NEXT },
161 { 0x0041, KEY_EPG },
162 { 0x0019, KEY_VIDEO },
163 { 0x0016, KEY_AUDIO },
164 { 0x0037, KEY_DOT },
165 { 0x002a, KEY_AGAIN },
166 { 0x002c, KEY_CAMERA },
167 { 0x003c, KEY_NEW },
168 { 0x0115, KEY_RECORD },
169 { 0x010b, KEY_TIME },
170 { 0x0043, KEY_VOLUMEUP },
171 { 0x0042, KEY_VOLUMEDOWN },
172 { 0x004b, KEY_CHANNELUP },
173 { 0x004e, KEY_CHANNELDOWN },
174};
175
176static u8 af9015_ir_table_leadtek[] = {
177 0x03, 0xfc, 0x00, 0xff, 0x1a, 0x01, 0x00, /* KEY_POWER2 */
178 0x03, 0xfc, 0x56, 0xa9, 0xb4, 0x04, 0x00, /* KEY_TV */
179 0x03, 0xfc, 0x4b, 0xb4, 0xb3, 0x04, 0x00, /* KEY_RED */
180 0x03, 0xfc, 0x4c, 0xb3, 0xb2, 0x04, 0x00, /* KEY_GREEN */
181 0x03, 0xfc, 0x4d, 0xb2, 0xb1, 0x04, 0x00, /* KEY_YELLOW */
182 0x03, 0xfc, 0x4e, 0xb1, 0xb0, 0x04, 0x00, /* KEY_BLUE */
183 0x03, 0xfc, 0x1f, 0xe0, 0x3d, 0x00, 0x00, /* KEY_TEXT */
184 0x03, 0xfc, 0x40, 0xbf, 0x13, 0x01, 0x00, /* KEY_SLEEP */
185 0x03, 0xfc, 0x14, 0xeb, 0x10, 0x00, 0x00, /* KEY_MUTE */
186 0x03, 0xfc, 0x49, 0xb6, 0x05, 0x01, 0x00, /* KEY_ESC */
187 0x03, 0xfc, 0x50, 0xaf, 0x29, 0x00, 0x00, /* KEY_STOP (1)*/
188 0x03, 0xfc, 0x0c, 0xf3, 0x52, 0x00, 0x00, /* KEY_UP */
189 0x03, 0xfc, 0x03, 0xfc, 0x09, 0x00, 0x00, /* KEY_SCREEN */
190 0x03, 0xfc, 0x08, 0xf7, 0x50, 0x00, 0x00, /* KEY_LEFT */
191 0x03, 0xfc, 0x13, 0xec, 0x28, 0x00, 0x00, /* KEY_OK (1) */
192 0x03, 0xfc, 0x04, 0xfb, 0x4f, 0x00, 0x00, /* KEY_RIGHT */
193 0x03, 0xfc, 0x4f, 0xb0, 0x0f, 0x01, 0x00, /* KEY_MENU */
194 0x03, 0xfc, 0x10, 0xef, 0x51, 0x00, 0x00, /* KEY_DOWN */
195 0x03, 0xfc, 0x51, 0xae, 0x3f, 0x00, 0x00, /* KEY_CHANNEL */
196 0x03, 0xfc, 0x42, 0xbd, 0x13, 0x00, 0x00, /* KEY_REWIND */
197 0x03, 0xfc, 0x43, 0xbc, 0x12, 0x00, 0x00, /* KEY_PLAY */
198 0x03, 0xfc, 0x44, 0xbb, 0x11, 0x00, 0x00, /* KEY_FASTFORWARD */
199 0x03, 0xfc, 0x52, 0xad, 0x19, 0x00, 0x00, /* KEY_VIDEO (1) */
200 0x03, 0xfc, 0x54, 0xab, 0x05, 0x00, 0x00, /* KEY_PREVIOUS */
201 0x03, 0xfc, 0x46, 0xb9, 0x29, 0x00, 0x00, /* KEY_STOP (2) */
202 0x03, 0xfc, 0x55, 0xaa, 0x2b, 0x00, 0x00, /* KEY_NEXT */
203 0x03, 0xfc, 0x53, 0xac, 0x41, 0x00, 0x00, /* KEY_EPG */
204 0x03, 0xfc, 0x05, 0xfa, 0x1e, 0x00, 0x00, /* KEY_1 */
205 0x03, 0xfc, 0x06, 0xf9, 0x1f, 0x00, 0x00, /* KEY_2 */
206 0x03, 0xfc, 0x07, 0xf8, 0x20, 0x00, 0x00, /* KEY_3 */
207 0x03, 0xfc, 0x1e, 0xe1, 0x19, 0x00, 0x00, /* KEY_VIDEO (2) */
208 0x03, 0xfc, 0x09, 0xf6, 0x21, 0x00, 0x00, /* KEY_4 */
209 0x03, 0xfc, 0x0a, 0xf5, 0x22, 0x00, 0x00, /* KEY_5 */
210 0x03, 0xfc, 0x0b, 0xf4, 0x23, 0x00, 0x00, /* KEY_6 */
211 0x03, 0xfc, 0x1b, 0xe4, 0x16, 0x00, 0x00, /* KEY_AUDIO */
212 0x03, 0xfc, 0x0d, 0xf2, 0x24, 0x00, 0x00, /* KEY_7 */
213 0x03, 0xfc, 0x0e, 0xf1, 0x25, 0x00, 0x00, /* KEY_8 */
214 0x03, 0xfc, 0x0f, 0xf0, 0x26, 0x00, 0x00, /* KEY_9 */
215 0x03, 0xfc, 0x16, 0xe9, 0x28, 0x00, 0x00, /* KEY_OK (2) */
216 0x03, 0xfc, 0x41, 0xbe, 0x37, 0x00, 0x00, /* KEY_DOT */
217 0x03, 0xfc, 0x12, 0xed, 0x27, 0x00, 0x00, /* KEY_0 */
218 0x03, 0xfc, 0x11, 0xee, 0x2a, 0x00, 0x00, /* KEY_AGAIN */
219 0x03, 0xfc, 0x48, 0xb7, 0x2c, 0x00, 0x00, /* KEY_CAMERA */
220 0x03, 0xfc, 0x4a, 0xb5, 0x3c, 0x00, 0x00, /* KEY_NEW */
221 0x03, 0xfc, 0x47, 0xb8, 0x15, 0x01, 0x00, /* KEY_RECORD */
222 0x03, 0xfc, 0x45, 0xba, 0x0b, 0x01, 0x00, /* KEY_TIME */
223 0x03, 0xfc, 0x5e, 0xa1, 0x43, 0x00, 0x00, /* KEY_VOLUMEUP */
224 0x03, 0xfc, 0x5a, 0xa5, 0x42, 0x00, 0x00, /* KEY_VOLUMEDOWN */
225 0x03, 0xfc, 0x5b, 0xa4, 0x4b, 0x00, 0x00, /* KEY_CHANNELUP */
226 0x03, 0xfc, 0x5f, 0xa0, 0x4e, 0x00, 0x00, /* KEY_CHANNELDOWN */
227};
228
229/* TwinHan AzureWave AD-TU700(704J) */
230static struct ir_scancode ir_codes_af9015_table_twinhan[] = {
231 { 0x053f, KEY_POWER },
232 { 0x0019, KEY_FAVORITES }, /* Favorite List */
233 { 0x0004, KEY_TEXT }, /* Teletext */
234 { 0x000e, KEY_POWER },
235 { 0x000e, KEY_INFO }, /* Preview */
236 { 0x0008, KEY_EPG }, /* Info/EPG */
237 { 0x000f, KEY_LIST }, /* Record List */
238 { 0x001e, KEY_1 },
239 { 0x001f, KEY_2 },
240 { 0x0020, KEY_3 },
241 { 0x0021, KEY_4 },
242 { 0x0022, KEY_5 },
243 { 0x0023, KEY_6 },
244 { 0x0024, KEY_7 },
245 { 0x0025, KEY_8 },
246 { 0x0026, KEY_9 },
247 { 0x0027, KEY_0 },
248 { 0x0029, KEY_CANCEL }, /* Cancel */
249 { 0x004c, KEY_CLEAR }, /* Clear */
250 { 0x002a, KEY_BACK }, /* Back */
251 { 0x002b, KEY_TAB }, /* Tab */
252 { 0x0052, KEY_UP }, /* up arrow */
253 { 0x0051, KEY_DOWN }, /* down arrow */
254 { 0x004f, KEY_RIGHT }, /* right arrow */
255 { 0x0050, KEY_LEFT }, /* left arrow */
256 { 0x0028, KEY_ENTER }, /* Enter / ok */
257 { 0x0252, KEY_VOLUMEUP },
258 { 0x0251, KEY_VOLUMEDOWN },
259 { 0x004e, KEY_CHANNELDOWN },
260 { 0x004b, KEY_CHANNELUP },
261 { 0x004a, KEY_RECORD },
262 { 0x0111, KEY_PLAY },
263 { 0x0017, KEY_PAUSE },
264 { 0x000c, KEY_REWIND }, /* FR << */
265 { 0x0011, KEY_FASTFORWARD }, /* FF >> */
266 { 0x0115, KEY_PREVIOUS }, /* Replay */
267 { 0x010e, KEY_NEXT }, /* Skip */
268 { 0x0013, KEY_CAMERA }, /* Capture */
269 { 0x010f, KEY_LANGUAGE }, /* SAP */
270 { 0x0113, KEY_TV2 }, /* PIP */
271 { 0x001d, KEY_ZOOM }, /* Full Screen */
272 { 0x0117, KEY_SUBTITLE }, /* Subtitle / CC */
273 { 0x0010, KEY_MUTE },
274 { 0x0119, KEY_AUDIO }, /* L/R */ /* TODO better event */
275 { 0x0116, KEY_SLEEP }, /* Hibernate */
276 { 0x0116, KEY_SWITCHVIDEOMODE },
277 /* A/V */ /* TODO does not work */
278 { 0x0006, KEY_AGAIN }, /* Recall */
279 { 0x0116, KEY_KPPLUS }, /* Zoom+ */ /* TODO does not work */
280 { 0x0116, KEY_KPMINUS }, /* Zoom- */ /* TODO does not work */
281 { 0x0215, KEY_RED },
282 { 0x020a, KEY_GREEN },
283 { 0x021c, KEY_YELLOW },
284 { 0x0205, KEY_BLUE },
285};
286
287static u8 af9015_ir_table_twinhan[] = {
288 0x00, 0xff, 0x16, 0xe9, 0x3f, 0x05, 0x00,
289 0x00, 0xff, 0x07, 0xf8, 0x16, 0x01, 0x00,
290 0x00, 0xff, 0x14, 0xeb, 0x11, 0x01, 0x00,
291 0x00, 0xff, 0x1a, 0xe5, 0x4d, 0x00, 0x00,
292 0x00, 0xff, 0x4c, 0xb3, 0x17, 0x00, 0x00,
293 0x00, 0xff, 0x12, 0xed, 0x11, 0x00, 0x00,
294 0x00, 0xff, 0x40, 0xbf, 0x0c, 0x00, 0x00,
295 0x00, 0xff, 0x11, 0xee, 0x4a, 0x00, 0x00,
296 0x00, 0xff, 0x54, 0xab, 0x13, 0x00, 0x00,
297 0x00, 0xff, 0x41, 0xbe, 0x15, 0x01, 0x00,
298 0x00, 0xff, 0x42, 0xbd, 0x0e, 0x01, 0x00,
299 0x00, 0xff, 0x43, 0xbc, 0x17, 0x01, 0x00,
300 0x00, 0xff, 0x50, 0xaf, 0x0f, 0x01, 0x00,
301 0x00, 0xff, 0x4d, 0xb2, 0x1d, 0x00, 0x00,
302 0x00, 0xff, 0x47, 0xb8, 0x13, 0x01, 0x00,
303 0x00, 0xff, 0x05, 0xfa, 0x4b, 0x00, 0x00,
304 0x00, 0xff, 0x02, 0xfd, 0x4e, 0x00, 0x00,
305 0x00, 0xff, 0x0e, 0xf1, 0x06, 0x00, 0x00,
306 0x00, 0xff, 0x1e, 0xe1, 0x52, 0x02, 0x00,
307 0x00, 0xff, 0x0a, 0xf5, 0x51, 0x02, 0x00,
308 0x00, 0xff, 0x10, 0xef, 0x10, 0x00, 0x00,
309 0x00, 0xff, 0x49, 0xb6, 0x19, 0x01, 0x00,
310 0x00, 0xff, 0x15, 0xea, 0x27, 0x00, 0x00,
311 0x00, 0xff, 0x03, 0xfc, 0x1e, 0x00, 0x00,
312 0x00, 0xff, 0x01, 0xfe, 0x1f, 0x00, 0x00,
313 0x00, 0xff, 0x06, 0xf9, 0x20, 0x00, 0x00,
314 0x00, 0xff, 0x09, 0xf6, 0x21, 0x00, 0x00,
315 0x00, 0xff, 0x1d, 0xe2, 0x22, 0x00, 0x00,
316 0x00, 0xff, 0x1f, 0xe0, 0x23, 0x00, 0x00,
317 0x00, 0xff, 0x0d, 0xf2, 0x24, 0x00, 0x00,
318 0x00, 0xff, 0x19, 0xe6, 0x25, 0x00, 0x00,
319 0x00, 0xff, 0x1b, 0xe4, 0x26, 0x00, 0x00,
320 0x00, 0xff, 0x00, 0xff, 0x2b, 0x00, 0x00,
321 0x00, 0xff, 0x4a, 0xb5, 0x4c, 0x00, 0x00,
322 0x00, 0xff, 0x4b, 0xb4, 0x52, 0x00, 0x00,
323 0x00, 0xff, 0x51, 0xae, 0x51, 0x00, 0x00,
324 0x00, 0xff, 0x52, 0xad, 0x4f, 0x00, 0x00,
325 0x00, 0xff, 0x4e, 0xb1, 0x50, 0x00, 0x00,
326 0x00, 0xff, 0x0c, 0xf3, 0x29, 0x00, 0x00,
327 0x00, 0xff, 0x4f, 0xb0, 0x28, 0x00, 0x00,
328 0x00, 0xff, 0x13, 0xec, 0x2a, 0x00, 0x00,
329 0x00, 0xff, 0x17, 0xe8, 0x19, 0x00, 0x00,
330 0x00, 0xff, 0x04, 0xfb, 0x0f, 0x00, 0x00,
331 0x00, 0xff, 0x48, 0xb7, 0x0e, 0x00, 0x00,
332 0x00, 0xff, 0x0f, 0xf0, 0x04, 0x00, 0x00,
333 0x00, 0xff, 0x1c, 0xe3, 0x08, 0x00, 0x00,
334 0x00, 0xff, 0x18, 0xe7, 0x15, 0x02, 0x00,
335 0x00, 0xff, 0x53, 0xac, 0x0a, 0x02, 0x00,
336 0x00, 0xff, 0x5e, 0xa1, 0x1c, 0x02, 0x00,
337 0x00, 0xff, 0x5f, 0xa0, 0x05, 0x02, 0x00,
338};
339
340/* A-Link DTU(m) */
341static struct ir_scancode ir_codes_af9015_table_a_link[] = {
342 { 0x001e, KEY_1 },
343 { 0x001f, KEY_2 },
344 { 0x0020, KEY_3 },
345 { 0x0021, KEY_4 },
346 { 0x0022, KEY_5 },
347 { 0x0023, KEY_6 },
348 { 0x0024, KEY_7 },
349 { 0x0025, KEY_8 },
350 { 0x0026, KEY_9 },
351 { 0x0027, KEY_0 },
352 { 0x002e, KEY_CHANNELUP },
353 { 0x002d, KEY_CHANNELDOWN },
354 { 0x0428, KEY_ZOOM },
355 { 0x0041, KEY_MUTE },
356 { 0x0042, KEY_VOLUMEDOWN },
357 { 0x0043, KEY_VOLUMEUP },
358 { 0x0044, KEY_GOTO }, /* jump */
359 { 0x0545, KEY_POWER },
360};
361
362static u8 af9015_ir_table_a_link[] = {
363 0x08, 0xf7, 0x12, 0xed, 0x45, 0x05, 0x00, /* power */
364 0x08, 0xf7, 0x1a, 0xe5, 0x41, 0x00, 0x00, /* mute */
365 0x08, 0xf7, 0x01, 0xfe, 0x1e, 0x00, 0x00, /* 1 */
366 0x08, 0xf7, 0x1c, 0xe3, 0x21, 0x00, 0x00, /* 4 */
367 0x08, 0xf7, 0x03, 0xfc, 0x24, 0x00, 0x00, /* 7 */
368 0x08, 0xf7, 0x05, 0xfa, 0x28, 0x04, 0x00, /* zoom */
369 0x08, 0xf7, 0x00, 0xff, 0x43, 0x00, 0x00, /* volume up */
370 0x08, 0xf7, 0x16, 0xe9, 0x42, 0x00, 0x00, /* volume down */
371 0x08, 0xf7, 0x0f, 0xf0, 0x1f, 0x00, 0x00, /* 2 */
372 0x08, 0xf7, 0x0d, 0xf2, 0x22, 0x00, 0x00, /* 5 */
373 0x08, 0xf7, 0x1b, 0xe4, 0x25, 0x00, 0x00, /* 8 */
374 0x08, 0xf7, 0x06, 0xf9, 0x27, 0x00, 0x00, /* 0 */
375 0x08, 0xf7, 0x14, 0xeb, 0x2e, 0x00, 0x00, /* channel up */
376 0x08, 0xf7, 0x1d, 0xe2, 0x2d, 0x00, 0x00, /* channel down */
377 0x08, 0xf7, 0x02, 0xfd, 0x20, 0x00, 0x00, /* 3 */
378 0x08, 0xf7, 0x18, 0xe7, 0x23, 0x00, 0x00, /* 6 */
379 0x08, 0xf7, 0x04, 0xfb, 0x26, 0x00, 0x00, /* 9 */
380 0x08, 0xf7, 0x07, 0xf8, 0x44, 0x00, 0x00, /* jump */
381};
382
383/* MSI DIGIVOX mini II V3.0 */
384static struct ir_scancode ir_codes_af9015_table_msi[] = {
385 { 0x001e, KEY_1 },
386 { 0x001f, KEY_2 },
387 { 0x0020, KEY_3 },
388 { 0x0021, KEY_4 },
389 { 0x0022, KEY_5 },
390 { 0x0023, KEY_6 },
391 { 0x0024, KEY_7 },
392 { 0x0025, KEY_8 },
393 { 0x0026, KEY_9 },
394 { 0x0027, KEY_0 },
395 { 0x030f, KEY_CHANNELUP },
396 { 0x030e, KEY_CHANNELDOWN },
397 { 0x0042, KEY_VOLUMEDOWN },
398 { 0x0043, KEY_VOLUMEUP },
399 { 0x0545, KEY_POWER },
400 { 0x0052, KEY_UP }, /* up */
401 { 0x0051, KEY_DOWN }, /* down */
402 { 0x0028, KEY_ENTER },
403};
404
405static u8 af9015_ir_table_msi[] = {
406 0x03, 0xfc, 0x17, 0xe8, 0x45, 0x05, 0x00, /* power */
407 0x03, 0xfc, 0x0d, 0xf2, 0x51, 0x00, 0x00, /* down */
408 0x03, 0xfc, 0x03, 0xfc, 0x52, 0x00, 0x00, /* up */
409 0x03, 0xfc, 0x1a, 0xe5, 0x1e, 0x00, 0x00, /* 1 */
410 0x03, 0xfc, 0x02, 0xfd, 0x1f, 0x00, 0x00, /* 2 */
411 0x03, 0xfc, 0x04, 0xfb, 0x20, 0x00, 0x00, /* 3 */
412 0x03, 0xfc, 0x1c, 0xe3, 0x21, 0x00, 0x00, /* 4 */
413 0x03, 0xfc, 0x08, 0xf7, 0x22, 0x00, 0x00, /* 5 */
414 0x03, 0xfc, 0x1d, 0xe2, 0x23, 0x00, 0x00, /* 6 */
415 0x03, 0xfc, 0x11, 0xee, 0x24, 0x00, 0x00, /* 7 */
416 0x03, 0xfc, 0x0b, 0xf4, 0x25, 0x00, 0x00, /* 8 */
417 0x03, 0xfc, 0x10, 0xef, 0x26, 0x00, 0x00, /* 9 */
418 0x03, 0xfc, 0x09, 0xf6, 0x27, 0x00, 0x00, /* 0 */
419 0x03, 0xfc, 0x14, 0xeb, 0x43, 0x00, 0x00, /* volume up */
420 0x03, 0xfc, 0x1f, 0xe0, 0x42, 0x00, 0x00, /* volume down */
421 0x03, 0xfc, 0x15, 0xea, 0x0f, 0x03, 0x00, /* channel up */
422 0x03, 0xfc, 0x05, 0xfa, 0x0e, 0x03, 0x00, /* channel down */
423 0x03, 0xfc, 0x16, 0xe9, 0x28, 0x00, 0x00, /* enter */
424};
425
426/* MYGICTV U718 */
427static struct ir_scancode ir_codes_af9015_table_mygictv[] = {
428 { 0x003d, KEY_SWITCHVIDEOMODE },
429 /* TV / AV */
430 { 0x0545, KEY_POWER },
431 { 0x001e, KEY_1 },
432 { 0x001f, KEY_2 },
433 { 0x0020, KEY_3 },
434 { 0x0021, KEY_4 },
435 { 0x0022, KEY_5 },
436 { 0x0023, KEY_6 },
437 { 0x0024, KEY_7 },
438 { 0x0025, KEY_8 },
439 { 0x0026, KEY_9 },
440 { 0x0027, KEY_0 },
441 { 0x0041, KEY_MUTE },
442 { 0x002a, KEY_ESC }, /* Esc */
443 { 0x002e, KEY_CHANNELUP },
444 { 0x002d, KEY_CHANNELDOWN },
445 { 0x0042, KEY_VOLUMEDOWN },
446 { 0x0043, KEY_VOLUMEUP },
447 { 0x0052, KEY_UP }, /* up arrow */
448 { 0x0051, KEY_DOWN }, /* down arrow */
449 { 0x004f, KEY_RIGHT }, /* right arrow */
450 { 0x0050, KEY_LEFT }, /* left arrow */
451 { 0x0028, KEY_ENTER }, /* ok */
452 { 0x0115, KEY_RECORD },
453 { 0x0313, KEY_PLAY },
454 { 0x0113, KEY_PAUSE },
455 { 0x0116, KEY_STOP },
456 { 0x0307, KEY_REWIND }, /* FR << */
457 { 0x0309, KEY_FASTFORWARD }, /* FF >> */
458 { 0x003b, KEY_TIME }, /* TimeShift */
459 { 0x003e, KEY_CAMERA }, /* Snapshot */
460 { 0x0316, KEY_CYCLEWINDOWS }, /* yellow, min / max */
461 { 0x0000, KEY_ZOOM }, /* 'select' (?) */
462 { 0x0316, KEY_SHUFFLE }, /* Shuffle */
463 { 0x0345, KEY_POWER },
464};
465
466static u8 af9015_ir_table_mygictv[] = {
467 0x02, 0xbd, 0x0c, 0xf3, 0x3d, 0x00, 0x00, /* TV / AV */
468 0x02, 0xbd, 0x14, 0xeb, 0x45, 0x05, 0x00, /* power */
469 0x02, 0xbd, 0x00, 0xff, 0x1e, 0x00, 0x00, /* 1 */
470 0x02, 0xbd, 0x01, 0xfe, 0x1f, 0x00, 0x00, /* 2 */
471 0x02, 0xbd, 0x02, 0xfd, 0x20, 0x00, 0x00, /* 3 */
472 0x02, 0xbd, 0x03, 0xfc, 0x21, 0x00, 0x00, /* 4 */
473 0x02, 0xbd, 0x04, 0xfb, 0x22, 0x00, 0x00, /* 5 */
474 0x02, 0xbd, 0x05, 0xfa, 0x23, 0x00, 0x00, /* 6 */
475 0x02, 0xbd, 0x06, 0xf9, 0x24, 0x00, 0x00, /* 7 */
476 0x02, 0xbd, 0x07, 0xf8, 0x25, 0x00, 0x00, /* 8 */
477 0x02, 0xbd, 0x08, 0xf7, 0x26, 0x00, 0x00, /* 9 */
478 0x02, 0xbd, 0x09, 0xf6, 0x27, 0x00, 0x00, /* 0 */
479 0x02, 0xbd, 0x0a, 0xf5, 0x41, 0x00, 0x00, /* mute */
480 0x02, 0xbd, 0x1c, 0xe3, 0x2a, 0x00, 0x00, /* esc */
481 0x02, 0xbd, 0x1f, 0xe0, 0x43, 0x00, 0x00, /* volume up */
482 0x02, 0xbd, 0x12, 0xed, 0x52, 0x00, 0x00, /* up arrow */
483 0x02, 0xbd, 0x11, 0xee, 0x50, 0x00, 0x00, /* left arrow */
484 0x02, 0xbd, 0x15, 0xea, 0x28, 0x00, 0x00, /* ok */
485 0x02, 0xbd, 0x10, 0xef, 0x4f, 0x00, 0x00, /* right arrow */
486 0x02, 0xbd, 0x13, 0xec, 0x51, 0x00, 0x00, /* down arrow */
487 0x02, 0xbd, 0x0e, 0xf1, 0x42, 0x00, 0x00, /* volume down */
488 0x02, 0xbd, 0x19, 0xe6, 0x15, 0x01, 0x00, /* record */
489 0x02, 0xbd, 0x1e, 0xe1, 0x13, 0x03, 0x00, /* play */
490 0x02, 0xbd, 0x16, 0xe9, 0x16, 0x01, 0x00, /* stop */
491 0x02, 0xbd, 0x0b, 0xf4, 0x28, 0x04, 0x00, /* yellow, min / max */
492 0x02, 0xbd, 0x0f, 0xf0, 0x3b, 0x00, 0x00, /* time shift */
493 0x02, 0xbd, 0x18, 0xe7, 0x2e, 0x00, 0x00, /* channel up */
494 0x02, 0xbd, 0x1a, 0xe5, 0x2d, 0x00, 0x00, /* channel down */
495 0x02, 0xbd, 0x17, 0xe8, 0x3e, 0x00, 0x00, /* snapshot */
496 0x02, 0xbd, 0x40, 0xbf, 0x13, 0x01, 0x00, /* pause */
497 0x02, 0xbd, 0x41, 0xbe, 0x09, 0x03, 0x00, /* FF >> */
498 0x02, 0xbd, 0x42, 0xbd, 0x07, 0x03, 0x00, /* FR << */
499 0x02, 0xbd, 0x43, 0xbc, 0x00, 0x00, 0x00, /* 'select' (?) */
500 0x02, 0xbd, 0x44, 0xbb, 0x16, 0x03, 0x00, /* shuffle */
501 0x02, 0xbd, 0x45, 0xba, 0x45, 0x03, 0x00, /* power */
502};
503
504/* KWorld PlusTV Dual DVB-T Stick (DVB-T 399U) */
505static u8 af9015_ir_table_kworld[] = {
506 0x86, 0x6b, 0x0c, 0xf3, 0x2e, 0x07, 0x00,
507 0x86, 0x6b, 0x16, 0xe9, 0x2d, 0x07, 0x00,
508 0x86, 0x6b, 0x1d, 0xe2, 0x37, 0x07, 0x00,
509 0x86, 0x6b, 0x00, 0xff, 0x1e, 0x07, 0x00,
510 0x86, 0x6b, 0x01, 0xfe, 0x1f, 0x07, 0x00,
511 0x86, 0x6b, 0x02, 0xfd, 0x20, 0x07, 0x00,
512 0x86, 0x6b, 0x03, 0xfc, 0x21, 0x07, 0x00,
513 0x86, 0x6b, 0x04, 0xfb, 0x22, 0x07, 0x00,
514 0x86, 0x6b, 0x05, 0xfa, 0x23, 0x07, 0x00,
515 0x86, 0x6b, 0x06, 0xf9, 0x24, 0x07, 0x00,
516 0x86, 0x6b, 0x07, 0xf8, 0x25, 0x07, 0x00,
517 0x86, 0x6b, 0x08, 0xf7, 0x26, 0x07, 0x00,
518 0x86, 0x6b, 0x09, 0xf6, 0x4d, 0x07, 0x00,
519 0x86, 0x6b, 0x0a, 0xf5, 0x4e, 0x07, 0x00,
520 0x86, 0x6b, 0x14, 0xeb, 0x4f, 0x07, 0x00,
521 0x86, 0x6b, 0x1e, 0xe1, 0x50, 0x07, 0x00,
522 0x86, 0x6b, 0x17, 0xe8, 0x52, 0x07, 0x00,
523 0x86, 0x6b, 0x1f, 0xe0, 0x51, 0x07, 0x00,
524 0x86, 0x6b, 0x0e, 0xf1, 0x0b, 0x07, 0x00,
525 0x86, 0x6b, 0x20, 0xdf, 0x0c, 0x07, 0x00,
526 0x86, 0x6b, 0x42, 0xbd, 0x0d, 0x07, 0x00,
527 0x86, 0x6b, 0x0b, 0xf4, 0x0e, 0x07, 0x00,
528 0x86, 0x6b, 0x43, 0xbc, 0x0f, 0x07, 0x00,
529 0x86, 0x6b, 0x10, 0xef, 0x10, 0x07, 0x00,
530 0x86, 0x6b, 0x21, 0xde, 0x11, 0x07, 0x00,
531 0x86, 0x6b, 0x13, 0xec, 0x12, 0x07, 0x00,
532 0x86, 0x6b, 0x11, 0xee, 0x13, 0x07, 0x00,
533 0x86, 0x6b, 0x12, 0xed, 0x14, 0x07, 0x00,
534 0x86, 0x6b, 0x19, 0xe6, 0x15, 0x07, 0x00,
535 0x86, 0x6b, 0x1a, 0xe5, 0x16, 0x07, 0x00,
536 0x86, 0x6b, 0x1b, 0xe4, 0x17, 0x07, 0x00,
537 0x86, 0x6b, 0x4b, 0xb4, 0x18, 0x07, 0x00,
538 0x86, 0x6b, 0x40, 0xbf, 0x19, 0x07, 0x00,
539 0x86, 0x6b, 0x44, 0xbb, 0x1a, 0x07, 0x00,
540 0x86, 0x6b, 0x41, 0xbe, 0x1b, 0x07, 0x00,
541 0x86, 0x6b, 0x22, 0xdd, 0x1c, 0x07, 0x00,
542 0x86, 0x6b, 0x15, 0xea, 0x1d, 0x07, 0x00,
543 0x86, 0x6b, 0x0f, 0xf0, 0x3f, 0x07, 0x00,
544 0x86, 0x6b, 0x1c, 0xe3, 0x40, 0x07, 0x00,
545 0x86, 0x6b, 0x4a, 0xb5, 0x41, 0x07, 0x00,
546 0x86, 0x6b, 0x48, 0xb7, 0x42, 0x07, 0x00,
547 0x86, 0x6b, 0x49, 0xb6, 0x43, 0x07, 0x00,
548 0x86, 0x6b, 0x18, 0xe7, 0x44, 0x07, 0x00,
549 0x86, 0x6b, 0x23, 0xdc, 0x45, 0x07, 0x00,
550};
551
552/* AverMedia Volar X */
553static struct ir_scancode ir_codes_af9015_table_avermedia[] = {
554 { 0x053d, KEY_PROG1 }, /* SOURCE */
555 { 0x0512, KEY_POWER }, /* POWER */
556 { 0x051e, KEY_1 }, /* 1 */
557 { 0x051f, KEY_2 }, /* 2 */
558 { 0x0520, KEY_3 }, /* 3 */
559 { 0x0521, KEY_4 }, /* 4 */
560 { 0x0522, KEY_5 }, /* 5 */
561 { 0x0523, KEY_6 }, /* 6 */
562 { 0x0524, KEY_7 }, /* 7 */
563 { 0x0525, KEY_8 }, /* 8 */
564 { 0x0526, KEY_9 }, /* 9 */
565 { 0x053f, KEY_LEFT }, /* L / DISPLAY */
566 { 0x0527, KEY_0 }, /* 0 */
567 { 0x050f, KEY_RIGHT }, /* R / CH RTN */
568 { 0x0518, KEY_PROG2 }, /* SNAP SHOT */
569 { 0x051c, KEY_PROG3 }, /* 16-CH PREV */
570 { 0x052d, KEY_VOLUMEDOWN }, /* VOL DOWN */
571 { 0x053e, KEY_ZOOM }, /* FULL SCREEN */
572 { 0x052e, KEY_VOLUMEUP }, /* VOL UP */
573 { 0x0510, KEY_MUTE }, /* MUTE */
574 { 0x0504, KEY_AUDIO }, /* AUDIO */
575 { 0x0515, KEY_RECORD }, /* RECORD */
576 { 0x0511, KEY_PLAY }, /* PLAY */
577 { 0x0516, KEY_STOP }, /* STOP */
578 { 0x050c, KEY_PLAYPAUSE }, /* TIMESHIFT / PAUSE */
579 { 0x0505, KEY_BACK }, /* << / RED */
580 { 0x0509, KEY_FORWARD }, /* >> / YELLOW */
581 { 0x0517, KEY_TEXT }, /* TELETEXT */
582 { 0x050a, KEY_EPG }, /* EPG */
583 { 0x0513, KEY_MENU }, /* MENU */
584
585 { 0x050e, KEY_CHANNELUP }, /* CH UP */
586 { 0x050d, KEY_CHANNELDOWN }, /* CH DOWN */
587 { 0x0519, KEY_FIRST }, /* |<< / GREEN */
588 { 0x0508, KEY_LAST }, /* >>| / BLUE */
589};
590
591static u8 af9015_ir_table_avermedia[] = {
592 0x02, 0xfd, 0x00, 0xff, 0x12, 0x05, 0x00,
593 0x02, 0xfd, 0x01, 0xfe, 0x3d, 0x05, 0x00,
594 0x02, 0xfd, 0x03, 0xfc, 0x17, 0x05, 0x00,
595 0x02, 0xfd, 0x04, 0xfb, 0x0a, 0x05, 0x00,
596 0x02, 0xfd, 0x05, 0xfa, 0x1e, 0x05, 0x00,
597 0x02, 0xfd, 0x06, 0xf9, 0x1f, 0x05, 0x00,
598 0x02, 0xfd, 0x07, 0xf8, 0x20, 0x05, 0x00,
599 0x02, 0xfd, 0x09, 0xf6, 0x21, 0x05, 0x00,
600 0x02, 0xfd, 0x0a, 0xf5, 0x22, 0x05, 0x00,
601 0x02, 0xfd, 0x0b, 0xf4, 0x23, 0x05, 0x00,
602 0x02, 0xfd, 0x0d, 0xf2, 0x24, 0x05, 0x00,
603 0x02, 0xfd, 0x0e, 0xf1, 0x25, 0x05, 0x00,
604 0x02, 0xfd, 0x0f, 0xf0, 0x26, 0x05, 0x00,
605 0x02, 0xfd, 0x11, 0xee, 0x27, 0x05, 0x00,
606 0x02, 0xfd, 0x08, 0xf7, 0x04, 0x05, 0x00,
607 0x02, 0xfd, 0x0c, 0xf3, 0x3e, 0x05, 0x00,
608 0x02, 0xfd, 0x10, 0xef, 0x1c, 0x05, 0x00,
609 0x02, 0xfd, 0x12, 0xed, 0x3f, 0x05, 0x00,
610 0x02, 0xfd, 0x13, 0xec, 0x0f, 0x05, 0x00,
611 0x02, 0xfd, 0x14, 0xeb, 0x10, 0x05, 0x00,
612 0x02, 0xfd, 0x15, 0xea, 0x13, 0x05, 0x00,
613 0x02, 0xfd, 0x17, 0xe8, 0x18, 0x05, 0x00,
614 0x02, 0xfd, 0x18, 0xe7, 0x11, 0x05, 0x00,
615 0x02, 0xfd, 0x19, 0xe6, 0x15, 0x05, 0x00,
616 0x02, 0xfd, 0x1a, 0xe5, 0x0c, 0x05, 0x00,
617 0x02, 0xfd, 0x1b, 0xe4, 0x16, 0x05, 0x00,
618 0x02, 0xfd, 0x1c, 0xe3, 0x09, 0x05, 0x00,
619 0x02, 0xfd, 0x1d, 0xe2, 0x05, 0x05, 0x00,
620 0x02, 0xfd, 0x1e, 0xe1, 0x2d, 0x05, 0x00,
621 0x02, 0xfd, 0x1f, 0xe0, 0x2e, 0x05, 0x00,
622 0x03, 0xfc, 0x00, 0xff, 0x08, 0x05, 0x00,
623 0x03, 0xfc, 0x01, 0xfe, 0x19, 0x05, 0x00,
624 0x03, 0xfc, 0x02, 0xfd, 0x0d, 0x05, 0x00,
625 0x03, 0xfc, 0x03, 0xfc, 0x0e, 0x05, 0x00,
626};
627
628static u8 af9015_ir_table_avermedia_ks[] = {
629 0x05, 0xfa, 0x01, 0xfe, 0x12, 0x05, 0x00,
630 0x05, 0xfa, 0x02, 0xfd, 0x0e, 0x05, 0x00,
631 0x05, 0xfa, 0x03, 0xfc, 0x0d, 0x05, 0x00,
632 0x05, 0xfa, 0x04, 0xfb, 0x2e, 0x05, 0x00,
633 0x05, 0xfa, 0x05, 0xfa, 0x2d, 0x05, 0x00,
634 0x05, 0xfa, 0x06, 0xf9, 0x10, 0x05, 0x00,
635 0x05, 0xfa, 0x07, 0xf8, 0x0f, 0x05, 0x00,
636 0x05, 0xfa, 0x08, 0xf7, 0x3d, 0x05, 0x00,
637 0x05, 0xfa, 0x09, 0xf6, 0x1e, 0x05, 0x00,
638 0x05, 0xfa, 0x0a, 0xf5, 0x1f, 0x05, 0x00,
639 0x05, 0xfa, 0x0b, 0xf4, 0x20, 0x05, 0x00,
640 0x05, 0xfa, 0x0c, 0xf3, 0x21, 0x05, 0x00,
641 0x05, 0xfa, 0x0d, 0xf2, 0x22, 0x05, 0x00,
642 0x05, 0xfa, 0x0e, 0xf1, 0x23, 0x05, 0x00,
643 0x05, 0xfa, 0x0f, 0xf0, 0x24, 0x05, 0x00,
644 0x05, 0xfa, 0x10, 0xef, 0x25, 0x05, 0x00,
645 0x05, 0xfa, 0x11, 0xee, 0x26, 0x05, 0x00,
646 0x05, 0xfa, 0x12, 0xed, 0x27, 0x05, 0x00,
647 0x05, 0xfa, 0x13, 0xec, 0x04, 0x05, 0x00,
648 0x05, 0xfa, 0x15, 0xea, 0x0a, 0x05, 0x00,
649 0x05, 0xfa, 0x16, 0xe9, 0x11, 0x05, 0x00,
650 0x05, 0xfa, 0x17, 0xe8, 0x15, 0x05, 0x00,
651 0x05, 0xfa, 0x18, 0xe7, 0x16, 0x05, 0x00,
652 0x05, 0xfa, 0x1c, 0xe3, 0x05, 0x05, 0x00,
653 0x05, 0xfa, 0x1d, 0xe2, 0x09, 0x05, 0x00,
654 0x05, 0xfa, 0x4d, 0xb2, 0x3f, 0x05, 0x00,
655 0x05, 0xfa, 0x56, 0xa9, 0x3e, 0x05, 0x00
656};
657
658/* Digittrade DVB-T USB Stick */
659static struct ir_scancode ir_codes_af9015_table_digittrade[] = {
660 { 0x010f, KEY_LAST }, /* RETURN */
661 { 0x0517, KEY_TEXT }, /* TELETEXT */
662 { 0x0108, KEY_EPG }, /* EPG */
663 { 0x0513, KEY_POWER }, /* POWER */
664 { 0x0109, KEY_ZOOM }, /* FULLSCREEN */
665 { 0x0040, KEY_AUDIO }, /* DUAL SOUND */
666 { 0x002c, KEY_PRINT }, /* SNAPSHOT */
667 { 0x0516, KEY_SUBTITLE }, /* SUBTITLE */
668 { 0x0052, KEY_CHANNELUP }, /* CH Up */
669 { 0x0051, KEY_CHANNELDOWN },/* Ch Dn */
670 { 0x0057, KEY_VOLUMEUP }, /* Vol Up */
671 { 0x0056, KEY_VOLUMEDOWN }, /* Vol Dn */
672 { 0x0110, KEY_MUTE }, /* MUTE */
673 { 0x0027, KEY_0 },
674 { 0x001e, KEY_1 },
675 { 0x001f, KEY_2 },
676 { 0x0020, KEY_3 },
677 { 0x0021, KEY_4 },
678 { 0x0022, KEY_5 },
679 { 0x0023, KEY_6 },
680 { 0x0024, KEY_7 },
681 { 0x0025, KEY_8 },
682 { 0x0026, KEY_9 },
683 { 0x0117, KEY_PLAYPAUSE }, /* TIMESHIFT */
684 { 0x0115, KEY_RECORD }, /* RECORD */
685 { 0x0313, KEY_PLAY }, /* PLAY */
686 { 0x0116, KEY_STOP }, /* STOP */
687 { 0x0113, KEY_PAUSE }, /* PAUSE */
688};
689
690static u8 af9015_ir_table_digittrade[] = {
691 0x00, 0xff, 0x06, 0xf9, 0x13, 0x05, 0x00,
692 0x00, 0xff, 0x4d, 0xb2, 0x17, 0x01, 0x00,
693 0x00, 0xff, 0x1f, 0xe0, 0x2c, 0x00, 0x00,
694 0x00, 0xff, 0x0a, 0xf5, 0x15, 0x01, 0x00,
695 0x00, 0xff, 0x0e, 0xf1, 0x16, 0x01, 0x00,
696 0x00, 0xff, 0x09, 0xf6, 0x09, 0x01, 0x00,
697 0x00, 0xff, 0x01, 0xfe, 0x08, 0x01, 0x00,
698 0x00, 0xff, 0x05, 0xfa, 0x10, 0x01, 0x00,
699 0x00, 0xff, 0x02, 0xfd, 0x56, 0x00, 0x00,
700 0x00, 0xff, 0x40, 0xbf, 0x57, 0x00, 0x00,
701 0x00, 0xff, 0x19, 0xe6, 0x52, 0x00, 0x00,
702 0x00, 0xff, 0x17, 0xe8, 0x51, 0x00, 0x00,
703 0x00, 0xff, 0x10, 0xef, 0x0f, 0x01, 0x00,
704 0x00, 0xff, 0x54, 0xab, 0x27, 0x00, 0x00,
705 0x00, 0xff, 0x1b, 0xe4, 0x1e, 0x00, 0x00,
706 0x00, 0xff, 0x11, 0xee, 0x1f, 0x00, 0x00,
707 0x00, 0xff, 0x15, 0xea, 0x20, 0x00, 0x00,
708 0x00, 0xff, 0x12, 0xed, 0x21, 0x00, 0x00,
709 0x00, 0xff, 0x16, 0xe9, 0x22, 0x00, 0x00,
710 0x00, 0xff, 0x4c, 0xb3, 0x23, 0x00, 0x00,
711 0x00, 0xff, 0x48, 0xb7, 0x24, 0x00, 0x00,
712 0x00, 0xff, 0x04, 0xfb, 0x25, 0x00, 0x00,
713 0x00, 0xff, 0x00, 0xff, 0x26, 0x00, 0x00,
714 0x00, 0xff, 0x1e, 0xe1, 0x13, 0x03, 0x00,
715 0x00, 0xff, 0x1a, 0xe5, 0x13, 0x01, 0x00,
716 0x00, 0xff, 0x03, 0xfc, 0x17, 0x05, 0x00,
717 0x00, 0xff, 0x0d, 0xf2, 0x16, 0x05, 0x00,
718 0x00, 0xff, 0x1d, 0xe2, 0x40, 0x00, 0x00,
719};
720
721/* TREKSTOR DVB-T USB Stick */
722static struct ir_scancode ir_codes_af9015_table_trekstor[] = {
723 { 0x0704, KEY_AGAIN }, /* Home */
724 { 0x0705, KEY_MUTE }, /* Mute */
725 { 0x0706, KEY_UP }, /* Up */
726 { 0x0707, KEY_DOWN }, /* Down */
727 { 0x0709, KEY_RIGHT }, /* Right */
728 { 0x070a, KEY_ENTER }, /* OK */
729 { 0x070b, KEY_FASTFORWARD }, /* Fast forward */
730 { 0x070c, KEY_REWIND }, /* Rewind */
731 { 0x070d, KEY_PLAY }, /* Play/Pause */
732 { 0x070e, KEY_VOLUMEUP }, /* Volume + */
733 { 0x070f, KEY_VOLUMEDOWN }, /* Volume - */
734 { 0x0710, KEY_RECORD }, /* Record */
735 { 0x0711, KEY_STOP }, /* Stop */
736 { 0x0712, KEY_ZOOM }, /* TV */
737 { 0x0713, KEY_EPG }, /* Info/EPG */
738 { 0x0714, KEY_CHANNELDOWN }, /* Channel - */
739 { 0x0715, KEY_CHANNELUP }, /* Channel + */
740 { 0x071e, KEY_1 },
741 { 0x071f, KEY_2 },
742 { 0x0720, KEY_3 },
743 { 0x0721, KEY_4 },
744 { 0x0722, KEY_5 },
745 { 0x0723, KEY_6 },
746 { 0x0724, KEY_7 },
747 { 0x0725, KEY_8 },
748 { 0x0726, KEY_9 },
749 { 0x0708, KEY_LEFT }, /* LEFT */
750 { 0x0727, KEY_0 },
751};
752
753static u8 af9015_ir_table_trekstor[] = {
754 0x00, 0xff, 0x86, 0x79, 0x04, 0x07, 0x00,
755 0x00, 0xff, 0x85, 0x7a, 0x05, 0x07, 0x00,
756 0x00, 0xff, 0x87, 0x78, 0x06, 0x07, 0x00,
757 0x00, 0xff, 0x8c, 0x73, 0x07, 0x07, 0x00,
758 0x00, 0xff, 0x89, 0x76, 0x09, 0x07, 0x00,
759 0x00, 0xff, 0x88, 0x77, 0x0a, 0x07, 0x00,
760 0x00, 0xff, 0x8a, 0x75, 0x0b, 0x07, 0x00,
761 0x00, 0xff, 0x9e, 0x61, 0x0c, 0x07, 0x00,
762 0x00, 0xff, 0x8d, 0x72, 0x0d, 0x07, 0x00,
763 0x00, 0xff, 0x8b, 0x74, 0x0e, 0x07, 0x00,
764 0x00, 0xff, 0x9b, 0x64, 0x0f, 0x07, 0x00,
765 0x00, 0xff, 0x9d, 0x62, 0x10, 0x07, 0x00,
766 0x00, 0xff, 0x8e, 0x71, 0x11, 0x07, 0x00,
767 0x00, 0xff, 0x9c, 0x63, 0x12, 0x07, 0x00,
768 0x00, 0xff, 0x8f, 0x70, 0x13, 0x07, 0x00,
769 0x00, 0xff, 0x93, 0x6c, 0x14, 0x07, 0x00,
770 0x00, 0xff, 0x97, 0x68, 0x15, 0x07, 0x00,
771 0x00, 0xff, 0x92, 0x6d, 0x1e, 0x07, 0x00,
772 0x00, 0xff, 0x96, 0x69, 0x1f, 0x07, 0x00,
773 0x00, 0xff, 0x9a, 0x65, 0x20, 0x07, 0x00,
774 0x00, 0xff, 0x91, 0x6e, 0x21, 0x07, 0x00,
775 0x00, 0xff, 0x95, 0x6a, 0x22, 0x07, 0x00,
776 0x00, 0xff, 0x99, 0x66, 0x23, 0x07, 0x00,
777 0x00, 0xff, 0x90, 0x6f, 0x24, 0x07, 0x00,
778 0x00, 0xff, 0x94, 0x6b, 0x25, 0x07, 0x00,
779 0x00, 0xff, 0x98, 0x67, 0x26, 0x07, 0x00,
780 0x00, 0xff, 0x9f, 0x60, 0x08, 0x07, 0x00,
781 0x00, 0xff, 0x84, 0x7b, 0x27, 0x07, 0x00,
782};
783
784/* MSI DIGIVOX mini III */
785static struct ir_scancode ir_codes_af9015_table_msi_digivox_iii[] = {
786 { 0x0713, KEY_POWER }, /* [red power button] */
787 { 0x073b, KEY_VIDEO }, /* Source */
788 { 0x073e, KEY_ZOOM }, /* Zoom */
789 { 0x070b, KEY_POWER2 }, /* ShutDown */
790 { 0x071e, KEY_1 },
791 { 0x071f, KEY_2 },
792 { 0x0720, KEY_3 },
793 { 0x0721, KEY_4 },
794 { 0x0722, KEY_5 },
795 { 0x0723, KEY_6 },
796 { 0x0724, KEY_7 },
797 { 0x0725, KEY_8 },
798 { 0x0726, KEY_9 },
799 { 0x0727, KEY_0 },
800 { 0x0752, KEY_CHANNELUP }, /* CH+ */
801 { 0x0751, KEY_CHANNELDOWN }, /* CH- */
802 { 0x0750, KEY_VOLUMEUP }, /* Vol+ */
803 { 0x074f, KEY_VOLUMEDOWN }, /* Vol- */
804 { 0x0705, KEY_ESC }, /* [back up arrow] */
805 { 0x0708, KEY_OK }, /* [enter arrow] */
806 { 0x073f, KEY_RECORD }, /* Rec */
807 { 0x0716, KEY_STOP }, /* Stop */
808 { 0x072a, KEY_PLAY }, /* Play */
809 { 0x073c, KEY_MUTE }, /* Mute */
810 { 0x0718, KEY_UP },
811 { 0x0707, KEY_DOWN },
812 { 0x070f, KEY_LEFT },
813 { 0x0715, KEY_RIGHT },
814 { 0x0736, KEY_RED },
815 { 0x0737, KEY_GREEN },
816 { 0x072d, KEY_YELLOW },
817 { 0x072e, KEY_BLUE },
818};
819
820static u8 af9015_ir_table_msi_digivox_iii[] = {
821 0x61, 0xd6, 0x43, 0xbc, 0x13, 0x07, 0x00, /* KEY_POWER */
822 0x61, 0xd6, 0x01, 0xfe, 0x3b, 0x07, 0x00, /* KEY_VIDEO */
823 0x61, 0xd6, 0x0b, 0xf4, 0x3e, 0x07, 0x00, /* KEY_ZOOM */
824 0x61, 0xd6, 0x03, 0xfc, 0x0b, 0x07, 0x00, /* KEY_POWER2 */
825 0x61, 0xd6, 0x04, 0xfb, 0x1e, 0x07, 0x00, /* KEY_1 */
826 0x61, 0xd6, 0x08, 0xf7, 0x1f, 0x07, 0x00, /* KEY_2 */
827 0x61, 0xd6, 0x02, 0xfd, 0x20, 0x07, 0x00, /* KEY_3 */
828 0x61, 0xd6, 0x0f, 0xf0, 0x21, 0x07, 0x00, /* KEY_4 */
829 0x61, 0xd6, 0x05, 0xfa, 0x22, 0x07, 0x00, /* KEY_5 */
830 0x61, 0xd6, 0x06, 0xf9, 0x23, 0x07, 0x00, /* KEY_6 */
831 0x61, 0xd6, 0x0c, 0xf3, 0x24, 0x07, 0x00, /* KEY_7 */
832 0x61, 0xd6, 0x0d, 0xf2, 0x25, 0x07, 0x00, /* KEY_8 */
833 0x61, 0xd6, 0x0a, 0xf5, 0x26, 0x07, 0x00, /* KEY_9 */
834 0x61, 0xd6, 0x11, 0xee, 0x27, 0x07, 0x00, /* KEY_0 */
835 0x61, 0xd6, 0x09, 0xf6, 0x52, 0x07, 0x00, /* KEY_CHANNELUP */
836 0x61, 0xd6, 0x07, 0xf8, 0x51, 0x07, 0x00, /* KEY_CHANNELDOWN */
837 0x61, 0xd6, 0x0e, 0xf1, 0x50, 0x07, 0x00, /* KEY_VOLUMEUP */
838 0x61, 0xd6, 0x13, 0xec, 0x4f, 0x07, 0x00, /* KEY_VOLUMEDOWN */
839 0x61, 0xd6, 0x10, 0xef, 0x05, 0x07, 0x00, /* KEY_ESC */
840 0x61, 0xd6, 0x12, 0xed, 0x08, 0x07, 0x00, /* KEY_OK */
841 0x61, 0xd6, 0x14, 0xeb, 0x3f, 0x07, 0x00, /* KEY_RECORD */
842 0x61, 0xd6, 0x15, 0xea, 0x16, 0x07, 0x00, /* KEY_STOP */
843 0x61, 0xd6, 0x16, 0xe9, 0x2a, 0x07, 0x00, /* KEY_PLAY */
844 0x61, 0xd6, 0x17, 0xe8, 0x3c, 0x07, 0x00, /* KEY_MUTE */
845 0x61, 0xd6, 0x18, 0xe7, 0x18, 0x07, 0x00, /* KEY_UP */
846 0x61, 0xd6, 0x19, 0xe6, 0x07, 0x07, 0x00, /* KEY_DOWN */
847 0x61, 0xd6, 0x1a, 0xe5, 0x0f, 0x07, 0x00, /* KEY_LEFT */
848 0x61, 0xd6, 0x1b, 0xe4, 0x15, 0x07, 0x00, /* KEY_RIGHT */
849 0x61, 0xd6, 0x1c, 0xe3, 0x36, 0x07, 0x00, /* KEY_RED */
850 0x61, 0xd6, 0x1d, 0xe2, 0x37, 0x07, 0x00, /* KEY_GREEN */
851 0x61, 0xd6, 0x1e, 0xe1, 0x2d, 0x07, 0x00, /* KEY_YELLOW */
852 0x61, 0xd6, 0x1f, 0xe0, 0x2e, 0x07, 0x00, /* KEY_BLUE */
853};
854
855#endif 124#endif
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index 4685259e1614..1759d26bca42 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -354,7 +354,7 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
354static int anysee_tuner_attach(struct dvb_usb_adapter *adap) 354static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
355{ 355{
356 struct anysee_state *state = adap->dev->priv; 356 struct anysee_state *state = adap->dev->priv;
357 deb_info("%s: \n", __func__); 357 deb_info("%s:\n", __func__);
358 358
359 switch (state->tuner) { 359 switch (state->tuner) {
360 case DVB_PLL_THOMSON_DTT7579: 360 case DVB_PLL_THOMSON_DTT7579:
@@ -374,78 +374,32 @@ static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
374 return 0; 374 return 0;
375} 375}
376 376
377static int anysee_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 377static int anysee_rc_query(struct dvb_usb_device *d)
378{ 378{
379 u8 buf[] = {CMD_GET_IR_CODE}; 379 u8 buf[] = {CMD_GET_IR_CODE};
380 struct ir_scancode *keymap = d->props.rc.legacy.rc_key_map;
381 u8 ircode[2]; 380 u8 ircode[2];
382 int i, ret; 381 int ret;
382
383 /* Remote controller is basic NEC using address byte 0x08.
384 Anysee device RC query returns only two bytes, status and code,
385 address byte is dropped. Also it does not return any value for
386 NEC RCs having address byte other than 0x08. Due to that, we
387 cannot use that device as standard NEC receiver.
388 It could be possible make hack which reads whole code directly
389 from device memory... */
383 390
384 ret = anysee_ctrl_msg(d, buf, sizeof(buf), &ircode[0], 2); 391 ret = anysee_ctrl_msg(d, buf, sizeof(buf), ircode, sizeof(ircode));
385 if (ret) 392 if (ret)
386 return ret; 393 return ret;
387 394
388 *event = 0; 395 if (ircode[0]) {
389 *state = REMOTE_NO_KEY_PRESSED; 396 deb_rc("%s: key pressed %02x\n", __func__, ircode[1]);
390 397 ir_keydown(d->rc_input_dev, 0x08 << 8 | ircode[1], 0);
391 for (i = 0; i < d->props.rc.legacy.rc_key_map_size; i++) {
392 if (rc5_custom(&keymap[i]) == ircode[0] &&
393 rc5_data(&keymap[i]) == ircode[1]) {
394 *event = keymap[i].keycode;
395 *state = REMOTE_KEY_PRESSED;
396 return 0;
397 }
398 } 398 }
399
399 return 0; 400 return 0;
400} 401}
401 402
402static struct ir_scancode ir_codes_anysee_table[] = {
403 { 0x0100, KEY_0 },
404 { 0x0101, KEY_1 },
405 { 0x0102, KEY_2 },
406 { 0x0103, KEY_3 },
407 { 0x0104, KEY_4 },
408 { 0x0105, KEY_5 },
409 { 0x0106, KEY_6 },
410 { 0x0107, KEY_7 },
411 { 0x0108, KEY_8 },
412 { 0x0109, KEY_9 },
413 { 0x010a, KEY_POWER },
414 { 0x010b, KEY_DOCUMENTS }, /* * */
415 { 0x0119, KEY_FAVORITES },
416 { 0x0120, KEY_SLEEP },
417 { 0x0121, KEY_MODE }, /* 4:3 / 16:9 select */
418 { 0x0122, KEY_ZOOM },
419 { 0x0147, KEY_TEXT },
420 { 0x0116, KEY_TV }, /* TV / radio select */
421 { 0x011e, KEY_LANGUAGE }, /* Second Audio Program */
422 { 0x011a, KEY_SUBTITLE },
423 { 0x011b, KEY_CAMERA }, /* screenshot */
424 { 0x0142, KEY_MUTE },
425 { 0x010e, KEY_MENU },
426 { 0x010f, KEY_EPG },
427 { 0x0117, KEY_INFO },
428 { 0x0110, KEY_EXIT },
429 { 0x0113, KEY_VOLUMEUP },
430 { 0x0112, KEY_VOLUMEDOWN },
431 { 0x0111, KEY_CHANNELUP },
432 { 0x0114, KEY_CHANNELDOWN },
433 { 0x0115, KEY_OK },
434 { 0x011d, KEY_RED },
435 { 0x011f, KEY_GREEN },
436 { 0x011c, KEY_YELLOW },
437 { 0x0144, KEY_BLUE },
438 { 0x010c, KEY_SHUFFLE }, /* snapshot */
439 { 0x0148, KEY_STOP },
440 { 0x0150, KEY_PLAY },
441 { 0x0151, KEY_PAUSE },
442 { 0x0149, KEY_RECORD },
443 { 0x0118, KEY_PREVIOUS }, /* |<< */
444 { 0x010d, KEY_NEXT }, /* >>| */
445 { 0x0124, KEY_PROG1 }, /* F1 */
446 { 0x0125, KEY_PROG2 }, /* F2 */
447};
448
449/* DVB USB Driver stuff */ 403/* DVB USB Driver stuff */
450static struct dvb_usb_device_properties anysee_properties; 404static struct dvb_usb_device_properties anysee_properties;
451 405
@@ -520,11 +474,12 @@ static struct dvb_usb_device_properties anysee_properties = {
520 } 474 }
521 }, 475 },
522 476
523 .rc.legacy = { 477 .rc.core = {
524 .rc_key_map = ir_codes_anysee_table, 478 .rc_codes = RC_MAP_ANYSEE,
525 .rc_key_map_size = ARRAY_SIZE(ir_codes_anysee_table), 479 .protocol = IR_TYPE_OTHER,
480 .module_name = "anysee",
526 .rc_query = anysee_rc_query, 481 .rc_query = anysee_rc_query,
527 .rc_interval = 200, /* windows driver uses 500ms */ 482 .rc_interval = 250, /* windows driver uses 500ms */
528 }, 483 },
529 484
530 .i2c_algo = &anysee_i2c_algo, 485 .i2c_algo = &anysee_i2c_algo,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
index cead089bbb4f..88e4a62abc44 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
@@ -20,7 +20,6 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d)
20 } 20 }
21 21
22 strlcpy(d->i2c_adap.name, d->desc->name, sizeof(d->i2c_adap.name)); 22 strlcpy(d->i2c_adap.name, d->desc->name, sizeof(d->i2c_adap.name));
23 d->i2c_adap.class = I2C_CLASS_TV_DIGITAL,
24 d->i2c_adap.algo = d->props.i2c_algo; 23 d->i2c_adap.algo = d->props.i2c_algo;
25 d->i2c_adap.algo_data = NULL; 24 d->i2c_adap.algo_data = NULL;
26 d->i2c_adap.dev.parent = &d->udev->dev; 25 d->i2c_adap.dev.parent = &d->udev->dev;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 1a774d58d664..192a40ce583d 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -32,6 +32,7 @@
32#define USB_VID_EMPIA 0xeb1a 32#define USB_VID_EMPIA 0xeb1a
33#define USB_VID_GENPIX 0x09c0 33#define USB_VID_GENPIX 0x09c0
34#define USB_VID_GRANDTEC 0x5032 34#define USB_VID_GRANDTEC 0x5032
35#define USB_VID_GTEK 0x1f4d
35#define USB_VID_HANFTEK 0x15f4 36#define USB_VID_HANFTEK 0x15f4
36#define USB_VID_HAUPPAUGE 0x2040 37#define USB_VID_HAUPPAUGE 0x2040
37#define USB_VID_HYPER_PALTEK 0x1025 38#define USB_VID_HYPER_PALTEK 0x1025
@@ -133,6 +134,8 @@
133#define USB_PID_KWORLD_VSTREAM_WARM 0x17df 134#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
134#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055 135#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055
135#define USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2 0x0069 136#define USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2 0x0069
137#define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097
138#define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099
136#define USB_PID_TWINHAN_VP7041_COLD 0x3201 139#define USB_PID_TWINHAN_VP7041_COLD 0x3201
137#define USB_PID_TWINHAN_VP7041_WARM 0x3202 140#define USB_PID_TWINHAN_VP7041_WARM 0x3202
138#define USB_PID_TWINHAN_VP7020_COLD 0x3203 141#define USB_PID_TWINHAN_VP7020_COLD 0x3203
@@ -143,6 +146,7 @@
143#define USB_PID_TWINHAN_VP7021_WARM 0x3208 146#define USB_PID_TWINHAN_VP7021_WARM 0x3208
144#define USB_PID_TINYTWIN 0x3226 147#define USB_PID_TINYTWIN 0x3226
145#define USB_PID_TINYTWIN_2 0xe402 148#define USB_PID_TINYTWIN_2 0xe402
149#define USB_PID_TINYTWIN_3 0x9016
146#define USB_PID_DNTV_TINYUSB2_COLD 0x3223 150#define USB_PID_DNTV_TINYUSB2_COLD 0x3223
147#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 151#define USB_PID_DNTV_TINYUSB2_WARM 0x3224
148#define USB_PID_ULTIMA_TVBOX_COLD 0x8105 152#define USB_PID_ULTIMA_TVBOX_COLD 0x8105
@@ -196,6 +200,7 @@
196#define USB_PID_AVERMEDIA_A309 0xa309 200#define USB_PID_AVERMEDIA_A309 0xa309
197#define USB_PID_AVERMEDIA_A310 0xa310 201#define USB_PID_AVERMEDIA_A310 0xa310
198#define USB_PID_AVERMEDIA_A850 0x850a 202#define USB_PID_AVERMEDIA_A850 0x850a
203#define USB_PID_AVERMEDIA_A850T 0x850b
199#define USB_PID_AVERMEDIA_A805 0xa805 204#define USB_PID_AVERMEDIA_A805 0xa805
200#define USB_PID_AVERMEDIA_A815M 0x815a 205#define USB_PID_AVERMEDIA_A815M 0x815a
201#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 206#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006
@@ -268,6 +273,7 @@
268#define USB_PID_GENPIX_8PSK_REV_2 0x0202 273#define USB_PID_GENPIX_8PSK_REV_2 0x0202
269#define USB_PID_GENPIX_SKYWALKER_1 0x0203 274#define USB_PID_GENPIX_SKYWALKER_1 0x0203
270#define USB_PID_GENPIX_SKYWALKER_CW3K 0x0204 275#define USB_PID_GENPIX_SKYWALKER_CW3K 0x0204
276#define USB_PID_GENPIX_SKYWALKER_2 0x0206
271#define USB_PID_SIGMATEK_DVB_110 0x6610 277#define USB_PID_SIGMATEK_DVB_110 0x6610
272#define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 278#define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513
273#define USB_PID_MSI_DIGIVOX_DUO 0x8801 279#define USB_PID_MSI_DIGIVOX_DUO 0x8801
diff --git a/drivers/media/dvb/dvb-usb/friio-fe.c b/drivers/media/dvb/dvb-usb/friio-fe.c
index 93c21ddd0b77..015b4e8af1a5 100644
--- a/drivers/media/dvb/dvb-usb/friio-fe.c
+++ b/drivers/media/dvb/dvb-usb/friio-fe.c
@@ -75,7 +75,7 @@ static int jdvbt90502_single_reg_write(struct jdvbt90502_state *state,
75 return 0; 75 return 0;
76} 76}
77 77
78static int _jdvbt90502_write(struct dvb_frontend *fe, u8 *buf, int len) 78static int _jdvbt90502_write(struct dvb_frontend *fe, const u8 buf[], int len)
79{ 79{
80 struct jdvbt90502_state *state = fe->demodulator_priv; 80 struct jdvbt90502_state *state = fe->demodulator_priv;
81 int err, i; 81 int err, i;
diff --git a/drivers/media/dvb/dvb-usb/gp8psk-fe.c b/drivers/media/dvb/dvb-usb/gp8psk-fe.c
index dbdb5347b2a8..60d11e57e7d0 100644
--- a/drivers/media/dvb/dvb-usb/gp8psk-fe.c
+++ b/drivers/media/dvb/dvb-usb/gp8psk-fe.c
@@ -109,7 +109,7 @@ static int gp8psk_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength
109 109
110static int gp8psk_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) 110static int gp8psk_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
111{ 111{
112 tune->min_delay_ms = 200; 112 tune->min_delay_ms = 800;
113 return 0; 113 return 0;
114} 114}
115 115
@@ -334,7 +334,7 @@ success:
334 334
335static struct dvb_frontend_ops gp8psk_fe_ops = { 335static struct dvb_frontend_ops gp8psk_fe_ops = {
336 .info = { 336 .info = {
337 .name = "Genpix 8psk-to-USB2 DVB-S", 337 .name = "Genpix DVB-S",
338 .type = FE_QPSK, 338 .type = FE_QPSK,
339 .frequency_min = 800000, 339 .frequency_min = 800000,
340 .frequency_max = 2250000, 340 .frequency_max = 2250000,
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c
index 45106ac49674..c821293dbc22 100644
--- a/drivers/media/dvb/dvb-usb/gp8psk.c
+++ b/drivers/media/dvb/dvb-usb/gp8psk.c
@@ -227,6 +227,7 @@ static struct usb_device_id gp8psk_usb_table [] = {
227 { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_8PSK_REV_1_WARM) }, 227 { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_8PSK_REV_1_WARM) },
228 { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_8PSK_REV_2) }, 228 { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_8PSK_REV_2) },
229 { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_SKYWALKER_1) }, 229 { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_SKYWALKER_1) },
230 { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_SKYWALKER_2) },
230/* { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_SKYWALKER_CW3K) }, */ 231/* { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_SKYWALKER_CW3K) }, */
231 { 0 }, 232 { 0 },
232}; 233};
@@ -258,7 +259,7 @@ static struct dvb_usb_device_properties gp8psk_properties = {
258 259
259 .generic_bulk_ctrl_endpoint = 0x01, 260 .generic_bulk_ctrl_endpoint = 0x01,
260 261
261 .num_device_descs = 3, 262 .num_device_descs = 4,
262 .devices = { 263 .devices = {
263 { .name = "Genpix 8PSK-to-USB2 Rev.1 DVB-S receiver", 264 { .name = "Genpix 8PSK-to-USB2 Rev.1 DVB-S receiver",
264 .cold_ids = { &gp8psk_usb_table[0], NULL }, 265 .cold_ids = { &gp8psk_usb_table[0], NULL },
@@ -272,6 +273,10 @@ static struct dvb_usb_device_properties gp8psk_properties = {
272 .cold_ids = { NULL }, 273 .cold_ids = { NULL },
273 .warm_ids = { &gp8psk_usb_table[3], NULL }, 274 .warm_ids = { &gp8psk_usb_table[3], NULL },
274 }, 275 },
276 { .name = "Genpix SkyWalker-2 DVB-S receiver",
277 .cold_ids = { NULL },
278 .warm_ids = { &gp8psk_usb_table[4], NULL },
279 },
275 { NULL }, 280 { NULL },
276 } 281 }
277}; 282};
@@ -306,6 +311,6 @@ module_init(gp8psk_usb_module_init);
306module_exit(gp8psk_usb_module_exit); 311module_exit(gp8psk_usb_module_exit);
307 312
308MODULE_AUTHOR("Alan Nisota <alannisota@gamil.com>"); 313MODULE_AUTHOR("Alan Nisota <alannisota@gamil.com>");
309MODULE_DESCRIPTION("Driver for Genpix 8psk-to-USB2 DVB-S"); 314MODULE_DESCRIPTION("Driver for Genpix DVB-S");
310MODULE_VERSION("1.1"); 315MODULE_VERSION("1.1");
311MODULE_LICENSE("GPL"); 316MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c b/drivers/media/dvb/dvb-usb/lmedm04.c
new file mode 100644
index 000000000000..d939fbbf9fe6
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/lmedm04.c
@@ -0,0 +1,1088 @@
1/* DVB USB compliant linux driver for
2 *
3 * DM04/QQBOX DVB-S USB BOX LME2510C + SHARP:BS2F7HZ7395
4 * LME2510C + LG TDQY-P001F
5 * LME2510 + LG TDQY-P001F
6 *
7 * MVB7395 (LME2510C+SHARP:BS2F7HZ7395)
8 * SHARP:BS2F7HZ7395 = (STV0288+Sharp IX2505V)
9 *
10 * MV001F (LME2510+LGTDQY-P001F)
11 * LG TDQY - P001F =(TDA8263 + TDA10086H)
12 *
13 * MVB0001F (LME2510C+LGTDQT-P001F)
14 *
15 * For firmware see Documentation/dvb/lmedm04.txt
16 *
17 * I2C addresses:
18 * 0xd0 - STV0288 - Demodulator
19 * 0xc0 - Sharp IX2505V - Tuner
20 * --or--
21 * 0x1c - TDA10086 - Demodulator
22 * 0xc0 - TDA8263 - Tuner
23 *
24 * ***Please Note***
25 * There are other variants of the DM04
26 * ***NOT SUPPORTED***
27 * MV0194 (LME2510+SHARP0194)
28 * MVB0194 (LME2510C+SHARP0194)
29 *
30 *
31 * VID = 3344 PID LME2510=1122 LME2510C=1120
32 *
33 * Copyright (C) 2010 Malcolm Priestley (tvboxspy@gmail.com)
34 * LME2510(C)(C) Leaguerme (Shenzhen) MicroElectronics Co., Ltd.
35 *
36 * This program is free software; you can redistribute it and/or modify
37 * it under the terms of the GNU General Public License Version 2, as
38 * published by the Free Software Foundation.
39 *
40 * This program is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 * GNU General Public License for more details.
44 *
45 * You should have received a copy of the GNU General Public License
46 * along with this program; if not, write to the Free Software
47 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48 *
49 *
50 * see Documentation/dvb/README.dvb-usb for more information
51 *
52 * Known Issues :
53 * LME2510: Non Intel USB chipsets fail to maintain High Speed on
54 * Boot or Hot Plug.
55 *
56 * QQbox suffers from noise on LNB voltage.
57 *
58 * PID functions have been removed from this driver version due to
59 * problems with different firmware and application versions.
60 */
61#define DVB_USB_LOG_PREFIX "LME2510(C)"
62#include <linux/usb.h>
63#include <linux/usb/input.h>
64#include <media/ir-core.h>
65
66#include "dvb-usb.h"
67#include "lmedm04.h"
68#include "tda826x.h"
69#include "tda10086.h"
70#include "stv0288.h"
71#include "ix2505v.h"
72
73
74
75/* debug */
76static int dvb_usb_lme2510_debug;
77#define l_dprintk(var, level, args...) do { \
78 if ((var >= level)) \
79 printk(KERN_DEBUG DVB_USB_LOG_PREFIX ": " args); \
80} while (0)
81
82#define deb_info(level, args...) l_dprintk(dvb_usb_lme2510_debug, level, args)
83#define debug_data_snipet(level, name, p) \
84 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
85 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
86 *(p+5), *(p+6), *(p+7));
87
88
89module_param_named(debug, dvb_usb_lme2510_debug, int, 0644);
90MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))."
91 DVB_USB_DEBUG_STATUS);
92
93static int dvb_usb_lme2510_firmware;
94module_param_named(firmware, dvb_usb_lme2510_firmware, int, 0644);
95MODULE_PARM_DESC(firmware, "set default firmware 0=Sharp7395 1=LG");
96
97
98DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
99#define TUNER_LG 0x1
100#define TUNER_S7395 0x2
101
102struct lme2510_state {
103 u8 id;
104 u8 tuner_config;
105 u8 signal_lock;
106 u8 signal_level;
107 u8 signal_sn;
108 u8 time_key;
109 u8 i2c_talk_onoff;
110 u8 i2c_gate;
111 u8 i2c_tuner_gate_w;
112 u8 i2c_tuner_gate_r;
113 u8 i2c_tuner_addr;
114 u8 stream_on;
115 u8 one_tune;
116 void *buffer;
117 struct urb *lme_urb;
118 void *usb_buffer;
119
120};
121
122static int lme2510_bulk_write(struct usb_device *dev,
123 u8 *snd, int len, u8 pipe)
124{
125 int ret, actual_l;
126
127 ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe),
128 snd, len , &actual_l, 500);
129 return ret;
130}
131
132static int lme2510_bulk_read(struct usb_device *dev,
133 u8 *rev, int len, u8 pipe)
134{
135 int ret, actual_l;
136
137 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe),
138 rev, len , &actual_l, 500);
139 return ret;
140}
141
142static int lme2510_usb_talk(struct dvb_usb_device *d,
143 u8 *wbuf, int wlen, u8 *rbuf, int rlen)
144{
145 struct lme2510_state *st = d->priv;
146 u8 *buff;
147 int ret = 0;
148
149 if (st->usb_buffer == NULL) {
150 st->usb_buffer = kmalloc(512, GFP_KERNEL);
151 if (st->usb_buffer == NULL) {
152 info("MEM Error no memory");
153 return -ENOMEM;
154 }
155 }
156 buff = st->usb_buffer;
157
158 /* the read/write capped at 512 */
159 memcpy(buff, wbuf, (wlen > 512) ? 512 : wlen);
160
161 ret = mutex_lock_interruptible(&d->usb_mutex);
162
163 if (ret < 0)
164 return -EAGAIN;
165
166 ret |= usb_clear_halt(d->udev, usb_sndbulkpipe(d->udev, 0x01));
167
168 ret |= lme2510_bulk_write(d->udev, buff, wlen , 0x01);
169
170 msleep(12);
171
172 ret |= usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x01));
173
174 ret |= lme2510_bulk_read(d->udev, buff, (rlen > 512) ?
175 512 : rlen , 0x01);
176
177 if (rlen > 0)
178 memcpy(rbuf, buff, rlen);
179
180 mutex_unlock(&d->usb_mutex);
181
182 return (ret < 0) ? -ENODEV : 0;
183}
184
185static int lme2510_usb_talk_restart(struct dvb_usb_device *d,
186 u8 *wbuf, int wlen, u8 *rbuf, int rlen) {
187 static u8 stream_on[] = LME_ST_ON_W;
188 int ret;
189 u8 rbuff[10];
190 /*Send Normal Command*/
191 ret = lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
192 /*Restart Stream Command*/
193 ret |= lme2510_usb_talk(d, stream_on, sizeof(stream_on),
194 rbuff, sizeof(rbuff));
195 return ret;
196}
197static int lme2510_remote_keypress(struct dvb_usb_adapter *adap, u16 keypress)
198{
199 struct dvb_usb_device *d = adap->dev;
200
201 deb_info(1, "INT Key Keypress =%04x", keypress);
202
203 if (keypress > 0)
204 ir_keydown(d->rc_input_dev, keypress, 0);
205
206 return 0;
207}
208
209static void lme2510_int_response(struct urb *lme_urb)
210{
211 struct dvb_usb_adapter *adap = lme_urb->context;
212 struct lme2510_state *st = adap->dev->priv;
213 static u8 *ibuf, *rbuf;
214 int i = 0, offset;
215
216 switch (lme_urb->status) {
217 case 0:
218 case -ETIMEDOUT:
219 break;
220 case -ECONNRESET:
221 case -ENOENT:
222 case -ESHUTDOWN:
223 return;
224 default:
225 info("Error %x", lme_urb->status);
226 break;
227 }
228
229 rbuf = (u8 *) lme_urb->transfer_buffer;
230
231 offset = ((lme_urb->actual_length/8) > 4)
232 ? 4 : (lme_urb->actual_length/8) ;
233
234 for (i = 0; i < offset; ++i) {
235 ibuf = (u8 *)&rbuf[i*8];
236 deb_info(5, "INT O/S C =%02x C/O=%02x Type =%02x%02x",
237 offset, i, ibuf[0], ibuf[1]);
238
239 switch (ibuf[0]) {
240 case 0xaa:
241 debug_data_snipet(1, "INT Remote data snipet in", ibuf);
242 lme2510_remote_keypress(adap,
243 (u16)(ibuf[4]<<8)+ibuf[5]);
244 break;
245 case 0xbb:
246 switch (st->tuner_config) {
247 case TUNER_LG:
248 if (ibuf[2] > 0)
249 st->signal_lock = ibuf[2];
250 st->signal_level = ibuf[4];
251 st->signal_sn = ibuf[3];
252 st->time_key = ibuf[7];
253 break;
254 case TUNER_S7395:
255 /* Tweak for earlier firmware*/
256 if (ibuf[1] == 0x03) {
257 st->signal_level = ibuf[3];
258 st->signal_sn = ibuf[4];
259 } else {
260 st->signal_level = ibuf[4];
261 st->signal_sn = ibuf[5];
262 }
263 break;
264 default:
265 break;
266 }
267 debug_data_snipet(5, "INT Remote data snipet in", ibuf);
268 break;
269 case 0xcc:
270 debug_data_snipet(1, "INT Control data snipet", ibuf);
271 break;
272 default:
273 debug_data_snipet(1, "INT Unknown data snipet", ibuf);
274 break;
275 }
276 }
277 usb_submit_urb(lme_urb, GFP_ATOMIC);
278}
279
280static int lme2510_int_read(struct dvb_usb_adapter *adap)
281{
282 struct lme2510_state *lme_int = adap->dev->priv;
283
284 lme_int->lme_urb = usb_alloc_urb(0, GFP_ATOMIC);
285
286 if (lme_int->lme_urb == NULL)
287 return -ENOMEM;
288
289 lme_int->buffer = usb_alloc_coherent(adap->dev->udev, 5000, GFP_ATOMIC,
290 &lme_int->lme_urb->transfer_dma);
291
292 if (lme_int->buffer == NULL)
293 return -ENOMEM;
294
295 usb_fill_int_urb(lme_int->lme_urb,
296 adap->dev->udev,
297 usb_rcvintpipe(adap->dev->udev, 0xa),
298 lme_int->buffer,
299 4096,
300 lme2510_int_response,
301 adap,
302 11);
303
304 lme_int->lme_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
305
306 usb_submit_urb(lme_int->lme_urb, GFP_ATOMIC);
307 info("INT Interupt Service Started");
308
309 return 0;
310}
311
312static int lme2510_return_status(struct usb_device *dev)
313{
314 int ret = 0;
315 u8 data[10] = {0};
316
317 ret |= usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
318 0x06, 0x80, 0x0302, 0x00, data, 0x0006, 200);
319 info("Firmware Status: %x (%x)", ret , data[2]);
320
321 return (ret < 0) ? -ENODEV : data[2];
322}
323
324static int lme2510_msg(struct dvb_usb_device *d,
325 u8 *wbuf, int wlen, u8 *rbuf, int rlen)
326{
327 int ret = 0;
328 struct lme2510_state *st = d->priv;
329
330 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
331 return -EAGAIN;
332
333 if (st->i2c_talk_onoff == 1) {
334
335 ret = lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
336
337 switch (st->tuner_config) {
338 case TUNER_LG:
339 if (wbuf[2] == 0x1c) {
340 if (wbuf[3] == 0x0e) {
341 st->signal_lock = rbuf[1];
342 if ((st->stream_on & 1) &&
343 (st->signal_lock & 0x10)) {
344 lme2510_usb_talk_restart(d,
345 wbuf, wlen, rbuf, rlen);
346 st->i2c_talk_onoff = 0;
347 }
348 msleep(80);
349 }
350 }
351 break;
352 case TUNER_S7395:
353 if (wbuf[2] == 0xd0) {
354 if (wbuf[3] == 0x24) {
355 st->signal_lock = rbuf[1];
356 if ((st->stream_on & 1) &&
357 (st->signal_lock & 0x8)) {
358 lme2510_usb_talk_restart(d,
359 wbuf, wlen, rbuf, rlen);
360 st->i2c_talk_onoff = 0;
361 }
362 }
363 if ((wbuf[3] != 0x6) & (wbuf[3] != 0x5))
364 msleep(5);
365
366
367 }
368 break;
369 default:
370 break;
371 }
372 } else {
373 switch (st->tuner_config) {
374 case TUNER_LG:
375 switch (wbuf[3]) {
376 case 0x0e:
377 rbuf[0] = 0x55;
378 rbuf[1] = st->signal_lock;
379 break;
380 case 0x43:
381 rbuf[0] = 0x55;
382 rbuf[1] = st->signal_level;
383 break;
384 case 0x1c:
385 rbuf[0] = 0x55;
386 rbuf[1] = st->signal_sn;
387 break;
388 /*DiSEqC functions as per TDA10086*/
389 case 0x36:
390 case 0x48:
391 case 0x49:
392 case 0x4a:
393 case 0x4b:
394 case 0x4c:
395 case 0x4d:
396 if (wbuf[2] == 0x1c)
397 lme2510_usb_talk_restart(d,
398 wbuf, wlen, rbuf, rlen);
399 default:
400 break;
401 }
402 break;
403 case TUNER_S7395:
404 switch (wbuf[3]) {
405 case 0x10:
406 rbuf[0] = 0x55;
407 rbuf[1] = (st->signal_level & 0x80)
408 ? 0 : (st->signal_level * 2);
409 break;
410 case 0x2d:
411 rbuf[0] = 0x55;
412 rbuf[1] = st->signal_sn;
413 break;
414 case 0x24:
415 rbuf[0] = 0x55;
416 rbuf[1] = (st->signal_level & 0x80)
417 ? 0 : st->signal_lock;
418 break;
419 case 0x6:
420 if (wbuf[2] == 0xd0)
421 lme2510_usb_talk(d,
422 wbuf, wlen, rbuf, rlen);
423 break;
424 case 0x1:
425 if (st->one_tune > 0)
426 break;
427 st->one_tune++;
428 st->i2c_talk_onoff = 1;
429 /*DiSEqC functions as per STV0288*/
430 case 0x5:
431 case 0x7:
432 case 0x8:
433 case 0x9:
434 case 0xa:
435 case 0xb:
436 if (wbuf[2] == 0xd0)
437 lme2510_usb_talk_restart(d,
438 wbuf, wlen, rbuf, rlen);
439 break;
440 default:
441 rbuf[0] = 0x55;
442 rbuf[1] = 0x00;
443 break;
444 }
445 break;
446 default:
447 break;
448
449 }
450
451 deb_info(4, "I2C From Interupt Message out(%02x) in(%02x)",
452 wbuf[3], rbuf[1]);
453
454 }
455
456 mutex_unlock(&d->i2c_mutex);
457
458 return ret;
459}
460
461
462static int lme2510_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
463 int num)
464{
465 struct dvb_usb_device *d = i2c_get_adapdata(adap);
466 struct lme2510_state *st = d->priv;
467 static u8 obuf[64], ibuf[512];
468 int i, read, read_o;
469 u16 len;
470 u8 gate = st->i2c_gate;
471
472 if (gate == 0)
473 gate = 5;
474
475 if (num > 2)
476 warn("more than 2 i2c messages"
477 "at a time is not handled yet. TODO.");
478
479 for (i = 0; i < num; i++) {
480 read_o = 1 & (msg[i].flags & I2C_M_RD);
481 read = i+1 < num && (msg[i+1].flags & I2C_M_RD);
482 read |= read_o;
483 gate = (msg[i].addr == st->i2c_tuner_addr)
484 ? (read) ? st->i2c_tuner_gate_r
485 : st->i2c_tuner_gate_w
486 : st->i2c_gate;
487 obuf[0] = gate | (read << 7);
488
489 if (gate == 5)
490 obuf[1] = (read) ? 2 : msg[i].len + 1;
491 else
492 obuf[1] = msg[i].len + read + 1;
493
494 obuf[2] = msg[i].addr;
495 if (read) {
496 if (read_o)
497 len = 3;
498 else {
499 memcpy(&obuf[3], msg[i].buf, msg[i].len);
500 obuf[msg[i].len+3] = msg[i+1].len;
501 len = msg[i].len+4;
502 }
503 } else {
504 memcpy(&obuf[3], msg[i].buf, msg[i].len);
505 len = msg[i].len+3;
506 }
507
508 if (lme2510_msg(d, obuf, len, ibuf, 512) < 0) {
509 deb_info(1, "i2c transfer failed.");
510 return -EAGAIN;
511 }
512
513 if (read) {
514 if (read_o)
515 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
516 else {
517 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
518 i++;
519 }
520 }
521 }
522 return i;
523}
524
525static u32 lme2510_i2c_func(struct i2c_adapter *adapter)
526{
527 return I2C_FUNC_I2C;
528}
529
530static struct i2c_algorithm lme2510_i2c_algo = {
531 .master_xfer = lme2510_i2c_xfer,
532 .functionality = lme2510_i2c_func,
533};
534
535/* Callbacks for DVB USB */
536static int lme2510_identify_state(struct usb_device *udev,
537 struct dvb_usb_device_properties *props,
538 struct dvb_usb_device_description **desc,
539 int *cold)
540{
541 if (lme2510_return_status(udev) == 0x44)
542 *cold = 1;
543 else
544 *cold = 0;
545 return 0;
546}
547
548static int lme2510_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
549{
550 struct lme2510_state *st = adap->dev->priv;
551 static u8 stream_on[] = LME_ST_ON_W;
552 static u8 clear_reg_3[] = LME_CLEAR_PID;
553 static u8 rbuf[1];
554 static u8 timeout;
555 int ret = 0, len = 2, rlen = sizeof(rbuf);
556
557 deb_info(1, "STM (%02x)", onoff);
558
559 if (onoff == 1) {
560 st->i2c_talk_onoff = 0;
561 timeout = 0;
562 /* wait for i2C to be free */
563 while (mutex_lock_interruptible(&adap->dev->i2c_mutex) < 0) {
564 timeout++;
565 if (timeout > 5)
566 return -ENODEV;
567 }
568 msleep(100);
569 ret |= lme2510_usb_talk(adap->dev,
570 stream_on, len, rbuf, rlen);
571 st->stream_on = 1;
572 st->one_tune = 0;
573 mutex_unlock(&adap->dev->i2c_mutex);
574 } else {
575 deb_info(1, "STM Steam Off");
576 ret |= lme2510_usb_talk(adap->dev, clear_reg_3,
577 sizeof(clear_reg_3), rbuf, rlen);
578 st->stream_on = 0;
579 st->i2c_talk_onoff = 1;
580 }
581
582 return (ret < 0) ? -ENODEV : 0;
583}
584
585static int lme2510_int_service(struct dvb_usb_adapter *adap)
586{
587 struct dvb_usb_device *d = adap->dev;
588 struct input_dev *input_dev;
589 char *ir_codes = RC_MAP_LME2510;
590 int ret = 0;
591
592 info("STA Configuring Remote");
593
594 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
595
596 strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
597
598 input_dev = input_allocate_device();
599 if (!input_dev)
600 return -ENOMEM;
601
602 input_dev->name = "LME2510 Remote Control";
603 input_dev->phys = d->rc_phys;
604
605 usb_to_input_id(d->udev, &input_dev->id);
606
607 ret |= ir_input_register(input_dev, ir_codes, NULL, "LME 2510");
608
609 if (ret) {
610 input_free_device(input_dev);
611 return ret;
612 }
613
614 d->rc_input_dev = input_dev;
615 /* Start the Interupt */
616 ret = lme2510_int_read(adap);
617
618 if (ret < 0) {
619 ir_input_unregister(input_dev);
620 input_free_device(input_dev);
621 }
622 return (ret < 0) ? -ENODEV : 0;
623}
624
625static u8 check_sum(u8 *p, u8 len)
626{
627 u8 sum = 0;
628 while (len--)
629 sum += *p++;
630 return sum;
631}
632
633static int lme2510_download_firmware(struct usb_device *dev,
634 const struct firmware *fw)
635{
636 int ret = 0;
637 u8 data[512] = {0};
638 u16 j, wlen, len_in, start, end;
639 u8 packet_size, dlen, i;
640 u8 *fw_data;
641
642 packet_size = 0x31;
643 len_in = 1;
644
645
646 info("FRM Starting Firmware Download");
647
648 for (i = 1; i < 3; i++) {
649 start = (i == 1) ? 0 : 512;
650 end = (i == 1) ? 512 : fw->size;
651 for (j = start; j < end; j += (packet_size+1)) {
652 fw_data = (u8 *)(fw->data + j);
653 if ((end - j) > packet_size) {
654 data[0] = i;
655 dlen = packet_size;
656 } else {
657 data[0] = i | 0x80;
658 dlen = (u8)(end - j)-1;
659 }
660 data[1] = dlen;
661 memcpy(&data[2], fw_data, dlen+1);
662 wlen = (u8) dlen + 4;
663 data[wlen-1] = check_sum(fw_data, dlen+1);
664 deb_info(1, "Data S=%02x:E=%02x CS= %02x", data[3],
665 data[dlen+2], data[dlen+3]);
666 ret |= lme2510_bulk_write(dev, data, wlen, 1);
667 ret |= lme2510_bulk_read(dev, data, len_in , 1);
668 ret |= (data[0] == 0x88) ? 0 : -1;
669 }
670 }
671 usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
672 0x06, 0x80, 0x0200, 0x00, data, 0x0109, 1000);
673
674
675 data[0] = 0x8a;
676 len_in = 1;
677 msleep(2000);
678 ret |= lme2510_bulk_write(dev, data , len_in, 1); /*Resetting*/
679 ret |= lme2510_bulk_read(dev, data, len_in, 1);
680 msleep(400);
681
682 if (ret < 0)
683 info("FRM Firmware Download Failed (%04x)" , ret);
684 else
685 info("FRM Firmware Download Completed - Resetting Device");
686
687
688 return (ret < 0) ? -ENODEV : 0;
689}
690
691/* Default firmware for LME2510C */
692const char lme_firmware[50] = "dvb-usb-lme2510c-s7395.fw";
693
694static void lme_coldreset(struct usb_device *dev)
695{
696 int ret = 0, len_in;
697 u8 data[512] = {0};
698
699 data[0] = 0x0a;
700 len_in = 1;
701 info("FRM Firmware Cold Reset");
702 ret |= lme2510_bulk_write(dev, data , len_in, 1); /*Cold Resetting*/
703 ret |= lme2510_bulk_read(dev, data, len_in, 1);
704 return;
705}
706
707static void lme_firmware_switch(struct usb_device *udev, int cold)
708{
709 const struct firmware *fw = NULL;
710 char lme2510c_s7395[] = "dvb-usb-lme2510c-s7395.fw";
711 char lme2510c_lg[] = "dvb-usb-lme2510c-lg.fw";
712 char *firm_msg[] = {"Loading", "Switching to"};
713 int ret;
714
715 if (udev->descriptor.idProduct == 0x1122)
716 return;
717
718 switch (dvb_usb_lme2510_firmware) {
719 case 0:
720 default:
721 memcpy(&lme_firmware, lme2510c_s7395, sizeof(lme2510c_s7395));
722 ret = request_firmware(&fw, lme_firmware, &udev->dev);
723 if (ret == 0) {
724 info("FRM %s S7395 Firmware", firm_msg[cold]);
725 break;
726 }
727 if (cold == 0)
728 dvb_usb_lme2510_firmware = 1;
729 else
730 cold = 0;
731 case 1:
732 memcpy(&lme_firmware, lme2510c_lg, sizeof(lme2510c_lg));
733 ret = request_firmware(&fw, lme_firmware, &udev->dev);
734 if (ret == 0) {
735 info("FRM %s LG Firmware", firm_msg[cold]);
736 break;
737 }
738 info("FRM No Firmware Found - please install");
739 dvb_usb_lme2510_firmware = 0;
740 cold = 0;
741 break;
742 }
743 release_firmware(fw);
744 if (cold)
745 lme_coldreset(udev);
746 return;
747}
748
749static int lme2510_kill_urb(struct usb_data_stream *stream)
750{
751 int i;
752 for (i = 0; i < stream->urbs_submitted; i++) {
753 deb_info(3, "killing URB no. %d.", i);
754
755 /* stop the URB */
756 usb_kill_urb(stream->urb_list[i]);
757 }
758 stream->urbs_submitted = 0;
759 return 0;
760}
761
762static struct tda10086_config tda10086_config = {
763 .demod_address = 0x1c,
764 .invert = 0,
765 .diseqc_tone = 1,
766 .xtal_freq = TDA10086_XTAL_16M,
767};
768
769static struct stv0288_config lme_config = {
770 .demod_address = 0xd0,
771 .min_delay_ms = 15,
772 .inittab = s7395_inittab,
773};
774
775static struct ix2505v_config lme_tuner = {
776 .tuner_address = 0xc0,
777 .min_delay_ms = 100,
778 .tuner_gain = 0x0,
779 .tuner_chargepump = 0x3,
780};
781
782static int dm04_lme2510_set_voltage(struct dvb_frontend *fe,
783 fe_sec_voltage_t voltage)
784{
785 struct dvb_usb_adapter *adap = fe->dvb->priv;
786 struct lme2510_state *st = adap->dev->priv;
787 static u8 voltage_low[] = LME_VOLTAGE_L;
788 static u8 voltage_high[] = LME_VOLTAGE_H;
789 static u8 lnb_on[] = LNB_ON;
790 static u8 lnb_off[] = LNB_OFF;
791 static u8 rbuf[1];
792 int ret = 0, len = 3, rlen = 1;
793
794 if (st->stream_on == 1)
795 return 0;
796
797 ret |= lme2510_usb_talk(adap->dev, lnb_on, len, rbuf, rlen);
798
799 switch (voltage) {
800 case SEC_VOLTAGE_18:
801 ret |= lme2510_usb_talk(adap->dev,
802 voltage_high, len, rbuf, rlen);
803 break;
804
805 case SEC_VOLTAGE_OFF:
806 ret |= lme2510_usb_talk(adap->dev,
807 lnb_off, len, rbuf, rlen);
808 case SEC_VOLTAGE_13:
809 default:
810 ret |= lme2510_usb_talk(adap->dev,
811 voltage_low, len, rbuf, rlen);
812 break;
813
814
815 };
816 st->i2c_talk_onoff = 1;
817 return (ret < 0) ? -ENODEV : 0;
818}
819
820static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap)
821{
822 int ret = 0;
823 struct lme2510_state *st = adap->dev->priv;
824
825 /* Interupt Start */
826 ret = lme2510_int_service(adap);
827 if (ret < 0) {
828 info("INT Unable to start Interupt Service");
829 return -ENODEV;
830 }
831
832 st->i2c_talk_onoff = 1;
833 st->i2c_gate = 4;
834
835 adap->fe = dvb_attach(tda10086_attach, &tda10086_config,
836 &adap->dev->i2c_adap);
837
838 if (adap->fe) {
839 info("TUN Found Frontend TDA10086");
840 memcpy(&adap->fe->ops.info.name,
841 &"DM04_LG_TDQY-P001F DVB-S", 24);
842 adap->fe->ops.set_voltage = dm04_lme2510_set_voltage;
843 st->i2c_tuner_gate_w = 4;
844 st->i2c_tuner_gate_r = 4;
845 st->i2c_tuner_addr = 0xc0;
846 if (dvb_attach(tda826x_attach, adap->fe, 0xc0,
847 &adap->dev->i2c_adap, 1)) {
848 info("TUN TDA8263 Found");
849 st->tuner_config = TUNER_LG;
850 if (dvb_usb_lme2510_firmware != 1) {
851 dvb_usb_lme2510_firmware = 1;
852 lme_firmware_switch(adap->dev->udev, 1);
853 }
854 return 0;
855 }
856 kfree(adap->fe);
857 adap->fe = NULL;
858 }
859 st->i2c_gate = 5;
860 adap->fe = dvb_attach(stv0288_attach, &lme_config,
861 &adap->dev->i2c_adap);
862
863 if (adap->fe) {
864 info("FE Found Stv0288");
865 memcpy(&adap->fe->ops.info.name,
866 &"DM04_SHARP:BS2F7HZ7395", 22);
867 adap->fe->ops.set_voltage = dm04_lme2510_set_voltage;
868 st->i2c_tuner_gate_w = 4;
869 st->i2c_tuner_gate_r = 5;
870 st->i2c_tuner_addr = 0xc0;
871 if (dvb_attach(ix2505v_attach , adap->fe, &lme_tuner,
872 &adap->dev->i2c_adap)) {
873 st->tuner_config = TUNER_S7395;
874 info("TUN Sharp IX2505V silicon tuner");
875 if (dvb_usb_lme2510_firmware != 0) {
876 dvb_usb_lme2510_firmware = 0;
877 lme_firmware_switch(adap->dev->udev, 1);
878 }
879 return 0;
880 }
881 kfree(adap->fe);
882 adap->fe = NULL;
883 }
884
885 info("DM04 Not Supported");
886 return -ENODEV;
887}
888
889static int lme2510_powerup(struct dvb_usb_device *d, int onoff)
890{
891 struct lme2510_state *st = d->priv;
892 st->i2c_talk_onoff = 1;
893 return 0;
894}
895
896/* DVB USB Driver stuff */
897static struct dvb_usb_device_properties lme2510_properties;
898static struct dvb_usb_device_properties lme2510c_properties;
899
900static int lme2510_probe(struct usb_interface *intf,
901 const struct usb_device_id *id)
902{
903 struct usb_device *udev = interface_to_usbdev(intf);
904 int ret = 0;
905
906 usb_reset_configuration(udev);
907
908 usb_set_interface(udev, intf->cur_altsetting->desc.bInterfaceNumber, 1);
909
910 if (udev->speed != USB_SPEED_HIGH) {
911 ret = usb_reset_device(udev);
912 info("DEV Failed to connect in HIGH SPEED mode");
913 return -ENODEV;
914 }
915
916 lme_firmware_switch(udev, 0);
917
918 if (0 == dvb_usb_device_init(intf, &lme2510_properties,
919 THIS_MODULE, NULL, adapter_nr)) {
920 info("DEV registering device driver");
921 return 0;
922 }
923 if (0 == dvb_usb_device_init(intf, &lme2510c_properties,
924 THIS_MODULE, NULL, adapter_nr)) {
925 info("DEV registering device driver");
926 return 0;
927 }
928
929 info("DEV lme2510 Error");
930 return -ENODEV;
931
932}
933
934static struct usb_device_id lme2510_table[] = {
935 { USB_DEVICE(0x3344, 0x1122) }, /* LME2510 */
936 { USB_DEVICE(0x3344, 0x1120) }, /* LME2510C */
937 {} /* Terminating entry */
938};
939
940MODULE_DEVICE_TABLE(usb, lme2510_table);
941
942static struct dvb_usb_device_properties lme2510_properties = {
943 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
944 .usb_ctrl = DEVICE_SPECIFIC,
945 .download_firmware = lme2510_download_firmware,
946 .firmware = "dvb-usb-lme2510-lg.fw",
947
948 .size_of_priv = sizeof(struct lme2510_state),
949 .num_adapters = 1,
950 .adapter = {
951 {
952 .streaming_ctrl = lme2510_streaming_ctrl,
953 .frontend_attach = dm04_lme2510_frontend_attach,
954 /* parameter for the MPEG2-data transfer */
955 .stream = {
956 .type = USB_BULK,
957 .count = 10,
958 .endpoint = 0x06,
959 .u = {
960 .bulk = {
961 .buffersize = 4096,
962
963 }
964 }
965 }
966 }
967 },
968 .power_ctrl = lme2510_powerup,
969 .identify_state = lme2510_identify_state,
970 .i2c_algo = &lme2510_i2c_algo,
971 .generic_bulk_ctrl_endpoint = 0,
972 .num_device_descs = 1,
973 .devices = {
974 { "DM04 LME2510 DVB-S USB 2.0",
975 { &lme2510_table[0], NULL },
976 },
977
978 }
979};
980
981static struct dvb_usb_device_properties lme2510c_properties = {
982 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
983 .usb_ctrl = DEVICE_SPECIFIC,
984 .download_firmware = lme2510_download_firmware,
985 .firmware = lme_firmware,
986 .size_of_priv = sizeof(struct lme2510_state),
987 .num_adapters = 1,
988 .adapter = {
989 {
990 .streaming_ctrl = lme2510_streaming_ctrl,
991 .frontend_attach = dm04_lme2510_frontend_attach,
992 /* parameter for the MPEG2-data transfer */
993 .stream = {
994 .type = USB_BULK,
995 .count = 10,
996 .endpoint = 0x8,
997 .u = {
998 .bulk = {
999 .buffersize = 4096,
1000
1001 }
1002 }
1003 }
1004 }
1005 },
1006 .power_ctrl = lme2510_powerup,
1007 .identify_state = lme2510_identify_state,
1008 .i2c_algo = &lme2510_i2c_algo,
1009 .generic_bulk_ctrl_endpoint = 0,
1010 .num_device_descs = 1,
1011 .devices = {
1012 { "DM04 LME2510C USB2.0",
1013 { &lme2510_table[1], NULL },
1014 },
1015 }
1016};
1017
1018void *lme2510_exit_int(struct dvb_usb_device *d)
1019{
1020 struct lme2510_state *st = d->priv;
1021 struct dvb_usb_adapter *adap = &d->adapter[0];
1022 void *buffer = NULL;
1023
1024 if (adap != NULL) {
1025 lme2510_kill_urb(&adap->stream);
1026 adap->feedcount = 0;
1027 }
1028
1029 if (st->lme_urb != NULL) {
1030 st->i2c_talk_onoff = 1;
1031 st->signal_lock = 0;
1032 st->signal_level = 0;
1033 st->signal_sn = 0;
1034 buffer = st->usb_buffer;
1035 usb_kill_urb(st->lme_urb);
1036 usb_free_coherent(d->udev, 5000, st->buffer,
1037 st->lme_urb->transfer_dma);
1038 info("Interupt Service Stopped");
1039 ir_input_unregister(d->rc_input_dev);
1040 info("Remote Stopped");
1041 }
1042 return buffer;
1043}
1044
1045void lme2510_exit(struct usb_interface *intf)
1046{
1047 struct dvb_usb_device *d = usb_get_intfdata(intf);
1048 void *usb_buffer;
1049
1050 if (d != NULL) {
1051 usb_buffer = lme2510_exit_int(d);
1052 dvb_usb_device_exit(intf);
1053 kfree(usb_buffer);
1054 }
1055}
1056
1057static struct usb_driver lme2510_driver = {
1058 .name = "LME2510C_DVBS",
1059 .probe = lme2510_probe,
1060 .disconnect = lme2510_exit,
1061 .id_table = lme2510_table,
1062};
1063
1064/* module stuff */
1065static int __init lme2510_module_init(void)
1066{
1067 int result = usb_register(&lme2510_driver);
1068 if (result) {
1069 err("usb_register failed. Error number %d", result);
1070 return result;
1071 }
1072
1073 return 0;
1074}
1075
1076static void __exit lme2510_module_exit(void)
1077{
1078 /* deregister this driver from the USB subsystem */
1079 usb_deregister(&lme2510_driver);
1080}
1081
1082module_init(lme2510_module_init);
1083module_exit(lme2510_module_exit);
1084
1085MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1086MODULE_DESCRIPTION("LM2510(C) DVB-S USB2.0");
1087MODULE_VERSION("1.60");
1088MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.h b/drivers/media/dvb/dvb-usb/lmedm04.h
new file mode 100644
index 000000000000..e6af16c1e3e5
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/lmedm04.h
@@ -0,0 +1,173 @@
1/* DVB USB compliant linux driver for
2 *
3 * DM04/QQBOX DVB-S USB BOX LME2510C + SHARP:BS2F7HZ7395
4 * LME2510C + LG TDQY-P001F
5 * LME2510 + LG TDQY-P001F
6 *
7 * MVB7395 (LME2510C+SHARP:BS2F7HZ7395)
8 * SHARP:BS2F7HZ7395 = (STV0288+Sharp IX2505V)
9 *
10 * MVB001F (LME2510+LGTDQT-P001F)
11 * LG TDQY - P001F =(TDA8263 + TDA10086H)
12 *
13 * MVB0001F (LME2510C+LGTDQT-P001F)
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the Free
17 * Software Foundation, version 2.
18 * *
19 * see Documentation/dvb/README.dvb-usb for more information
20 */
21#ifndef _DVB_USB_LME2510_H_
22#define _DVB_USB_LME2510_H_
23
24/* Streamer & PID
25 *
26 * Note: These commands do not actually stop the streaming
27 * but form some kind of packet filtering/stream count
28 * or tuning related functions.
29 * 06 XX
30 * offset 1 = 00 Enable Streaming
31 *
32 *
33 * PID
34 * 03 XX XX ----> reg number ---> setting....20 XX
35 * offset 1 = length
36 * offset 2 = start of data
37 * end byte -1 = 20
38 * end byte = clear pid always a0, other wise 9c, 9a ??
39 *
40*/
41#define LME_ST_ON_W {0x06, 0x00}
42#define LME_CLEAR_PID {0x03, 0x02, 0x20, 0xa0}
43
44/* LNB Voltage
45 * 07 XX XX
46 * offset 1 = 01
47 * offset 2 = 00=Voltage low 01=Voltage high
48 *
49 * LNB Power
50 * 03 01 XX
51 * offset 2 = 00=ON 01=OFF
52 */
53
54#define LME_VOLTAGE_L {0x07, 0x01, 0x00}
55#define LME_VOLTAGE_H {0x07, 0x01, 0x01}
56#define LNB_ON {0x3a, 0x01, 0x00}
57#define LNB_OFF {0x3a, 0x01, 0x01}
58
59/* Initial stv0288 settings for 7395 Frontend */
60static u8 s7395_inittab[] = {
61 0x01, 0x15,
62 0x02, 0x20,
63 0x03, 0xa0,
64 0x04, 0xa0,
65 0x05, 0x12,
66 0x06, 0x00,
67 0x09, 0x00,
68 0x0a, 0x04,
69 0x0b, 0x00,
70 0x0c, 0x00,
71 0x0d, 0x00,
72 0x0e, 0xc1,
73 0x0f, 0x54,
74 0x11, 0x7a,
75 0x12, 0x03,
76 0x13, 0x48,
77 0x14, 0x84,
78 0x15, 0xc5,
79 0x16, 0xb8,
80 0x17, 0x9c,
81 0x18, 0x00,
82 0x19, 0xa6,
83 0x1a, 0x88,
84 0x1b, 0x8f,
85 0x1c, 0xf0,
86 0x20, 0x0b,
87 0x21, 0x54,
88 0x22, 0xff,
89 0x23, 0x01,
90 0x28, 0x46,
91 0x29, 0x66,
92 0x2a, 0x90,
93 0x2b, 0xfa,
94 0x2c, 0xd9,
95 0x30, 0x0,
96 0x31, 0x1e,
97 0x32, 0x14,
98 0x33, 0x0f,
99 0x34, 0x09,
100 0x35, 0x0c,
101 0x36, 0x05,
102 0x37, 0x2f,
103 0x38, 0x16,
104 0x39, 0xbd,
105 0x3a, 0x0,
106 0x3b, 0x13,
107 0x3c, 0x11,
108 0x3d, 0x30,
109 0x40, 0x63,
110 0x41, 0x04,
111 0x42, 0x60,
112 0x43, 0x00,
113 0x44, 0x00,
114 0x45, 0x00,
115 0x46, 0x00,
116 0x47, 0x00,
117 0x4a, 0x00,
118 0x50, 0x12,
119 0x51, 0x36,
120 0x52, 0x21,
121 0x53, 0x94,
122 0x54, 0xb2,
123 0x55, 0x29,
124 0x56, 0x64,
125 0x57, 0x2b,
126 0x58, 0x54,
127 0x59, 0x86,
128 0x5a, 0x00,
129 0x5b, 0x9b,
130 0x5c, 0x08,
131 0x5d, 0x7f,
132 0x5e, 0xff,
133 0x5f, 0x8d,
134 0x70, 0x0,
135 0x71, 0x0,
136 0x72, 0x0,
137 0x74, 0x0,
138 0x75, 0x0,
139 0x76, 0x0,
140 0x81, 0x0,
141 0x82, 0x3f,
142 0x83, 0x3f,
143 0x84, 0x0,
144 0x85, 0x0,
145 0x88, 0x0,
146 0x89, 0x0,
147 0x8a, 0x0,
148 0x8b, 0x0,
149 0x8c, 0x0,
150 0x90, 0x0,
151 0x91, 0x0,
152 0x92, 0x0,
153 0x93, 0x0,
154 0x94, 0x1c,
155 0x97, 0x0,
156 0xa0, 0x48,
157 0xa1, 0x0,
158 0xb0, 0xb8,
159 0xb1, 0x3a,
160 0xb2, 0x10,
161 0xb3, 0x82,
162 0xb4, 0x80,
163 0xb5, 0x82,
164 0xb6, 0x82,
165 0xb7, 0x82,
166 0xb8, 0x20,
167 0xb9, 0x0,
168 0xf0, 0x0,
169 0xf1, 0x0,
170 0xf2, 0xc0,
171 0xff, 0xff,
172};
173#endif
diff --git a/drivers/media/dvb/firewire/firedtv-avc.c b/drivers/media/dvb/firewire/firedtv-avc.c
index 28294af752db..f0f1842fab60 100644
--- a/drivers/media/dvb/firewire/firedtv-avc.c
+++ b/drivers/media/dvb/firewire/firedtv-avc.c
@@ -24,6 +24,8 @@
24#include <linux/wait.h> 24#include <linux/wait.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26 26
27#include <dvb_frontend.h>
28
27#include "firedtv.h" 29#include "firedtv.h"
28 30
29#define FCP_COMMAND_REGISTER 0xfffff0000b00ULL 31#define FCP_COMMAND_REGISTER 0xfffff0000b00ULL
@@ -130,6 +132,20 @@ MODULE_PARM_DESC(debug, "Verbose logging (none = 0"
130 ", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS) 132 ", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS)
131 ", or a combination, or all = -1)"); 133 ", or a combination, or all = -1)");
132 134
135/*
136 * This is a workaround since there is no vendor specific command to retrieve
137 * ca_info using AVC. If this parameter is not used, ca_system_id will be
138 * filled with application_manufacturer from ca_app_info.
139 * Digital Everywhere have said that adding ca_info is on their TODO list.
140 */
141static unsigned int num_fake_ca_system_ids;
142static int fake_ca_system_ids[4] = { -1, -1, -1, -1 };
143module_param_array(fake_ca_system_ids, int, &num_fake_ca_system_ids, 0644);
144MODULE_PARM_DESC(fake_ca_system_ids, "If your CAM application manufacturer "
145 "does not have the same ca_system_id as your CAS, you can "
146 "override what ca_system_ids are presented to the "
147 "application by setting this field to an array of ids.");
148
133static const char *debug_fcp_ctype(unsigned int ctype) 149static const char *debug_fcp_ctype(unsigned int ctype)
134{ 150{
135 static const char *ctypes[] = { 151 static const char *ctypes[] = {
@@ -368,10 +384,30 @@ static int avc_tuner_tuneqpsk(struct firedtv *fdtv,
368 c->operand[12] = 0; 384 c->operand[12] = 0;
369 385
370 if (fdtv->type == FIREDTV_DVB_S2) { 386 if (fdtv->type == FIREDTV_DVB_S2) {
371 c->operand[13] = 0x1; 387 if (fdtv->fe.dtv_property_cache.delivery_system == SYS_DVBS2) {
372 c->operand[14] = 0xff; 388 switch (fdtv->fe.dtv_property_cache.modulation) {
373 c->operand[15] = 0xff; 389 case QAM_16: c->operand[13] = 0x1; break;
374 390 case QPSK: c->operand[13] = 0x2; break;
391 case PSK_8: c->operand[13] = 0x3; break;
392 default: c->operand[13] = 0x2; break;
393 }
394 switch (fdtv->fe.dtv_property_cache.rolloff) {
395 case ROLLOFF_AUTO: c->operand[14] = 0x2; break;
396 case ROLLOFF_35: c->operand[14] = 0x2; break;
397 case ROLLOFF_20: c->operand[14] = 0x0; break;
398 case ROLLOFF_25: c->operand[14] = 0x1; break;
399 /* case ROLLOFF_NONE: c->operand[14] = 0xff; break; */
400 }
401 switch (fdtv->fe.dtv_property_cache.pilot) {
402 case PILOT_AUTO: c->operand[15] = 0x0; break;
403 case PILOT_OFF: c->operand[15] = 0x0; break;
404 case PILOT_ON: c->operand[15] = 0x1; break;
405 }
406 } else {
407 c->operand[13] = 0x1; /* auto modulation */
408 c->operand[14] = 0xff; /* disable rolloff */
409 c->operand[15] = 0xff; /* disable pilot */
410 }
375 return 16; 411 return 16;
376 } else { 412 } else {
377 return 13; 413 return 13;
@@ -977,7 +1013,7 @@ int avc_ca_info(struct firedtv *fdtv, char *app_info, unsigned int *len)
977{ 1013{
978 struct avc_command_frame *c = (void *)fdtv->avc_data; 1014 struct avc_command_frame *c = (void *)fdtv->avc_data;
979 struct avc_response_frame *r = (void *)fdtv->avc_data; 1015 struct avc_response_frame *r = (void *)fdtv->avc_data;
980 int pos, ret; 1016 int i, pos, ret;
981 1017
982 mutex_lock(&fdtv->avc_mutex); 1018 mutex_lock(&fdtv->avc_mutex);
983 1019
@@ -1004,9 +1040,18 @@ int avc_ca_info(struct firedtv *fdtv, char *app_info, unsigned int *len)
1004 app_info[0] = (EN50221_TAG_CA_INFO >> 16) & 0xff; 1040 app_info[0] = (EN50221_TAG_CA_INFO >> 16) & 0xff;
1005 app_info[1] = (EN50221_TAG_CA_INFO >> 8) & 0xff; 1041 app_info[1] = (EN50221_TAG_CA_INFO >> 8) & 0xff;
1006 app_info[2] = (EN50221_TAG_CA_INFO >> 0) & 0xff; 1042 app_info[2] = (EN50221_TAG_CA_INFO >> 0) & 0xff;
1007 app_info[3] = 2; 1043 if (num_fake_ca_system_ids == 0) {
1008 app_info[4] = r->operand[pos + 0]; 1044 app_info[3] = 2;
1009 app_info[5] = r->operand[pos + 1]; 1045 app_info[4] = r->operand[pos + 0];
1046 app_info[5] = r->operand[pos + 1];
1047 } else {
1048 app_info[3] = num_fake_ca_system_ids * 2;
1049 for (i = 0; i < num_fake_ca_system_ids; i++) {
1050 app_info[4 + i * 2] =
1051 (fake_ca_system_ids[i] >> 8) & 0xff;
1052 app_info[5 + i * 2] = fake_ca_system_ids[i] & 0xff;
1053 }
1054 }
1010 *len = app_info[3] + 4; 1055 *len = app_info[3] + 4;
1011out: 1056out:
1012 mutex_unlock(&fdtv->avc_mutex); 1057 mutex_unlock(&fdtv->avc_mutex);
diff --git a/drivers/media/dvb/firewire/firedtv-fe.c b/drivers/media/dvb/firewire/firedtv-fe.c
index e49cdc88b0c7..d10920e2f3a2 100644
--- a/drivers/media/dvb/firewire/firedtv-fe.c
+++ b/drivers/media/dvb/firewire/firedtv-fe.c
@@ -155,6 +155,16 @@ static int fdtv_get_frontend(struct dvb_frontend *fe,
155 return -EOPNOTSUPP; 155 return -EOPNOTSUPP;
156} 156}
157 157
158static int fdtv_get_property(struct dvb_frontend *fe, struct dtv_property *tvp)
159{
160 return 0;
161}
162
163static int fdtv_set_property(struct dvb_frontend *fe, struct dtv_property *tvp)
164{
165 return 0;
166}
167
158void fdtv_frontend_init(struct firedtv *fdtv) 168void fdtv_frontend_init(struct firedtv *fdtv)
159{ 169{
160 struct dvb_frontend_ops *ops = &fdtv->fe.ops; 170 struct dvb_frontend_ops *ops = &fdtv->fe.ops;
@@ -166,6 +176,9 @@ void fdtv_frontend_init(struct firedtv *fdtv)
166 ops->set_frontend = fdtv_set_frontend; 176 ops->set_frontend = fdtv_set_frontend;
167 ops->get_frontend = fdtv_get_frontend; 177 ops->get_frontend = fdtv_get_frontend;
168 178
179 ops->get_property = fdtv_get_property;
180 ops->set_property = fdtv_set_property;
181
169 ops->read_status = fdtv_read_status; 182 ops->read_status = fdtv_read_status;
170 ops->read_ber = fdtv_read_ber; 183 ops->read_ber = fdtv_read_ber;
171 ops->read_signal_strength = fdtv_read_signal_strength; 184 ops->read_signal_strength = fdtv_read_signal_strength;
@@ -179,7 +192,6 @@ void fdtv_frontend_init(struct firedtv *fdtv)
179 192
180 switch (fdtv->type) { 193 switch (fdtv->type) {
181 case FIREDTV_DVB_S: 194 case FIREDTV_DVB_S:
182 case FIREDTV_DVB_S2:
183 fi->type = FE_QPSK; 195 fi->type = FE_QPSK;
184 196
185 fi->frequency_min = 950000; 197 fi->frequency_min = 950000;
@@ -188,7 +200,7 @@ void fdtv_frontend_init(struct firedtv *fdtv)
188 fi->symbol_rate_min = 1000000; 200 fi->symbol_rate_min = 1000000;
189 fi->symbol_rate_max = 40000000; 201 fi->symbol_rate_max = 40000000;
190 202
191 fi->caps = FE_CAN_INVERSION_AUTO | 203 fi->caps = FE_CAN_INVERSION_AUTO |
192 FE_CAN_FEC_1_2 | 204 FE_CAN_FEC_1_2 |
193 FE_CAN_FEC_2_3 | 205 FE_CAN_FEC_2_3 |
194 FE_CAN_FEC_3_4 | 206 FE_CAN_FEC_3_4 |
@@ -198,6 +210,26 @@ void fdtv_frontend_init(struct firedtv *fdtv)
198 FE_CAN_QPSK; 210 FE_CAN_QPSK;
199 break; 211 break;
200 212
213 case FIREDTV_DVB_S2:
214 fi->type = FE_QPSK;
215
216 fi->frequency_min = 950000;
217 fi->frequency_max = 2150000;
218 fi->frequency_stepsize = 125;
219 fi->symbol_rate_min = 1000000;
220 fi->symbol_rate_max = 40000000;
221
222 fi->caps = FE_CAN_INVERSION_AUTO |
223 FE_CAN_FEC_1_2 |
224 FE_CAN_FEC_2_3 |
225 FE_CAN_FEC_3_4 |
226 FE_CAN_FEC_5_6 |
227 FE_CAN_FEC_7_8 |
228 FE_CAN_FEC_AUTO |
229 FE_CAN_QPSK |
230 FE_CAN_2G_MODULATION;
231 break;
232
201 case FIREDTV_DVB_C: 233 case FIREDTV_DVB_C:
202 fi->type = FE_QAM; 234 fi->type = FE_QAM;
203 235
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index b5f6a04f9c12..e9062b08a485 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -257,6 +257,13 @@ config DVB_CX22702
257 help 257 help
258 A DVB-T tuner module. Say Y when you want to support this frontend. 258 A DVB-T tuner module. Say Y when you want to support this frontend.
259 259
260config DVB_S5H1432
261 tristate "Samsung s5h1432 demodulator (OFDM)"
262 depends on DVB_CORE && I2C
263 default m if DVB_FE_CUSTOMISE
264 help
265 A DVB-T tuner module. Say Y when you want to support this frontend.
266
260config DVB_DRX397XD 267config DVB_DRX397XD
261 tristate "Micronas DRX3975D/DRX3977D based" 268 tristate "Micronas DRX3975D/DRX3977D based"
262 depends on DVB_CORE && I2C 269 depends on DVB_CORE && I2C
@@ -455,16 +462,8 @@ config DVB_LGDT330X
455 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 462 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
456 to support this frontend. 463 to support this frontend.
457 464
458config DVB_LGDT3304
459 tristate "LG Electronics LGDT3304"
460 depends on DVB_CORE && I2C
461 default m if DVB_FE_CUSTOMISE
462 help
463 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
464 to support this frontend.
465
466config DVB_LGDT3305 465config DVB_LGDT3305
467 tristate "LG Electronics LGDT3305 based" 466 tristate "LG Electronics LGDT3304 and LGDT3305 based"
468 depends on DVB_CORE && I2C 467 depends on DVB_CORE && I2C
469 default m if DVB_FE_CUSTOMISE 468 default m if DVB_FE_CUSTOMISE
470 help 469 help
@@ -607,6 +606,13 @@ config DVB_TDA665x
607 Currently supported tuners: 606 Currently supported tuners:
608 * Panasonic ENV57H12D5 (ET-50DT) 607 * Panasonic ENV57H12D5 (ET-50DT)
609 608
609config DVB_IX2505V
610 tristate "Sharp IX2505V silicon tuner"
611 depends on DVB_CORE && I2C
612 default m if DVB_FE_CUSTOMISE
613 help
614 A DVB-S tuner module. Say Y when you want to support this frontend.
615
610comment "Tools to develop new frontends" 616comment "Tools to develop new frontends"
611 617
612config DVB_DUMMY_FE 618config DVB_DUMMY_FE
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index 874e8ada4d1d..9a31985c0dfb 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_DVB_STB0899) += stb0899.o
16obj-$(CONFIG_DVB_STB6100) += stb6100.o 16obj-$(CONFIG_DVB_STB6100) += stb6100.o
17obj-$(CONFIG_DVB_SP8870) += sp8870.o 17obj-$(CONFIG_DVB_SP8870) += sp8870.o
18obj-$(CONFIG_DVB_CX22700) += cx22700.o 18obj-$(CONFIG_DVB_CX22700) += cx22700.o
19obj-$(CONFIG_DVB_S5H1432) += s5h1432.o
19obj-$(CONFIG_DVB_CX24110) += cx24110.o 20obj-$(CONFIG_DVB_CX24110) += cx24110.o
20obj-$(CONFIG_DVB_TDA8083) += tda8083.o 21obj-$(CONFIG_DVB_TDA8083) += tda8083.o
21obj-$(CONFIG_DVB_L64781) += l64781.o 22obj-$(CONFIG_DVB_L64781) += l64781.o
@@ -45,7 +46,6 @@ obj-$(CONFIG_DVB_OR51132) += or51132.o
45obj-$(CONFIG_DVB_BCM3510) += bcm3510.o 46obj-$(CONFIG_DVB_BCM3510) += bcm3510.o
46obj-$(CONFIG_DVB_S5H1420) += s5h1420.o 47obj-$(CONFIG_DVB_S5H1420) += s5h1420.o
47obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o 48obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o
48obj-$(CONFIG_DVB_LGDT3304) += lgdt3304.o
49obj-$(CONFIG_DVB_LGDT3305) += lgdt3305.o 49obj-$(CONFIG_DVB_LGDT3305) += lgdt3305.o
50obj-$(CONFIG_DVB_CX24123) += cx24123.o 50obj-$(CONFIG_DVB_CX24123) += cx24123.o
51obj-$(CONFIG_DVB_LNBP21) += lnbp21.o 51obj-$(CONFIG_DVB_LNBP21) += lnbp21.o
@@ -82,3 +82,4 @@ obj-$(CONFIG_DVB_ISL6423) += isl6423.o
82obj-$(CONFIG_DVB_EC100) += ec100.o 82obj-$(CONFIG_DVB_EC100) += ec100.o
83obj-$(CONFIG_DVB_DS3000) += ds3000.o 83obj-$(CONFIG_DVB_DS3000) += ds3000.o
84obj-$(CONFIG_DVB_MB86A16) += mb86a16.o 84obj-$(CONFIG_DVB_MB86A16) += mb86a16.o
85obj-$(CONFIG_DVB_IX2505V) += ix2505v.o
diff --git a/drivers/media/dvb/frontends/af9013.c b/drivers/media/dvb/frontends/af9013.c
index dac917f7bb7f..e2a95c07bab4 100644
--- a/drivers/media/dvb/frontends/af9013.c
+++ b/drivers/media/dvb/frontends/af9013.c
@@ -42,6 +42,8 @@ struct af9013_state {
42 42
43 struct af9013_config config; 43 struct af9013_config config;
44 44
45 /* tuner/demod RF and IF AGC limits used for signal strength calc */
46 u8 signal_strength_en, rf_50, rf_80, if_50, if_80;
45 u16 signal_strength; 47 u16 signal_strength;
46 u32 ber; 48 u32 ber;
47 u32 ucblocks; 49 u32 ucblocks;
@@ -220,184 +222,37 @@ static u32 af913_div(u32 a, u32 b, u32 x)
220 222
221static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw) 223static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw)
222{ 224{
223 int ret = 0; 225 int ret, i, j, found;
224 u8 i = 0;
225 u8 buf[24];
226 u32 uninitialized_var(ns_coeff1_2048nu);
227 u32 uninitialized_var(ns_coeff1_8191nu);
228 u32 uninitialized_var(ns_coeff1_8192nu);
229 u32 uninitialized_var(ns_coeff1_8193nu);
230 u32 uninitialized_var(ns_coeff2_2k);
231 u32 uninitialized_var(ns_coeff2_8k);
232
233 deb_info("%s: adc_clock:%d bw:%d\n", __func__, 226 deb_info("%s: adc_clock:%d bw:%d\n", __func__,
234 state->config.adc_clock, bw); 227 state->config.adc_clock, bw);
235 228
236 switch (state->config.adc_clock) { 229 /* lookup coeff from table */
237 case 28800: /* 28.800 MHz */ 230 for (i = 0, found = 0; i < ARRAY_SIZE(coeff_table); i++) {
238 switch (bw) { 231 if (coeff_table[i].adc_clock == state->config.adc_clock &&
239 case BANDWIDTH_6_MHZ: 232 coeff_table[i].bw == bw) {
240 ns_coeff1_2048nu = 0x01e79e7a; 233 found = 1;
241 ns_coeff1_8191nu = 0x0079eb6e;
242 ns_coeff1_8192nu = 0x0079e79e;
243 ns_coeff1_8193nu = 0x0079e3cf;
244 ns_coeff2_2k = 0x00f3cf3d;
245 ns_coeff2_8k = 0x003cf3cf;
246 break;
247 case BANDWIDTH_7_MHZ:
248 ns_coeff1_2048nu = 0x0238e38e;
249 ns_coeff1_8191nu = 0x008e3d55;
250 ns_coeff1_8192nu = 0x008e38e4;
251 ns_coeff1_8193nu = 0x008e3472;
252 ns_coeff2_2k = 0x011c71c7;
253 ns_coeff2_8k = 0x00471c72;
254 break; 234 break;
255 case BANDWIDTH_8_MHZ:
256 ns_coeff1_2048nu = 0x028a28a3;
257 ns_coeff1_8191nu = 0x00a28f3d;
258 ns_coeff1_8192nu = 0x00a28a29;
259 ns_coeff1_8193nu = 0x00a28514;
260 ns_coeff2_2k = 0x01451451;
261 ns_coeff2_8k = 0x00514514;
262 break;
263 default:
264 ret = -EINVAL;
265 } 235 }
266 break;
267 case 20480: /* 20.480 MHz */
268 switch (bw) {
269 case BANDWIDTH_6_MHZ:
270 ns_coeff1_2048nu = 0x02adb6dc;
271 ns_coeff1_8191nu = 0x00ab7313;
272 ns_coeff1_8192nu = 0x00ab6db7;
273 ns_coeff1_8193nu = 0x00ab685c;
274 ns_coeff2_2k = 0x0156db6e;
275 ns_coeff2_8k = 0x0055b6dc;
276 break;
277 case BANDWIDTH_7_MHZ:
278 ns_coeff1_2048nu = 0x03200001;
279 ns_coeff1_8191nu = 0x00c80640;
280 ns_coeff1_8192nu = 0x00c80000;
281 ns_coeff1_8193nu = 0x00c7f9c0;
282 ns_coeff2_2k = 0x01900000;
283 ns_coeff2_8k = 0x00640000;
284 break;
285 case BANDWIDTH_8_MHZ:
286 ns_coeff1_2048nu = 0x03924926;
287 ns_coeff1_8191nu = 0x00e4996e;
288 ns_coeff1_8192nu = 0x00e49249;
289 ns_coeff1_8193nu = 0x00e48b25;
290 ns_coeff2_2k = 0x01c92493;
291 ns_coeff2_8k = 0x00724925;
292 break;
293 default:
294 ret = -EINVAL;
295 }
296 break;
297 case 28000: /* 28.000 MHz */
298 switch (bw) {
299 case BANDWIDTH_6_MHZ:
300 ns_coeff1_2048nu = 0x01f58d10;
301 ns_coeff1_8191nu = 0x007d672f;
302 ns_coeff1_8192nu = 0x007d6344;
303 ns_coeff1_8193nu = 0x007d5f59;
304 ns_coeff2_2k = 0x00fac688;
305 ns_coeff2_8k = 0x003eb1a2;
306 break;
307 case BANDWIDTH_7_MHZ:
308 ns_coeff1_2048nu = 0x02492492;
309 ns_coeff1_8191nu = 0x00924db7;
310 ns_coeff1_8192nu = 0x00924925;
311 ns_coeff1_8193nu = 0x00924492;
312 ns_coeff2_2k = 0x01249249;
313 ns_coeff2_8k = 0x00492492;
314 break;
315 case BANDWIDTH_8_MHZ:
316 ns_coeff1_2048nu = 0x029cbc15;
317 ns_coeff1_8191nu = 0x00a7343f;
318 ns_coeff1_8192nu = 0x00a72f05;
319 ns_coeff1_8193nu = 0x00a729cc;
320 ns_coeff2_2k = 0x014e5e0a;
321 ns_coeff2_8k = 0x00539783;
322 break;
323 default:
324 ret = -EINVAL;
325 }
326 break;
327 case 25000: /* 25.000 MHz */
328 switch (bw) {
329 case BANDWIDTH_6_MHZ:
330 ns_coeff1_2048nu = 0x0231bcb5;
331 ns_coeff1_8191nu = 0x008c7391;
332 ns_coeff1_8192nu = 0x008c6f2d;
333 ns_coeff1_8193nu = 0x008c6aca;
334 ns_coeff2_2k = 0x0118de5b;
335 ns_coeff2_8k = 0x00463797;
336 break;
337 case BANDWIDTH_7_MHZ:
338 ns_coeff1_2048nu = 0x028f5c29;
339 ns_coeff1_8191nu = 0x00a3dc29;
340 ns_coeff1_8192nu = 0x00a3d70a;
341 ns_coeff1_8193nu = 0x00a3d1ec;
342 ns_coeff2_2k = 0x0147ae14;
343 ns_coeff2_8k = 0x0051eb85;
344 break;
345 case BANDWIDTH_8_MHZ:
346 ns_coeff1_2048nu = 0x02ecfb9d;
347 ns_coeff1_8191nu = 0x00bb44c1;
348 ns_coeff1_8192nu = 0x00bb3ee7;
349 ns_coeff1_8193nu = 0x00bb390d;
350 ns_coeff2_2k = 0x01767dce;
351 ns_coeff2_8k = 0x005d9f74;
352 break;
353 default:
354 ret = -EINVAL;
355 }
356 break;
357 default:
358 err("invalid xtal");
359 return -EINVAL;
360 } 236 }
361 if (ret) { 237
362 err("invalid bandwidth"); 238 if (!found) {
363 return ret; 239 err("invalid bw or clock");
240 ret = -EINVAL;
241 goto error;
364 } 242 }
365 243
366 buf[i++] = (u8) ((ns_coeff1_2048nu & 0x03000000) >> 24); 244 deb_info("%s: coeff: ", __func__);
367 buf[i++] = (u8) ((ns_coeff1_2048nu & 0x00ff0000) >> 16); 245 debug_dump(coeff_table[i].val, sizeof(coeff_table[i].val), deb_info);
368 buf[i++] = (u8) ((ns_coeff1_2048nu & 0x0000ff00) >> 8);
369 buf[i++] = (u8) ((ns_coeff1_2048nu & 0x000000ff));
370 buf[i++] = (u8) ((ns_coeff2_2k & 0x01c00000) >> 22);
371 buf[i++] = (u8) ((ns_coeff2_2k & 0x003fc000) >> 14);
372 buf[i++] = (u8) ((ns_coeff2_2k & 0x00003fc0) >> 6);
373 buf[i++] = (u8) ((ns_coeff2_2k & 0x0000003f));
374 buf[i++] = (u8) ((ns_coeff1_8191nu & 0x03000000) >> 24);
375 buf[i++] = (u8) ((ns_coeff1_8191nu & 0x00ffc000) >> 16);
376 buf[i++] = (u8) ((ns_coeff1_8191nu & 0x0000ff00) >> 8);
377 buf[i++] = (u8) ((ns_coeff1_8191nu & 0x000000ff));
378 buf[i++] = (u8) ((ns_coeff1_8192nu & 0x03000000) >> 24);
379 buf[i++] = (u8) ((ns_coeff1_8192nu & 0x00ffc000) >> 16);
380 buf[i++] = (u8) ((ns_coeff1_8192nu & 0x0000ff00) >> 8);
381 buf[i++] = (u8) ((ns_coeff1_8192nu & 0x000000ff));
382 buf[i++] = (u8) ((ns_coeff1_8193nu & 0x03000000) >> 24);
383 buf[i++] = (u8) ((ns_coeff1_8193nu & 0x00ffc000) >> 16);
384 buf[i++] = (u8) ((ns_coeff1_8193nu & 0x0000ff00) >> 8);
385 buf[i++] = (u8) ((ns_coeff1_8193nu & 0x000000ff));
386 buf[i++] = (u8) ((ns_coeff2_8k & 0x01c00000) >> 22);
387 buf[i++] = (u8) ((ns_coeff2_8k & 0x003fc000) >> 14);
388 buf[i++] = (u8) ((ns_coeff2_8k & 0x00003fc0) >> 6);
389 buf[i++] = (u8) ((ns_coeff2_8k & 0x0000003f));
390
391 deb_info("%s: coeff:", __func__);
392 debug_dump(buf, sizeof(buf), deb_info);
393 246
394 /* program */ 247 /* program */
395 for (i = 0; i < sizeof(buf); i++) { 248 for (j = 0; j < sizeof(coeff_table[i].val); j++) {
396 ret = af9013_write_reg(state, 0xae00 + i, buf[i]); 249 ret = af9013_write_reg(state, 0xae00 + j,
250 coeff_table[i].val[j]);
397 if (ret) 251 if (ret)
398 break; 252 break;
399 } 253 }
400 254
255error:
401 return ret; 256 return ret;
402} 257}
403 258
@@ -486,6 +341,19 @@ static int af9013_set_freq_ctrl(struct af9013_state *state, fe_bandwidth_t bw)
486 if_sample_freq = 4300000; /* 4.3 MHz */ 341 if_sample_freq = 4300000; /* 4.3 MHz */
487 break; 342 break;
488 } 343 }
344 } else if (state->config.tuner == AF9013_TUNER_TDA18218) {
345 switch (bw) {
346 case BANDWIDTH_6_MHZ:
347 if_sample_freq = 3000000; /* 3 MHz */
348 break;
349 case BANDWIDTH_7_MHZ:
350 if_sample_freq = 3500000; /* 3.5 MHz */
351 break;
352 case BANDWIDTH_8_MHZ:
353 default:
354 if_sample_freq = 4000000; /* 4 MHz */
355 break;
356 }
489 } 357 }
490 358
491 while (if_sample_freq > (adc_freq / 2)) 359 while (if_sample_freq > (adc_freq / 2))
@@ -1097,45 +965,31 @@ static int af9013_update_signal_strength(struct dvb_frontend *fe)
1097{ 965{
1098 struct af9013_state *state = fe->demodulator_priv; 966 struct af9013_state *state = fe->demodulator_priv;
1099 int ret; 967 int ret;
1100 u8 tmp0; 968 u8 rf_gain, if_gain;
1101 u8 rf_gain, rf_50, rf_80, if_gain, if_50, if_80;
1102 int signal_strength; 969 int signal_strength;
1103 970
1104 deb_info("%s\n", __func__); 971 deb_info("%s\n", __func__);
1105 972
1106 state->signal_strength = 0; 973 if (state->signal_strength_en) {
1107
1108 ret = af9013_read_reg_bits(state, 0x9bee, 0, 1, &tmp0);
1109 if (ret)
1110 goto error;
1111 if (tmp0) {
1112 ret = af9013_read_reg(state, 0x9bbd, &rf_50);
1113 if (ret)
1114 goto error;
1115 ret = af9013_read_reg(state, 0x9bd0, &rf_80);
1116 if (ret)
1117 goto error;
1118 ret = af9013_read_reg(state, 0x9be2, &if_50);
1119 if (ret)
1120 goto error;
1121 ret = af9013_read_reg(state, 0x9be4, &if_80);
1122 if (ret)
1123 goto error;
1124 ret = af9013_read_reg(state, 0xd07c, &rf_gain); 974 ret = af9013_read_reg(state, 0xd07c, &rf_gain);
1125 if (ret) 975 if (ret)
1126 goto error; 976 goto error;
1127 ret = af9013_read_reg(state, 0xd07d, &if_gain); 977 ret = af9013_read_reg(state, 0xd07d, &if_gain);
1128 if (ret) 978 if (ret)
1129 goto error; 979 goto error;
1130 signal_strength = (0xffff / (9 * (rf_50 + if_50) - \ 980 signal_strength = (0xffff / \
1131 11 * (rf_80 + if_80))) * (10 * (rf_gain + if_gain) - \ 981 (9 * (state->rf_50 + state->if_50) - \
1132 11 * (rf_80 + if_80)); 982 11 * (state->rf_80 + state->if_80))) * \
983 (10 * (rf_gain + if_gain) - \
984 11 * (state->rf_80 + state->if_80));
1133 if (signal_strength < 0) 985 if (signal_strength < 0)
1134 signal_strength = 0; 986 signal_strength = 0;
1135 else if (signal_strength > 0xffff) 987 else if (signal_strength > 0xffff)
1136 signal_strength = 0xffff; 988 signal_strength = 0xffff;
1137 989
1138 state->signal_strength = signal_strength; 990 state->signal_strength = signal_strength;
991 } else {
992 state->signal_strength = 0;
1139 } 993 }
1140 994
1141error: 995error:
@@ -1368,6 +1222,7 @@ static int af9013_init(struct dvb_frontend *fe)
1368 break; 1222 break;
1369 case AF9013_TUNER_MXL5005D: 1223 case AF9013_TUNER_MXL5005D:
1370 case AF9013_TUNER_MXL5005R: 1224 case AF9013_TUNER_MXL5005R:
1225 case AF9013_TUNER_MXL5007T:
1371 len = ARRAY_SIZE(tuner_init_mxl5005); 1226 len = ARRAY_SIZE(tuner_init_mxl5005);
1372 init = tuner_init_mxl5005; 1227 init = tuner_init_mxl5005;
1373 break; 1228 break;
@@ -1393,6 +1248,7 @@ static int af9013_init(struct dvb_frontend *fe)
1393 init = tuner_init_mt2060_2; 1248 init = tuner_init_mt2060_2;
1394 break; 1249 break;
1395 case AF9013_TUNER_TDA18271: 1250 case AF9013_TUNER_TDA18271:
1251 case AF9013_TUNER_TDA18218:
1396 len = ARRAY_SIZE(tuner_init_tda18271); 1252 len = ARRAY_SIZE(tuner_init_tda18271);
1397 init = tuner_init_tda18271; 1253 init = tuner_init_tda18271;
1398 break; 1254 break;
@@ -1438,6 +1294,27 @@ static int af9013_init(struct dvb_frontend *fe)
1438 if (ret) 1294 if (ret)
1439 goto error; 1295 goto error;
1440 1296
1297 /* read values needed for signal strength calculation */
1298 ret = af9013_read_reg_bits(state, 0x9bee, 0, 1,
1299 &state->signal_strength_en);
1300 if (ret)
1301 goto error;
1302
1303 if (state->signal_strength_en) {
1304 ret = af9013_read_reg(state, 0x9bbd, &state->rf_50);
1305 if (ret)
1306 goto error;
1307 ret = af9013_read_reg(state, 0x9bd0, &state->rf_80);
1308 if (ret)
1309 goto error;
1310 ret = af9013_read_reg(state, 0x9be2, &state->if_50);
1311 if (ret)
1312 goto error;
1313 ret = af9013_read_reg(state, 0x9be4, &state->if_80);
1314 if (ret)
1315 goto error;
1316 }
1317
1441error: 1318error:
1442 return ret; 1319 return ret;
1443} 1320}
diff --git a/drivers/media/dvb/frontends/af9013.h b/drivers/media/dvb/frontends/af9013.h
index 72c71bb5d117..e53d873f7555 100644
--- a/drivers/media/dvb/frontends/af9013.h
+++ b/drivers/media/dvb/frontends/af9013.h
@@ -44,6 +44,7 @@ enum af9013_tuner {
44 AF9013_TUNER_MT2060_2 = 147, /* Microtune */ 44 AF9013_TUNER_MT2060_2 = 147, /* Microtune */
45 AF9013_TUNER_TDA18271 = 156, /* NXP */ 45 AF9013_TUNER_TDA18271 = 156, /* NXP */
46 AF9013_TUNER_QT1010A = 162, /* Quantek */ 46 AF9013_TUNER_QT1010A = 162, /* Quantek */
47 AF9013_TUNER_MXL5007T = 177, /* MaxLinear */
47 AF9013_TUNER_TDA18218 = 179, /* NXP */ 48 AF9013_TUNER_TDA18218 = 179, /* NXP */
48}; 49};
49 50
diff --git a/drivers/media/dvb/frontends/af9013_priv.h b/drivers/media/dvb/frontends/af9013_priv.h
index 0fd42b7e248e..e00b2a4a2db6 100644
--- a/drivers/media/dvb/frontends/af9013_priv.h
+++ b/drivers/media/dvb/frontends/af9013_priv.h
@@ -60,6 +60,56 @@ struct snr_table {
60 u8 snr; 60 u8 snr;
61}; 61};
62 62
63struct coeff {
64 u32 adc_clock;
65 fe_bandwidth_t bw;
66 u8 val[24];
67};
68
69/* pre-calculated coeff lookup table */
70static struct coeff coeff_table[] = {
71 /* 28.800 MHz */
72 { 28800, BANDWIDTH_8_MHZ, { 0x02, 0x8a, 0x28, 0xa3, 0x05, 0x14,
73 0x51, 0x11, 0x00, 0xa2, 0x8f, 0x3d, 0x00, 0xa2, 0x8a,
74 0x29, 0x00, 0xa2, 0x85, 0x14, 0x01, 0x45, 0x14, 0x14 } },
75 { 28800, BANDWIDTH_7_MHZ, { 0x02, 0x38, 0xe3, 0x8e, 0x04, 0x71,
76 0xc7, 0x07, 0x00, 0x8e, 0x3d, 0x55, 0x00, 0x8e, 0x38,
77 0xe4, 0x00, 0x8e, 0x34, 0x72, 0x01, 0x1c, 0x71, 0x32 } },
78 { 28800, BANDWIDTH_6_MHZ, { 0x01, 0xe7, 0x9e, 0x7a, 0x03, 0xcf,
79 0x3c, 0x3d, 0x00, 0x79, 0xeb, 0x6e, 0x00, 0x79, 0xe7,
80 0x9e, 0x00, 0x79, 0xe3, 0xcf, 0x00, 0xf3, 0xcf, 0x0f } },
81 /* 20.480 MHz */
82 { 20480, BANDWIDTH_8_MHZ, { 0x03, 0x92, 0x49, 0x26, 0x07, 0x24,
83 0x92, 0x13, 0x00, 0xe4, 0x99, 0x6e, 0x00, 0xe4, 0x92,
84 0x49, 0x00, 0xe4, 0x8b, 0x25, 0x01, 0xc9, 0x24, 0x25 } },
85 { 20480, BANDWIDTH_7_MHZ, { 0x03, 0x20, 0x00, 0x01, 0x06, 0x40,
86 0x00, 0x00, 0x00, 0xc8, 0x06, 0x40, 0x00, 0xc8, 0x00,
87 0x00, 0x00, 0xc7, 0xf9, 0xc0, 0x01, 0x90, 0x00, 0x00 } },
88 { 20480, BANDWIDTH_6_MHZ, { 0x02, 0xad, 0xb6, 0xdc, 0x05, 0x5b,
89 0x6d, 0x2e, 0x00, 0xab, 0x73, 0x13, 0x00, 0xab, 0x6d,
90 0xb7, 0x00, 0xab, 0x68, 0x5c, 0x01, 0x56, 0xdb, 0x1c } },
91 /* 28.000 MHz */
92 { 28000, BANDWIDTH_8_MHZ, { 0x02, 0x9c, 0xbc, 0x15, 0x05, 0x39,
93 0x78, 0x0a, 0x00, 0xa7, 0x34, 0x3f, 0x00, 0xa7, 0x2f,
94 0x05, 0x00, 0xa7, 0x29, 0xcc, 0x01, 0x4e, 0x5e, 0x03 } },
95 { 28000, BANDWIDTH_7_MHZ, { 0x02, 0x49, 0x24, 0x92, 0x04, 0x92,
96 0x49, 0x09, 0x00, 0x92, 0x4d, 0xb7, 0x00, 0x92, 0x49,
97 0x25, 0x00, 0x92, 0x44, 0x92, 0x01, 0x24, 0x92, 0x12 } },
98 { 28000, BANDWIDTH_6_MHZ, { 0x01, 0xf5, 0x8d, 0x10, 0x03, 0xeb,
99 0x1a, 0x08, 0x00, 0x7d, 0x67, 0x2f, 0x00, 0x7d, 0x63,
100 0x44, 0x00, 0x7d, 0x5f, 0x59, 0x00, 0xfa, 0xc6, 0x22 } },
101 /* 25.000 MHz */
102 { 25000, BANDWIDTH_8_MHZ, { 0x02, 0xec, 0xfb, 0x9d, 0x05, 0xd9,
103 0xf7, 0x0e, 0x00, 0xbb, 0x44, 0xc1, 0x00, 0xbb, 0x3e,
104 0xe7, 0x00, 0xbb, 0x39, 0x0d, 0x01, 0x76, 0x7d, 0x34 } },
105 { 25000, BANDWIDTH_7_MHZ, { 0x02, 0x8f, 0x5c, 0x29, 0x05, 0x1e,
106 0xb8, 0x14, 0x00, 0xa3, 0xdc, 0x29, 0x00, 0xa3, 0xd7,
107 0x0a, 0x00, 0xa3, 0xd1, 0xec, 0x01, 0x47, 0xae, 0x05 } },
108 { 25000, BANDWIDTH_6_MHZ, { 0x02, 0x31, 0xbc, 0xb5, 0x04, 0x63,
109 0x79, 0x1b, 0x00, 0x8c, 0x73, 0x91, 0x00, 0x8c, 0x6f,
110 0x2d, 0x00, 0x8c, 0x6a, 0xca, 0x01, 0x18, 0xde, 0x17 } },
111};
112
63/* QPSK SNR lookup table */ 113/* QPSK SNR lookup table */
64static struct snr_table qpsk_snr_table[] = { 114static struct snr_table qpsk_snr_table[] = {
65 { 0x0b4771, 0 }, 115 { 0x0b4771, 0 },
@@ -480,9 +530,10 @@ static struct regdesc tuner_init_mxl5003d[] = {
480 { 0x9bd9, 0, 8, 0x08 }, 530 { 0x9bd9, 0, 8, 0x08 },
481}; 531};
482 532
483/* MaxLinear MXL5005 tuner init 533/* MaxLinear MXL5005S & MXL5007T tuner init
484 AF9013_TUNER_MXL5005D = 13 534 AF9013_TUNER_MXL5005D = 13
485 AF9013_TUNER_MXL5005R = 30 */ 535 AF9013_TUNER_MXL5005R = 30
536 AF9013_TUNER_MXL5007T = 177 */
486static struct regdesc tuner_init_mxl5005[] = { 537static struct regdesc tuner_init_mxl5005[] = {
487 { 0x9bd5, 0, 8, 0x01 }, 538 { 0x9bd5, 0, 8, 0x01 },
488 { 0x9bd6, 0, 8, 0x07 }, 539 { 0x9bd6, 0, 8, 0x07 },
@@ -791,8 +842,9 @@ static struct regdesc tuner_init_unknown[] = {
791 { 0x9bd9, 0, 8, 0x08 }, 842 { 0x9bd9, 0, 8, 0x08 },
792}; 843};
793 844
794/* NXP TDA18271 tuner init 845/* NXP TDA18271 & TDA18218 tuner init
795 AF9013_TUNER_TDA18271 = 156 */ 846 AF9013_TUNER_TDA18271 = 156
847 AF9013_TUNER_TDA18218 = 179 */
796static struct regdesc tuner_init_tda18271[] = { 848static struct regdesc tuner_init_tda18271[] = {
797 { 0x9bd5, 0, 8, 0x01 }, 849 { 0x9bd5, 0, 8, 0x01 },
798 { 0x9bd6, 0, 8, 0x04 }, 850 { 0x9bd6, 0, 8, 0x04 },
diff --git a/drivers/media/dvb/frontends/au8522_decoder.c b/drivers/media/dvb/frontends/au8522_decoder.c
index 29cdbfe36852..6d9c5943eb3d 100644
--- a/drivers/media/dvb/frontends/au8522_decoder.c
+++ b/drivers/media/dvb/frontends/au8522_decoder.c
@@ -36,7 +36,6 @@
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-chip-ident.h> 38#include <media/v4l2-chip-ident.h>
39#include <media/v4l2-i2c-drv.h>
40#include <media/v4l2-device.h> 39#include <media/v4l2-device.h>
41#include "au8522.h" 40#include "au8522.h"
42#include "au8522_priv.h" 41#include "au8522_priv.h"
@@ -831,9 +830,25 @@ static const struct i2c_device_id au8522_id[] = {
831 830
832MODULE_DEVICE_TABLE(i2c, au8522_id); 831MODULE_DEVICE_TABLE(i2c, au8522_id);
833 832
834static struct v4l2_i2c_driver_data v4l2_i2c_data = { 833static struct i2c_driver au8522_driver = {
835 .name = "au8522", 834 .driver = {
836 .probe = au8522_probe, 835 .owner = THIS_MODULE,
837 .remove = au8522_remove, 836 .name = "au8522",
838 .id_table = au8522_id, 837 },
838 .probe = au8522_probe,
839 .remove = au8522_remove,
840 .id_table = au8522_id,
839}; 841};
842
843static __init int init_au8522(void)
844{
845 return i2c_add_driver(&au8522_driver);
846}
847
848static __exit void exit_au8522(void)
849{
850 i2c_del_driver(&au8522_driver);
851}
852
853module_init(init_au8522);
854module_exit(exit_au8522);
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index 00b5c7e91d5d..ff6c4983051c 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -54,7 +54,7 @@ MODULE_PARM_DESC(debug, "Enable verbose debug messages");
54#define dprintk if (debug) printk 54#define dprintk if (debug) printk
55 55
56/* Register values to initialise the demod */ 56/* Register values to initialise the demod */
57static u8 init_tab[] = { 57static const u8 init_tab[] = {
58 0x00, 0x00, /* Stop aquisition */ 58 0x00, 0x00, /* Stop aquisition */
59 0x0B, 0x06, 59 0x0B, 0x06,
60 0x09, 0x01, 60 0x09, 0x01,
@@ -92,52 +92,56 @@ static int cx22702_writereg(struct cx22702_state *state, u8 reg, u8 data)
92 92
93 ret = i2c_transfer(state->i2c, &msg, 1); 93 ret = i2c_transfer(state->i2c, &msg, 1);
94 94
95 if (ret != 1) 95 if (unlikely(ret != 1)) {
96 printk(KERN_ERR 96 printk(KERN_ERR
97 "%s: error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", 97 "%s: error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
98 __func__, reg, data, ret); 98 __func__, reg, data, ret);
99 return -1;
100 }
99 101
100 return (ret != 1) ? -1 : 0; 102 return 0;
101} 103}
102 104
103static u8 cx22702_readreg(struct cx22702_state *state, u8 reg) 105static u8 cx22702_readreg(struct cx22702_state *state, u8 reg)
104{ 106{
105 int ret; 107 int ret;
106 u8 b0[] = { reg }; 108 u8 data;
107 u8 b1[] = { 0 };
108 109
109 struct i2c_msg msg[] = { 110 struct i2c_msg msg[] = {
110 { .addr = state->config->demod_address, .flags = 0, 111 { .addr = state->config->demod_address, .flags = 0,
111 .buf = b0, .len = 1 }, 112 .buf = &reg, .len = 1 },
112 { .addr = state->config->demod_address, .flags = I2C_M_RD, 113 { .addr = state->config->demod_address, .flags = I2C_M_RD,
113 .buf = b1, .len = 1 } }; 114 .buf = &data, .len = 1 } };
114 115
115 ret = i2c_transfer(state->i2c, msg, 2); 116 ret = i2c_transfer(state->i2c, msg, 2);
116 117
117 if (ret != 2) 118 if (unlikely(ret != 2)) {
118 printk(KERN_ERR "%s: readreg error (ret == %i)\n", 119 printk(KERN_ERR "%s: error (reg == 0x%02x, ret == %i)\n",
119 __func__, ret); 120 __func__, reg, ret);
121 return 0;
122 }
120 123
121 return b1[0]; 124 return data;
122} 125}
123 126
124static int cx22702_set_inversion(struct cx22702_state *state, int inversion) 127static int cx22702_set_inversion(struct cx22702_state *state, int inversion)
125{ 128{
126 u8 val; 129 u8 val;
127 130
131 val = cx22702_readreg(state, 0x0C);
128 switch (inversion) { 132 switch (inversion) {
129 case INVERSION_AUTO: 133 case INVERSION_AUTO:
130 return -EOPNOTSUPP; 134 return -EOPNOTSUPP;
131 case INVERSION_ON: 135 case INVERSION_ON:
132 val = cx22702_readreg(state, 0x0C); 136 val |= 0x01;
133 return cx22702_writereg(state, 0x0C, val | 0x01); 137 break;
134 case INVERSION_OFF: 138 case INVERSION_OFF:
135 val = cx22702_readreg(state, 0x0C); 139 val &= 0xfe;
136 return cx22702_writereg(state, 0x0C, val & 0xfe); 140 break;
137 default: 141 default:
138 return -EINVAL; 142 return -EINVAL;
139 } 143 }
140 144 return cx22702_writereg(state, 0x0C, val);
141} 145}
142 146
143/* Retrieve the demod settings */ 147/* Retrieve the demod settings */
@@ -244,13 +248,15 @@ static int cx22702_get_tps(struct cx22702_state *state,
244static int cx22702_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 248static int cx22702_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
245{ 249{
246 struct cx22702_state *state = fe->demodulator_priv; 250 struct cx22702_state *state = fe->demodulator_priv;
251 u8 val;
252
247 dprintk("%s(%d)\n", __func__, enable); 253 dprintk("%s(%d)\n", __func__, enable);
254 val = cx22702_readreg(state, 0x0D);
248 if (enable) 255 if (enable)
249 return cx22702_writereg(state, 0x0D, 256 val &= 0xfe;
250 cx22702_readreg(state, 0x0D) & 0xfe);
251 else 257 else
252 return cx22702_writereg(state, 0x0D, 258 val |= 0x01;
253 cx22702_readreg(state, 0x0D) | 1); 259 return cx22702_writereg(state, 0x0D, val);
254} 260}
255 261
256/* Talk to the demod, set the FEC, GUARD, QAM settings etc */ 262/* Talk to the demod, set the FEC, GUARD, QAM settings etc */
@@ -270,23 +276,21 @@ static int cx22702_set_tps(struct dvb_frontend *fe,
270 cx22702_set_inversion(state, p->inversion); 276 cx22702_set_inversion(state, p->inversion);
271 277
272 /* set bandwidth */ 278 /* set bandwidth */
279 val = cx22702_readreg(state, 0x0C) & 0xcf;
273 switch (p->u.ofdm.bandwidth) { 280 switch (p->u.ofdm.bandwidth) {
274 case BANDWIDTH_6_MHZ: 281 case BANDWIDTH_6_MHZ:
275 cx22702_writereg(state, 0x0C, 282 val |= 0x20;
276 (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20);
277 break; 283 break;
278 case BANDWIDTH_7_MHZ: 284 case BANDWIDTH_7_MHZ:
279 cx22702_writereg(state, 0x0C, 285 val |= 0x10;
280 (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10);
281 break; 286 break;
282 case BANDWIDTH_8_MHZ: 287 case BANDWIDTH_8_MHZ:
283 cx22702_writereg(state, 0x0C,
284 cx22702_readreg(state, 0x0C) & 0xcf);
285 break; 288 break;
286 default: 289 default:
287 dprintk("%s: invalid bandwidth\n", __func__); 290 dprintk("%s: invalid bandwidth\n", __func__);
288 return -EINVAL; 291 return -EINVAL;
289 } 292 }
293 cx22702_writereg(state, 0x0C, val);
290 294
291 p->u.ofdm.code_rate_LP = FEC_AUTO; /* temp hack as manual not working */ 295 p->u.ofdm.code_rate_LP = FEC_AUTO; /* temp hack as manual not working */
292 296
@@ -312,33 +316,31 @@ static int cx22702_set_tps(struct dvb_frontend *fe,
312 } 316 }
313 317
314 /* manually programmed values */ 318 /* manually programmed values */
315 val = 0; 319 switch (p->u.ofdm.constellation) { /* mask 0x18 */
316 switch (p->u.ofdm.constellation) {
317 case QPSK: 320 case QPSK:
318 val = (val & 0xe7); 321 val = 0x00;
319 break; 322 break;
320 case QAM_16: 323 case QAM_16:
321 val = (val & 0xe7) | 0x08; 324 val = 0x08;
322 break; 325 break;
323 case QAM_64: 326 case QAM_64:
324 val = (val & 0xe7) | 0x10; 327 val = 0x10;
325 break; 328 break;
326 default: 329 default:
327 dprintk("%s: invalid constellation\n", __func__); 330 dprintk("%s: invalid constellation\n", __func__);
328 return -EINVAL; 331 return -EINVAL;
329 } 332 }
330 switch (p->u.ofdm.hierarchy_information) { 333 switch (p->u.ofdm.hierarchy_information) { /* mask 0x07 */
331 case HIERARCHY_NONE: 334 case HIERARCHY_NONE:
332 val = (val & 0xf8);
333 break; 335 break;
334 case HIERARCHY_1: 336 case HIERARCHY_1:
335 val = (val & 0xf8) | 1; 337 val |= 0x01;
336 break; 338 break;
337 case HIERARCHY_2: 339 case HIERARCHY_2:
338 val = (val & 0xf8) | 2; 340 val |= 0x02;
339 break; 341 break;
340 case HIERARCHY_4: 342 case HIERARCHY_4:
341 val = (val & 0xf8) | 3; 343 val |= 0x03;
342 break; 344 break;
343 default: 345 default:
344 dprintk("%s: invalid hierarchy\n", __func__); 346 dprintk("%s: invalid hierarchy\n", __func__);
@@ -346,44 +348,42 @@ static int cx22702_set_tps(struct dvb_frontend *fe,
346 } 348 }
347 cx22702_writereg(state, 0x06, val); 349 cx22702_writereg(state, 0x06, val);
348 350
349 val = 0; 351 switch (p->u.ofdm.code_rate_HP) { /* mask 0x38 */
350 switch (p->u.ofdm.code_rate_HP) {
351 case FEC_NONE: 352 case FEC_NONE:
352 case FEC_1_2: 353 case FEC_1_2:
353 val = (val & 0xc7); 354 val = 0x00;
354 break; 355 break;
355 case FEC_2_3: 356 case FEC_2_3:
356 val = (val & 0xc7) | 0x08; 357 val = 0x08;
357 break; 358 break;
358 case FEC_3_4: 359 case FEC_3_4:
359 val = (val & 0xc7) | 0x10; 360 val = 0x10;
360 break; 361 break;
361 case FEC_5_6: 362 case FEC_5_6:
362 val = (val & 0xc7) | 0x18; 363 val = 0x18;
363 break; 364 break;
364 case FEC_7_8: 365 case FEC_7_8:
365 val = (val & 0xc7) | 0x20; 366 val = 0x20;
366 break; 367 break;
367 default: 368 default:
368 dprintk("%s: invalid code_rate_HP\n", __func__); 369 dprintk("%s: invalid code_rate_HP\n", __func__);
369 return -EINVAL; 370 return -EINVAL;
370 } 371 }
371 switch (p->u.ofdm.code_rate_LP) { 372 switch (p->u.ofdm.code_rate_LP) { /* mask 0x07 */
372 case FEC_NONE: 373 case FEC_NONE:
373 case FEC_1_2: 374 case FEC_1_2:
374 val = (val & 0xf8);
375 break; 375 break;
376 case FEC_2_3: 376 case FEC_2_3:
377 val = (val & 0xf8) | 1; 377 val |= 0x01;
378 break; 378 break;
379 case FEC_3_4: 379 case FEC_3_4:
380 val = (val & 0xf8) | 2; 380 val |= 0x02;
381 break; 381 break;
382 case FEC_5_6: 382 case FEC_5_6:
383 val = (val & 0xf8) | 3; 383 val |= 0x03;
384 break; 384 break;
385 case FEC_7_8: 385 case FEC_7_8:
386 val = (val & 0xf8) | 4; 386 val |= 0x04;
387 break; 387 break;
388 default: 388 default:
389 dprintk("%s: invalid code_rate_LP\n", __func__); 389 dprintk("%s: invalid code_rate_LP\n", __func__);
@@ -391,30 +391,28 @@ static int cx22702_set_tps(struct dvb_frontend *fe,
391 } 391 }
392 cx22702_writereg(state, 0x07, val); 392 cx22702_writereg(state, 0x07, val);
393 393
394 val = 0; 394 switch (p->u.ofdm.guard_interval) { /* mask 0x0c */
395 switch (p->u.ofdm.guard_interval) {
396 case GUARD_INTERVAL_1_32: 395 case GUARD_INTERVAL_1_32:
397 val = (val & 0xf3); 396 val = 0x00;
398 break; 397 break;
399 case GUARD_INTERVAL_1_16: 398 case GUARD_INTERVAL_1_16:
400 val = (val & 0xf3) | 0x04; 399 val = 0x04;
401 break; 400 break;
402 case GUARD_INTERVAL_1_8: 401 case GUARD_INTERVAL_1_8:
403 val = (val & 0xf3) | 0x08; 402 val = 0x08;
404 break; 403 break;
405 case GUARD_INTERVAL_1_4: 404 case GUARD_INTERVAL_1_4:
406 val = (val & 0xf3) | 0x0c; 405 val = 0x0c;
407 break; 406 break;
408 default: 407 default:
409 dprintk("%s: invalid guard_interval\n", __func__); 408 dprintk("%s: invalid guard_interval\n", __func__);
410 return -EINVAL; 409 return -EINVAL;
411 } 410 }
412 switch (p->u.ofdm.transmission_mode) { 411 switch (p->u.ofdm.transmission_mode) { /* mask 0x03 */
413 case TRANSMISSION_MODE_2K: 412 case TRANSMISSION_MODE_2K:
414 val = (val & 0xfc);
415 break; 413 break;
416 case TRANSMISSION_MODE_8K: 414 case TRANSMISSION_MODE_8K:
417 val = (val & 0xfc) | 1; 415 val |= 0x1;
418 break; 416 break;
419 default: 417 default:
420 dprintk("%s: invalid transmission_mode\n", __func__); 418 dprintk("%s: invalid transmission_mode\n", __func__);
@@ -505,7 +503,7 @@ static int cx22702_read_signal_strength(struct dvb_frontend *fe,
505{ 503{
506 struct cx22702_state *state = fe->demodulator_priv; 504 struct cx22702_state *state = fe->demodulator_priv;
507 505
508 u16 rs_ber = 0; 506 u16 rs_ber;
509 rs_ber = cx22702_readreg(state, 0x23); 507 rs_ber = cx22702_readreg(state, 0x23);
510 *signal_strength = (rs_ber << 8) | rs_ber; 508 *signal_strength = (rs_ber << 8) | rs_ber;
511 509
@@ -516,7 +514,7 @@ static int cx22702_read_snr(struct dvb_frontend *fe, u16 *snr)
516{ 514{
517 struct cx22702_state *state = fe->demodulator_priv; 515 struct cx22702_state *state = fe->demodulator_priv;
518 516
519 u16 rs_ber = 0; 517 u16 rs_ber;
520 if (cx22702_readreg(state, 0xE4) & 0x02) { 518 if (cx22702_readreg(state, 0xE4) & 0x02) {
521 /* Realtime statistics */ 519 /* Realtime statistics */
522 rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 520 rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7
@@ -572,7 +570,7 @@ static void cx22702_release(struct dvb_frontend *fe)
572 kfree(state); 570 kfree(state);
573} 571}
574 572
575static struct dvb_frontend_ops cx22702_ops; 573static const struct dvb_frontend_ops cx22702_ops;
576 574
577struct dvb_frontend *cx22702_attach(const struct cx22702_config *config, 575struct dvb_frontend *cx22702_attach(const struct cx22702_config *config,
578 struct i2c_adapter *i2c) 576 struct i2c_adapter *i2c)
@@ -587,7 +585,6 @@ struct dvb_frontend *cx22702_attach(const struct cx22702_config *config,
587 /* setup the state */ 585 /* setup the state */
588 state->config = config; 586 state->config = config;
589 state->i2c = i2c; 587 state->i2c = i2c;
590 state->prevUCBlocks = 0;
591 588
592 /* check if the demod is there */ 589 /* check if the demod is there */
593 if (cx22702_readreg(state, 0x1f) != 0x3) 590 if (cx22702_readreg(state, 0x1f) != 0x3)
@@ -605,7 +602,7 @@ error:
605} 602}
606EXPORT_SYMBOL(cx22702_attach); 603EXPORT_SYMBOL(cx22702_attach);
607 604
608static struct dvb_frontend_ops cx22702_ops = { 605static const struct dvb_frontend_ops cx22702_ops = {
609 606
610 .info = { 607 .info = {
611 .name = "Conexant CX22702 DVB-T", 608 .name = "Conexant CX22702 DVB-T",
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c
index 00a4e8f03304..7a1a5bc337d8 100644
--- a/drivers/media/dvb/frontends/cx24110.c
+++ b/drivers/media/dvb/frontends/cx24110.c
@@ -310,7 +310,7 @@ static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate)
310 310
311} 311}
312 312
313static int _cx24110_pll_write (struct dvb_frontend* fe, u8 *buf, int len) 313static int _cx24110_pll_write (struct dvb_frontend* fe, const u8 buf[], int len)
314{ 314{
315 struct cx24110_state *state = fe->demodulator_priv; 315 struct cx24110_state *state = fe->demodulator_priv;
316 316
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index d8f921b6fafd..fad6a990a39b 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -1108,7 +1108,6 @@ struct dvb_frontend *cx24123_attach(const struct cx24123_config *config,
1108 1108
1109 strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", 1109 strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus",
1110 sizeof(state->tuner_i2c_adapter.name)); 1110 sizeof(state->tuner_i2c_adapter.name));
1111 state->tuner_i2c_adapter.class = I2C_CLASS_TV_DIGITAL,
1112 state->tuner_i2c_adapter.algo = &cx24123_tuner_i2c_algo; 1111 state->tuner_i2c_adapter.algo = &cx24123_tuner_i2c_algo;
1113 state->tuner_i2c_adapter.algo_data = NULL; 1112 state->tuner_i2c_adapter.algo_data = NULL;
1114 i2c_set_adapdata(&state->tuner_i2c_adapter, state); 1113 i2c_set_adapdata(&state->tuner_i2c_adapter, state);
diff --git a/drivers/media/dvb/frontends/dibx000_common.c b/drivers/media/dvb/frontends/dibx000_common.c
index 980e02f1575e..a4991026254d 100644
--- a/drivers/media/dvb/frontends/dibx000_common.c
+++ b/drivers/media/dvb/frontends/dibx000_common.c
@@ -130,7 +130,6 @@ static int i2c_adapter_init(struct i2c_adapter *i2c_adap,
130 struct dibx000_i2c_master *mst) 130 struct dibx000_i2c_master *mst)
131{ 131{
132 strncpy(i2c_adap->name, name, sizeof(i2c_adap->name)); 132 strncpy(i2c_adap->name, name, sizeof(i2c_adap->name));
133 i2c_adap->class = I2C_CLASS_TV_DIGITAL, i2c_adap->algo = algo;
134 i2c_adap->algo_data = NULL; 133 i2c_adap->algo_data = NULL;
135 i2c_set_adapdata(i2c_adap, mst); 134 i2c_set_adapdata(i2c_adap, mst);
136 if (i2c_add_adapter(i2c_adap) < 0) 135 if (i2c_add_adapter(i2c_adap) < 0)
diff --git a/drivers/media/dvb/frontends/drx397xD.c b/drivers/media/dvb/frontends/drx397xD.c
index f74cca6dc26b..a05007c80985 100644
--- a/drivers/media/dvb/frontends/drx397xD.c
+++ b/drivers/media/dvb/frontends/drx397xD.c
@@ -232,7 +232,7 @@ static int write_fw(struct drx397xD_state *s, enum blob_ix ix)
232exit_rc: 232exit_rc:
233 read_unlock(&fw[s->chip_rev].lock); 233 read_unlock(&fw[s->chip_rev].lock);
234 234
235 return 0; 235 return rc;
236} 236}
237 237
238/* Function is not endian safe, use the RD16 wrapper below */ 238/* Function is not endian safe, use the RD16 wrapper below */
diff --git a/drivers/media/dvb/frontends/ix2505v.c b/drivers/media/dvb/frontends/ix2505v.c
new file mode 100644
index 000000000000..55f2eba7bc96
--- /dev/null
+++ b/drivers/media/dvb/frontends/ix2505v.c
@@ -0,0 +1,323 @@
1/**
2 * Driver for Sharp IX2505V (marked B0017) DVB-S silicon tuner
3 *
4 * Copyright (C) 2010 Malcolm Priestley
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License Version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 */
20
21#include <linux/module.h>
22#include <linux/dvb/frontend.h>
23#include <linux/slab.h>
24#include <linux/types.h>
25
26#include "ix2505v.h"
27
28static int ix2505v_debug;
29#define dprintk(level, args...) do { \
30 if (ix2505v_debug & level) \
31 printk(KERN_DEBUG "ix2505v: " args); \
32} while (0)
33
34#define deb_info(args...) dprintk(0x01, args)
35#define deb_i2c(args...) dprintk(0x02, args)
36
37struct ix2505v_state {
38 struct i2c_adapter *i2c;
39 const struct ix2505v_config *config;
40 u32 frequency;
41};
42
43/**
44 * Data read format of the Sharp IX2505V B0017
45 *
46 * byte1: 1 | 1 | 0 | 0 | 0 | MA1 | MA0 | 1
47 * byte2: POR | FL | RD2 | RD1 | RD0 | X | X | X
48 *
49 * byte1 = address
50 * byte2;
51 * POR = Power on Reset (VCC H=<2.2v L=>2.2v)
52 * FL = Phase Lock (H=lock L=unlock)
53 * RD0-2 = Reserved internal operations
54 *
55 * Only POR can be used to check the tuner is present
56 *
57 * Caution: after byte2 the I2C reverts to write mode continuing to read
58 * may corrupt tuning data.
59 *
60 */
61
62static int ix2505v_read_status_reg(struct ix2505v_state *state)
63{
64 u8 addr = state->config->tuner_address;
65 u8 b2[] = {0};
66 int ret;
67
68 struct i2c_msg msg[1] = {
69 { .addr = addr, .flags = I2C_M_RD, .buf = b2, .len = 1 }
70 };
71
72 ret = i2c_transfer(state->i2c, msg, 1);
73 deb_i2c("Read %s ", __func__);
74
75 return (ret = 1) ? (int) b2[0] : -1;
76}
77
78static int ix2505v_write(struct ix2505v_state *state, u8 buf[], u8 count)
79{
80 struct i2c_msg msg[1] = {
81 { .addr = state->config->tuner_address, .flags = 0,
82 .buf = buf, .len = count },
83 };
84
85 int ret;
86
87 ret = i2c_transfer(state->i2c, msg, 1);
88
89 if (ret != 1) {
90 deb_i2c("%s: i2c error, ret=%d\n", __func__, ret);
91 return -EIO;
92 }
93
94 return 0;
95}
96
97static int ix2505v_release(struct dvb_frontend *fe)
98{
99 struct ix2505v_state *state = fe->tuner_priv;
100
101 fe->tuner_priv = NULL;
102 kfree(state);
103
104 return 0;
105}
106
107/**
108 * Data write format of the Sharp IX2505V B0017
109 *
110 * byte1: 1 | 1 | 0 | 0 | 0 | 0(MA1)| 0(MA0)| 0
111 * byte2: 0 | BG1 | BG2 | N8 | N7 | N6 | N5 | N4
112 * byte3: N3 | N2 | N1 | A5 | A4 | A3 | A2 | A1
113 * byte4: 1 | 1(C1) | 1(C0) | PD5 | PD4 | TM | 0(RTS)| 1(REF)
114 * byte5: BA2 | BA1 | BA0 | PSC | PD3 |PD2/TS2|DIV/TS1|PD0/TS0
115 *
116 * byte1 = address
117 *
118 * Write order
119 * 1) byte1 -> byte2 -> byte3 -> byte4 -> byte5
120 * 2) byte1 -> byte4 -> byte5 -> byte2 -> byte3
121 * 3) byte1 -> byte2 -> byte3 -> byte4
122 * 4) byte1 -> byte4 -> byte5 -> byte2
123 * 5) byte1 -> byte2 -> byte3
124 * 6) byte1 -> byte4 -> byte5
125 * 7) byte1 -> byte2
126 * 8) byte1 -> byte4
127 *
128 * Recommended Setup
129 * 1 -> 8 -> 6
130 */
131
132static int ix2505v_set_params(struct dvb_frontend *fe,
133 struct dvb_frontend_parameters *params)
134{
135 struct ix2505v_state *state = fe->tuner_priv;
136 u32 frequency = params->frequency;
137 u32 b_w = (params->u.qpsk.symbol_rate * 27) / 32000;
138 u32 div_factor, N , A, x;
139 int ret = 0, len;
140 u8 gain, cc, ref, psc, local_osc, lpf;
141 u8 data[4] = {0};
142
143 if ((frequency < fe->ops.info.frequency_min)
144 || (frequency > fe->ops.info.frequency_max))
145 return -EINVAL;
146
147 if (state->config->tuner_gain)
148 gain = (state->config->tuner_gain < 4)
149 ? state->config->tuner_gain : 0;
150 else
151 gain = 0x0;
152
153 if (state->config->tuner_chargepump)
154 cc = state->config->tuner_chargepump;
155 else
156 cc = 0x3;
157
158 ref = 8; /* REF =1 */
159 psc = 32; /* PSC = 0 */
160
161 div_factor = (frequency * ref) / 40; /* local osc = 4Mhz */
162 x = div_factor / psc;
163 N = x/100;
164 A = ((x - (N * 100)) * psc) / 100;
165
166 data[0] = ((gain & 0x3) << 5) | (N >> 3);
167 data[1] = (N << 5) | (A & 0x1f);
168 data[2] = 0x81 | ((cc & 0x3) << 5) ; /*PD5,PD4 & TM = 0|C1,C0|REF=1*/
169
170 deb_info("Frq=%d x=%d N=%d A=%d\n", frequency, x, N, A);
171
172 if (frequency <= 1065000)
173 local_osc = (6 << 5) | 2;
174 else if (frequency <= 1170000)
175 local_osc = (7 << 5) | 2;
176 else if (frequency <= 1300000)
177 local_osc = (1 << 5);
178 else if (frequency <= 1445000)
179 local_osc = (2 << 5);
180 else if (frequency <= 1607000)
181 local_osc = (3 << 5);
182 else if (frequency <= 1778000)
183 local_osc = (4 << 5);
184 else if (frequency <= 1942000)
185 local_osc = (5 << 5);
186 else /*frequency up to 2150000*/
187 local_osc = (6 << 5);
188
189 data[3] = local_osc; /* all other bits set 0 */
190
191 if (b_w <= 10000)
192 lpf = 0xc;
193 else if (b_w <= 12000)
194 lpf = 0x2;
195 else if (b_w <= 14000)
196 lpf = 0xa;
197 else if (b_w <= 16000)
198 lpf = 0x6;
199 else if (b_w <= 18000)
200 lpf = 0xe;
201 else if (b_w <= 20000)
202 lpf = 0x1;
203 else if (b_w <= 22000)
204 lpf = 0x9;
205 else if (b_w <= 24000)
206 lpf = 0x5;
207 else if (b_w <= 26000)
208 lpf = 0xd;
209 else if (b_w <= 28000)
210 lpf = 0x3;
211 else
212 lpf = 0xb;
213
214 deb_info("Osc=%x b_w=%x lpf=%x\n", local_osc, b_w, lpf);
215 deb_info("Data 0=[%x%x%x%x]\n", data[0], data[1], data[2], data[3]);
216
217 if (fe->ops.i2c_gate_ctrl)
218 fe->ops.i2c_gate_ctrl(fe, 1);
219
220 len = sizeof(data);
221
222 ret |= ix2505v_write(state, data, len);
223
224 data[2] |= 0x4; /* set TM = 1 other bits same */
225
226 len = 1;
227 ret |= ix2505v_write(state, &data[2], len); /* write byte 4 only */
228
229 msleep(10);
230
231 data[2] |= ((lpf >> 2) & 0x3) << 3; /* lpf */
232 data[3] |= (lpf & 0x3) << 2;
233
234 deb_info("Data 2=[%x%x]\n", data[2], data[3]);
235
236 len = 2;
237 ret |= ix2505v_write(state, &data[2], len); /* write byte 4 & 5 */
238
239 if (fe->ops.i2c_gate_ctrl)
240 fe->ops.i2c_gate_ctrl(fe, 0);
241
242 if (state->config->min_delay_ms)
243 msleep(state->config->min_delay_ms);
244
245 state->frequency = frequency;
246
247 return ret;
248}
249
250static int ix2505v_get_frequency(struct dvb_frontend *fe, u32 *frequency)
251{
252 struct ix2505v_state *state = fe->tuner_priv;
253
254 *frequency = state->frequency;
255
256 return 0;
257}
258
259static struct dvb_tuner_ops ix2505v_tuner_ops = {
260 .info = {
261 .name = "Sharp IX2505V (B0017)",
262 .frequency_min = 950000,
263 .frequency_max = 2175000
264 },
265 .release = ix2505v_release,
266 .set_params = ix2505v_set_params,
267 .get_frequency = ix2505v_get_frequency,
268};
269
270struct dvb_frontend *ix2505v_attach(struct dvb_frontend *fe,
271 const struct ix2505v_config *config,
272 struct i2c_adapter *i2c)
273{
274 struct ix2505v_state *state = NULL;
275 int ret;
276
277 if (NULL == config) {
278 deb_i2c("%s: no config ", __func__);
279 goto error;
280 }
281
282 state = kzalloc(sizeof(struct ix2505v_state), GFP_KERNEL);
283 if (NULL == state)
284 return NULL;
285
286 state->config = config;
287 state->i2c = i2c;
288
289 if (state->config->tuner_write_only) {
290 if (fe->ops.i2c_gate_ctrl)
291 fe->ops.i2c_gate_ctrl(fe, 1);
292
293 ret = ix2505v_read_status_reg(state);
294
295 if (ret & 0x80) {
296 deb_i2c("%s: No IX2505V found\n", __func__);
297 goto error;
298 }
299
300 if (fe->ops.i2c_gate_ctrl)
301 fe->ops.i2c_gate_ctrl(fe, 0);
302 }
303
304 fe->tuner_priv = state;
305
306 memcpy(&fe->ops.tuner_ops, &ix2505v_tuner_ops,
307 sizeof(struct dvb_tuner_ops));
308 deb_i2c("%s: initialization (%s addr=0x%02x) ok\n",
309 __func__, fe->ops.tuner_ops.info.name, config->tuner_address);
310
311 return fe;
312
313error:
314 ix2505v_release(fe);
315 return NULL;
316}
317EXPORT_SYMBOL(ix2505v_attach);
318
319module_param_named(debug, ix2505v_debug, int, 0644);
320MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
321MODULE_DESCRIPTION("DVB IX2505V tuner driver");
322MODULE_AUTHOR("Malcolm Priestley");
323MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/ix2505v.h b/drivers/media/dvb/frontends/ix2505v.h
new file mode 100644
index 000000000000..67e89d616d50
--- /dev/null
+++ b/drivers/media/dvb/frontends/ix2505v.h
@@ -0,0 +1,64 @@
1/**
2 * Driver for Sharp IX2505V (marked B0017) DVB-S silicon tuner
3 *
4 * Copyright (C) 2010 Malcolm Priestley
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License Version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef DVB_IX2505V_H
21#define DVB_IX2505V_H
22
23#include <linux/i2c.h>
24#include "dvb_frontend.h"
25
26/**
27 * Attach a ix2505v tuner to the supplied frontend structure.
28 *
29 * @param fe Frontend to attach to.
30 * @param config ix2505v_config structure
31 * @return FE pointer on success, NULL on failure.
32 */
33
34struct ix2505v_config {
35 u8 tuner_address;
36
37 /*Baseband AMP gain control 0/1=0dB(default) 2=-2bB 3=-4dB */
38 u8 tuner_gain;
39
40 /*Charge pump output +/- 0=120 1=260 2=555 3=1200(default) */
41 u8 tuner_chargepump;
42
43 /* delay after tune */
44 int min_delay_ms;
45
46 /* disables reads*/
47 u8 tuner_write_only;
48
49};
50
51#if defined(CONFIG_DVB_IX2505V) || \
52 (defined(CONFIG_DVB_IX2505V_MODULE) && defined(MODULE))
53extern struct dvb_frontend *ix2505v_attach(struct dvb_frontend *fe,
54 const struct ix2505v_config *config, struct i2c_adapter *i2c);
55#else
56static inline struct dvb_frontend *ix2505v_attach(struct dvb_frontend *fe,
57 const struct ix2505v_config *config, struct i2c_adapter *i2c)
58{
59 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
60 return NULL;
61}
62#endif
63
64#endif /* DVB_IX2505V_H */
diff --git a/drivers/media/dvb/frontends/lgdt3304.c b/drivers/media/dvb/frontends/lgdt3304.c
deleted file mode 100644
index 45a529b06b9d..000000000000
--- a/drivers/media/dvb/frontends/lgdt3304.c
+++ /dev/null
@@ -1,380 +0,0 @@
1/*
2 * Driver for LG ATSC lgdt3304 driver
3 *
4 * Copyright (C) 2008 Markus Rechberger <mrechberger@sundtek.de>
5 *
6 */
7
8#include <linux/kernel.h>
9#include <linux/module.h>
10#include <linux/slab.h>
11#include <linux/delay.h>
12#include "dvb_frontend.h"
13#include "lgdt3304.h"
14
15static unsigned int debug = 0;
16module_param(debug, int, 0644);
17MODULE_PARM_DESC(debug,"lgdt3304 debugging (default off)");
18
19#define dprintk(fmt, args...) if (debug) do {\
20 printk("lgdt3304 debug: " fmt, ##args); } while (0)
21
22struct lgdt3304_state
23{
24 struct dvb_frontend frontend;
25 fe_modulation_t current_modulation;
26 __u32 snr;
27 __u32 current_frequency;
28 __u8 addr;
29 struct i2c_adapter *i2c;
30};
31
32static int i2c_write_demod_bytes (struct dvb_frontend *fe, __u8 *buf, int len)
33{
34 struct lgdt3304_state *state = fe->demodulator_priv;
35 struct i2c_msg i2cmsgs = {
36 .addr = state->addr,
37 .flags = 0,
38 .len = 3,
39 .buf = buf
40 };
41 int i;
42 int err;
43
44 for (i=0; i<len-1; i+=3){
45 if((err = i2c_transfer(state->i2c, &i2cmsgs, 1))<0) {
46 printk("%s i2c_transfer error %d\n", __func__, err);
47 if (err < 0)
48 return err;
49 else
50 return -EREMOTEIO;
51 }
52 i2cmsgs.buf += 3;
53 }
54 return 0;
55}
56
57static int lgdt3304_i2c_read_reg(struct dvb_frontend *fe, unsigned int reg)
58{
59 struct lgdt3304_state *state = fe->demodulator_priv;
60 struct i2c_msg i2cmsgs[2];
61 int ret;
62 __u8 buf;
63
64 __u8 regbuf[2] = { reg>>8, reg&0xff };
65
66 i2cmsgs[0].addr = state->addr;
67 i2cmsgs[0].flags = 0;
68 i2cmsgs[0].len = 2;
69 i2cmsgs[0].buf = regbuf;
70
71 i2cmsgs[1].addr = state->addr;
72 i2cmsgs[1].flags = I2C_M_RD;
73 i2cmsgs[1].len = 1;
74 i2cmsgs[1].buf = &buf;
75
76 if((ret = i2c_transfer(state->i2c, i2cmsgs, 2))<0) {
77 printk("%s i2c_transfer error %d\n", __func__, ret);
78 return ret;
79 }
80
81 return buf;
82}
83
84static int lgdt3304_i2c_write_reg(struct dvb_frontend *fe, int reg, int val)
85{
86 struct lgdt3304_state *state = fe->demodulator_priv;
87 char buffer[3] = { reg>>8, reg&0xff, val };
88 int ret;
89
90 struct i2c_msg i2cmsgs = {
91 .addr = state->addr,
92 .flags = 0,
93 .len = 3,
94 .buf=buffer
95 };
96 ret = i2c_transfer(state->i2c, &i2cmsgs, 1);
97 if (ret != 1) {
98 printk("%s i2c_transfer error %d\n", __func__, ret);
99 return ret;
100 }
101
102 return 0;
103}
104
105
106static int lgdt3304_soft_Reset(struct dvb_frontend *fe)
107{
108 lgdt3304_i2c_write_reg(fe, 0x0002, 0x9a);
109 lgdt3304_i2c_write_reg(fe, 0x0002, 0x9b);
110 mdelay(200);
111 return 0;
112}
113
114static int lgdt3304_set_parameters(struct dvb_frontend *fe, struct dvb_frontend_parameters *param) {
115 int err = 0;
116
117 static __u8 lgdt3304_vsb8_data[] = {
118 /* 16bit , 8bit */
119 /* regs , val */
120 0x00, 0x00, 0x02,
121 0x00, 0x00, 0x13,
122 0x00, 0x0d, 0x02,
123 0x00, 0x0e, 0x02,
124 0x00, 0x12, 0x32,
125 0x00, 0x13, 0xc4,
126 0x01, 0x12, 0x17,
127 0x01, 0x13, 0x15,
128 0x01, 0x14, 0x18,
129 0x01, 0x15, 0xff,
130 0x01, 0x16, 0x2c,
131 0x02, 0x14, 0x67,
132 0x02, 0x24, 0x8d,
133 0x04, 0x27, 0x12,
134 0x04, 0x28, 0x4f,
135 0x03, 0x08, 0x80,
136 0x03, 0x09, 0x00,
137 0x03, 0x0d, 0x00,
138 0x03, 0x0e, 0x1c,
139 0x03, 0x14, 0xe1,
140 0x05, 0x0e, 0x5b,
141 };
142
143 /* not yet tested .. */
144 static __u8 lgdt3304_qam64_data[] = {
145 /* 16bit , 8bit */
146 /* regs , val */
147 0x00, 0x00, 0x18,
148 0x00, 0x0d, 0x02,
149 //0x00, 0x0e, 0x02,
150 0x00, 0x12, 0x2a,
151 0x00, 0x13, 0x00,
152 0x03, 0x14, 0xe3,
153 0x03, 0x0e, 0x1c,
154 0x03, 0x08, 0x66,
155 0x03, 0x09, 0x66,
156 0x03, 0x0a, 0x08,
157 0x03, 0x0b, 0x9b,
158 0x05, 0x0e, 0x5b,
159 };
160
161
162 /* tested with KWorld a340 */
163 static __u8 lgdt3304_qam256_data[] = {
164 /* 16bit , 8bit */
165 /* regs , val */
166 0x00, 0x00, 0x01, //0x19,
167 0x00, 0x12, 0x2a,
168 0x00, 0x13, 0x80,
169 0x00, 0x0d, 0x02,
170 0x03, 0x14, 0xe3,
171
172 0x03, 0x0e, 0x1c,
173 0x03, 0x08, 0x66,
174 0x03, 0x09, 0x66,
175 0x03, 0x0a, 0x08,
176 0x03, 0x0b, 0x9b,
177
178 0x03, 0x0d, 0x14,
179 //0x05, 0x0e, 0x5b,
180 0x01, 0x06, 0x4a,
181 0x01, 0x07, 0x3d,
182 0x01, 0x08, 0x70,
183 0x01, 0x09, 0xa3,
184
185 0x05, 0x04, 0xfd,
186
187 0x00, 0x0d, 0x82,
188
189 0x05, 0x0e, 0x5b,
190
191 0x05, 0x0e, 0x5b,
192
193 0x00, 0x02, 0x9a,
194
195 0x00, 0x02, 0x9b,
196
197 0x00, 0x00, 0x01,
198 0x00, 0x12, 0x2a,
199 0x00, 0x13, 0x80,
200 0x00, 0x0d, 0x02,
201 0x03, 0x14, 0xe3,
202
203 0x03, 0x0e, 0x1c,
204 0x03, 0x08, 0x66,
205 0x03, 0x09, 0x66,
206 0x03, 0x0a, 0x08,
207 0x03, 0x0b, 0x9b,
208
209 0x03, 0x0d, 0x14,
210 0x01, 0x06, 0x4a,
211 0x01, 0x07, 0x3d,
212 0x01, 0x08, 0x70,
213 0x01, 0x09, 0xa3,
214
215 0x05, 0x04, 0xfd,
216
217 0x00, 0x0d, 0x82,
218
219 0x05, 0x0e, 0x5b,
220 };
221
222 struct lgdt3304_state *state = fe->demodulator_priv;
223 if (state->current_modulation != param->u.vsb.modulation) {
224 switch(param->u.vsb.modulation) {
225 case VSB_8:
226 err = i2c_write_demod_bytes(fe, lgdt3304_vsb8_data,
227 sizeof(lgdt3304_vsb8_data));
228 break;
229 case QAM_64:
230 err = i2c_write_demod_bytes(fe, lgdt3304_qam64_data,
231 sizeof(lgdt3304_qam64_data));
232 break;
233 case QAM_256:
234 err = i2c_write_demod_bytes(fe, lgdt3304_qam256_data,
235 sizeof(lgdt3304_qam256_data));
236 break;
237 default:
238 break;
239 }
240
241 if (err) {
242 printk("%s error setting modulation\n", __func__);
243 } else {
244 state->current_modulation = param->u.vsb.modulation;
245 }
246 }
247 state->current_frequency = param->frequency;
248
249 lgdt3304_soft_Reset(fe);
250
251
252 if (fe->ops.tuner_ops.set_params)
253 fe->ops.tuner_ops.set_params(fe, param);
254
255 return 0;
256}
257
258static int lgdt3304_init(struct dvb_frontend *fe) {
259 return 0;
260}
261
262static int lgdt3304_sleep(struct dvb_frontend *fe) {
263 return 0;
264}
265
266
267static int lgdt3304_read_status(struct dvb_frontend *fe, fe_status_t *status)
268{
269 struct lgdt3304_state *state = fe->demodulator_priv;
270 int r011d;
271 int qam_lck;
272
273 *status = 0;
274 dprintk("lgdt read status\n");
275
276 r011d = lgdt3304_i2c_read_reg(fe, 0x011d);
277
278 dprintk("%02x\n", r011d);
279
280 switch(state->current_modulation) {
281 case VSB_8:
282 if (r011d & 0x80) {
283 dprintk("VSB Locked\n");
284 *status |= FE_HAS_CARRIER;
285 *status |= FE_HAS_LOCK;
286 *status |= FE_HAS_SYNC;
287 *status |= FE_HAS_SIGNAL;
288 }
289 break;
290 case QAM_64:
291 case QAM_256:
292 qam_lck = r011d & 0x7;
293 switch(qam_lck) {
294 case 0x0: dprintk("Unlock\n");
295 break;
296 case 0x4: dprintk("1st Lock in acquisition state\n");
297 break;
298 case 0x6: dprintk("2nd Lock in acquisition state\n");
299 break;
300 case 0x7: dprintk("Final Lock in good reception state\n");
301 *status |= FE_HAS_CARRIER;
302 *status |= FE_HAS_LOCK;
303 *status |= FE_HAS_SYNC;
304 *status |= FE_HAS_SIGNAL;
305 break;
306 }
307 break;
308 default:
309 printk("%s unhandled modulation\n", __func__);
310 }
311
312
313 return 0;
314}
315
316static int lgdt3304_read_ber(struct dvb_frontend *fe, __u32 *ber)
317{
318 dprintk("read ber\n");
319 return 0;
320}
321
322static int lgdt3304_read_snr(struct dvb_frontend *fe, __u16 *snr)
323{
324 dprintk("read snr\n");
325 return 0;
326}
327
328static int lgdt3304_read_ucblocks(struct dvb_frontend *fe, __u32 *ucblocks)
329{
330 dprintk("read ucblocks\n");
331 return 0;
332}
333
334static void lgdt3304_release(struct dvb_frontend *fe)
335{
336 struct lgdt3304_state *state = (struct lgdt3304_state *)fe->demodulator_priv;
337 kfree(state);
338}
339
340static struct dvb_frontend_ops demod_lgdt3304={
341 .info = {
342 .name = "LG 3304",
343 .type = FE_ATSC,
344 .frequency_min = 54000000,
345 .frequency_max = 858000000,
346 .frequency_stepsize = 62500,
347 .symbol_rate_min = 5056941,
348 .symbol_rate_max = 10762000,
349 .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
350 },
351 .init = lgdt3304_init,
352 .sleep = lgdt3304_sleep,
353 .set_frontend = lgdt3304_set_parameters,
354 .read_snr = lgdt3304_read_snr,
355 .read_ber = lgdt3304_read_ber,
356 .read_status = lgdt3304_read_status,
357 .read_ucblocks = lgdt3304_read_ucblocks,
358 .release = lgdt3304_release,
359};
360
361struct dvb_frontend* lgdt3304_attach(const struct lgdt3304_config *config,
362 struct i2c_adapter *i2c)
363{
364
365 struct lgdt3304_state *state;
366 state = kzalloc(sizeof(struct lgdt3304_state), GFP_KERNEL);
367 if (state == NULL)
368 return NULL;
369 state->addr = config->i2c_address;
370 state->i2c = i2c;
371
372 memcpy(&state->frontend.ops, &demod_lgdt3304, sizeof(struct dvb_frontend_ops));
373 state->frontend.demodulator_priv = state;
374 return &state->frontend;
375}
376
377EXPORT_SYMBOL_GPL(lgdt3304_attach);
378MODULE_AUTHOR("Markus Rechberger <mrechberger@empiatech.com>");
379MODULE_DESCRIPTION("LGE LGDT3304 DVB-T demodulator driver");
380MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/lgdt3304.h b/drivers/media/dvb/frontends/lgdt3304.h
deleted file mode 100644
index fc409fe59acb..000000000000
--- a/drivers/media/dvb/frontends/lgdt3304.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Driver for DVB-T lgdt3304 demodulator
3 *
4 * Copyright (C) 2008 Markus Rechberger <mrechberger@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */
21
22#ifndef LGDT3304_H
23#define LGDT3304_H
24
25#include <linux/dvb/frontend.h>
26
27struct lgdt3304_config
28{
29 /* demodulator's I2C address */
30 u8 i2c_address;
31};
32
33#if defined(CONFIG_DVB_LGDT3304) || (defined(CONFIG_DVB_LGDT3304_MODULE) && defined(MODULE))
34extern struct dvb_frontend* lgdt3304_attach(const struct lgdt3304_config *config,
35 struct i2c_adapter *i2c);
36#else
37static inline struct dvb_frontend* lgdt3304_attach(const struct lgdt3304_config *config,
38 struct i2c_adapter *i2c)
39{
40 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
41 return NULL;
42}
43#endif /* CONFIG_DVB_LGDT */
44
45#endif /* LGDT3304_H */
diff --git a/drivers/media/dvb/frontends/lgs8gxx.c b/drivers/media/dvb/frontends/lgs8gxx.c
index 5ea28ae2ba8f..0fcddc4569d2 100644
--- a/drivers/media/dvb/frontends/lgs8gxx.c
+++ b/drivers/media/dvb/frontends/lgs8gxx.c
@@ -662,7 +662,7 @@ static void lgs8gxx_release(struct dvb_frontend *fe)
662} 662}
663 663
664 664
665static int lgs8gxx_write(struct dvb_frontend *fe, u8 *buf, int len) 665static int lgs8gxx_write(struct dvb_frontend *fe, const u8 buf[], int len)
666{ 666{
667 struct lgs8gxx_state *priv = fe->demodulator_priv; 667 struct lgs8gxx_state *priv = fe->demodulator_priv;
668 668
diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c
index beba5aa0db50..319672f8e1a7 100644
--- a/drivers/media/dvb/frontends/mt352.c
+++ b/drivers/media/dvb/frontends/mt352.c
@@ -69,7 +69,7 @@ static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
69 return 0; 69 return 0;
70} 70}
71 71
72static int _mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen) 72static int _mt352_write(struct dvb_frontend* fe, const u8 ibuf[], int ilen)
73{ 73{
74 int err,i; 74 int err,i;
75 for (i=0; i < ilen-1; i++) 75 for (i=0; i < ilen-1; i++)
diff --git a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h
index 595092f9f0c4..ca2562d6f289 100644
--- a/drivers/media/dvb/frontends/mt352.h
+++ b/drivers/media/dvb/frontends/mt352.h
@@ -63,7 +63,7 @@ static inline struct dvb_frontend* mt352_attach(const struct mt352_config* confi
63} 63}
64#endif // CONFIG_DVB_MT352 64#endif // CONFIG_DVB_MT352
65 65
66static inline int mt352_write(struct dvb_frontend *fe, u8 *buf, int len) { 66static inline int mt352_write(struct dvb_frontend *fe, const u8 buf[], int len) {
67 int r = 0; 67 int r = 0;
68 if (fe->ops.write) 68 if (fe->ops.write)
69 r = fe->ops.write(fe, buf, len); 69 r = fe->ops.write(fe, buf, len);
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c
index 2e9fd2893ede..e87b747ea99c 100644
--- a/drivers/media/dvb/frontends/s5h1420.c
+++ b/drivers/media/dvb/frontends/s5h1420.c
@@ -920,7 +920,6 @@ struct dvb_frontend *s5h1420_attach(const struct s5h1420_config *config,
920 /* create tuner i2c adapter */ 920 /* create tuner i2c adapter */
921 strlcpy(state->tuner_i2c_adapter.name, "S5H1420-PN1010 tuner I2C bus", 921 strlcpy(state->tuner_i2c_adapter.name, "S5H1420-PN1010 tuner I2C bus",
922 sizeof(state->tuner_i2c_adapter.name)); 922 sizeof(state->tuner_i2c_adapter.name));
923 state->tuner_i2c_adapter.class = I2C_CLASS_TV_DIGITAL,
924 state->tuner_i2c_adapter.algo = &s5h1420_tuner_i2c_algo; 923 state->tuner_i2c_adapter.algo = &s5h1420_tuner_i2c_algo;
925 state->tuner_i2c_adapter.algo_data = NULL; 924 state->tuner_i2c_adapter.algo_data = NULL;
926 i2c_set_adapdata(&state->tuner_i2c_adapter, state); 925 i2c_set_adapdata(&state->tuner_i2c_adapter, state);
diff --git a/drivers/media/dvb/frontends/s5h1432.c b/drivers/media/dvb/frontends/s5h1432.c
new file mode 100644
index 000000000000..0c6dcb90d168
--- /dev/null
+++ b/drivers/media/dvb/frontends/s5h1432.c
@@ -0,0 +1,415 @@
1/*
2 * Samsung s5h1432 DVB-T demodulator driver
3 *
4 * Copyright (C) 2009 Bill Liu <Bill.Liu@Conexant.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/string.h>
25#include <linux/slab.h>
26#include <linux/delay.h>
27#include "dvb_frontend.h"
28#include "s5h1432.h"
29
30struct s5h1432_state {
31
32 struct i2c_adapter *i2c;
33
34 /* configuration settings */
35 const struct s5h1432_config *config;
36
37 struct dvb_frontend frontend;
38
39 fe_modulation_t current_modulation;
40 unsigned int first_tune:1;
41
42 u32 current_frequency;
43 int if_freq;
44
45 u8 inversion;
46};
47
48static int debug;
49
50#define dprintk(arg...) do { \
51 if (debug) \
52 printk(arg); \
53 } while (0)
54
55static int s5h1432_writereg(struct s5h1432_state *state,
56 u8 addr, u8 reg, u8 data)
57{
58 int ret;
59 u8 buf[] = { reg, data };
60
61 struct i2c_msg msg = {.addr = addr, .flags = 0, .buf = buf, .len = 2 };
62
63 ret = i2c_transfer(state->i2c, &msg, 1);
64
65 if (ret != 1)
66 printk(KERN_ERR "%s: writereg error 0x%02x 0x%02x 0x%04x, "
67 "ret == %i)\n", __func__, addr, reg, data, ret);
68
69 return (ret != 1) ? -1 : 0;
70}
71
72static u8 s5h1432_readreg(struct s5h1432_state *state, u8 addr, u8 reg)
73{
74 int ret;
75 u8 b0[] = { reg };
76 u8 b1[] = { 0 };
77
78 struct i2c_msg msg[] = {
79 {.addr = addr, .flags = 0, .buf = b0, .len = 1},
80 {.addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 1}
81 };
82
83 ret = i2c_transfer(state->i2c, msg, 2);
84
85 if (ret != 2)
86 printk(KERN_ERR "%s: readreg error (ret == %i)\n",
87 __func__, ret);
88 return b1[0];
89}
90
91static int s5h1432_sleep(struct dvb_frontend *fe)
92{
93 return 0;
94}
95
96static int s5h1432_set_channel_bandwidth(struct dvb_frontend *fe,
97 u32 bandwidth)
98{
99 struct s5h1432_state *state = fe->demodulator_priv;
100
101 u8 reg = 0;
102
103 /* Register [0x2E] bit 3:2 : 8MHz = 0; 7MHz = 1; 6MHz = 2 */
104 reg = s5h1432_readreg(state, S5H1432_I2C_TOP_ADDR, 0x2E);
105 reg &= ~(0x0C);
106 switch (bandwidth) {
107 case 6:
108 reg |= 0x08;
109 break;
110 case 7:
111 reg |= 0x04;
112 break;
113 case 8:
114 reg |= 0x00;
115 break;
116 default:
117 return 0;
118 }
119 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x2E, reg);
120 return 1;
121}
122
123static int s5h1432_set_IF(struct dvb_frontend *fe, u32 ifFreqHz)
124{
125 struct s5h1432_state *state = fe->demodulator_priv;
126
127 switch (ifFreqHz) {
128 case TAIWAN_HI_IF_FREQ_44_MHZ:
129 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe4, 0x55);
130 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe5, 0x55);
131 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe7, 0x15);
132 break;
133 case EUROPE_HI_IF_FREQ_36_MHZ:
134 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe4, 0x00);
135 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe5, 0x00);
136 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe7, 0x40);
137 break;
138 case IF_FREQ_6_MHZ:
139 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe4, 0x00);
140 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe5, 0x00);
141 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe7, 0xe0);
142 break;
143 case IF_FREQ_3point3_MHZ:
144 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe4, 0x66);
145 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe5, 0x66);
146 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe7, 0xEE);
147 break;
148 case IF_FREQ_3point5_MHZ:
149 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe4, 0x55);
150 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe5, 0x55);
151 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe7, 0xED);
152 break;
153 case IF_FREQ_4_MHZ:
154 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe4, 0xAA);
155 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe5, 0xAA);
156 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe7, 0xEA);
157 break;
158 default:
159 {
160 u32 value = 0;
161 value = (u32) (((48000 - (ifFreqHz / 1000)) * 512 *
162 (u32) 32768) / (48 * 1000));
163 printk(KERN_INFO
164 "Default IFFreq %d :reg value = 0x%x\n",
165 ifFreqHz, value);
166 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe4,
167 (u8) value & 0xFF);
168 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe5,
169 (u8) (value >> 8) & 0xFF);
170 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe7,
171 (u8) (value >> 16) & 0xFF);
172 break;
173 }
174
175 }
176
177 return 1;
178}
179
180/* Talk to the demod, set the FEC, GUARD, QAM settings etc */
181static int s5h1432_set_frontend(struct dvb_frontend *fe,
182 struct dvb_frontend_parameters *p)
183{
184 u32 dvb_bandwidth = 8;
185 struct s5h1432_state *state = fe->demodulator_priv;
186
187 if (p->frequency == state->current_frequency) {
188 /*current_frequency = p->frequency; */
189 /*state->current_frequency = p->frequency; */
190 } else {
191 fe->ops.tuner_ops.set_params(fe, p);
192 msleep(300);
193 s5h1432_set_channel_bandwidth(fe, dvb_bandwidth);
194 switch (p->u.ofdm.bandwidth) {
195 case BANDWIDTH_6_MHZ:
196 dvb_bandwidth = 6;
197 s5h1432_set_IF(fe, IF_FREQ_4_MHZ);
198 break;
199 case BANDWIDTH_7_MHZ:
200 dvb_bandwidth = 7;
201 s5h1432_set_IF(fe, IF_FREQ_4_MHZ);
202 break;
203 case BANDWIDTH_8_MHZ:
204 dvb_bandwidth = 8;
205 s5h1432_set_IF(fe, IF_FREQ_4_MHZ);
206 break;
207 default:
208 return 0;
209 }
210 /*fe->ops.tuner_ops.set_params(fe, p); */
211/*Soft Reset chip*/
212 msleep(30);
213 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x09, 0x1a);
214 msleep(30);
215 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x09, 0x1b);
216
217 s5h1432_set_channel_bandwidth(fe, dvb_bandwidth);
218 switch (p->u.ofdm.bandwidth) {
219 case BANDWIDTH_6_MHZ:
220 dvb_bandwidth = 6;
221 s5h1432_set_IF(fe, IF_FREQ_4_MHZ);
222 break;
223 case BANDWIDTH_7_MHZ:
224 dvb_bandwidth = 7;
225 s5h1432_set_IF(fe, IF_FREQ_4_MHZ);
226 break;
227 case BANDWIDTH_8_MHZ:
228 dvb_bandwidth = 8;
229 s5h1432_set_IF(fe, IF_FREQ_4_MHZ);
230 break;
231 default:
232 return 0;
233 }
234 /*fe->ops.tuner_ops.set_params(fe,p); */
235 /*Soft Reset chip*/
236 msleep(30);
237 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x09, 0x1a);
238 msleep(30);
239 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x09, 0x1b);
240
241 }
242
243 state->current_frequency = p->frequency;
244
245 return 0;
246}
247
248static int s5h1432_init(struct dvb_frontend *fe)
249{
250 struct s5h1432_state *state = fe->demodulator_priv;
251
252 u8 reg = 0;
253 state->current_frequency = 0;
254 printk(KERN_INFO " s5h1432_init().\n");
255
256 /*Set VSB mode as default, this also does a soft reset */
257 /*Initialize registers */
258
259 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x04, 0xa8);
260 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x05, 0x01);
261 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x07, 0x70);
262 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x19, 0x80);
263 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x1b, 0x9D);
264 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x1c, 0x30);
265 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x1d, 0x20);
266 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x1e, 0x1B);
267 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x2e, 0x40);
268 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x42, 0x84);
269 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x50, 0x5a);
270 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x5a, 0xd3);
271 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x68, 0x50);
272 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xb8, 0x3c);
273 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xc4, 0x10);
274 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xcc, 0x9c);
275 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xDA, 0x00);
276 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe1, 0x94);
277 /* s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xf4, 0xa1); */
278 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xf9, 0x00);
279
280 /*For NXP tuner*/
281
282 /*Set 3.3MHz as default IF frequency */
283 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe4, 0x66);
284 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe5, 0x66);
285 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0xe7, 0xEE);
286 /* Set reg 0x1E to get the full dynamic range */
287 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x1e, 0x31);
288
289 /* Mode setting in demod */
290 reg = s5h1432_readreg(state, S5H1432_I2C_TOP_ADDR, 0x42);
291 reg |= 0x80;
292 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x42, reg);
293 /* Serial mode */
294
295 /* Soft Reset chip */
296
297 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x09, 0x1a);
298 msleep(30);
299 s5h1432_writereg(state, S5H1432_I2C_TOP_ADDR, 0x09, 0x1b);
300
301
302 return 0;
303}
304
305static int s5h1432_read_status(struct dvb_frontend *fe, fe_status_t *status)
306{
307 return 0;
308}
309
310static int s5h1432_read_signal_strength(struct dvb_frontend *fe,
311 u16 *signal_strength)
312{
313 return 0;
314}
315
316static int s5h1432_read_snr(struct dvb_frontend *fe, u16 *snr)
317{
318 return 0;
319}
320
321static int s5h1432_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
322{
323
324 return 0;
325}
326
327static int s5h1432_read_ber(struct dvb_frontend *fe, u32 *ber)
328{
329 return 0;
330}
331
332static int s5h1432_get_frontend(struct dvb_frontend *fe,
333 struct dvb_frontend_parameters *p)
334{
335 return 0;
336}
337
338static int s5h1432_get_tune_settings(struct dvb_frontend *fe,
339 struct dvb_frontend_tune_settings *tune)
340{
341 return 0;
342}
343
344static void s5h1432_release(struct dvb_frontend *fe)
345{
346 struct s5h1432_state *state = fe->demodulator_priv;
347 kfree(state);
348}
349
350static struct dvb_frontend_ops s5h1432_ops;
351
352struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config,
353 struct i2c_adapter *i2c)
354{
355 struct s5h1432_state *state = NULL;
356
357 printk(KERN_INFO " Enter s5h1432_attach(). attach success!\n");
358 /* allocate memory for the internal state */
359 state = kmalloc(sizeof(struct s5h1432_state), GFP_KERNEL);
360 if (state == NULL)
361 goto error;
362
363 /* setup the state */
364 state->config = config;
365 state->i2c = i2c;
366 state->current_modulation = QAM_16;
367 state->inversion = state->config->inversion;
368
369 /* create dvb_frontend */
370 memcpy(&state->frontend.ops, &s5h1432_ops,
371 sizeof(struct dvb_frontend_ops));
372
373 state->frontend.demodulator_priv = state;
374
375 return &state->frontend;
376
377error:
378 kfree(state);
379 return NULL;
380}
381EXPORT_SYMBOL(s5h1432_attach);
382
383static struct dvb_frontend_ops s5h1432_ops = {
384
385 .info = {
386 .name = "Samsung s5h1432 DVB-T Frontend",
387 .type = FE_OFDM,
388 .frequency_min = 177000000,
389 .frequency_max = 858000000,
390 .frequency_stepsize = 166666,
391 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
392 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
393 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
394 FE_CAN_HIERARCHY_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
395 FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_RECOVER},
396
397 .init = s5h1432_init,
398 .sleep = s5h1432_sleep,
399 .set_frontend = s5h1432_set_frontend,
400 .get_frontend = s5h1432_get_frontend,
401 .get_tune_settings = s5h1432_get_tune_settings,
402 .read_status = s5h1432_read_status,
403 .read_ber = s5h1432_read_ber,
404 .read_signal_strength = s5h1432_read_signal_strength,
405 .read_snr = s5h1432_read_snr,
406 .read_ucblocks = s5h1432_read_ucblocks,
407 .release = s5h1432_release,
408};
409
410module_param(debug, int, 0644);
411MODULE_PARM_DESC(debug, "Enable verbose debug messages");
412
413MODULE_DESCRIPTION("Samsung s5h1432 DVB-T Demodulator driver");
414MODULE_AUTHOR("Bill Liu");
415MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/s5h1432.h b/drivers/media/dvb/frontends/s5h1432.h
new file mode 100644
index 000000000000..b57438c32546
--- /dev/null
+++ b/drivers/media/dvb/frontends/s5h1432.h
@@ -0,0 +1,91 @@
1/*
2 * Samsung s5h1432 VSB/QAM demodulator driver
3 *
4 * Copyright (C) 2009 Bill Liu <Bill.Liu@Conexant.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21
22#ifndef __S5H1432_H__
23#define __S5H1432_H__
24
25#include <linux/dvb/frontend.h>
26
27#define S5H1432_I2C_TOP_ADDR (0x02 >> 1)
28
29#define TAIWAN_HI_IF_FREQ_44_MHZ 44000000
30#define EUROPE_HI_IF_FREQ_36_MHZ 36000000
31#define IF_FREQ_6_MHZ 6000000
32#define IF_FREQ_3point3_MHZ 3300000
33#define IF_FREQ_3point5_MHZ 3500000
34#define IF_FREQ_4_MHZ 4000000
35
36struct s5h1432_config {
37
38 /* serial/parallel output */
39#define S5H1432_PARALLEL_OUTPUT 0
40#define S5H1432_SERIAL_OUTPUT 1
41 u8 output_mode;
42
43 /* GPIO Setting */
44#define S5H1432_GPIO_OFF 0
45#define S5H1432_GPIO_ON 1
46 u8 gpio;
47
48 /* MPEG signal timing */
49#define S5H1432_MPEGTIMING_CONTINOUS_INVERTING_CLOCK 0
50#define S5H1432_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK 1
51#define S5H1432_MPEGTIMING_NONCONTINOUS_INVERTING_CLOCK 2
52#define S5H1432_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK 3
53 u16 mpeg_timing;
54
55 /* IF Freq for QAM and VSB in KHz */
56#define S5H1432_IF_3250 3250
57#define S5H1432_IF_3500 3500
58#define S5H1432_IF_4000 4000
59#define S5H1432_IF_5380 5380
60#define S5H1432_IF_44000 44000
61#define S5H1432_VSB_IF_DEFAULT s5h1432_IF_44000
62#define S5H1432_QAM_IF_DEFAULT s5h1432_IF_44000
63 u16 qam_if;
64 u16 vsb_if;
65
66 /* Spectral Inversion */
67#define S5H1432_INVERSION_OFF 0
68#define S5H1432_INVERSION_ON 1
69 u8 inversion;
70
71 /* Return lock status based on tuner lock, or demod lock */
72#define S5H1432_TUNERLOCKING 0
73#define S5H1432_DEMODLOCKING 1
74 u8 status_mode;
75};
76
77#if defined(CONFIG_DVB_S5H1432) || \
78 (defined(CONFIG_DVB_S5H1432_MODULE) && defined(MODULE))
79extern struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config,
80 struct i2c_adapter *i2c);
81#else
82static inline struct dvb_frontend *s5h1432_attach(const struct s5h1432_config
83 *config,
84 struct i2c_adapter *i2c)
85{
86 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
87 return NULL;
88}
89#endif /* CONFIG_DVB_s5h1432 */
90
91#endif /* __s5h1432_H__ */
diff --git a/drivers/media/dvb/frontends/si21xx.c b/drivers/media/dvb/frontends/si21xx.c
index d21a327db629..4b0c99a08a85 100644
--- a/drivers/media/dvb/frontends/si21xx.c
+++ b/drivers/media/dvb/frontends/si21xx.c
@@ -268,7 +268,7 @@ static int si21_writereg(struct si21xx_state *state, u8 reg, u8 data)
268 return (ret != 1) ? -EREMOTEIO : 0; 268 return (ret != 1) ? -EREMOTEIO : 0;
269} 269}
270 270
271static int si21_write(struct dvb_frontend *fe, u8 *buf, int len) 271static int si21_write(struct dvb_frontend *fe, const u8 buf[], int len)
272{ 272{
273 struct si21xx_state *state = fe->demodulator_priv; 273 struct si21xx_state *state = fe->demodulator_priv;
274 274
diff --git a/drivers/media/dvb/frontends/stb6100.c b/drivers/media/dvb/frontends/stb6100.c
index f73c13323e90..80a9e4cba631 100644
--- a/drivers/media/dvb/frontends/stb6100.c
+++ b/drivers/media/dvb/frontends/stb6100.c
@@ -506,7 +506,7 @@ static struct dvb_tuner_ops stb6100_ops = {
506}; 506};
507 507
508struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe, 508struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
509 struct stb6100_config *config, 509 const struct stb6100_config *config,
510 struct i2c_adapter *i2c) 510 struct i2c_adapter *i2c)
511{ 511{
512 struct stb6100_state *state = NULL; 512 struct stb6100_state *state = NULL;
diff --git a/drivers/media/dvb/frontends/stb6100.h b/drivers/media/dvb/frontends/stb6100.h
index 395d056599a6..2ab096614b3f 100644
--- a/drivers/media/dvb/frontends/stb6100.h
+++ b/drivers/media/dvb/frontends/stb6100.h
@@ -97,13 +97,13 @@ struct stb6100_state {
97#if defined(CONFIG_DVB_STB6100) || (defined(CONFIG_DVB_STB6100_MODULE) && defined(MODULE)) 97#if defined(CONFIG_DVB_STB6100) || (defined(CONFIG_DVB_STB6100_MODULE) && defined(MODULE))
98 98
99extern struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe, 99extern struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
100 struct stb6100_config *config, 100 const struct stb6100_config *config,
101 struct i2c_adapter *i2c); 101 struct i2c_adapter *i2c);
102 102
103#else 103#else
104 104
105static inline struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe, 105static inline struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
106 struct stb6100_config *config, 106 const struct stb6100_config *config,
107 struct i2c_adapter *i2c) 107 struct i2c_adapter *i2c)
108{ 108{
109 printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__); 109 printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
diff --git a/drivers/media/dvb/frontends/stv0288.c b/drivers/media/dvb/frontends/stv0288.c
index 2930a5d6768a..63db8fd2754c 100644
--- a/drivers/media/dvb/frontends/stv0288.c
+++ b/drivers/media/dvb/frontends/stv0288.c
@@ -6,6 +6,8 @@
6 Copyright (C) 2008 Igor M. Liplianin <liplianin@me.by> 6 Copyright (C) 2008 Igor M. Liplianin <liplianin@me.by>
7 Removed stb6000 specific tuner code and revised some 7 Removed stb6000 specific tuner code and revised some
8 procedures. 8 procedures.
9 2010-09-01 Josef Pavlik <josef@pavlik.it>
10 Fixed diseqc_msg, diseqc_burst and set_tone problems
9 11
10 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by 13 it under the terms of the GNU General Public License as published by
@@ -78,7 +80,7 @@ static int stv0288_writeregI(struct stv0288_state *state, u8 reg, u8 data)
78 return (ret != 1) ? -EREMOTEIO : 0; 80 return (ret != 1) ? -EREMOTEIO : 0;
79} 81}
80 82
81static int stv0288_write(struct dvb_frontend *fe, u8 *buf, int len) 83static int stv0288_write(struct dvb_frontend *fe, const u8 buf[], int len)
82{ 84{
83 struct stv0288_state *state = fe->demodulator_priv; 85 struct stv0288_state *state = fe->demodulator_priv;
84 86
@@ -156,14 +158,13 @@ static int stv0288_send_diseqc_msg(struct dvb_frontend *fe,
156 158
157 stv0288_writeregI(state, 0x09, 0); 159 stv0288_writeregI(state, 0x09, 0);
158 msleep(30); 160 msleep(30);
159 stv0288_writeregI(state, 0x05, 0x16); 161 stv0288_writeregI(state, 0x05, 0x12);/* modulated mode, single shot */
160 162
161 for (i = 0; i < m->msg_len; i++) { 163 for (i = 0; i < m->msg_len; i++) {
162 if (stv0288_writeregI(state, 0x06, m->msg[i])) 164 if (stv0288_writeregI(state, 0x06, m->msg[i]))
163 return -EREMOTEIO; 165 return -EREMOTEIO;
164 msleep(12);
165 } 166 }
166 167 msleep(m->msg_len*12);
167 return 0; 168 return 0;
168} 169}
169 170
@@ -174,13 +175,14 @@ static int stv0288_send_diseqc_burst(struct dvb_frontend *fe,
174 175
175 dprintk("%s\n", __func__); 176 dprintk("%s\n", __func__);
176 177
177 if (stv0288_writeregI(state, 0x05, 0x16))/* burst mode */ 178 if (stv0288_writeregI(state, 0x05, 0x03))/* burst mode, single shot */
178 return -EREMOTEIO; 179 return -EREMOTEIO;
179 180
180 if (stv0288_writeregI(state, 0x06, burst == SEC_MINI_A ? 0x00 : 0xff)) 181 if (stv0288_writeregI(state, 0x06, burst == SEC_MINI_A ? 0x00 : 0xff))
181 return -EREMOTEIO; 182 return -EREMOTEIO;
182 183
183 if (stv0288_writeregI(state, 0x06, 0x12)) 184 msleep(15);
185 if (stv0288_writeregI(state, 0x05, 0x12))
184 return -EREMOTEIO; 186 return -EREMOTEIO;
185 187
186 return 0; 188 return 0;
@@ -192,18 +194,19 @@ static int stv0288_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
192 194
193 switch (tone) { 195 switch (tone) {
194 case SEC_TONE_ON: 196 case SEC_TONE_ON:
195 if (stv0288_writeregI(state, 0x05, 0x10))/* burst mode */ 197 if (stv0288_writeregI(state, 0x05, 0x10))/* cont carrier */
196 return -EREMOTEIO; 198 return -EREMOTEIO;
197 return stv0288_writeregI(state, 0x06, 0xff); 199 break;
198 200
199 case SEC_TONE_OFF: 201 case SEC_TONE_OFF:
200 if (stv0288_writeregI(state, 0x05, 0x13))/* burst mode */ 202 if (stv0288_writeregI(state, 0x05, 0x12))/* burst mode off*/
201 return -EREMOTEIO; 203 return -EREMOTEIO;
202 return stv0288_writeregI(state, 0x06, 0x00); 204 break;
203 205
204 default: 206 default:
205 return -EINVAL; 207 return -EINVAL;
206 } 208 }
209 return 0;
207} 210}
208 211
209static u8 stv0288_inittab[] = { 212static u8 stv0288_inittab[] = {
@@ -486,7 +489,7 @@ static int stv0288_set_frontend(struct dvb_frontend *fe,
486 tda[2] = 0x0; /* CFRL */ 489 tda[2] = 0x0; /* CFRL */
487 for (tm = -6; tm < 7;) { 490 for (tm = -6; tm < 7;) {
488 /* Viterbi status */ 491 /* Viterbi status */
489 if (stv0288_readreg(state, 0x24) & 0x80) 492 if (stv0288_readreg(state, 0x24) & 0x8)
490 break; 493 break;
491 494
492 tda[2] += 40; 495 tda[2] += 40;
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c
index 968874469726..4e3db3a42e06 100644
--- a/drivers/media/dvb/frontends/stv0299.c
+++ b/drivers/media/dvb/frontends/stv0299.c
@@ -92,7 +92,7 @@ static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
92 return (ret != 1) ? -EREMOTEIO : 0; 92 return (ret != 1) ? -EREMOTEIO : 0;
93} 93}
94 94
95static int stv0299_write(struct dvb_frontend* fe, u8 *buf, int len) 95static int stv0299_write(struct dvb_frontend* fe, const u8 buf[], int len)
96{ 96{
97 struct stv0299_state* state = fe->demodulator_priv; 97 struct stv0299_state* state = fe->demodulator_priv;
98 98
diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h
index 0fd96e22b650..ba219b767a69 100644
--- a/drivers/media/dvb/frontends/stv0299.h
+++ b/drivers/media/dvb/frontends/stv0299.h
@@ -65,7 +65,7 @@ struct stv0299_config
65 * First of each pair is the register, second is the value. 65 * First of each pair is the register, second is the value.
66 * List should be terminated with an 0xff, 0xff pair. 66 * List should be terminated with an 0xff, 0xff pair.
67 */ 67 */
68 u8* inittab; 68 const u8* inittab;
69 69
70 /* master clock to use */ 70 /* master clock to use */
71 u32 mclk; 71 u32 mclk;
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index f2a8abe0a243..ea485d923550 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -598,7 +598,7 @@ static int tda1004x_decode_fec(int tdafec)
598 return -1; 598 return -1;
599} 599}
600 600
601static int tda1004x_write(struct dvb_frontend* fe, u8 *buf, int len) 601static int tda1004x_write(struct dvb_frontend* fe, const u8 buf[], int len)
602{ 602{
603 struct tda1004x_state* state = fe->demodulator_priv; 603 struct tda1004x_state* state = fe->demodulator_priv;
604 604
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
index 8c612719adfc..adbbf6d3d044 100644
--- a/drivers/media/dvb/frontends/zl10353.c
+++ b/drivers/media/dvb/frontends/zl10353.c
@@ -64,7 +64,7 @@ static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
64 return 0; 64 return 0;
65} 65}
66 66
67static int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen) 67static int zl10353_write(struct dvb_frontend *fe, const u8 ibuf[], int ilen)
68{ 68{
69 int err, i; 69 int err, i;
70 for (i = 0; i < ilen - 1; i++) 70 for (i = 0; i < ilen - 1; i++)
diff --git a/drivers/media/dvb/mantis/mantis_core.c b/drivers/media/dvb/mantis/mantis_core.c
index 8113b23ce448..22524a8e6f61 100644
--- a/drivers/media/dvb/mantis/mantis_core.c
+++ b/drivers/media/dvb/mantis/mantis_core.c
@@ -91,10 +91,7 @@ static int get_mac_address(struct mantis_pci *mantis)
91 return err; 91 return err;
92 } 92 }
93 dprintk(verbose, MANTIS_ERROR, 0, 93 dprintk(verbose, MANTIS_ERROR, 0,
94 " MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]\n", 94 " MAC Address=[%pM]\n", mantis->mac_address);
95 mantis->mac_address[0], mantis->mac_address[1],
96 mantis->mac_address[2], mantis->mac_address[3],
97 mantis->mac_address[4], mantis->mac_address[5]);
98 95
99 return 0; 96 return 0;
100} 97}
diff --git a/drivers/media/dvb/mantis/mantis_i2c.c b/drivers/media/dvb/mantis/mantis_i2c.c
index 7870bcf9689a..e7794517fe26 100644
--- a/drivers/media/dvb/mantis/mantis_i2c.c
+++ b/drivers/media/dvb/mantis/mantis_i2c.c
@@ -229,7 +229,6 @@ int __devinit mantis_i2c_init(struct mantis_pci *mantis)
229 i2c_set_adapdata(i2c_adapter, mantis); 229 i2c_set_adapdata(i2c_adapter, mantis);
230 230
231 i2c_adapter->owner = THIS_MODULE; 231 i2c_adapter->owner = THIS_MODULE;
232 i2c_adapter->class = I2C_CLASS_TV_DIGITAL;
233 i2c_adapter->algo = &mantis_algo; 232 i2c_adapter->algo = &mantis_algo;
234 i2c_adapter->algo_data = NULL; 233 i2c_adapter->algo_data = NULL;
235 i2c_adapter->timeout = 500; 234 i2c_adapter->timeout = 500;
diff --git a/drivers/media/dvb/mantis/mantis_ioc.c b/drivers/media/dvb/mantis/mantis_ioc.c
index de148ded52d8..fe31cfb0b158 100644
--- a/drivers/media/dvb/mantis/mantis_ioc.c
+++ b/drivers/media/dvb/mantis/mantis_ioc.c
@@ -68,14 +68,7 @@ int mantis_get_mac(struct mantis_pci *mantis)
68 return err; 68 return err;
69 } 69 }
70 70
71 dprintk(MANTIS_ERROR, 0, 71 dprintk(MANTIS_ERROR, 0, " MAC Address=[%pM]\n", mac_addr);
72 " MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]\n",
73 mac_addr[0],
74 mac_addr[1],
75 mac_addr[2],
76 mac_addr[3],
77 mac_addr[4],
78 mac_addr[5]);
79 72
80 return 0; 73 return 0;
81} 74}
diff --git a/drivers/media/dvb/ngene/ngene-i2c.c b/drivers/media/dvb/ngene/ngene-i2c.c
index 477fe0aade86..c3ae956714e7 100644
--- a/drivers/media/dvb/ngene/ngene-i2c.c
+++ b/drivers/media/dvb/ngene/ngene-i2c.c
@@ -165,7 +165,6 @@ int ngene_i2c_init(struct ngene *dev, int dev_nr)
165 struct i2c_adapter *adap = &(dev->channel[dev_nr].i2c_adapter); 165 struct i2c_adapter *adap = &(dev->channel[dev_nr].i2c_adapter);
166 166
167 i2c_set_adapdata(adap, &(dev->channel[dev_nr])); 167 i2c_set_adapdata(adap, &(dev->channel[dev_nr]));
168 adap->class = I2C_CLASS_TV_DIGITAL | I2C_CLASS_TV_ANALOG;
169 168
170 strcpy(adap->name, "nGene"); 169 strcpy(adap->name, "nGene");
171 170
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index 1c798219dc7c..6ca6713d527a 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -647,7 +647,6 @@ static int __devinit pluto2_probe(struct pci_dev *pdev,
647 i2c_set_adapdata(&pluto->i2c_adap, pluto); 647 i2c_set_adapdata(&pluto->i2c_adap, pluto);
648 strcpy(pluto->i2c_adap.name, DRIVER_NAME); 648 strcpy(pluto->i2c_adap.name, DRIVER_NAME);
649 pluto->i2c_adap.owner = THIS_MODULE; 649 pluto->i2c_adap.owner = THIS_MODULE;
650 pluto->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
651 pluto->i2c_adap.dev.parent = &pdev->dev; 650 pluto->i2c_adap.dev.parent = &pdev->dev;
652 pluto->i2c_adap.algo_data = &pluto->i2c_bit; 651 pluto->i2c_adap.algo_data = &pluto->i2c_bit;
653 pluto->i2c_bit.data = pluto; 652 pluto->i2c_bit.data = pluto;
diff --git a/drivers/media/dvb/pt1/pt1.c b/drivers/media/dvb/pt1/pt1.c
index 69ad94934ec2..0486919c1d0f 100644
--- a/drivers/media/dvb/pt1/pt1.c
+++ b/drivers/media/dvb/pt1/pt1.c
@@ -1087,7 +1087,6 @@ pt1_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1087 pt1_update_power(pt1); 1087 pt1_update_power(pt1);
1088 1088
1089 i2c_adap = &pt1->i2c_adap; 1089 i2c_adap = &pt1->i2c_adap;
1090 i2c_adap->class = I2C_CLASS_TV_DIGITAL;
1091 i2c_adap->algo = &pt1_i2c_algo; 1090 i2c_adap->algo = &pt1_i2c_algo;
1092 i2c_adap->algo_data = NULL; 1091 i2c_adap->algo_data = NULL;
1093 i2c_adap->dev.parent = &pdev->dev; 1092 i2c_adap->dev.parent = &pdev->dev;
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c
index ff3b0fa901b3..135e45bd00c7 100644
--- a/drivers/media/dvb/siano/smscoreapi.c
+++ b/drivers/media/dvb/siano/smscoreapi.c
@@ -1504,8 +1504,7 @@ int smscore_gpio_set_level(struct smscore_device_t *coredev, u8 PinNum,
1504 u32 msgData[3]; /* keep it 3 ! */ 1504 u32 msgData[3]; /* keep it 3 ! */
1505 } *pMsg; 1505 } *pMsg;
1506 1506
1507 if ((NewLevel > 1) || (PinNum > MAX_GPIO_PIN_NUMBER) || 1507 if ((NewLevel > 1) || (PinNum > MAX_GPIO_PIN_NUMBER))
1508 (PinNum > MAX_GPIO_PIN_NUMBER))
1509 return -EINVAL; 1508 return -EINVAL;
1510 1509
1511 totalLen = sizeof(struct SmsMsgHdr_ST) + 1510 totalLen = sizeof(struct SmsMsgHdr_ST) +
diff --git a/drivers/media/dvb/siano/smsir.c b/drivers/media/dvb/siano/smsir.c
index d0e4639ee9db..a27c44a8af5a 100644
--- a/drivers/media/dvb/siano/smsir.c
+++ b/drivers/media/dvb/siano/smsir.c
@@ -40,7 +40,7 @@ void sms_ir_event(struct smscore_device_t *coredev, const char *buf, int len)
40 const s32 *samples = (const void *)buf; 40 const s32 *samples = (const void *)buf;
41 41
42 for (i = 0; i < len >> 2; i++) { 42 for (i = 0; i < len >> 2; i++) {
43 struct ir_raw_event ev; 43 DEFINE_IR_RAW_EVENT(ev);
44 44
45 ev.duration = abs(samples[i]) * 1000; /* Convert to ns */ 45 ev.duration = abs(samples[i]) * 1000; /* Convert to ns */
46 ev.pulse = (samples[i] > 0) ? false : true; 46 ev.pulse = (samples[i] > 0) ? false : true;
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index a12b88f53ed9..fc0a60f8a1e1 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -2472,7 +2472,6 @@ static int __devinit av7110_attach(struct saa7146_dev* dev,
2472 get recognized before the main driver is fully loaded */ 2472 get recognized before the main driver is fully loaded */
2473 saa7146_write(dev, GPIO_CTRL, 0x500000); 2473 saa7146_write(dev, GPIO_CTRL, 0x500000);
2474 2474
2475 av7110->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
2476 strlcpy(av7110->i2c_adap.name, pci_ext->ext_priv, sizeof(av7110->i2c_adap.name)); 2475 strlcpy(av7110->i2c_adap.name, pci_ext->ext_priv, sizeof(av7110->i2c_adap.name));
2477 2476
2478 saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */ 2477 saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */
@@ -2886,7 +2885,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
2886 2885
2887 2886
2888static struct saa7146_extension av7110_extension_driver = { 2887static struct saa7146_extension av7110_extension_driver = {
2889 .name = "dvb", 2888 .name = "av7110",
2890 .flags = SAA7146_USE_I2C_IRQ, 2889 .flags = SAA7146_USE_I2C_IRQ,
2891 2890
2892 .module = THIS_MODULE, 2891 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 244d5d51f5f9..952b33dbac4f 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -245,8 +245,11 @@ int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen)
245 return -1; 245 return -1;
246 } 246 }
247 while (1) { 247 while (1) {
248 if ((len = dvb_ringbuffer_avail(buf)) < 6) 248 len = dvb_ringbuffer_avail(buf);
249 if (len < 6) {
250 wake_up(&buf->queue);
249 return -1; 251 return -1;
252 }
250 sync = DVB_RINGBUFFER_PEEK(buf, 0) << 24; 253 sync = DVB_RINGBUFFER_PEEK(buf, 0) << 24;
251 sync |= DVB_RINGBUFFER_PEEK(buf, 1) << 16; 254 sync |= DVB_RINGBUFFER_PEEK(buf, 1) << 16;
252 sync |= DVB_RINGBUFFER_PEEK(buf, 2) << 8; 255 sync |= DVB_RINGBUFFER_PEEK(buf, 2) << 8;
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c
index 054661315311..37666d4edab6 100644
--- a/drivers/media/dvb/ttpci/budget-core.c
+++ b/drivers/media/dvb/ttpci/budget-core.c
@@ -495,8 +495,6 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
495 if (bi->type != BUDGET_FS_ACTIVY) 495 if (bi->type != BUDGET_FS_ACTIVY)
496 saa7146_write(dev, GPIO_CTRL, 0x500000); /* GPIO 3 = 1 */ 496 saa7146_write(dev, GPIO_CTRL, 0x500000); /* GPIO 3 = 1 */
497 497
498 budget->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
499
500 strlcpy(budget->i2c_adap.name, budget->card->name, sizeof(budget->i2c_adap.name)); 498 strlcpy(budget->i2c_adap.name, budget->card->name, sizeof(budget->i2c_adap.name));
501 499
502 saa7146_i2c_adapter_prepare(dev, &budget->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); 500 saa7146_i2c_adapter_prepare(dev, &budget->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120);
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 4a3f2b8ea37d..40625b26ac10 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -1694,7 +1694,6 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1694 1694
1695 i2c_set_adapdata(&ttusb->i2c_adap, ttusb); 1695 i2c_set_adapdata(&ttusb->i2c_adap, ttusb);
1696 1696
1697 ttusb->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
1698 ttusb->i2c_adap.algo = &ttusb_dec_algo; 1697 ttusb->i2c_adap.algo = &ttusb_dec_algo;
1699 ttusb->i2c_adap.algo_data = NULL; 1698 ttusb->i2c_adap.algo_data = NULL;
1700 ttusb->i2c_adap.dev.parent = &udev->dev; 1699 ttusb->i2c_adap.dev.parent = &udev->dev;