Skip to content

Commit

Permalink
[PATCH] v4l: CX88 cards update
Browse files Browse the repository at this point in the history
This patch adds support for various CX88 cards and allows specifying
card addresses.

Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Michael Krufky <mkrufky@m1k.net>
Signed-off-by: cybercide@f2s.com <cybercide@f2s.com>
Signed-off-by: Catalin Climov <catalin@climov.com>
Signed-off-by: Nickolay V Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Mauro Carvalho Chehab authored and Linus Torvalds committed Jun 24, 2005
1 parent 2d03e28 commit b45009b
Show file tree
Hide file tree
Showing 13 changed files with 778 additions and 236 deletions.
488 changes: 402 additions & 86 deletions drivers/media/video/cx88/cx88-blackbird.c

Large diffs are not rendered by default.

235 changes: 161 additions & 74 deletions drivers/media/video/cx88/cx88-cards.c

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions drivers/media/video/cx88/cx88-core.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: cx88-core.c,v 1.24 2005/01/19 12:01:55 kraxel Exp $
* $Id: cx88-core.c,v 1.28 2005/06/12 04:19:19 mchehab Exp $
*
* device driver for Conexant 2388x based TV cards
* driver core
Expand Down Expand Up @@ -51,12 +51,15 @@ module_param(latency,int,0444);
MODULE_PARM_DESC(latency,"pci latency timer");

