Commit 86eda90e authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

[media] coda: simplify parameter buffer setup code

Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarKamil Debski <k.debski@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 9acf7693
...@@ -905,21 +905,34 @@ static void coda_free_framebuffers(struct coda_ctx *ctx) ...@@ -905,21 +905,34 @@ static void coda_free_framebuffers(struct coda_ctx *ctx)
} }
} }
static void coda_parabuf_write(struct coda_ctx *ctx, int index, u32 value)
{
struct coda_dev *dev = ctx->dev;
u32 *p = ctx->parabuf.vaddr;
if (dev->devtype->product == CODA_DX6)
p[index] = value;
else
p[index ^ 1] = value;
}
static int coda_alloc_framebuffers(struct coda_ctx *ctx, struct coda_q_data *q_data, u32 fourcc) static int coda_alloc_framebuffers(struct coda_ctx *ctx, struct coda_q_data *q_data, u32 fourcc)
{ {
struct coda_dev *dev = ctx->dev; struct coda_dev *dev = ctx->dev;
int height = q_data->height; int height = q_data->height;
int width = q_data->width; dma_addr_t paddr;
u32 *p; int ysize;
int i; int i;
ysize = round_up(q_data->width, 8) * height;
/* Allocate frame buffers */ /* Allocate frame buffers */
ctx->num_internal_frames = CODA_MAX_FRAMEBUFFERS; ctx->num_internal_frames = CODA_MAX_FRAMEBUFFERS;
for (i = 0; i < ctx->num_internal_frames; i++) { for (i = 0; i < ctx->num_internal_frames; i++) {
ctx->internal_frames[i].size = q_data->sizeimage; ctx->internal_frames[i].size = q_data->sizeimage;
if (fourcc == V4L2_PIX_FMT_H264 && dev->devtype->product != CODA_DX6) if (fourcc == V4L2_PIX_FMT_H264 && dev->devtype->product != CODA_DX6)
ctx->internal_frames[i].size += width / 2 * height / 2; ctx->internal_frames[i].size += ysize/4;
ctx->internal_frames[i].vaddr = dma_alloc_coherent( ctx->internal_frames[i].vaddr = dma_alloc_coherent(
&dev->plat_dev->dev, ctx->internal_frames[i].size, &dev->plat_dev->dev, ctx->internal_frames[i].size,
&ctx->internal_frames[i].paddr, GFP_KERNEL); &ctx->internal_frames[i].paddr, GFP_KERNEL);
...@@ -930,32 +943,14 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx, struct coda_q_data *q_d ...@@ -930,32 +943,14 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx, struct coda_q_data *q_d
} }
/* Register frame buffers in the parameter buffer */ /* Register frame buffers in the parameter buffer */
p = ctx->parabuf.vaddr;
if (dev->devtype->product == CODA_DX6) {
for (i = 0; i < ctx->num_internal_frames; i++) { for (i = 0; i < ctx->num_internal_frames; i++) {
p[i * 3] = ctx->internal_frames[i].paddr; /* Y */ paddr = ctx->internal_frames[i].paddr;
p[i * 3 + 1] = p[i * 3] + width * height; /* Cb */ coda_parabuf_write(ctx, i * 3 + 0, paddr); /* Y */
p[i * 3 + 2] = p[i * 3 + 1] + width / 2 * height / 2; /* Cr */ coda_parabuf_write(ctx, i * 3 + 1, paddr + ysize); /* Cb */
} coda_parabuf_write(ctx, i * 3 + 2, paddr + ysize + ysize/4); /* Cr */
} else {
for (i = 0; i < ctx->num_internal_frames; i += 2) {
p[i * 3 + 1] = ctx->internal_frames[i].paddr; /* Y */
p[i * 3] = p[i * 3 + 1] + width * height; /* Cb */
p[i * 3 + 3] = p[i * 3] + (width / 2) * (height / 2); /* Cr */
if (fourcc == V4L2_PIX_FMT_H264) if (dev->devtype->product != CODA_DX6 && fourcc == V4L2_PIX_FMT_H264)
p[96 + i + 1] = p[i * 3 + 3] + (width / 2) * (height / 2); coda_parabuf_write(ctx, 96 + i, ctx->internal_frames[i].paddr + ysize + ysize/4 + ysize/4);
if (i + 1 < ctx->num_internal_frames) {
p[i * 3 + 2] = ctx->internal_frames[i+1].paddr; /* Y */
p[i * 3 + 5] = p[i * 3 + 2] + width * height ; /* Cb */
p[i * 3 + 4] = p[i * 3 + 5] + (width / 2) * (height / 2); /* Cr */
if (fourcc == V4L2_PIX_FMT_H264)
p[96 + i] = p[i * 3 + 4] + (width / 2) * (height / 2);
}
}
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment