Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp750246ybj; Tue, 5 May 2020 07:04:01 -0700 (PDT) X-Google-Smtp-Source: APiQypJlDQMG2RjFZWQ36v/xOrnNn5cxjap0YiNgdNy3nphF5RT9pqh9R7nR9HwZpzfX8mGqQ9ov X-Received: by 2002:a17:906:355b:: with SMTP id s27mr2881206eja.184.1588687441135; Tue, 05 May 2020 07:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588687441; cv=none; d=google.com; s=arc-20160816; b=Hod5KEwg++7P4xdSlpeknHgYAEsysZpJVUU4d0S+1raZx9U8C8BBxZosUjWBq6Q1l8 kCPpEFHFNL4DlIniFnvCpxZ8fJUubs+5Qh3w4NTWkyt+/LvqG3bgiguOo23zYi1aHJG/ VZ0L4ypEZWzwG+ucymtgwCQPVQSbaNjFa3oLrX0IHftaDFOdVJMyzLctCBMEmIMOgw5r QFEFiPwMTgdWyVLx4CO7c1oL2EGaL0KYiGTNQjwnyU6r95cSKFtXpPIYqW+spwZpeiwH ZYo6zxdXIiPSkKcZ+3gQnvjNd3EqYu1JICFMy+O/lj0ZVMQBZivCS0XnWpV21XLngW79 DH+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=+UbiAYhPZRfUeVMZutaPQ3V3Gnl2w+CohnbPHZBXREs=; b=AeqWVS3AlZP68Y5txZfMOdO7EXCuA3DLCnxSWMVoAQPhxgBs1n4jWRMRsQjM8ha3ox EhPNAEYYRJXkn/B7OvjLVbpXGi5UFlxB+soNXazq9StBTeVUotsr0FAb6rjpCSdGJduS 7d3NWpIDED1trUhs/14MydfeFxaxeenjnZMUWl9suOtwv7nAeUneSHD3DDzoabz5/6g/ xXCI9xmoQdQLt8C/7izVg7wjwxDWl7HFj94LbGTVhiflpJzgld6wuto0VLNOhjAN08K9 SGpOyhq5RIfQzkfO+ImjwPDlsuDxqD+LM1LNaOyx/YwKpzr0uttOpwcSYFRiVtnXm/2k cF6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si1314854edb.178.2020.05.05.07.03.26; Tue, 05 May 2020 07:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729113AbgEEN7q (ORCPT + 99 others); Tue, 5 May 2020 09:59:46 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42496 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbgEEN7q (ORCPT ); Tue, 5 May 2020 09:59:46 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 57E5B2A1C94 Message-ID: Subject: Re: [PATCH v3 1/3] media: rkvdec: Fix .buf_prepare From: Ezequiel Garcia To: Tomasz Figa Cc: Linux Media Mailing List , "open list:ARM/Rockchip SoC..." , Linux Kernel Mailing List , kernel@collabora.com, Jonas Karlman , Heiko Stuebner , Hans Verkuil , Alexandre Courbot , Jeffrey Kardatzke , Gustavo Padovan Date: Tue, 05 May 2020 10:59:35 -0300 In-Reply-To: References: <20200505134110.3435-1-ezequiel@collabora.com> <20200505134110.3435-2-ezequiel@collabora.com> Organization: Collabora Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-05-05 at 15:56 +0200, Tomasz Figa wrote: > Hi Ezequiel, > > On Tue, May 5, 2020 at 3:41 PM Ezequiel Garcia wrote: > > The driver should only set the payload on .buf_prepare > > if the buffer is CAPTURE type, or if an OUTPUT buffer > > has a zeroed payload. > > Thanks for the patch. Just one question below. > > Where does the requirement to set OUTPUT buffer bytesused to sizeimage > if the original bytesused is 0 come from? > If I'm reading english correctly, it's here: https://www.kernel.org/doc/html/latest/media/uapi/v4l/buffer.html """ The number of bytes occupied by the data in the buffer. It depends on the negotiated data format and may change with each buffer for compressed variable size data like JPEG images. Drivers must set this field when type refers to a capture stream, applications when it refers to an output stream. If the application sets this to 0 for an output stream, then bytesused will be set to the size of the buffer (see the length field of this struct) by the driver. For multiplanar formats this field is ignored and the planes pointer is used instead. """ Thanks! Ezequiel > Best regards, > Tomasz > > > Fix it. > > > > Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver") > > Signed-off-by: Ezequiel Garcia > > --- > > drivers/staging/media/rkvdec/rkvdec.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c > > index 225eeca73356..4df2a248ab96 100644 > > --- a/drivers/staging/media/rkvdec/rkvdec.c > > +++ b/drivers/staging/media/rkvdec/rkvdec.c > > @@ -456,7 +456,15 @@ static int rkvdec_buf_prepare(struct vb2_buffer *vb) > > if (vb2_plane_size(vb, i) < sizeimage) > > return -EINVAL; > > } > > - vb2_set_plane_payload(vb, 0, f->fmt.pix_mp.plane_fmt[0].sizeimage); > > + > > + /* > > + * Buffer's bytesused is written by the driver for CAPTURE buffers, > > + * or if the application passed zero bytesused on an OUTPUT buffer. > > + */ > > + if (!V4L2_TYPE_IS_OUTPUT(vq->type) || > > + (V4L2_TYPE_IS_OUTPUT(vq->type) && !vb2_get_plane_payload(vb, 0))) > > + vb2_set_plane_payload(vb, 0, > > + f->fmt.pix_mp.plane_fmt[0].sizeimage); > > return 0; > > } > > > > -- > > 2.26.0.rc2 > >