static unsigned int tuner[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
static unsigned int radio[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
static unsigned int card[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };

module_param_array(tuner, int, NULL, 0444);
module_param_array(radio, int, NULL, 0444);
module_param_array(card, int, NULL, 0444);

MODULE_PARM_DESC(tuner,"tuner type");
MODULE_PARM_DESC(radio,"radio tuner type");
MODULE_PARM_DESC(card,"card type");

static unsigned int nicam = 0;
Expand Down Expand Up @@ -429,7 +432,7 @@ int cx88_sram_channel_setup(struct cx88_core *core,
/* ------------------------------------------------------------------ */
/* debug helper code */

static int cx88_risc_decode(u32 risc)
int cx88_risc_decode(u32 risc)
{
static char *instr[16] = {
[ RISC_SYNC >> 28 ] = "sync",
Expand Down Expand Up @@ -1173,8 +1176,20 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
"insmod option" : "autodetected");

core->tuner_type = tuner[core->nr];
core->radio_type = radio[core->nr];
if (UNSET == core->tuner_type)
core->tuner_type = cx88_boards[core->board].tuner_type;
if (UNSET == core->radio_type)
core->radio_type = cx88_boards[core->board].radio_type;
if (!core->tuner_addr)
core->tuner_addr = cx88_boards[core->board].tuner_addr;
if (!core->radio_addr)
core->radio_addr = cx88_boards[core->board].radio_addr;

printk(KERN_INFO "TV tuner %d at 0x%02x, Radio tuner %d at 0x%02x\n",
core->tuner_type, core->tuner_addr<<1,
core->radio_type, core->radio_addr<<1);

core->tda9887_conf = cx88_boards[core->board].tda9887_conf;

/* init hardware */
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cx88/cx88-dvb.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: cx88-dvb.c,v 1.31 2005/03/07 15:58:05 kraxel Exp $
* $Id: cx88-dvb.c,v 1.33 2005/06/12 04:19:19 mchehab Exp $
*
* device driver for Conexant 2388x based TV cards
* MPEG Transport Stream (DVB) routines
Expand Down
18 changes: 15 additions & 3 deletions drivers/media/video/cx88/cx88-i2c.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: cx88-i2c.c,v 1.20 2005/02/15 15:59:35 kraxel Exp $
$Id: cx88-i2c.c,v 1.23 2005/06/12 04:19:19 mchehab Exp $
cx88-i2c.c -- all the i2c code is here
Expand Down Expand Up @@ -91,15 +91,27 @@ static int cx8800_bit_getsda(void *data)

static int attach_inform(struct i2c_client *client)
{
struct tuner_addr tun_addr;
struct cx88_core *core = i2c_get_adapdata(client->adapter);

dprintk(1, "i2c attach [addr=0x%x,client=%s]\n",
client->addr, i2c_clientname(client));
if (!client->driver->command)
return 0;

if (core->tuner_type != UNSET)
client->driver->command(client, TUNER_SET_TYPE, &core->tuner_type);
if (core->radio_type != UNSET) {
tun_addr.v4l2_tuner = V4L2_TUNER_RADIO;
tun_addr.type = core->radio_type;
tun_addr.addr = core->radio_addr;
client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr);
}
if (core->tuner_type != UNSET) {
tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV;
tun_addr.type = core->tuner_type;
tun_addr.addr = core->tuner_addr;
client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr);
}

if (core->tda9887_conf)
client->driver->command(client, TDA9887_SET_CONFIG, &core->tda9887_conf);
return 0;
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/video/cx88/cx88-input.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: cx88-input.c,v 1.9 2005/03/04 09:12:23 kraxel Exp $
* $Id: cx88-input.c,v 1.11 2005/05/22 20:57:56 nsh Exp $
*
* Device driver for GPIO attached remote control interfaces
* on Conexant 2388x based TV/DVB cards.
Expand Down Expand Up @@ -235,6 +235,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
/* detect & configure */
switch (core->board) {
case CX88_BOARD_DNTV_LIVE_DVB_T:
case CX88_BOARD_KWORLD_DVB_T:
ir_codes = ir_codes_dntv_live_dvb_t;
ir->gpio_addr = MO_GP1_IO;
ir->mask_keycode = 0x1f;
Expand Down Expand Up @@ -269,6 +270,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
ir->polling = 1; // ms
break;
}

if (NULL == ir_codes) {
kfree(ir);
return -ENODEV;
Expand Down
52 changes: 42 additions & 10 deletions drivers/media/video/cx88/cx88-mpeg.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: cx88-mpeg.c,v 1.25 2005/03/07 14:18:00 kraxel Exp $
* $Id: cx88-mpeg.c,v 1.26 2005/06/03 13:31:51 mchehab Exp $
*
* Support for the mpeg transport stream transfers
* PCI function #2 of the cx2388x.
Expand Down Expand Up @@ -55,7 +55,7 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
{
struct cx88_core *core = dev->core;

dprintk(1, "cx8802_start_mpegport_dma %d\n", buf->vb.width);
dprintk(0, "cx8802_start_dma %d\n", buf->vb.width);

/* setup fifo + format */
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28],
Expand Down Expand Up @@ -100,18 +100,21 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
q->count = 1;

/* enable irqs */
dprintk( 0, "setting the interrupt mask\n" );
cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04);
cx_write(MO_TS_INTMSK, 0x1f0011);
cx_set(MO_TS_INTMSK, 0x1f0011);
//cx_write(MO_TS_INTMSK, 0x0f0011);

/* start dma */
cx_write(MO_DEV_CNTRL2, (1<<5)); /* FIXME: s/write/set/ ??? */
cx_write(MO_TS_DMACNTRL, 0x11);
cx_set(MO_DEV_CNTRL2, (1<<5));
cx_set(MO_TS_DMACNTRL, 0x11);
return 0;
}

static int cx8802_stop_dma(struct cx8802_dev *dev)
{
struct cx88_core *core = dev->core;
dprintk( 0, "cx8802_stop_dma\n" );

/* stop dma */
cx_clear(MO_TS_DMACNTRL, 0x11);
Expand All @@ -131,8 +134,12 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
struct cx88_buffer *buf;
struct list_head *item;

dprintk( 0, "cx8802_restart_queue\n" );
if (list_empty(&q->active))
{
dprintk( 0, "cx8802_restart_queue: queue is empty\n" );
return 0;
}

buf = list_entry(q->active.next, struct cx88_buffer, vb.queue);
dprintk(2,"restart_queue [%p/%d]: restart dma\n",
Expand Down Expand Up @@ -182,27 +189,32 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
struct cx88_buffer *prev;
struct cx88_dmaqueue *q = &dev->mpegq;

dprintk( 1, "cx8802_buf_queue\n" );
/* add jump to stopper */
buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);

if (list_empty(&q->active)) {
dprintk( 0, "queue is empty - first active\n" );
list_add_tail(&buf->vb.queue,&q->active);
cx8802_start_dma(dev, q, buf);
buf->vb.state = STATE_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2,"[%p/%d] %s - first active\n",
dprintk(0,"[%p/%d] %s - first active\n",
buf, buf->vb.i, __FUNCTION__);
//udelay(100);

} else {
dprintk( 1, "queue is not empty - append to active\n" );
prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue);
list_add_tail(&buf->vb.queue,&q->active);
buf->vb.state = STATE_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
dprintk(2,"[%p/%d] %s - append to active\n",
dprintk( 1, "[%p/%d] %s - append to active\n",
buf, buf->vb.i, __FUNCTION__);
//udelay(100);
}
}

Expand All @@ -224,14 +236,18 @@ static void do_cancel_buffers(struct cx8802_dev *dev, char *reason, int restart)
buf, buf->vb.i, reason, (unsigned long)buf->risc.dma);
}
if (restart)
{
dprintk(0, "restarting queue\n" );
cx8802_restart_queue(dev,q);
}
spin_unlock_irqrestore(&dev->slock,flags);
}

