summaryrefslogtreecommitdiff
path: root/drivers/media/platform/coda/coda-common.c
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2015-03-24 14:30:52 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-10 10:07:58 -0300
commitad532d37b2958f6c7652429be36ddd46a65ab67a (patch)
treea9cf7cc63cd123c88512d4363f6ae9b5b4910d7d /drivers/media/platform/coda/coda-common.c
parent73751da61c00db9914ae1c47a25f7462722bc76b (diff)
[media] coda: allocate bitstream buffer from REQBUFS, size depends on the format
Allocating the bitstream buffer only when the format is set allows to guarantee that at least two frames fit into the bitstream buffer. For small frame sizes a smaller bitstream buffer can be allocated. Since the bitstream buffer size now depends on the format, replace CODA_MAX_FRAME_SIZE with ctx->bitstream.size where appropriate and remove the now unused constant. Since REQBUFS can be called multiple times, but the format can't be changed unless REQBUFS 0 was called before, we can just keep the allocated context and bitstream buffers if REQBUFS is called multiple times with a non-zero buffer count. [fixed a resource leak preventing repeatedly decoding] Signed-off-by: Peter Seiderer <ps.report@gmx.net> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/platform/coda/coda-common.c')
-rw-r--r--drivers/media/platform/coda/coda-common.c22
1 files changed, 0 insertions, 22 deletions
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index a8a6c36a1f00..3a852ac6a8c3 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1723,20 +1723,6 @@ static int coda_open(struct file *file)
goto err_dma_alloc;
}
}
- if (ctx->use_bit && ctx->inst_type == CODA_INST_DECODER) {
- ctx->bitstream.size = CODA_MAX_FRAME_SIZE;
- ctx->bitstream.vaddr = dma_alloc_writecombine(
- &dev->plat_dev->dev, ctx->bitstream.size,
- &ctx->bitstream.paddr, GFP_KERNEL);
- if (!ctx->bitstream.vaddr) {
- v4l2_err(&dev->v4l2_dev,
- "failed to allocate bitstream ringbuffer");
- ret = -ENOMEM;
- goto err_dma_writecombine;
- }
- }
- kfifo_init(&ctx->bitstream_fifo,
- ctx->bitstream.vaddr, ctx->bitstream.size);
mutex_init(&ctx->bitstream_mutex);
mutex_init(&ctx->buffer_mutex);
INIT_LIST_HEAD(&ctx->buffer_meta_list);
@@ -1750,10 +1736,6 @@ static int coda_open(struct file *file)
return 0;
-err_dma_writecombine:
- if (ctx->dev->devtype->product == CODA_DX6)
- coda_free_aux_buf(dev, &ctx->workbuf);
- coda_free_aux_buf(dev, &ctx->parabuf);
err_dma_alloc:
v4l2_ctrl_handler_free(&ctx->ctrls);
err_ctrls_setup:
@@ -1798,10 +1780,6 @@ static int coda_release(struct file *file)
list_del(&ctx->list);
coda_unlock(ctx);
- if (ctx->bitstream.vaddr) {
- dma_free_writecombine(&dev->plat_dev->dev, ctx->bitstream.size,
- ctx->bitstream.vaddr, ctx->bitstream.paddr);
- }
if (ctx->dev->devtype->product == CODA_DX6)
coda_free_aux_buf(dev, &ctx->workbuf);