diff options
author | Gerd Knorr <devnull@localhost> | 2004-07-30 11:14:05 +0000 |
---|---|---|
committer | Gerd Knorr <devnull@localhost> | 2004-07-30 11:14:05 +0000 |
commit | bc8eeb034d24fe27a013559c33c496c2fd4a678b (patch) | |
tree | 82f3f83ac89b2469abb64bcd332533b7d2b18818 /linux/drivers/media/video/cx88/cx88-core.c | |
parent | 93b2339c38d21f324ed5945efa4712385601341c (diff) | |
download | mediapointer-dvb-s2-bc8eeb034d24fe27a013559c33c496c2fd4a678b.tar.gz mediapointer-dvb-s2-bc8eeb034d24fe27a013559c33c496c2fd4a678b.tar.bz2 |
- cx88: more reorganization stuff.
Diffstat (limited to 'linux/drivers/media/video/cx88/cx88-core.c')
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-core.c | 127 |
1 files changed, 125 insertions, 2 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-core.c b/linux/drivers/media/video/cx88/cx88-core.c index 31ad10653..b0d80a681 100644 --- a/linux/drivers/media/video/cx88/cx88-core.c +++ b/linux/drivers/media/video/cx88/cx88-core.c @@ -29,6 +29,7 @@ #include <linux/sound.h> #include <linux/interrupt.h> #include <linux/pci.h> +#include <linux/delay.h> #include <linux/videodev.h> #include "cx88.h" @@ -55,7 +56,7 @@ static unsigned int card[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; MODULE_PARM(card,"1-" __stringify(CX88_MAXBOARDS) "i"); MODULE_PARM_DESC(card,"card type"); -#define dprintk(fmt, arg...) if (core_debug) \ +#define dprintk(level,fmt, arg...) if (core_debug >= level) \ printk(KERN_DEBUG "%s: " fmt, core->name , ## arg) static unsigned int cx88_devcount; @@ -382,7 +383,7 @@ int cx88_sram_channel_setup(struct cx88_core *core, cx_write(ch->cnt1_reg, (bpl >> 3) -1); cx_write(ch->cnt2_reg, (lines*16) >> 3); - dprintk("sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines); + dprintk(1,"sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines); return 0; } @@ -513,6 +514,14 @@ char *cx88_vid_irqs[32] = { "y_sync", "u_sync", "v_sync", "vbi_sync", "opc_err", "par_err", "rip_err", "pci_abort", }; +char *cx88_mpeg_irqs[32] = { + "ts_risci1", NULL, NULL, NULL, + "ts_risci2", NULL, NULL, NULL, + "ts_oflow", NULL, NULL, NULL, + "ts_sync", NULL, NULL, NULL, + "opc_err", "par_err", "rip_err", "pci_abort", + "ts_err?", +}; void cx88_print_irqbits(char *name, char *tag, char **strings, u32 bits, u32 mask) @@ -533,6 +542,113 @@ void cx88_print_irqbits(char *name, char *tag, char **strings, /* ------------------------------------------------------------------ */ +void cx88_irq(struct cx88_core *core, u32 status, u32 mask) +{ + cx88_print_irqbits(core->name, "irq pci", + cx88_pci_irqs, status, mask); +} + +void cx88_wakeup(struct cx88_core *core, + struct cx88_dmaqueue *q, u32 count) +{ + struct cx88_buffer *buf; + + for (;;) { + if (list_empty(&q->active)) + break; + buf = list_entry(q->active.next, + struct cx88_buffer, vb.queue); + if (buf->count > count) + break; + do_gettimeofday(&buf->vb.ts); + dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i, + count, buf->count); + buf->vb.state = STATE_DONE; + list_del(&buf->vb.queue); + wake_up(&buf->vb.done); + } + if (list_empty(&q->active)) { + del_timer(&q->timeout); + } else { + mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); + } +} + +void cx88_shutdown(struct cx88_core *core) +{ + /* disable RISC controller + IRQs */ + cx_write(MO_DEV_CNTRL2, 0); + + /* stop dma transfers */ + cx_write(MO_VID_DMACNTRL, 0x0); + cx_write(MO_AUD_DMACNTRL, 0x0); + cx_write(MO_TS_DMACNTRL, 0x0); + cx_write(MO_VIP_DMACNTRL, 0x0); + cx_write(MO_GPHST_DMACNTRL, 0x0); + + /* stop interupts */ + cx_write(MO_PCI_INTMSK, 0x0); + cx_write(MO_VID_INTMSK, 0x0); + cx_write(MO_AUD_INTMSK, 0x0); + cx_write(MO_TS_INTMSK, 0x0); + cx_write(MO_VIP_INTMSK, 0x0); + cx_write(MO_GPHST_INTMSK, 0x0); + + /* stop capturing */ + cx_write(VID_CAPTURE_CONTROL, 0); +} + +int cx88_reset(struct cx88_core *core) +{ + dprintk(1,"%s\n",__FUNCTION__); + cx88_shutdown(core); + + /* clear irq status */ + cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int + cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int + cx_write(MO_INT1_STAT, 0xFFFFFFFF); // Clear RISC int + + /* wait a bit */ + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ/10); + + /* init sram */ + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], 720*4, 0); + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH22], 128, 0); + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH23], 128, 0); + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH24], 128, 0); + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0); + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0); + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 512, 0); + + /* misc init ... */ + cx_write(MO_INPUT_FORMAT, ((1 << 13) | // agc enable + (1 << 12) | // agc gain + (1 << 11) | // adaptibe agc + (0 << 10) | // chroma agc + (0 << 9) | // ckillen + (7))); + + /* setup image format */ + cx_andor(MO_COLOR_CTRL, 0x4000, 0x4000); + + /* setup FIFO Threshholds */ + cx_write(MO_PDMA_STHRSH, 0x0807); + cx_write(MO_PDMA_DTHRSH, 0x0807); + + /* fixes flashing of image */ + cx_write(MO_AGC_SYNC_TIP1, 0x0380000F); + cx_write(MO_AGC_BACK_VBI, 0x00E00555); + + cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int + cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int + cx_write(MO_INT1_STAT, 0xFFFFFFFF); // Clear RISC int + + return 0; +} + +/* ------------------------------------------------------------------ */ + static int cx88_pci_quirks(char *name, struct pci_dev *pci) { unsigned int lat = UNSET; @@ -687,7 +803,9 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) core->tda9887_conf = cx88_boards[core->board].tda9887_conf; /* init hardware */ + cx88_reset(core); cx88_i2c_init(core,pci); + cx88_card_setup(core); up(&devlist); return core; @@ -724,6 +842,11 @@ EXPORT_SYMBOL(cx88_pci_irqs); EXPORT_SYMBOL(cx88_vid_irqs); EXPORT_SYMBOL(cx88_print_irqbits); +EXPORT_SYMBOL(cx88_irq); +EXPORT_SYMBOL(cx88_wakeup); +EXPORT_SYMBOL(cx88_reset); +EXPORT_SYMBOL(cx88_shutdown); + EXPORT_SYMBOL(cx88_risc_buffer); EXPORT_SYMBOL(cx88_risc_stopper); EXPORT_SYMBOL(cx88_free_buffer); |