Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp860003rwj; Fri, 23 Dec 2022 09:00:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXv/+ZtEE8XqaD2WYJWjXmewU85UzDJRZECAXXF+TZvXm8QFLRYtq0IFHXjnyYalEL1QGCeK X-Received: by 2002:a17:90a:ec0a:b0:223:d07e:f6d2 with SMTP id l10-20020a17090aec0a00b00223d07ef6d2mr11470593pjy.33.1671814812086; Fri, 23 Dec 2022 09:00:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671814812; cv=none; d=google.com; s=arc-20160816; b=gYSybsCrYtaw2NwKxjSWqPpTItHBenkFL7gx5HlKQNURuOTPhb8EQuQE9tVlk8BEKk kibIBaOtJofbZqZKGr5yZhvhy2uADiGtGPHjuMHTe09p3cHz5Uoh/t8+prpPr2soI5tk +74djbVeO2yenNU5MHZLHrGlhdh/Y9rT2b6UxS1jRfaVJGVT2XuGzjlFjM7f8tH4Qn1b T+DyB9ORxUOK3y9EyIJr8N/srpSAxiZBbZ7PQEkfCVV0Oq+ZcryQZGVgdIOmMtFmttAc BY1pRtdxFpbFFxFcy/5nNbDnC35A8zmYD9irlfAZQqIHuZeKCYgKXoMCxAZFFw9yKzF6 1Ccw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4N34Q6vegmizYVH/tay3YsZhocDkMZUURFeC6HW8OZY=; b=icZwvK7oAjV/CZpQzXGYFXExf6WJocYyjC1dcFWz/K9lxAITpj3YOgpfmkM4IlU+zb x9S1bnA7AC4iA0dfoXv/1qJiQ5fmr5KjnmCIVRw6M82qh3fOlxogyQD+bShw98O16V6e 1rO2q+W9ZCEM/BbbSj24UXNR5/s0BZGR2RUbVOOHn9pfJZr/UgW49xXuwlyHJoHzwZia lrbT9rEBknhp+iv6gZx8TNm7xOb6N4KA8bkpLSaOf+fjo9SrFH877scGIqFZ3Girhjf7 lvYTsSIZGIiGi7u84x8naSTzhTWiqx9gprFf3ZeBuPQq7Js41t6dQ8lZ5ogi6y+QDOWn 67bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20210112.gappssmtp.com header.s=20210112 header.b=26oprJ2y; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a6563cc000000b00477c8923f79si4104146pgv.449.2022.12.23.09.00.03; Fri, 23 Dec 2022 09:00:12 -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=@vanguardiasur-com-ar.20210112.gappssmtp.com header.s=20210112 header.b=26oprJ2y; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231908AbiLWQ2X (ORCPT + 65 others); Fri, 23 Dec 2022 11:28:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231889AbiLWQ2U (ORCPT ); Fri, 23 Dec 2022 11:28:20 -0500 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28D5B11A15 for ; Fri, 23 Dec 2022 08:28:17 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id f16so5515923ljc.8 for ; Fri, 23 Dec 2022 08:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4N34Q6vegmizYVH/tay3YsZhocDkMZUURFeC6HW8OZY=; b=26oprJ2ySY43mmV/tXV+KTU60nkGFIzDG3APBYN9J7MEhdLnpDrnO5HG6WFMBpBBgh qFu66TOEn+q+AhINcJOW7GKj+A63DO8IPA+U40QxUdt739fPp4ZY+5++iiVWHE0dGGdS t/FUX7GzA49xmUPahdQ/hA4sk1yMNwS3FkBtAQ2rR5Ce8A9e88Z+iotx4hK6U4naZJpV 3p02qf4nExBet0Qciw3epPpAylNQyalQcrY0Uzz+2IxvZEW8v50GZBZazI+TUbQ/CyZK pL+7xggp/WZXVwUFX4/SOCKIVje8q6CdATw1oQtY/XRMLK4dPrZhfQKJTzxUZPo4N1EK MF6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4N34Q6vegmizYVH/tay3YsZhocDkMZUURFeC6HW8OZY=; b=B13JO6x2WBIjt2fvqjX+dNRJ/eQfsyRSTTszckJq2CQfAhEatDM+rnkNzJHfF5UYcf RGa3iAF19A7wp+WCBf4iCcJk4z2gleQA4QGBWOOSbyqyiTCdN7hOcRJ1uCn1I/K21n6U q0jT4Y1aFf54wWfnXF5+t2y7b2I2/nejEGZeES0VkDvpas5u4hB6iR+KI9d/TkbOUe2h ctlgOAQJfteObe/K5UoVCVmsa7LuX1uKS41Dr3Fm/VEfdBPQlpNjsE8t97Ug+eM546rk eC0OyTEWTCHToV7OX3LZcAoO154pByzRWY3olIIi69bTd8dXMa70KP281pwnWDCd/oKq SLrQ== X-Gm-Message-State: AFqh2kotfiX2pq1yJ/1gVwGg5LGJZ5M6cRfzPWhQ9mYRxFjy2lURYEDb TlPWwRFEbWnqvxF54y4HueR516T4/sTVProXa5481waXIN8KP92q X-Received: by 2002:a2e:7016:0:b0:27a:306:5dfd with SMTP id l22-20020a2e7016000000b0027a03065dfdmr741643ljc.72.1671812895550; Fri, 23 Dec 2022 08:28:15 -0800 (PST) MIME-Version: 1.0 References: <20221223141644.703088-1-nicolas.dufresne@collabora.com> In-Reply-To: <20221223141644.703088-1-nicolas.dufresne@collabora.com> From: Ezequiel Garcia Date: Fri, 23 Dec 2022 13:28:03 -0300 Message-ID: Subject: Re: [PATCH] hantro: Fix JPEG encoder ENUM_FRAMESIZE on RK3399 To: Nicolas Dufresne 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 everyone, On Fri, Dec 23, 2022 at 11:17 AM Nicolas Dufresne wrote: > > The frmsize structure was left initialize to 0, as side effect, the driver was > reporting an invalid frmsize. > > Size: Stepwise 0x0 - 0x0 with step 0/0 > > Fix this by replicating the constraints in the raw formats too. This fixes > taking picture in Gnome Cheese Software, or any software using GSteamer > encodebin feature. > > Fixes: 775fec69008d30 ("media: add Rockchip VPU JPEG encoder driver") The frmsize is only for bitstream formats (see comment in struct hantro_fmt). If I can read code correctly, this was broken by this commit: commit 79c987de8b35421a2a975982929f150dd415f8f7 Author: Benjamin Gaignard Date: Mon Apr 4 18:06:40 2022 +0200 media: hantro: Use post processor scaling capacities Before that commit we used to return EINVAL for enum_framesizes in RAW formats. I guess we missed that :-) 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: 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, } /* For non-coded formats check if postprocessing scaling is possible */ - if (fmt->codec_mode == HANTRO_MODE_NONE && hantro_needs_postproc(ctx, fmt)) { - return hanto_postproc_enum_framesizes(ctx, fsize); + if (fmt->codec_mode == HANTRO_MODE_NONE) + if (hantro_needs_postproc(ctx, fmt)) + return hanto_postproc_enum_framesizes(ctx, fsize); + else + return -ENOTTY; } else if (fsize->index != 0) { vpu_debug(0, "invalid frame size index (expected 0, got %d)\n", fsize->index); (ENOTTY was suggested by Nicolas on IRC) Nicolas also pointed out that our current handling of frmsize is not correct, as we cannot express different constraints on combinations of RAW and bitstream formats. This seems to call for a rework of enum_framesizes, so frmsize is not static but somehow obtained per-codec. Thanks, Ezequiel > Reported-by: Robert Mader > Signed-off-by: Nicolas Dufresne And thanks a lot for the report and the patch!