aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2015-03-24 13:30:53 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-10 09:08:30 -0400
commit650b939ecd3f0a1a9dc800155f7efadeb1794868 (patch)
tree5d696482ca2d85d11ec900737cdfb815fad3cdcc
parentad532d37b2958f6c7652429be36ddd46a65ab67a (diff)
[media] coda: move parameter buffer in together with context buffer allocation
The parameter buffer is a per-context buffer, so we can allocate and free it together with the other context buffers during REQBUFS. Since this was the last context buffer allocated in coda-common.c, we can now move coda_alloc_context_buf into coda-bit.c. 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>
-rw-r--r--drivers/media/platform/coda/coda-bit.c21
-rw-r--r--drivers/media/platform/coda/coda-common.c12
-rw-r--r--drivers/media/platform/coda/coda.h7
3 files changed, 20 insertions, 20 deletions
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 5aa8d8774d0c..0073f5a5b86c 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -31,6 +31,7 @@
31 31
32#include "coda.h" 32#include "coda.h"
33 33
34#define CODA_PARA_BUF_SIZE (10 * 1024)
34#define CODA7_PS_BUF_SIZE 0x28000 35#define CODA7_PS_BUF_SIZE 0x28000
35#define CODA9_PS_SAVE_SIZE (512 * 1024) 36#define CODA9_PS_SAVE_SIZE (512 * 1024)
36 37
@@ -300,6 +301,14 @@ static void coda_parabuf_write(struct coda_ctx *ctx, int index, u32 value)
300 p[index ^ 1] = value; 301 p[index ^ 1] = value;
301} 302}
302 303
304static inline int coda_alloc_context_buf(struct coda_ctx *ctx,
305 struct coda_aux_buf *buf, size_t size,
306 const char *name)
307{
308 return coda_alloc_aux_buf(ctx->dev, buf, size, name, ctx->debugfs_entry);
309}
310
311
303static void coda_free_framebuffers(struct coda_ctx *ctx) 312static void coda_free_framebuffers(struct coda_ctx *ctx)
304{ 313{
305 int i; 314 int i;
@@ -380,6 +389,7 @@ static void coda_free_context_buffers(struct coda_ctx *ctx)
380 coda_free_aux_buf(dev, &ctx->psbuf); 389 coda_free_aux_buf(dev, &ctx->psbuf);
381 if (dev->devtype->product != CODA_DX6) 390 if (dev->devtype->product != CODA_DX6)
382 coda_free_aux_buf(dev, &ctx->workbuf); 391 coda_free_aux_buf(dev, &ctx->workbuf);
392 coda_free_aux_buf(dev, &ctx->parabuf);
383} 393}
384 394
385static int coda_alloc_context_buffers(struct coda_ctx *ctx, 395static int coda_alloc_context_buffers(struct coda_ctx *ctx,
@@ -389,6 +399,15 @@ static int coda_alloc_context_buffers(struct coda_ctx *ctx,
389 size_t size; 399 size_t size;
390 int ret; 400 int ret;
391 401
402 if (!ctx->parabuf.vaddr) {
403 ret = coda_alloc_context_buf(ctx, &ctx->parabuf,
404 CODA_PARA_BUF_SIZE, "parabuf");
405 if (ret < 0) {
406 v4l2_err(&dev->v4l2_dev, "failed to allocate parabuf");
407 return ret;
408 }
409 }
410
392 if (dev->devtype->product == CODA_DX6) 411 if (dev->devtype->product == CODA_DX6)
393 return 0; 412 return 0;
394 413
@@ -402,7 +421,7 @@ static int coda_alloc_context_buffers(struct coda_ctx *ctx,
402 v4l2_err(&dev->v4l2_dev, 421 v4l2_err(&dev->v4l2_dev,
403 "failed to allocate %d byte slice buffer", 422 "failed to allocate %d byte slice buffer",
404 ctx->slicebuf.size); 423 ctx->slicebuf.size);
405 return ret; 424 goto err;
406 } 425 }
407 } 426 }
408 427
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 3a852ac6a8c3..ae7a35148b84 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -46,7 +46,6 @@
46#define CODADX6_MAX_INSTANCES 4 46#define CODADX6_MAX_INSTANCES 4
47#define CODA_MAX_FORMATS 4 47#define CODA_MAX_FORMATS 4
48 48
49#define CODA_PARA_BUF_SIZE (10 * 1024)
50#define CODA_ISRAM_SIZE (2048 * 2) 49#define CODA_ISRAM_SIZE (2048 * 2)
51 50
52#define MIN_W 176 51#define MIN_W 176
@@ -1715,14 +1714,6 @@ static int coda_open(struct file *file)
1715 1714
1716 ctx->fh.ctrl_handler = &ctx->ctrls; 1715 ctx->fh.ctrl_handler = &ctx->ctrls;
1717 1716
1718 if (ctx->use_bit) {
1719 ret = coda_alloc_context_buf(ctx, &ctx->parabuf,
1720 CODA_PARA_BUF_SIZE, "parabuf");
1721 if (ret < 0) {
1722 v4l2_err(&dev->v4l2_dev, "failed to allocate parabuf");
1723 goto err_dma_alloc;
1724 }
1725 }
1726 mutex_init(&ctx->bitstream_mutex); 1717 mutex_init(&ctx->bitstream_mutex);
1727 mutex_init(&ctx->buffer_mutex); 1718 mutex_init(&ctx->buffer_mutex);
1728 INIT_LIST_HEAD(&ctx->buffer_meta_list); 1719 INIT_LIST_HEAD(&ctx->buffer_meta_list);
@@ -1736,8 +1727,6 @@ static int coda_open(struct file *file)
1736 1727
1737 return 0; 1728 return 0;
1738 1729
1739err_dma_alloc:
1740 v4l2_ctrl_handler_free(&ctx->ctrls);
1741err_ctrls_setup: 1730err_ctrls_setup:
1742 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 1731 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
1743err_ctx_init: 1732err_ctx_init:
@@ -1783,7 +1772,6 @@ static int coda_release(struct file *file)
1783 if (ctx->dev->devtype->product == CODA_DX6) 1772 if (ctx->dev->devtype->product == CODA_DX6)
1784 coda_free_aux_buf(dev, &ctx->workbuf); 1773 coda_free_aux_buf(dev, &ctx->workbuf);
1785 1774
1786 coda_free_aux_buf(dev, &ctx->parabuf);
1787 v4l2_ctrl_handler_free(&ctx->ctrls); 1775 v4l2_ctrl_handler_free(&ctx->ctrls);
1788 clk_disable_unprepare(dev->clk_ahb); 1776 clk_disable_unprepare(dev->clk_ahb);
1789 clk_disable_unprepare(dev->clk_per); 1777 clk_disable_unprepare(dev->clk_per);
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h
index 01d940c630b3..2b59e1660e58 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -249,13 +249,6 @@ int coda_alloc_aux_buf(struct coda_dev *dev, struct coda_aux_buf *buf,
249 size_t size, const char *name, struct dentry *parent); 249 size_t size, const char *name, struct dentry *parent);
250void coda_free_aux_buf(struct coda_dev *dev, struct coda_aux_buf *buf); 250void coda_free_aux_buf(struct coda_dev *dev, struct coda_aux_buf *buf);
251 251
252static inline int coda_alloc_context_buf(struct coda_ctx *ctx,
253 struct coda_aux_buf *buf, size_t size,
254 const char *name)
255{
256 return coda_alloc_aux_buf(ctx->dev, buf, size, name, ctx->debugfs_entry);
257}
258
259int coda_encoder_queue_init(void *priv, struct vb2_queue *src_vq, 252int coda_encoder_queue_init(void *priv, struct vb2_queue *src_vq,
260 struct vb2_queue *dst_vq); 253 struct vb2_queue *dst_vq);
261int coda_decoder_queue_init(void *priv, struct vb2_queue *src_vq, 254int coda_decoder_queue_init(void *priv, struct vb2_queue *src_vq,