提交 86eda90e 编写于 作者: P Philipp Zabel 提交者: Mauro Carvalho Chehab

[media] coda: simplify parameter buffer setup code

Signed-off-by: NPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: NKamil Debski <k.debski@samsung.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 9acf7693
......@@ -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)
{
struct coda_dev *dev = ctx->dev;
int height = q_data->height;
int width = q_data->width;
u32 *p;
dma_addr_t paddr;
int ysize;
int i;
ysize = round_up(q_data->width, 8) * height;
/* Allocate frame buffers */
ctx->num_internal_frames = CODA_MAX_FRAMEBUFFERS;
for (i = 0; i < ctx->num_internal_frames; i++) {
ctx->internal_frames[i].size = q_data->sizeimage;
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(
&dev->plat_dev->dev, ctx->internal_frames[i].size,
&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
}
/* Register frame buffers in the parameter buffer */
p = ctx->parabuf.vaddr;
for (i = 0; i < ctx->num_internal_frames; i++) {
paddr = ctx->internal_frames[i].paddr;
coda_parabuf_write(ctx, i * 3 + 0, paddr); /* Y */
coda_parabuf_write(ctx, i * 3 + 1, paddr + ysize); /* Cb */
coda_parabuf_write(ctx, i * 3 + 2, paddr + ysize + ysize/4); /* Cr */
if (dev->devtype->product == CODA_DX6) {
for (i = 0; i < ctx->num_internal_frames; i++) {
p[i * 3] = ctx->internal_frames[i].paddr; /* Y */
p[i * 3 + 1] = p[i * 3] + width * height; /* Cb */
p[i * 3 + 2] = p[i * 3 + 1] + width / 2 * height / 2; /* 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)
p[96 + i + 1] = p[i * 3 + 3] + (width / 2) * (height / 2);
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);
}
}
if (dev->devtype->product != CODA_DX6 && fourcc == V4L2_PIX_FMT_H264)
coda_parabuf_write(ctx, 96 + i, ctx->internal_frames[i].paddr + ysize + ysize/4 + ysize/4);
}
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册