Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795975673; b=1ilygOEHd1afnnCsNoPgCATkPWhZRnxze1qlP4BxyYlUfRTYfLQPditT/yemMvmpG49k eVUAxwggTrLdh9bSgc1sHq3SkmJvM/JJwunEn3Otx3q2Do26LpVlb4XtnMns1FwAV4L+c h3pNbYjvzAG6P1L6hj0lvM3ZFpOzAHaC3vbVyVQyx1yXJ7GwKAOTaom5uRqw003tmZkPO eUInz9WbYTLkJmaWdB8HoIPgpvyo50j9ZcYUeaY595GWFOG5k1ExJgrgNsprSTHKXg7MF qSQelaq+Z7j+qbNbljxicGlfENYLT4TnVKdAFONBvRr82gS4TnAaII/2xO8x7m9g3iA== 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-Forwarded-Encrypted: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=X8DjXNLytyz0Gfm3UJq9qWi6aF0wlcUfvRzGT4IvpZCsFjbSClT9NJKC/Wm32vDGKv1V qUy6IcID6M+hztOsdX9wp6/VbAQPGbjPkahFOYlJD84/rsIQrtQV2SyeUjUTF411UsIEl jW6UL/5wYnFsjabgK3f9NbNQfi4NP2tHzTpNxx1YDJHaOFh4li7w9LxsU/aYqOuTx7XlI HqZ4BvUDVEbE9xsozRCCjpZ7EbcnWHHTwzS1Og7yU2EWtDDYmLchph/GJj929XVlYj0L2 QxLEfA4yMrdSLW7diVP9HE4KqgNzDzb73wQXy/7m7sRcoGl/fNQPV27i1czyakp7+8w== 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.51 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 E1C28606A6B7 for ; Sun, 29 Nov 2026 18:07:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E1C28606A6B7 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-f51.google.com with SMTP id a640c23a62f3a-c505b2e1cb9so1712937366b.2 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=MBymsFWgQIgMFzWtw6vrWKicGkj8DEG527loYK0qWDjGrI1DNc4a77YPn4KJZooz95 KwWAJOpiUsDVFf3sXVqcxHj8YybDmjkgHdKcRUEtCoNAy86Gl2d0udFsBiZCBzKFVfNM g/f1SFp6JGwy1ZqABytWd8h9TDJFIOfMQ4VR1tRtyPxEujxjUumB3c0gLiPCCGGjD8l1 tGY5Sy+8kXJAl936fkY7fjVm7zkxfvWP0SDFg6s4J2yuxCu3F5bo5ZflIIH+lMTEa4sF Gu3OYFW8gu6hdUvwWL0H4pdWzvQgGnoAhslV/YpCqxxD2WyLnNmovEU6joAdnCSTecES cmkw== X-Forwarded-Encrypted: i=1; AL+hErG2M3cFJ7OirJzcfmCD1vOZa0Vnozx/q7Gx9/i5FL+O4DySBCFUs+3pqy2z5N0lkvcx4g89e6V+njbq9Q==@vger.kernel.org X-Gm-Message-State: APuU4Z8xbpo95yggFV4ZcDZVlFoNXDSXQf8JpHGX+Y03daPvVG0j6vLA 0qW8JlfJz5ZN1hXPpWwV8TIrE7DqSVgZg7ueR1Zw1Lc4wkOntgmBWi0H X-Gm-Gg: AZFdTZd/F5su+ce1qk8MQ39t2P30E6d+Qf2B0RF1O1PA0o4bjmsozRXpLhz+CKlTb/+ RwjspazGFRdH9RhAFbBbJTojG45rWjCEi5DbhR5uP6XOsxGB4B7olE6J8upGjLiXeesUaeTG6ez /S7q9dBoTDWerZfUxCHhDhIcBQZTojlgqptAfqBfxq+/soK1ytAsJzuv+vyJ32URUaU6gpW0fKG yEjXMttywRr7hXMm5/Q//PE5CIOLK+xwpec3REa5mYxTdkR/4+cWSi9pxQhYmoPySXyzEDiv2QH eUdpRhRLYDwd2cXvedC6oLccpwm8bB+ZRG59xy4y6FrfzKHp15LkCJhCZlHAQrnR6B7I8X6idAf yr1N7/itUOXxTpp56hhx/h+xSSiuAD+6zmFBCtSYCjjDL/U90VvBXuhALFE7DO6vgM4r+YhZHBV YQOOTmCWsrDl0NmhbX3loq4i1Y4tU1EXoiyEdrw8ukKakw14/qjrQOshHr2LwML9OSe7LU5BLaT Im3LO+kTKlHqu/fAVSORbhAUOrxxRYiArHotKVIeRHISTgyDZa4SPRTWw13lR/tfTRugQAEvRc3 jyq9dmlovwNhhMBD/X5QjliDUuP/afJltnfeGYY33JZxq7L0j6gXESMMyGCrx+DZG/zRTXEJVV9 2RNaCai+idg== 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-media@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