Commit 84bb4d04 authored by Xia Jiang's avatar Xia Jiang Committed by Mauro Carvalho Chehab

media: platform: Redefinition of mtk_jpeg_q_data structure

The standard v4l2_pix_format_mplane structure contains width/height/
sizeimage/bytesperline, so use v4l2_pix_format_mplane to replace them.
Reviewed-by: default avatarTomasz Figa <tfiga@chromium.org>
Signed-off-by: default avatarXia Jiang <xia.jiang@mediatek.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent ac5a59c8
...@@ -207,15 +207,15 @@ static int mtk_jpeg_g_fmt_vid_mplane(struct file *file, void *priv, ...@@ -207,15 +207,15 @@ static int mtk_jpeg_g_fmt_vid_mplane(struct file *file, void *priv,
q_data = mtk_jpeg_get_q_data(ctx, f->type); q_data = mtk_jpeg_get_q_data(ctx, f->type);
pix_mp->width = q_data->w; pix_mp->width = q_data->pix_mp.width;
pix_mp->height = q_data->h; pix_mp->height = q_data->pix_mp.height;
pix_mp->field = V4L2_FIELD_NONE; pix_mp->field = V4L2_FIELD_NONE;
pix_mp->pixelformat = q_data->fmt->fourcc; pix_mp->pixelformat = q_data->fmt->fourcc;
pix_mp->num_planes = q_data->fmt->colplanes; pix_mp->num_planes = q_data->fmt->colplanes;
pix_mp->colorspace = ctx->colorspace; pix_mp->colorspace = q_data->pix_mp.colorspace;
pix_mp->ycbcr_enc = ctx->ycbcr_enc; pix_mp->ycbcr_enc = q_data->pix_mp.ycbcr_enc;
pix_mp->xfer_func = ctx->xfer_func; pix_mp->xfer_func = q_data->pix_mp.xfer_func;
pix_mp->quantization = ctx->quantization; pix_mp->quantization = q_data->pix_mp.quantization;
v4l2_dbg(1, debug, &jpeg->v4l2_dev, "(%d) g_fmt:%c%c%c%c wxh:%ux%u\n", v4l2_dbg(1, debug, &jpeg->v4l2_dev, "(%d) g_fmt:%c%c%c%c wxh:%ux%u\n",
f->type, f->type,
...@@ -228,8 +228,8 @@ static int mtk_jpeg_g_fmt_vid_mplane(struct file *file, void *priv, ...@@ -228,8 +228,8 @@ static int mtk_jpeg_g_fmt_vid_mplane(struct file *file, void *priv,
for (i = 0; i < pix_mp->num_planes; i++) { for (i = 0; i < pix_mp->num_planes; i++) {
struct v4l2_plane_pix_format *pfmt = &pix_mp->plane_fmt[i]; struct v4l2_plane_pix_format *pfmt = &pix_mp->plane_fmt[i];
pfmt->bytesperline = q_data->bytesperline[i]; pfmt->bytesperline = q_data->pix_mp.plane_fmt[i].bytesperline;
pfmt->sizeimage = q_data->sizeimage[i]; pfmt->sizeimage = q_data->pix_mp.plane_fmt[i].sizeimage;
v4l2_dbg(1, debug, &jpeg->v4l2_dev, v4l2_dbg(1, debug, &jpeg->v4l2_dev,
"plane[%d] bpl=%u, size=%u\n", "plane[%d] bpl=%u, size=%u\n",
...@@ -318,12 +318,12 @@ static int mtk_jpeg_s_fmt_mplane(struct mtk_jpeg_ctx *ctx, ...@@ -318,12 +318,12 @@ static int mtk_jpeg_s_fmt_mplane(struct mtk_jpeg_ctx *ctx,
q_data->fmt = mtk_jpeg_find_format(mtk_jpeg_formats, q_data->fmt = mtk_jpeg_find_format(mtk_jpeg_formats,
MTK_JPEG_NUM_FORMATS, MTK_JPEG_NUM_FORMATS,
pix_mp->pixelformat, fmt_type); pix_mp->pixelformat, fmt_type);
q_data->w = pix_mp->width; q_data->pix_mp.width = pix_mp->width;
q_data->h = pix_mp->height; q_data->pix_mp.height = pix_mp->height;
ctx->colorspace = pix_mp->colorspace; q_data->pix_mp.colorspace = pix_mp->colorspace;
ctx->ycbcr_enc = pix_mp->ycbcr_enc; q_data->pix_mp.ycbcr_enc = pix_mp->ycbcr_enc;
ctx->xfer_func = pix_mp->xfer_func; q_data->pix_mp.xfer_func = pix_mp->xfer_func;
ctx->quantization = pix_mp->quantization; q_data->pix_mp.quantization = pix_mp->quantization;
v4l2_dbg(1, debug, &jpeg->v4l2_dev, "(%d) s_fmt:%c%c%c%c wxh:%ux%u\n", v4l2_dbg(1, debug, &jpeg->v4l2_dev, "(%d) s_fmt:%c%c%c%c wxh:%ux%u\n",
f->type, f->type,
...@@ -331,15 +331,18 @@ static int mtk_jpeg_s_fmt_mplane(struct mtk_jpeg_ctx *ctx, ...@@ -331,15 +331,18 @@ static int mtk_jpeg_s_fmt_mplane(struct mtk_jpeg_ctx *ctx,
(q_data->fmt->fourcc >> 8 & 0xff), (q_data->fmt->fourcc >> 8 & 0xff),
(q_data->fmt->fourcc >> 16 & 0xff), (q_data->fmt->fourcc >> 16 & 0xff),
(q_data->fmt->fourcc >> 24 & 0xff), (q_data->fmt->fourcc >> 24 & 0xff),
q_data->w, q_data->h); q_data->pix_mp.width, q_data->pix_mp.height);
for (i = 0; i < q_data->fmt->colplanes; i++) { for (i = 0; i < q_data->fmt->colplanes; i++) {
q_data->bytesperline[i] = pix_mp->plane_fmt[i].bytesperline; q_data->pix_mp.plane_fmt[i].bytesperline =
q_data->sizeimage[i] = pix_mp->plane_fmt[i].sizeimage; pix_mp->plane_fmt[i].bytesperline;
q_data->pix_mp.plane_fmt[i].sizeimage =
pix_mp->plane_fmt[i].sizeimage;
v4l2_dbg(1, debug, &jpeg->v4l2_dev, v4l2_dbg(1, debug, &jpeg->v4l2_dev,
"plane[%d] bpl=%u, size=%u\n", "plane[%d] bpl=%u, size=%u\n",
i, q_data->bytesperline[i], q_data->sizeimage[i]); i, q_data->pix_mp.plane_fmt[i].bytesperline,
q_data->pix_mp.plane_fmt[i].sizeimage);
} }
return 0; return 0;
...@@ -404,15 +407,15 @@ static int mtk_jpeg_g_selection(struct file *file, void *priv, ...@@ -404,15 +407,15 @@ static int mtk_jpeg_g_selection(struct file *file, void *priv,
switch (s->target) { switch (s->target) {
case V4L2_SEL_TGT_COMPOSE: case V4L2_SEL_TGT_COMPOSE:
case V4L2_SEL_TGT_COMPOSE_DEFAULT: case V4L2_SEL_TGT_COMPOSE_DEFAULT:
s->r.width = ctx->out_q.w; s->r.width = ctx->out_q.pix_mp.width;
s->r.height = ctx->out_q.h; s->r.height = ctx->out_q.pix_mp.height;
s->r.left = 0; s->r.left = 0;
s->r.top = 0; s->r.top = 0;
break; break;
case V4L2_SEL_TGT_COMPOSE_BOUNDS: case V4L2_SEL_TGT_COMPOSE_BOUNDS:
case V4L2_SEL_TGT_COMPOSE_PADDED: case V4L2_SEL_TGT_COMPOSE_PADDED:
s->r.width = ctx->cap_q.w; s->r.width = ctx->cap_q.pix_mp.width;
s->r.height = ctx->cap_q.h; s->r.height = ctx->cap_q.pix_mp.height;
s->r.left = 0; s->r.left = 0;
s->r.top = 0; s->r.top = 0;
break; break;
...@@ -468,14 +471,14 @@ static int mtk_jpeg_queue_setup(struct vb2_queue *q, ...@@ -468,14 +471,14 @@ static int mtk_jpeg_queue_setup(struct vb2_queue *q,
if (*num_planes) { if (*num_planes) {
for (i = 0; i < *num_planes; i++) for (i = 0; i < *num_planes; i++)
if (sizes[i] < q_data->sizeimage[i]) if (sizes[i] < q_data->pix_mp.plane_fmt[i].sizeimage)
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
*num_planes = q_data->fmt->colplanes; *num_planes = q_data->fmt->colplanes;
for (i = 0; i < q_data->fmt->colplanes; i++) { for (i = 0; i < q_data->fmt->colplanes; i++) {
sizes[i] = q_data->sizeimage[i]; sizes[i] = q_data->pix_mp.plane_fmt[i].sizeimage;
v4l2_dbg(1, debug, &jpeg->v4l2_dev, "sizeimage[%d]=%u\n", v4l2_dbg(1, debug, &jpeg->v4l2_dev, "sizeimage[%d]=%u\n",
i, sizes[i]); i, sizes[i]);
} }
...@@ -494,7 +497,8 @@ static int mtk_jpeg_buf_prepare(struct vb2_buffer *vb) ...@@ -494,7 +497,8 @@ static int mtk_jpeg_buf_prepare(struct vb2_buffer *vb)
return -EINVAL; return -EINVAL;
for (i = 0; i < q_data->fmt->colplanes; i++) for (i = 0; i < q_data->fmt->colplanes; i++)
vb2_set_plane_payload(vb, i, q_data->sizeimage[i]); vb2_set_plane_payload(vb, i,
q_data->pix_mp.plane_fmt[i].sizeimage);
return 0; return 0;
} }
...@@ -506,7 +510,8 @@ static bool mtk_jpeg_check_resolution_change(struct mtk_jpeg_ctx *ctx, ...@@ -506,7 +510,8 @@ static bool mtk_jpeg_check_resolution_change(struct mtk_jpeg_ctx *ctx,
struct mtk_jpeg_q_data *q_data; struct mtk_jpeg_q_data *q_data;
q_data = &ctx->out_q; q_data = &ctx->out_q;
if (q_data->w != param->pic_w || q_data->h != param->pic_h) { if (q_data->pix_mp.width != param->pic_w ||
q_data->pix_mp.height != param->pic_h) {
v4l2_dbg(1, debug, &jpeg->v4l2_dev, "Picture size change\n"); v4l2_dbg(1, debug, &jpeg->v4l2_dev, "Picture size change\n");
return true; return true;
} }
...@@ -529,20 +534,20 @@ static void mtk_jpeg_set_queue_data(struct mtk_jpeg_ctx *ctx, ...@@ -529,20 +534,20 @@ static void mtk_jpeg_set_queue_data(struct mtk_jpeg_ctx *ctx,
int i; int i;
q_data = &ctx->out_q; q_data = &ctx->out_q;
q_data->w = param->pic_w; q_data->pix_mp.width = param->pic_w;
q_data->h = param->pic_h; q_data->pix_mp.height = param->pic_h;
q_data = &ctx->cap_q; q_data = &ctx->cap_q;
q_data->w = param->dec_w; q_data->pix_mp.width = param->dec_w;
q_data->h = param->dec_h; q_data->pix_mp.height = param->dec_h;
q_data->fmt = mtk_jpeg_find_format(mtk_jpeg_formats, q_data->fmt = mtk_jpeg_find_format(mtk_jpeg_formats,
MTK_JPEG_NUM_FORMATS, MTK_JPEG_NUM_FORMATS,
param->dst_fourcc, param->dst_fourcc,
MTK_JPEG_FMT_FLAG_DEC_CAPTURE); MTK_JPEG_FMT_FLAG_DEC_CAPTURE);
for (i = 0; i < q_data->fmt->colplanes; i++) { for (i = 0; i < q_data->fmt->colplanes; i++) {
q_data->bytesperline[i] = param->mem_stride[i]; q_data->pix_mp.plane_fmt[i].bytesperline = param->mem_stride[i];
q_data->sizeimage[i] = param->comp_size[i]; q_data->pix_mp.plane_fmt[i].sizeimage = param->comp_size[i];
} }
v4l2_dbg(1, debug, &jpeg->v4l2_dev, v4l2_dbg(1, debug, &jpeg->v4l2_dev,
...@@ -841,32 +846,36 @@ static void mtk_jpeg_set_default_params(struct mtk_jpeg_ctx *ctx) ...@@ -841,32 +846,36 @@ static void mtk_jpeg_set_default_params(struct mtk_jpeg_ctx *ctx)
struct mtk_jpeg_q_data *q = &ctx->out_q; struct mtk_jpeg_q_data *q = &ctx->out_q;
int i; int i;
ctx->colorspace = V4L2_COLORSPACE_JPEG, q->pix_mp.colorspace = V4L2_COLORSPACE_JPEG,
ctx->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; q->pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
ctx->quantization = V4L2_QUANTIZATION_DEFAULT; q->pix_mp.quantization = V4L2_QUANTIZATION_DEFAULT;
ctx->xfer_func = V4L2_XFER_FUNC_DEFAULT; q->pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT;
q->fmt = mtk_jpeg_find_format(mtk_jpeg_formats, MTK_JPEG_NUM_FORMATS, q->fmt = mtk_jpeg_find_format(mtk_jpeg_formats, MTK_JPEG_NUM_FORMATS,
V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_JPEG,
MTK_JPEG_FMT_FLAG_DEC_OUTPUT); MTK_JPEG_FMT_FLAG_DEC_OUTPUT);
q->w = MTK_JPEG_MIN_WIDTH; q->pix_mp.width = MTK_JPEG_MIN_WIDTH;
q->h = MTK_JPEG_MIN_HEIGHT; q->pix_mp.height = MTK_JPEG_MIN_HEIGHT;
q->bytesperline[0] = 0; q->pix_mp.plane_fmt[0].bytesperline = 0;
q->sizeimage[0] = MTK_JPEG_DEFAULT_SIZEIMAGE; q->pix_mp.plane_fmt[0].sizeimage = MTK_JPEG_DEFAULT_SIZEIMAGE;
q = &ctx->cap_q; q = &ctx->cap_q;
q->fmt = mtk_jpeg_find_format(mtk_jpeg_formats, MTK_JPEG_NUM_FORMATS, q->fmt = mtk_jpeg_find_format(mtk_jpeg_formats, MTK_JPEG_NUM_FORMATS,
V4L2_PIX_FMT_YUV420M, V4L2_PIX_FMT_YUV420M,
MTK_JPEG_FMT_FLAG_DEC_CAPTURE); MTK_JPEG_FMT_FLAG_DEC_CAPTURE);
q->w = MTK_JPEG_MIN_WIDTH; q->pix_mp.colorspace = V4L2_COLORSPACE_JPEG,
q->h = MTK_JPEG_MIN_HEIGHT; q->pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
q->pix_mp.quantization = V4L2_QUANTIZATION_DEFAULT;
q->pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT;
q->pix_mp.width = MTK_JPEG_MIN_WIDTH;
q->pix_mp.height = MTK_JPEG_MIN_HEIGHT;
for (i = 0; i < q->fmt->colplanes; i++) { for (i = 0; i < q->fmt->colplanes; i++) {
u32 stride = q->w * q->fmt->h_sample[i] / 4; u32 stride = q->pix_mp.width * q->fmt->h_sample[i] / 4;
u32 h = q->h * q->fmt->v_sample[i] / 4; u32 h = q->pix_mp.height * q->fmt->v_sample[i] / 4;
q->bytesperline[i] = stride; q->pix_mp.plane_fmt[i].bytesperline = stride;
q->sizeimage[i] = stride * h; q->pix_mp.plane_fmt[i].sizeimage = stride * h;
} }
} }
......
...@@ -96,18 +96,11 @@ struct mtk_jpeg_fmt { ...@@ -96,18 +96,11 @@ struct mtk_jpeg_fmt {
/** /**
* mtk_jpeg_q_data - parameters of one queue * mtk_jpeg_q_data - parameters of one queue
* @fmt: driver-specific format of this queue * @fmt: driver-specific format of this queue
* @w: image width * @pix_mp: multiplanar format
* @h: image height
* @bytesperline: distance in bytes between the leftmost pixels in two adjacent
* lines
* @sizeimage: image buffer size in bytes
*/ */
struct mtk_jpeg_q_data { struct mtk_jpeg_q_data {
struct mtk_jpeg_fmt *fmt; struct mtk_jpeg_fmt *fmt;
u32 w; struct v4l2_pix_format_mplane pix_mp;
u32 h;
u32 bytesperline[VIDEO_MAX_PLANES];
u32 sizeimage[VIDEO_MAX_PLANES];
}; };
/** /**
...@@ -117,10 +110,6 @@ struct mtk_jpeg_q_data { ...@@ -117,10 +110,6 @@ struct mtk_jpeg_q_data {
* @cap_q: destination (capture) queue queue information * @cap_q: destination (capture) queue queue information
* @fh: V4L2 file handle * @fh: V4L2 file handle
* @state: state of the context * @state: state of the context
* @colorspace: enum v4l2_colorspace; supplemental to pixelformat
* @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
* @quantization: enum v4l2_quantization, colorspace quantization
* @xfer_func: enum v4l2_xfer_func, colorspace transfer function
*/ */
struct mtk_jpeg_ctx { struct mtk_jpeg_ctx {
struct mtk_jpeg_dev *jpeg; struct mtk_jpeg_dev *jpeg;
...@@ -128,11 +117,6 @@ struct mtk_jpeg_ctx { ...@@ -128,11 +117,6 @@ struct mtk_jpeg_ctx {
struct mtk_jpeg_q_data cap_q; struct mtk_jpeg_q_data cap_q;
struct v4l2_fh fh; struct v4l2_fh fh;
enum mtk_jpeg_ctx_state state; enum mtk_jpeg_ctx_state state;
enum v4l2_colorspace colorspace;
enum v4l2_ycbcr_encoding ycbcr_enc;
enum v4l2_quantization quantization;
enum v4l2_xfer_func xfer_func;
}; };
#endif /* _MTK_JPEG_CORE_H */ #endif /* _MTK_JPEG_CORE_H */
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