From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795975673; b=hz4SYqwvVjgOEHdUMTWZvU+enKuUZb4cc3xkYqH6/rfIQtpdMXKwkQv2lisD0svF32yn dUPodZ/q070QSX9dd7crUEuzCZSq3JwkwmPC/bLAcRPPuwp4dfy1RCNqWN/4VLhV9LwLs L89+lDvjz2Q6ZS+Dq/rhRfWsU7X3AsTWuw8Yu2lfnvv3n4mqelg6oSjSfTMmcp8u85Ebn QYghFB8NHUqPLpbIV7GLLU7EwSu06Tomk6NP7DT1X2hoFkgPmhnONiec67AAZYfhoRMlF Y7zii3TzwDFpVdEWHV9nfZNpsfYBU4bTl8RoJc7SuUfzjafi7ip/nlMp+S89fNep0Nw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795975673; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=uxlbvC9L23kPGPsD1z816AUNTgyjyvt1Frf158JY+jI=; b=X+pMqAGfTPl0GEQikd4LhbAcJQzejTBEJw+MGgk68JZ987kraHIHqkk80guyIUs9UwNo WIuc/Oqkf/fUNyR/ac3fO9BqOEGbDpfRyxxLtQJtsSdQhU6Ifz/jWY3sHD4QUUNvfQ/Jn 8dVgItfZj9OPGyhoUjTk+sMSLO66VoSee1z7G82jK0SWK2U8HOIt4oqP71KseabKfniCY KItIEQazKExO+s8DvmQZdJc2GAdB3edCm6cAmpbzimMO74b66Lyu5b+fOe6z2MpXy6icJ fYND665VfTC/WGCNKPyPgNUdQybEGJ4GS0gcrJAIUx3hmeIX89tRhwHNM9hWM4iwioQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k67+gy6u; arc=none smtp.remote-ip=209.85.218.50 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D43B1606A6A9 for ; Sun, 29 Nov 2026 18:07:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D43B1606A6A9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k67+gy6u Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-c515369b627so1061142766b.1 for ; Sun, 29 Nov 2026 10:07:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795975671; x=1796580471; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=uxlbvC9L23kPGPsD1z816AUNTgyjyvt1Frf158JY+jI=; b=k67+gy6uZB660/JQz2rc6mpr93DZtvjrKpP6yni+HbGcj3h4uS5xhxWFkrkc2+sEyN KrCflY+RWloUBzXU2HS1OBzJ9yhqPOTLk1da/nosiGeQU3pmHceGr2tZ8pbTwrYwy2Mt NDR+vTJ5Jfn5JJNdcG1FtcD+SA7TY4o3LUFYf8mn6kni6a75JvqB7/naaVq9hDiPdTzd +Z1LgoMvwXUoIz3Cyq5CVoHsgwMYNUhwNO/Mu1bUskZOdSAi2td7GBtc2Rr64cPsnmzv 29L0iFUYfBpQCHeePjMGeFrwqscHs/Nmss8Qqo5qtaBmEqN0Sz9n2G0AY80RfgHh+neb cEPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795975671; x=1796580471; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=uxlbvC9L23kPGPsD1z816AUNTgyjyvt1Frf158JY+jI=; b=lbfO+NIeeoUG8PdnDZMOFXvo2EjYqLIfcP30r96XnlMjBYc3f6RhmNvIsXSWrOwHQP 14sgiu0PrE6mYrdc0rFpk0kxVbQy05Zr0RiRz7BcAmKQDNm1mzLfDGU2yni//XvcfK75 8splhIysV79Bk9HR95BYyP/dl8dr8sELzJP2op4uZJTpvjS5t+cNOGBRCS4v5UcVtg3h LbOpYAgMoXnKPruI96V8xZlQqNxRYo0OqPJOBStHpgJclnwfIGjeWafk+nkEn2TLa472 OyNTsegrHTZ0EirrQnl3gJ5SZB/oRrqpEiSNCNkJ8db2rBVdlaWI55IlSc1+RK4+bMQC wgJA== X-Gm-Message-State: APuU4Z+J1hl/6GobiaLeq58jc5iZAAhTPW9GauAkN+tBeV8jg9M6JrOb Z9Xz2XPPlnGfSG83b90mhSRmgqRQqUMH7XX9sCGCY6FZLvhNLIsQye40 X-Gm-Gg: AZFdTZdZbJRAeog3cXCa6JpSSRXdiFDnJafSRH91UX6GdV/E4f5EjdJLJkRmmMWNtmm bO0HiHuk8qO0i4w+Fa2oQtpB+L8g+OxQ9RsPMU0K7L01hzSvlluPrRwO6zTnuPvoCdYiMqn+a87 2+eux9IZ8vppFMN03KrYRHUiG569LnlENZErhSoSJ6v+HKz4g8Tze2JxNCnQU0HixYPzkiacQVk Zf4driNR1OjuR8BnCSP5rQJ7A1G1lNcmTNxrbNwZX9678+DXlWff3/zewZHN6mFRq3wBsavSHHD CmwN1oAer/tVzSCRNMtTNPjSMVmQlywz4BXGJoDOv/DnbFZMWU7F1RbrPb4FYiIGlgT9FrMwUj/ ZxI6kQz9hFUpL5N58MMUT3NS4FeYQgG3fNrZ3irLlWzkU8M7wdzLPLM+/cpT8Lwigj0l31j0+yW ckJCicH/OKw/n0smFzLh+xZ2DOCvvVMMac7HM4XJD5RkmHXcyXX0wRTEngGYO0vWcr64m/e2Pm+ XLxTC5oBt7Q7R/AbkXwo/BjZQTOu9JMLp4DlrJ/J2QQnbYd50DQe9+sqHm/rOJu720o47WC4ZcQ tYaVuqJQiQKDsupLoRkOmPTP8zR1agrOuK1nbdOcgvirfBZmR8GYKPg06NnuBM7k3tWBB0dKKew y7sdpnoieGg== X-Received: by 2002:a17:906:409a:b0:c46:9d50:8af0 with SMTP id a640c23a62f3a-c513ac9a35bmr1797235466b.36.1795975671009; Sun, 29 Nov 2026 10:07:51 -0800 (PST) Received: from xeon ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513ae8ce16sm1061518266b.37.2026.11.29.10.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 10:07:50 -0800 (PST) From: Svyatoslav Ryhel To: Mauro Carvalho Chehab , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Greg Kroah-Hartman , Svyatoslav Ryhel , Hans Verkuil , Mikko Perttunen Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 07/15] media: tegra-video: vi: Match fourcc against channel format bitmap Date: Sun, 29 Nov 2026 20:07:14 +0200 Message-ID: <20261129180722.142186-8-clamor95@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261129180722.142186-1-clamor95@gmail.com> References: <20261129180722.142186-1-clamor95@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jonas Schwöbel Update tegra_get_format_by_fourcc() to accept a struct tegra_vi_channel pointer and match fourcc values against the channel's TPG or subdevice format bitmap, updating callers in vi.c accordingly. This is required because VI supports different media bus formats with the same pixel format, so only the first matching instance would be returned without checking whether the index is among the supported formats. Co-developed-by: Svyatoslav Ryhel Signed-off-by: Jonas Schwöbel Signed-off-by: Svyatoslav Ryhel --- .../media/platform/nvidia/tegra-video/vi.c | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/nvidia/tegra-video/vi.c b/drivers/media/platform/nvidia/tegra-video/vi.c index 2a0ffdd3896f6..15f05ca19c752 100644 --- a/drivers/media/platform/nvidia/tegra-video/vi.c +++ b/drivers/media/platform/nvidia/tegra-video/vi.c @@ -88,16 +88,24 @@ static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi, } static const struct tegra_video_format * -tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc) +tegra_get_format_by_fourcc(struct tegra_vi_channel *chan, u32 fourcc) { + unsigned long *fmts_bitmap = chan->tpg_fmts_bitmap; + struct tegra_vi *vi = chan->vi; unsigned int i; - for (i = 0; i < vi->soc->nformats; ++i) { + if (!IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) + fmts_bitmap = chan->fmts_bitmap; + + for (i = 0; i < vi->soc->nformats; ++i) if (vi->soc->video_formats[i].fourcc == fourcc) - return &vi->soc->video_formats[i]; - } + if (test_bit(i, fmts_bitmap)) + break; - return NULL; + if (i >= vi->soc->nformats) + return NULL; + + return &vi->soc->video_formats[i]; } /* @@ -320,7 +328,7 @@ static int tegra_channel_enum_framesizes(struct file *file, void *fh, .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; - fmtinfo = tegra_get_format_by_fourcc(chan->vi, sizes->pixel_format); + fmtinfo = tegra_get_format_by_fourcc(chan, sizes->pixel_format); if (!fmtinfo) return -EINVAL; @@ -403,12 +411,11 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, * Retrieve the format information and if requested format isn't * supported, keep the current format. */ - fmtinfo = tegra_get_format_by_fourcc(chan->vi, pix->pixelformat); + fmtinfo = tegra_get_format_by_fourcc(chan, pix->pixelformat); if (!fmtinfo) { pix->pixelformat = chan->format.pixelformat; pix->colorspace = chan->format.colorspace; - fmtinfo = tegra_get_format_by_fourcc(chan->vi, - pix->pixelformat); + fmtinfo = tegra_get_format_by_fourcc(chan, pix->pixelformat); } pix->field = V4L2_FIELD_NONE; @@ -485,7 +492,7 @@ static int tegra_channel_set_format(struct file *file, void *fh, if (ret) return ret; - fmtinfo = tegra_get_format_by_fourcc(chan->vi, pix->pixelformat); + fmtinfo = tegra_get_format_by_fourcc(chan, pix->pixelformat); fmt.pad = 0; v4l2_fill_mbus_format(&fmt.format, pix, fmtinfo->code); -- 2.53.0