Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1202343lqb; Thu, 30 May 2024 03:32:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXt/WV5+weChQEMP9f60vzDeypenrEdXa3T9hgp0v1b5/H2xOxkVQKfxEXmH+w4Bh+6kPOQtf4IUuMvM/1xCsHzTtjPfEgXieSDDJR+Sg== X-Google-Smtp-Source: AGHT+IEKsNmBBwlVDc0o+37Ys3jan4CfjQtdmSVQSk3jEtkZA9GAqS4PKW5lx9Np+v7Fwq9CU/Ia X-Received: by 2002:a50:8e15:0:b0:57a:19f5:76cd with SMTP id 4fb4d7f45d1cf-57a19f57779mr903061a12.19.1717065131506; Thu, 30 May 2024 03:32:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717065131; cv=pass; d=google.com; s=arc-20160816; b=nAk7JnW/Oqw05NpRjA0k9SbwkKckxrHjIl/yj1WhZ70im3t5p7dR04k5pF1eSPeCYr iimUCB0kxGz6GensyiVXCsIF/9TNsNqxSs4/VFaxDHY/N2wCc0y26ibt7qUZjwfYgq4S rMYcj+7ZQU19Zi5WnOunRcF61u/iiiw41S0bUOXizqvDvYInnWKUvRmvxGJRZ+5Tej9V Q+0HD7S6DzSNa4U5sGpXpuaVHm2g5uMHRm0XI1Igrj2Ea4/P7Jp6pFK3CTtLfVSuLSsm n6zQ2/wRzuTFpTXH3jMfYJWh8xpj5l+YALXHPExtL37oJKpOSECzHfy15vaSAPnIYqAZ LFSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=iyiGRCLQo5jTCBOqRBJKAgRlh5j1q2jz3KB9Ro2br98=; fh=3vXm4rg0LR6rDyVCUXmwJn1C8Bx1y9yMGBoc0vFzkKw=; b=PErByjDysdLR32eoIPSAMZQTzy98JrPIon/yUUet+TeDLdHKl8br6qyAt1Qv+cKaFi nQ3fhHL/ESNyoqS7TsDRLzGCIJiAQ76xoqG4Nizm0+u2Xby/tNiX9C0Cs7+bqa7ZEL5t kTtN84dXFXK3uKAjzoqnsUiZvP/OZp4G9bggLY93vOP4QrutCCR5fLu1SjSSNzWcl0sF sjxCwbHeW3kSKhQyj921birkAG6/1NprQwflFtjEGwxHyBnPg9OjfERS5mauT4Yw8LN5 VWfD7l/HIIwiaHLVRyipFn2UNWmdUFzWZN6ucm/ZFvmHU5548w+VO+F+y+vs4isSwXMF kryg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-195264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a243a79afsi351209a12.256.2024.05.30.03.32.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 03:32:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-195264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 15B4A1F23DD2 for ; Thu, 30 May 2024 10:32:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4605F17C7A1; Thu, 30 May 2024 10:32:03 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A45C2183965; Thu, 30 May 2024 10:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065122; cv=none; b=XSp1YS2I6aHTW3JuHhZ8ckVZPSfT+1kzuxQDgt0/qQM9dRwS15AFJ9po6eIdkmH9y8voX8d7O/956ZwnBLpBNOnbWrRw8pJeLZ8icqK1o/lycABOgcp8qNgsiXz0QmRFbxZuW1X4A82ppyp0aAAEWh7oHovW8+IjftsAXCx0hAI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065122; c=relaxed/simple; bh=YLlmJ33QAXAGokrUhIV1Wqhjw+NfUL8PMllVM2CeyzM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IhrZk/u+cHQJRGOh3Sn448gfjgMfl3hUnrqAja6U7QBeQ+V2e1jgFul5L1rvUf7IcShVE8BkZ8yCbxVqscNaE2OxyXYLympcWY3Djl8ykECkDniXJn0l96HTDx+cu9qsu0zgfVvCgk6UUon2u6EttDaeVaUoYxKMpxnnAdYpGlA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13286C2BBFC; Thu, 30 May 2024 10:32:00 +0000 (UTC) Message-ID: Date: Thu, 30 May 2024 12:31:59 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] media: uapi: v4l: Change V4L2_TYPE_IS_CAPTURE condition To: Nas Chung , mchehab@kernel.org, linux-media@vger.kernel.org, sebastian.fricke@collabora.com, m.tretter@pengutronix.de Cc: linux-kernel@vger.kernel.org References: <20240528020425.4994-1-nas.chung@chipsnmedia.com> Content-Language: en-US, nl From: Hans Verkuil Autocrypt: addr=hverkuil@xs4all.nl; keydata= xsFNBFQ84W0BEAC7EF1iL4s3tY8cRTVkJT/297h0Hz0ypA+ByVM4CdU9sN6ua/YoFlr9k0K4 BFUlg7JzJoUuRbKxkYb8mmqOe722j7N3HO8+ofnio5cAP5W0WwDpM0kM84BeHU0aPSTsWiGR yw55SOK2JBSq7hueotWLfJLobMWhQii0Zd83hGT9SIt9uHaHjgwmtTH7MSTIiaY6N14nw2Ud C6Uykc1va0Wqqc2ov5ihgk/2k2SKa02ookQI3e79laOrbZl5BOXNKR9LguuOZdX4XYR3Zi6/ BsJ7pVCK9xkiVf8svlEl94IHb+sa1KrlgGv3fn5xgzDw8Z222TfFceDL/2EzUyTdWc4GaPMC E/c1B4UOle6ZHg02+I8tZicjzj5+yffv1lB5A1btG+AmoZrgf0X2O1B96fqgHx8w9PIpVERN YsmkfxvhfP3MO3oHh8UY1OLKdlKamMneCLk2up1Zlli347KMjHAVjBAiy8qOguKF9k7HOjif JCLYTkggrRiEiE1xg4tblBNj8WGyKH+u/hwwwBqCd/Px2HvhAsJQ7DwuuB3vBAp845BJYUU3 06kRihFqbO0vEt4QmcQDcbWINeZ2zX5TK7QQ91ldHdqJn6MhXulPKcM8tCkdD8YNXXKyKqNl UVqXnarz8m2JCbHgjEkUlAJCNd6m3pfESLZwSW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IIQn1TOkuXrciTVfZY1cZD0aVxwlxXBnUNZZNslldvXFtndxR0SFat sflovhDxKyhFwXOP0Rv8H378/+14TaykknRBIKEc0+lcr+EMOSUR5eg4aURb8Gc3Uc7fgQ6q UssTXzHPyj1hAyDpfu8DzAwlh4kKFTodxSsKAjI45SLjadSc94/5Gy8645Y1KgBzBPTH7Q== In-Reply-To: <20240528020425.4994-1-nas.chung@chipsnmedia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 28/05/2024 04:04, Nas Chung wrote: > Explicitly compare a buffer type only with valid buffer types, > to avoid matching the buffer type outside of valid buffer > type set. > > Signed-off-by: Nas Chung > --- > include/uapi/linux/videodev2.h | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index fe6b67e83751..fa2b7086e480 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -157,6 +157,10 @@ enum v4l2_buf_type { > V4L2_BUF_TYPE_PRIVATE = 0x80, > }; > > +#define V4L2_TYPE_IS_VALID(type) \ > + ((type) >= V4L2_BUF_TYPE_VIDEO_CAPTURE \ > + && (type) <= V4L2_BUF_TYPE_META_OUTPUT) > + > #define V4L2_TYPE_IS_MULTIPLANAR(type) \ > ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \ > || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) > @@ -171,7 +175,8 @@ enum v4l2_buf_type { > || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \ > || (type) == V4L2_BUF_TYPE_META_OUTPUT) > > -#define V4L2_TYPE_IS_CAPTURE(type) (!V4L2_TYPE_IS_OUTPUT(type)) > +#define V4L2_TYPE_IS_CAPTURE(type) \ > + (V4L2_TYPE_IS_VALID(type) && !V4L2_TYPE_IS_OUTPUT(type)) > > enum v4l2_tuner_type { > V4L2_TUNER_RADIO = 1, This patch introduced this warning: In function 'find_format_by_index', inlined from 'vdec_enum_fmt' at drivers/media/platform/qcom/venus/vdec.c:452:8: drivers/media/platform/qcom/venus/vdec.c:172:32: warning: 'valid' may be used uninitialized [-Wmaybe-uninitialized] 172 | if (k == index && valid) | ~~~~~~~~~~~^~~~~~~~ drivers/media/platform/qcom/venus/vdec.c: In function 'vdec_enum_fmt': drivers/media/platform/qcom/venus/vdec.c:157:22: note: 'valid' was declared here 157 | bool valid; | ^~~~~ This driver does this: bool valid; if (V4L2_TYPE_IS_OUTPUT(type)) { valid = venus_helper_check_codec(inst, fmt[i].pixfmt); } else if (V4L2_TYPE_IS_CAPTURE(type)) { valid = venus_helper_check_format(inst, fmt[i].pixfmt); With your patch both V4L2_TYPE_IS_OUTPUT(type) and V4L2_TYPE_IS_CAPTURE(type) can return false, something that wasn't possible without this patch. In this driver the fix would just be to drop the second 'if' altogether, so just '} else {'. Since these defines are part of the public API, this change introduces a subtle behavior difference that can affect applications. That said, I do consider this an improvement. I would like some changes, though: 1) Just after "V4L2_BUF_TYPE_META_OUTPUT = 14," in enum v4l2_buf_type, add a comment saying that V4L2_TYPE_IS_VALID and (for output types) V4L2_TYPE_IS_OUTPUT must be updated if a new type is added. It's all too easy to forget that otherwise. 2) Add a patch fixing the venus/vdec.c code. 3) Something else I noticed, but I think this change should be in a separate patch: V4L2_TYPE_IS_OUTPUT() returns true for V4L2_BUF_TYPE_VIDEO_OVERLAY, but that definitely belongs to CAPTURE. Nobody really uses that type anymore, but still, it should be fixed. Regards, Hans