aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttpci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/ttpci')
-rw-r--r--drivers/media/dvb/ttpci/av7110.c201
-rw-r--r--drivers/media/dvb/ttpci/av7110.h11
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c8
-rw-r--r--drivers/media/dvb/ttpci/av7110_ir.c140
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c74
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c9
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c197
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c5
-rw-r--r--drivers/media/dvb/ttpci/budget.c6
9 files changed, 482 insertions, 169 deletions
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index e4c6e87f6c5d..22b203f8ff27 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -168,7 +168,9 @@ static void init_av7110_av(struct av7110 *av7110)
168 if (ret < 0) 168 if (ret < 0)
169 printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret); 169 printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret);
170 if (rgb_on && 170 if (rgb_on &&
171 (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) { 171 ((av7110->dev->pci->subsystem_vendor == 0x110a) ||
172 (av7110->dev->pci->subsystem_vendor == 0x13c2)) &&
173 (av7110->dev->pci->subsystem_device == 0x0000)) {
172 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16 174 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
173 //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8 175 //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8
174 } 176 }
@@ -177,9 +179,6 @@ static void init_av7110_av(struct av7110 *av7110)
177 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); 179 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
178 if (ret < 0) 180 if (ret < 0)
179 printk("dvb-ttpci:cannot set volume :%d\n",ret); 181 printk("dvb-ttpci:cannot set volume :%d\n",ret);
180 ret = av7110_setup_irc_config(av7110, 0);
181 if (ret < 0)
182 printk("dvb-ttpci:cannot setup irc config :%d\n",ret);
183} 182}
184 183
185static void recover_arm(struct av7110 *av7110) 184static void recover_arm(struct av7110 *av7110)
@@ -265,60 +264,6 @@ static int arm_thread(void *data)
265} 264}
266 265
267 266
268/**
269 * Hack! we save the last av7110 ptr. This should be ok, since
270 * you rarely will use more then one IR control.
271 *
272 * If we want to support multiple controls we would have to do much more...
273 */
274int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
275{
276 int ret = 0;
277 static struct av7110 *last;
278
279 dprintk(4, "%p\n", av7110);
280
281 if (!av7110)
282 av7110 = last;
283 else
284 last = av7110;
285
286 if (av7110) {
287 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config);
288 av7110->ir_config = ir_config;
289 }
290 return ret;
291}
292
293static void (*irc_handler)(u32);
294
295void av7110_register_irc_handler(void (*func)(u32))
296{
297 dprintk(4, "registering %p\n", func);
298 irc_handler = func;
299}
300
301void av7110_unregister_irc_handler(void (*func)(u32))
302{
303 dprintk(4, "unregistering %p\n", func);
304 irc_handler = NULL;
305}
306
307static void run_handlers(unsigned long ircom)
308{
309 if (irc_handler != NULL)
310 (*irc_handler)((u32) ircom);
311}
312
313static DECLARE_TASKLET(irtask, run_handlers, 0);
314
315static void IR_handle(struct av7110 *av7110, u32 ircom)
316{
317 dprintk(4, "ircommand = %08x\n", ircom);
318 irtask.data = (unsigned long) ircom;
319 tasklet_schedule(&irtask);
320}
321
322/**************************************************************************** 267/****************************************************************************
323 * IRQ handling 268 * IRQ handling
324 ****************************************************************************/ 269 ****************************************************************************/
@@ -711,8 +656,9 @@ static void gpioirq(unsigned long data)
711 return; 656 return;
712 657
713 case DATA_IRCOMMAND: 658 case DATA_IRCOMMAND:
714 IR_handle(av7110, 659 if (av7110->ir_handler)
715 swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); 660 av7110->ir_handler(av7110,
661 swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4)));
716 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); 662 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
717 break; 663 break;
718 664
@@ -1668,9 +1614,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra
1668 return 0; 1614 return 0;
1669} 1615}
1670 1616
1671static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1617static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
1672{ 1618{
1673 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1674 int ret; 1619 int ret;
1675 u8 data[4]; 1620 u8 data[4];
1676 u32 div; 1621 u32 div;
@@ -1687,7 +1632,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
1687 1632
1688 if (params->frequency > 1530000) data[3] = 0xc0; 1633 if (params->frequency > 1530000) data[3] = 0xc0;
1689 1634
1690 ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); 1635 ret = i2c_transfer(i2c, &msg, 1);
1691 if (ret != 1) 1636 if (ret != 1)
1692 return -EIO; 1637 return -EIO;
1693 return 0; 1638 return 0;
@@ -1751,9 +1696,8 @@ static u8 alps_bsbe1_inittab[] = {
1751 0xff, 0xff 1696 0xff, 0xff
1752}; 1697};
1753 1698
1754static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1699static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
1755{ 1700{
1756 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1757 int ret; 1701 int ret;
1758 u8 data[4]; 1702 u8 data[4];
1759 u32 div; 1703 u32 div;
@@ -1768,7 +1712,7 @@ static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
1768 data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; 1712 data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
1769 data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4; 1713 data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
1770 1714
1771 ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); 1715 ret = i2c_transfer(i2c, &msg, 1);
1772 return (ret != 1) ? -EIO : 0; 1716 return (ret != 1) ? -EIO : 0;
1773} 1717}
1774 1718
@@ -1936,6 +1880,98 @@ static struct sp8870_config alps_tdlb7_config = {
1936}; 1880};
1937 1881
1938 1882
1883static u8 nexusca_stv0297_inittab[] = {
1884 0x80, 0x01,
1885 0x80, 0x00,
1886 0x81, 0x01,
1887 0x81, 0x00,
1888 0x00, 0x09,
1889 0x01, 0x69,
1890 0x03, 0x00,
1891 0x04, 0x00,
1892 0x07, 0x00,
1893 0x08, 0x00,
1894 0x20, 0x00,
1895 0x21, 0x40,
1896 0x22, 0x00,
1897 0x23, 0x00,
1898 0x24, 0x40,
1899 0x25, 0x88,
1900 0x30, 0xff,
1901 0x31, 0x00,
1902 0x32, 0xff,
1903 0x33, 0x00,
1904 0x34, 0x50,
1905 0x35, 0x7f,
1906 0x36, 0x00,
1907 0x37, 0x20,
1908 0x38, 0x00,
1909 0x40, 0x1c,
1910 0x41, 0xff,
1911 0x42, 0x29,
1912 0x43, 0x00,
1913 0x44, 0xff,
1914 0x45, 0x00,
1915 0x46, 0x00,
1916 0x49, 0x04,
1917 0x4a, 0x00,
1918 0x4b, 0x7b,
1919 0x52, 0x30,
1920 0x55, 0xae,
1921 0x56, 0x47,
1922 0x57, 0xe1,
1923 0x58, 0x3a,
1924 0x5a, 0x1e,
1925 0x5b, 0x34,
1926 0x60, 0x00,
1927 0x63, 0x00,
1928 0x64, 0x00,
1929 0x65, 0x00,
1930 0x66, 0x00,
1931 0x67, 0x00,
1932 0x68, 0x00,
1933 0x69, 0x00,
1934 0x6a, 0x02,
1935 0x6b, 0x00,
1936 0x70, 0xff,
1937 0x71, 0x00,
1938 0x72, 0x00,
1939 0x73, 0x00,
1940 0x74, 0x0c,
1941 0x80, 0x00,
1942 0x81, 0x00,
1943 0x82, 0x00,
1944 0x83, 0x00,
1945 0x84, 0x04,
1946 0x85, 0x80,
1947 0x86, 0x24,
1948 0x87, 0x78,
1949 0x88, 0x10,
1950 0x89, 0x00,
1951 0x90, 0x01,
1952 0x91, 0x01,
1953 0xa0, 0x04,
1954 0xa1, 0x00,
1955 0xa2, 0x00,
1956 0xb0, 0x91,
1957 0xb1, 0x0b,
1958 0xc0, 0x53,
1959 0xc1, 0x70,
1960 0xc2, 0x12,
1961 0xd0, 0x00,
1962 0xd1, 0x00,
1963 0xd2, 0x00,
1964 0xd3, 0x00,
1965 0xd4, 0x00,
1966 0xd5, 0x00,
1967 0xde, 0x00,
1968 0xdf, 0x00,
1969 0x61, 0x49,
1970 0x62, 0x0b,
1971 0x53, 0x08,
1972 0x59, 0x08,
1973 0xff, 0xff,
1974};
1939 1975
1940static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1976static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1941{ 1977{
@@ -1984,6 +2020,7 @@ static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_
1984static struct stv0297_config nexusca_stv0297_config = { 2020static struct stv0297_config nexusca_stv0297_config = {
1985 2021
1986 .demod_address = 0x1C, 2022 .demod_address = 0x1C,
2023 .inittab = nexusca_stv0297_inittab,
1987 .invert = 1, 2024 .invert = 1,
1988 .pll_set = nexusca_stv0297_pll_set, 2025 .pll_set = nexusca_stv0297_pll_set,
1989}; 2026};
@@ -2261,7 +2298,7 @@ static int frontend_init(struct av7110 *av7110)
2261 2298
2262 case 0x000A: // Hauppauge/TT Nexus-CA rev1.X 2299 case 0x000A: // Hauppauge/TT Nexus-CA rev1.X
2263 2300
2264 av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap, 0x7b); 2301 av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap);
2265 if (av7110->fe) { 2302 if (av7110->fe) {
2266 /* set TDA9819 into DVB mode */ 2303 /* set TDA9819 into DVB mode */
2267 saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9198 pin9(STD) 2304 saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9198 pin9(STD)
@@ -2692,7 +2729,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
2692 goto err_av7110_exit_v4l_12; 2729 goto err_av7110_exit_v4l_12;
2693 2730
2694#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) 2731#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
2695 av7110_ir_init(); 2732 av7110_ir_init(av7110);
2696#endif 2733#endif
2697 printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num); 2734 printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num);
2698 av7110_num++; 2735 av7110_num++;
@@ -2734,6 +2771,9 @@ static int av7110_detach(struct saa7146_dev* saa)
2734 struct av7110 *av7110 = saa->ext_priv; 2771 struct av7110 *av7110 = saa->ext_priv;
2735 dprintk(4, "%p\n", av7110); 2772 dprintk(4, "%p\n", av7110);
2736 2773
2774#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
2775 av7110_ir_exit(av7110);
2776#endif
2737 if (budgetpatch) { 2777 if (budgetpatch) {
2738 /* Disable RPS1 */ 2778 /* Disable RPS1 */
2739 saa7146_write(saa, MC1, MASK_29); 2779 saa7146_write(saa, MC1, MASK_29);
@@ -2830,7 +2870,7 @@ static struct saa7146_pci_extension_data x_var = { \
2830 .ext_priv = x_name, \ 2870 .ext_priv = x_name, \
2831 .ext = &av7110_extension } 2871 .ext = &av7110_extension }
2832 2872
2833MAKE_AV7110_INFO(tts_1_X, "Technotrend/Hauppauge WinTV DVB-S rev1.X"); 2873MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C");
2834MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X"); 2874MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X");
2835MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X"); 2875MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X");
2836MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X"); 2876MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X");
@@ -2842,16 +2882,16 @@ MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C");
2842MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); 2882MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6");
2843 2883
2844static struct pci_device_id pci_tbl[] = { 2884static struct pci_device_id pci_tbl[] = {
2845 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), 2885 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
2846 MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000), 2886 MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000),
2847 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), 2887 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001),
2848 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), 2888 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002),
2849 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), 2889 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003),
2850 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), 2890 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006),
2851 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), 2891 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008),
2852 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), 2892 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
2853 MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), 2893 MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e),
2854 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), 2894 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
2855 2895
2856/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte 2896/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte
2857/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 2897/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1
@@ -2889,9 +2929,6 @@ static int __init av7110_init(void)
2889 2929
2890static void __exit av7110_exit(void) 2930static void __exit av7110_exit(void)
2891{ 2931{
2892#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
2893 av7110_ir_exit();
2894#endif
2895 saa7146_unregister_extension(&av7110_extension); 2932 saa7146_unregister_extension(&av7110_extension);
2896} 2933}
2897 2934
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
index 508b7739c609..cce00ef293e9 100644
--- a/drivers/media/dvb/ttpci/av7110.h
+++ b/drivers/media/dvb/ttpci/av7110.h
@@ -228,7 +228,10 @@ struct av7110 {
228 struct dvb_video_events video_events; 228 struct dvb_video_events video_events;
229 video_size_t video_size; 229 video_size_t video_size;
230 230
231 u32 ir_config; 231 u32 ir_config;
232 u32 ir_command;
233 void (*ir_handler)(struct av7110 *av7110, u32 ircom);
234 struct tasklet_struct ir_tasklet;
232 235
233 /* firmware stuff */ 236 /* firmware stuff */
234 unsigned char *bin_fw; 237 unsigned char *bin_fw;
@@ -257,12 +260,10 @@ struct av7110 {
257extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 260extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
258 u16 subpid, u16 pcrpid); 261 u16 subpid, u16 pcrpid);
259 262
260extern void av7110_register_irc_handler(void (*func)(u32));
261extern void av7110_unregister_irc_handler(void (*func)(u32));
262extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config); 263extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config);
263 264
264extern int av7110_ir_init (void); 265extern int av7110_ir_init(struct av7110 *av7110);
265extern void av7110_ir_exit (void); 266extern void av7110_ir_exit(struct av7110 *av7110);
266 267
267/* msp3400 i2c subaddresses */ 268/* msp3400 i2c subaddresses */
268#define MSP_WR_DEM 0x10 269#define MSP_WR_DEM 0x10
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index 1220826696c5..7442f56a72ec 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -41,6 +41,8 @@
41#include "av7110.h" 41#include "av7110.h"
42#include "av7110_hw.h" 42#include "av7110_hw.h"
43 43
44#define _NOHANDSHAKE
45
44/**************************************************************************** 46/****************************************************************************
45 * DEBI functions 47 * DEBI functions
46 ****************************************************************************/ 48 ****************************************************************************/
@@ -364,7 +366,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
364 msleep(1); 366 msleep(1);
365 } 367 }
366 368
367 wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); 369 if (FW_VERSION(av7110->arm_app) <= 0x261f)
370 wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2);
368 371
369#ifndef _NOHANDSHAKE 372#ifndef _NOHANDSHAKE
370 start = jiffies; 373 start = jiffies;
@@ -437,7 +440,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
437 440
438 wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); 441 wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2);
439 442
440 wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); 443 if (FW_VERSION(av7110->arm_app) <= 0x261f)
444 wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2);
441 445
442#ifdef COM_DEBUG 446#ifdef COM_DEBUG
443 start = jiffies; 447 start = jiffies;
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
index 665cdb8a3f71..357a3728ec68 100644
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ b/drivers/media/dvb/ttpci/av7110_ir.c
@@ -7,16 +7,16 @@
7#include <asm/bitops.h> 7#include <asm/bitops.h>
8 8
9#include "av7110.h" 9#include "av7110.h"
10#include "av7110_hw.h"
10 11
11#define UP_TIMEOUT (HZ/4) 12#define UP_TIMEOUT (HZ*7/25)
12 13
13/* enable ir debugging by or'ing debug with 16 */ 14/* enable ir debugging by or'ing debug with 16 */
14 15
15static int ir_initialized; 16static int av_cnt;
17static struct av7110 *av_list[4];
16static struct input_dev input_dev; 18static struct input_dev input_dev;
17 19
18static u32 ir_config;
19
20static u16 key_map [256] = { 20static u16 key_map [256] = {
21 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, 21 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7,
22 KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO, 22 KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO,
@@ -53,8 +53,11 @@ static void av7110_emit_keyup(unsigned long data)
53static struct timer_list keyup_timer = { .function = av7110_emit_keyup }; 53static struct timer_list keyup_timer = { .function = av7110_emit_keyup };
54 54
55 55
56static void av7110_emit_key(u32 ircom) 56static void av7110_emit_key(unsigned long parm)
57{ 57{
58 struct av7110 *av7110 = (struct av7110 *) parm;
59 u32 ir_config = av7110->ir_config;
60 u32 ircom = av7110->ir_command;
58 u8 data; 61 u8 data;
59 u8 addr; 62 u8 addr;
60 static u16 old_toggle = 0; 63 static u16 old_toggle = 0;
@@ -62,19 +65,33 @@ static void av7110_emit_key(u32 ircom)
62 u16 keycode; 65 u16 keycode;
63 66
64 /* extract device address and data */ 67 /* extract device address and data */
65 if (ir_config & 0x0001) { 68 switch (ir_config & 0x0003) {
66 /* TODO RCMM: ? bits device address, 8 bits data */ 69 case 0: /* RC5: 5 bits device address, 6 bits data */
70 data = ircom & 0x3f;
71 addr = (ircom >> 6) & 0x1f;
72 break;
73
74 case 1: /* RCMM: 8(?) bits device address, 8(?) bits data */
67 data = ircom & 0xff; 75 data = ircom & 0xff;
68 addr = (ircom >> 8) & 0xff; 76 addr = (ircom >> 8) & 0xff;
69 } else { 77 break;
70 /* RC5: 5 bits device address, 6 bits data */ 78
79 case 2: /* extended RC5: 5 bits device address, 7 bits data */
71 data = ircom & 0x3f; 80 data = ircom & 0x3f;
72 addr = (ircom >> 6) & 0x1f; 81 addr = (ircom >> 6) & 0x1f;
82 /* invert 7th data bit for backward compatibility with RC5 keymaps */
83 if (!(ircom & 0x1000))
84 data |= 0x40;
85 break;
86
87 default:
88 printk("invalid ir_config %x\n", ir_config);
89 return;
73 } 90 }
74 91
75 keycode = key_map[data]; 92 keycode = key_map[data];
76 93
77 dprintk(16, "#########%08x######### addr %i data 0x%02x (keycode %i)\n", 94 dprintk(16, "code %08x -> addr %i data 0x%02x -> keycode %i\n",
78 ircom, addr, data, keycode); 95 ircom, addr, data, keycode);
79 96
80 /* check device address (if selected) */ 97 /* check device address (if selected) */
@@ -87,10 +104,10 @@ static void av7110_emit_key(u32 ircom)
87 return; 104 return;
88 } 105 }
89 106
90 if (ir_config & 0x0001) 107 if ((ir_config & 0x0003) == 1)
91 new_toggle = 0; /* RCMM */ 108 new_toggle = 0; /* RCMM */
92 else 109 else
93 new_toggle = (ircom & 0x800); /* RC5 */ 110 new_toggle = (ircom & 0x800); /* RC5, extended RC5 */
94 111
95 if (timer_pending(&keyup_timer)) { 112 if (timer_pending(&keyup_timer)) {
96 del_timer(&keyup_timer); 113 del_timer(&keyup_timer);
@@ -137,6 +154,8 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer,
137{ 154{
138 char *page; 155 char *page;
139 int size = 4 + 256 * sizeof(u16); 156 int size = 4 + 256 * sizeof(u16);
157 u32 ir_config;
158 int i;
140 159
141 if (count < size) 160 if (count < size)
142 return -EINVAL; 161 return -EINVAL;
@@ -153,60 +172,95 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer,
153 memcpy(&ir_config, page, 4); 172 memcpy(&ir_config, page, 4);
154 memcpy(&key_map, page + 4, 256 * sizeof(u16)); 173 memcpy(&key_map, page + 4, 256 * sizeof(u16));
155 vfree(page); 174 vfree(page);
156 av7110_setup_irc_config(NULL, ir_config); 175 if (FW_VERSION(av_list[0]->arm_app) >= 0x2620 && !(ir_config & 0x0001))
176 ir_config |= 0x0002; /* enable extended RC5 */
177 for (i = 0; i < av_cnt; i++)
178 av7110_setup_irc_config(av_list[i], ir_config);
157 input_register_keys(); 179 input_register_keys();
158 return count; 180 return count;
159} 181}
160 182
161 183
162int __init av7110_ir_init(void) 184int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
163{ 185{
164 static struct proc_dir_entry *e; 186 int ret = 0;
165 187
166 if (ir_initialized) 188 dprintk(4, "%p\n", av7110);
167 return 0; 189 if (av7110) {
190 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config);
191 av7110->ir_config = ir_config;
192 }
193 return ret;
194}
168 195
169 init_timer(&keyup_timer);
170 keyup_timer.data = 0;
171 196
172 input_dev.name = "DVB on-card IR receiver"; 197static void ir_handler(struct av7110 *av7110, u32 ircom)
198{
199 dprintk(4, "ircommand = %08x\n", ircom);
200 av7110->ir_command = ircom;
201 tasklet_schedule(&av7110->ir_tasklet);
202}
173 203
174 /**
175 * enable keys
176 */
177 set_bit(EV_KEY, input_dev.evbit);
178 set_bit(EV_REP, input_dev.evbit);
179 204
180 input_register_keys(); 205int __init av7110_ir_init(struct av7110 *av7110)
206{
207 static struct proc_dir_entry *e;
181 208
182 input_register_device(&input_dev); 209 if (av_cnt >= sizeof av_list/sizeof av_list[0])
183 input_dev.timer.function = input_repeat_key; 210 return -ENOSPC;
184 211
185 av7110_setup_irc_config(NULL, 0x0001); 212 av7110_setup_irc_config(av7110, 0x0001);
186 av7110_register_irc_handler(av7110_emit_key); 213 av_list[av_cnt++] = av7110;
187 214
188 e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); 215 if (av_cnt == 1) {
189 if (e) { 216 init_timer(&keyup_timer);
190 e->write_proc = av7110_ir_write_proc; 217 keyup_timer.data = 0;
191 e->size = 4 + 256 * sizeof(u16); 218
219 input_dev.name = "DVB on-card IR receiver";
220 set_bit(EV_KEY, input_dev.evbit);
221 set_bit(EV_REP, input_dev.evbit);
222 input_register_keys();
223 input_register_device(&input_dev);
224 input_dev.timer.function = input_repeat_key;
225
226 e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL);
227 if (e) {
228 e->write_proc = av7110_ir_write_proc;
229 e->size = 4 + 256 * sizeof(u16);
230 }
192 } 231 }
193 232
194 ir_initialized = 1; 233 tasklet_init(&av7110->ir_tasklet, av7110_emit_key, (unsigned long) av7110);
234 av7110->ir_handler = ir_handler;
235
195 return 0; 236 return 0;
196} 237}
197 238
198 239
199void __exit av7110_ir_exit(void) 240void __exit av7110_ir_exit(struct av7110 *av7110)
200{ 241{
201 if (ir_initialized == 0) 242 int i;
243
244 if (av_cnt == 0)
202 return; 245 return;
203 del_timer_sync(&keyup_timer); 246
204 remove_proc_entry("av7110_ir", NULL); 247 av7110->ir_handler = NULL;
205 av7110_unregister_irc_handler(av7110_emit_key); 248 tasklet_kill(&av7110->ir_tasklet);
206 input_unregister_device(&input_dev); 249 for (i = 0; i < av_cnt; i++)
207 ir_initialized = 0; 250 if (av_list[i] == av7110) {
251 av_list[i] = av_list[av_cnt-1];
252 av_list[av_cnt-1] = NULL;
253 break;
254 }
255
256 if (av_cnt == 1) {
257 del_timer_sync(&keyup_timer);
258 remove_proc_entry("av7110_ir", NULL);
259 input_unregister_device(&input_dev);
260 }
261
262 av_cnt--;
208} 263}
209 264
210//MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>"); 265//MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>");
211//MODULE_LICENSE("GPL"); 266//MODULE_LICENSE("GPL");
212
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index e65fc36e2ce8..6af74f78b3e5 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -70,7 +70,7 @@ static int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val)
70 return 0; 70 return 0;
71} 71}
72 72
73static struct v4l2_input inputs[2] = { 73static struct v4l2_input inputs[4] = {
74 { 74 {
75 .index = 0, 75 .index = 0,
76 .name = "DVB", 76 .name = "DVB",
@@ -87,6 +87,22 @@ static struct v4l2_input inputs[2] = {
87 .tuner = 0, 87 .tuner = 0,
88 .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 88 .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
89 .status = 0, 89 .status = 0,
90 }, {
91 .index = 2,
92 .name = "Video",
93 .type = V4L2_INPUT_TYPE_CAMERA,
94 .audioset = 0,
95 .tuner = 0,
96 .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
97 .status = 0,
98 }, {
99 .index = 3,
100 .name = "Y/C",
101 .type = V4L2_INPUT_TYPE_CAMERA,
102 .audioset = 0,
103 .tuner = 0,
104 .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
105 .status = 0,
90 } 106 }
91}; 107};
92 108
@@ -212,24 +228,44 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh)
212 } 228 }
213 229
214 if (0 != av7110->current_input) { 230 if (0 != av7110->current_input) {
231 dprintk(1, "switching to analog TV:\n");
215 adswitch = 1; 232 adswitch = 1;
216 source = SAA7146_HPS_SOURCE_PORT_B; 233 source = SAA7146_HPS_SOURCE_PORT_B;
217 sync = SAA7146_HPS_SYNC_PORT_B; 234 sync = SAA7146_HPS_SYNC_PORT_B;
218 memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2); 235 memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2);
219 dprintk(1, "switching to analog TV\n");
220 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source
221 msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source
222 msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source
223 msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
224 msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
225 msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
226 236
227 if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { 237 switch (av7110->current_input) {
228 if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) 238 case 1:
229 dprintk(1, "setting band in demodulator failed.\n"); 239 dprintk(1, "switching SAA7113 to Analog Tuner Input.\n");
230 } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { 240 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source
231 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) 241 msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source
232 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) 242 msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source
243 msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
244 msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
245 msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
246
247 if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
248 if (ves1820_writereg(dev, 0x09, 0x0f, 0x60))
249 dprintk(1, "setting band in demodulator failed.\n");
250 } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
251 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD)
252 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF)
253 }
254 if (i2c_writereg(av7110, 0x48, 0x02, 0xd0) != 1)
255 dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
256 break;
257 case 2:
258 dprintk(1, "switching SAA7113 to Video AV CVBS Input.\n");
259 if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1)
260 dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
261 break;
262 case 3:
263 dprintk(1, "switching SAA7113 to Video AV Y/C Input.\n");
264 if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1)
265 dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
266 break;
267 default:
268 dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input.\n");
233 } 269 }
234 } else { 270 } else {
235 adswitch = 0; 271 adswitch = 0;
@@ -300,7 +336,6 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
300 // FIXME: standard / stereo detection is still broken 336 // FIXME: standard / stereo detection is still broken
301 msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det); 337 msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det);
302 dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det); 338 dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det);
303
304 msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det); 339 msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det);
305 dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det); 340 dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det);
306 stereo = (s8)(stereo_det >> 8); 341 stereo = (s8)(stereo_det >> 8);
@@ -310,7 +345,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
310 t->audmode = V4L2_TUNER_MODE_STEREO; 345 t->audmode = V4L2_TUNER_MODE_STEREO;
311 } 346 }
312 else if (stereo < -0x10) { 347 else if (stereo < -0x10) {
313 /* bilingual*/ 348 /* bilingual */
314 t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 349 t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
315 t->audmode = V4L2_TUNER_MODE_LANG1; 350 t->audmode = V4L2_TUNER_MODE_LANG1;
316 } 351 }
@@ -344,7 +379,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
344 fm_matrix = 0x3000; // mono 379 fm_matrix = 0x3000; // mono
345 src = 0x0010; 380 src = 0x0010;
346 break; 381 break;
347 default: /* case V4L2_TUNER_MODE_MONO: {*/ 382 default: /* case V4L2_TUNER_MODE_MONO: */
348 dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n"); 383 dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n");
349 fm_matrix = 0x3000; // mono 384 fm_matrix = 0x3000; // mono
350 src = 0x0030; 385 src = 0x0030;
@@ -406,7 +441,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
406 dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index); 441 dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index);
407 442
408 if (av7110->analog_tuner_flags) { 443 if (av7110->analog_tuner_flags) {
409 if (i->index < 0 || i->index >= 2) 444 if (i->index < 0 || i->index >= 4)
410 return -EINVAL; 445 return -EINVAL;
411 } else { 446 } else {
412 if (i->index != 0) 447 if (i->index != 0)
@@ -433,10 +468,9 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
433 if (!av7110->analog_tuner_flags) 468 if (!av7110->analog_tuner_flags)
434 return 0; 469 return 0;
435 470
436 if (input < 0 || input >= 2) 471 if (input < 0 || input >= 4)
437 return -EINVAL; 472 return -EINVAL;
438 473
439 /* FIXME: switch inputs here */
440 av7110->current_input = input; 474 av7110->current_input = input;
441 return av7110_dvb_c_switch(fh); 475 return av7110_dvb_c_switch(fh);
442 } 476 }
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 9746d2bb916f..7692cd23f839 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -192,7 +192,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
192{ 192{
193 struct budget_av *budget_av = (struct budget_av *) ca->data; 193 struct budget_av *budget_av = (struct budget_av *) ca->data;
194 struct saa7146_dev *saa = budget_av->budget.dev; 194 struct saa7146_dev *saa = budget_av->budget.dev;
195 int timeout = 50; // 5 seconds (4.4.6 Ready) 195 int timeout = 500; // 5 seconds (4.4.6 Ready)
196 196
197 if (slot != 0) 197 if (slot != 0)
198 return -EINVAL; 198 return -EINVAL;
@@ -217,7 +217,6 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
217 { 217 {
218 printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); 218 printk(KERN_ERR "budget-av: cam reset failed (timeout).\n");
219 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ 219 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
220 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
221 return -ETIMEDOUT; 220 return -ETIMEDOUT;
222 } 221 }
223 222
@@ -276,7 +275,6 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
276 { 275 {
277 printk(KERN_INFO "budget-av: cam ejected\n"); 276 printk(KERN_INFO "budget-av: cam ejected\n");
278 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ 277 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
279 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
280 budget_av->slot_status = 0; 278 budget_av->slot_status = 0;
281 } 279 }
282 } 280 }
@@ -453,9 +451,9 @@ static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 sra
453} 451}
454 452
455static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, 453static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe,
454 struct i2c_adapter *i2c,
456 struct dvb_frontend_parameters *params) 455 struct dvb_frontend_parameters *params)
457{ 456{
458 struct budget_av *budget_av = (struct budget_av *) fe->dvb->priv;
459 u32 div; 457 u32 div;
460 u8 buf[4]; 458 u8 buf[4];
461 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; 459 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
@@ -481,7 +479,7 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe,
481 else if (params->frequency < 2150000) 479 else if (params->frequency < 2150000)
482 buf[3] |= 0xC0; 480 buf[3] |= 0xC0;
483 481
484 if (i2c_transfer(&budget_av->budget.i2c_adap, &msg, 1) != 1) 482 if (i2c_transfer(i2c, &msg, 1) != 1)
485 return -EIO; 483 return -EIO;
486 return 0; 484 return 0;
487} 485}
@@ -745,6 +743,7 @@ static void frontend_init(struct budget_av *budget_av)
745 case SUBID_DVBC_KNC1_PLUS: 743 case SUBID_DVBC_KNC1_PLUS:
746 case SUBID_DVBT_KNC1_PLUS: 744 case SUBID_DVBT_KNC1_PLUS:
747 // Enable / PowerON Frontend 745 // Enable / PowerON Frontend
746 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
748 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI); 747 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
749 break; 748 break;
750 } 749 }
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index a1267054bc01..2980db3ef22f 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -40,6 +40,7 @@
40 40
41#include "dvb_ca_en50221.h" 41#include "dvb_ca_en50221.h"
42#include "stv0299.h" 42#include "stv0299.h"
43#include "stv0297.h"
43#include "tda1004x.h" 44#include "tda1004x.h"
44 45
45#define DEBIADDR_IR 0x1234 46#define DEBIADDR_IR 0x1234
@@ -548,9 +549,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ra
548 return 0; 549 return 0;
549} 550}
550 551
551static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 552static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params)
552{ 553{
553 struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
554 u8 buf[4]; 554 u8 buf[4];
555 u32 div; 555 u32 div;
556 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; 556 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
@@ -567,7 +567,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_param
567 if (params->frequency > 1530000) 567 if (params->frequency > 1530000)
568 buf[3] = 0xc0; 568 buf[3] = 0xc0;
569 569
570 if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) 570 if (i2c_transfer(i2c, &msg, 1) != 1)
571 return -EIO; 571 return -EIO;
572 return 0; 572 return 0;
573} 573}
@@ -669,9 +669,9 @@ static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate,
669} 669}
670 670
671static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, 671static int philips_su1278_tt_pll_set(struct dvb_frontend *fe,
672 struct i2c_adapter *i2c,
672 struct dvb_frontend_parameters *params) 673 struct dvb_frontend_parameters *params)
673{ 674{
674 struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
675 u32 div; 675 u32 div;
676 u8 buf[4]; 676 u8 buf[4];
677 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; 677 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
@@ -697,7 +697,7 @@ static int philips_su1278_tt_pll_set(struct dvb_frontend *fe,
697 else if (params->frequency < 2150000) 697 else if (params->frequency < 2150000)
698 buf[3] |= 0xC0; 698 buf[3] |= 0xC0;
699 699
700 if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) 700 if (i2c_transfer(i2c, &msg, 1) != 1)
701 return -EIO; 701 return -EIO;
702 return 0; 702 return 0;
703} 703}
@@ -848,6 +848,180 @@ static struct tda1004x_config philips_tdm1316l_config = {
848 .request_firmware = philips_tdm1316l_request_firmware, 848 .request_firmware = philips_tdm1316l_request_firmware,
849}; 849};
850 850
851static int dvbc_philips_tdm1316l_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
852{
853 struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
854 u8 tuner_buf[5];
855 struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,
856 .flags = 0,
857 .buf = tuner_buf,
858 .len = sizeof(tuner_buf) };
859 int tuner_frequency = 0;
860 u8 band, cp, filter;
861
862 // determine charge pump
863 tuner_frequency = params->frequency + 36125000;
864 if (tuner_frequency < 87000000)
865 return -EINVAL;
866 else if (tuner_frequency < 130000000) {
867 cp = 3;
868 band = 1;
869 } else if (tuner_frequency < 160000000) {
870 cp = 5;
871 band = 1;
872 } else if (tuner_frequency < 200000000) {
873 cp = 6;
874 band = 1;
875 } else if (tuner_frequency < 290000000) {
876 cp = 3;
877 band = 2;
878 } else if (tuner_frequency < 420000000) {
879 cp = 5;
880 band = 2;
881 } else if (tuner_frequency < 480000000) {
882 cp = 6;
883 band = 2;
884 } else if (tuner_frequency < 620000000) {
885 cp = 3;
886 band = 4;
887 } else if (tuner_frequency < 830000000) {
888 cp = 5;
889 band = 4;
890 } else if (tuner_frequency < 895000000) {
891 cp = 7;
892 band = 4;
893 } else
894 return -EINVAL;
895
896 // assume PLL filter should always be 8MHz for the moment.
897 filter = 1;
898
899 // calculate divisor
900 tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500;
901
902 // setup tuner buffer
903 tuner_buf[0] = tuner_frequency >> 8;
904 tuner_buf[1] = tuner_frequency & 0xff;
905 tuner_buf[2] = 0xc8;
906 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
907 tuner_buf[4] = 0x80;
908
909 stv0297_enable_plli2c(fe);
910 if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
911 return -EIO;
912
913 msleep(50);
914
915 stv0297_enable_plli2c(fe);
916 if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
917 return -EIO;
918
919 msleep(1);
920
921 return 0;
922}
923
924static u8 dvbc_philips_tdm1316l_inittab[] = {
925 0x80, 0x01,
926 0x80, 0x00,
927 0x81, 0x01,
928 0x81, 0x00,
929 0x00, 0x09,
930 0x01, 0x69,
931 0x03, 0x00,
932 0x04, 0x00,
933 0x07, 0x00,
934 0x08, 0x00,
935 0x20, 0x00,
936 0x21, 0x40,
937 0x22, 0x00,
938 0x23, 0x00,
939 0x24, 0x40,
940 0x25, 0x88,
941 0x30, 0xff,
942 0x31, 0x00,
943 0x32, 0xff,
944 0x33, 0x00,
945 0x34, 0x50,
946 0x35, 0x7f,
947 0x36, 0x00,
948 0x37, 0x20,
949 0x38, 0x00,
950 0x40, 0x1c,
951 0x41, 0xff,
952 0x42, 0x29,
953 0x43, 0x20,
954 0x44, 0xff,
955 0x45, 0x00,
956 0x46, 0x00,
957 0x49, 0x04,
958 0x4a, 0x00,
959 0x4b, 0x7b,
960 0x52, 0x30,
961 0x55, 0xae,
962 0x56, 0x47,
963 0x57, 0xe1,
964 0x58, 0x3a,
965 0x5a, 0x1e,
966 0x5b, 0x34,
967 0x60, 0x00,
968 0x63, 0x00,
969 0x64, 0x00,
970 0x65, 0x00,
971 0x66, 0x00,
972 0x67, 0x00,
973 0x68, 0x00,
974 0x69, 0x00,
975 0x6a, 0x02,
976 0x6b, 0x00,
977 0x70, 0xff,
978 0x71, 0x00,
979 0x72, 0x00,
980 0x73, 0x00,
981 0x74, 0x0c,
982 0x80, 0x00,
983 0x81, 0x00,
984 0x82, 0x00,
985 0x83, 0x00,
986 0x84, 0x04,
987 0x85, 0x80,
988 0x86, 0x24,
989 0x87, 0x78,
990 0x88, 0x10,
991 0x89, 0x00,
992 0x90, 0x01,
993 0x91, 0x01,
994 0xa0, 0x04,
995 0xa1, 0x00,
996 0xa2, 0x00,
997 0xb0, 0x91,
998 0xb1, 0x0b,
999 0xc0, 0x53,
1000 0xc1, 0x70,
1001 0xc2, 0x12,
1002 0xd0, 0x00,
1003 0xd1, 0x00,
1004 0xd2, 0x00,
1005 0xd3, 0x00,
1006 0xd4, 0x00,
1007 0xd5, 0x00,
1008 0xde, 0x00,
1009 0xdf, 0x00,
1010 0x61, 0x38,
1011 0x62, 0x0a,
1012 0x53, 0x13,
1013 0x59, 0x08,
1014 0xff, 0xff,
1015};
1016
1017static struct stv0297_config dvbc_philips_tdm1316l_config = {
1018 .demod_address = 0x1c,
1019 .inittab = dvbc_philips_tdm1316l_inittab,
1020 .invert = 0,
1021 .pll_set = dvbc_philips_tdm1316l_pll_set,
1022};
1023
1024
851 1025
852 1026
853static void frontend_init(struct budget_ci *budget_ci) 1027static void frontend_init(struct budget_ci *budget_ci)
@@ -869,6 +1043,15 @@ static void frontend_init(struct budget_ci *budget_ci)
869 } 1043 }
870 break; 1044 break;
871 1045
1046 case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt))
1047 budget_ci->tuner_pll_address = 0x61;
1048 budget_ci->budget.dvb_frontend =
1049 stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1050 if (budget_ci->budget.dvb_frontend) {
1051 break;
1052 }
1053 break;
1054
872 case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) 1055 case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
873 budget_ci->tuner_pll_address = 0x63; 1056 budget_ci->tuner_pll_address = 0x63;
874 budget_ci->budget.dvb_frontend = 1057 budget_ci->budget.dvb_frontend =
@@ -878,7 +1061,7 @@ static void frontend_init(struct budget_ci *budget_ci)
878 } 1061 }
879 break; 1062 break;
880 1063
881 case 0x1012: // Hauppauge/TT Nova-T CI budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) 1064 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
882 budget_ci->tuner_pll_address = 0x60; 1065 budget_ci->tuner_pll_address = 0x60;
883 budget_ci->budget.dvb_frontend = 1066 budget_ci->budget.dvb_frontend =
884 tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1067 tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
@@ -966,10 +1149,12 @@ static struct saa7146_extension budget_extension;
966MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC); 1149MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC);
967MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); 1150MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
968MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT); 1151MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT);
1152MAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT);
969 1153
970static struct pci_device_id pci_tbl[] = { 1154static struct pci_device_id pci_tbl[] = {
971 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), 1155 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c),
972 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), 1156 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f),
1157 MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010),
973 MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011), 1158 MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011),
974 MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012), 1159 MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012),
975 { 1160 {
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index 8142e26b47f5..b1f21ef0e3b3 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -353,9 +353,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra
353 return 0; 353 return 0;
354} 354}
355 355
356static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 356static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
357{ 357{
358 struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
359 u8 data[4]; 358 u8 data[4];
360 u32 div; 359 u32 div;
361 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; 360 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
@@ -370,7 +369,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
370 369
371 if (params->frequency > 1530000) data[3] = 0xc0; 370 if (params->frequency > 1530000) data[3] = 0xc0;
372 371
373 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; 372 if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO;
374 return 0; 373 return 0;
375} 374}
376 375
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 9961917e8a7f..43d6c8268642 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -332,9 +332,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra
332 return 0; 332 return 0;
333} 333}
334 334
335static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 335static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
336{ 336{
337 struct budget* budget = (struct budget*) fe->dvb->priv;
338 u8 data[4]; 337 u8 data[4];
339 u32 div; 338 u32 div;
340 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; 339 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
@@ -349,7 +348,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
349 348
350 if (params->frequency > 1530000) data[3] = 0xc0; 349 if (params->frequency > 1530000) data[3] = 0xc0;
351 350
352 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; 351 if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO;
353 return 0; 352 return 0;
354} 353}
355 354
@@ -481,6 +480,7 @@ static int s5h1420_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete
481 480
482static struct s5h1420_config s5h1420_config = { 481static struct s5h1420_config s5h1420_config = {
483 .demod_address = 0x53, 482 .demod_address = 0x53,
483 .invert = 1,
484 .pll_set = s5h1420_pll_set, 484 .pll_set = s5h1420_pll_set,
485}; 485};
486 486