vserver 2.0 rc7
[linux-2.6.git] / drivers / media / video / cx88 / cx88-core.c
index 3239c81..1ff79b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cx88-core.c,v 1.15 2004/10/25 11:26:36 kraxel Exp $
+ * $Id: cx88-core.c,v 1.24 2005/01/19 12:01:55 kraxel Exp $
  *
  * device driver for Conexant 2388x based TV cards
  * driver core
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/kmod.h>
@@ -62,6 +63,10 @@ static unsigned int nicam = 0;
 module_param(nicam,int,0644);
 MODULE_PARM_DESC(nicam,"tv audio is nicam");
 
+static unsigned int nocomb = 0;
+module_param(nocomb,int,0644);
+MODULE_PARM_DESC(nocomb,"disable comb filter");
+
 #define dprintk(level,fmt, arg...)     if (core_debug >= level)        \
        printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
 
@@ -424,7 +429,7 @@ int cx88_sram_channel_setup(struct cx88_core *core,
 /* ------------------------------------------------------------------ */
 /* debug helper code                                                  */
 
-int cx88_risc_decode(u32 risc)
+static int cx88_risc_decode(u32 risc)
 {
        static char *instr[16] = {
                [ RISC_SYNC    >> 28 ] = "sync",
@@ -462,6 +467,7 @@ int cx88_risc_decode(u32 risc)
        return incr[risc >> 28] ? incr[risc >> 28] : 1;
 }
 
+#if 0 /* currently unused, but useful for debugging */
 void cx88_risc_disasm(struct cx88_core *core,
                      struct btcx_riscmem *risc)
 {
@@ -479,6 +485,7 @@ void cx88_risc_disasm(struct cx88_core *core,
                        break;
        }
 }
+#endif
 
 void cx88_sram_channel_dump(struct cx88_core *core,
                            struct sram_channel *ch)
@@ -535,7 +542,7 @@ void cx88_sram_channel_dump(struct cx88_core *core,
               core->name,cx_read(ch->cnt2_reg));
 }
 
-char *cx88_pci_irqs[32] = {
+static char *cx88_pci_irqs[32] = {
        "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
        "src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
        "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
@@ -579,10 +586,19 @@ void cx88_print_irqbits(char *name, char *tag, char **strings,
 
 /* ------------------------------------------------------------------ */
 
-void cx88_irq(struct cx88_core *core, u32 status, u32 mask)
+int cx88_core_irq(struct cx88_core *core, u32 status)
 {
-       cx88_print_irqbits(core->name, "irq pci",
-                          cx88_pci_irqs, status, mask);
+       int handled = 0;
+
+       if (status & (1<<18)) {
+               cx88_ir_irq(core);
+               handled++;
+       }
+       if (!handled)
+               cx88_print_irqbits(core->name, "irq pci",
+                                  cx88_pci_irqs, status,
+                                  core->pci_irqmask);
+       return handled;
 }
 
 void cx88_wakeup(struct cx88_core *core,
@@ -800,6 +816,8 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
                value |= (1 << 0); // 3-tap interpolation
        if (width < 193)
                value |= (1 << 1); // 5-tap interpolation
+       if (nocomb)
+               value |= (3 << 5); // disable comb filter
 
        cx_write(MO_FILTER_EVEN,  value);
        cx_write(MO_FILTER_ODD,   value);
@@ -887,8 +905,8 @@ static int set_tvaudio(struct cx88_core *core)
        cx88_set_tvaudio(core);
        // cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO);
 
-       cx_write(MO_AUDD_LNGTH, 128/8);  /* fifo size */
-       cx_write(MO_AUDR_LNGTH, 128/8);  /* fifo size */
+       cx_write(MO_AUDD_LNGTH,    128); /* fifo size */
+       cx_write(MO_AUDR_LNGTH,    128); /* fifo size */
        cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */
        return 0;
 }
@@ -969,6 +987,9 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
        cx_write(MO_VBI_PACKET, ((1 << 11) | /* (norm_vdelay(norm)   << 11) | */
                                 norm_vbipack(norm)));
 
+       // this is needed as well to set all tvnorm parameter
+       cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED);
+
        // audio
        set_tvaudio(core);
 
@@ -1105,9 +1126,10 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
                goto fail_unlock;
 
        memset(core,0,sizeof(*core));
+       atomic_inc(&core->refcount);
        core->pci_bus  = pci->bus->number;
        core->pci_slot = PCI_SLOT(pci->devfn);
-       atomic_inc(&core->refcount);
+       core->pci_irqmask = 0x00fc00;
 
        core->nr = cx88_devcount++;
        sprintf(core->name,"cx88[%d]",core->nr);
@@ -1150,6 +1172,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
        cx88_reset(core);
        cx88_i2c_init(core,pci);
        cx88_card_setup(core);
+       cx88_ir_init(core,pci);
 
        up(&devlist);
        return core;
@@ -1170,6 +1193,7 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
                return;
 
        down(&devlist);
+       cx88_ir_fini(core);
        if (0 == core->i2c_rc)
                i2c_bit_del_bus(&core->i2c_adap);
        list_del(&core->devlist);
@@ -1182,12 +1206,11 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
 /* ------------------------------------------------------------------ */
 
 EXPORT_SYMBOL(cx88_print_ioctl);
-EXPORT_SYMBOL(cx88_pci_irqs);
 EXPORT_SYMBOL(cx88_vid_irqs);
 EXPORT_SYMBOL(cx88_mpeg_irqs);
 EXPORT_SYMBOL(cx88_print_irqbits);
 
-EXPORT_SYMBOL(cx88_irq);
+EXPORT_SYMBOL(cx88_core_irq);
 EXPORT_SYMBOL(cx88_wakeup);
 EXPORT_SYMBOL(cx88_reset);
 EXPORT_SYMBOL(cx88_shutdown);
@@ -1197,8 +1220,6 @@ EXPORT_SYMBOL(cx88_risc_databuffer);
 EXPORT_SYMBOL(cx88_risc_stopper);
 EXPORT_SYMBOL(cx88_free_buffer);
 
-EXPORT_SYMBOL(cx88_risc_disasm);
-
 EXPORT_SYMBOL(cx88_sram_channels);
 EXPORT_SYMBOL(cx88_sram_channel_setup);
 EXPORT_SYMBOL(cx88_sram_channel_dump);