From patchwork Mon Dec 3 12:46:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709471 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 CAFC414BD for ; Mon, 3 Dec 2018 12:46:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB54D2B31D for ; Mon, 3 Dec 2018 12:46:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF9D02B33E; Mon, 3 Dec 2018 12:46:10 +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 2B0D12B31D for ; Mon, 3 Dec 2018 12:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbeLCMrD (ORCPT ); Mon, 3 Dec 2018 07:47:03 -0500 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:56628 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726369AbeLCMrD (ORCPT ); Mon, 3 Dec 2018 07:47:03 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TnbvgsFXOfGaRTnbzgjDVY; Mon, 03 Dec 2018 13:46:07 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Sakari Ailus , Hans Verkuil Subject: [PATCH 2/3] vim2m: add buf_validate callback Date: Mon, 3 Dec 2018 13:46:02 +0100 Message-Id: <20181203124603.17932-2-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203124603.17932-1-hverkuil-cisco@xs4all.nl> References: <20181203124603.17932-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfO+cokn8FA6LlsPECxJWLH1nBRThU2KEeyyDkzxQUDI0uw0Dj808+HmtEGQOSzRcTbPTLZ5CnMH9SMygusY71bN03HGCP/txCoYVRK4Vi1QA9x9XQOuU XO4VFWXxxyAkmxkp61TqR97+yrNJLj96Q/K0UBIJ/rBfP9oYc+lGYWnfN6Jhct/u67Uv4ZbJVDtMDKQhuyszUZEKZyx62Hg8fm/rkAkbV2/9HTdQXbEeamY3 6s5SVsGZGq0phX7QjE8NO50D8wvYr3QOFCup9gV3Egc= 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 Split off the field validation from buf_prepare into a new buf_validate function. Field validation for output buffers should be done there since buf_prepare is not guaranteed to be called at QBUF time. Signed-off-by: Hans Verkuil --- drivers/media/platform/vim2m.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c index d01821a6906a..9559be91daca 100644 --- a/drivers/media/platform/vim2m.c +++ b/drivers/media/platform/vim2m.c @@ -753,15 +753,13 @@ static int vim2m_queue_setup(struct vb2_queue *vq, return 0; } -static int vim2m_buf_prepare(struct vb2_buffer *vb) +static int vim2m_buf_validate(struct vb2_buffer *vb) { struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); - struct vim2m_q_data *q_data; dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type); - q_data = get_q_data(ctx, vb->vb2_queue->type); if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { if (vbuf->field == V4L2_FIELD_ANY) vbuf->field = V4L2_FIELD_NONE; @@ -772,6 +770,17 @@ static int vim2m_buf_prepare(struct vb2_buffer *vb) } } + return 0; +} + +static int vim2m_buf_prepare(struct vb2_buffer *vb) +{ + struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); + struct vim2m_q_data *q_data; + + dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type); + + q_data = get_q_data(ctx, vb->vb2_queue->type); if (vb2_plane_size(vb, 0) < q_data->sizeimage) { dprintk(ctx->dev, "%s data will not fit into plane (%lu < %lu)\n", __func__, vb2_plane_size(vb, 0), (long)q_data->sizeimage); @@ -832,6 +841,7 @@ static void vim2m_buf_request_complete(struct vb2_buffer *vb) static const struct vb2_ops vim2m_qops = { .queue_setup = vim2m_queue_setup, + .buf_validate = vim2m_buf_validate, .buf_prepare = vim2m_buf_prepare, .buf_queue = vim2m_buf_queue, .start_streaming = vim2m_start_streaming,