Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp906383rwj; Fri, 23 Dec 2022 09:34:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBQeMtvf20RfYVaaN4Lj48J6EDEpJXrdCpEgykXQ2+erwZDBYsZ1U4BJ7mTNTadxR3YmST X-Received: by 2002:a50:eac6:0:b0:45a:7d2:9b35 with SMTP id u6-20020a50eac6000000b0045a07d29b35mr9021420edp.0.1671816878550; Fri, 23 Dec 2022 09:34:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671816878; cv=none; d=google.com; s=arc-20160816; b=BoPnlMQJvLHDH77V/sa0sU+4BMbuC8fXaX1qETbkAWQMGFGgILfsDLDQGPifNH6jaY 22foYROEVZWOrxCuBLINsuDrMYYhI53i/ICzuKANEiH6ghmgcGopAk6s8nPa/Req77/E uDGd6p1YjLf3e5Qla0DA16azMaBlg5gCV/hoiPlK9NYLNHGo4i1QDno/JE/rREVsQCGC zJOZFBpaptVCEl3yaZLXGyJu6T5Qj6zOseKYQeUi/XjwgpRCx3mL+7JdzpjMr+y7R7Zr Hu7/9G0NQYidjqGyipUrNuU+pHg5J4bs54WL9k0323Q4OPnTP+L6e/4zHKZ2cYeU+TPR Bxuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=XCGMNcHEtDYsj2XnjawNSDwdZAYMSCCEpT245iGWo7Y=; b=v/mNAKCD8BvNSHO+kHjipFen7lG8CL3kH4SbP8kzHJbmU5gcOmk48MqnsNFhStrQHA uilTgmjYM3GiU8y2LcZaKg1XQhPvIx8wIewXVNf2CS5U0Q0HPqWKLRtJlRIhNhPuIOWI XDN+vpmKvgC7Kn8K16CoIxLDYe895OiDktGukz9ikknZH4LGNHN45ojk6g0EhsDnBqKp 2p2g0DbLk95L5aKol9nJD0MiJ2kXD8DDGxvCXbCgNq7H7Mm1UiEkh/qZ3VXvxLzID2em PnwMg71XbGYIKgdmE4CUFm1NuNPcLyPtY73e6ASOBF/bOYcO3bItKwjCeHrd/zTeRu/d kh+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AozgfGUB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020aa7dc08000000b0047ee55bfa3asi2703693edu.176.2022.12.23.09.34.21; Fri, 23 Dec 2022 09:34:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AozgfGUB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230453AbiLWRFi (ORCPT + 65 others); Fri, 23 Dec 2022 12:05:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbiLWRFf (ORCPT ); Fri, 23 Dec 2022 12:05:35 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A8718345; Fri, 23 Dec 2022 09:05:33 -0800 (PST) Received: from nicolas-tpx395.localdomain (192-222-136-102.qc.cable.ebox.net [192.222.136.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id 05A0A6602CDF; Fri, 23 Dec 2022 17:05:30 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1671815132; bh=DilnnI7vRaCXcahELlHtM/5jZDRYaD/HhEUVFXz7hWo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AozgfGUBs7euhdMl7UmO4pz9LJ8Iyx0U7Nu8qcQhw2Y4bpNw8roJ2d8f6lTGWVu13 oXIx6dTkzcMqNGb6lj9x887/uj8CcZ+z4e/Mho0R8FdLumxopwN066s2Q9LJgkNVs0 FgvDlOYcNngeVjDKiF1T+9PoaNSUKq7RQ1vWDbjCLVGMr4rVeDbzrSMaFHUYLQkMp7 dztTC5CFVglT/+TeZX8hb7SESVRFGnpHoRIT9CZ79ljb1brmVqcl7ydr57zkCE7gxQ 0Wl10NEAKdJ1CR3vxjRegH5Yg+W8/KDtLMkZRwq9Pd+T9r+n5hoVX8/dJVLHLXzl0g vq4t3OVFzsG9w== Message-ID: <6449640fcfbbfd4b72e619f03704b7e9031a8a17.camel@collabora.com> Subject: Re: [PATCH] hantro: Fix JPEG encoder ENUM_FRAMESIZE on RK3399 From: Nicolas Dufresne To: Ezequiel Garcia Cc: Philipp Zabel , Mauro Carvalho Chehab , Heiko Stuebner , Hans Verkuil , kernel@collabora.com, Robert Mader , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 23 Dec 2022 12:05:21 -0500 In-Reply-To: References: <20221223141644.703088-1-nicolas.dufresne@collabora.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.2 (3.46.2-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le vendredi 23 d=C3=A9cembre 2022 =C3=A0 13:28 -0300, Ezequiel Garcia a =C3= =A9crit=C2=A0: > Hi everyone, >=20 > On Fri, Dec 23, 2022 at 11:17 AM Nicolas Dufresne > wrote: > >=20 > > The frmsize structure was left initialize to 0, as side effect, the dri= ver was > > reporting an invalid frmsize. > >=20 > > Size: Stepwise 0x0 - 0x0 with step 0/0 > >=20 > > Fix this by replicating the constraints in the raw formats too. This fi= xes > > taking picture in Gnome Cheese Software, or any software using GSteamer > > encodebin feature. > >=20 > > Fixes: 775fec69008d30 ("media: add Rockchip VPU JPEG encoder driver") >=20 > The frmsize is only for bitstream formats (see comment in struct hantro_f= mt). > If I can read code correctly, this was broken by this commit: >=20 > commit 79c987de8b35421a2a975982929f150dd415f8f7 > Author: Benjamin Gaignard > Date: Mon Apr 4 18:06:40 2022 +0200 >=20 > media: hantro: Use post processor scaling capacities >=20 > Before that commit we used to return EINVAL for enum_framesizes > in RAW formats. I guess we missed that :-) I see, and gstreamer had a quirk for such a bogus response. Let me explain = why its bogus, for the general knowlege. A driver that supports ENUM_FRAMESIZE = but does not return any sizes, is in theory a driver that does not support anyt= hing. Fortunaly, GStreamer considered not having a single framesize bogus, and wo= uld fallback to the old school try_fmt() dance to find the supported sizes. So yes, it used to work in gstreamer, and its indeed 79c987de8b35421a2a975982929f150dd415f8f7 that broke it. I'll correct his in= V2. >=20 > To be completely honest, I'm not sure if we used to support encodebin, > and I'm not too sure how to approach this issue, but I would really > love to start with something super simple like: >=20 > diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c > b/drivers/media/platform/verisilicon/hantro_v4l2.c > index 2c7a805289e7..0b28f86b7463 100644 > --- a/drivers/media/platform/verisilicon/hantro_v4l2.c > +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c > @@ -161,8 +161,11 @@ static int vidioc_enum_framesizes(struct file > *file, void *priv, > } >=20 > /* For non-coded formats check if postprocessing scaling is possi= ble */ > - if (fmt->codec_mode =3D=3D HANTRO_MODE_NONE && > hantro_needs_postproc(ctx, fmt)) { > - return hanto_postproc_enum_framesizes(ctx, fsize); > + if (fmt->codec_mode =3D=3D HANTRO_MODE_NONE) > + if (hantro_needs_postproc(ctx, fmt)) > + return hanto_postproc_enum_framesizes(ctx, fsize); > + else > + return -ENOTTY; > } else if (fsize->index !=3D 0) { > vpu_debug(0, "invalid frame size index (expected 0, got %= d)\n", > fsize->index); >=20 > (ENOTTY was suggested by Nicolas on IRC) >=20 > Nicolas also pointed out that our current handling of frmsize is not corr= ect, > as we cannot express different constraints on combinations of RAW > and bitstream formats. >=20 > This seems to call for a rework of enum_framesizes, so frmsize > is not static but somehow obtained per-codec. So I'll respin along these line to we more or less "revert back" to working state. Though having a framesize enumeration on encoder raw (OUTPUT queue) = is what makes most sense so that will have to be revisited with a corrected mechanism, as whenever we add VP8 and H.264 encoding, we'll need different = range per codec. I'll check in January with my colleague, we might do that inside= the VP8 encoder branch (that is nearly ready and will be sent after the holiday= s), or could be an intermediate set. regards, Nicolas >=20 > Thanks, > Ezequiel >=20 > > Reported-by: Robert Mader > > Signed-off-by: Nicolas Dufresne >=20 > And thanks a lot for the report and the patch! >=20