Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp278313rdb; Thu, 22 Feb 2024 03:35:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZH2zxQyT3vdADod9zipDJgYdPubNSoWzchuNtJi4SzalTSUUfuLbfmsiRaHS+9OhwIbne6iIDaxSbuhs2HKCvOq0fkSm6cO9TaFqb3w== X-Google-Smtp-Source: AGHT+IHEHNhmsmyPDQyuzu5eGaUcTs2OakN2xs/F90FviXbNrplRLYc8DCRi9TrHvrxLleQnRuQg X-Received: by 2002:a17:906:1312:b0:a3e:9e4d:dafb with SMTP id w18-20020a170906131200b00a3e9e4ddafbmr7043018ejb.29.1708601699997; Thu, 22 Feb 2024 03:34:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601699; cv=pass; d=google.com; s=arc-20160816; b=WeeDNmEF0ZSf6JVh1aW2/Bdcz2qg5HQ7LQV+UVze8R4sZ9myhzO0bac05xb2RuWxhm BftNSrZms69J8C8IgOwiSNFgUxi3kNiW9TQASe0/mpIiExl84w1nZrSARaYclkB/7G3V VWokjwiBtVit9srnySeka5daP8AjeGmwSB1uKXYNnBbERx17YDMGqEvdfSO+NwptuBGw TK3yCWgJuZflXUVCOqZB63XoRRmLqu8O2EaLTe5oRolddlAwwnoAJO4D1ES1FjWNSk6I ykenCp7HgD+DWTpybhd5dxBhvg/Vp80c3E1vhP6xiEPcN9leuPzUckSiIJMzerJXgdhj ZYug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=KDTKo8nwJfEk5uEFOup5d3eAQRKj8Rt0pJw7LKWz+J8=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=lSGWEoFLMwV6UpPCd7LciZaSEmU/Y/j3WkXcYUNBFpvicHEQruhu/3MsPd8TYun/KU tSMD5DH+mJKFFkzafUvr+QJf+MDNhLonqVXE9w5cBMX8s5kcS+Q00CNOqO2ab/l+3sg2 7c13np3MD7z8L5kpQO651dUI97dizMrcnoLo0v+Ddq/pX2gTVSLJPRwk3/Z2HItVQezZ SRaZMeMsZp8PMUSd/fRi3fRKgZYjLAv1kLJawpzejizrzkU9lwauh/Porxw8u03Ts7wV RivLQSKCAypIczRJF+yN0YIqGIOL5NITmrv7xJhBj3e45KX1MrzVGwKt841+9QRPCfbF MzkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hxSQijN+; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-76418-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qk20-20020a1709077f9400b00a3e87e79591si4033197ejc.719.2024.02.22.03.34.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:34:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76418-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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hxSQijN+; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-76418-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com 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 98C121F23A48 for ; Thu, 22 Feb 2024 11:34:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 644C24CB4B; Thu, 22 Feb 2024 11:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="hxSQijN+" Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 7B381383BD; Thu, 22 Feb 2024 11:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601617; cv=none; b=D0a+xoaYkfRC1ETgr78/4hsxpPqpe7X/ODHYDz0Tur1IztlJrS5KsTNo+sOp/bFk9Yx1SNvpReMdogrvBPN6hiB95Ho5R41izTBi+kwPty85e9bpTgfGVhOChPlNOj98NGjjS3h24XZx3F7K1HsRPh1Q0cH3doR7u/aF7z8tujM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601617; c=relaxed/simple; bh=7KGerdWec5IZppJCBmGQMaaFwKJSklzBgiHvlZ/BodU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=nmNIo4+lDb0l/T9zDV+Pj9cnkwv6QSbDwXddqvVQWz41+WpkxP8OnKTDjzIulR7MENhEZfoY2O0Al9PwK7wUjPhQdNOc/PLIuz42ixM98SH8m5Nd0FAPUzjxWvW9d6nGpGzs1fc+pjiivgV/uct6iq5VQxmiIlEvqpF9lFsatoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=hxSQijN+; arc=none smtp.client-ip=198.47.19.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXNbu027801; Thu, 22 Feb 2024 05:33:23 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601603; bh=KDTKo8nwJfEk5uEFOup5d3eAQRKj8Rt0pJw7LKWz+J8=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=hxSQijN+yyQZ0aq66v/lrtYrCZZ0intct2jQnfoyEe0DNKdTjZDb+qhrk45Wmh2CY sV7sLNf/mzJeGvdsjyQgTSPsZ2hfWVe02bGAH3G3+H1RxerMj3sKWUTeR5O0/STEwE ZwKOA5s9BGILO15sIZYOUCTNzcMk1d/6tEVO6gq8= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXNHw059398 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:23 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 22 Feb 2024 05:33:22 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 22 Feb 2024 05:33:22 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXLtH091250; Thu, 22 Feb 2024 05:33:22 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:25 +0530 Subject: [PATCH RFC 09/21] SQUASH: media: ti: j721e-csi2rx: Fix link validation for multi-stream Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20240222-multistream-v1-9-1837ed916eeb@ti.com> References: <20240222-multistream-v1-0-1837ed916eeb@ti.com> In-Reply-To: <20240222-multistream-v1-0-1837ed916eeb@ti.com> To: Tomi Valkeinen , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Vaishnav Achath , Maxime Ripard , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: , , , Vignesh Raghavendra , Aradhya Bhatia , Devarsh Thakkar , Changhuang Liang , Jack Zhu , Julien Massot , Jayshri Pawar , Jai Luthra X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2910; i=j-luthra@ti.com; h=from:subject:message-id; bh=7KGerdWec5IZppJCBmGQMaaFwKJSklzBgiHvlZ/BodU=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDiLD3CQvkO0R/IE0W3GZS7SvhrPN95twVTF ELYQ1rJmbCJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw4gAKCRBD3pH5JJpx RSgGD/9CcjtzPAxV9SLZb9MZEOMzgldhbZeZ6bV5XagvDm8qHJl0lCNWTaq9JdFpeeDAfXnPg6H ONS/0o4OmOT85zdImrz0kMDUyN4PRLj3WfB1BXS2QM+Z9islSGiQgUdQplrg4G8l6qFvi7pvIp+ k1RwObyEg/jOo2jQWVqSxGBsxSB7EYttPtuGZBRmhZNgbRfStt4WNFhPzDTyQJilBZOxo50aDwy phZW9nNz71WvGcItWvBfKvilD/5zGKhkFSu8iNuOoBXlKXjOTkIwxkmQFPiC9EYV3j4x+ofkQ7x CG1MgXPC/px+J6kgDkZNoCVHJp5jHh8hcQhjIwuvrYTtYt6GrzX/KCDbELtpYRZME/UxdyCtOWn jPV8qtbIQSSl21jVZMZnPBEx8KquzoKlDyoZzvWOhZmkDdDkJqq+ZoX5wgiBo2wISYUV/bQwF9a GTwfe5YPD66r23cnWh7dXLtbAyb//MIgPId4hMOnDhdQZJYUBj4AJa0OzGAZnNu0jjEKDKr3IDF h04MCdpcwCThplbHMPJkRVCMaVHdV05XBNHlW6IgK1K/wxfWDpT0FMsd6Cyw2OTUvTwidHzoVvN ezxVvYjWD9JWJgjVkZz6gYWC6lAI+HnKuBGkI9im8AzvYFvLKHBUo30/FH2bSwLsEX41yvv9op3 2nEQLT5lm4H9Jtg== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 With the new architecture, multiple video nodes are connected to output pads of the ticsi2rx subdev. Fix the link validation for such scenarios. Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 42eb1bff21e2..1443338f4134 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -1133,45 +1133,54 @@ static int ti_csi2rx_link_validate(struct media_link *link) struct v4l2_subdev_format source_fmt = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, .pad = link->source->index, + .stream = 0, }; + struct v4l2_subdev_state *state; const struct ti_csi2rx_fmt *ti_fmt; int ret; - ret = v4l2_subdev_call_state_active(&csi->subdev, pad, - get_fmt, &source_fmt); - if (ret) - return ret; + state = v4l2_subdev_lock_and_get_active_state(&csi->subdev); + ret = v4l2_subdev_call(&csi->subdev, pad, get_fmt, state, &source_fmt); + v4l2_subdev_unlock_state(state); + + if (ret) { + dev_dbg(csi->dev, + "Skipping validation as no format present on \"%s\":%u:0\n", + link->source->entity->name, link->source->index); + return 0; + } if (source_fmt.format.width != csi_fmt->width) { - dev_dbg(csi->dev, "Width does not match (source %u, sink %u)\n", + dev_err(csi->dev, "Width does not match (source %u, sink %u)\n", source_fmt.format.width, csi_fmt->width); return -EPIPE; } if (source_fmt.format.height != csi_fmt->height) { - dev_dbg(csi->dev, "Height does not match (source %u, sink %u)\n", + dev_err(csi->dev, "Height does not match (source %u, sink %u)\n", source_fmt.format.height, csi_fmt->height); return -EPIPE; } if (source_fmt.format.field != csi_fmt->field && csi_fmt->field != V4L2_FIELD_NONE) { - dev_dbg(csi->dev, "Field does not match (source %u, sink %u)\n", + dev_err(csi->dev, "Field does not match (source %u, sink %u)\n", source_fmt.format.field, csi_fmt->field); return -EPIPE; } ti_fmt = find_format_by_code(source_fmt.format.code); if (!ti_fmt) { - dev_dbg(csi->dev, "Media bus format 0x%x not supported\n", + dev_err(csi->dev, "Media bus format 0x%x not supported\n", source_fmt.format.code); return -EPIPE; } if (ti_fmt->fourcc != csi_fmt->pixelformat) { - dev_dbg(csi->dev, - "Cannot transform source fmt 0x%x to sink fmt 0x%x\n", - ti_fmt->fourcc, csi_fmt->pixelformat); + dev_err(csi->dev, + "Cannot transform \"%s\":%u format %p4cc to %p4cc\n", + link->source->entity->name, link->source->index, + &ti_fmt->fourcc, &csi_fmt->pixelformat); return -EPIPE; } -- 2.43.0