From patchwork Sat Aug 4 12:45:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10555715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 700C36CB for ; Sat, 4 Aug 2018 12:45:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62E4E2A13A for ; Sat, 4 Aug 2018 12:45:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 575262A146; Sat, 4 Aug 2018 12:45:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B61CC2A13A for ; Sat, 4 Aug 2018 12:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729683AbeHDOqR (ORCPT ); Sat, 4 Aug 2018 10:46:17 -0400 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:54953 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727513AbeHDOqN (ORCPT ); Sat, 4 Aug 2018 10:46:13 -0400 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id lvvyfCzUl6brUlvw8fFM6a; Sat, 04 Aug 2018 14:45:36 +0200 From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCHv17 31/34] vim2m: support requests Date: Sat, 4 Aug 2018 14:45:23 +0200 Message-Id: <20180804124526.46206-32-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180804124526.46206-1-hverkuil@xs4all.nl> References: <20180804124526.46206-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfMfoZIowzRMLFYhM/5clPbPkVpwXv/qzfc/960QgLA2xrqT3qiYaOTcuSo1dx+Z5TuIeEVLy23T/2WjC06XjHv9tUi4IlV0biDpfmHtd9KMksB286Nh6 HzCz5fhzSsFpcjcdZl+lJeijnG8wIx1OEYLZJwO1O66n11LJ1IGE5CdJDAvoeCp7f1inHQzcxdj4FRNTyFgxt5y2bD0rVAzo1Fg= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Add support for requests to vim2m. Signed-off-by: Hans Verkuil Reviewed-by: Mauro Carvalho Chehab --- drivers/media/platform/vim2m.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c index 6f87ef025ff1..3b8df2c9d24a 100644 --- a/drivers/media/platform/vim2m.c +++ b/drivers/media/platform/vim2m.c @@ -379,8 +379,18 @@ static void device_run(void *priv) src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); + /* Apply request controls if needed */ + if (src_buf->vb2_buf.req_obj.req) + v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req, + &ctx->hdl); + device_process(ctx, src_buf, dst_buf); + /* Complete request controls if needed */ + if (src_buf->vb2_buf.req_obj.req) + v4l2_ctrl_request_complete(src_buf->vb2_buf.req_obj.req, + &ctx->hdl); + /* Run delayed work, which simulates a hardware irq */ schedule_delayed_work(&dev->work_run, msecs_to_jiffies(ctx->transtime)); } @@ -808,12 +818,21 @@ static void vim2m_stop_streaming(struct vb2_queue *q) vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); if (vbuf == NULL) return; + v4l2_ctrl_request_complete(vbuf->vb2_buf.req_obj.req, + &ctx->hdl); spin_lock_irqsave(&ctx->dev->irqlock, flags); v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); spin_unlock_irqrestore(&ctx->dev->irqlock, flags); } } +static void vim2m_buf_request_complete(struct vb2_buffer *vb) +{ + struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); + + v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->hdl); +} + static const struct vb2_ops vim2m_qops = { .queue_setup = vim2m_queue_setup, .buf_prepare = vim2m_buf_prepare, @@ -822,6 +841,7 @@ static const struct vb2_ops vim2m_qops = { .stop_streaming = vim2m_stop_streaming, .wait_prepare = vb2_ops_wait_prepare, .wait_finish = vb2_ops_wait_finish, + .buf_request_complete = vim2m_buf_request_complete, }; static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) @@ -988,6 +1008,11 @@ static const struct v4l2_m2m_ops m2m_ops = { .job_abort = job_abort, }; +static const struct media_device_ops m2m_media_ops = { + .req_validate = vb2_request_validate, + .req_queue = vb2_m2m_request_queue, +}; + static int vim2m_probe(struct platform_device *pdev) { struct vim2m_dev *dev; @@ -1036,6 +1061,7 @@ static int vim2m_probe(struct platform_device *pdev) dev->mdev.dev = &pdev->dev; strlcpy(dev->mdev.model, "vim2m", sizeof(dev->mdev.model)); media_device_init(&dev->mdev); + dev->mdev.ops = &m2m_media_ops; dev->v4l2_dev.mdev = &dev->mdev; ret = v4l2_m2m_register_media_controller(dev->m2m_dev,