void cx8802_cancel_buffers(struct cx8802_dev *dev)
{
struct cx88_dmaqueue *q = &dev->mpegq;

dprintk( 1, "cx8802_cancel_buffers" );
del_timer_sync(&q->timeout);
cx8802_stop_dma(dev);
do_cancel_buffers(dev,"cancel",0);
Expand All @@ -241,7 +257,7 @@ static void cx8802_timeout(unsigned long data)
{
struct cx8802_dev *dev = (struct cx8802_dev*)data;

dprintk(1, "%s\n",__FUNCTION__);
dprintk(0, "%s\n",__FUNCTION__);

if (debug)
cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]);
Expand All @@ -254,12 +270,17 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
struct cx88_core *core = dev->core;
u32 status, mask, count;

dprintk( 1, "cx8802_mpeg_irq\n" );
status = cx_read(MO_TS_INTSTAT);
mask = cx_read(MO_TS_INTMSK);
if (0 == (status & mask))
return;

cx_write(MO_TS_INTSTAT, status);
#if 0
cx88_print_irqbits(core->name, "irq mpeg ",
cx88_mpeg_irqs, status, mask);
#endif
if (debug || (status & mask & ~0xff))
cx88_print_irqbits(core->name, "irq mpeg ",
cx88_mpeg_irqs, status, mask);
Expand All @@ -273,6 +294,7 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)

/* risc1 y */
if (status & 0x01) {
dprintk( 1, "wake up\n" );
spin_lock(&dev->slock);
count = cx_read(MO_TS_GPCNT);
cx88_wakeup(dev->core, &dev->mpegq, count);
Expand All @@ -288,24 +310,30 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)

/* other general errors */
if (status & 0x1f0100) {
dprintk( 0, "general errors: 0x%08x\n", status & 0x1f0100 );
spin_lock(&dev->slock);
cx8802_stop_dma(dev);
cx8802_restart_queue(dev,&dev->mpegq);
spin_unlock(&dev->slock);
}
}

#define MAX_IRQ_LOOP 10

static irqreturn_t cx8802_irq(int irq, void *dev_id, struct pt_regs *regs)
{
struct cx8802_dev *dev = dev_id;
struct cx88_core *core = dev->core;
u32 status;
int loop, handled = 0;

for (loop = 0; loop < 10; loop++) {
for (loop = 0; loop < MAX_IRQ_LOOP; loop++) {
status = cx_read(MO_PCI_INTSTAT) & (core->pci_irqmask | 0x04);
if (0 == status)
goto out;
dprintk( 1, "cx8802_irq\n" );
dprintk( 1, " loop: %d/%d\n", loop, MAX_IRQ_LOOP );
dprintk( 1, " status: %d\n", status );
handled = 1;
cx_write(MO_PCI_INTSTAT, status);

Expand All @@ -314,7 +342,8 @@ static irqreturn_t cx8802_irq(int irq, void *dev_id, struct pt_regs *regs)
if (status & 0x04)
cx8802_mpeg_irq(dev);
};
if (10 == loop) {
if (MAX_IRQ_LOOP == loop) {
dprintk( 0, "clearing mask\n" );
printk(KERN_WARNING "%s/0: irq loop -- clearing mask\n",
core->name);
cx_write(MO_PCI_INTMSK,0);
Expand Down Expand Up @@ -378,6 +407,7 @@ int cx8802_init_common(struct cx8802_dev *dev)

void cx8802_fini_common(struct cx8802_dev *dev)
{
dprintk( 2, "cx8802_fini_common\n" );
cx8802_stop_dma(dev);
pci_disable_device(dev->pci);

Expand All @@ -399,6 +429,7 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
/* stop mpeg dma */
spin_lock(&dev->slock);
if (!list_empty(&dev->mpegq.active)) {
dprintk( 2, "suspend\n" );
printk("%s: suspend mpeg\n", core->name);
cx8802_stop_dma(dev);
del_timer(&dev->mpegq.timeout);
Expand Down Expand Up @@ -463,4 +494,5 @@ EXPORT_SYMBOL(cx8802_resume_common);
* Local variables:
* c-basic-offset: 8
* End:
* kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off
*/
3 changes: 2 additions & 1 deletion drivers/media/video/cx88/cx88-reg.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: cx88-reg.h,v 1.6 2004/10/13 10:39:00 kraxel Exp $
$Id: cx88-reg.h,v 1.7 2005/06/03 13:31:51 mchehab Exp $
cx88x-hw.h - CX2388x register offsets
Expand Down Expand Up @@ -397,6 +397,7 @@
#define AUD_RATE_ADJ4 0x3205e4
#define AUD_RATE_ADJ5 0x3205e8
#define AUD_APB_IN_RATE_ADJ 0x3205ec
#define AUD_I2SCNTL 0x3205ec
#define AUD_PHASE_FIX_CTL 0x3205f0
#define AUD_PLL_PRESCALE 0x320600
#define AUD_PLL_DDS 0x320604
Expand Down
Loading

0 comments on commit b45009b

Please sign in to comment.