summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <devnull@localhost>2005-12-14 16:21:46 +0000
committerMauro Carvalho Chehab <devnull@localhost>2005-12-14 16:21:46 +0000
commitee17490340127eb30b60fd662e4e3fc6ab3295a6 (patch)
tree49f6cff30b4e114e89770336b097926f1d00c852 /linux
parentac4e05df065bba889cae236d96371a3f170b1eb4 (diff)
downloadmediapointer-dvb-s2-ee17490340127eb30b60fd662e4e3fc6ab3295a6.tar.gz
mediapointer-dvb-s2-ee17490340127eb30b60fd662e4e3fc6ab3295a6.tar.bz2
Several fixes at videobuf and alsa stuff. Still doesn't work.
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/video/cx88/cx88-alsa.c121
1 files changed, 91 insertions, 30 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-alsa.c b/linux/drivers/media/video/cx88/cx88-alsa.c
index 74ca95624..dc9e66cba 100644
--- a/linux/drivers/media/video/cx88/cx88-alsa.c
+++ b/linux/drivers/media/video/cx88/cx88-alsa.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-alsa.c,v 1.16 2005/12/13 22:59:37 mchehab Exp $
+ * $Id: cx88-alsa.c,v 1.17 2005/12/14 16:21:46 mchehab Exp $
*
* Support for audio capture
* PCI function #1 of the cx2388x.
@@ -93,6 +93,8 @@ struct cx88_audio_dev {
u32 __iomem *mmio;
long opened;
snd_pcm_substream_t *substream;
+
+ struct videobuf_dmabuf dma;
};
typedef struct cx88_audio_dev snd_cx88_card_t;
@@ -178,9 +180,11 @@ int _cx88_start_audio_dma(snd_cx88_card_t *chip,
/* reset counter */
cx_write(MO_AUDD_GPCNTRL,GP_COUNT_CONTROL_RESET);
+ dprintk(1,"Enabling IRQ\n");
/* enable irqs */
cx_set(MO_PCI_INTMSK, chip->core->pci_irqmask | 0x02);
+
/* Enables corresponding bits at AUD_INT_STAT */
#if 1 /*keep*/
/* Maybe necessary to enable other errors */
@@ -368,7 +372,8 @@ static void snd_cx88_pci_error(bt87x_t *chip, unsigned int status)
static int
buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
{
- struct cx8801_fh *fh = q->priv_data;
+ struct cx8801_fh *fh = q->priv_data;
+ struct cx88_audio_dev *chip = fh->dev;
*size = fh->size;
if (0 == *count)
@@ -378,6 +383,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
*count = 2;
if (*count > 32)
*count = 32;
+
+ dprintk(2,"Count=%d, size=%d\n" ,*count,*size);
return 0;
}
@@ -431,6 +438,9 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
struct cx88_audio_dev *chip = fh->dev;
struct cx88_dmaqueue *q = &chip->q;
+
+ dprintk(2,"Buffer 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);
@@ -443,9 +453,7 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue,&q->active);
-
_cx88_start_audio_dma(chip, q, buf);
-
buf->vb.state = STATE_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
@@ -487,35 +495,47 @@ static struct videobuf_queue_ops audio_qops = {
.buf_queue = buffer_queue,
.buf_release = buffer_release,
};
-#if 0
+
static int dsp_buffer_init(snd_cx88_card_t *chip)
{
int err;
+ struct cx8801_fh *fh;
- BUG_ON(!chip->dmasound.bufsize);
+ BUG_ON(!chip->dma_size);
/* allocate + initialize per filehandle data */
fh = kmalloc(sizeof(*fh),GFP_KERNEL);
if (NULL == fh)
return -ENOMEM;
memset(fh,0,sizeof(*fh));
- file->private_data = fh;
- fh->dev = dev;
+ fh->dev = chip;
- videobuf_queue_init(&fh->mpegq, &audio_qops,
- dev->pci, &dev->slock,
+ videobuf_queue_init(&fh->vb_q, &audio_qops,
+ chip->pci, &chip->reg_lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx88_buffer),
fh);
- videobuf_dma_init(&chip->dmasound.dma);
- err = videobuf_dma_init_kernel(&chip->dmasound.dma, PCI_DMA_FROMDEVICE,
- (chip->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
+ videobuf_read_start(&fh->vb_q);
+ videobuf_dma_init(&chip->dma);
+ err = videobuf_dma_init_kernel(&chip->dma, PCI_DMA_FROMDEVICE,
+ (chip->dma_size + PAGE_SIZE) >> PAGE_SHIFT);
if (0 != err)
return err;
return 0;
}
-#endif
+
+static int dsp_buffer_free(snd_cx88_card_t *chip)
+{
+ BUG_ON(!chip->dma_size);
+
+ videobuf_dma_free(&chip->dma);
+
+ chip->dma_size = 0;
+
+ return 0;
+}
+
/****************************************************************************
ALSA PCM Interface
****************************************************************************/
@@ -535,11 +555,11 @@ static snd_pcm_hardware_t snd_cx88_digital_hw = {
.rate_max = 48000,
.channels_min = 2,
.channels_max = 2,
- .buffer_bytes_max = 255 * 4092,
- .period_bytes_min = 32,
- .period_bytes_max = 4092,
+ .buffer_bytes_max = (1024*256),
+ .period_bytes_min = 64,
+ .period_bytes_max = 256,
.periods_min = 2,
- .periods_max = 255,
+ .periods_max = 1024,
};
/*
@@ -561,6 +581,7 @@ static int snd_cx88_pcm_open(snd_pcm_substream_t *substream)
snd_card_cx88_pcm_t *pcm;
int err;
+ dprintk(1,"Opening PCM!\n");
if (test_and_set_bit(0, &chip->opened))
return -EBUSY;
@@ -569,7 +590,6 @@ static int snd_cx88_pcm_open(snd_pcm_substream_t *substream)
goto _error;
chip->substream = substream;
- return 0;
pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
if (pcm == NULL) {
@@ -584,7 +604,10 @@ static int snd_cx88_pcm_open(snd_pcm_substream_t *substream)
runtime->private_free = snd_card_cx88_runtime_free;
runtime->hw = snd_cx88_digital_hw;
+ dprintk(1,"Opened PCM!\n");
+ return 0;
_error:
+ dprintk(1,"Error opening PCM!\n");
clear_bit(0, &chip->opened);
smp_mb__after_clear_bit();
return err;
@@ -609,6 +632,23 @@ static int snd_cx88_close(snd_pcm_substream_t *substream)
static int snd_cx88_hw_params(snd_pcm_substream_t * substream,
snd_pcm_hw_params_t * hw_params)
{
+ int err;
+ snd_cx88_card_t *chip = snd_pcm_substream_chip(substream);
+
+
+ chip->period_size = params_period_bytes(hw_params);
+ chip->dma_size = chip->period_size * params_periods(hw_params);
+
+ dprintk(1,"Setting buffer\n");
+
+
+ dsp_buffer_init(chip);
+ if (0 != (err = videobuf_dma_pci_map(chip->pci, &chip->dma))) {
+ dsp_buffer_free(chip);
+ return err;
+ }
+
+ dprintk(1,"Buffer ready\n");
return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
}
@@ -629,8 +669,7 @@ static int snd_cx88_prepare(snd_pcm_substream_t *substream)
spin_lock_irq(&chip->reg_lock);
- chip->dma_size = snd_pcm_lib_buffer_bytes(substream);
- chip->period_size = snd_pcm_lib_period_bytes(substream);
+ //err = dsp_buffer_init(chip);
spin_unlock_irq(&chip->reg_lock);
return 0;
@@ -645,13 +684,14 @@ static int snd_cx88_card_trigger(snd_pcm_substream_t *substream, int cmd)
snd_cx88_card_t *chip = snd_pcm_substream_chip(substream);
int err;
+ dprintk(2,"PCM Trigger");
spin_lock(&chip->reg_lock);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
// err=_cx88_start_audio_dma(chip);
case SNDRV_PCM_TRIGGER_STOP:
-// err=_cx88_stop_audio_dma(chip);
+ err=_cx88_stop_audio_dma(chip);
default:
err=-EINVAL;
}
@@ -915,8 +955,8 @@ static int __devinit snd_cx88_create(snd_card_t *card, struct pci_dev *pci,
#if 0
if (!request_mem_region(pci_resource_start(pci,0),
- pci_resource_len(pci,0),
- "CX88 audio")) {
+ pci_resource_len(pci,0),
+ "CX88 audio")) {
err = -EBUSY;
printk(KERN_ERR "%s: can't get MMIO memory @ 0x%lx\n",
"CX88 audio",pci_resource_start(pci,0));
@@ -1015,11 +1055,13 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
if (err < 0)
return (err);
-/*
- err = snd_cx88_pcm(chip, DEVICE_DIGITAL, "CX88 Digital");
- if (err < 0)
- goto fail_free;
-*/
+ //err = snd_cx88_pcm(chip, DEVICE_DIGITAL, "CX88 Digital");
+ err = snd_cx88_pcm(chip, 0, "CX88 Digital");
+ if (err < 0) {
+ snd_card_free(card);
+ return (err);
+ }
+
err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_capture_volume, chip));
if (err < 0) {
snd_card_free(card);
@@ -1052,7 +1094,26 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
*/
static void __devexit cx88_audio_finidev(struct pci_dev *pci)
{
- snd_card_free(pci_get_drvdata(pci));
+ struct cx88_audio_dev *card = pci_get_drvdata(pci);
+ struct cx88_core *core = card->core;
+
+ _cx88_stop_audio_dma(card);
+
+ pci_disable_device(pci);
+
+ /* unregister stuff */
+
+ free_irq(pci->irq, card);
+
+ /* free memory */
+
+ btcx_riscmem_free(card->pci,&card->q.stopper);
+ cx88_core_put(core,card->pci);
+
+ snd_card_free((void *)card);
+
+ kfree(card);
+
pci_set_drvdata(pci, NULL);
devno--;