aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@brturbo.com.br>2005-07-12 16:58:44 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-12 19:01:04 -0400
commit41ef7c1ed48cb273c7b7a9ffd48a262a22f84483 (patch)
treec3a2772ae4eb3ea34c5023921095b78d2acd352e /drivers/media
parentfa9846a8c5965636fbade8655ae0ce1f9a655bd4 (diff)
[PATCH] v4l: CX88 Update
- Removed unused structures. - Removed BTTV version check. - Some debug structs moved to their own .c file and converted to static - Comment changed to express better when attach_inform is running - set_freq removed from set_mode at tuner-core.c. - I2C cleanups and converged to a basic reference structure. - Rename tuner structures fields. - It calls VIDIOC_G_FREQUENCY to get tuner freq from tuner. - added missing contrast offset value, set to 0. - Let Kconfig decide whether to include frontend-specific code. Signed-Off-By: Nickolay V. Shmyrev <nshmyrev@yandex.ru> Signed-off-by: Michael Krufky <mkrufky@m1k.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c5
-rw-r--r--drivers/media/video/cx88/cx88-core.c48
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c36
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c31
-rw-r--r--drivers/media/video/cx88/cx88-input.c448
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c26
-rw-r--r--drivers/media/video/cx88/cx88-reg.h11
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c76
-rw-r--r--drivers/media/video/cx88/cx88-video.c303
-rw-r--r--drivers/media/video/cx88/cx88.h12
10 files changed, 296 insertions, 700 deletions
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 91f8afeded88..4f39688f780a 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -690,11 +690,9 @@ static void blackbird_codec_settings(struct cx8802_dev *dev)
690 int bitrate_mode = 1; 690 int bitrate_mode = 1;
691 int bitrate = 7500000; 691 int bitrate = 7500000;
692 int bitrate_peak = 7500000; 692 int bitrate_peak = 7500000;
693#if 1
694 bitrate_mode = BLACKBIRD_VIDEO_CBR; 693 bitrate_mode = BLACKBIRD_VIDEO_CBR;
695 bitrate = 4000*1024; 694 bitrate = 4000*1024;
696 bitrate_peak = 4000*1024; 695 bitrate_peak = 4000*1024;
697#endif
698 696
699 /* assign stream type */ 697 /* assign stream type */
700 blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM); 698 blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM);
@@ -810,9 +808,6 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
810 cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */ 808 cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */
811 cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */ 809 cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */
812 810
813#if 0 /* FIXME */
814 set_scale(dev, 720, 480, V4L2_FIELD_INTERLACED);
815#endif
816 blackbird_codec_settings(dev); 811 blackbird_codec_settings(dev);
817 msleep(1); 812 msleep(1);
818 813
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 96cb0ff33bbd..5e868f5cd0c0 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-core.c,v 1.31 2005/06/22 22:58:04 mchehab Exp $ 2 * $Id: cx88-core.c,v 1.33 2005/07/07 14:17:47 mchehab Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * driver core 5 * driver core
@@ -470,25 +470,6 @@ int cx88_risc_decode(u32 risc)
470 return incr[risc >> 28] ? incr[risc >> 28] : 1; 470 return incr[risc >> 28] ? incr[risc >> 28] : 1;
471} 471}
472 472
473#if 0 /* currently unused, but useful for debugging */
474void cx88_risc_disasm(struct cx88_core *core,
475 struct btcx_riscmem *risc)
476{
477 unsigned int i,j,n;
478
479 printk("%s: risc disasm: %p [dma=0x%08lx]\n",
480 core->name, risc->cpu, (unsigned long)risc->dma);
481 for (i = 0; i < (risc->size >> 2); i += n) {
482 printk("%s: %04d: ", core->name, i);
483 n = cx88_risc_decode(risc->cpu[i]);
484 for (j = 1; j < n; j++)
485 printk("%s: %04d: 0x%08x [ arg #%d ]\n",
486 core->name, i+j, risc->cpu[i+j], j);
487 if (risc->cpu[i] == RISC_JUMP)
488 break;
489 }
490}
491#endif
492 473
493void cx88_sram_channel_dump(struct cx88_core *core, 474void cx88_sram_channel_dump(struct cx88_core *core,
494 struct sram_channel *ch) 475 struct sram_channel *ch)
@@ -545,30 +526,12 @@ void cx88_sram_channel_dump(struct cx88_core *core,
545 core->name,cx_read(ch->cnt2_reg)); 526 core->name,cx_read(ch->cnt2_reg));
546} 527}
547 528
548/* Used only on cx88-core */
549static char *cx88_pci_irqs[32] = { 529static char *cx88_pci_irqs[32] = {
550 "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1", 530 "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
551 "src_dma", "dst_dma", "risc_rd_err", "risc_wr_err", 531 "src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
552 "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err", 532 "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
553 "i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1" 533 "i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1"
554}; 534};
555/* Used only on cx88-video */
556char *cx88_vid_irqs[32] = {
557 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
558 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
559 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
560 "y_sync", "u_sync", "v_sync", "vbi_sync",
561 "opc_err", "par_err", "rip_err", "pci_abort",
562};
563/* Used only on cx88-mpeg */
564char *cx88_mpeg_irqs[32] = {
565 "ts_risci1", NULL, NULL, NULL,
566 "ts_risci2", NULL, NULL, NULL,
567 "ts_oflow", NULL, NULL, NULL,
568 "ts_sync", NULL, NULL, NULL,
569 "opc_err", "par_err", "rip_err", "pci_abort",
570 "ts_err?",
571};
572 535
573void cx88_print_irqbits(char *name, char *tag, char **strings, 536void cx88_print_irqbits(char *name, char *tag, char **strings,
574 u32 bits, u32 mask) 537 u32 bits, u32 mask)
@@ -618,16 +581,11 @@ void cx88_wakeup(struct cx88_core *core,
618 break; 581 break;
619 buf = list_entry(q->active.next, 582 buf = list_entry(q->active.next,
620 struct cx88_buffer, vb.queue); 583 struct cx88_buffer, vb.queue);
621#if 0
622 if (buf->count > count)
623 break;
624#else
625 /* count comes from the hw and is is 16bit wide -- 584 /* count comes from the hw and is is 16bit wide --
626 * this trick handles wrap-arounds correctly for 585 * this trick handles wrap-arounds correctly for
627 * up to 32767 buffers in flight... */ 586 * up to 32767 buffers in flight... */
628 if ((s16) (count - buf->count) < 0) 587 if ((s16) (count - buf->count) < 0)
629 break; 588 break;
630#endif
631 do_gettimeofday(&buf->vb.ts); 589 do_gettimeofday(&buf->vb.ts);
632 dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i, 590 dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i,
633 count, buf->count); 591 count, buf->count);
@@ -955,12 +913,10 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
955 norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); 913 norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
956 cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat); 914 cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat);
957 915
958#if 1
959 // FIXME: as-is from DScaler 916 // FIXME: as-is from DScaler
960 dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", 917 dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
961 norm->cxoformat, cx_read(MO_OUTPUT_FORMAT)); 918 norm->cxoformat, cx_read(MO_OUTPUT_FORMAT));
962 cx_write(MO_OUTPUT_FORMAT, norm->cxoformat); 919 cx_write(MO_OUTPUT_FORMAT, norm->cxoformat);
963#endif
964 920
965 // MO_SCONV_REG = adc clock / video dec clock * 2^17 921 // MO_SCONV_REG = adc clock / video dec clock * 2^17
966 tmp64 = adc_clock * (u64)(1 << 17); 922 tmp64 = adc_clock * (u64)(1 << 17);
@@ -1219,8 +1175,6 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1219/* ------------------------------------------------------------------ */ 1175/* ------------------------------------------------------------------ */
1220 1176
1221EXPORT_SYMBOL(cx88_print_ioctl); 1177EXPORT_SYMBOL(cx88_print_ioctl);
1222EXPORT_SYMBOL(cx88_vid_irqs);
1223EXPORT_SYMBOL(cx88_mpeg_irqs);
1224EXPORT_SYMBOL(cx88_print_irqbits); 1178EXPORT_SYMBOL(cx88_print_irqbits);
1225 1179
1226EXPORT_SYMBOL(cx88_core_irq); 1180EXPORT_SYMBOL(cx88_core_irq);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 690477a67917..5544e1d6a344 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-dvb.c,v 1.39 2005/07/02 20:00:46 mkrufky Exp $ 2 * $Id: cx88-dvb.c,v 1.41 2005/07/04 19:35:05 mkrufky Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * MPEG Transport Stream (DVB) routines 5 * MPEG Transport Stream (DVB) routines
@@ -30,22 +30,20 @@
30#include <linux/file.h> 30#include <linux/file.h>
31#include <linux/suspend.h> 31#include <linux/suspend.h>
32 32
33/* these three frontends need merging via linuxtv cvs ... */
34#define HAVE_CX22702 1
35#define HAVE_OR51132 1
36#define HAVE_LGDT3302 1
37
38#include "cx88.h" 33#include "cx88.h"
39#include "dvb-pll.h" 34#include "dvb-pll.h"
40#include "mt352.h" 35
41#include "mt352_priv.h" 36#if CONFIG_DVB_MT352
42#if HAVE_CX22702 37# include "mt352.h"
38# include "mt352_priv.h"
39#endif
40#if CONFIG_DVB_CX22702
43# include "cx22702.h" 41# include "cx22702.h"
44#endif 42#endif
45#if HAVE_OR51132 43#if CONFIG_DVB_OR51132
46# include "or51132.h" 44# include "or51132.h"
47#endif 45#endif
48#if HAVE_LGDT3302 46#if CONFIG_DVB_LGDT3302
49# include "lgdt3302.h" 47# include "lgdt3302.h"
50#endif 48#endif
51 49
@@ -104,6 +102,7 @@ static struct videobuf_queue_ops dvb_qops = {
104 102
105/* ------------------------------------------------------------------ */ 103/* ------------------------------------------------------------------ */
106 104
105#if CONFIG_DVB_MT352
107static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) 106static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
108{ 107{
109 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 }; 108 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
@@ -171,8 +170,9 @@ static struct mt352_config dntv_live_dvbt_config = {
171 .demod_init = dntv_live_dvbt_demod_init, 170 .demod_init = dntv_live_dvbt_demod_init,
172 .pll_set = mt352_pll_set, 171 .pll_set = mt352_pll_set,
173}; 172};
173#endif
174 174
175#if HAVE_CX22702 175#if CONFIG_DVB_CX22702
176static struct cx22702_config connexant_refboard_config = { 176static struct cx22702_config connexant_refboard_config = {
177 .demod_address = 0x43, 177 .demod_address = 0x43,
178 .pll_address = 0x60, 178 .pll_address = 0x60,
@@ -186,7 +186,7 @@ static struct cx22702_config hauppauge_novat_config = {
186}; 186};
187#endif 187#endif
188 188
189#if HAVE_OR51132 189#if CONFIG_DVB_OR51132
190static int or51132_set_ts_param(struct dvb_frontend* fe, 190static int or51132_set_ts_param(struct dvb_frontend* fe,
191 int is_punctured) 191 int is_punctured)
192{ 192{
@@ -203,7 +203,7 @@ static struct or51132_config pchdtv_hd3000 = {
203}; 203};
204#endif 204#endif
205 205
206#if HAVE_LGDT3302 206#if CONFIG_DVB_LGDT3302
207static int lgdt3302_set_ts_param(struct dvb_frontend* fe, int is_punctured) 207static int lgdt3302_set_ts_param(struct dvb_frontend* fe, int is_punctured)
208{ 208{
209 struct cx8802_dev *dev= fe->dvb->priv; 209 struct cx8802_dev *dev= fe->dvb->priv;
@@ -237,7 +237,7 @@ static int dvb_register(struct cx8802_dev *dev)
237 237
238 /* init frontend */ 238 /* init frontend */
239 switch (dev->core->board) { 239 switch (dev->core->board) {
240#if HAVE_CX22702 240#if CONFIG_DVB_CX22702
241 case CX88_BOARD_HAUPPAUGE_DVB_T1: 241 case CX88_BOARD_HAUPPAUGE_DVB_T1:
242 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config, 242 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config,
243 &dev->core->i2c_adap); 243 &dev->core->i2c_adap);
@@ -248,6 +248,7 @@ static int dvb_register(struct cx8802_dev *dev)
248 &dev->core->i2c_adap); 248 &dev->core->i2c_adap);
249 break; 249 break;
250#endif 250#endif
251#if CONFIG_DVB_MT352
251 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 252 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
252 dev->core->pll_addr = 0x61; 253 dev->core->pll_addr = 0x61;
253 dev->core->pll_desc = &dvb_pll_lg_z201; 254 dev->core->pll_desc = &dvb_pll_lg_z201;
@@ -268,13 +269,14 @@ static int dvb_register(struct cx8802_dev *dev)
268 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config, 269 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
269 &dev->core->i2c_adap); 270 &dev->core->i2c_adap);
270 break; 271 break;
271#if HAVE_OR51132 272#endif
273#if CONFIG_DVB_OR51132
272 case CX88_BOARD_PCHDTV_HD3000: 274 case CX88_BOARD_PCHDTV_HD3000:
273 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000, 275 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
274 &dev->core->i2c_adap); 276 &dev->core->i2c_adap);
275 break; 277 break;
276#endif 278#endif
277#if HAVE_LGDT3302 279#if CONFIG_DVB_LGDT3302
278 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: 280 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
279 dev->ts_gen_cntrl = 0x08; 281 dev->ts_gen_cntrl = 0x08;
280 { 282 {
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index b5342234b305..8403c4e95050 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: cx88-i2c.c,v 1.24 2005/06/17 18:46:23 mkrufky Exp $ 2 $Id: cx88-i2c.c,v 1.28 2005/07/05 17:37:35 nsh Exp $
3 3
4 cx88-i2c.c -- all the i2c code is here 4 cx88-i2c.c -- all the i2c code is here
5 5
@@ -91,25 +91,32 @@ static int cx8800_bit_getsda(void *data)
91 91
92static int attach_inform(struct i2c_client *client) 92static int attach_inform(struct i2c_client *client)
93{ 93{
94 struct tuner_addr tun_addr; 94 struct tuner_setup tun_setup;
95 struct cx88_core *core = i2c_get_adapdata(client->adapter); 95 struct cx88_core *core = i2c_get_adapdata(client->adapter);
96 96
97 dprintk(1, "i2c attach [addr=0x%x,client=%s]\n", 97 dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
98 client->addr, i2c_clientname(client)); 98 client->driver->name,client->addr,i2c_clientname(client));
99 if (!client->driver->command) 99 if (!client->driver->command)
100 return 0; 100 return 0;
101 101
102 if (core->radio_type != UNSET) { 102 if (core->radio_type != UNSET) {
103 tun_addr.v4l2_tuner = V4L2_TUNER_RADIO; 103 if ((core->radio_addr==ADDR_UNSET)||(core->radio_addr==client->addr)) {
104 tun_addr.type = core->radio_type; 104 tun_setup.mode_mask = T_RADIO;
105 tun_addr.addr = core->radio_addr; 105 tun_setup.type = core->radio_type;
106 client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr); 106 tun_setup.addr = core->radio_addr;
107
108 client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup);
109 }
107 } 110 }
108 if (core->tuner_type != UNSET) { 111 if (core->tuner_type != UNSET) {
109 tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV; 112 if ((core->tuner_addr==ADDR_UNSET)||(core->tuner_addr==client->addr)) {
110 tun_addr.type = core->tuner_type; 113
111 tun_addr.addr = core->tuner_addr; 114 tun_setup.mode_mask = T_ANALOG_TV;
112 client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr); 115 tun_setup.type = core->tuner_type;
116 tun_setup.addr = core->tuner_addr;
117
118 client->driver->command (client,TUNER_SET_TYPE_ADDR, &tun_setup);
119 }
113 } 120 }
114 121
115 if (core->tda9887_conf) 122 if (core->tda9887_conf)
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index bdc26e75ab5f..214887798192 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-input.c,v 1.13 2005/06/13 16:07:46 nsh Exp $ 2 * $Id: cx88-input.c,v 1.15 2005/07/07 13:58:38 mchehab Exp $
3 * 3 *
4 * Device driver for GPIO attached remote control interfaces 4 * Device driver for GPIO attached remote control interfaces
5 * on Conexant 2388x based TV/DVB cards. 5 * on Conexant 2388x based TV/DVB cards.
@@ -38,199 +38,206 @@
38 38
39/* DigitalNow DNTV Live DVB-T Remote */ 39/* DigitalNow DNTV Live DVB-T Remote */
40static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = { 40static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = {
41 [ 0x00 ] = KEY_ESC, // 'go up a level?' 41 [0x00] = KEY_ESC, /* 'go up a level?' */
42 [ 0x01 ] = KEY_KP1, // '1' 42 /* Keys 0 to 9 */
43 [ 0x02 ] = KEY_KP2, // '2' 43 [0x0a] = KEY_KP0,
44 [ 0x03 ] = KEY_KP3, // '3' 44 [0x01] = KEY_KP1,
45 [ 0x04 ] = KEY_KP4, // '4' 45 [0x02] = KEY_KP2,
46 [ 0x05 ] = KEY_KP5, // '5' 46 [0x03] = KEY_KP3,
47 [ 0x06 ] = KEY_KP6, // '6' 47 [0x04] = KEY_KP4,
48 [ 0x07 ] = KEY_KP7, // '7' 48 [0x05] = KEY_KP5,
49 [ 0x08 ] = KEY_KP8, // '8' 49 [0x06] = KEY_KP6,
50 [ 0x09 ] = KEY_KP9, // '9' 50 [0x07] = KEY_KP7,
51 [ 0x0a ] = KEY_KP0, // '0' 51 [0x08] = KEY_KP8,
52 [ 0x0b ] = KEY_TUNER, // 'tv/fm' 52 [0x09] = KEY_KP9,
53 [ 0x0c ] = KEY_SEARCH, // 'scan' 53
54 [ 0x0d ] = KEY_STOP, // 'stop' 54 [0x0b] = KEY_TUNER, /* tv/fm */
55 [ 0x0e ] = KEY_PAUSE, // 'pause' 55 [0x0c] = KEY_SEARCH, /* scan */
56 [ 0x0f ] = KEY_LIST, // 'source' 56 [0x0d] = KEY_STOP,
57 57 [0x0e] = KEY_PAUSE,
58 [ 0x10 ] = KEY_MUTE, // 'mute' 58 [0x0f] = KEY_LIST, /* source */
59 [ 0x11 ] = KEY_REWIND, // 'backward <<' 59
60 [ 0x12 ] = KEY_POWER, // 'power' 60 [0x10] = KEY_MUTE,
61 [ 0x13 ] = KEY_S, // 'snap' 61 [0x11] = KEY_REWIND, /* backward << */
62 [ 0x14 ] = KEY_AUDIO, // 'stereo' 62 [0x12] = KEY_POWER,
63 [ 0x15 ] = KEY_CLEAR, // 'reset' 63 [0x13] = KEY_S, /* snap */
64 [ 0x16 ] = KEY_PLAY, // 'play' 64 [0x14] = KEY_AUDIO, /* stereo */
65 [ 0x17 ] = KEY_ENTER, // 'enter' 65 [0x15] = KEY_CLEAR, /* reset */
66 [ 0x18 ] = KEY_ZOOM, // 'full screen' 66 [0x16] = KEY_PLAY,
67 [ 0x19 ] = KEY_FASTFORWARD, // 'forward >>' 67 [0x17] = KEY_ENTER,
68 [ 0x1a ] = KEY_CHANNELUP, // 'channel +' 68 [0x18] = KEY_ZOOM, /* full screen */
69 [ 0x1b ] = KEY_VOLUMEUP, // 'volume +' 69 [0x19] = KEY_FASTFORWARD, /* forward >> */
70 [ 0x1c ] = KEY_INFO, // 'preview' 70 [0x1a] = KEY_CHANNELUP,
71 [ 0x1d ] = KEY_RECORD, // 'record' 71 [0x1b] = KEY_VOLUMEUP,
72 [ 0x1e ] = KEY_CHANNELDOWN, // 'channel -' 72 [0x1c] = KEY_INFO, /* preview */
73 [ 0x1f ] = KEY_VOLUMEDOWN, // 'volume -' 73 [0x1d] = KEY_RECORD, /* record */
74 [0x1e] = KEY_CHANNELDOWN,
75 [0x1f] = KEY_VOLUMEDOWN,
74}; 76};
75 77
76/* ---------------------------------------------------------------------- */ 78/* ---------------------------------------------------------------------- */
77 79
78/* IO-DATA BCTV7E Remote */ 80/* IO-DATA BCTV7E Remote */
79static IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = { 81static IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = {
80 [ 0x40 ] = KEY_TV, // TV 82 [0x40] = KEY_TV,
81 [ 0x20 ] = KEY_RADIO, // FM 83 [0x20] = KEY_RADIO, /* FM */
82 [ 0x60 ] = KEY_EPG, // EPG 84 [0x60] = KEY_EPG,
83 [ 0x00 ] = KEY_POWER, // power 85 [0x00] = KEY_POWER,
84 86
85 [ 0x50 ] = KEY_KP1, // 1 87 /* Keys 0 to 9 */
86 [ 0x30 ] = KEY_KP2, // 2 88 [0x44] = KEY_KP0, /* 10 */
87 [ 0x70 ] = KEY_KP3, // 3 89 [0x50] = KEY_KP1,
88 [ 0x10 ] = KEY_L, // Live 90 [0x30] = KEY_KP2,
89 91 [0x70] = KEY_KP3,
90 [ 0x48 ] = KEY_KP4, // 4 92 [0x48] = KEY_KP4,
91 [ 0x28 ] = KEY_KP5, // 5 93 [0x28] = KEY_KP5,
92 [ 0x68 ] = KEY_KP6, // 6 94 [0x68] = KEY_KP6,
93 [ 0x08 ] = KEY_T, // Time Shift 95 [0x58] = KEY_KP7,
94 96 [0x38] = KEY_KP8,
95 [ 0x58 ] = KEY_KP7, // 7 97 [0x78] = KEY_KP9,
96 [ 0x38 ] = KEY_KP8, // 8 98
97 [ 0x78 ] = KEY_KP9, // 9 99 [0x10] = KEY_L, /* Live */
98 [ 0x18 ] = KEY_PLAYPAUSE, // Play 100 [0x08] = KEY_T, /* Time Shift */
99 101
100 [ 0x44 ] = KEY_KP0, // 10 102 [0x18] = KEY_PLAYPAUSE, /* Play */
101 [ 0x24 ] = KEY_ENTER, // 11 103
102 [ 0x64 ] = KEY_ESC, // 12 104 [0x24] = KEY_ENTER, /* 11 */
103 [ 0x04 ] = KEY_M, // Multi 105 [0x64] = KEY_ESC, /* 12 */
104 106 [0x04] = KEY_M, /* Multi */
105 [ 0x54 ] = KEY_VIDEO, // VIDEO 107
106 [ 0x34 ] = KEY_CHANNELUP, // channel + 108 [0x54] = KEY_VIDEO,
107 [ 0x74 ] = KEY_VOLUMEUP, // volume + 109 [0x34] = KEY_CHANNELUP,
108 [ 0x14 ] = KEY_MUTE, // Mute 110 [0x74] = KEY_VOLUMEUP,
109 111 [0x14] = KEY_MUTE,
110 [ 0x4c ] = KEY_S, // SVIDEO 112
111 [ 0x2c ] = KEY_CHANNELDOWN, // channel - 113 [0x4c] = KEY_S, /* SVIDEO */
112 [ 0x6c ] = KEY_VOLUMEDOWN, // volume - 114 [0x2c] = KEY_CHANNELDOWN,
113 [ 0x0c ] = KEY_ZOOM, // Zoom 115 [0x6c] = KEY_VOLUMEDOWN,
114 116 [0x0c] = KEY_ZOOM,
115 [ 0x5c ] = KEY_PAUSE, // pause 117
116 [ 0x3c ] = KEY_C, // || (red) 118 [0x5c] = KEY_PAUSE,
117 [ 0x7c ] = KEY_RECORD, // recording 119 [0x3c] = KEY_C, /* || (red) */
118 [ 0x1c ] = KEY_STOP, // stop 120 [0x7c] = KEY_RECORD, /* recording */
119 121 [0x1c] = KEY_STOP,
120 [ 0x41 ] = KEY_REWIND, // backward << 122
121 [ 0x21 ] = KEY_PLAY, // play 123 [0x41] = KEY_REWIND, /* backward << */
122 [ 0x61 ] = KEY_FASTFORWARD, // forward >> 124 [0x21] = KEY_PLAY,
123 [ 0x01 ] = KEY_NEXT, // skip >| 125 [0x61] = KEY_FASTFORWARD, /* forward >> */
126 [0x01] = KEY_NEXT, /* skip >| */
124}; 127};
125 128
126/* ---------------------------------------------------------------------- */ 129/* ---------------------------------------------------------------------- */
127 130
128/* ADS Tech Instant TV DVB-T PCI Remote */ 131/* ADS Tech Instant TV DVB-T PCI Remote */
129static IR_KEYTAB_TYPE ir_codes_adstech_dvb_t_pci[IR_KEYTAB_SIZE] = { 132static IR_KEYTAB_TYPE ir_codes_adstech_dvb_t_pci[IR_KEYTAB_SIZE] = {
130 [ 0x5b ] = KEY_POWER, 133 /* Keys 0 to 9 */
131 [ 0x5f ] = KEY_MUTE, 134 [0x4d] = KEY_0,
132 [ 0x57 ] = KEY_1, 135 [0x57] = KEY_1,
133 [ 0x4f ] = KEY_2, 136 [0x4f] = KEY_2,
134 [ 0x53 ] = KEY_3, 137 [0x53] = KEY_3,
135 [ 0x56 ] = KEY_4, 138 [0x56] = KEY_4,
136 [ 0x4e ] = KEY_5, 139 [0x4e] = KEY_5,
137 [ 0x5e ] = KEY_6, 140 [0x5e] = KEY_6,
138 [ 0x54 ] = KEY_7, 141 [0x54] = KEY_7,
139 [ 0x4c ] = KEY_8, 142 [0x4c] = KEY_8,
140 [ 0x5c ] = KEY_9, 143 [0x5c] = KEY_9,
141 [ 0x4d ] = KEY_0, 144
142 [ 0x55 ] = KEY_GOTO, 145 [0x5b] = KEY_POWER,
143 [ 0x5d ] = KEY_SEARCH, 146 [0x5f] = KEY_MUTE,
144 [ 0x17 ] = KEY_EPG, // Guide 147 [0x55] = KEY_GOTO,
145 [ 0x1f ] = KEY_MENU, 148 [0x5d] = KEY_SEARCH,
146 [ 0x0f ] = KEY_UP, 149 [0x17] = KEY_EPG, /* Guide */
147 [ 0x46 ] = KEY_DOWN, 150 [0x1f] = KEY_MENU,
148 [ 0x16 ] = KEY_LEFT, 151 [0x0f] = KEY_UP,
149 [ 0x1e ] = KEY_RIGHT, 152 [0x46] = KEY_DOWN,
150 [ 0x0e ] = KEY_SELECT, // Enter 153 [0x16] = KEY_LEFT,
151 [ 0x5a ] = KEY_INFO, 154 [0x1e] = KEY_RIGHT,
152 [ 0x52 ] = KEY_EXIT, 155 [0x0e] = KEY_SELECT, /* Enter */
153 [ 0x59 ] = KEY_PREVIOUS, 156 [0x5a] = KEY_INFO,
154 [ 0x51 ] = KEY_NEXT, 157 [0x52] = KEY_EXIT,
155 [ 0x58 ] = KEY_REWIND, 158 [0x59] = KEY_PREVIOUS,
156 [ 0x50 ] = KEY_FORWARD, 159 [0x51] = KEY_NEXT,
157 [ 0x44 ] = KEY_PLAYPAUSE, 160 [0x58] = KEY_REWIND,
158 [ 0x07 ] = KEY_STOP, 161 [0x50] = KEY_FORWARD,
159 [ 0x1b ] = KEY_RECORD, 162 [0x44] = KEY_PLAYPAUSE,
160 [ 0x13 ] = KEY_TUNER, // Live 163 [0x07] = KEY_STOP,
161 [ 0x0a ] = KEY_A, 164 [0x1b] = KEY_RECORD,
162 [ 0x12 ] = KEY_B, 165 [0x13] = KEY_TUNER, /* Live */
163 [ 0x03 ] = KEY_PROG1, // 1 166 [0x0a] = KEY_A,
164 [ 0x01 ] = KEY_PROG2, // 2 167 [0x12] = KEY_B,
165 [ 0x00 ] = KEY_PROG3, // 3 168 [0x03] = KEY_PROG1, /* 1 */
166 [ 0x06 ] = KEY_DVD, 169 [0x01] = KEY_PROG2, /* 2 */
167 [ 0x48 ] = KEY_AUX, // Photo 170 [0x00] = KEY_PROG3, /* 3 */
168 [ 0x40 ] = KEY_VIDEO, 171 [0x06] = KEY_DVD,
169 [ 0x19 ] = KEY_AUDIO, // Music 172 [0x48] = KEY_AUX, /* Photo */
170 [ 0x0b ] = KEY_CHANNELUP, 173 [0x40] = KEY_VIDEO,
171 [ 0x08 ] = KEY_CHANNELDOWN, 174 [0x19] = KEY_AUDIO, /* Music */
172 [ 0x15 ] = KEY_VOLUMEUP, 175 [0x0b] = KEY_CHANNELUP,
173 [ 0x1c ] = KEY_VOLUMEDOWN, 176 [0x08] = KEY_CHANNELDOWN,
177 [0x15] = KEY_VOLUMEUP,
178 [0x1c] = KEY_VOLUMEDOWN,
174}; 179};
175 180
176/* ---------------------------------------------------------------------- */ 181/* ---------------------------------------------------------------------- */
177 182
178/* MSI TV@nywhere remote */ 183/* MSI TV@nywhere remote */
179static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = { 184static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = {
180 [ 0x00 ] = KEY_0, /* '0' */ 185 /* Keys 0 to 9 */
181 [ 0x01 ] = KEY_1, /* '1' */ 186 [0x00] = KEY_0,
182 [ 0x02 ] = KEY_2, /* '2' */ 187 [0x01] = KEY_1,
183 [ 0x03 ] = KEY_3, /* '3' */ 188 [0x02] = KEY_2,
184 [ 0x04 ] = KEY_4, /* '4' */ 189 [0x03] = KEY_3,
185 [ 0x05 ] = KEY_5, /* '5' */ 190 [0x04] = KEY_4,
186 [ 0x06 ] = KEY_6, /* '6' */ 191 [0x05] = KEY_5,
187 [ 0x07 ] = KEY_7, /* '7' */ 192 [0x06] = KEY_6,
188 [ 0x08 ] = KEY_8, /* '8' */ 193 [0x07] = KEY_7,
189 [ 0x09 ] = KEY_9, /* '9' */ 194 [0x08] = KEY_8,
190 [ 0x0c ] = KEY_MUTE, /* 'Mute' */ 195 [0x09] = KEY_9,
191 [ 0x0f ] = KEY_SCREEN, /* 'Full Screen' */ 196
192 [ 0x10 ] = KEY_F, /* 'Funtion' */ 197 [0x0c] = KEY_MUTE,
193 [ 0x11 ] = KEY_T, /* 'Time shift' */ 198 [0x0f] = KEY_SCREEN, /* Full Screen */
194 [ 0x12 ] = KEY_POWER, /* 'Power' */ 199 [0x10] = KEY_F, /* Funtion */
195 [ 0x13 ] = KEY_MEDIA, /* 'MTS' */ 200 [0x11] = KEY_T, /* Time shift */
196 [ 0x14 ] = KEY_SLOW, /* 'Slow' */ 201 [0x12] = KEY_POWER,
197 [ 0x16 ] = KEY_REWIND, /* 'backward <<' */ 202 [0x13] = KEY_MEDIA, /* MTS */
198 [ 0x17 ] = KEY_ENTER, /* 'Return' */ 203 [0x14] = KEY_SLOW,
199 [ 0x18 ] = KEY_FASTFORWARD, /* 'forward >>' */ 204 [0x16] = KEY_REWIND, /* backward << */
200 [ 0x1a ] = KEY_CHANNELUP, /* 'Channel+' */ 205 [0x17] = KEY_ENTER, /* Return */
201 [ 0x1b ] = KEY_VOLUMEUP, /* 'Volume+' */ 206 [0x18] = KEY_FASTFORWARD, /* forward >> */
202 [ 0x1e ] = KEY_CHANNELDOWN, /* 'Channel-' */ 207 [0x1a] = KEY_CHANNELUP,
203 [ 0x1f ] = KEY_VOLUMEDOWN, /* 'Volume-' */ 208 [0x1b] = KEY_VOLUMEUP,
209 [0x1e] = KEY_CHANNELDOWN,
210 [0x1f] = KEY_VOLUMEDOWN,
204}; 211};
205 212
206/* ---------------------------------------------------------------------- */ 213/* ---------------------------------------------------------------------- */
207 214
208struct cx88_IR { 215struct cx88_IR {
209 struct cx88_core *core; 216 struct cx88_core *core;
210 struct input_dev input; 217 struct input_dev input;
211 struct ir_input_state ir; 218 struct ir_input_state ir;
212 char name[32]; 219 char name[32];
213 char phys[32]; 220 char phys[32];
214 221
215 /* sample from gpio pin 16 */ 222 /* sample from gpio pin 16 */
216 int sampling; 223 int sampling;
217 u32 samples[16]; 224 u32 samples[16];
218 int scount; 225 int scount;
219 unsigned long release; 226 unsigned long release;
220 227
221 /* poll external decoder */ 228 /* poll external decoder */
222 int polling; 229 int polling;
223 struct work_struct work; 230 struct work_struct work;
224 struct timer_list timer; 231 struct timer_list timer;
225 u32 gpio_addr; 232 u32 gpio_addr;
226 u32 last_gpio; 233 u32 last_gpio;
227 u32 mask_keycode; 234 u32 mask_keycode;
228 u32 mask_keydown; 235 u32 mask_keydown;
229 u32 mask_keyup; 236 u32 mask_keyup;
230}; 237};
231 238
232static int ir_debug = 0; 239static int ir_debug = 0;
233module_param(ir_debug, int, 0644); /* debug level [IR] */ 240module_param(ir_debug, int, 0644); /* debug level [IR] */
234MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); 241MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
235 242
236#define ir_dprintk(fmt, arg...) if (ir_debug) \ 243#define ir_dprintk(fmt, arg...) if (ir_debug) \
@@ -254,37 +261,37 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
254 /* extract data */ 261 /* extract data */
255 data = ir_extract_bits(gpio, ir->mask_keycode); 262 data = ir_extract_bits(gpio, ir->mask_keycode);
256 ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n", 263 ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n",
257 gpio, data, 264 gpio, data,
258 ir->polling ? "poll" : "irq", 265 ir->polling ? "poll" : "irq",
259 (gpio & ir->mask_keydown) ? " down" : "", 266 (gpio & ir->mask_keydown) ? " down" : "",
260 (gpio & ir->mask_keyup) ? " up" : ""); 267 (gpio & ir->mask_keyup) ? " up" : "");
261 268
262 if (ir->mask_keydown) { 269 if (ir->mask_keydown) {
263 /* bit set on keydown */ 270 /* bit set on keydown */
264 if (gpio & ir->mask_keydown) { 271 if (gpio & ir->mask_keydown) {
265 ir_input_keydown(&ir->input,&ir->ir,data,data); 272 ir_input_keydown(&ir->input, &ir->ir, data, data);
266 } else { 273 } else {
267 ir_input_nokey(&ir->input,&ir->ir); 274 ir_input_nokey(&ir->input, &ir->ir);
268 } 275 }
269 276
270 } else if (ir->mask_keyup) { 277 } else if (ir->mask_keyup) {
271 /* bit cleared on keydown */ 278 /* bit cleared on keydown */
272 if (0 == (gpio & ir->mask_keyup)) { 279 if (0 == (gpio & ir->mask_keyup)) {
273 ir_input_keydown(&ir->input,&ir->ir,data,data); 280 ir_input_keydown(&ir->input, &ir->ir, data, data);
274 } else { 281 } else {
275 ir_input_nokey(&ir->input,&ir->ir); 282 ir_input_nokey(&ir->input, &ir->ir);
276 } 283 }
277 284
278 } else { 285 } else {
279 /* can't distinguish keydown/up :-/ */ 286 /* can't distinguish keydown/up :-/ */
280 ir_input_keydown(&ir->input,&ir->ir,data,data); 287 ir_input_keydown(&ir->input, &ir->ir, data, data);
281 ir_input_nokey(&ir->input,&ir->ir); 288 ir_input_nokey(&ir->input, &ir->ir);
282 } 289 }
283} 290}
284 291
285static void ir_timer(unsigned long data) 292static void ir_timer(unsigned long data)
286{ 293{
287 struct cx88_IR *ir = (struct cx88_IR*)data; 294 struct cx88_IR *ir = (struct cx88_IR *)data;
288 295
289 schedule_work(&ir->work); 296 schedule_work(&ir->work);
290} 297}
@@ -307,62 +314,62 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
307 IR_KEYTAB_TYPE *ir_codes = NULL; 314 IR_KEYTAB_TYPE *ir_codes = NULL;
308 int ir_type = IR_TYPE_OTHER; 315 int ir_type = IR_TYPE_OTHER;
309 316
310 ir = kmalloc(sizeof(*ir),GFP_KERNEL); 317 ir = kmalloc(sizeof(*ir), GFP_KERNEL);
311 if (NULL == ir) 318 if (NULL == ir)
312 return -ENOMEM; 319 return -ENOMEM;
313 memset(ir,0,sizeof(*ir)); 320 memset(ir, 0, sizeof(*ir));
314 321
315 /* detect & configure */ 322 /* detect & configure */
316 switch (core->board) { 323 switch (core->board) {
317 case CX88_BOARD_DNTV_LIVE_DVB_T: 324 case CX88_BOARD_DNTV_LIVE_DVB_T:
318 case CX88_BOARD_KWORLD_DVB_T: 325 case CX88_BOARD_KWORLD_DVB_T:
319 ir_codes = ir_codes_dntv_live_dvb_t; 326 ir_codes = ir_codes_dntv_live_dvb_t;
320 ir->gpio_addr = MO_GP1_IO; 327 ir->gpio_addr = MO_GP1_IO;
321 ir->mask_keycode = 0x1f; 328 ir->mask_keycode = 0x1f;
322 ir->mask_keyup = 0x60; 329 ir->mask_keyup = 0x60;
323 ir->polling = 50; // ms 330 ir->polling = 50; /* ms */
324 break; 331 break;
325 case CX88_BOARD_HAUPPAUGE: 332 case CX88_BOARD_HAUPPAUGE:
326 case CX88_BOARD_HAUPPAUGE_DVB_T1: 333 case CX88_BOARD_HAUPPAUGE_DVB_T1:
327 ir_codes = ir_codes_hauppauge_new; 334 ir_codes = ir_codes_hauppauge_new;
328 ir_type = IR_TYPE_RC5; 335 ir_type = IR_TYPE_RC5;
329 ir->sampling = 1; 336 ir->sampling = 1;
330 break; 337 break;
331 case CX88_BOARD_WINFAST2000XP_EXPERT: 338 case CX88_BOARD_WINFAST2000XP_EXPERT:
332 ir_codes = ir_codes_winfast; 339 ir_codes = ir_codes_winfast;
333 ir->gpio_addr = MO_GP0_IO; 340 ir->gpio_addr = MO_GP0_IO;
334 ir->mask_keycode = 0x8f8; 341 ir->mask_keycode = 0x8f8;
335 ir->mask_keyup = 0x100; 342 ir->mask_keyup = 0x100;
336 ir->polling = 1; // ms 343 ir->polling = 1; /* ms */
337 break; 344 break;
338 case CX88_BOARD_IODATA_GVBCTV7E: 345 case CX88_BOARD_IODATA_GVBCTV7E:
339 ir_codes = ir_codes_iodata_bctv7e; 346 ir_codes = ir_codes_iodata_bctv7e;
340 ir->gpio_addr = MO_GP0_IO; 347 ir->gpio_addr = MO_GP0_IO;
341 ir->mask_keycode = 0xfd; 348 ir->mask_keycode = 0xfd;
342 ir->mask_keydown = 0x02; 349 ir->mask_keydown = 0x02;
343 ir->polling = 5; // ms 350 ir->polling = 5; /* ms */
344 break; 351 break;
345 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO: 352 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
346 ir_codes = ir_codes_pixelview; 353 ir_codes = ir_codes_pixelview;
347 ir->gpio_addr = MO_GP1_IO; 354 ir->gpio_addr = MO_GP1_IO;
348 ir->mask_keycode = 0x1f; 355 ir->mask_keycode = 0x1f;
349 ir->mask_keyup = 0x80; 356 ir->mask_keyup = 0x80;
350 ir->polling = 1; // ms 357 ir->polling = 1; /* ms */
351 break; 358 break;
352 case CX88_BOARD_ADSTECH_DVB_T_PCI: 359 case CX88_BOARD_ADSTECH_DVB_T_PCI:
353 ir_codes = ir_codes_adstech_dvb_t_pci; 360 ir_codes = ir_codes_adstech_dvb_t_pci;
354 ir->gpio_addr = MO_GP1_IO; 361 ir->gpio_addr = MO_GP1_IO;
355 ir->mask_keycode = 0xbf; 362 ir->mask_keycode = 0xbf;
356 ir->mask_keyup = 0x40; 363 ir->mask_keyup = 0x40;
357 ir->polling = 50; // ms 364 ir->polling = 50; /* ms */
365 break;
366 case CX88_BOARD_MSI_TVANYWHERE_MASTER:
367 ir_codes = ir_codes_msi_tvanywhere;
368 ir->gpio_addr = MO_GP1_IO;
369 ir->mask_keycode = 0x1f;
370 ir->mask_keyup = 0x40;
371 ir->polling = 1; /* ms */
358 break; 372 break;
359 case CX88_BOARD_MSI_TVANYWHERE_MASTER:
360 ir_codes = ir_codes_msi_tvanywhere;
361 ir->gpio_addr = MO_GP1_IO;
362 ir->mask_keycode = 0x1f;
363 ir->mask_keyup = 0x40;
364 ir->polling = 1;
365 break;
366 } 373 }
367 374
368 if (NULL == ir_codes) { 375 if (NULL == ir_codes) {
@@ -373,8 +380,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
373 /* init input device */ 380 /* init input device */
374 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", 381 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)",
375 cx88_boards[core->board].name); 382 cx88_boards[core->board].name);
376 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 383 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
377 pci_name(pci));
378 384
379 ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes); 385 ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes);
380 ir->input.name = ir->name; 386 ir->input.name = ir->name;
@@ -382,10 +388,10 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
382 ir->input.id.bustype = BUS_PCI; 388 ir->input.id.bustype = BUS_PCI;
383 ir->input.id.version = 1; 389 ir->input.id.version = 1;
384 if (pci->subsystem_vendor) { 390 if (pci->subsystem_vendor) {
385 ir->input.id.vendor = pci->subsystem_vendor; 391 ir->input.id.vendor = pci->subsystem_vendor;
386 ir->input.id.product = pci->subsystem_device; 392 ir->input.id.product = pci->subsystem_device;
387 } else { 393 } else {
388 ir->input.id.vendor = pci->vendor; 394 ir->input.id.vendor = pci->vendor;
389 ir->input.id.product = pci->device; 395 ir->input.id.product = pci->device;
390 } 396 }
391 397
@@ -397,13 +403,13 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
397 INIT_WORK(&ir->work, cx88_ir_work, ir); 403 INIT_WORK(&ir->work, cx88_ir_work, ir);
398 init_timer(&ir->timer); 404 init_timer(&ir->timer);
399 ir->timer.function = ir_timer; 405 ir->timer.function = ir_timer;
400 ir->timer.data = (unsigned long)ir; 406 ir->timer.data = (unsigned long)ir;
401 schedule_work(&ir->work); 407 schedule_work(&ir->work);
402 } 408 }
403 if (ir->sampling) { 409 if (ir->sampling) {
404 core->pci_irqmask |= (1<<18); // IR_SMP_INT 410 core->pci_irqmask |= (1 << 18); /* IR_SMP_INT */
405 cx_write(MO_DDS_IO, 0xa80a80); // 4 kHz sample rate 411 cx_write(MO_DDS_IO, 0xa80a80); /* 4 kHz sample rate */
406 cx_write(MO_DDSCFG_IO, 0x5); // enable 412 cx_write(MO_DDSCFG_IO, 0x5); /* enable */
407 } 413 }
408 414
409 /* all done */ 415 /* all done */
@@ -439,7 +445,7 @@ int cx88_ir_fini(struct cx88_core *core)
439void cx88_ir_irq(struct cx88_core *core) 445void cx88_ir_irq(struct cx88_core *core)
440{ 446{
441 struct cx88_IR *ir = core->ir; 447 struct cx88_IR *ir = core->ir;
442 u32 samples,rc5; 448 u32 samples, rc5;
443 int i; 449 int i;
444 450
445 if (NULL == ir) 451 if (NULL == ir)
@@ -448,7 +454,7 @@ void cx88_ir_irq(struct cx88_core *core)
448 return; 454 return;
449 455
450 samples = cx_read(MO_SAMPLE_IO); 456 samples = cx_read(MO_SAMPLE_IO);
451 if (0 != samples && 0xffffffff != samples) { 457 if (0 != samples && 0xffffffff != samples) {
452 /* record sample data */ 458 /* record sample data */
453 if (ir->scount < ARRAY_SIZE(ir->samples)) 459 if (ir->scount < ARRAY_SIZE(ir->samples))
454 ir->samples[ir->scount++] = samples; 460 ir->samples[ir->scount++] = samples;
@@ -456,8 +462,8 @@ void cx88_ir_irq(struct cx88_core *core)
456 } 462 }
457 if (!ir->scount) { 463 if (!ir->scount) {
458 /* nothing to sample */ 464 /* nothing to sample */
459 if (ir->ir.keypressed && time_after(jiffies,ir->release)) 465 if (ir->ir.keypressed && time_after(jiffies, ir->release))
460 ir_input_nokey(&ir->input,&ir->ir); 466 ir_input_nokey(&ir->input, &ir->ir);
461 return; 467 return;
462 } 468 }
463 469
@@ -467,14 +473,14 @@ void cx88_ir_irq(struct cx88_core *core)
467 for (i = 0; i < ir->scount; i++) 473 for (i = 0; i < ir->scount; i++)
468 ir->samples[i] = ~ir->samples[i]; 474 ir->samples[i] = ~ir->samples[i];
469 if (ir_debug) 475 if (ir_debug)
470 ir_dump_samples(ir->samples,ir->scount); 476 ir_dump_samples(ir->samples, ir->scount);
471 477
472 /* decode it */ 478 /* decode it */
473 switch (core->board) { 479 switch (core->board) {
474 case CX88_BOARD_HAUPPAUGE: 480 case CX88_BOARD_HAUPPAUGE:
475 case CX88_BOARD_HAUPPAUGE_DVB_T1: 481 case CX88_BOARD_HAUPPAUGE_DVB_T1:
476 rc5 = ir_decode_biphase(ir->samples,ir->scount,5,7); 482 rc5 = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
477 ir_dprintk("biphase decoded: %x\n",rc5); 483 ir_dprintk("biphase decoded: %x\n", rc5);
478 if ((rc5 & 0xfffff000) != 0x3000) 484 if ((rc5 & 0xfffff000) != 0x3000)
479 break; 485 break;
480 ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5); 486 ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5);
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 85da6dc8d0e0..fe2767c0ff94 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-mpeg.c,v 1.30 2005/07/05 19:44:40 mkrufky Exp $ 2 * $Id: cx88-mpeg.c,v 1.31 2005/07/07 14:17:47 mchehab Exp $
3 * 3 *
4 * Support for the mpeg transport stream transfers 4 * Support for the mpeg transport stream transfers
5 * PCI function #2 of the cx2388x. 5 * PCI function #2 of the cx2388x.
@@ -64,7 +64,6 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
64 /* write TS length to chip */ 64 /* write TS length to chip */
65 cx_write(MO_TS_LNGTH, buf->vb.width); 65 cx_write(MO_TS_LNGTH, buf->vb.width);
66 66
67#if 1
68 /* FIXME: this needs a review. 67 /* FIXME: this needs a review.
69 * also: move to cx88-blackbird + cx88-dvb source files? */ 68 * also: move to cx88-blackbird + cx88-dvb source files? */
70 69
@@ -76,9 +75,9 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
76 cx_write(TS_HW_SOP_CNTRL,0x47<<16|188<<4|0x01); 75 cx_write(TS_HW_SOP_CNTRL,0x47<<16|188<<4|0x01);
77 if ((core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q) || 76 if ((core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q) ||
78 (core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T)) { 77 (core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T)) {
79 cx_write(TS_SOP_STAT, 0<<16 | 0<<14 | 1<<13 | 0<<12); 78 cx_write(TS_SOP_STAT, 1<<13);
80 } else { 79 } else {
81 cx_write(TS_SOP_STAT,0x00); 80 cx_write(TS_SOP_STAT, 0x00);
82 } 81 }
83 cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl); 82 cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl);
84 udelay(100); 83 udelay(100);
@@ -98,7 +97,6 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
98 cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ 97 cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */
99 udelay(100); 98 udelay(100);
100 } 99 }
101#endif
102 100
103 /* reset counter */ 101 /* reset counter */
104 cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET); 102 cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET);
@@ -270,6 +268,15 @@ static void cx8802_timeout(unsigned long data)
270 do_cancel_buffers(dev,"timeout",1); 268 do_cancel_buffers(dev,"timeout",1);
271} 269}
272 270
271static char *cx88_mpeg_irqs[32] = {
272 "ts_risci1", NULL, NULL, NULL,
273 "ts_risci2", NULL, NULL, NULL,
274 "ts_oflow", NULL, NULL, NULL,
275 "ts_sync", NULL, NULL, NULL,
276 "opc_err", "par_err", "rip_err", "pci_abort",
277 "ts_err?",
278};
279
273static void cx8802_mpeg_irq(struct cx8802_dev *dev) 280static void cx8802_mpeg_irq(struct cx8802_dev *dev)
274{ 281{
275 struct cx88_core *core = dev->core; 282 struct cx88_core *core = dev->core;
@@ -282,10 +289,7 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
282 return; 289 return;
283 290
284 cx_write(MO_TS_INTSTAT, status); 291 cx_write(MO_TS_INTSTAT, status);
285#if 0 292
286 cx88_print_irqbits(core->name, "irq mpeg ",
287 cx88_mpeg_irqs, status, mask);
288#endif
289 if (debug || (status & mask & ~0xff)) 293 if (debug || (status & mask & ~0xff))
290 cx88_print_irqbits(core->name, "irq mpeg ", 294 cx88_print_irqbits(core->name, "irq mpeg ",
291 cx88_mpeg_irqs, status, mask); 295 cx88_mpeg_irqs, status, mask);
@@ -441,10 +445,8 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
441 } 445 }
442 spin_unlock(&dev->slock); 446 spin_unlock(&dev->slock);
443 447
444#if 1
445 /* FIXME -- shutdown device */ 448 /* FIXME -- shutdown device */
446 cx88_shutdown(dev->core); 449 cx88_shutdown(dev->core);
447#endif
448 450
449 pci_save_state(pci_dev); 451 pci_save_state(pci_dev);
450 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { 452 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
@@ -466,10 +468,8 @@ int cx8802_resume_common(struct pci_dev *pci_dev)
466 pci_set_power_state(pci_dev, PCI_D0); 468 pci_set_power_state(pci_dev, PCI_D0);
467 pci_restore_state(pci_dev); 469 pci_restore_state(pci_dev);
468 470
469#if 1
470 /* FIXME: re-initialize hardware */ 471 /* FIXME: re-initialize hardware */
471 cx88_reset(dev->core); 472 cx88_reset(dev->core);
472#endif
473 473
474 /* restart video+vbi capture */ 474 /* restart video+vbi capture */
475 spin_lock(&dev->slock); 475 spin_lock(&dev->slock);
diff --git a/drivers/media/video/cx88/cx88-reg.h b/drivers/media/video/cx88/cx88-reg.h
index 63ad33f5818b..37f82662d265 100644
--- a/drivers/media/video/cx88/cx88-reg.h
+++ b/drivers/media/video/cx88/cx88-reg.h
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: cx88-reg.h,v 1.7 2005/06/03 13:31:51 mchehab Exp $ 2 $Id: cx88-reg.h,v 1.8 2005/07/07 13:58:38 mchehab Exp $
3 3
4 cx88x-hw.h - CX2388x register offsets 4 cx88x-hw.h - CX2388x register offsets
5 5
@@ -604,20 +604,11 @@
604#define EN_I2SIN_STR2DAC 0x00004000 604#define EN_I2SIN_STR2DAC 0x00004000
605#define EN_I2SIN_ENABLE 0x00008000 605#define EN_I2SIN_ENABLE 0x00008000
606 606
607#if 0
608/* old */
609#define EN_DMTRX_SUMDIFF 0x00000800
610#define EN_DMTRX_SUMR 0x00000880
611#define EN_DMTRX_LR 0x00000900
612#define EN_DMTRX_MONO 0x00000980
613#else
614/* dscaler cvs */
615#define EN_DMTRX_SUMDIFF (0 << 7) 607#define EN_DMTRX_SUMDIFF (0 << 7)
616#define EN_DMTRX_SUMR (1 << 7) 608#define EN_DMTRX_SUMR (1 << 7)
617#define EN_DMTRX_LR (2 << 7) 609#define EN_DMTRX_LR (2 << 7)
618#define EN_DMTRX_MONO (3 << 7) 610#define EN_DMTRX_MONO (3 << 7)
619#define EN_DMTRX_BYPASS (1 << 11) 611#define EN_DMTRX_BYPASS (1 << 11)
620#endif
621 612
622// Video 613// Video
623#define VID_CAPTURE_CONTROL 0x310180 614#define VID_CAPTURE_CONTROL 0x310180
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 46d78b1dc9b2..91207f10bae7 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: cx88-tvaudio.c,v 1.36 2005/06/05 05:53:45 mchehab Exp $ 2 $Id: cx88-tvaudio.c,v 1.37 2005/07/07 13:58:38 mchehab Exp $
3 3
4 cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver 4 cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
5 5
@@ -278,80 +278,6 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap)
278 set_audio_finish(core); 278 set_audio_finish(core);
279} 279}
280 280
281#if 0
282static void set_audio_standard_NICAM(struct cx88_core *core)
283{
284 static const struct rlist nicam_common[] = {
285 /* from dscaler */
286 { AUD_RATE_ADJ1, 0x00000010 },
287 { AUD_RATE_ADJ2, 0x00000040 },
288 { AUD_RATE_ADJ3, 0x00000100 },
289 { AUD_RATE_ADJ4, 0x00000400 },
290 { AUD_RATE_ADJ5, 0x00001000 },
291 // { AUD_DMD_RA_DDS, 0x00c0d5ce },
292
293 // Deemphasis 1:
294 { AUD_DEEMPHGAIN_R, 0x000023c2 },
295 { AUD_DEEMPHNUMER1_R, 0x0002a7bc },
296 { AUD_DEEMPHNUMER2_R, 0x0003023e },
297 { AUD_DEEMPHDENOM1_R, 0x0000f3d0 },
298 { AUD_DEEMPHDENOM2_R, 0x00000000 },
299
300#if 0
301 // Deemphasis 2: (other tv norm?)
302 { AUD_DEEMPHGAIN_R, 0x0000c600 },
303 { AUD_DEEMPHNUMER1_R, 0x00066738 },
304 { AUD_DEEMPHNUMER2_R, 0x00066739 },
305 { AUD_DEEMPHDENOM1_R, 0x0001e88c },
306 { AUD_DEEMPHDENOM2_R, 0x0001e88c },
307#endif
308
309 { AUD_DEEMPHDENOM2_R, 0x00000000 },
310 { AUD_ERRLOGPERIOD_R, 0x00000fff },
311 { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff },
312 { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff },
313 { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f },
314 { AUD_POLYPH80SCALEFAC, 0x00000003 },
315
316 // setup QAM registers
317 { AUD_PDF_DDS_CNST_BYTE2, 0x06 },
318 { AUD_PDF_DDS_CNST_BYTE1, 0x82 },
319 { AUD_PDF_DDS_CNST_BYTE0, 0x16 },
320 { AUD_QAM_MODE, 0x05 },
321
322 { /* end of list */ },
323 };
324 static const struct rlist nicam_pal_i[] = {
325 { AUD_PDF_DDS_CNST_BYTE0, 0x12 },
326 { AUD_PHACC_FREQ_8MSB, 0x3a },
327 { AUD_PHACC_FREQ_8LSB, 0x93 },
328
329 { /* end of list */ },
330 };
331 static const struct rlist nicam_default[] = {
332 { AUD_PDF_DDS_CNST_BYTE0, 0x16 },
333 { AUD_PHACC_FREQ_8MSB, 0x34 },
334 { AUD_PHACC_FREQ_8LSB, 0x4c },
335
336 { /* end of list */ },
337 };
338
339 set_audio_start(core, 0x0010,
340 EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO);
341 set_audio_registers(core, nicam_common);
342 switch (core->tvaudio) {
343 case WW_NICAM_I:
344 dprintk("%s PAL-I NICAM (status: unknown)\n",__FUNCTION__);
345 set_audio_registers(core, nicam_pal_i);
346 break;
347 case WW_NICAM_BGDKL:
348 dprintk("%s PAL-BGDK NICAM (status: unknown)\n",__FUNCTION__);
349 set_audio_registers(core, nicam_default);
350 break;
351 };
352 set_audio_finish(core);
353}
354#endif
355 281
356static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo) 282static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo)
357{ 283{
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index dc997549b634..c44a079d08c0 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-video.c,v 1.70 2005/06/20 03:36:00 mkrufky Exp $ 2 * $Id: cx88-video.c,v 1.79 2005/07/07 14:17:47 mchehab Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * video4linux video interface 5 * video4linux video interface
@@ -86,13 +86,6 @@ static struct cx88_tvnorm tvnorms[] = {
86 .id = V4L2_STD_NTSC_M_JP, 86 .id = V4L2_STD_NTSC_M_JP,
87 .cxiformat = VideoFormatNTSCJapan, 87 .cxiformat = VideoFormatNTSCJapan,
88 .cxoformat = 0x181f0008, 88 .cxoformat = 0x181f0008,
89#if 0
90 },{
91 .name = "NTSC-4.43",
92 .id = FIXME,
93 .cxiformat = VideoFormatNTSC443,
94 .cxoformat = 0x181f0008,
95#endif
96 },{ 89 },{
97 .name = "PAL-BG", 90 .name = "PAL-BG",
98 .id = V4L2_STD_PAL_BG, 91 .id = V4L2_STD_PAL_BG,
@@ -248,6 +241,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
248 .default_value = 0, 241 .default_value = 0,
249 .type = V4L2_CTRL_TYPE_INTEGER, 242 .type = V4L2_CTRL_TYPE_INTEGER,
250 }, 243 },
244 .off = 0,
251 .reg = MO_CONTR_BRIGHT, 245 .reg = MO_CONTR_BRIGHT,
252 .mask = 0xff00, 246 .mask = 0xff00,
253 .shift = 8, 247 .shift = 8,
@@ -674,231 +668,6 @@ static struct videobuf_queue_ops cx8800_video_qops = {
674 668
675/* ------------------------------------------------------------------ */ 669/* ------------------------------------------------------------------ */
676 670
677#if 0 /* overlay support not finished yet */
678static u32* ov_risc_field(struct cx8800_dev *dev, struct cx8800_fh *fh,
679 u32 *rp, struct btcx_skiplist *skips,
680 u32 sync_line, int skip_even, int skip_odd)
681{
682 int line,maxy,start,end,skip,nskips;
683 u32 ri,ra;
684 u32 addr;
685
686 /* sync instruction */
687 *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
688
689 addr = (unsigned long)dev->fbuf.base;
690 addr += dev->fbuf.fmt.bytesperline * fh->win.w.top;
691 addr += (fh->fmt->depth >> 3) * fh->win.w.left;
692
693 /* scan lines */
694 for (maxy = -1, line = 0; line < fh->win.w.height;
695 line++, addr += dev->fbuf.fmt.bytesperline) {
696 if ((line%2) == 0 && skip_even)
697 continue;
698 if ((line%2) == 1 && skip_odd)
699 continue;
700
701 /* calculate clipping */
702 if (line > maxy)
703 btcx_calc_skips(line, fh->win.w.width, &maxy,
704 skips, &nskips, fh->clips, fh->nclips);
705
706 /* write out risc code */
707 for (start = 0, skip = 0; start < fh->win.w.width; start = end) {
708 if (skip >= nskips) {
709 ri = RISC_WRITE;
710 end = fh->win.w.width;
711 } else if (start < skips[skip].start) {
712 ri = RISC_WRITE;
713 end = skips[skip].start;
714 } else {
715 ri = RISC_SKIP;
716 end = skips[skip].end;
717 skip++;
718 }
719 if (RISC_WRITE == ri)
720 ra = addr + (fh->fmt->depth>>3)*start;
721 else
722 ra = 0;
723
724 if (0 == start)
725 ri |= RISC_SOL;
726 if (fh->win.w.width == end)
727 ri |= RISC_EOL;
728 ri |= (fh->fmt->depth>>3) * (end-start);
729
730 *(rp++)=cpu_to_le32(ri);
731 if (0 != ra)
732 *(rp++)=cpu_to_le32(ra);
733 }
734 }
735 kfree(skips);
736 return rp;
737}
738
739static int ov_risc_frame(struct cx8800_dev *dev, struct cx8800_fh *fh,
740 struct cx88_buffer *buf)
741{
742 struct btcx_skiplist *skips;
743 u32 instructions,fields;
744 u32 *rp;
745 int rc;
746
747 /* skip list for window clipping */
748 if (NULL == (skips = kmalloc(sizeof(*skips) * fh->nclips,GFP_KERNEL)))
749 return -ENOMEM;
750
751 fields = 0;
752 if (V4L2_FIELD_HAS_TOP(fh->win.field))
753 fields++;
754 if (V4L2_FIELD_HAS_BOTTOM(fh->win.field))
755 fields++;
756
757 /* estimate risc mem: worst case is (clip+1) * lines instructions
758 + syncs + jump (all 2 dwords) */
759 instructions = (fh->nclips+1) * fh->win.w.height;
760 instructions += 3 + 4;
761 if ((rc = btcx_riscmem_alloc(dev->pci,&buf->risc,instructions*8)) < 0) {
762 kfree(skips);
763 return rc;
764 }
765
766 /* write risc instructions */
767 rp = buf->risc.cpu;
768 switch (fh->win.field) {
769 case V4L2_FIELD_TOP:
770 rp = ov_risc_field(dev, fh, rp, skips, 0, 0, 0);
771 break;
772 case V4L2_FIELD_BOTTOM:
773 rp = ov_risc_field(dev, fh, rp, skips, 0x200, 0, 0);
774 break;
775 case V4L2_FIELD_INTERLACED:
776 rp = ov_risc_field(dev, fh, rp, skips, 0, 0, 1);
777 rp = ov_risc_field(dev, fh, rp, skips, 0x200, 1, 0);
778 break;
779 default:
780 BUG();
781 }
782
783 /* save pointer to jmp instruction address */
784 buf->risc.jmp = rp;
785 kfree(skips);
786 return 0;
787}
788
789static int verify_window(struct cx8800_dev *dev, struct v4l2_window *win)
790{
791 enum v4l2_field field;
792 int maxw, maxh;
793
794 if (NULL == dev->fbuf.base)
795 return -EINVAL;
796 if (win->w.width < 48 || win->w.height < 32)
797 return -EINVAL;
798 if (win->clipcount > 2048)
799 return -EINVAL;
800
801 field = win->field;
802 maxw = norm_maxw(core->tvnorm);
803 maxh = norm_maxh(core->tvnorm);
804
805 if (V4L2_FIELD_ANY == field) {
806 field = (win->w.height > maxh/2)
807 ? V4L2_FIELD_INTERLACED
808 : V4L2_FIELD_TOP;
809 }
810 switch (field) {
811 case V4L2_FIELD_TOP:
812 case V4L2_FIELD_BOTTOM:
813 maxh = maxh / 2;
814 break;
815 case V4L2_FIELD_INTERLACED:
816 break;
817 default:
818 return -EINVAL;
819 }
820
821 win->field = field;
822 if (win->w.width > maxw)
823 win->w.width = maxw;
824 if (win->w.height > maxh)
825 win->w.height = maxh;
826 return 0;
827}
828
829static int setup_window(struct cx8800_dev *dev, struct cx8800_fh *fh,
830 struct v4l2_window *win)
831{
832 struct v4l2_clip *clips = NULL;
833 int n,size,retval = 0;
834
835 if (NULL == fh->fmt)
836 return -EINVAL;
837 retval = verify_window(dev,win);
838 if (0 != retval)
839 return retval;
840
841 /* copy clips -- luckily v4l1 + v4l2 are binary
842 compatible here ...*/
843 n = win->clipcount;
844 size = sizeof(*clips)*(n+4);
845 clips = kmalloc(size,GFP_KERNEL);
846 if (NULL == clips)
847 return -ENOMEM;
848 if (n > 0) {
849 if (copy_from_user(clips,win->clips,sizeof(struct v4l2_clip)*n)) {
850 kfree(clips);
851 return -EFAULT;
852 }
853 }
854
855 /* clip against screen */
856 if (NULL != dev->fbuf.base)
857 n = btcx_screen_clips(dev->fbuf.fmt.width, dev->fbuf.fmt.height,
858 &win->w, clips, n);
859 btcx_sort_clips(clips,n);
860
861 /* 4-byte alignments */
862 switch (fh->fmt->depth) {
863 case 8:
864 case 24:
865 btcx_align(&win->w, clips, n, 3);
866 break;
867 case 16:
868 btcx_align(&win->w, clips, n, 1);
869 break;
870 case 32:
871 /* no alignment fixups needed */
872 break;
873 default:
874 BUG();
875 }
876
877 down(&fh->vidq.lock);
878 if (fh->clips)
879 kfree(fh->clips);
880 fh->clips = clips;
881 fh->nclips = n;
882 fh->win = *win;
883#if 0
884 fh->ov.setup_ok = 1;
885#endif
886
887 /* update overlay if needed */
888 retval = 0;
889#if 0
890 if (check_btres(fh, RESOURCE_OVERLAY)) {
891 struct bttv_buffer *new;
892
893 new = videobuf_alloc(sizeof(*new));
894 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
895 retval = bttv_switch_overlay(btv,fh,new);
896 }
897#endif
898 up(&fh->vidq.lock);
899 return retval;
900}
901#endif
902 671
903/* ------------------------------------------------------------------ */ 672/* ------------------------------------------------------------------ */
904 673
@@ -1327,9 +1096,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1327 struct cx8800_fh *fh = file->private_data; 1096 struct cx8800_fh *fh = file->private_data;
1328 struct cx8800_dev *dev = fh->dev; 1097 struct cx8800_dev *dev = fh->dev;
1329 struct cx88_core *core = dev->core; 1098 struct cx88_core *core = dev->core;
1330#if 0
1331 unsigned long flags;
1332#endif
1333 int err; 1099 int err;
1334 1100
1335 if (video_debug > 1) 1101 if (video_debug > 1)
@@ -1350,9 +1116,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1350 V4L2_CAP_READWRITE | 1116 V4L2_CAP_READWRITE |
1351 V4L2_CAP_STREAMING | 1117 V4L2_CAP_STREAMING |
1352 V4L2_CAP_VBI_CAPTURE | 1118 V4L2_CAP_VBI_CAPTURE |
1353#if 0
1354 V4L2_CAP_VIDEO_OVERLAY |
1355#endif
1356 0; 1119 0;
1357 if (UNSET != core->tuner_type) 1120 if (UNSET != core->tuner_type)
1358 cap->capabilities |= V4L2_CAP_TUNER; 1121 cap->capabilities |= V4L2_CAP_TUNER;
@@ -1453,36 +1216,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1453 } 1216 }
1454 1217
1455 1218
1456#if 0
1457 /* needs review */
1458 case VIDIOC_G_AUDIO:
1459 {
1460 struct v4l2_audio *a = arg;
1461 unsigned int n = a->index;
1462
1463 memset(a,0,sizeof(*a));
1464 a->index = n;
1465 switch (n) {
1466 case 0:
1467 if ((CX88_VMUX_TELEVISION == INPUT(n)->type)
1468 || (CX88_VMUX_CABLE == INPUT(n)->type)) {
1469 strcpy(a->name,"Television");
1470 // FIXME figure out if stereo received and set V4L2_AUDCAP_STEREO.
1471 return 0;
1472 }
1473 break;
1474 case 1:
1475 if (CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q == core->board) {
1476 strcpy(a->name,"Line In");
1477 a->capability = V4L2_AUDCAP_STEREO;
1478 return 0;
1479 }
1480 break;
1481 }
1482 // Audio input not available.
1483 return -EINVAL;
1484 }
1485#endif
1486 1219
1487 /* --- capture ioctls ---------------------------------------- */ 1220 /* --- capture ioctls ---------------------------------------- */
1488 case VIDIOC_ENUM_FMT: 1221 case VIDIOC_ENUM_FMT:
@@ -1592,6 +1325,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1592 1325
1593 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1326 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1594 f->frequency = dev->freq; 1327 f->frequency = dev->freq;
1328
1329 cx88_call_i2c_clients(dev->core,VIDIOC_G_FREQUENCY,f);
1330
1595 return 0; 1331 return 0;
1596 } 1332 }
1597 case VIDIOC_S_FREQUENCY: 1333 case VIDIOC_S_FREQUENCY:
@@ -1846,6 +1582,14 @@ static void cx8800_vid_timeout(unsigned long data)
1846 spin_unlock_irqrestore(&dev->slock,flags); 1582 spin_unlock_irqrestore(&dev->slock,flags);
1847} 1583}
1848 1584
1585static char *cx88_vid_irqs[32] = {
1586 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
1587 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
1588 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
1589 "y_sync", "u_sync", "v_sync", "vbi_sync",
1590 "opc_err", "par_err", "rip_err", "pci_abort",
1591};
1592
1849static void cx8800_vid_irq(struct cx8800_dev *dev) 1593static void cx8800_vid_irq(struct cx8800_dev *dev)
1850{ 1594{
1851 struct cx88_core *core = dev->core; 1595 struct cx88_core *core = dev->core;
@@ -2013,7 +1757,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
2013{ 1757{
2014 struct cx8800_dev *dev; 1758 struct cx8800_dev *dev;
2015 struct cx88_core *core; 1759 struct cx88_core *core;
2016 struct tuner_addr tun_addr;
2017 int err; 1760 int err;
2018 1761
2019 dev = kmalloc(sizeof(*dev),GFP_KERNEL); 1762 dev = kmalloc(sizeof(*dev),GFP_KERNEL);
@@ -2087,22 +1830,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
2087 request_module("tuner"); 1830 request_module("tuner");
2088 if (core->tda9887_conf) 1831 if (core->tda9887_conf)
2089 request_module("tda9887"); 1832 request_module("tda9887");
2090 if (core->radio_type != UNSET) {
2091 tun_addr.v4l2_tuner = V4L2_TUNER_RADIO;
2092 tun_addr.type = core->radio_type;
2093 tun_addr.addr = core->radio_addr;
2094 cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE_ADDR, &tun_addr);
2095 }
2096 if (core->tuner_type != UNSET) {
2097 tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV;
2098 tun_addr.type = core->tuner_type;
2099 tun_addr.addr = core->tuner_addr;
2100 cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE_ADDR, &tun_addr);
2101 }
2102
2103 if (core->tda9887_conf)
2104 cx88_call_i2c_clients(dev->core,TDA9887_SET_CONFIG,&core->tda9887_conf);
2105
2106 /* register v4l devices */ 1833 /* register v4l devices */
2107 dev->video_dev = cx88_vdev_init(core,dev->pci, 1834 dev->video_dev = cx88_vdev_init(core,dev->pci,
2108 &cx8800_video_template,"video"); 1835 &cx8800_video_template,"video");
@@ -2212,10 +1939,8 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
2212 } 1939 }
2213 spin_unlock(&dev->slock); 1940 spin_unlock(&dev->slock);
2214 1941
2215#if 1
2216 /* FIXME -- shutdown device */ 1942 /* FIXME -- shutdown device */
2217 cx88_shutdown(dev->core); 1943 cx88_shutdown(dev->core);
2218#endif
2219 1944
2220 pci_save_state(pci_dev); 1945 pci_save_state(pci_dev);
2221 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { 1946 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
@@ -2237,10 +1962,8 @@ static int cx8800_resume(struct pci_dev *pci_dev)
2237 pci_set_power_state(pci_dev, PCI_D0); 1962 pci_set_power_state(pci_dev, PCI_D0);
2238 pci_restore_state(pci_dev); 1963 pci_restore_state(pci_dev);
2239 1964
2240#if 1
2241 /* FIXME: re-initialize hardware */ 1965 /* FIXME: re-initialize hardware */
2242 cx88_reset(dev->core); 1966 cx88_reset(dev->core);
2243#endif
2244 1967
2245 /* restart video+vbi capture */ 1968 /* restart video+vbi capture */
2246 spin_lock(&dev->slock); 1969 spin_lock(&dev->slock);
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index bc5e038bc0fe..307beae04f2a 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88.h,v 1.67 2005/07/01 12:10:07 mkrufky Exp $ 2 * $Id: cx88.h,v 1.68 2005/07/07 14:17:47 mchehab Exp $
3 * 3 *
4 * v4l2 device driver for cx2388x based TV cards 4 * v4l2 device driver for cx2388x based TV cards
5 * 5 *
@@ -82,9 +82,9 @@ struct cx88_tvnorm {
82static unsigned int inline norm_maxw(struct cx88_tvnorm *norm) 82static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
83{ 83{
84 return (norm->id & V4L2_STD_625_50) ? 768 : 640; 84 return (norm->id & V4L2_STD_625_50) ? 768 : 640;
85// return (norm->id & V4L2_STD_625_50) ? 720 : 640;
86} 85}
87 86
87
88static unsigned int inline norm_maxh(struct cx88_tvnorm *norm) 88static unsigned int inline norm_maxh(struct cx88_tvnorm *norm)
89{ 89{
90 return (norm->id & V4L2_STD_625_50) ? 576 : 480; 90 return (norm->id & V4L2_STD_625_50) ? 576 : 480;
@@ -220,7 +220,6 @@ struct cx88_subid {
220#define RESOURCE_VBI 4 220#define RESOURCE_VBI 4
221 221
222#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */ 222#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */
223//#define BUFFER_TIMEOUT (HZ*2)
224 223
225/* buffer for one video frame */ 224/* buffer for one video frame */
226struct cx88_buffer { 225struct cx88_buffer {
@@ -336,11 +335,6 @@ struct cx8800_dev {
336 struct pci_dev *pci; 335 struct pci_dev *pci;
337 unsigned char pci_rev,pci_lat; 336 unsigned char pci_rev,pci_lat;
338 337
339#if 0
340 /* video overlay */
341 struct v4l2_framebuffer fbuf;
342 struct cx88_buffer *screen;
343#endif
344 338
345 /* capture queues */ 339 /* capture queues */
346 struct cx88_dmaqueue vidq; 340 struct cx88_dmaqueue vidq;
@@ -435,8 +429,6 @@ struct cx8802_dev {
435/* ----------------------------------------------------------- */ 429/* ----------------------------------------------------------- */
436/* cx88-core.c */ 430/* cx88-core.c */
437 431
438extern char *cx88_vid_irqs[32];
439extern char *cx88_mpeg_irqs[32];
440extern void cx88_print_irqbits(char *name, char *tag, char **strings, 432extern void cx88_print_irqbits(char *name, char *tag, char **strings,
441 u32 bits, u32 mask); 433 u32 bits, u32 mask);
442extern void cx88_print_ioctl(char *name, unsigned int cmd); 434extern void cx88_print_ioctl(char *name, unsigned int cmd);