[media] coda: simplify parameter buffer setup code
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@redhat.com>
This commit is contained in:
parent
9acf7693b7
commit
86eda90eaa
1 changed files with 23 additions and 28 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register frame buffers in the parameter buffer */
|
/* 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) {
|
if (dev->devtype->product != CODA_DX6 && fourcc == V4L2_PIX_FMT_H264)
|
||||||
for (i = 0; i < ctx->num_internal_frames; i++) {
|
coda_parabuf_write(ctx, 96 + i, ctx->internal_frames[i].paddr + ysize + ysize/4 + ysize/4);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue