aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-05-11 09:36:31 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-02 14:22:19 -0400
commitfecfedeb27ab9497cbdd2c6fb7972082a7ed9263 (patch)
treee81b9ee9c9c0278849d92f0b778ea964fa6f33b3 /drivers
parent952684035a91334dbe33b15063514cab5e7c6907 (diff)
V4L/DVB: Remove videobuf_sg_alloc abuse
The cx88 and cx25821 drivers abuse videobuf_buffer to handle audio data. Remove the abuse by creating private audio buffer structures with a videobuf_dmabuf field. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c29
-rw-r--r--drivers/staging/cx25821/cx25821-alsa.c29
2 files changed, 28 insertions, 30 deletions
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 07fe905f6575..ba499d04de4d 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -54,6 +54,12 @@
54 Data type declarations - Can be moded to a header file later 54 Data type declarations - Can be moded to a header file later
55 ****************************************************************************/ 55 ****************************************************************************/
56 56
57struct cx88_audio_buffer {
58 unsigned int bpl;
59 struct btcx_riscmem risc;
60 struct videobuf_dmabuf dma;
61};
62
57struct cx88_audio_dev { 63struct cx88_audio_dev {
58 struct cx88_core *core; 64 struct cx88_core *core;
59 struct cx88_dmaqueue q; 65 struct cx88_dmaqueue q;
@@ -75,7 +81,7 @@ struct cx88_audio_dev {
75 81
76 struct videobuf_dmabuf *dma_risc; 82 struct videobuf_dmabuf *dma_risc;
77 83
78 struct cx88_buffer *buf; 84 struct cx88_audio_buffer *buf;
79 85
80 struct snd_pcm_substream *substream; 86 struct snd_pcm_substream *substream;
81}; 87};
@@ -123,7 +129,7 @@ MODULE_PARM_DESC(debug,"enable debug messages");
123 129
124static int _cx88_start_audio_dma(snd_cx88_card_t *chip) 130static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
125{ 131{
126 struct cx88_buffer *buf = chip->buf; 132 struct cx88_audio_buffer *buf = chip->buf;
127 struct cx88_core *core=chip->core; 133 struct cx88_core *core=chip->core;
128 struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25]; 134 struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25];
129 135
@@ -376,7 +382,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
376 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 382 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream);
377 struct videobuf_dmabuf *dma; 383 struct videobuf_dmabuf *dma;
378 384
379 struct cx88_buffer *buf; 385 struct cx88_audio_buffer *buf;
380 int ret; 386 int ret;
381 387
382 if (substream->runtime->dma_area) { 388 if (substream->runtime->dma_area) {
@@ -391,21 +397,16 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
391 BUG_ON(!chip->dma_size); 397 BUG_ON(!chip->dma_size);
392 BUG_ON(chip->num_periods & (chip->num_periods-1)); 398 BUG_ON(chip->num_periods & (chip->num_periods-1));
393 399
394 buf = videobuf_sg_alloc(sizeof(*buf)); 400 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
395 if (NULL == buf) 401 if (NULL == buf)
396 return -ENOMEM; 402 return -ENOMEM;
397 403
398 buf->vb.memory = V4L2_MEMORY_MMAP; 404 buf->bpl = chip->period_size;
399 buf->vb.field = V4L2_FIELD_NONE;
400 buf->vb.width = chip->period_size;
401 buf->bpl = chip->period_size;
402 buf->vb.height = chip->num_periods;
403 buf->vb.size = chip->dma_size;
404 405
405 dma = videobuf_to_dma(&buf->vb); 406 dma = &buf->dma;
406 videobuf_dma_init(dma); 407 videobuf_dma_init(dma);
407 ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE, 408 ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE,
408 (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT)); 409 (PAGE_ALIGN(chip->dma_size) >> PAGE_SHIFT));
409 if (ret < 0) 410 if (ret < 0)
410 goto error; 411 goto error;
411 412
@@ -414,7 +415,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
414 goto error; 415 goto error;
415 416
416 ret = cx88_risc_databuffer(chip->pci, &buf->risc, dma->sglist, 417 ret = cx88_risc_databuffer(chip->pci, &buf->risc, dma->sglist,
417 buf->vb.width, buf->vb.height, 1); 418 chip->period_size, chip->num_periods, 1);
418 if (ret < 0) 419 if (ret < 0)
419 goto error; 420 goto error;
420 421
@@ -422,8 +423,6 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
422 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP|RISC_IRQ1|RISC_CNT_INC); 423 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP|RISC_IRQ1|RISC_CNT_INC);
423 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 424 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
424 425
425 buf->vb.state = VIDEOBUF_PREPARED;
426
427 chip->buf = buf; 426 chip->buf = buf;
428 chip->dma_risc = dma; 427 chip->dma_risc = dma;
429 428
diff --git a/drivers/staging/cx25821/cx25821-alsa.c b/drivers/staging/cx25821/cx25821-alsa.c
index 4ce8790b05ec..0771a6a313ad 100644
--- a/drivers/staging/cx25821/cx25821-alsa.c
+++ b/drivers/staging/cx25821/cx25821-alsa.c
@@ -55,6 +55,12 @@
55static struct snd_card *snd_cx25821_cards[SNDRV_CARDS]; 55static struct snd_card *snd_cx25821_cards[SNDRV_CARDS];
56static int devno; 56static int devno;
57 57
58struct cx25821_audio_buffer {
59 unsigned int bpl;
60 struct btcx_riscmem risc;
61 struct videobuf_dmabuf dma;
62};
63
58struct cx25821_audio_dev { 64struct cx25821_audio_dev {
59 struct cx25821_dev *dev; 65 struct cx25821_dev *dev;
60 struct cx25821_dmaqueue q; 66 struct cx25821_dmaqueue q;
@@ -77,7 +83,7 @@ struct cx25821_audio_dev {
77 83
78 struct videobuf_dmabuf *dma_risc; 84 struct videobuf_dmabuf *dma_risc;
79 85
80 struct cx25821_buffer *buf; 86 struct cx25821_audio_buffer *buf;
81 87
82 struct snd_pcm_substream *substream; 88 struct snd_pcm_substream *substream;
83}; 89};
@@ -136,7 +142,7 @@ MODULE_PARM_DESC(debug, "enable debug messages");
136 142
137static int _cx25821_start_audio_dma(struct cx25821_audio_dev *chip) 143static int _cx25821_start_audio_dma(struct cx25821_audio_dev *chip)
138{ 144{
139 struct cx25821_buffer *buf = chip->buf; 145 struct cx25821_audio_buffer *buf = chip->buf;
140 struct cx25821_dev *dev = chip->dev; 146 struct cx25821_dev *dev = chip->dev;
141 struct sram_channel *audio_ch = 147 struct sram_channel *audio_ch =
142 &cx25821_sram_channels[AUDIO_SRAM_CHANNEL]; 148 &cx25821_sram_channels[AUDIO_SRAM_CHANNEL];
@@ -432,7 +438,7 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream *substream,
432 struct cx25821_audio_dev *chip = snd_pcm_substream_chip(substream); 438 struct cx25821_audio_dev *chip = snd_pcm_substream_chip(substream);
433 struct videobuf_dmabuf *dma; 439 struct videobuf_dmabuf *dma;
434 440
435 struct cx25821_buffer *buf; 441 struct cx25821_audio_buffer *buf;
436 int ret; 442 int ret;
437 443
438 if (substream->runtime->dma_area) { 444 if (substream->runtime->dma_area) {
@@ -447,25 +453,19 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream *substream,
447 BUG_ON(!chip->dma_size); 453 BUG_ON(!chip->dma_size);
448 BUG_ON(chip->num_periods & (chip->num_periods - 1)); 454 BUG_ON(chip->num_periods & (chip->num_periods - 1));
449 455
450 buf = videobuf_sg_alloc(sizeof(*buf)); 456 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
451 if (NULL == buf) 457 if (NULL == buf)
452 return -ENOMEM; 458 return -ENOMEM;
453 459
454 if (chip->period_size > AUDIO_LINE_SIZE) 460 if (chip->period_size > AUDIO_LINE_SIZE)
455 chip->period_size = AUDIO_LINE_SIZE; 461 chip->period_size = AUDIO_LINE_SIZE;
456 462
457 buf->vb.memory = V4L2_MEMORY_MMAP;
458 buf->vb.field = V4L2_FIELD_NONE;
459 buf->vb.width = chip->period_size;
460 buf->bpl = chip->period_size; 463 buf->bpl = chip->period_size;
461 buf->vb.height = chip->num_periods;
462 buf->vb.size = chip->dma_size;
463 464
464 dma = videobuf_to_dma(&buf->vb); 465 dma = &buf->dma;
465 videobuf_dma_init(dma); 466 videobuf_dma_init(dma);
466
467 ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE, 467 ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE,
468 (PAGE_ALIGN(buf->vb.size) >> 468 (PAGE_ALIGN(chip->dma_size) >>
469 PAGE_SHIFT)); 469 PAGE_SHIFT));
470 if (ret < 0) 470 if (ret < 0)
471 goto error; 471 goto error;
@@ -476,7 +476,8 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream *substream,
476 476
477 ret = 477 ret =
478 cx25821_risc_databuffer_audio(chip->pci, &buf->risc, dma->sglist, 478 cx25821_risc_databuffer_audio(chip->pci, &buf->risc, dma->sglist,
479 buf->vb.width, buf->vb.height, 1); 479 chip->period_size, chip->num_periods,
480 1);
480 if (ret < 0) { 481 if (ret < 0) {
481 printk(KERN_INFO 482 printk(KERN_INFO
482 "DEBUG: ERROR after cx25821_risc_databuffer_audio()\n"); 483 "DEBUG: ERROR after cx25821_risc_databuffer_audio()\n");
@@ -488,8 +489,6 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream *substream,
488 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 489 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
489 buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ 490 buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */
490 491
491 buf->vb.state = VIDEOBUF_PREPARED;
492
493 chip->buf = buf; 492 chip->buf = buf;
494 chip->dma_risc = dma; 493 chip->dma_risc = dma;
495 494