From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752935AbdF2MFW (ORCPT ); Thu, 29 Jun 2017 08:05:22 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:17881 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752689AbdF2MFA (ORCPT ); Thu, 29 Jun 2017 08:05:00 -0400 X-AuditID: cbfec7f4-f79806d000001279-0e-5954ece8339a Subject: Re: [PATCH v3 7/8] [media] s5p-jpeg: Add support for resolution change event To: Thierry Escande , Jacek Anaszewski , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org From: Andrzej Pietrasiewicz Message-id: <0ffcd243-24a2-3cb5-f421-6134a12c25c6@samsung.com> Date: Thu, 29 Jun 2017 14:04:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-version: 1.0 In-reply-to: <1498579734-1594-8-git-send-email-thierry.escande@collabora.com> Content-type: text/plain; charset=utf-8; format=flowed Content-language: en-US Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOKsWRmVeSWpSXmKPExsWy7djPc7ov3oREGtycyGxxe+sGFovLu+aw WfRs2MpqsWzTHyaL/quX2BxYPXbcXcLosXPWXXaPTas62Tw+b5ILYInisklJzcksSy3St0vg yjhzorLgqktFc/Nq1gbGO6ZdjJwcEgImEu3HlzBC2GISF+6tZ+ti5OIQEljKKHF1yXRWCOcz o8TR2deBMhxgHRu+yULElzFKnJ7xF6roBZDTe4YNZJSwQLjExxv7WUASIgITGCUObNvJDpJg FrCV6DjUyQJiswkYS+w92MEIMpVXwE7i6iZREJNFQFViz4FSkApRgQiJRZMmgnXyCghK/Jh8 D6yTU8BX4k3vDkaIiVYSz/61skLY4hLNrTdZIGx5ic1r3jKDnCAhsIhdouHpKyaIB2QlN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/OLkEgh3pTEyqrU ovz4otKc1OJDjKZAv01klhJNzgemgbySeEMTQ3NLQyNjCwtzIyMlcd6pH66ECwmkJ5akZqem FqQWwfQxcXBKNTDGeExmv/Vh53Htwu1y090v1U1NvrKi53f5w42Cv4oz78/sPqawRjGHcY8O V8vs9NoZd4Vc/vEb7l5v9Ekp99HcyZxV7556HPftYXtslKP7TDlIW1dq2QreCfaGPxe1Xwk4 2cO0Z69OpZRsr6z3tiZV/r+CVQ7O6v8WHPdqtjvmcefuzZsLvuxWYinOSDTUYi4qTgQAO9NU ncsCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170629120455eucas1p2f539155452854ad09dac19ce2060e2fe X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?QW5kcnplaiBQaWV0cmFzaWV3aWN6G1NSUE9MLUtlcm5lbCAo?= =?UTF-8?B?VFApG+yCvOyEseyghOyekBtTZW5pb3IgU29mdHdhcmUgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QW5kcnplaiBUb21hc3ogUGlldHJhc2lld2ljehtTUlBPTC1L?= =?UTF-8?B?ZXJuZWwgKFRQKRtTYW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2Fy?= =?UTF-8?B?ZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170627161104epcas2p4480e376fb194d189571797699c55295b X-RootMTR: 20170627161104epcas2p4480e376fb194d189571797699c55295b References: <1498579734-1594-1-git-send-email-thierry.escande@collabora.com> <1498579734-1594-8-git-send-email-thierry.escande@collabora.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org W dniu 27.06.2017 o 18:08, Thierry Escande pisze: > From: henryhsu > > This patch adds support for resolution change event to notify clients so > they can prepare correct output buffer. When resolution change happened, > G_FMT for CAPTURE should return old resolution and format before CAPTURE > queues streamoff. > > This event is used in the Chromium browser project by the V4L2 JPEG > Decode Accelerator (V4L2JDA) to allocate output buffer. > > Signed-off-by: Henry-Ruey Hsu > Signed-off-by: Thierry Escande Acked-by: Andrzej Pietrasiewicz > --- > drivers/media/platform/s5p-jpeg/jpeg-core.c | 106 +++++++++++++++++++++------- > drivers/media/platform/s5p-jpeg/jpeg-core.h | 7 ++ > 2 files changed, 89 insertions(+), 24 deletions(-) > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c > index cca0fb8..5ad3d43 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1633,8 +1634,6 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) > FMT_TYPE_OUTPUT : FMT_TYPE_CAPTURE; > > q_data->fmt = s5p_jpeg_find_format(ct, pix->pixelformat, f_type); > - q_data->w = pix->width; > - q_data->h = pix->height; > if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG) { > /* > * During encoding Exynos4x12 SoCs access wider memory area > @@ -1642,6 +1641,8 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) > * the JPEG_IMAGE_SIZE register. In order to avoid sysmmu > * page fault calculate proper buffer size in such a case. > */ > + q_data->w = pix->width; > + q_data->h = pix->height; > if (ct->jpeg->variant->hw_ex4_compat && > f_type == FMT_TYPE_OUTPUT && ct->mode == S5P_JPEG_ENCODE) > q_data->size = exynos4_jpeg_get_output_buffer_size(ct, > @@ -1717,6 +1718,15 @@ static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv, > return s5p_jpeg_s_fmt(fh_to_ctx(priv), f); > } > > +static int s5p_jpeg_subscribe_event(struct v4l2_fh *fh, > + const struct v4l2_event_subscription *sub) > +{ > + if (sub->type == V4L2_EVENT_SOURCE_CHANGE) > + return v4l2_src_change_event_subscribe(fh, sub); > + > + return -EINVAL; > +} > + > static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx, > struct v4l2_rect *r) > { > @@ -2042,6 +2052,9 @@ static const struct v4l2_ioctl_ops s5p_jpeg_ioctl_ops = { > > .vidioc_g_selection = s5p_jpeg_g_selection, > .vidioc_s_selection = s5p_jpeg_s_selection, > + > + .vidioc_subscribe_event = s5p_jpeg_subscribe_event, > + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, > }; > > /* > @@ -2434,8 +2447,17 @@ static int s5p_jpeg_job_ready(void *priv) > { > struct s5p_jpeg_ctx *ctx = priv; > > - if (ctx->mode == S5P_JPEG_DECODE) > + if (ctx->mode == S5P_JPEG_DECODE) { > + /* > + * We have only one input buffer and one output buffer. If there > + * is a resolution change event, no need to continue decoding. > + */ > + if (ctx->state == JPEGCTX_RESOLUTION_CHANGE) > + return 0; > + > return ctx->hdr_parsed; > + } > + > return 1; > } > > @@ -2514,6 +2536,30 @@ static int s5p_jpeg_buf_prepare(struct vb2_buffer *vb) > return 0; > } > > +static void s5p_jpeg_set_capture_queue_data(struct s5p_jpeg_ctx *ctx) > +{ > + struct s5p_jpeg_q_data *q_data = &ctx->cap_q; > + > + q_data->w = ctx->out_q.w; > + q_data->h = ctx->out_q.h; > + > + /* > + * This call to jpeg_bound_align_image() takes care of width and > + * height values alignment when user space calls the QBUF of > + * OUTPUT buffer after the S_FMT of CAPTURE buffer. > + * Please note that on Exynos4x12 SoCs, resigning from executing > + * S_FMT on capture buffer for each JPEG image can result in a > + * hardware hangup if subsampling is lower than the one of input > + * JPEG. > + */ > + jpeg_bound_align_image(ctx, &q_data->w, S5P_JPEG_MIN_WIDTH, > + S5P_JPEG_MAX_WIDTH, q_data->fmt->h_align, > + &q_data->h, S5P_JPEG_MIN_HEIGHT, > + S5P_JPEG_MAX_HEIGHT, q_data->fmt->v_align); > + > + q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3; > +} > + > static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) > { > struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); > @@ -2521,7 +2567,18 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) > > if (ctx->mode == S5P_JPEG_DECODE && > vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { > - struct s5p_jpeg_q_data *q_data; > + static const struct v4l2_event ev_src_ch = { > + .type = V4L2_EVENT_SOURCE_CHANGE, > + .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION, > + }; > + struct vb2_queue *dst_vq; > + u32 ori_w; > + u32 ori_h; > + > + dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, > + V4L2_BUF_TYPE_VIDEO_CAPTURE); > + ori_w = ctx->out_q.w; > + ori_h = ctx->out_q.h; > > ctx->hdr_parsed = s5p_jpeg_parse_hdr(&ctx->out_q, > (unsigned long)vb2_plane_vaddr(vb, 0), > @@ -2532,28 +2589,18 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) > return; > } > > - q_data = &ctx->cap_q; > - q_data->w = ctx->out_q.w; > - q_data->h = ctx->out_q.h; > - > /* > - * This call to jpeg_bound_align_image() takes care of width and > - * height values alignment when user space calls the QBUF of > - * OUTPUT buffer after the S_FMT of CAPTURE buffer. > - * Please note that on Exynos4x12 SoCs, resigning from executing > - * S_FMT on capture buffer for each JPEG image can result in a > - * hardware hangup if subsampling is lower than the one of input > - * JPEG. > + * If there is a resolution change event, only update capture > + * queue when it is not streaming. Otherwise, update it in > + * STREAMOFF. See s5p_jpeg_stop_streaming for detail. > */ > - jpeg_bound_align_image(ctx, > - &q_data->w, > - S5P_JPEG_MIN_WIDTH, S5P_JPEG_MAX_WIDTH, > - q_data->fmt->h_align, > - &q_data->h, > - S5P_JPEG_MIN_HEIGHT, S5P_JPEG_MAX_HEIGHT, > - q_data->fmt->v_align); > - > - q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3; > + if (ctx->out_q.w != ori_w || ctx->out_q.h != ori_h) { > + v4l2_event_queue_fh(&ctx->fh, &ev_src_ch); > + if (vb2_is_streaming(dst_vq)) > + ctx->state = JPEGCTX_RESOLUTION_CHANGE; > + else > + s5p_jpeg_set_capture_queue_data(ctx); > + } > } > > v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); > @@ -2573,6 +2620,17 @@ static void s5p_jpeg_stop_streaming(struct vb2_queue *q) > { > struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(q); > > + /* > + * STREAMOFF is an acknowledgment for resolution change event. > + * Before STREAMOFF, we still have to return the old resolution and > + * subsampling. Update capture queue when the stream is off. > + */ > + if (ctx->state == JPEGCTX_RESOLUTION_CHANGE && > + q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { > + s5p_jpeg_set_capture_queue_data(ctx); > + ctx->state = JPEGCTX_RUNNING; > + } > + > pm_runtime_put(ctx->jpeg->dev); > } > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h b/drivers/media/platform/s5p-jpeg/jpeg-core.h > index 4492a35..9aa26bd 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h > @@ -98,6 +98,11 @@ enum exynos4_jpeg_img_quality_level { > QUALITY_LEVEL_4, /* low */ > }; > > +enum s5p_jpeg_ctx_state { > + JPEGCTX_RUNNING = 0, > + JPEGCTX_RESOLUTION_CHANGE, > +}; > + > /** > * struct s5p_jpeg - JPEG IP abstraction > * @lock: the mutex protecting this structure > @@ -220,6 +225,7 @@ struct s5p_jpeg_q_data { > * @hdr_parsed: set if header has been parsed during decompression > * @crop_altered: set if crop rectangle has been altered by the user space > * @ctrl_handler: controls handler > + * @state: state of the context > */ > struct s5p_jpeg_ctx { > struct s5p_jpeg *jpeg; > @@ -235,6 +241,7 @@ struct s5p_jpeg_ctx { > bool hdr_parsed; > bool crop_altered; > struct v4l2_ctrl_handler ctrl_handler; > + enum s5p_jpeg_ctx_state state; > }; > > /** >