From patchwork Thu Feb 22 11:31:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp189013dyb; Thu, 22 Feb 2024 03:34:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVFc37OLzivVopN55NxhfV5awlbDqPrLXTH+oOxgusO+EsdmlXDzv/M3ER8u3WcIiqFPyRRY1A8F/lVK3X02cWeGmTnBg== X-Google-Smtp-Source: AGHT+IHZ+UPhcn6liJYOchUMwtrqYSlFI0ptQdOemlrc+1YDgEvlHuAwxfqvS3n48mxie2DPN1fg X-Received: by 2002:a05:622a:1995:b0:42c:6e5b:777 with SMTP id u21-20020a05622a199500b0042c6e5b0777mr26931808qtc.11.1708601659386; Thu, 22 Feb 2024 03:34:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601659; cv=pass; d=google.com; s=arc-20160816; b=pXGQg0UJF9Wa8Fm2AB5ZL/MW1v+jzjcm1pwBu1I3BXXYVul2plj7ECiudP+RU5cTHj 13v/WhFErvOPQhSJY116Zjcl1FI+WLygapxSvyze2zDxxSTrmdb5nAr2AQxdrBnxrkcT i6RQ3shHwNz9QxyidZUN61KJ8VCk9aSmqMUckIpeSG1QqUoEV2z4ZhIuu07Dy2wRfKVv XBTueHq5sOujaWjDLad4KQMdTTCPZ5h9a5yt0/R9KNlfXDmrz169kJ6syABhqWOpCLgG /+2cvCqW3lC6AoZn4ezy//vTu+5V8fQZz9LeF3DxxCkihbOCMuT4SIHqJMTWRMX43fbA BZyQ== 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=unATImeiTgCx2h83hV/vvpZDGrNkG9tQmTwgLhrnhvI=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=0EHe59Zkroqb3AhhsTujZ4YeTfIjX9tDfr0h3mBzHj+GuHn2GXSxlR45U97iTL1HqC 6nm8dUo7b2zhA3tDoI+40Vgp9iwzXICtSQeKdJ8T/Udobb4m2io9/3n870RZvdI1L/DE Y4fSA3969WocDALX39n85zR4layr2CmHB/5eLrVawlvxicNMl9OVueTIA91b5S/8fYjJ h21sZmjjfK2oEAxQLV/7nmapVIGMqw6LE69DW7SXFo6SqN0RBhKhYA15rMfrgpEjt9re tk5RwWX8s70QLT7VTBhSk2NOdYmzsctu3pxQ5t4sKsLMQdAF99rmxYbEeczPyNQYmJhB my6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=rVeJYGXd; 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-76416-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76416-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t22-20020ac87616000000b0042dce6d4a7csi12385992qtq.20.2024.02.22.03.34.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:34:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76416-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=rVeJYGXd; 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-76416-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76416-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E1E541C234E2 for ; Thu, 22 Feb 2024 11:34:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 846F347F6C; Thu, 22 Feb 2024 11:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="rVeJYGXd" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 9CDF7381A1; Thu, 22 Feb 2024 11:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601607; cv=none; b=LyWEGs0/m9BL5VLRyxKgWnEi0cc8wcBMFbJxyrEHMXS7KuS0kj2A6W3sFl41VhC7m6u7yizUm7gxpe26BBWGh+MKjQfYnInCYhu64wFRNqzFOo0RO20/GB968R6oO6oYja3HCV4sLuJFtU38c1ydJbRlOPWzooqgF4GUt9soSso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601607; c=relaxed/simple; bh=RGZevRFsIBvLsB1s0og8plkNvtCkfORtLILdFlyUzw0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=fp5C4e2uJGdKQmVpuFdiwsxAyomKseQhxVGOiMCups42qgWeRL4TQ3coJsOyswYtLO4IfsjzeI8CeIzawgaz0D2BNYXN5r9ABvzKX8qBux0t3nzWMsDWfbTg1TOPkIQajjXdARk9cUB8APDTroCfa8uStlh72rm/yNhFrIUd5qo= 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=rVeJYGXd; arc=none smtp.client-ip=198.47.19.141 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 fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBX7O6059121; Thu, 22 Feb 2024 05:33:07 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601587; bh=unATImeiTgCx2h83hV/vvpZDGrNkG9tQmTwgLhrnhvI=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=rVeJYGXdT7Ymnf2W3KyFM42kDH/batnZnLLyh2+TyVQiP/CSD3IFOLukhWUeaWN0X oqjXbTnCOzloDPiHKZNvVcL0jOdCOypZNvv9ySWUTH7vSaWBO8wDQL9UD1cpCXN8Ff TvooYNuJos6qSxv4qPQglQ/tS7xreZdjB5qNv6g0= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBX7VF056960 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:07 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) 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:06 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE104.ent.ti.com (157.170.170.34) 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:06 -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 41MBX5bj090878; Thu, 22 Feb 2024 05:33:06 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:17 +0530 Subject: [PATCH RFC 01/21] media: ti: j721e-csi2rx: Fix races while restarting DMA Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-1-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=1532; i=j-luthra@ti.com; h=from:subject:message-id; bh=RGZevRFsIBvLsB1s0og8plkNvtCkfORtLILdFlyUzw0=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDaW9QfFKtaA48EMnvlA0N0UPpud5MN0AiqU qz3gSThwtSJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw2gAKCRBD3pH5JJpx RZpWD/9TrlLiXZwWyOpm0PdGXZeBKB+af2zmPStZLGcfOE2aiYqIvQXZasnffBaD+rtu0LF9vKc LSuRyNTfIbaKkideXMz5oYsyu46z9AeJ6+MLj2D3iEYabvJZknCGVOK5Xx1xyKGhBnAcd9XucDl zEPeX3tcpyBN8fwIaJ27pMs+HCW/9AEyZA+/DwVLrtz2UTYNmSHOz5cgaAXy2U2URgP66oi3VLU sEym4xvzKCa4uwid9Ns+O+bfgaFgyJMuHmGWwPig2nmVpTF4m5IiTsaOl5+h+a8XvYDDLoCyMcV 8dorGmBTMb0WhPzeJ5GA7Dkw8lN+gbinoHomqJlf/B0gw5v1Ln6PQuWlY//NPyeWNL12lbCnHE2 blYQ3L6zQE7eRI49fuN891rkdnHy3mnvzXySDNvx62kNG50yt7N1xthBjYH9FnutwaXcPzUe4MU lex+cUEG8cEBn7iT8ZkoNO2jUdQvk06e/+mOPv3KqzGzFFsNRhYhQpMAw6BYVPav+0x/4mtEcuD HSVaMyIRajwZ2Jpa//Fc5g9TPDaIR27LMer1l4X5D/Iz2PzLnmfrZ2xxma8fU6wqR3ABHdwBF8+ 2dJ8GlCphRINgnAea64x8tbbhCsvt3J/69JwpD/e/PBQdYGeFjPQPfbsiw3gDyKPUewiXs0rdow Bxk05JYwsUwjIBQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598693492836658 X-GMAIL-MSGID: 1791598693492836658 After the frame is submitted to DMA, it may happen that the submitted list is not updated soon enough, and the DMA callback is triggered before that. This can lead to kernel crashes, so move everything in a single lock/unlock section to prevent such races. Fixes: b4a3d877dc92 ("media: ti: Add CSI2RX support for J721E") Signed-off-by: Jai Luthra --- drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index be47a4a24f97..e2cac8d73d78 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -810,15 +810,14 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb) dev_warn(csi->dev, "Failed to drain DMA. Next frame might be bogus\n"); + spin_lock_irqsave(&dma->lock, flags); ret = ti_csi2rx_start_dma(csi, buf); if (ret) { - dev_err(csi->dev, "Failed to start DMA: %d\n", ret); - spin_lock_irqsave(&dma->lock, flags); vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); dma->state = TI_CSI2RX_DMA_IDLE; spin_unlock_irqrestore(&dma->lock, flags); + dev_err(csi->dev, "Failed to start DMA: %d\n", ret); } else { - spin_lock_irqsave(&dma->lock, flags); list_add_tail(&buf->list, &dma->submitted); spin_unlock_irqrestore(&dma->lock, flags); } From patchwork Thu Feb 22 11:31:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp189535dyb; Thu, 22 Feb 2024 03:35:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVf006MnKnS6tgBo95q0S7Z7hWf5uhlT8nSaoarYZRkHF89vNU+34NTXQF9fR1rvG2tAbkStHIidJ3LPK+MvTV22ZyKxQ== X-Google-Smtp-Source: AGHT+IGqGQlCMEUANBghJDZQ7rTqjD2AGzeJbk2sL+DJ4OALQkIdw1jhlfVdfDhsC54Y+HzRHRL0 X-Received: by 2002:a17:90a:43c6:b0:299:1446:7ab6 with SMTP id r64-20020a17090a43c600b0029914467ab6mr15043789pjg.19.1708601721255; Thu, 22 Feb 2024 03:35:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601721; cv=pass; d=google.com; s=arc-20160816; b=ScPbpjvcNWsL3mEr+JFIc8X02CyUv0VS77XLW+4twgQYzC5lZypcxmOAyF8y9yppZX 4ClESu3QZrRtGVu6OsdN9sobddwkDXolnVEraLyeIOfPmJX8A8h7qP8hrPgTe3xmaW88 AYHije0xo8APZ6IkwzegF26ceh8khg6ykJ1raL9CAwV0HFGmRhfa8EAaDncnXqvQfGps XeGGYvawZ2MK11vF5yE3zAQwZKBtUsJlGcm07ICVWbx+0bLFbNPgP2u43ONMDmZEuSCG q+dJRQcUYCUMkLFW9T69EqoTl90VD9OsumuBh0WyZvxO0np5LaTmEHTjANUwrC9lyrrL E0Bw== 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=2cNr2W9c0uUvSVuROSL/j2Uzf+2G2fP0MYHF6MQhS7M=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=CCdHCc+CQZQGG6p+TY/kWqCAmNpD3CUseggkcLe8qgbrCHVW6yU70udOHlGwa+uyRL +vDZ6aE1cVk2rxBPvdnRm609URBf4m/Aojc6hwEVpC8uvV3wgswFYd14AW06OcY3mvhq TMsr6CEUyQZPznh9xYGs5XxKtBBDf+0Is3YSP7uyWX+FNMI9nIZiCdUKoqPkp4XxrZzb 6GFZctXczQl2T0I8DS1h8fiIe38WueeyXIt4r2K3DeHZZUN16O+Nt6QnV4kQhHtktfnL yXkicMvV1Rwu+eJckZgCNQJrcGQCGpjxJ1JxewLiiAhRxihCrCUjtgh7IW0LIouahydV Zh8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lvGKYUpE; 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-76417-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76417-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a73-20020a63904c000000b005dc952f426asi10016747pge.850.2024.02.22.03.35.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:35:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76417-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lvGKYUpE; 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-76417-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76417-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 50D062816EE for ; Thu, 22 Feb 2024 11:35:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4AE8F4D58A; Thu, 22 Feb 2024 11:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="lvGKYUpE" 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 28627482CA; Thu, 22 Feb 2024 11:33:33 +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=1708601616; cv=none; b=lIMjL3hXVYmAQCSzjlF/0ufgyIDHPqxdI7Kwhz5lPoKzdWCJjhbm1Txkg9mUKNPsIGevdb5I2IcCopFKp3E4fXy9E29AeCl9mvorRZ/qZXN6Lm3ENIvqUyIc9I2xLMa5QOKC2kX/n+qIVecOiT2RdDUTMlX+5nl9A5IPiBc1Ax0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601616; c=relaxed/simple; bh=im2b3XkRWHVDjENKTL39XO+OkPYZPgPa/EbqRfvqcr0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=PpwVN5MzlCXdiWnwADMWD/m42kCOKTD0nt355blESfANp+GAJTATsDv2/ex+0NiEx9L2i+ZDaHLOyLyCNfwYMkVCJAA4YRp65VdEMEZ+R4q/UcX3hvpgrCd/VjIeNeq7rvDZFxWZWXsWeLqQVEISLSA0EiAOJpT0qpCX82Gl2eQ= 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=lvGKYUpE; 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 fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBX9F7027774; Thu, 22 Feb 2024 05:33:09 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601589; bh=2cNr2W9c0uUvSVuROSL/j2Uzf+2G2fP0MYHF6MQhS7M=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=lvGKYUpEXvpx56rZAYJarKRBpUBbwsk1qJxq1DIN8Ff3429hAGiH/yLakW7P42Qyz lmmilnJFYmGLsGxME6UtDoim/rt5023qnMToheBTu2ur8Ugt30fSQX53jBGVsK/X3G JDZkKp+ZE+NxU1rpSDMVCdRqNx9V7ZaIo7IfWnNc= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBX9he056994 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:09 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE115.ent.ti.com (157.170.170.26) 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:08 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE115.ent.ti.com (157.170.170.26) 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:08 -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 41MBX7Zi090935; Thu, 22 Feb 2024 05:33:07 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:18 +0530 Subject: [PATCH RFC 02/21] media: cadence: csi2rx: configure DPHY before starting source stream Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-2-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=2426; i=j-luthra@ti.com; h=from:subject:message-id; bh=PdPEqazmXTfXDrKucBNAcGZRh84r972NesVdYj6Urnc=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDb6Btyd3l4s3XpQ/yhAgO7WB8o/94UBxhg+ XZYNViZIxWJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw2wAKCRBD3pH5JJpx RVpsD/wIaFvgYeOJgz5+wO05LNXrzihOfqTYOxNbgEkhoLL6v3JEki/UwYlZeSMoOf69WgModFv hcb5p3UWzSb7LAMOpYW2Bu2xl3i6xYuDW8SKgMuIqHNoI2J3whJcCbLyjkiVGTZFh/ZcgZkio8M jCuNGH+FkFvBRwKhFYx70Hzbdj6rP8B8o5cOR3C3PtLAGUBNoNnB6mKF6cAhnYdQJJGRCYQPeLm 8x6RfzUwiTyD1spj7gD89t6Omp4MtX5hnoEubWqzyBFpM5Sc88CjtoOF+mSyxL9wlXZ+KkKlesj g/Nq50PR9i9GKE1Pr/LVBcsFrYdrS+pjQzK1HL1MNmu/WDFHYSNembITaVxlS57amJXjzAoBF5G h8p2swwvmerLrnfoETDGP5huLmknB8KuA1ZbXyrd09NTgEcsWG9MQ6DOTWh1Sfxj4Fe40x3zezf Pqslw41+wN7dcd98yCOzlE309H3eZXPTwPlBDotOnDsHZGTV/F4w3vjtW9smURa/krS9p8UVKof frq1G4NfQlmFaPCCFcHrHb3kZQnwMUeIlQJ9ExL/ejJi02kqmHbFTLIVdKf3IxT0aaDTOocsg7N 61To7EuKBHPpaI3JPySWycPeejbzLZ7SnOxvx7wKj8QBdb4SYzd9wl0E3jxqJdXT0pfoXDFFIh1 YKIMsDs2rR+HTVA== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598758323574908 X-GMAIL-MSGID: 1791598758323574908 From: Pratyush Yadav When the source device is operating above 1.5 Gbps per lane, it needs to send the Skew Calibration Sequence before sending any HS data. If the DPHY is initialized after the source stream is started, then it might miss the sequence and not be able to receive data properly. Move the start of source subdev to the end of the sequence to make sure everything is ready to receive data before the source starts streaming. Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra Reviewed-by: Julien Massot Tested-by: Julien Massot Reviewed-by: Changhuang Liang Tested-by: Changhuang Liang --- drivers/media/platform/cadence/cdns-csi2rx.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 70b7f8a9e4f2..75e602c1d762 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -243,10 +243,6 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) writel(reg, csi2rx->base + CSI2RX_STATIC_CFG_REG); - ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); - if (ret) - goto err_disable_pclk; - /* Enable DPHY clk and data lanes. */ if (csi2rx->dphy) { reg = CSI2RX_DPHY_CL_EN | CSI2RX_DPHY_CL_RST; @@ -256,6 +252,13 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) } writel(reg, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); + + ret = csi2rx_configure_ext_dphy(csi2rx); + if (ret) { + dev_err(csi2rx->dev, + "Failed to configure external DPHY: %d\n", ret); + goto err_disable_pclk; + } } /* @@ -295,14 +298,9 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) reset_control_deassert(csi2rx->sys_rst); - if (csi2rx->dphy) { - ret = csi2rx_configure_ext_dphy(csi2rx); - if (ret) { - dev_err(csi2rx->dev, - "Failed to configure external DPHY: %d\n", ret); - goto err_disable_sysclk; - } - } + ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); + if (ret) + goto err_disable_sysclk; clk_disable_unprepare(csi2rx->p_clk); @@ -316,6 +314,10 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) clk_disable_unprepare(csi2rx->pixel_clk[i - 1]); } + if (csi2rx->dphy) { + writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); + phy_power_off(csi2rx->dphy); + } err_disable_pclk: clk_disable_unprepare(csi2rx->p_clk); From patchwork Thu Feb 22 11:31:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp189030dyb; Thu, 22 Feb 2024 03:34:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXasd/mf6dQtqu+rXJmc48T96FXDCF++kgJpAuz6tylwyGDjgyud7U5Nwlvjf1ensgF4n0w2L2TMT5RpR7gq0GzJgMilg== X-Google-Smtp-Source: AGHT+IE5byQZ8TVShK4GyZcRnQmisFqx06/lYIkcb4FZ3P6dYiPnVVrslUkO76yISh6iSMjfeMQq X-Received: by 2002:a05:6358:57a8:b0:17b:5c7c:2801 with SMTP id m40-20020a05635857a800b0017b5c7c2801mr4575497rwf.14.1708601661418; Thu, 22 Feb 2024 03:34:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601661; cv=pass; d=google.com; s=arc-20160816; b=M6wotPNIcCExdMLw3ZeuiZhG+qqxy6PTJuxgWAzLyk1oFAYnay1S4Zjct1TqTegQCU qxmubWE+U1Mvjsnf/qKpUNG801LOHgPIls53dA9RCZaiuwW14mbdSNNJaF7PHUQY3Sl4 wW5l/32J6WDD4E+zb7p9jM1NGooCO656e0mPE49bHY3cZtbYDDd/TkYqkpdFOVDCJsqH Qe1W8Xtz+QogUl0aKfS+VMGdaAP2Vstprna0PEJn/6Xfy/voyGRdTyX+34xfNudYyZgu Tcdemqsh5a7aoYkskYOFSJAaTrz3pAZgaRB2WYLzX3+VRwTjDCxY5ssY4TNxb1oDDCJR eDXg== 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=/i192URWf1TmsQf1cjCbx2z4wkXH+kCVVw7/yDHFIIc=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=K9OQsNDyXw5mzfB/dz8p2nEoj+ty6hne+cJc7wqKuRGZB6YkgYl5eOLt0+bISzQsD8 KDmWS/+EemSvtfV+rGgNkwwVgpX56yGu+5YZ7PTomoJPqAAR/pLwZ6yHs+ad6LvvnzQY blA9HfIyWyBnLpJ/JEDifWZjmAd5g8zqKGXTGl1d3EhrGVE6XDFXAQ9p0hjOneDeJdsh nJZbZ4N7/bHLHx8m9UoBAZcNBEcojGVOs3M53m+lTcRY94U9CCoUrSf/L5rzI8EOqiPQ B72jXEONkyZyijDYismYovG+TlGT37OLABBrkHTNnq5wN2upckjP9Qs6x0cctbihNOq0 du3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=chrMIB7d; 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-76415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76415-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a185-20020a6390c2000000b005cddfe0c82bsi9948193pge.211.2024.02.22.03.34.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:34:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=chrMIB7d; 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-76415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76415-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 347E7282256 for ; Thu, 22 Feb 2024 11:34:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B85E8481A5; Thu, 22 Feb 2024 11:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="chrMIB7d" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 9CF4E3FB27; Thu, 22 Feb 2024 11:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601607; cv=none; b=ejzlw6zrufrQQMexCS0Ok2d8Yl9k/K/dR83qFG/9t4XPA3IDWzD4t5dCQM4renyqq3+FfuJz/c8y3lYkxQS0LitT1xwPf1DwTUniQY7POmbKA5fVPsGEZLKiBicXg6my3qNr4PXS9n9SUoAR10zoryYaZpMHav+c3Koa57CUmCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601607; c=relaxed/simple; bh=awIpiB7+rPodbBNyQqhDBuuBw28/P0JB2hHzrKB5VA4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=t39wjWHcZQ5zpm+aPAMdEjv//S3tb22ebY97ghoLHruBBP/lFBDG6zqg9uhXtpuAsTLzAyiFMdr2QZyXWAk1sG3Juv+RB+kiIa/2MzPjHZ9ppGVw76sM09uxHs3Mi75xh1g1yEQbvZn16niZZLdI3a50GkIzWlQvilf5hUq+v2w= 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=chrMIB7d; arc=none smtp.client-ip=198.47.19.141 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 fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXB5o059128; Thu, 22 Feb 2024 05:33:11 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601591; bh=/i192URWf1TmsQf1cjCbx2z4wkXH+kCVVw7/yDHFIIc=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=chrMIB7dp3IKQEymdm3CWvDJVVSoZfG0hEMJxegDDTlwcQIjaP9MYC+lvDwnKIXm3 A6gIdV5pStPsmzC3yVWiVwOXS4PGwQYdaE90KeZ4qXFiJm/vFBuhIPp0oKmvaROS8F zCxOSKZZNyaYBx5lNzl1N5olUB+ut9SfHQ0HZp18= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXBJP059184 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:11 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE112.ent.ti.com (157.170.170.23) 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:11 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE101.ent.ti.com (157.170.170.31) 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:10 -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 41MBX9Xf090998; Thu, 22 Feb 2024 05:33:10 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:19 +0530 Subject: [PATCH RFC 03/21] media: cadence: csi2rx: Support runtime PM Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-3-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=3486; i=j-luthra@ti.com; h=from:subject:message-id; bh=gL2KFHtJC4ZaxiomDu0d9bCTf1l/780KtEZpDitoGVM=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDcRZ3wPVgXir6vjlfdPfIq2tLGr5W8ntgai IjeS9CnSIaJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw3AAKCRBD3pH5JJpx RWSID/4y9uUWJ4VVRhH5Z8m4Ax0uHMLG/1DV4f6Oxvy5YHjlLCbnQYES2t7Sfi6MITcec60nqbL 3wz1HnCS5iNsOSATsfm3PtjfWdC32y+4DNCbYPWVg5VnA2wYMiqhhYlYdzFsBSbR1HPxXXo9PgP sHIEhIm/B3/H13dFjZg3wK9Rgw4HjX6e4s/bomaNSwB/+G/Jys56hvE5Oadcl9aCbJRWP1ohZcq DasQ03br2FebIWUmNI+BrNAh1J3PtxWc8E6SsgzXvhoeUT8FAuDUSzEKMrGr4JSkHz1beqxsFQa pGqhzBnn1omCZN+r1Zg5B5Bm+kwt2UTOcDwcstIQxEzgzqw7r7w2LQotTsoXyDfN3Z76r5Nj0za xpRtOIbwYy5PwTViofUWXqpstad7HyjS6LwQKjr8nvWy8IuvAe8psCWKHrNpWPvCLTM65s7nIWI 1jB4jfhlUvwexFUmXobQAizia8vHPkJnqjuW1lId0AtVfzuiBye5ZhzvJMBeGpxBHgXVsLcGhQs aCHqOdt659HM59/2CYf6Di3YzGvIY8lnX2/wwguCkSDlSCdoNlmPhHTDXTJzV6dKH3+3C6aaLbr X+0a6hxbJnbV7nriu2W/667n+zscIl4/SuCdtippfyskWfombECI3AsbC2Nkucd8UHxWFdFjBRn c3CcUeLsp/1Nyqw== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598695696649004 X-GMAIL-MSGID: 1791598695696649004 From: Jayshri Pawar Use runtime power management hooks to save power when CSI-RX is not in use. Also stop/start any in-progress streams, which might happen during a system suspend/resume cycle. Signed-off-by: Jayshri Pawar Co-developed-by: Jai Luthra Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 43 +++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 75e602c1d762..e19993ed351c 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -370,6 +370,12 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable) struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); int ret = 0; + if (enable) { + ret = pm_runtime_resume_and_get(csi2rx->dev); + if (ret < 0) + return ret; + } + mutex_lock(&csi2rx->lock); if (enable) { @@ -379,8 +385,10 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable) */ if (!csi2rx->count) { ret = csi2rx_start(csi2rx); - if (ret) + if (ret) { + pm_runtime_put(csi2rx->dev); goto out; + } } csi2rx->count++; @@ -392,6 +400,8 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable) */ if (!csi2rx->count) csi2rx_stop(csi2rx); + + pm_runtime_put(csi2rx->dev); } out: @@ -665,6 +675,29 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx) return ret; } +static int csi2rx_suspend(struct device *dev) +{ + struct csi2rx_priv *csi2rx = dev_get_drvdata(dev); + + mutex_lock(&csi2rx->lock); + if (csi2rx->count) + csi2rx_stop(csi2rx); + mutex_unlock(&csi2rx->lock); + + return 0; +} + +static int csi2rx_resume(struct device *dev) +{ + struct csi2rx_priv *csi2rx = dev_get_drvdata(dev); + + mutex_lock(&csi2rx->lock); + if (csi2rx->count) + csi2rx_start(csi2rx); + mutex_unlock(&csi2rx->lock); + return 0; +} + static int csi2rx_probe(struct platform_device *pdev) { struct csi2rx_priv *csi2rx; @@ -711,6 +744,7 @@ static int csi2rx_probe(struct platform_device *pdev) if (ret) goto err_cleanup; + pm_runtime_enable(csi2rx->dev); ret = v4l2_async_register_subdev(&csi2rx->subdev); if (ret < 0) goto err_free_state; @@ -725,6 +759,7 @@ static int csi2rx_probe(struct platform_device *pdev) err_free_state: v4l2_subdev_cleanup(&csi2rx->subdev); + pm_runtime_disable(csi2rx->dev); err_cleanup: v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); @@ -743,9 +778,14 @@ static void csi2rx_remove(struct platform_device *pdev) v4l2_async_unregister_subdev(&csi2rx->subdev); v4l2_subdev_cleanup(&csi2rx->subdev); media_entity_cleanup(&csi2rx->subdev.entity); + pm_runtime_disable(csi2rx->dev); kfree(csi2rx); } +static const struct dev_pm_ops csi2rx_pm_ops = { + SET_RUNTIME_PM_OPS(csi2rx_suspend, csi2rx_resume, NULL) +}; + static const struct of_device_id csi2rx_of_table[] = { { .compatible = "starfive,jh7110-csi2rx" }, { .compatible = "cdns,csi2rx" }, @@ -760,6 +800,7 @@ static struct platform_driver csi2rx_driver = { .driver = { .name = "cdns-csi2rx", .of_match_table = csi2rx_of_table, + .pm = &csi2rx_pm_ops, }, }; module_platform_driver(csi2rx_driver); From patchwork Thu Feb 22 11:31:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp189745dyb; Thu, 22 Feb 2024 03:35:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWovZOAtdaFv1oyE4xwm7bYAkgBZyudycQu7IhlSJG8Sx+XuYvfrlXaDoWwQ4xnIBzY5JwxDbi3bL4UdHm83tEhHeruGw== X-Google-Smtp-Source: AGHT+IGaEi1icVvy/jtlYYtinw+rgH/x8+fdDQuTtBAiC4/0ndyWHDEnhWwj87oQRLW0FyiZcmZO X-Received: by 2002:a17:906:190b:b0:a3c:2f68:54a9 with SMTP id a11-20020a170906190b00b00a3c2f6854a9mr1727469eje.3.1708601744493; Thu, 22 Feb 2024 03:35:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601744; cv=pass; d=google.com; s=arc-20160816; b=CB5SGH7LdYS83+ed174RPF+UY/C1ZnqbAQDbjcInepq2aCLGC0AxiCZ8Q7ii9MT12T tux+7dFs6WXUWu/5J/Q0l5MAi26j34qcBxdhKdUmHjvU65ogQ/R7cNVwN8VjKl+CNbS8 pH81vuRCYr0ce3CIF67Iko+vmu/AYiKiRBhna3V/rLMvzuWgV/qT0qFXhK74piYUyE24 YI9peikDa1Bna1GlZMt6Kk0iFoB/fUn9ECU+7yG9Lpuh99ixPh8dL84ptLeNl+5qmEV3 BG/5h98a2RbWtreUn9ZPpZUPfpgsucw4aaBn0LWjEvuH4frL6BIkuhSUoJ2wi/g73F2Z JWzg== 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=fdOYox9DC6gaFbNXKWSXcI2XCkmrQ8/pFo/KcAvlo6Y=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=aYc6hzyIt9pZQpCCeEc5SIBvJuy6k12gXJJ1WVkDV4z0VeL6aTshEsfKmmbu5gryY8 7OVJhXlS08fX1hOTjbTa0zWBW4whRdju8FTCnlDjiwx2jZRshZ2unETNXNX+6rBxWW0Z RrfLHn7RRhXzbnreOAN8+Wa3HkrrKPtjduxA+MRt3veUNP7VeCycv0mhAsn7+H/wAaex SjVydziYvnrjK8QSuGUsYBk+Bns/eUEfZUGFW1+GrfIARzGdbpFard45Kbl1k72/MmAL ScDgfTCiHrUkAPuRcgEeWYaDhuXBqEDRoiJQLvE9q5rLsBJwdQTM90zf+CIBzqeYei27 3lww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=baZirKwC; 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-76419-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76419-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com 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.35.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:35:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76419-ouuuleilei=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=baZirKwC; 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-76419-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76419-ouuuleilei=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 CDE8F1F252EA for ; Thu, 22 Feb 2024 11:35:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09E764DA1E; Thu, 22 Feb 2024 11:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="baZirKwC" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 8B5533FB27; Thu, 22 Feb 2024 11:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601617; cv=none; b=bD+ESougOtetMmnjfloUfAmD//V2hirm9SQylstX+oj6udKeuOap+ZUGtnju8znq7EH/YowgUe2wBegQ7+3EIziqJB1y/8r11Jr2M7LUkysaYjpW1t086DudCxsjwkDswFhSWGPPJnfqcPUS208DsR2X/SFys4DLucy7tVPFiYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601617; c=relaxed/simple; bh=xGHj86FA+f6kWv3VdyKdm4QdgFyq8JS4xFMjziCTvbI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=eIlieR6gmvu8m3HWItjFyUXd9aif5v5Tl5u8JyI2EGEe+TDGMp/qI0+pTrIAEa2bHRuh1Of4jMvyXbHQTb11cgU3Gk5yHt0oDgS9GEC4gUxUSHeSOqgSJaiviOtDBOjPX6TfL65o2TarrbXmECVU4t396/CLnbx1HspWZH87iHY= 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=baZirKwC; arc=none smtp.client-ip=198.47.23.248 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXD2N018037; Thu, 22 Feb 2024 05:33:13 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601593; bh=fdOYox9DC6gaFbNXKWSXcI2XCkmrQ8/pFo/KcAvlo6Y=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=baZirKwC6JwTXys1cSizX8hmCuvpYWaycLHOivCO876kUyga01TegbnYTvgBFCwNz NfHBHM3dpOsNKU7wUt6KsAuZ99olZPZ2pRtw9pOa47rOhPbLSHWarVxlNRmiRKevWU R+Phkz9v09SeQ4SdhpmWuR4YUyvM9rqCfR55+EBc= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXDtd057088 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:13 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) 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:12 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE107.ent.ti.com (157.170.170.37) 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:12 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXBa5128545; Thu, 22 Feb 2024 05:33:12 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:20 +0530 Subject: [PATCH RFC 04/21] dt-bindings: media: ti,j721e-csi2rx-shim: Support 32 dma chans Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-4-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=2376; i=j-luthra@ti.com; h=from:subject:message-id; bh=xGHj86FA+f6kWv3VdyKdm4QdgFyq8JS4xFMjziCTvbI=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDdzbRg1271XX4f/9jlXsbLOF3Q6G/iDZBAy YSvFhRrrLyJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw3QAKCRBD3pH5JJpx RbdeEACkJL3LWLqFl21Xy4DfTqvA1tkg/L8MgPXSHOtf9TKPwYY7jW6SeqhJlSq0tu/UiRVq4yE fKo4KKhyPA0ZLwcyKWR1RoPey8JKwlYwq8ok3LzLw7x9IZ/OucXwCnv/FPS7HoIKZ6gRPB+/eJ9 7ocgcPHmp5p6Sy9qCyhaUZRkwn3XYyTIo1gUjE3I3j9gBR8BbJ8Ox8fahCNfYmYUCewUcBRZJes JWW5N2F34HBeBY0ziJOLwmOm0HGtPmCTty44VwJLs0fQ5ovi/QBOr2by7nD80IlRnCU8rlU2XKp n4z2CiapprI4yWVHrnJdEwcmec3Bhmx1tSjNV3wnObDkIsRa9b+kjUG2SfRnAyNfP7gBmcxX9GT XUZEXiHcqLKKRZc7ruLH7bwcBShXCvQvljOGqcu3CBmcsuA54lUHXbr0SB7FnOF2faf7MXCecDR VZ+0OoDcPJYxmAQO8SHdfRGhfUJFk2ivyhQcOLk+OOetGq2l3SwGn9kIx4jHBFp5YadO0IuKWw0 81PZ6IxVGb52CvJTCtr6Mj7mBHK4JzlPBH+yNrJV8D0E+i823O6wPpk0hLGY9JwR1zqpv4/D8XU lLD8CLr4O6T2M5zq63gvnEFKIjFSc0XXnLTXBb+UAcAQBpB5xIU8SenJwAhO0drPW/SLdURurIX owGra5fy3Gdgl7g== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598783067478017 X-GMAIL-MSGID: 1791598783067478017 The CSI2RX SHIM IP can support a maximum of 32x DMA channels. These can be used to split incoming "streams" of data on the CSI-RX port, distinguished by MIPI Virtual Channel (or Data Type), into different locations in memory (/dev/videoX nodes). Actual number of DMA channels reserved is different for each SoC integrating this IP, but a maximum of 32x channels are always available in this IP's register space, so set minimum as 1 and maximum as 32. Link: https://www.ti.com/lit/pdf/spruiv7 Signed-off-by: Jai Luthra --- .../bindings/media/ti,j721e-csi2rx-shim.yaml | 40 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml b/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml index f762fdc05e4d..e47dab7b959e 100644 --- a/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml +++ b/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml @@ -20,11 +20,45 @@ properties: const: ti,j721e-csi2rx-shim dmas: - maxItems: 1 + minItems: 1 + maxItems: 32 dma-names: + minItems: 1 + maxItems: 32 items: - const: rx0 + - const: rx1 + - const: rx2 + - const: rx3 + - const: rx4 + - const: rx5 + - const: rx6 + - const: rx7 + - const: rx8 + - const: rx9 + - const: rx10 + - const: rx11 + - const: rx12 + - const: rx13 + - const: rx14 + - const: rx15 + - const: rx16 + - const: rx17 + - const: rx18 + - const: rx19 + - const: rx20 + - const: rx21 + - const: rx22 + - const: rx23 + - const: rx24 + - const: rx25 + - const: rx26 + - const: rx27 + - const: rx28 + - const: rx29 + - const: rx30 + - const: rx31 reg: maxItems: 1 @@ -62,8 +96,8 @@ examples: ti_csi2rx0: ticsi2rx@4500000 { compatible = "ti,j721e-csi2rx-shim"; - dmas = <&main_udmap 0x4940>; - dma-names = "rx0"; + dmas = <&main_udmap 0x4940>, <&main_udmap 0x4941>; + dma-names = "rx0", "rx1"; reg = <0x4500000 0x1000>; power-domains = <&k3_pds 26 TI_SCI_PD_EXCLUSIVE>; #address-cells = <1>; From patchwork Thu Feb 22 11:31:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp190336dyb; Thu, 22 Feb 2024 03:37:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX2j9vXVE8kfVISsLSAVh0GXcxt3g5CQ7vBJyj3B1P/uvF0svZFpt2tr9KpmEI/hD7vhwQNKeiQ55zHbMkGVZLM4HneFQ== X-Google-Smtp-Source: AGHT+IE1xN+fDc89w/+i5y0zluSEKe/hNUwn2bLN4v9o0eBuSulXuzLZkk5GBpRzasegCuH+hiaw X-Received: by 2002:a05:620a:22e8:b0:787:3e08:bbc with SMTP id p8-20020a05620a22e800b007873e080bbcmr17837150qki.20.1708601829250; Thu, 22 Feb 2024 03:37:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601829; cv=pass; d=google.com; s=arc-20160816; b=f/5/wAHPE8pLDznS1ZR3PNhPh9U6q21fkJQJa+rSRiiSYw48LH5PZjI6BDkqC4edcY vePFT2X4dAK0ttEk38j8TcPE24WSsmNp4ri7mp6qeYP/uUBIQuQ6u1Ifo3yMf+GPBXSk DzGW7OPkNeWRkbFNTxg8fqrsiSPBe/+yr5uinFYcuukuDaPzfCHfTGti07AzCP4u53if GqG9OpkqlL5UqJ7abXoSSUsFD+KuYx6ovVAtipAgVNDbIhn0Y1zYgRtH469s0cW9yDVe d2IFf+4tYRmZ6aKQC5LoNGE2EWy3S1ztu5u2RAXQdhTl1WMgv71O7VTHRZ7aN7e0zagP +wkg== 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=uRek8HB31hxgFd4VtVdI75F7X94Dk4dicwPPOE0HkfI=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=nDgL9OWQujLN2/bBLITDHlaWLwPML7vTYRrRhbpwMtXCj/hNDhAP93Y7vRAe/BbEWg z8TsyLzbHJ7N/3A2pfs/nfX+BnxZkB7Xvw+PeWhPBtu81BftHXpMuzswYs5JWDhY0UES ot1YtBrO5lVm6d0MUClqfryEEoQKgmaxmmwAKFrjJAm8ASj8Ysis3BoCSimigNAC54AQ GjYlMsjt4I8g7PIyp5Q1rjYnSuwgiI30bkLJABH0FpcMFEwvl80uOCU/T7cYBWqSlS0P 1Wdyvy9fzUPfFHsJkfpX5R5ot9Y7yD2C0ajujlVMjzjPUHWTOH+CXDLmW3PUDHKbV3Nn 6JLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hed7TErn; 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-76421-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76421-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pe16-20020a05620a851000b0078724563d65si12657176qkn.127.2024.02.22.03.37.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:37:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76421-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hed7TErn; 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-76421-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76421-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EE08A1C2350A for ; Thu, 22 Feb 2024 11:37:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 941BA524BE; Thu, 22 Feb 2024 11:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="hed7TErn" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 8B5A844C84; Thu, 22 Feb 2024 11:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601618; cv=none; b=aqTkEyELg1rT6avmFM/L1+bX8u2PUbJb/pBOmKqQCYr5SzTWRUDXo7EZDOFlmfxSvWr/VZFRIanjmXoG253bDRT13h3r+35X5qeM7w+gCJzdEH9JbSZvoftheMlt96ObTNoA6C/v7n3NieEo53cEbojpzPEe+q6mfk7HAaFkVdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601618; c=relaxed/simple; bh=Dhya25mNNYpnxX740aUEDySmDBWBtKvGFXJk/wUL1uI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=TNhBfaoVzSL/SU8s/uaAYCXwnVbYp8vcRKe7H3/wsA1qCqtpTYHAUzOhMGk2t8lA108Mibjez7PvoB5Bm71+LwmYZ1QiHBXC7Wd2F77Jk2YdoQOOoWK+rZLUs5SkBKwdGbmD0JLxNSv41Ibl+908PapuGZeFKVylXqrIMq6vfU4= 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=hed7TErn; arc=none smtp.client-ip=198.47.23.248 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXGAm018046; Thu, 22 Feb 2024 05:33:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601596; bh=uRek8HB31hxgFd4VtVdI75F7X94Dk4dicwPPOE0HkfI=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=hed7TErn+WRvEvZIJK9RZB4ZeBukCZPqbcFlN7zeV1XBsvOqNj8AK3hVnnan7mY3e hIF9mDtrqEAhw8XgpPMDw7LBcCYw9Ozq0Swk8INjFa+2Y47RV7tI86RfsT7ScXH4zS 8hnvPM/0vzkPzRzdGEJESfVgaZ1BQfGidmrhaGGU= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXGZr057137 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:16 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE104.ent.ti.com (10.64.6.25) 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:15 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE112.ent.ti.com (10.64.6.33) 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:15 -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 41MBXDwu091104; Thu, 22 Feb 2024 05:33:14 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:21 +0530 Subject: [PATCH RFC 05/21] media: ti: j721e-csi2rx: separate out device and context Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-5-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=26384; i=j-luthra@ti.com; h=from:subject:message-id; bh=Dhya25mNNYpnxX740aUEDySmDBWBtKvGFXJk/wUL1uI=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDe+5PRotqPklbzcwVcplGBh37lIo9cvh1Mg 9IYMuStUn6JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw3gAKCRBD3pH5JJpx RWOIEACvVTWWRGyBRRMm20zBa1h6kBBPMijocy99F8WV23DB1GryNgMVfL8RwvTdv0e6aBrVFNO t77VA8M7R3ifHzX0Liol581gizq9bLuGYQ7VpjlbEyAV3JuDevcqXG8WwME+By96KJFbvtJdQ2E mEU7y7ye8nX2ZaMzIPx80oACZuuTp8ZMsfklE2/XSVdmEo83cgjRrCAHj+NFZeOdRy80QvtIJIR ADKaVzJtM2TnORYXaYt5TeUUMesfEvfURcRfguGnJwDRjAdAG9JYTlo6G4vrZ2FxQqZgQ3Ttz0a P7I7IBWVsGKde4LVger0GKa0/hrN6jsA81hKqVcKv4XnzZUrf6RcnpPjuUTb1w0pPH5FjSj79Km li/YmAuyIBZE99DWt1fRhyNlVLs/9yCPNHda4caKqXmvWds+n3lZsuSPsG5Xu+lRd9VVuokiyjT aYXS4Y8pKeEXJpKWmZo2tiI0LL9+Gx6jCcVLecfTx7T7DmzYAOb4xZz35p6NI8hcejyO8IdNcTu ebSzjgDwHkTLs9GzTMrcr6OPsQuyd0Kd7mvleUVRy0i4RR15tPpNvyCTITDGeEXOLB0cA3dGdgp Ey0OyPoSZFsyR2u1+1uYWbzmsX3PKz/6a+b+zsMIaFrrz3qP2V+/6lAzPulY5/Y+5+9ButOhwg6 9H65JLj/BssofFA== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598871738755552 X-GMAIL-MSGID: 1791598871738755552 The TI CSI2RX wrapper has two parts: the main device and the DMA contexts. The driver was originally written with single camera capture in mind, so only one DMA context was needed. For the sake of simplicity, the context specific stuff was not modeled different to the main device. To enable multiplexed stream capture, the contexts need to be separated out from the main device. Create a struct ti_csi2rx_ctx that holds the DMA context specific things. Separate out functions handling the device and context related functionality. Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 422 ++++++++++++--------- 1 file changed, 240 insertions(+), 182 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index e2cac8d73d78..51fac664d01c 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -40,6 +40,8 @@ #define SHIM_PSI_CFG0_DST_TAG GENMASK(31, 16) #define PSIL_WORD_SIZE_BYTES 16 +#define TI_CSI2RX_NUM_CTX 1 + /* * There are no hard limits on the width or height. The DMA engine can handle * all sizes. The max width and height are arbitrary numbers for this driver. @@ -64,7 +66,7 @@ struct ti_csi2rx_buffer { /* Common v4l2 buffer. Must be first. */ struct vb2_v4l2_buffer vb; struct list_head list; - struct ti_csi2rx_dev *csi; + struct ti_csi2rx_ctx *ctx; }; enum ti_csi2rx_dma_state { @@ -84,29 +86,37 @@ struct ti_csi2rx_dma { * Queue of buffers submitted to DMA engine. */ struct list_head submitted; - /* Buffer to drain stale data from PSI-L endpoint */ - struct { - void *vaddr; - dma_addr_t paddr; - size_t len; - } drain; +}; + +struct ti_csi2rx_dev; + +struct ti_csi2rx_ctx { + struct ti_csi2rx_dev *csi; + struct video_device vdev; + struct vb2_queue vidq; + struct mutex mutex; /* To serialize ioctls. */ + struct v4l2_format v_fmt; + struct ti_csi2rx_dma dma; + u32 sequence; + u32 idx; }; struct ti_csi2rx_dev { struct device *dev; void __iomem *shim; struct v4l2_device v4l2_dev; - struct video_device vdev; struct media_device mdev; struct media_pipeline pipe; struct media_pad pad; struct v4l2_async_notifier notifier; struct v4l2_subdev *source; - struct vb2_queue vidq; - struct mutex mutex; /* To serialize ioctls. */ - struct v4l2_format v_fmt; - struct ti_csi2rx_dma dma; - u32 sequence; + struct ti_csi2rx_ctx ctx[TI_CSI2RX_NUM_CTX]; + /* Buffer to drain stale data from PSI-L endpoint */ + struct { + void *vaddr; + dma_addr_t paddr; + size_t len; + } drain; }; static const struct ti_csi2rx_fmt ti_csi2rx_formats[] = { @@ -236,7 +246,7 @@ static const struct ti_csi2rx_fmt ti_csi2rx_formats[] = { }; /* Forward declaration needed by ti_csi2rx_dma_callback. */ -static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi, +static int ti_csi2rx_start_dma(struct ti_csi2rx_ctx *ctx, struct ti_csi2rx_buffer *buf); static const struct ti_csi2rx_fmt *find_format_by_fourcc(u32 pixelformat) @@ -326,7 +336,7 @@ static int ti_csi2rx_enum_fmt_vid_cap(struct file *file, void *priv, static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *prov, struct v4l2_format *f) { - struct ti_csi2rx_dev *csi = video_drvdata(file); + struct ti_csi2rx_ctx *csi = video_drvdata(file); *f = csi->v_fmt; @@ -357,7 +367,7 @@ static int ti_csi2rx_try_fmt_vid_cap(struct file *file, void *priv, static int ti_csi2rx_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { - struct ti_csi2rx_dev *csi = video_drvdata(file); + struct ti_csi2rx_ctx *csi = video_drvdata(file); struct vb2_queue *q = &csi->vidq; int ret; @@ -443,25 +453,33 @@ static int csi_async_notifier_bound(struct v4l2_async_notifier *notifier, static int csi_async_notifier_complete(struct v4l2_async_notifier *notifier) { struct ti_csi2rx_dev *csi = dev_get_drvdata(notifier->v4l2_dev->dev); - struct video_device *vdev = &csi->vdev; - int ret; + int ret, i; - ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); - if (ret) - return ret; + for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) { + struct ti_csi2rx_ctx *ctx = &csi->ctx[i]; + struct video_device *vdev = &ctx->vdev; - ret = v4l2_create_fwnode_links_to_pad(csi->source, &csi->pad, - MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); - - if (ret) { - video_unregister_device(vdev); - return ret; + ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); + if (ret) + goto unregister_dev; } + ret = v4l2_create_fwnode_links_to_pad(csi->source, &csi->pad, + MEDIA_LNK_FL_IMMUTABLE | + MEDIA_LNK_FL_ENABLED); + if (ret) + goto unregister_dev; + ret = v4l2_device_register_subdev_nodes(&csi->v4l2_dev); if (ret) - video_unregister_device(vdev); + goto unregister_dev; + return 0; + +unregister_dev: + i--; + for (; i >= 0; i--) + video_unregister_device(&csi->ctx[i].vdev); return ret; } @@ -507,12 +525,13 @@ static int ti_csi2rx_notifier_register(struct ti_csi2rx_dev *csi) return 0; } -static void ti_csi2rx_setup_shim(struct ti_csi2rx_dev *csi) +static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *ctx) { + struct ti_csi2rx_dev *csi = ctx->csi; const struct ti_csi2rx_fmt *fmt; unsigned int reg; - fmt = find_format_by_fourcc(csi->v_fmt.fmt.pix.pixelformat); + fmt = find_format_by_fourcc(ctx->v_fmt.fmt.pix.pixelformat); /* De-assert the pixel interface reset. */ reg = SHIM_CNTL_PIX_RST; @@ -579,8 +598,9 @@ static void ti_csi2rx_drain_callback(void *param) * To prevent that stale data corrupting the subsequent transactions, it is * required to issue DMA requests to drain it out. */ -static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *csi) +static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *ctx) { + struct ti_csi2rx_dev *csi = ctx->csi; struct dma_async_tx_descriptor *desc; struct completion drain_complete; dma_cookie_t cookie; @@ -588,8 +608,8 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *csi) init_completion(&drain_complete); - desc = dmaengine_prep_slave_single(csi->dma.chan, csi->dma.drain.paddr, - csi->dma.drain.len, DMA_DEV_TO_MEM, + desc = dmaengine_prep_slave_single(ctx->dma.chan, csi->drain.paddr, + csi->drain.len, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (!desc) { ret = -EIO; @@ -604,11 +624,11 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *csi) if (ret) goto out; - dma_async_issue_pending(csi->dma.chan); + dma_async_issue_pending(ctx->dma.chan); if (!wait_for_completion_timeout(&drain_complete, msecs_to_jiffies(DRAIN_TIMEOUT_MS))) { - dmaengine_terminate_sync(csi->dma.chan); + dmaengine_terminate_sync(ctx->dma.chan); dev_dbg(csi->dev, "DMA transfer timed out for drain buffer\n"); ret = -ETIMEDOUT; goto out; @@ -620,8 +640,8 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *csi) static void ti_csi2rx_dma_callback(void *param) { struct ti_csi2rx_buffer *buf = param; - struct ti_csi2rx_dev *csi = buf->csi; - struct ti_csi2rx_dma *dma = &csi->dma; + struct ti_csi2rx_ctx *ctx = buf->ctx; + struct ti_csi2rx_dma *dma = &ctx->dma; unsigned long flags; /* @@ -629,7 +649,7 @@ static void ti_csi2rx_dma_callback(void *param) * hardware monitor registers. */ buf->vb.vb2_buf.timestamp = ktime_get_ns(); - buf->vb.sequence = csi->sequence++; + buf->vb.sequence = ctx->sequence++; spin_lock_irqsave(&dma->lock, flags); @@ -641,8 +661,9 @@ static void ti_csi2rx_dma_callback(void *param) while (!list_empty(&dma->queue)) { buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); - if (ti_csi2rx_start_dma(csi, buf)) { - dev_err(csi->dev, "Failed to queue the next buffer for DMA\n"); + if (ti_csi2rx_start_dma(ctx, buf)) { + dev_err(ctx->csi->dev, + "Failed to queue the next buffer for DMA\n"); vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); } else { list_move_tail(&buf->list, &dma->submitted); @@ -655,17 +676,17 @@ static void ti_csi2rx_dma_callback(void *param) spin_unlock_irqrestore(&dma->lock, flags); } -static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi, +static int ti_csi2rx_start_dma(struct ti_csi2rx_ctx *ctx, struct ti_csi2rx_buffer *buf) { unsigned long addr; struct dma_async_tx_descriptor *desc; - size_t len = csi->v_fmt.fmt.pix.sizeimage; + size_t len = ctx->v_fmt.fmt.pix.sizeimage; dma_cookie_t cookie; int ret = 0; addr = vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0); - desc = dmaengine_prep_slave_single(csi->dma.chan, addr, len, + desc = dmaengine_prep_slave_single(ctx->dma.chan, addr, len, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (!desc) @@ -679,20 +700,20 @@ static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi, if (ret) return ret; - dma_async_issue_pending(csi->dma.chan); + dma_async_issue_pending(ctx->dma.chan); return 0; } -static void ti_csi2rx_stop_dma(struct ti_csi2rx_dev *csi) +static void ti_csi2rx_stop_dma(struct ti_csi2rx_ctx *ctx) { - struct ti_csi2rx_dma *dma = &csi->dma; + struct ti_csi2rx_dma *dma = &ctx->dma; enum ti_csi2rx_dma_state state; unsigned long flags; int ret; spin_lock_irqsave(&dma->lock, flags); - state = csi->dma.state; + state = ctx->dma.state; dma->state = TI_CSI2RX_DMA_STOPPED; spin_unlock_irqrestore(&dma->lock, flags); @@ -703,30 +724,30 @@ static void ti_csi2rx_stop_dma(struct ti_csi2rx_dev *csi) * is stopped, as the module-level pixel reset cannot be * enforced before terminating DMA. */ - ret = ti_csi2rx_drain_dma(csi); + ret = ti_csi2rx_drain_dma(ctx); if (ret && ret != -ETIMEDOUT) - dev_warn(csi->dev, + dev_warn(ctx->csi->dev, "Failed to drain DMA. Next frame might be bogus\n"); } - ret = dmaengine_terminate_sync(csi->dma.chan); + ret = dmaengine_terminate_sync(ctx->dma.chan); if (ret) - dev_err(csi->dev, "Failed to stop DMA: %d\n", ret); + dev_err(ctx->csi->dev, "Failed to stop DMA: %d\n", ret); } -static void ti_csi2rx_cleanup_buffers(struct ti_csi2rx_dev *csi, +static void ti_csi2rx_cleanup_buffers(struct ti_csi2rx_ctx *ctx, enum vb2_buffer_state state) { - struct ti_csi2rx_dma *dma = &csi->dma; + struct ti_csi2rx_dma *dma = &ctx->dma; struct ti_csi2rx_buffer *buf, *tmp; unsigned long flags; spin_lock_irqsave(&dma->lock, flags); - list_for_each_entry_safe(buf, tmp, &csi->dma.queue, list) { + list_for_each_entry_safe(buf, tmp, &ctx->dma.queue, list) { list_del(&buf->list); vb2_buffer_done(&buf->vb.vb2_buf, state); } - list_for_each_entry_safe(buf, tmp, &csi->dma.submitted, list) { + list_for_each_entry_safe(buf, tmp, &ctx->dma.submitted, list) { list_del(&buf->list); vb2_buffer_done(&buf->vb.vb2_buf, state); } @@ -737,8 +758,8 @@ static int ti_csi2rx_queue_setup(struct vb2_queue *q, unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], struct device *alloc_devs[]) { - struct ti_csi2rx_dev *csi = vb2_get_drv_priv(q); - unsigned int size = csi->v_fmt.fmt.pix.sizeimage; + struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(q); + unsigned int size = ctx->v_fmt.fmt.pix.sizeimage; if (*nplanes) { if (sizes[0] < size) @@ -754,11 +775,11 @@ static int ti_csi2rx_queue_setup(struct vb2_queue *q, unsigned int *nbuffers, static int ti_csi2rx_buffer_prepare(struct vb2_buffer *vb) { - struct ti_csi2rx_dev *csi = vb2_get_drv_priv(vb->vb2_queue); - unsigned long size = csi->v_fmt.fmt.pix.sizeimage; + struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); + unsigned long size = ctx->v_fmt.fmt.pix.sizeimage; if (vb2_plane_size(vb, 0) < size) { - dev_err(csi->dev, "Data will not fit into plane\n"); + dev_err(ctx->csi->dev, "Data will not fit into plane\n"); return -EINVAL; } @@ -768,15 +789,15 @@ static int ti_csi2rx_buffer_prepare(struct vb2_buffer *vb) static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb) { - struct ti_csi2rx_dev *csi = vb2_get_drv_priv(vb->vb2_queue); + struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); struct ti_csi2rx_buffer *buf; - struct ti_csi2rx_dma *dma = &csi->dma; + struct ti_csi2rx_dma *dma = &ctx->dma; bool restart_dma = false; unsigned long flags = 0; int ret; buf = container_of(vb, struct ti_csi2rx_buffer, vb.vb2_buf); - buf->csi = csi; + buf->ctx = ctx; spin_lock_irqsave(&dma->lock, flags); /* @@ -805,18 +826,18 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb) * the application and will only confuse it. Issue a DMA * transaction to drain that up. */ - ret = ti_csi2rx_drain_dma(csi); + ret = ti_csi2rx_drain_dma(ctx); if (ret && ret != -ETIMEDOUT) - dev_warn(csi->dev, + dev_warn(ctx->csi->dev, "Failed to drain DMA. Next frame might be bogus\n"); spin_lock_irqsave(&dma->lock, flags); - ret = ti_csi2rx_start_dma(csi, buf); + ret = ti_csi2rx_start_dma(ctx, buf); if (ret) { vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); dma->state = TI_CSI2RX_DMA_IDLE; spin_unlock_irqrestore(&dma->lock, flags); - dev_err(csi->dev, "Failed to start DMA: %d\n", ret); + dev_err(ctx->csi->dev, "Failed to start DMA: %d\n", ret); } else { list_add_tail(&buf->list, &dma->submitted); spin_unlock_irqrestore(&dma->lock, flags); @@ -826,8 +847,9 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb) static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) { - struct ti_csi2rx_dev *csi = vb2_get_drv_priv(vq); - struct ti_csi2rx_dma *dma = &csi->dma; + struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vq); + struct ti_csi2rx_dev *csi = ctx->csi; + struct ti_csi2rx_dma *dma = &ctx->dma; struct ti_csi2rx_buffer *buf; unsigned long flags; int ret = 0; @@ -839,18 +861,18 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) if (ret) return ret; - ret = video_device_pipeline_start(&csi->vdev, &csi->pipe); + ret = video_device_pipeline_start(&ctx->vdev, &csi->pipe); if (ret) goto err; - ti_csi2rx_setup_shim(csi); + ti_csi2rx_setup_shim(ctx); - csi->sequence = 0; + ctx->sequence = 0; spin_lock_irqsave(&dma->lock, flags); buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); - ret = ti_csi2rx_start_dma(csi, buf); + ret = ti_csi2rx_start_dma(ctx, buf); if (ret) { dev_err(csi->dev, "Failed to start DMA: %d\n", ret); spin_unlock_irqrestore(&dma->lock, flags); @@ -868,22 +890,23 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) return 0; err_dma: - ti_csi2rx_stop_dma(csi); + ti_csi2rx_stop_dma(ctx); err_pipeline: - video_device_pipeline_stop(&csi->vdev); + video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX); err: - ti_csi2rx_cleanup_buffers(csi, VB2_BUF_STATE_QUEUED); + ti_csi2rx_cleanup_buffers(ctx, VB2_BUF_STATE_QUEUED); return ret; } static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) { - struct ti_csi2rx_dev *csi = vb2_get_drv_priv(vq); + struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vq); + struct ti_csi2rx_dev *csi = ctx->csi; int ret; - video_device_pipeline_stop(&csi->vdev); + video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX); @@ -892,8 +915,8 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) if (ret) dev_err(csi->dev, "Failed to stop subdev stream\n"); - ti_csi2rx_stop_dma(csi); - ti_csi2rx_cleanup_buffers(csi, VB2_BUF_STATE_ERROR); + ti_csi2rx_stop_dma(ctx); + ti_csi2rx_cleanup_buffers(ctx, VB2_BUF_STATE_ERROR); } static const struct vb2_ops csi_vb2_qops = { @@ -906,27 +929,60 @@ static const struct vb2_ops csi_vb2_qops = { .wait_finish = vb2_ops_wait_finish, }; -static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *csi) +static void ti_csi2rx_cleanup_dma(struct ti_csi2rx_ctx *ctx) { - struct vb2_queue *q = &csi->vidq; + dma_release_channel(ctx->dma.chan); +} + +static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi) +{ + media_device_unregister(&csi->mdev); + v4l2_device_unregister(&csi->v4l2_dev); + media_device_cleanup(&csi->mdev); +} + +static void ti_csi2rx_cleanup_notifier(struct ti_csi2rx_dev *csi) +{ + v4l2_async_nf_unregister(&csi->notifier); + v4l2_async_nf_cleanup(&csi->notifier); +} + +static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_ctx *ctx) +{ + vb2_queue_release(&ctx->vidq); +} + +static void ti_csi2rx_cleanup_ctx(struct ti_csi2rx_ctx *ctx) +{ + ti_csi2rx_cleanup_dma(ctx); + ti_csi2rx_cleanup_vb2q(ctx); + + video_unregister_device(&ctx->vdev); + + mutex_destroy(&ctx->mutex); +} + +static int ti_csi2rx_init_vb2q(struct ti_csi2rx_ctx *ctx) +{ + struct vb2_queue *q = &ctx->vidq; int ret; q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; q->io_modes = VB2_MMAP | VB2_DMABUF; - q->drv_priv = csi; + q->drv_priv = ctx; q->buf_struct_size = sizeof(struct ti_csi2rx_buffer); q->ops = &csi_vb2_qops; q->mem_ops = &vb2_dma_contig_memops; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->dev = dmaengine_get_dma_device(csi->dma.chan); - q->lock = &csi->mutex; + q->dev = dmaengine_get_dma_device(ctx->dma.chan); + q->lock = &ctx->mutex; q->min_queued_buffers = 1; ret = vb2_queue_init(q); if (ret) return ret; - csi->vdev.queue = q; + ctx->vdev.queue = q; return 0; } @@ -935,8 +991,9 @@ static int ti_csi2rx_link_validate(struct media_link *link) { struct media_entity *entity = link->sink->entity; struct video_device *vdev = media_entity_to_video_device(entity); - struct ti_csi2rx_dev *csi = container_of(vdev, struct ti_csi2rx_dev, vdev); - struct v4l2_pix_format *csi_fmt = &csi->v_fmt.fmt.pix; + struct ti_csi2rx_ctx *ctx = container_of(vdev, struct ti_csi2rx_ctx, vdev); + struct ti_csi2rx_dev *csi = ctx->csi; + struct v4l2_pix_format *csi_fmt = &ctx->v_fmt.fmt.pix; struct v4l2_subdev_format source_fmt = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, .pad = link->source->index, @@ -989,47 +1046,69 @@ static const struct media_entity_operations ti_csi2rx_video_entity_ops = { .link_validate = ti_csi2rx_link_validate, }; -static int ti_csi2rx_init_dma(struct ti_csi2rx_dev *csi) +static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *ctx) { struct dma_slave_config cfg = { .src_addr_width = DMA_SLAVE_BUSWIDTH_16_BYTES, }; int ret; - INIT_LIST_HEAD(&csi->dma.queue); - INIT_LIST_HEAD(&csi->dma.submitted); - spin_lock_init(&csi->dma.lock); + INIT_LIST_HEAD(&ctx->dma.queue); + INIT_LIST_HEAD(&ctx->dma.submitted); + spin_lock_init(&ctx->dma.lock); - csi->dma.state = TI_CSI2RX_DMA_STOPPED; + ctx->dma.state = TI_CSI2RX_DMA_STOPPED; - csi->dma.chan = dma_request_chan(csi->dev, "rx0"); - if (IS_ERR(csi->dma.chan)) - return PTR_ERR(csi->dma.chan); + ctx->dma.chan = dma_request_chan(ctx->csi->dev, "rx0"); + if (IS_ERR(ctx->dma.chan)) + return PTR_ERR(ctx->dma.chan); - ret = dmaengine_slave_config(csi->dma.chan, &cfg); + ret = dmaengine_slave_config(ctx->dma.chan, &cfg); if (ret) { - dma_release_channel(csi->dma.chan); + dma_release_channel(ctx->dma.chan); return ret; } - csi->dma.drain.len = DRAIN_BUFFER_SIZE; - csi->dma.drain.vaddr = dma_alloc_coherent(csi->dev, csi->dma.drain.len, - &csi->dma.drain.paddr, - GFP_KERNEL); - if (!csi->dma.drain.vaddr) - return -ENOMEM; - return 0; } static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) { struct media_device *mdev = &csi->mdev; - struct video_device *vdev = &csi->vdev; + int ret; + + mdev->dev = csi->dev; + mdev->hw_revision = 1; + strscpy(mdev->model, "TI-CSI2RX", sizeof(mdev->model)); + + media_device_init(mdev); + + csi->v4l2_dev.mdev = mdev; + + ret = v4l2_device_register(csi->dev, &csi->v4l2_dev); + if (ret) + return ret; + + ret = media_device_register(mdev); + if (ret) { + v4l2_device_unregister(&csi->v4l2_dev); + media_device_cleanup(mdev); + return ret; + } + + return 0; +} + +static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *ctx) +{ + struct ti_csi2rx_dev *csi = ctx->csi; + struct video_device *vdev = &ctx->vdev; const struct ti_csi2rx_fmt *fmt; - struct v4l2_pix_format *pix_fmt = &csi->v_fmt.fmt.pix; + struct v4l2_pix_format *pix_fmt = &ctx->v_fmt.fmt.pix; int ret; + mutex_init(&ctx->mutex); + fmt = find_format_by_fourcc(V4L2_PIX_FMT_UYVY); if (!fmt) return -EINVAL; @@ -1042,15 +1121,16 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) pix_fmt->quantization = V4L2_QUANTIZATION_LIM_RANGE, pix_fmt->xfer_func = V4L2_XFER_FUNC_SRGB, - ti_csi2rx_fill_fmt(fmt, &csi->v_fmt); + ti_csi2rx_fill_fmt(fmt, &ctx->v_fmt); - mdev->dev = csi->dev; - mdev->hw_revision = 1; - strscpy(mdev->model, "TI-CSI2RX", sizeof(mdev->model)); - - media_device_init(mdev); + csi->pad.flags = MEDIA_PAD_FL_SINK; + vdev->entity.ops = &ti_csi2rx_video_entity_ops; + ret = media_entity_pads_init(&ctx->vdev.entity, 1, &csi->pad); + if (ret) + return ret; - strscpy(vdev->name, TI_CSI2RX_MODULE_NAME, sizeof(vdev->name)); + snprintf(vdev->name, sizeof(vdev->name), "%s context %u", + dev_name(csi->dev), ctx->idx); vdev->v4l2_dev = &csi->v4l2_dev; vdev->vfl_dir = VFL_DIR_RX; vdev->fops = &csi_fops; @@ -1058,61 +1138,28 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) vdev->release = video_device_release_empty; vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_IO_MC; - vdev->lock = &csi->mutex; - video_set_drvdata(vdev, csi); + vdev->lock = &ctx->mutex; + video_set_drvdata(vdev, ctx); - csi->pad.flags = MEDIA_PAD_FL_SINK; - vdev->entity.ops = &ti_csi2rx_video_entity_ops; - ret = media_entity_pads_init(&csi->vdev.entity, 1, &csi->pad); + ret = ti_csi2rx_init_dma(ctx); if (ret) return ret; - csi->v4l2_dev.mdev = mdev; - - ret = v4l2_device_register(csi->dev, &csi->v4l2_dev); + ret = ti_csi2rx_init_vb2q(ctx); if (ret) - return ret; - - ret = media_device_register(mdev); - if (ret) { - v4l2_device_unregister(&csi->v4l2_dev); - media_device_cleanup(mdev); - return ret; - } + goto cleanup_dma; return 0; -} -static void ti_csi2rx_cleanup_dma(struct ti_csi2rx_dev *csi) -{ - dma_free_coherent(csi->dev, csi->dma.drain.len, - csi->dma.drain.vaddr, csi->dma.drain.paddr); - csi->dma.drain.vaddr = NULL; - dma_release_channel(csi->dma.chan); -} - -static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi) -{ - media_device_unregister(&csi->mdev); - v4l2_device_unregister(&csi->v4l2_dev); - media_device_cleanup(&csi->mdev); -} - -static void ti_csi2rx_cleanup_subdev(struct ti_csi2rx_dev *csi) -{ - v4l2_async_nf_unregister(&csi->notifier); - v4l2_async_nf_cleanup(&csi->notifier); -} - -static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_dev *csi) -{ - vb2_queue_release(&csi->vidq); +cleanup_dma: + ti_csi2rx_cleanup_dma(ctx); + return ret; } static int ti_csi2rx_probe(struct platform_device *pdev) { struct ti_csi2rx_dev *csi; - int ret; + int ret, i; csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); if (!csi) @@ -1121,62 +1168,73 @@ static int ti_csi2rx_probe(struct platform_device *pdev) csi->dev = &pdev->dev; platform_set_drvdata(pdev, csi); - mutex_init(&csi->mutex); csi->shim = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(csi->shim)) { ret = PTR_ERR(csi->shim); - goto err_mutex; + return ret; } - ret = ti_csi2rx_init_dma(csi); - if (ret) - goto err_mutex; + csi->drain.len = DRAIN_BUFFER_SIZE; + csi->drain.vaddr = dma_alloc_coherent(csi->dev, csi->drain.len, + &csi->drain.paddr, + GFP_KERNEL); + if (!csi->drain.vaddr) + return -ENOMEM; ret = ti_csi2rx_v4l2_init(csi); - if (ret) - goto err_dma; - - ret = ti_csi2rx_init_vb2q(csi); if (ret) goto err_v4l2; + for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) { + csi->ctx[i].idx = i; + csi->ctx[i].csi = csi; + ret = ti_csi2rx_init_ctx(&csi->ctx[i]); + if (ret) + goto err_ctx; + } + ret = ti_csi2rx_notifier_register(csi); if (ret) - goto err_vb2q; + goto err_ctx; ret = of_platform_populate(csi->dev->of_node, NULL, NULL, csi->dev); if (ret) { dev_err(csi->dev, "Failed to create children: %d\n", ret); - goto err_subdev; + goto err_notifier; } return 0; -err_subdev: - ti_csi2rx_cleanup_subdev(csi); -err_vb2q: - ti_csi2rx_cleanup_vb2q(csi); +err_notifier: + ti_csi2rx_cleanup_notifier(csi); +err_ctx: + i--; + for (; i >= 0; i--) + ti_csi2rx_cleanup_ctx(&csi->ctx[i]); + err_v4l2: - ti_csi2rx_cleanup_v4l2(csi); -err_dma: - ti_csi2rx_cleanup_dma(csi); -err_mutex: - mutex_destroy(&csi->mutex); + dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, + csi->drain.paddr); return ret; } static int ti_csi2rx_remove(struct platform_device *pdev) { struct ti_csi2rx_dev *csi = platform_get_drvdata(pdev); + int i; + + for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) { + if (vb2_is_busy(&csi->ctx[i].vidq)) + return -EBUSY; + } - video_unregister_device(&csi->vdev); + for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) + ti_csi2rx_cleanup_ctx(&csi->ctx[i]); - ti_csi2rx_cleanup_vb2q(csi); - ti_csi2rx_cleanup_subdev(csi); + ti_csi2rx_cleanup_notifier(csi); ti_csi2rx_cleanup_v4l2(csi); - ti_csi2rx_cleanup_dma(csi); - - mutex_destroy(&csi->mutex); + dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, + csi->drain.paddr); return 0; } From patchwork Thu Feb 22 11:31:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp190028dyb; Thu, 22 Feb 2024 03:36:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW8RtHdsa2NR66HL4Cgqnywm1Au0qcPa7Cd5QyiB6q8FqYMqEN6Kt0EvXqavQtC9vwC+5ZZ++W3+QXLnQtA9MyFIWps9Q== X-Google-Smtp-Source: AGHT+IERhmZwR8UoUkipgy8g2TBbKGIcrMQVMEEor6Iu2p8Xa36QnZl+qRF0IxE4k/PF6mEKNAYs X-Received: by 2002:a05:6a21:8183:b0:19e:9143:2ab5 with SMTP id pd3-20020a056a21818300b0019e91432ab5mr14239040pzb.25.1708601783237; Thu, 22 Feb 2024 03:36:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601783; cv=pass; d=google.com; s=arc-20160816; b=KkrCDMAnDHCClaHsTz4yfyjRb6uZNemlLZi7U8FQ67KyVoG6e8F/pwBp6I5IZia3p/ xniK1Feg5UcgJ+n06on6edP/tL+/KMc9vfJI1BJtUGNC0iv3V8oTGwiT3QbC11GkHYwn oqFeIka8r6ip7leHBHKjJRoqwgFKlYSiIroT4oGysFC3NtgMEqxIBY4mMDGJNIR9hZLh EZIJVsc6YjVhvkyrGew4qnYwO8C17kqnP1fGa7zxkxg5wtO0HlCa5r4jsPShknt5TmtS cIxnD6oo1xjoTn6GFN0pzUrl6NnTJYEZ4dtBZ4OAD5eQFzpQ0KCrHMdzTyjb/9v6FOxf j0dQ== 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=vgG8Pl1M4grO/Gh8T9ZEbDeHXu7+7KB9qSq+V1q4TSs=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=LM9pLIKZKDzhKBGVsMeLnJZFExT1NTmCKxeDZyeNy6bBvHyZiPNAeNbXfR0Gs7GWQO EuRgyR6iQc/p0ENaPXzWBSDu4Ia6pNRwhnuciJ1pcYCJNsee9JCIk2lMrz0fVXMR0y1Q wQVwdXAnbGKLVHChchOzezBLZ0NLzUw4r3aqqxBs4V2hc6fg8On4RsKS6dCqoVRih/CG B/dQOiMNejOvb+ploW1/ZZs08U5M/hQb8MlX5U1rPShfwPEUAQEaFf+CExCOPiT/NWW3 jjXFKytSa0g42WNQqRfyA3BdxZtGXgMN7d37qx++IV5fs+1lqi0KOwtCxVWcdAg3mW9Q AO+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=mLQk3L5p; 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-76422-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76422-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x13-20020aa7918d000000b006e1358dc6fbsi10024006pfa.378.2024.02.22.03.36.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:36:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76422-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=mLQk3L5p; 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-76422-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76422-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A7FD1281A58 for ; Thu, 22 Feb 2024 11:36:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 794F24F615; Thu, 22 Feb 2024 11:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="mLQk3L5p" 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 EB5D9482E2; Thu, 22 Feb 2024 11:33:36 +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=1708601618; cv=none; b=SKBUQBhYQv+JNH4Q3w//gIXs8WNY+P4xm4+Ll++1o+En1HpPysW/EQ+6+xhVrcuRJKEN/Y9VOzxbsbuYEHyF1I70oxOCN0plSbCtCrLw1LWaspZfHJ/q9lemy634czk7uPK86D/6YU1aEpG2E/XPbaaptmPVZOQrWq33gSRJBsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601618; c=relaxed/simple; bh=i3XZLUwa1rEf80HvLKRoXBv74vvKRzQwjCodPjjVeY0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=cZSp6MZhw/j1gYwzeOZ6wfr8cCvVVFdpp+w8/Yfxx7yVVrxEHRhNbzwD/PYxVGIT75j/9Tw0Po2M5sOYcD3VHlIWn/Zl7fJDSRpW5fXW2Y/6orxlw2EIW64psacXTu22PCVOUlN/14VJVjsDgOBaFtCPjAcXQNU829LeLUroEJg= 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=mLQk3L5p; 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 fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXHdu027789; Thu, 22 Feb 2024 05:33:17 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601597; bh=vgG8Pl1M4grO/Gh8T9ZEbDeHXu7+7KB9qSq+V1q4TSs=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=mLQk3L5pPmt8OmZI+1d8AexppK3hHYKcbLchap9zrDNL5jYwX0FMmUfbW6Dv8AXBL CrvLzMpSRd0JRhTeU2NvscwZYcC+OZh7bTcXk94kWEtx4gfIT8pmks2+aE/jecZAw7 D5JO6Vmt4oQ/aQ0tpuqhqfC5+9z3iBcx1KZcbr50= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXH7V014080 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:17 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE109.ent.ti.com (10.64.6.30) 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:17 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE105.ent.ti.com (10.64.6.26) 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:17 -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 41MBXGTi091164; Thu, 22 Feb 2024 05:33:17 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:22 +0530 Subject: [PATCH RFC 06/21] media: ti: j721e-csi2rx: prepare SHIM code for multiple contexts Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-6-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=2436; i=j-luthra@ti.com; h=from:subject:message-id; bh=hRPOamfPuHrERb/eWqzY/9jpUuBkempbM1uAnmFujKs=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDfNYkMPiKCTC2JPadipH7bxiCc5pmmNv4vj vnxTvztoxOJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw3wAKCRBD3pH5JJpx RRpsD/4wwJTyJYUjpaEjB/52IwpCWMs9edpqHg/ZBPFc/d1o/+MmQ/Kc9mymRzwh8fHOBBi5KXL Ah3zSbvx1c1kV5k1gVfRNFIALl/Ldw7U4BwCDK1r44FW1cAuqBm016GDCrlKwP6ZXrUmyg7DrHM EG8cwJIGHdMDk8Ejc2PumjM9RRJdUl0tXWeVP1Ro3lheDS5hpxrlhcTAPiRFQ+OiMwwWnNoDElI vXdbk1JeIl3Zm+wULZ66BNumLPV/4T78SN8ptEhYFM4/TOpcxw2HxOKveP1ZaDUPAYRBiSB8wlI 3KpoDpycMhZ8pnnlL1K4TG3ao1zDZG/RMmxySFkg7nvKlSeVOo3QKUol1wPcwmKJZBChL90tcQF QvdbJ+KDgC0gy4+OPNwBzirADwWvadUyDTbZlLi7AYaKVwFlpRY0ozkls60YsGG8Kh7Bp89nSRR HSizx33PukEbZuus9QQiQyLe99iRXMs+LR1W5d0klLpvxZf5WYFOHXSRyfnmcLeWJptzTROduAp oHEiFu4HAZzJMUuTsgViHbertPncOl3/trD3qBbmDft7wz3Jb4yBq9+qiAi3YMjNBAGr+HdTAbG ZwdhVHFyG52Ja5D/Cz9PdZ/lHRDPVwvirtaXR5q9Se161cPHm/yoCrbbPC5VB63NXG1yEvkc0CI YsM2Y3nnK00wrog== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598823356667869 X-GMAIL-MSGID: 1791598823356667869 From: Pratyush Yadav Currently the SHIM code to configure the context only touches the first context. Add support for writing to the context's registers based on the context index. Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra --- drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 51fac664d01c..e42941d8c457 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -25,7 +25,7 @@ #define SHIM_CNTL 0x10 #define SHIM_CNTL_PIX_RST BIT(0) -#define SHIM_DMACNTX 0x20 +#define SHIM_DMACNTX(i) (0x20 + ((i) * 0x20)) #define SHIM_DMACNTX_EN BIT(31) #define SHIM_DMACNTX_YUV422 GENMASK(27, 26) #define SHIM_DMACNTX_SIZE GENMASK(21, 20) @@ -35,7 +35,7 @@ #define SHIM_DMACNTX_SIZE_16 1 #define SHIM_DMACNTX_SIZE_32 2 -#define SHIM_PSI_CFG0 0x24 +#define SHIM_PSI_CFG0(i) (0x24 + ((i) * 0x20)) #define SHIM_PSI_CFG0_SRC_TAG GENMASK(15, 0) #define SHIM_PSI_CFG0_DST_TAG GENMASK(31, 16) @@ -573,11 +573,11 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *ctx) reg |= FIELD_PREP(SHIM_DMACNTX_SIZE, fmt->size); - writel(reg, csi->shim + SHIM_DMACNTX); + writel(reg, csi->shim + SHIM_DMACNTX(ctx->idx)); reg = FIELD_PREP(SHIM_PSI_CFG0_SRC_TAG, 0) | FIELD_PREP(SHIM_PSI_CFG0_DST_TAG, 0); - writel(reg, csi->shim + SHIM_PSI_CFG0); + writel(reg, csi->shim + SHIM_PSI_CFG0(ctx->idx)); } static void ti_csi2rx_drain_callback(void *param) @@ -894,7 +894,7 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) err_pipeline: video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); - writel(0, csi->shim + SHIM_DMACNTX); + writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); err: ti_csi2rx_cleanup_buffers(ctx, VB2_BUF_STATE_QUEUED); return ret; @@ -909,7 +909,7 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); - writel(0, csi->shim + SHIM_DMACNTX); + writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); ret = v4l2_subdev_call(csi->source, video, s_stream, 0); if (ret) From patchwork Thu Feb 22 11:31:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp192434dyb; Thu, 22 Feb 2024 03:41:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX2525w9LEZuNeFjAXRQRJNl5S6MYiKAeyA0pK9kQ6FU3Gnx6EmSToalU03pyr1MJ4wCJHquu8UEoBp4HfWwmE2PGcFYg== X-Google-Smtp-Source: AGHT+IHfcyxAgmt+57Gbx7R9BOnFS+uCgN3EqFK7fNS3fltBVCFRARtgFQXslSTnhbzgv89wjTyq X-Received: by 2002:a17:906:79d8:b0:a3d:1df3:9d35 with SMTP id m24-20020a17090679d800b00a3d1df39d35mr14002495ejo.23.1708602098624; Thu, 22 Feb 2024 03:41:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602098; cv=pass; d=google.com; s=arc-20160816; b=oyuIdDd8yTPscrOmJpHw74qE0r+djfnjZiS0X04XekcK4x5FG5sihYRS/MukbPdw1m 4DvjKdO4QOQzcRuPP/herC5SFur1rwOFUGkCTBwJRAUnismq9PNe24m1RMYq65Llw3Dn Jb8SLlJv/VwMDFWChGG5sY5I8ckON7l1vopmMU/D6pc7/bo+KbhfhAczLpbsmS3gHTmO j4SD+rGDm68acO8JdfsvDWbK83S+gUwbecDw9gdtNUaqmF9GZThogaN/A7kdiWUE5ftr VOLqDWtUMhEURMggW79kkDrX31pfKG9EYdXq3PDTSmRDZztbWABEQ37EO1Va3o/l2pwk It+A== 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=hjMUTlmpymMtXih2bSHWH48S62epqs0t4UUSlAQaSfc=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=Oxv0YorrQDUgTZYzgNzXXslx6Z/lIDdKvtkPhvOlV2Tu+1ezqOjvZhflr7aoVVYaZX CtLvZ+JRZvjV3Jo5Ejh2uqP6i6uW1X7exX9sjpVFV3ZUhXACfZTlXZOZg8MW9fzr8QSy 2wGeYVXgCkpjy7IaojmvGXm2+BQkG3abbxwDOjC0F0ePXz3qIbcOqLIeR50EBu0KqrmJ mPkU36bIw8ZT7ddIIQOxge1iRJ4prKvPRqMSpRzthE1+bCVhpv5msncl1v3nHlniKzTa 8VbMm9TAozzmip0FHdb/+VD+VwT++EE48uwyDZ6KfQPSoo6lt31L3XS/SyFIE0AO/fId nguw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HnHxeBrR; 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-76423-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76423-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h11-20020a17090634cb00b00a3d526f83fdsi5474166ejb.367.2024.02.22.03.41.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:41:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76423-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HnHxeBrR; 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-76423-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76423-ouuuleilei=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 BFC221F26FD2 for ; Thu, 22 Feb 2024 11:36:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55E3D4F5FE; Thu, 22 Feb 2024 11:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="HnHxeBrR" 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 CFE494C615; Thu, 22 Feb 2024 11:33:37 +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=1708601619; cv=none; b=GC+ik3t2K8vzNDGR3h+pVbwQsly2ieXRMmjXzT0A4r8A851D82rHaX/OhprOZ/yFcSet8AZdi8fR41Ie2riGHsrtQeJoUWENSBaQbOvSsyoKWwvjqRvLSXMWPn8uZm9s1jNQjzjGtqZ5IVMAbPhPAauiGD4QJavpDMncItLtcz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601619; c=relaxed/simple; bh=NkuknAzJS/tKWohPGjD0ggsJ9LC//lHX1riPoRArDVA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=igC8O3SHt+87TMyS7weeOsFpxp/1CqnFvmuVkQEMCkQI5XRxXh1UHc1vL9qQVSgyu3UxhF+8a1KPhFRZomjp9sIhdRIls2s9eDDoADfr3hpAitRQppHVXlIL8Zt0OQIrN0eVnZbnhA++7wqDUdOEp+pi01Ib1looqmwt4DQIQlM= 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=HnHxeBrR; 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 fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXJoU027794; Thu, 22 Feb 2024 05:33:19 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601599; bh=hjMUTlmpymMtXih2bSHWH48S62epqs0t4UUSlAQaSfc=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=HnHxeBrRL1m60sAWYTmXMZm1gU+wEB5s002vTWa5hj68MRZi38olVoRpFU4VqUwbE nkxDhv5Su5+d4l6TMxDGSooU8LUErYZVN/7T1LqDhBF7in0r+0wfe/YEGDrJeADNP+ PSeYSo/0CKOxF7EYDuwE+MFXLQea+ssozng/Bl5A= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXJIa014107 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:19 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE111.ent.ti.com (10.64.6.32) 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:19 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE110.ent.ti.com (10.64.6.31) 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:19 -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 41MBXI4I091205; Thu, 22 Feb 2024 05:33:18 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:23 +0530 Subject: [PATCH RFC 07/21] media: ti: j721e-csi2rx: allocate DMA channel based on context index Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-7-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=1393; i=j-luthra@ti.com; h=from:subject:message-id; bh=j/FVZDj0NTL0RooVFkoPWVyiLPQWJuy0qgzy23a+DCk=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDgjkgKNhaK9vvGfp6LiC19Sop3UFGjD99R6 Vw3ghcnJV2JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw4AAKCRBD3pH5JJpx RcBoEAC8/QUsQHYZ0+ro1rkl3HbyiG2cKH3JNb922sofqqly+8FiQQ1yGD6+QfdxUEY8Brfqd3J NQRl88JCwstd6E+F66sTTbFeoTHq5MtflkqdJLLzRr8kDQBhFYx+0+/P5sVqhAZtbJhJb7R4Lxi CmKRBz1NjPx5ATtvDK74+dEinWCx1Z9A6/YwnHF9dMdTTTlRtUIehaSVUZMCoFYfsXcw8vNEIw1 yiC9gIXVtyJHH/EUKFLxWKGSubCqlQJMG264SLVMSimMofCIPt808tbijPrMKWUlqwU0pegbzj+ UrNdR+rZl7yO4f/LX4GUxOLn3SyJY9vpFiIGiI6Vvxr6OXjdYoz2RSRpPnftQ1huIgrbtuU3qUD lH50g8AEzsC0iIkp9oPbTs2bg3mbo15/YDk8mmS79yN1ilWRmmq3fXs18fCFe1UNQkCByoxvdUG IQpAluicWKsyE8NmPBB2nmMCrQIMPF+7zLQLBm25dsAbtEddTzsAy/Bq8W/KgbTHHM+qy9HLmye UTqJaN/kuzLanNpFLYgi/cpzUT2oEIm3FLtr+myh6wDSf4MxPvrNite13goNMCN9UzcBwgbejnw XYKG9LPfDO6EEooK3vNXqCTRlcgBxJL5TB5+mW6xDOvgHx9HHNPyyPc0QdFN1XePE20/vssjC7K onTcapLpySzFOiA== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599154166671950 X-GMAIL-MSGID: 1791599154166671950 From: Pratyush Yadav With multiple contexts, there needs to be a different DMA channel for each context. Earlier, the DMA channel name was hard coded to "rx0" for the sake of simplicity. Generate the DMA channel name based on its index and get the channel corresponding to the context. Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra --- drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index e42941d8c457..80d7066100bf 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -1051,6 +1051,7 @@ static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *ctx) struct dma_slave_config cfg = { .src_addr_width = DMA_SLAVE_BUSWIDTH_16_BYTES, }; + char name[32]; int ret; INIT_LIST_HEAD(&ctx->dma.queue); @@ -1059,7 +1060,8 @@ static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *ctx) ctx->dma.state = TI_CSI2RX_DMA_STOPPED; - ctx->dma.chan = dma_request_chan(ctx->csi->dev, "rx0"); + snprintf(name, sizeof(name), "rx%u", ctx->idx); + ctx->dma.chan = dma_request_chan(ctx->csi->dev, name); if (IS_ERR(ctx->dma.chan)) return PTR_ERR(ctx->dma.chan); From patchwork Thu Feb 22 11:31:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp192643dyb; Thu, 22 Feb 2024 03:42:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWsfR7oEhBo35tYGp5JBQWIJ8E+36thYwhw5RyMx9X7hnQhNHXIdeJHKnF2CrkdRhErIxBmwRa9OS8CuUu4rdW4nPfM1A== X-Google-Smtp-Source: AGHT+IGj1Jzp0n66vTmCeH879ufe1pJhBELhx05q8XoGPWyoD8QbtYTz2Z9lkJCT53TUa+sY9S/V X-Received: by 2002:a17:906:abcf:b0:a3f:2ffd:c683 with SMTP id kq15-20020a170906abcf00b00a3f2ffdc683mr3558596ejb.62.1708602123922; Thu, 22 Feb 2024 03:42:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602123; cv=pass; d=google.com; s=arc-20160816; b=ZCmcaNItTAlq4nfc4mhrYpiOYBq4EsTxyXC/qzzQxlcbWbgKovYlo3pwAFetOtnt3w iigLwYLZOd6pBQ/FmuOc3c1Y1Cj7sUlMR9/gwyMUBMM6nRddMODoigoL2pjDx2Y8LB7C 3IQNywPlFxpHGIK7ie6lkC6F5ocE33w/J9nvcoeOxyqyB8n/W3KCm61YCAE4TG+/JiCa POctlXCVMqd4XTYFmJ8bX5ZBdL+V/On3jsv/xX8uQ7+d/ENeL6+W/GpNHjdyOxzBKjM5 yx09HOD8X+1rRG2YLLBtRdjlB7UmPY8ArotAvAZDMJcxj7Coe/ga1KwG5RspUhrKUm8G 8DDA== 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=FK4vACELRejD1soTNVVYsWj9/vO5TJ0UV4lYpPXtF0o=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=VYSwidr+NH2ghIuC5TsLziZlIrbnY3MA6TTtp/+e43dpVMgJIw9q8kTNoUa6FmGrh0 hEfIsi+JqALAQC+++1XXewA9wFaP6lD55XcOpd/6szdcqEI2LfxetO9PBM5ZhC21hfBx Tlw2K987Lu8iYjsB+Supe7WSizDof9hMsY3Kozs46OFmQlDS47N3RQliG/slnL/Nj3No lPUsGPcTsbBBfhsW6rkNBIPNE5pfbc2Odv41vz/aX6rKo+7MDa6L+GPc3oZBT0dkKkPa lBdcaTZJmCyh8ZQjljbk1APVT35BG6hX9jE1XnboyujzZZdxbuRhe+9OiQTDnvBNTTw9 dLiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=k2TNu+U6; 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-76420-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76420-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i24-20020a170906265800b00a3e5aa9bb7dsi4432607ejc.436.2024.02.22.03.42.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:42:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76420-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=k2TNu+U6; 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-76420-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76420-ouuuleilei=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 51BCE1F26EC3 for ; Thu, 22 Feb 2024 11:36:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E956B4F20E; Thu, 22 Feb 2024 11:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="k2TNu+U6" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 8B64D45010; Thu, 22 Feb 2024 11:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601617; cv=none; b=g7NNuMeiL0SYs88jPssG+8jjBxzyUGLvYqScEoovmyjo+9l9jtZYE4E0Zkrl4or/26a91lBPFrhGJgL8kvQXslHmhIFGvt87z18ferHL1+29bcLEMJdXq0FZFJ43KxC/9HXWjeR9ooCFU4OpcOi7WD5NRz5tzp+Q2DICAqzACRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601617; c=relaxed/simple; bh=Dca0Koq/zfrrUf9kobNjuQW8iIT2NcxY2qulOqqgK5A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=IO6Ybn8Cz5B10N97GGgE4TzhL5lQADuM8Zw+zdkPfacHOuiX7WkOlAhaqIkyUve9R7gd9CEBDM5tA3Axu/1w0y1EAMdZqJeF+yri9LPBxE63rniJjJvy8CcxbxH8Jg5og01rWPi5nJqoXQcvrgK0S9tncSiPhNQRBZbWBhNy3YI= 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=k2TNu+U6; arc=none smtp.client-ip=198.47.23.248 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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXLFp018054; Thu, 22 Feb 2024 05:33:21 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601601; bh=FK4vACELRejD1soTNVVYsWj9/vO5TJ0UV4lYpPXtF0o=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=k2TNu+U68xWJ2Isx7K1HgVBRL4aKUKVimHiDcVK87TMCq7TMNywhsVZCiIoq2YjcI ILsQi/BSOQL/oLMi094MAMQVlPjiVvQUfgtM+uo5UI6KTvUvbN4ituphl1n6xRaZPP kvX6DzNZLvCF5NuAvZIVrZUoEUDpna5oOjiqwVz8= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXLjA007539 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:21 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) 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:21 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE107.ent.ti.com (157.170.170.37) 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:21 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXJRQ128677; Thu, 22 Feb 2024 05:33:20 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:24 +0530 Subject: [PATCH RFC 08/21] media: ti: j721e-csi2rx: add a subdev for the core device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-8-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=11380; i=j-luthra@ti.com; h=from:subject:message-id; bh=Dca0Koq/zfrrUf9kobNjuQW8iIT2NcxY2qulOqqgK5A=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDhF7UrYNVPFQ1DNmqkiXFQeqGCo+0Bhm24q qv+hJgVy32JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw4QAKCRBD3pH5JJpx RXGYEADTvovif4tTyDlmv4kSdxSwRHTnVnaqIkllRQiH1OtDGRm57cj46ylQh+RdWQ+4ZvJMo6c lnwB5sAHhFTrcOMTPn44i+FPzD7UtwldAPDp+SzTm2wmqlODMZjFL7uz2O3NHkTeNDsfmGFFWnm ywt99ma/HRibXzNrhMfNsaGgIY0fWT0CjyJKfxN1WL8nk8okzemEerh1ZTjqpfnz9CKqApZO3pf JszAyhrEuyibZdX7Xoic8WUj0Gae6PpIjPW53yZzQBsKoP5d/byEg7RBz/UX9arhiLBf+d/BYQN 45sfxrzj/MiAlK3Au2qpt7Trcqg1G1FTLBPixQrwZKJXwBQ74eXiclEvDxyy0ro+4jrILOx1V8g n8SFLt09lFEU94IrXY/svqghY6D/UKs/GWwbNXhrtDakigWaJ8JlJjXFZD0F/UhyMz7lI3gprVI YzefAO3pjyPALsbnpkGd5Cn4noVozG4JFHAB3Pp662V+jFT5xxZv4ZG77YfjNO8Tec//lNZsv0X WXMgShdHNvkHFosepTD2zC9IseNCIcgZtwXy+lUx7Px/D3Ybkchc1MI85QBu5awkNGOa6u5GxI2 yK9MzGun0QfszRWsBiex1OIAEtpwKkzi8VaAYvluyP3grnqyC35UwdYdVNvyYMIKYz00H3y7I06 F9DDXWzK03tvK1A== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599180759153693 X-GMAIL-MSGID: 1791599180759153693 With single stream capture, it was simpler to use the video device as the media entity representing the main TI CSI2RX device. Now with multi stream capture coming into the picture, the model has shifted to each video device having a link to the main device's subdev. The routing would then be set on this subdev. Add this subdev, link each context to this subdev's entity and link the subdev's entity to the source. Also add an array of media pads. It will have one sink pad and source pads equal to the number of contexts. Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 217 +++++++++++++++++++-- 1 file changed, 198 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 80d7066100bf..42eb1bff21e2 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -51,6 +51,11 @@ #define MAX_WIDTH_BYTES SZ_16K #define MAX_HEIGHT_LINES SZ_16K +#define TI_CSI2RX_PAD_SINK 0 +#define TI_CSI2RX_PAD_FIRST_SOURCE 1 +#define TI_CSI2RX_NUM_SOURCE_PADS 1 +#define TI_CSI2RX_NUM_PADS (1 + TI_CSI2RX_NUM_SOURCE_PADS) + #define DRAIN_TIMEOUT_MS 50 #define DRAIN_BUFFER_SIZE SZ_32K @@ -97,6 +102,7 @@ struct ti_csi2rx_ctx { struct mutex mutex; /* To serialize ioctls. */ struct v4l2_format v_fmt; struct ti_csi2rx_dma dma; + struct media_pad pad; u32 sequence; u32 idx; }; @@ -104,12 +110,15 @@ struct ti_csi2rx_ctx { struct ti_csi2rx_dev { struct device *dev; void __iomem *shim; + struct mutex mutex; /* To serialize ioctls. */ + unsigned int enable_count; struct v4l2_device v4l2_dev; struct media_device mdev; struct media_pipeline pipe; - struct media_pad pad; + struct media_pad pads[TI_CSI2RX_NUM_PADS]; struct v4l2_async_notifier notifier; struct v4l2_subdev *source; + struct v4l2_subdev subdev; struct ti_csi2rx_ctx ctx[TI_CSI2RX_NUM_CTX]; /* Buffer to drain stale data from PSI-L endpoint */ struct { @@ -455,6 +464,15 @@ static int csi_async_notifier_complete(struct v4l2_async_notifier *notifier) struct ti_csi2rx_dev *csi = dev_get_drvdata(notifier->v4l2_dev->dev); int ret, i; + /* Create link from source to subdev */ + ret = v4l2_create_fwnode_links_to_pad(csi->source, + &csi->pads[TI_CSI2RX_PAD_SINK], + MEDIA_LNK_FL_IMMUTABLE | + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; + + /* Create and link video nodes for all DMA contexts */ for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) { struct ti_csi2rx_ctx *ctx = &csi->ctx[i]; struct video_device *vdev = &ctx->vdev; @@ -462,13 +480,17 @@ static int csi_async_notifier_complete(struct v4l2_async_notifier *notifier) ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); if (ret) goto unregister_dev; - } - ret = v4l2_create_fwnode_links_to_pad(csi->source, &csi->pad, - MEDIA_LNK_FL_IMMUTABLE | - MEDIA_LNK_FL_ENABLED); - if (ret) - goto unregister_dev; + ret = media_create_pad_link(&csi->subdev.entity, + TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx, + &vdev->entity, 0, + MEDIA_LNK_FL_IMMUTABLE | + MEDIA_LNK_FL_ENABLED); + if (ret) { + video_unregister_device(vdev); + goto unregister_dev; + } + } ret = v4l2_device_register_subdev_nodes(&csi->v4l2_dev); if (ret) @@ -883,7 +905,7 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) dma->state = TI_CSI2RX_DMA_ACTIVE; spin_unlock_irqrestore(&dma->lock, flags); - ret = v4l2_subdev_call(csi->source, video, s_stream, 1); + ret = v4l2_subdev_call(&csi->subdev, video, s_stream, 1); if (ret) goto err_dma; @@ -911,7 +933,7 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); - ret = v4l2_subdev_call(csi->source, video, s_stream, 0); + ret = v4l2_subdev_call(&csi->subdev, video, s_stream, 0); if (ret) dev_err(csi->dev, "Failed to stop subdev stream\n"); @@ -929,6 +951,119 @@ static const struct vb2_ops csi_vb2_qops = { .wait_finish = vb2_ops_wait_finish, }; +static inline struct ti_csi2rx_dev *to_csi2rx_dev(struct v4l2_subdev *sd) +{ + return container_of(sd, struct ti_csi2rx_dev, subdev); +} + +static int ti_csi2rx_sd_set_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_format *format) +{ + struct v4l2_mbus_framefmt *fmt; + int ret = 0; + + /* No transcoding, don't allow setting source fmt */ + if (format->pad >= TI_CSI2RX_PAD_FIRST_SOURCE) + return v4l2_subdev_get_fmt(sd, state, format); + + if (!find_format_by_code(format->format.code)) + format->format.code = ti_csi2rx_formats[0].code; + + format->format.field = V4L2_FIELD_NONE; + + fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream); + if (!fmt) { + ret = -EINVAL; + goto out; + } + *fmt = format->format; + + fmt = v4l2_subdev_state_get_format(state, TI_CSI2RX_PAD_FIRST_SOURCE, + format->stream); + if (!fmt) { + ret = -EINVAL; + goto out; + } + *fmt = format->format; + +out: + return ret; +} + +static int ti_csi2rx_sd_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state) +{ + struct v4l2_subdev_format format = { + .pad = TI_CSI2RX_PAD_SINK, + .format = { + .width = 640, + .height = 480, + .code = MEDIA_BUS_FMT_UYVY8_1X16, + .field = V4L2_FIELD_NONE, + .colorspace = V4L2_COLORSPACE_SRGB, + .ycbcr_enc = V4L2_YCBCR_ENC_601, + .quantization = V4L2_QUANTIZATION_LIM_RANGE, + .xfer_func = V4L2_XFER_FUNC_SRGB, + }, + }; + + return ti_csi2rx_sd_set_fmt(sd, state, &format); +} + +static int ti_csi2rx_sd_s_stream(struct v4l2_subdev *sd, int enable) +{ + struct ti_csi2rx_dev *csi = to_csi2rx_dev(sd); + int ret = 0; + + mutex_lock(&csi->mutex); + + if (enable) { + if (csi->enable_count > 0) { + csi->enable_count++; + goto out; + } + + ret = v4l2_subdev_call(csi->source, video, s_stream, 1); + if (ret) + goto out; + + csi->enable_count++; + } else { + if (csi->enable_count == 0) { + ret = -EINVAL; + goto out; + } + + if (--csi->enable_count > 0) + goto out; + + ret = v4l2_subdev_call(csi->source, video, s_stream, 0); + } + +out: + mutex_unlock(&csi->mutex); + return ret; +} + +static const struct v4l2_subdev_pad_ops ti_csi2rx_subdev_pad_ops = { + .get_fmt = v4l2_subdev_get_fmt, + .set_fmt = ti_csi2rx_sd_set_fmt, +}; + +static const struct v4l2_subdev_video_ops ti_csi2rx_subdev_video_ops = { + .s_stream = ti_csi2rx_sd_s_stream, +}; + +static const struct v4l2_subdev_ops ti_csi2rx_subdev_ops = { + .video = &ti_csi2rx_subdev_video_ops, + .pad = &ti_csi2rx_subdev_pad_ops, +}; + +static const struct v4l2_subdev_internal_ops ti_csi2rx_internal_ops = { + .init_state = ti_csi2rx_sd_init_state, +}; + static void ti_csi2rx_cleanup_dma(struct ti_csi2rx_ctx *ctx) { dma_release_channel(ctx->dma.chan); @@ -936,6 +1071,7 @@ static void ti_csi2rx_cleanup_dma(struct ti_csi2rx_ctx *ctx) static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi) { + v4l2_subdev_cleanup(&csi->subdev); media_device_unregister(&csi->mdev); v4l2_device_unregister(&csi->v4l2_dev); media_device_cleanup(&csi->mdev); @@ -1001,7 +1137,7 @@ static int ti_csi2rx_link_validate(struct media_link *link) const struct ti_csi2rx_fmt *ti_fmt; int ret; - ret = v4l2_subdev_call_state_active(csi->source, pad, + ret = v4l2_subdev_call_state_active(&csi->subdev, pad, get_fmt, &source_fmt); if (ret) return ret; @@ -1046,6 +1182,10 @@ static const struct media_entity_operations ti_csi2rx_video_entity_ops = { .link_validate = ti_csi2rx_link_validate, }; +static const struct media_entity_operations ti_csi2rx_subdev_entity_ops = { + .link_validate = v4l2_subdev_link_validate, +}; + static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *ctx) { struct dma_slave_config cfg = { @@ -1077,7 +1217,8 @@ static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *ctx) static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) { struct media_device *mdev = &csi->mdev; - int ret; + struct v4l2_subdev *sd = &csi->subdev; + int ret, i; mdev->dev = csi->dev; mdev->hw_revision = 1; @@ -1089,16 +1230,50 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) ret = v4l2_device_register(csi->dev, &csi->v4l2_dev); if (ret) - return ret; + goto cleanup_media; ret = media_device_register(mdev); - if (ret) { - v4l2_device_unregister(&csi->v4l2_dev); - media_device_cleanup(mdev); - return ret; - } + if (ret) + goto unregister_v4l2; + + v4l2_subdev_init(sd, &ti_csi2rx_subdev_ops); + sd->internal_ops = &ti_csi2rx_internal_ops; + sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; + sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE; + strscpy(sd->name, dev_name(csi->dev), sizeof(sd->name)); + sd->dev = csi->dev; + sd->entity.ops = &ti_csi2rx_subdev_entity_ops; + + csi->pads[TI_CSI2RX_PAD_SINK].flags = MEDIA_PAD_FL_SINK; + + for (i = TI_CSI2RX_PAD_FIRST_SOURCE; i < TI_CSI2RX_NUM_PADS; i++) + csi->pads[i].flags = MEDIA_PAD_FL_SOURCE; + + ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(csi->pads), + csi->pads); + if (ret) + goto unregister_media; + + ret = v4l2_subdev_init_finalize(sd); + if (ret) + goto unregister_media; + + ret = v4l2_device_register_subdev(&csi->v4l2_dev, sd); + if (ret) + goto cleanup_subdev; return 0; + +cleanup_subdev: + v4l2_subdev_cleanup(sd); +unregister_media: + media_device_unregister(mdev); +unregister_v4l2: + v4l2_device_unregister(&csi->v4l2_dev); +cleanup_media: + media_device_cleanup(mdev); + + return ret; } static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *ctx) @@ -1125,9 +1300,9 @@ static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *ctx) ti_csi2rx_fill_fmt(fmt, &ctx->v_fmt); - csi->pad.flags = MEDIA_PAD_FL_SINK; + ctx->pad.flags = MEDIA_PAD_FL_SINK; vdev->entity.ops = &ti_csi2rx_video_entity_ops; - ret = media_entity_pads_init(&ctx->vdev.entity, 1, &csi->pad); + ret = media_entity_pads_init(&ctx->vdev.entity, 1, &ctx->pad); if (ret) return ret; @@ -1183,6 +1358,8 @@ static int ti_csi2rx_probe(struct platform_device *pdev) if (!csi->drain.vaddr) return -ENOMEM; + mutex_init(&csi->mutex); + ret = ti_csi2rx_v4l2_init(csi); if (ret) goto err_v4l2; @@ -1215,6 +1392,7 @@ static int ti_csi2rx_probe(struct platform_device *pdev) ti_csi2rx_cleanup_ctx(&csi->ctx[i]); err_v4l2: + mutex_destroy(&csi->mutex); dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, csi->drain.paddr); return ret; @@ -1235,6 +1413,7 @@ static int ti_csi2rx_remove(struct platform_device *pdev) ti_csi2rx_cleanup_notifier(csi); ti_csi2rx_cleanup_v4l2(csi); + mutex_destroy(&csi->mutex); dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, csi->drain.paddr); From patchwork Thu Feb 22 11:31:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp189799dyb; Thu, 22 Feb 2024 03:35:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXcIrWF1dmCgqkJJTU5qNF99N5wa/dtjHKw0vo5ylTh1nx7nyq+2IargCrmbSLDwWFVD0aPqI2iM8k2vYofR2DMhNG1Tg== X-Google-Smtp-Source: AGHT+IGqnNyacQbOgOPPrv8G+OEVjbq5ahZYEuWMNuHT94wKy9MdHqzZmQd0fqEdakJ/PgaEKAiy X-Received: by 2002:a17:90a:bb15:b0:299:dd2:47f with SMTP id u21-20020a17090abb1500b002990dd2047fmr16194552pjr.10.1708601749406; Thu, 22 Feb 2024 03:35:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601749; cv=pass; d=google.com; s=arc-20160816; b=U10MQVzfg1e1wmkDwC6nSZxzGyslgxgUQl1Hb/QruZRbtdZlbucSXZFmtz+e9NB6TK JsFg9R6h8q6rAttEI0xTMobOJaj2wN5bzieVUIHIyysu6ft/CsjE/DtnmmfL3qUVGuPB tMn6hwl68n0WVUuL3mmFQRSkBNpQ4m/B33xim412daiG/uXnApR0XEb2mIJLl9GZbX45 JjVIHX63ieb+TjBF5k77TDGh4S2pyNT1FJ9uFrwUuwT3/H/eaOvhEHg1e9y1uNwBlhHK mUTItk0m0155AfFqSqp8+LnFSFcdTx/h6rR5dLPuDyk0NnrAij5rDidsCWenD8CLotuU CuWA== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76418-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fz12-20020a17090b024c00b0029958ab415dsi3111917pjb.190.2024.02.22.03.35.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:35:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76418-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76418-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B4F0E280AB2 for ; Thu, 22 Feb 2024 11:35:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EAC04E1BA; Thu, 22 Feb 2024 11:33:41 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598787604803108 X-GMAIL-MSGID: 1791598787604803108 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; } From patchwork Thu Feb 22 11:31:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp190191dyb; Thu, 22 Feb 2024 03:36:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXeEZYwWHLGGGJPK9K6aEmxnjOu6M6DSbe0qFy8piY47cZ88jKw46Y+zrk39iTihYP6JHMI71sTzHGu2m17yEohjmcNSw== X-Google-Smtp-Source: AGHT+IHqeG6eV6ekrHTGZ/kjWb4EyFCDpqD+EpL0IAGJ2dTCAvrFcj0+b0xlffUoHke/WV7Vq83D X-Received: by 2002:a05:6a20:43ac:b0:1a0:d1cb:5052 with SMTP id i44-20020a056a2043ac00b001a0d1cb5052mr2672212pzl.7.1708601810340; Thu, 22 Feb 2024 03:36:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601810; cv=pass; d=google.com; s=arc-20160816; b=z1JNdHOO+xal4wa7Y0XX6KqGMts2TMILLUVISX7u0HEUIF/2creqtJ0z5h2ogWQTmV MWaeP1N1Kh7o9VuCaO8CUzxFywepyndSCDhOHuIK6pyFkCNCB68knfhDw7TscIGMBIjv EHdM4lAfv2eK/vKY9jfTZJDaR/70x7tjmaVsqkizFE04HvTjYsJRIEW75OckSQ341H0D y1wumrOtpv3KJthbqSIdVYSMxjQ2m5K4DUmYWGtadFzSsvFubzJDnBcCmN+PBQ1jRqJ6 AC13kfx9KHBdbxEbTEeOOAYagG6kcf3yPj2KN02ChowrYkmtFnFCOEFFKtr4Hh+CLXO+ tUlw== 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=EeqeNLJCo+T2og6j8I0EcRbq+KaLZvEdxwzz07GzA3c=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=oK6tQj5ZmJjcnhXkHUYXkLkYwvZWf4ajCdp6kJCQth00oZM11tj9OpVuPzfkI24CqN qexrIB8bE0azsCFfgS7t/A628FRlwse4fiI1NrgYO1SusEdTqljxrD2yBpv/qUj8S0gu rRqR3Gzo/azbwDOqJRzhUB9Ika7P+t/5cwZLUGxJlaYF2Mn2AuGaToGG6+c/KZ7sqZvf lK/V/1HEMysXQWGyKyuhIzy9wJAdoNzao03iyYIfTFJ/6riHDZ7x+fn2GQlOkj+T2njP DN8a+gB8NzPHTYahNNaVDgUMh+B1KGcmoAgUXxP+DnEGh8qckSEoAicYCrjycchZqt7T fsMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hA7x9eCu; 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-76424-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76424-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j20-20020a056a00235400b006e48649bbe3si4158320pfj.343.2024.02.22.03.36.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:36:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76424-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hA7x9eCu; 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-76424-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76424-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 14A26280C4E for ; Thu, 22 Feb 2024 11:36:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EBA951031; Thu, 22 Feb 2024 11:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="hA7x9eCu" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 641B04CB47; Thu, 22 Feb 2024 11:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601620; cv=none; b=DNYXidQm5qkRy4BwD3KyVQOCtAG1FQ0O0GZ/nVIovo4RJ2C++lfLbvvdmZfV4C597Vmzfl249r0kpuaHruGYRdFMLerNbBfaY+bviArC9WPd6Dwe2uumN4yceA107QWClPaHJzhtWegMctDT9P7dUbdBnjWk7NU5uKwmw0PO+yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601620; c=relaxed/simple; bh=IJkveWM6BGN6FdJe2ONhxr2YmPcTsQQBqQhGtpl3Y/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=NJmbiVVBvLEnOyekZeL3XqkkM4DOf4RXRGcB8aMUlgtom2Ja8livSdbFDkVqZmK4z5VB5Qormqg5n7zHcpEGHuGB+n7duP9Uxsk6htJPu7TfOVWthHc8to+7Mt2jQgFv3nRDTKRUrucfpg8bZJoOhFnBS25/ZFGajzaZUyRTE78= 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=hA7x9eCu; arc=none smtp.client-ip=198.47.23.248 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXPNU018069; Thu, 22 Feb 2024 05:33:25 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601605; bh=EeqeNLJCo+T2og6j8I0EcRbq+KaLZvEdxwzz07GzA3c=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=hA7x9eCu5xFogOE9XphtBoCRguY2G3CL4ezXXgbv6lqB5i/AUSq4hWRtbKytyPzle v5PxgLQ7h+T/v0F24Ss8MNDDPHK3osy79xMjqvBaXfpI1c4+HZvAqw5/F8wqDBy8F3 I5dl893+EVrtB1kfIxEgnn5v4lAguSGCtHU/xQ48= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXPL6057238 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:25 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) 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:24 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE107.ent.ti.com (157.170.170.37) 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:24 -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 41MBXNla091279; Thu, 22 Feb 2024 05:33:24 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:26 +0530 Subject: [PATCH RFC 10/21] media: ti: j721e-csi2rx: get number of contexts from device tree Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-10-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=4858; i=j-luthra@ti.com; h=from:subject:message-id; bh=kxUrddGc08+EUx2GSspOKVpHM0K4NnSviF9UJ67LSDI=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDj2oBGiQHvwcIQqe0aQL4C4Gy6R1o7Gwp2p wNerGedfQaJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw4wAKCRBD3pH5JJpx Rf13D/9d1JbYOzqd6/JpppkxEah4e41VjPtb6gOk9G16KLVPUYwxXGgs2woXe+ry2fZJpqp4V5d pNUgV7YwCGoaDuqjWRiAlRr1NG6YLTPXwD7d2g0XxAflFd5nP+03gaZT7Qe9uQ67TkOopm6VwPL GlEaH3TOGt8VAVy34aE2onaQqWYoj+dFZoScbxhMW0BYGxx9XYPPbDhTn/+/3k4BaMbU2tqP9iY 2AO79qzjVvNLAvwYfVBPw+MLwGkokv5PKmgsyvNAXLqeTYU8bYrds81OzIf+40WLYUPqjnNXKKm c5xF0zygAh3Vb2nh70GXKY79mQ8ylmo6JfXdUdphA108YibdJ4kV0YvPuIwwfM6uSrjSkEC7STR B6A6h6H7sGzTtqhr6hGQf0oabu6zRn3fI3d4BT9kYjIIefnWayIMvyWvId4yKY05N5RU3g14tiY fWyyMb9I6BGXoCCx/NnLP3VsSX0+93sojC4gnEE0kgWksHCX4+IXgOEU43c1GQ3iQa9ipoPTTsQ Q9+67GQ0HBKNjWD58UJ1LDLFD7yU1Jzx1yZsnaTsw8CciUDdZQ4wpc1FwjDdrhgZUe3E+0nInhy L2HH5r/dltEmxyeBGXZzJ8z4doZUElJR+uDekxH8tX6KHhtssRtMi32xgxdb663qofEzVMorLRZ ZgVgTszaKoyvL7Q== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598851477229552 X-GMAIL-MSGID: 1791598851477229552 From: Pratyush Yadav Different platforms that use this driver might have different number of DMA channels allocated for CSI. So only as many DMA contexts can be used as the number of DMA channels available. Get the number of channels provided via device tree and only configure that many contexts, and hence only that many pads. Signed-off-by: Pratyush Yadav Co-developed-by: Jai Luthra Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 44 ++++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 1443338f4134..f6045888eed0 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -40,7 +40,7 @@ #define SHIM_PSI_CFG0_DST_TAG GENMASK(31, 16) #define PSIL_WORD_SIZE_BYTES 16 -#define TI_CSI2RX_NUM_CTX 1 +#define TI_CSI2RX_MAX_CTX 32 /* * There are no hard limits on the width or height. The DMA engine can handle @@ -53,8 +53,8 @@ #define TI_CSI2RX_PAD_SINK 0 #define TI_CSI2RX_PAD_FIRST_SOURCE 1 -#define TI_CSI2RX_NUM_SOURCE_PADS 1 -#define TI_CSI2RX_NUM_PADS (1 + TI_CSI2RX_NUM_SOURCE_PADS) +#define TI_CSI2RX_MAX_SOURCE_PADS TI_CSI2RX_MAX_CTX +#define TI_CSI2RX_MAX_PADS (1 + TI_CSI2RX_MAX_SOURCE_PADS) #define DRAIN_TIMEOUT_MS 50 #define DRAIN_BUFFER_SIZE SZ_32K @@ -112,14 +112,15 @@ struct ti_csi2rx_dev { void __iomem *shim; struct mutex mutex; /* To serialize ioctls. */ unsigned int enable_count; + unsigned int num_ctx; struct v4l2_device v4l2_dev; struct media_device mdev; struct media_pipeline pipe; - struct media_pad pads[TI_CSI2RX_NUM_PADS]; + struct media_pad pads[TI_CSI2RX_MAX_PADS]; struct v4l2_async_notifier notifier; struct v4l2_subdev *source; struct v4l2_subdev subdev; - struct ti_csi2rx_ctx ctx[TI_CSI2RX_NUM_CTX]; + struct ti_csi2rx_ctx ctx[TI_CSI2RX_MAX_CTX]; /* Buffer to drain stale data from PSI-L endpoint */ struct { void *vaddr; @@ -473,7 +474,7 @@ static int csi_async_notifier_complete(struct v4l2_async_notifier *notifier) return ret; /* Create and link video nodes for all DMA contexts */ - for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) { + for (i = 0; i < csi->num_ctx; i++) { struct ti_csi2rx_ctx *ctx = &csi->ctx[i]; struct video_device *vdev = &ctx->vdev; @@ -1255,10 +1256,12 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) csi->pads[TI_CSI2RX_PAD_SINK].flags = MEDIA_PAD_FL_SINK; - for (i = TI_CSI2RX_PAD_FIRST_SOURCE; i < TI_CSI2RX_NUM_PADS; i++) + for (i = TI_CSI2RX_PAD_FIRST_SOURCE; + i < TI_CSI2RX_PAD_FIRST_SOURCE + csi->num_ctx; i++) csi->pads[i].flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(csi->pads), + ret = media_entity_pads_init(&sd->entity, + TI_CSI2RX_PAD_FIRST_SOURCE + csi->num_ctx, csi->pads); if (ret) goto unregister_media; @@ -1344,8 +1347,9 @@ static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *ctx) static int ti_csi2rx_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct ti_csi2rx_dev *csi; - int ret, i; + int ret, i, count; csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); if (!csi) @@ -1367,13 +1371,29 @@ static int ti_csi2rx_probe(struct platform_device *pdev) if (!csi->drain.vaddr) return -ENOMEM; + /* Only use as many contexts as the number of DMA channels allocated. */ + count = of_property_count_strings(np, "dma-names"); + if (count < 0) { + dev_err(csi->dev, "Failed to get DMA channel count: %d\n", + count); + return count; + } + + csi->num_ctx = count; + if (csi->num_ctx > TI_CSI2RX_MAX_CTX) { + dev_warn(csi->dev, + "%u DMA channels passed. Maximum is %u. Ignoring the rest.\n", + csi->num_ctx, TI_CSI2RX_MAX_CTX); + csi->num_ctx = TI_CSI2RX_MAX_CTX; + } + mutex_init(&csi->mutex); ret = ti_csi2rx_v4l2_init(csi); if (ret) goto err_v4l2; - for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) { + for (i = 0; i < csi->num_ctx; i++) { csi->ctx[i].idx = i; csi->ctx[i].csi = csi; ret = ti_csi2rx_init_ctx(&csi->ctx[i]); @@ -1412,12 +1432,12 @@ static int ti_csi2rx_remove(struct platform_device *pdev) struct ti_csi2rx_dev *csi = platform_get_drvdata(pdev); int i; - for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) { + for (i = 0; i < csi->num_ctx; i++) { if (vb2_is_busy(&csi->ctx[i].vidq)) return -EBUSY; } - for (i = 0; i < TI_CSI2RX_NUM_CTX; i++) + for (i = 0; i < csi->num_ctx; i++) ti_csi2rx_cleanup_ctx(&csi->ctx[i]); ti_csi2rx_cleanup_notifier(csi); From patchwork Thu Feb 22 11:31:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp190155dyb; Thu, 22 Feb 2024 03:36:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLTxigFyRBlko9ty7yjka3Pi7vrPglA/oMPQLlNxUqTRsLH8Z4L42NZTs78Bmlk1SzIZWuMBnSY5PFbtWmrAYGRry5Gw== X-Google-Smtp-Source: AGHT+IEPWSC/jgKltNEZCCBUP6gmZZAvM7hxzJux1RBQqtWuuR4TICUk2QBlMg2gXHSb8JQA0rXq X-Received: by 2002:a1f:dbc2:0:b0:4c8:16fc:615 with SMTP id s185-20020a1fdbc2000000b004c816fc0615mr10692150vkg.8.1708601804583; Thu, 22 Feb 2024 03:36:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601804; cv=pass; d=google.com; s=arc-20160816; b=CZ6Z1RuOdvZ43FJH+2d1I52IUZOBVnra0D5TJ9XbqJnNggt5JijJIDuVryv/TmzdZx Vg8Aw7cjyFZ/ed7MuBooH3EtM8Scj7GLXqF471iUw8BL5/7pQVSUjMb/BKijtKivPhOJ egMB+Cj3xASeQ7eZsWUtsQqcaAOlA7L/UmYI+ngEHyBEcFrzS2ian0O939mvGwY/88+E kNUeU700xkveK5LiW/pn+P/nQuzdxh7iTxvDDXCUxpiebRJpVuGtUZBDZoJA1MrPINI9 VL+rQs2oYKRKKyIvu32f7WpwfXLI+SOLBFPs6zMLGCV4Eo8hFQggDk1ZsqpbPhCxvP+J 0OKA== 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=D1JcLO4nEUWK7guThesjK1pDOn36eFgs8+2V3wttK6k=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=WziGINmcv6gSQRdTiEij4vxkY3gDCy+Z7Y3CTpaAhytplTXoYvc3nuzqnK62eFdzJH ViqLPQaoyBPMGBC3Qx7inRanAQOar6HidhiTn1HiOqtzZzBdkxBbJ/eENXhbG/2d8ors NYOoqBlJYJodke41calobfXTinuNqIT8KEDua85S/Ss/wN1sabHi2UrJuv/qRMolG0w9 /Yac75wN5SPLVy50MfDyHmYVnYKYkyn9oy7mspY2cQJoXetEfGMZza4lNqVRvDJ4xpdp 0P623yHzyMTWPwn/dERhaMECrG5KGI3XX+bnxA9pMvM60EqVxBQFlTTZQqK4zbOl5eaB zDFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CYmtYY5x; 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-76425-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76425-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id kd19-20020a056214401300b0068fcd33c8d7si26025qvb.91.2024.02.22.03.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:36:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76425-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CYmtYY5x; 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-76425-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76425-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4DA7A1C2103E for ; Thu, 22 Feb 2024 11:36:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D50450A80; Thu, 22 Feb 2024 11:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="CYmtYY5x" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 AC2B44D5A5; Thu, 22 Feb 2024 11:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601621; cv=none; b=DFD40M4O3gjBAibccWAEf0oHkyObO4X4hRNWSUtcDg5xDx+KCSznxXD1j+1aIVxeTSDS7+Yo5opMV2MC/WBw3wrY9C/5pcio/tKBttbesaN+IPIH2gYaQufFb3EKbm0DxvUScLmMVWU2R7kICG8E2WTTJSgRb5HfrAAh6r3ZR1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601621; c=relaxed/simple; bh=OAFyGIfI4QNtZqZsii8PfuhldKXwI8qlEf3a30bhc4U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=cgbydQEWtel6lBNiwY6asafaVIngrXiUM8buFSVePh3Xfsdb8tX8xOzdBWjhK+KQnsX0HgzXX/SwzGyNStS5F4VyVtE00OzWLnaDPO4mkt0M1IgVNu7g+KlWk2Wp6ni3ferRqZW0+HUEZKMm/mvt9UyNy47E6YaJtIp3DV48cSM= 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=CYmtYY5x; arc=none smtp.client-ip=198.47.23.248 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 lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXRN6018078; Thu, 22 Feb 2024 05:33:27 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601607; bh=D1JcLO4nEUWK7guThesjK1pDOn36eFgs8+2V3wttK6k=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=CYmtYY5xhJEpgeHqjK8iEU5EeODd4qC7hDav5rv5m2zpcEUtCBC4xwy24wkEEoI6Q Id3pkVxl3WM3kj7uVm4DxDKMe7OmRrgtWj7C4IMO1hTABE6FLjLuRFRle4ITsJRUTV Ffi3ysN0biuDFLy4FY2YIzjlm8v//r1bBBE05qZ8= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXQG3059446 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:27 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE104.ent.ti.com (10.64.6.25) 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:26 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE100.ent.ti.com (10.64.6.21) 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:26 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXPTo128738; Thu, 22 Feb 2024 05:33:26 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:27 +0530 Subject: [PATCH RFC 11/21] media: cadence: csi2rx: add get_frame_desc wrapper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-11-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=2073; i=j-luthra@ti.com; h=from:subject:message-id; bh=UVjvXFZDdMcwPLK95L3EAt34fnv5iTWXgWYHYS6GVzQ=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDkR+ssg4gl30zSyVASKScmFXRmSLcX+zSte ZSKKYCvG+GJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw5AAKCRBD3pH5JJpx Rd1/EADDcvgw+Hz3E/hhe2SkvFpelMMmoxA0L9R4N5mHIxG4qikx7Nyt+T3bYcs3EK49nj1kD2r xfvbGT465MFEjXz3P6Uc/nRHQhuqGB8VpaEtQrlsmCw8jVr/VkDuKeN81CxhizFb/ZFzFuN6yfL UzvTYYKVae8EhsYYNVOUO0qat20bpviP6nbRYa9czF7ikD7Lzr3q3RWU4vGd6bqu///pLBub5Jz r5Aud8Xv4gbY+V75rJoQS6Eyo2y2rfvzpb7YfK/PvCE5djeM5f2h0WIRAq7Y/PGTYnTdXIfaWAp a4XmXNCnAM3r3oIySGHBTd4qS1ossYBgYyjh3/2w5lRa1b3rkxL6/KG6sjpHfyJLRjXkqDV4QO1 WJ2r9HMdXGXU8Y4UToBrKL/pM8qopVs5vhHgiLP1NVh96UQ9T376ogJue/p+gfJbsyPcqd++AfH 9LllgBiJPuwkU0I34FhF6OAPdyuuLzJEMppadUvFhVMALWeOok0icDKKoAdVYUBCPmfV+9srtZF X1CzfinQEnk5E9CaK1fjTqc4k7XJD0z4N+Ow8jwrB61SRsUChMTIpX7+qQBrWJW7xYKlRNhAXM8 SeEFfDCy9qDjCIF7MIBD+JmTVFqyxlN0DURi27wBL91GOW7uSK7ly/OJOA4hRaK2FjoysNDt435 LD8ObJXdme665Rw== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598845681985020 X-GMAIL-MSGID: 1791598845681985020 From: Pratyush Yadav J721E wrapper CSI2RX driver needs to get the frame descriptor from the source to find out info about virtual channel. This driver itself does not touch the routing or virtual channels in any way. So simply pass the descriptor through from the source. Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index e19993ed351c..989924dba9a9 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -139,6 +139,21 @@ static const struct csi2rx_fmt *csi2rx_get_fmt_by_code(u32 code) return NULL; } +static int csi2rx_get_frame_desc_from_source(struct csi2rx_priv *csi2rx, + struct v4l2_mbus_frame_desc *fd) +{ + struct media_pad *remote_pad; + + remote_pad = media_entity_remote_source_pad_unique(&csi2rx->subdev.entity); + if (!remote_pad) { + dev_err(csi2rx->dev, "No remote pad found for sink\n"); + return -ENODEV; + } + + return v4l2_subdev_call(csi2rx->source_subdev, pad, get_frame_desc, + remote_pad->index, fd); +} + static inline struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev) { @@ -470,10 +485,19 @@ static int csi2rx_init_state(struct v4l2_subdev *subdev, return csi2rx_set_fmt(subdev, state, &format); } +static int csi2rx_get_frame_desc(struct v4l2_subdev *subdev, unsigned int pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); + + return csi2rx_get_frame_desc_from_source(csi2rx, fd); +} + static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = { .enum_mbus_code = csi2rx_enum_mbus_code, .get_fmt = v4l2_subdev_get_fmt, .set_fmt = csi2rx_set_fmt, + .get_frame_desc = csi2rx_get_frame_desc, }; static const struct v4l2_subdev_video_ops csi2rx_video_ops = { From patchwork Thu Feb 22 11:31:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp194565dyb; Thu, 22 Feb 2024 03:46:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUw3wK0ja7SBpoJ8n0RDqkZ4ISB6/xglnU1A/JEx6uSJEiiJzWJszELGwmXrYrEZlT6mjcqS2OSsrPUSY4QHCjU49uD5A== X-Google-Smtp-Source: AGHT+IGnUuf5woNAMjD0gUV5SPBGweD0Km3fwpE+Bm7tMftgGj6Ld242kisFqRzb5esvr1dxQ9EM X-Received: by 2002:aa7:d78d:0:b0:565:4bcf:d89f with SMTP id s13-20020aa7d78d000000b005654bcfd89fmr354077edq.8.1708602390658; Thu, 22 Feb 2024 03:46:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602390; cv=pass; d=google.com; s=arc-20160816; b=sAKjx9c15nX6CQ5dORT+Qt/iuyLA1XGy/XVspcT8GuhxyxXwLIWuzA/KSHmjxdh0UH fdpMt9hEd8r7GyJ6ITZxYU/Xe1mnoRAwU/3WcT7a/o8tFiUV0bEm3Wr8GJP/s3Lj1STl l7dZN/FAyhjWsEYw5QOZTd4yrM7nNFjiJtT0ujzS4WL5IYOIrb5YtQ4CMzHIye7PLC5D /9w6ubt1dM5Mwuxek6h4XOdd5LJgSQXtOg6ZA6oQ1RM7ZqfTekAxfPRvR+Ak1nK73t8W 7jBcSTitDSOshmBJlG4UbowL6rG9zDB+LmIID7s0tm1xj88NMj0d/oOA1OBHL6mgz9Uc QhXQ== 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=a6u0dz7gnMTNjGZgYfZ5DagZDymNpTJ3M4uXSorQvAI=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=Ey+5tJDsztm4B4QQ4PIKs6YyRXhNtJ/LFhzjfINORB2Xq2j/cKNBgY7VUV6Kmwpjex rmswfWZ4ybCSH7sWT3sGIcfoy1kyDVkPDf9Dhwxt5bv7itX+NAzJNQ006fUS7sOumUjm wNB+vtyvURCyMCxJ7EIJRwa4FCsTvEpuSiI09HnWsGLh2kTIgflCVbpUhhqAI/nVeeHy MwmQPW7/POvVK76l0KdJ89+f5hv2IPH0BywFZxMn49Oep2ymDtUCKc1C2VjJGHiT2UKM CKwBrXuEFKi66VBzZuoLxSW0W9CzpZxuN7LuByObC/m/IOqthPXh/jvdSryNgQmVUiMn D66w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xvc2EISI; 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-76428-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76428-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g8-20020aa7d1c8000000b00563a116e665si5199097edp.282.2024.02.22.03.46.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:46:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76428-ouuuleilei=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=xvc2EISI; 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-76428-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76428-ouuuleilei=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 A8D681F28370 for ; Thu, 22 Feb 2024 11:37:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CA4453814; Thu, 22 Feb 2024 11:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="xvc2EISI" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 9599F4F8AB; Thu, 22 Feb 2024 11:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601626; cv=none; b=o/uWHpbomxqb9MDkg16vXjj1dJnJ0wAq8Ib/Rt4TAkXeQ6WXqVTi9LgtJd4EbdnIM7nKeg6/SdjPChvi9ghzeb73ErlYefj0ilDxhZuN6FnrQ1+c7LYteufVm43oGt4uIQbo2GKEIz+i8GSwQOdFyqXL1d3o8FpV47jdegocvVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601626; c=relaxed/simple; bh=zIYkGYnREr2zzxvatff2YEHLJNp39GM3nN7mI+RemYU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=FsQY6msa5zsP2T30SW/Ejh5tuqtBL6OSUdiL/K/1iJ1YeCuyIMpxqTnz+XkBT8obpx1DEQMg5mvyP8pluu1Oe+23UEGw9HLwq5Oqcg92JWVKpOY5xv+QGG9me+desdAPkrmv6xqXuyuJsPnQn8TnW9/0Ly7c0o6Sd/DH0ah76p4= 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=xvc2EISI; arc=none smtp.client-ip=198.47.23.249 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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXTGS112348; Thu, 22 Feb 2024 05:33:29 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601609; bh=a6u0dz7gnMTNjGZgYfZ5DagZDymNpTJ3M4uXSorQvAI=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=xvc2EISI80L264m4N2znCp3A/oYtzuBcqiipOacZWRpcpsIN7rpFOx1GVtOtjeC/u h18f9gCpd1smoAbX7q9HVhfNRoyHbDkDvezkMj4/Mvwcd9j6NbNl/cbJXahUianto9 0VgdGgjxjqB7Qcl5XAuY5Bpw0fwPZSK1J7ZfQYpU= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXScO007723 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:29 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE112.ent.ti.com (10.64.6.33) 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:28 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE100.ent.ti.com (10.64.6.21) 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:28 -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 41MBXR4H091345; Thu, 22 Feb 2024 05:33:27 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:28 +0530 Subject: [PATCH RFC 12/21] media: ti: j721e-csi2rx: add support for processing virtual channels Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-12-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=2874; i=j-luthra@ti.com; h=from:subject:message-id; bh=zIYkGYnREr2zzxvatff2YEHLJNp39GM3nN7mI+RemYU=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDlbvmJ1PmuUHzer1GkCJIG2CYbiEmT4z5Td O1M2a8KaMaJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw5QAKCRBD3pH5JJpx Rer/D/49xcRPEH/+G2XwYPjXH3qi31OHduruGlQu7oDxKSUZjUEaTUuQlLaVYEThPnpT+XXrrrm W0dbsgL/8AmeAHD4C7shTgoGbBwPmpUJaY+6Xq/dSWKXLKC6zymSjWsSUennxEbCc8aaHuOcSQP v/g8mmR8RZu8LTOsqQVC1BSMuRJLhmihG6b4ijRhPV+ovMYgwMBsAxHEEBfNaTWl0YAjPTB+FJl qEaxjoSnXQ0e/gyh77ywfi+WogcX7DojMjEaT9VKuiVYqnSbwMprmd2HneO93Ib+24hR+omqRnW T71QFFQC3TIoewJp9AoE36mq6Lmhes7oj/LZ597cxD57R8fs4WSo3DvPbx9wWbEdm6tETpFc4Ly iBxJTrbkTdwctXlEkjTsclaG87/VomivJbtJDVeMe5rggId+cvYZPeCqd6wv4us1F6HwDsDyJHM KhuESWYbcZeipK8y1Twh9zCcgtwgJvRdfMf3kOp6oHUsON1W5Iss0RvCoU9aNyTG0uVHwh48Gcv rDsw9FKZPRgY8IuNPrmt3EDNFnqhM790peE2PZ7sEQaBoYMBJkJfeCs7CLRTJyeOG+ySUI8fyxe 1mfwCNqQt1za8F8nbHKPWshx/7/cVmHcHg+R+iSIl06+HBiF4lSKYIg3O+bGedOA8NVZReRao9X YtAbIl1jxAWmWOQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599460533816985 X-GMAIL-MSGID: 1791599460533816985 Use get_frame_desc() to get the frame desc from the connected source, and use the provided virtual channel instead of hardcoded one. get_frame_desc() works per stream, but as we don't support multiple streams yet, we will just always use stream 0. If the source doesn't support get_frame_desc(), fall back to the previous method of always capturing virtual channel 0. Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index f6045888eed0..4be8a306ac1f 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -29,6 +29,7 @@ #define SHIM_DMACNTX_EN BIT(31) #define SHIM_DMACNTX_YUV422 GENMASK(27, 26) #define SHIM_DMACNTX_SIZE GENMASK(21, 20) +#define SHIM_DMACNTX_VC GENMASK(9, 6) #define SHIM_DMACNTX_FMT GENMASK(5, 0) #define SHIM_DMACNTX_YUV422_MODE_11 3 #define SHIM_DMACNTX_SIZE_8 0 @@ -105,6 +106,8 @@ struct ti_csi2rx_ctx { struct media_pad pad; u32 sequence; u32 idx; + u32 vc; + u32 stream; }; struct ti_csi2rx_dev { @@ -595,6 +598,7 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *ctx) } reg |= FIELD_PREP(SHIM_DMACNTX_SIZE, fmt->size); + reg |= FIELD_PREP(SHIM_DMACNTX_VC, ctx->vc); writel(reg, csi->shim + SHIM_DMACNTX(ctx->idx)); @@ -868,6 +872,33 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb) } } +static int ti_csi2rx_get_vc(struct ti_csi2rx_ctx *ctx) +{ + struct ti_csi2rx_dev *csi = ctx->csi; + struct v4l2_mbus_frame_desc fd; + struct media_pad *pad; + int ret, i; + + pad = media_entity_remote_pad_unique(&csi->subdev.entity, MEDIA_PAD_FL_SOURCE); + if (!pad) + return -ENODEV; + + ret = v4l2_subdev_call(csi->source, pad, get_frame_desc, pad->index, + &fd); + if (ret) + return ret; + + if (fd.type != V4L2_MBUS_FRAME_DESC_TYPE_CSI2) + return -EINVAL; + + for (i = 0; i < fd.num_entries; i++) { + if (ctx->stream == fd.entry[i].stream) + return fd.entry[i].bus.csi2.vc; + } + + return -ENODEV; +} + static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) { struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vq); @@ -888,6 +919,14 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) if (ret) goto err; + ret = ti_csi2rx_get_vc(ctx); + if (ret == -ENOIOCTLCMD) + ctx->vc = 0; + else if (ret < 0) + goto err; + else + ctx->vc = ret; + ti_csi2rx_setup_shim(ctx); ctx->sequence = 0; From patchwork Thu Feb 22 11:31:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp190442dyb; Thu, 22 Feb 2024 03:37:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUoIazGOZgCFhMb8LeajBSmQtnZdi+edqtkkQ4v1smSn8lOqn1aQVKo6MCpRJ9FFVCj7YQVNiJwnxcXV8mkricxxdxFAg== X-Google-Smtp-Source: AGHT+IH6IOt73YBlQ3DqWCh2qExz0804LWIG2JFzN0LLHrPGIKVcvJiUbYVZkGf6bkLNN670+cYv X-Received: by 2002:a0c:dc88:0:b0:68f:47e2:c617 with SMTP id n8-20020a0cdc88000000b0068f47e2c617mr15668919qvk.36.1708601843544; Thu, 22 Feb 2024 03:37:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601843; cv=pass; d=google.com; s=arc-20160816; b=y8dTw4WKQEsSuODhyXDDfwU99i9cQN2EHimdJhFLlv8AC6Dr32h25rGwgzW+B5udWp 8EiFcwQA8u9JWPOnbyYKXyl7LHnVTAAk59sbmUfCFEHlQyyrRZlS+odgVwi5cDuHKRhH k3mSUW7Fl42dXLn5o9grakEEm93aDon6AtXyoN5eJhNo3QBT5YBxE16SlkpS5McwGq73 xB/otHNDJmztcyWNcYAzCu7R6OdsQrSsSDvXL9WAqpdfef89YjHm4Tqr7vWsbxNLIB+B mAgVKQQgHLGBNgXtjauhogGs4aXUG3m68HIVVgc8ipxlnXxQsJ2fqVcTi57Xezu41hT7 WKGQ== 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=IIFOD7uZml1cZMulax2MAWAdhtL2PDteL/pS7c8c1vg=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=xg/Eb/BKAiLtmpzfZmfQIeJ/AjBVFF+8FH6ZmrKFuB71NAG2N2zxxQXkc47XnvNuWy FU4XXewNHy2rVoXz2mg0vp20gBKX5wLZsQwrWBsDvpMWoMEe9McT/n+nsX57eERVAeVV 7TYITE653UqDSAFI4L2CiH0ORBkrmnE0+h950KIo9V5EZ6FNk3d9FhDWWROF3Uma6or8 WmOU3LK/vPBEVqwU9d64/0HL5XkA2RWrMmhAs/9OybHEqyH5HH6Gck8g7crQ5oqo93g1 cZl13FnnmuBRLkKVI+hJBcOkHMB9wegECTpQgEB4zP8OWzcmSjG3i3wGmdxzJad2a+Nj m0jA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BmrmLF48; 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-76426-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76426-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r4-20020a0562140c4400b0068fbd79ccfcsi878164qvj.139.2024.02.22.03.37.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:37:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76426-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BmrmLF48; 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-76426-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76426-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 955A21C2251A for ; Thu, 22 Feb 2024 11:37:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBBF7535C2; Thu, 22 Feb 2024 11:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BmrmLF48" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 EFB8E4F211; Thu, 22 Feb 2024 11:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601624; cv=none; b=si0rI4W/YO5l2MInnY++S2j5FTmVZktCZ6bOW6+9gG4BI66KMKdtg91+VKrK6psaHG0muJCJi/xYRNccmSXWYI5KmPwB+BCsqTP/u+eOqeO6jNFuU3iOzRDd5p+6AEIEpXHKbQpztx+lVK1gkD09513TgMvIkLywtzFfAq2pwkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601624; c=relaxed/simple; bh=Na3FxDoFmJwKP2/Z+thurEhYoJ1q8QJrM9yU72Ifm1A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=D62ht26OeX17n7Unh3tsWurhQZ9HfCqiDzD4OnZgHfrIWNlcJOXNqTcXI5j7Q6q2neL2t8PG/PKgZSsW62sTM+GZVg7+/JQK9ma1LWVAu3xlx4qd4VdImnaPmyJ8UkdOR4u7IODWFndvCE7EK8kkTbaEunf7UOxH5GSosATHNhg= 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=BmrmLF48; arc=none smtp.client-ip=198.47.23.248 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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXUlt018090; Thu, 22 Feb 2024 05:33:30 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601610; bh=IIFOD7uZml1cZMulax2MAWAdhtL2PDteL/pS7c8c1vg=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=BmrmLF48vcqVdT/ofpJwNIkxU+/ZO2A9IQIBp/tyiyidCR8PIPoeQ32ThbUtZKc40 QnLjJ3rYGNGcDsdYByOMZeL7L1jlj/pCF/RXP+8e8VSUNzz6LYYysqzorkjPoBU/0j SHJ3FYLBRL6X4Ef4ec28CMGn4r8G7YTvv5pXxqnU= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXUYo007860 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:30 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE115.ent.ti.com (157.170.170.26) 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:30 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE106.ent.ti.com (157.170.170.36) 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:30 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXTYO128794; Thu, 22 Feb 2024 05:33:29 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:29 +0530 Subject: [PATCH RFC 13/21] media: cadence: csi2rx: Use new enable stream APIs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-13-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=2442; i=j-luthra@ti.com; h=from:subject:message-id; bh=Na3FxDoFmJwKP2/Z+thurEhYoJ1q8QJrM9yU72Ifm1A=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDm2nXX6+ZXmetmJ7ki72+WsjqiulUvHkFgP 7xWNQ1geB2JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw5gAKCRBD3pH5JJpx RcT2D/4rgzQuq3zQkIoE4qSuyAw/GfQ5cFCro98zAa2VhMJO/n0wTwFbWUo/VPzWURWzKXhjpzp 5xD0K2Qqbos8K2JkTF03EiQopJQqmW9wc90Nm2tLAS3YV5ew6dQZEzozANRhAwno18bgLsEPLwU rsUJiTq5QXoPXsr1P69BaQTb4eK3WrQxZ2XUrX0oSkKu3TUjSRIPDgzz0wt/UqI75waW1dE43mK Z1ieDwTK5LsoAk+zx5/zP4ci7mz1sz+uDkKPF+DidedAvnExGYEL/W+La5118U0FZASGrWpn2WA ttIyVbXuBzwVnZVlfTp1p1vEPZtrZKdRAaeMUGMlukh7TY++9dy8KsYQZtvAAXzPj7Vf3BXollu YdzGgDiKLi+CFkmEyi5SpBMvVv1NQM0ofoPcRDXBE/47iJXSCETF2ZlDx3VGMOOOkt70paChXCO wyZQWr8Y+9i0d90C0rEuXc8G6Sizeib/kf/qlgbYH6/E9m+9+vzCrAueicMQ78peTk6iQaSy8vj 6aKF6WZUcm5Kt4STi1kItSQkFWGGe4h5BumBZhIDGpEcyAU4evBkWFB0/K5ORhRI+9luCOKvI15 f1m0fFtFMC3UzXHjYfUDBNRNKSi2XMDuxqzAsQniShysnw4bnANlpoZtGlBjUm4mc3cWmxJjTdP 8Oa6AczAV9QRhiQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598886581740386 X-GMAIL-MSGID: 1791598886581740386 The enable_streams() API in v4l2 supports passing a bitmask to enable each pad/stream combination individually on any media subdev instead of doing s_stream(1) to start all streams on the subdev at once. This API is implemented by ds90ub960 driver (FPDLink deser) and thus the caller (cdns-csi2x) is required to use it. For now we only enable stream0. Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 989924dba9a9..bac341881e41 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -226,10 +226,18 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) static int csi2rx_start(struct csi2rx_priv *csi2rx) { unsigned int i; + struct media_pad *remote_pad; unsigned long lanes_used = 0; u32 reg; int ret; + remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); + if (!remote_pad) { + dev_err(csi2rx->dev, + "Failed to find connected source\n"); + return -ENODEV; + } + ret = clk_prepare_enable(csi2rx->p_clk); if (ret) return ret; @@ -313,7 +321,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) reset_control_deassert(csi2rx->sys_rst); - ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); + ret = v4l2_subdev_enable_streams(csi2rx->source_subdev, + remote_pad->index, BIT(0)); if (ret) goto err_disable_sysclk; @@ -341,6 +350,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) static void csi2rx_stop(struct csi2rx_priv *csi2rx) { + struct media_pad *remote_pad; unsigned int i; u32 val; int ret; @@ -369,8 +379,12 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) reset_control_assert(csi2rx->p_rst); clk_disable_unprepare(csi2rx->p_clk); - if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false)) + remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); + if (!remote_pad || + v4l2_subdev_disable_streams(csi2rx->source_subdev, + remote_pad->index, BIT(0))) { dev_warn(csi2rx->dev, "Couldn't disable our subdev\n"); + } if (csi2rx->dphy) { writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); From patchwork Thu Feb 22 11:31:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp190603dyb; Thu, 22 Feb 2024 03:37:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWUIZeNcQWTi/6vwsUl+LFDTkOUH+e5mcV325PzMSvLWl4jERsV7nO9gpKaQxawg4IL1iUNqERzq/fFolEArkI44z3mVw== X-Google-Smtp-Source: AGHT+IF2x9a/41Ipj4QhLVaNy3wRnHQOpBBlmN4Q05dMLOgbTSZ5DT11qDkRFTn1ntuCf/hjgOKA X-Received: by 2002:ac8:5702:0:b0:42d:d57f:2ac5 with SMTP id 2-20020ac85702000000b0042dd57f2ac5mr26010248qtw.44.1708601866540; Thu, 22 Feb 2024 03:37:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601866; cv=pass; d=google.com; s=arc-20160816; b=iO6ZLic6YGFjv0XXFqSx0tcQkRXd0I9XE16h/pj4B5mtMCJGGcmSFdnkPvkkqdDgN6 pCeePhyAre7cML+4iclFUoSXEnH9iKF5SxiSLuNnNhVUF4rGlObRbgZtHteGJoT2GWfq +PGrJl57bWFNX2CpUuvdZW1hVa5z2n4I0hqX4xea/g/bix9ED91XwjJq8CLmxNZfUke2 6eK77OXFGy8oBIK8kFe2HKpAnNPIN64U+SIGPKGHA3iBigRHppX/kc9RHcQ0x+ZD9DyG K9H5mxKA8AWWiLsMOGcccju65OFL1lk8+De78sLNFese2HD/n6vbGwvc9sn5EZZUZAeo rBDw== 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=M0LF22QZF6XumchGpsVakuaBOLKZPFb9Ju0h5sruiyg=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=qAvBx9Wd3EIDYZFX7Zn+ajwauZf+tG7kHhgAVSa62pPqKlmSQ7ofll7HJ6UdqvHZAY 2hOJTOd8345sJqrPYuw+UmN0H5VDKuocRvnTKOSgbF88aahDazkEr2H5gBMUt0vbSbpj opovPZ+PWoq6UFNvpvgE03C9ysRcphBttWmbR8KWOSoDnpIq9C9UIKMaGtU8ECGPassG 4HGsQoTy6IMxHkboOb/UtPjHMJJXH0Ic70L5n2lmVwep1c5Cph/MbDhQZv8YSGkf6IRd CjZhXK11uP6iEnBZPx2sJlUW4/YJmRG8G9sTzFdPuUzNe2GA/aRSsayy2BZTjayVKbJf ONgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fZSobvgg; 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-76427-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76427-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c19-20020a05620a135300b007859581c77dsi12770067qkl.567.2024.02.22.03.37.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:37:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76427-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fZSobvgg; 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-76427-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76427-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 345EE1C21128 for ; Thu, 22 Feb 2024 11:37:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 018A9405CE; Thu, 22 Feb 2024 11:33:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="fZSobvgg" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 933A54F8A3; Thu, 22 Feb 2024 11:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601626; cv=none; b=Fcgz3lqN4WOFj5SHu1rTO76oiFJqeeTuNJBXrL0ZfMCYeExGX8leT2nWP6EmJz4SEr+v1ROYGECNC58lORLRiu+ITW0rQiYTksqEcbDLMNLn30s0zZGIiEO0ApTqtMc4gbQKQj+icAnh1+oH2+KMd47X6Z6WD04rh/05duXXr2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601626; c=relaxed/simple; bh=caGp7GvizSMoNT4KdlOqx40uaBwfhs60zrkO8TCm4es=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=b39KBMSeXokZ9e3j0pSYra0aldw2VT++XougPYb6osJpePWWekM98/mtq0ZfVtsARCAlXih12vnXts4s1ia83x5MZ6KxckQ7q1fCNEPNScrY78fkinFwNEOyWd2h+lsXrSJgNsQNdQxj6rixbwICwY8E2PFELlziS6LR8u68eJo= 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=fZSobvgg; arc=none smtp.client-ip=198.47.19.141 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 fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXWBb059162; Thu, 22 Feb 2024 05:33:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601612; bh=M0LF22QZF6XumchGpsVakuaBOLKZPFb9Ju0h5sruiyg=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=fZSobvggbYfwD4k3cwMcZfshepi7vkm/70hKxzlev8n/O9mW7MOXZd4D+b4nUy1WO suPGuJOoWUuyrsfw/HINCo8stFJoHCYU7ZxmEcs1ZwDSgkWBghLzi+rjggYfL+PwHb pZ1BFoQExtnuj2tcwI35lMHsp7u2MNK/I4Y1CqtI= Received: from DFLE107.ent.ti.com (dfle107.ent.ti.com [10.64.6.28]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXWDC059534 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:32 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE107.ent.ti.com (10.64.6.28) 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:32 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE107.ent.ti.com (10.64.6.28) 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:32 -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 41MBXV8s091398; Thu, 22 Feb 2024 05:33:31 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:30 +0530 Subject: [PATCH RFC 14/21] media: cadence: csi2rx: Enable stream-wise routing Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-14-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=5676; i=j-luthra@ti.com; h=from:subject:message-id; bh=caGp7GvizSMoNT4KdlOqx40uaBwfhs60zrkO8TCm4es=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDnPMcTZn6E0hY5yUJa6GilHK/2G3ouPPN8x /yfWRR25u2JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw5wAKCRBD3pH5JJpx RQrYD/9Dwn1OkvuJLiQO0qtEF/UGc4H2O5r+HWUSMcklhki/ZrYe/8HOgupxR0eLrh/KVGSoqER s3d7KCDgzysGFU4K0queqfKpL8MIUQvXGPoaBTN+ekPn8i0giJy44CIawqNfpKavsxcAbvZsFvq ovRcMII8/FT+RI/LboU11eVfmoW8vu2VwH/PwJj7AG5RwD+HOjMH9Ziy/6M/UqXBSp7Nk4CD/5V kVrFBoPPcfsmBUXIwrK2mdFMcteJ8tQoGFQpBOQhvJ8isMCBhnAxRqR5NMTbYqLszyw2vFFUolP smyRUyY1+OrLS3H0r15xAptEmyq4OtnfTp+1gptkfqNhpy5M55v5/gRmjNPDW7N446u6ZNJnwB9 gw8loGLbhu2VpmcMIE3vEsmx9e9xyRyEg7DutmIk+kmDDoVrGSCspKUuy/0d6RgnjDdDEKFF60T ex8pcFOoI1lSvvdwknj4RUkjDIUuuo99UQ/Gw2kRMv7LHiY6d4nED5uH8u0qnEaLgDcdLYqlx3C mgdjquRYxlhsga4i7mN45Nj+0JUroSOwgXCVWPytVIEgM0/T4UcW/Kxv7xr7b6zcONskGyGJkLM 8RwVK5Z9lncS+cmrOiiD9SP3x+OEFboizuE9KJEYFPpXBAe6/YPa1ONQrrLfObCknRBfaaRBhKG DK4bVZnXGVzpyBQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598910914240213 X-GMAIL-MSGID: 1791598910914240213 Cadence CSI-2 bridge IP supports capturing multiple virtual "streams" of data over the same physical interface using MIPI Virtual Channels. The V4L2 subdev APIs should reflect this capability and allow per-stream routing and controls. While the hardware IP supports usecases where streams coming in the sink pad can be broadcasted to multiple source pads, the driver will need significant re-architecture to make that possible. The two users of this IP in mainline linux are TI Shim and StarFive JH7110 CAMSS, and both have only integrated the first source pad i.e stream0 of this IP. So for now keep it simple and only allow 1-to-1 mapping of streams from sink to source, without any broadcasting. This commit only adds support for subdev routing APIs, without actually setting the registers in the Cadence IP to filter for particular virtual channels. Subsequent commits will add that support. Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 91 ++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index bac341881e41..1b76610ff617 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -450,12 +450,55 @@ static int csi2rx_enum_mbus_code(struct v4l2_subdev *subdev, return 0; } +static int _csi2rx_set_routing(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, + struct v4l2_subdev_krouting *routing) +{ + static const struct v4l2_mbus_framefmt format = { + .width = 640, + .height = 480, + .code = MEDIA_BUS_FMT_UYVY8_1X16, + .field = V4L2_FIELD_NONE, + .colorspace = V4L2_COLORSPACE_SRGB, + .ycbcr_enc = V4L2_YCBCR_ENC_601, + .quantization = V4L2_QUANTIZATION_LIM_RANGE, + .xfer_func = V4L2_XFER_FUNC_SRGB, + }; + int ret; + + if (routing->num_routes > V4L2_FRAME_DESC_ENTRY_MAX) + return -EINVAL; + + ret = v4l2_subdev_routing_validate(subdev, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1); + if (ret) + return ret; + + ret = v4l2_subdev_set_routing_with_fmt(subdev, state, routing, &format); + if (ret) + return ret; + + return 0; +} + +static int csi2rx_set_routing(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, + enum v4l2_subdev_format_whence which, + struct v4l2_subdev_krouting *routing) +{ + struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); + + if (which == V4L2_SUBDEV_FORMAT_ACTIVE && csi2rx->count) + return -EBUSY; + + return _csi2rx_set_routing(subdev, state, routing); +} + static int csi2rx_set_fmt(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { struct v4l2_mbus_framefmt *fmt; - unsigned int i; /* No transcoding, source and sink formats must match. */ if (format->pad != CSI2RX_PAD_SINK) @@ -467,14 +510,19 @@ static int csi2rx_set_fmt(struct v4l2_subdev *subdev, format->format.field = V4L2_FIELD_NONE; /* Set sink format */ - fmt = v4l2_subdev_state_get_format(state, format->pad); + fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream); + if (!fmt) + return -EINVAL; + *fmt = format->format; - /* Propagate to source formats */ - for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) { - fmt = v4l2_subdev_state_get_format(state, i); - *fmt = format->format; - } + /* Propagate to source format */ + fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad, + format->stream); + if (!fmt) + return -EINVAL; + + *fmt = format->format; return 0; } @@ -482,21 +530,22 @@ static int csi2rx_set_fmt(struct v4l2_subdev *subdev, static int csi2rx_init_state(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state) { - struct v4l2_subdev_format format = { - .pad = CSI2RX_PAD_SINK, - .format = { - .width = 640, - .height = 480, - .code = MEDIA_BUS_FMT_UYVY8_1X16, - .field = V4L2_FIELD_NONE, - .colorspace = V4L2_COLORSPACE_SRGB, - .ycbcr_enc = V4L2_YCBCR_ENC_601, - .quantization = V4L2_QUANTIZATION_LIM_RANGE, - .xfer_func = V4L2_XFER_FUNC_SRGB, + struct v4l2_subdev_route routes[] = { + { + .sink_pad = CSI2RX_PAD_SINK, + .sink_stream = 0, + .source_pad = CSI2RX_PAD_SOURCE_STREAM0, + .source_stream = 0, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE, }, }; - return csi2rx_set_fmt(subdev, state, &format); + struct v4l2_subdev_krouting routing = { + .num_routes = ARRAY_SIZE(routes), + .routes = routes, + }; + + return _csi2rx_set_routing(subdev, state, &routing); } static int csi2rx_get_frame_desc(struct v4l2_subdev *subdev, unsigned int pad, @@ -512,6 +561,7 @@ static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = { .get_fmt = v4l2_subdev_get_fmt, .set_fmt = csi2rx_set_fmt, .get_frame_desc = csi2rx_get_frame_desc, + .set_routing = csi2rx_set_routing, }; static const struct v4l2_subdev_video_ops csi2rx_video_ops = { @@ -770,7 +820,8 @@ static int csi2rx_probe(struct platform_device *pdev) csi2rx->pads[CSI2RX_PAD_SINK].flags = MEDIA_PAD_FL_SINK; for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) csi2rx->pads[i].flags = MEDIA_PAD_FL_SOURCE; - csi2rx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + csi2rx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | + V4L2_SUBDEV_FL_STREAMS; csi2rx->subdev.entity.ops = &csi2rx_media_ops; ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX, From patchwork Thu Feb 22 11:31:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp195057dyb; Thu, 22 Feb 2024 03:47:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbAngNBChHd2CzdLCh6eQyotKWHESp6nyFcwG+vCp/fG5S3aush7lyTdDrWotkly+b9uAODzU5+C5K5S8bL98fsr+UaQ== X-Google-Smtp-Source: AGHT+IEFEXAPTbqfeZ2JvlC8unWHUdlhpD0YEaeIql08ZniPT5wxiXLc7jWGnhOqKC6IpfijYGaw X-Received: by 2002:a05:6402:2151:b0:563:bd60:5809 with SMTP id bq17-20020a056402215100b00563bd605809mr15751789edb.31.1708602460345; Thu, 22 Feb 2024 03:47:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602460; cv=pass; d=google.com; s=arc-20160816; b=ciEhSKa5Didv/JMwCXkbhmtvu2/Q8il2R0tmLSlxVYUGTp3yIhpuUm4XF1Mgm1//eg HgdsfrmfO7q+RgBMPZqSe/t4c+/FL/4Uh8DUDtzlvTOufdQO8a1JvNcawbskjvV+74IR vQbfunHl2jbf/KrG+ri9iIHUzGiLkCqzgRJ4r6Ju5wJD72daVT77uPwu5NQVqJnK9qcI xPYtuM3hb+1dCdGoYmxtXI/bsQiCv09+emnuTYXuy4UDsSP4oTM99sHDfP8pUV44RB6d DnUZGkJJtw5WEAE7WaKoYJ4vrmGT44KXO9X0tqQFVILI4AjB1TCr0z+wLz74FXuqHpfx HafQ== 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=Pq0KtB3Nang3grqsagiJ+0HbLgkmbO3CBWGVBQiMSsk=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=UrtAnlxI+4DDkCAWAsTW02cBfKFHzsG1gsdd77uFb0aW/JQ8pXcgPFRdJuNnAlFu11 grllzO3McOuelefibpeZlxBoySIING+bKiuGc90nGBT8PNEintbDcMsIBcWPHvdmtjga TnSHwEmOHODKLKvEsQArd6ACJ8qd/Eva9uWnQF9R4Uy52nV5V7gPwcKqmNYPRSoiL5Od LVUFYF6aJs5WivUpKv8oI28gIgNd5CYzBV3JROH6iQj0HmnlaeKTjkB0iO+Aoy3jkfdv doeIp2HuBxh5qlIlyCm/LN3eLlFLb1cYlCfeW3eQHMk8nkfcKGJVxdSjsbD4gmS9V0dr ANjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VUjEkVSW; 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-76429-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76429-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r15-20020a50aacf000000b00564477609c3si4338608edc.378.2024.02.22.03.47.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76429-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VUjEkVSW; 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-76429-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76429-ouuuleilei=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 625A41F28A8F for ; Thu, 22 Feb 2024 11:38:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99D8F55C2C; Thu, 22 Feb 2024 11:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="VUjEkVSW" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 336965337B; Thu, 22 Feb 2024 11:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601629; cv=none; b=c40+XlcR0v1DbdiTEJYpn/9dTgkdg/A5WWIdB34gjiJzdj1hduJT2RNZ2NW2cK+UYmgfcEM1OlBZk76vOCw4ld0hYKUOPfGCrcixPJKS/037arQFt3tcXzegamlrYjuZdXVYCOEYhd0oI9gSyCO3+8ajWE/rEAC1MYJJX9DqPS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601629; c=relaxed/simple; bh=cPFONFYE2nb+IO9iZMg9BmI+2H7DAZ1L+pH8J7rFXGc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=g1Qt2kBY/VdYkHCwq7nLOAQNsJZ1kozIHlwkzk1cUjWHzegg0ofKVYzcbk2MLHZOBkXK+35B9AeVlygcUqB7FOtiA4hxBtvzX7IJBCGCTLHCMxSLT4xfTT1BDbjZ7+jyERnoR9eCK8SLoLR1H61qUxsKQ1lTa6KR7KLhk7EyHCQ= 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=VUjEkVSW; arc=none smtp.client-ip=198.47.19.141 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 fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXYdo059172; Thu, 22 Feb 2024 05:33:34 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601614; bh=Pq0KtB3Nang3grqsagiJ+0HbLgkmbO3CBWGVBQiMSsk=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=VUjEkVSW8idOK0U/PDzd6E1PgKdXDLFXld81ny8S8GBS5nUR/7eAmohUmatjJbW8o yIAidGljU0abdaAxr0pVtI1vpnGd+0Wjkt2OyiL+2x31zvN8Vgdo/bsuqYjvpng3cs yfgn1RNbjQSv4fIIDbg+AWU9MRVvjsq2vR447LH4= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXY5c057359 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:34 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE110.ent.ti.com (157.170.170.21) 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:34 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE114.ent.ti.com (157.170.170.25) 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:34 -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 41MBXX4h091431; Thu, 22 Feb 2024 05:33:33 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:31 +0530 Subject: [PATCH RFC 15/21] SQUASH: media: cadence: csi2rx: Enable per-stream controls Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-15-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=9384; i=j-luthra@ti.com; h=from:subject:message-id; bh=cPFONFYE2nb+IO9iZMg9BmI+2H7DAZ1L+pH8J7rFXGc=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDoSJ1V++3bJA427yCkm9V3ixbMYp5EM+EOG gMG69Z5um2JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw6AAKCRBD3pH5JJpx RaTiD/9FOUlfyXc4GnumP/7KaiM8X0qiI29XFYqQJYH0m2admGEGyn/yO0N4ar/BaANSseTdamx Y2TiZ4GCMVJHgeiXD+H7VSAJoPtgK4nmE9Eyj/wcV0OEvG3YxGJgqDxROQFOS9GWbAweWfIOAB8 Dl7Z7AkR4AWfOn1ISHiWY09PWtgfS6zkTrI0WGrgVX7jxsej75wIiWPc9Jq8L+CX36NHzO1HSew iXTWg0K3EBQ+niyoODSbGGXQWLdnXiC6zMRH6IxGG+x6929RRknFLPu05mvQS6S/aDhSRQ0/+Mb i4Q+hEYIJVM90aLwFdA+s7lSn8zMrAkX895QCREE4wvi5mcqXO7xzaEXi8tfP+A06y10sZvaJrc H4ULNr2Lxgopr4GPl1EVsSEt/tS5YBf66PHxqutg7JNKdcH7SUp3plCk9/6QjRI67A74HLTG9zd boC9WqGXzW/+eEQeV1LcUL6jZhIQXLJ56MJjx1CwQa9LEmJm0ITM+/VKoPDWVjdkgfzDDh8dFMW /up5AY3ZfOmZ6F4NQuXly3LxW4BAjObU+P7yjgeLacSEXzD1VAEqoNMDrP2eFHPvLJwsEPo4GQl q2lNlAOyHaj2Il93kg0DERRcicYAr+bKYRxCUOxl5ZtiiogR/d5qmwqLky0uJUjMBlllDseDetv DKWx6rNtOlEXVrg== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599533373140802 X-GMAIL-MSGID: 1791599533373140802 With stream routing now supported in the driver, implement the enable_stream and disable_stream hooks in place of the stream-unaware s_stream hook. This allows consumer devices like a DMA bridge or ISP, to enable particular streams on a source pad, which in turn can be used to enable only particular streams on the CSI-TX device connected on the sink pad. Implement a fallback s_stream hook that internally calls enable_stream on each source pad, for consumer drivers that don't use multi-stream APIs to still work. Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 211 ++++++++++++++++++--------- 1 file changed, 142 insertions(+), 69 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 1b76610ff617..f08d3b845dc9 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -183,27 +183,43 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx) static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) { + struct v4l2_ctrl_handler *handler = csi2rx->source_subdev->ctrl_handler; union phy_configure_opts opts = { }; struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; - struct v4l2_subdev_format sd_fmt = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - .pad = CSI2RX_PAD_SINK, - }; + struct v4l2_mbus_framefmt *framefmt; + struct v4l2_subdev_state *state; const struct csi2rx_fmt *fmt; s64 link_freq; int ret; - ret = v4l2_subdev_call_state_active(&csi2rx->subdev, pad, get_fmt, - &sd_fmt); - if (ret < 0) - return ret; + if (v4l2_ctrl_find(handler, V4L2_CID_LINK_FREQ)) { + link_freq = v4l2_get_link_freq(handler, 0, 0); + } else { + state = v4l2_subdev_get_locked_active_state(&csi2rx->subdev); + framefmt = v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, + 0); - fmt = csi2rx_get_fmt_by_code(sd_fmt.format.code); + if (framefmt) { + fmt = csi2rx_get_fmt_by_code(framefmt->code); + } else { + dev_err(csi2rx->dev, + "Did not find active sink format\n"); + return -EINVAL; + } - link_freq = v4l2_get_link_freq(csi2rx->source_subdev->ctrl_handler, - fmt->bpp, 2 * csi2rx->num_lanes); - if (link_freq < 0) + link_freq = v4l2_get_link_freq(handler, fmt->bpp, + 2 * csi2rx->num_lanes); + + dev_warn(csi2rx->dev, + "Guessing link frequency using bitdepth of stream 0.\n"); + dev_warn(csi2rx->dev, + "V4L2_CID_LINK_FREQ control is required for multi format sources.\n"); + } + + if (link_freq < 0) { + dev_err(csi2rx->dev, "Unable to calculate link frequency\n"); return link_freq; + } ret = phy_mipi_dphy_get_default_config_for_hsclk(link_freq, csi2rx->num_lanes, cfg); @@ -226,18 +242,10 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) static int csi2rx_start(struct csi2rx_priv *csi2rx) { unsigned int i; - struct media_pad *remote_pad; unsigned long lanes_used = 0; u32 reg; int ret; - remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); - if (!remote_pad) { - dev_err(csi2rx->dev, - "Failed to find connected source\n"); - return -ENODEV; - } - ret = clk_prepare_enable(csi2rx->p_clk); if (ret) return ret; @@ -321,17 +329,10 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) reset_control_deassert(csi2rx->sys_rst); - ret = v4l2_subdev_enable_streams(csi2rx->source_subdev, - remote_pad->index, BIT(0)); - if (ret) - goto err_disable_sysclk; - clk_disable_unprepare(csi2rx->p_clk); return 0; -err_disable_sysclk: - clk_disable_unprepare(csi2rx->sys_clk); err_disable_pixclk: for (; i > 0; i--) { reset_control_assert(csi2rx->pixel_rst[i - 1]); @@ -350,7 +351,6 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) static void csi2rx_stop(struct csi2rx_priv *csi2rx) { - struct media_pad *remote_pad; unsigned int i; u32 val; int ret; @@ -379,13 +379,6 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) reset_control_assert(csi2rx->p_rst); clk_disable_unprepare(csi2rx->p_clk); - remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); - if (!remote_pad || - v4l2_subdev_disable_streams(csi2rx->source_subdev, - remote_pad->index, BIT(0))) { - dev_warn(csi2rx->dev, "Couldn't disable our subdev\n"); - } - if (csi2rx->dphy) { writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); @@ -394,47 +387,125 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) } } -static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable) +static int csi2rx_enable_streams(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) { struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); - int ret = 0; + struct media_pad *remote_pad; + u64 sink_streams; + int ret; - if (enable) { - ret = pm_runtime_resume_and_get(csi2rx->dev); - if (ret < 0) - return ret; + remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); + if (!remote_pad) { + dev_err(csi2rx->dev, + "Failed to find connected source\n"); + return -ENODEV; } + ret = pm_runtime_resume_and_get(csi2rx->dev); + if (ret < 0) + return ret; + + sink_streams = v4l2_subdev_state_xlate_streams(state, pad, + CSI2RX_PAD_SINK, + &streams_mask); + mutex_lock(&csi2rx->lock); + /* + * If we're not the first users, there's no need to + * enable the whole controller. + */ + if (!csi2rx->count) { + ret = csi2rx_start(csi2rx); + if (ret) + goto err_stream_start; + } - if (enable) { - /* - * If we're not the first users, there's no need to - * enable the whole controller. - */ - if (!csi2rx->count) { - ret = csi2rx_start(csi2rx); - if (ret) { - pm_runtime_put(csi2rx->dev); - goto out; - } - } + /* Start streaming on the source */ + ret = v4l2_subdev_enable_streams(csi2rx->source_subdev, remote_pad->index, + sink_streams); + if (ret) { + dev_err(csi2rx->dev, + "Failed to start streams %#llx on subdev\n", + sink_streams); + goto err_subdev_enable; + } - csi2rx->count++; - } else { - csi2rx->count--; + csi2rx->count++; + mutex_unlock(&csi2rx->lock); - /* - * Let the last user turn off the lights. - */ - if (!csi2rx->count) - csi2rx_stop(csi2rx); + return 0; + +err_subdev_enable: + if (!csi2rx->count) + csi2rx_stop(csi2rx); +err_stream_start: + mutex_unlock(&csi2rx->lock); + pm_runtime_put(csi2rx->dev); + return ret; +} + +static int csi2rx_disable_streams(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) +{ + struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); + struct media_pad *remote_pad; + u64 sink_streams; - pm_runtime_put(csi2rx->dev); + sink_streams = v4l2_subdev_state_xlate_streams(state, pad, + CSI2RX_PAD_SINK, + &streams_mask); + + remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); + if (!remote_pad || + v4l2_subdev_disable_streams(csi2rx->source_subdev, + remote_pad->index, sink_streams)) { + dev_err(csi2rx->dev, "Couldn't disable our subdev\n"); } -out: + mutex_lock(&csi2rx->lock); + csi2rx->count--; + /* + * Let the last user turn off the lights. + */ + if (!csi2rx->count) + csi2rx_stop(csi2rx); mutex_unlock(&csi2rx->lock); + + pm_runtime_put(csi2rx->dev); + + return 0; +} + +static int csi2rx_s_stream_fallback(struct v4l2_subdev *sd, int enable) +{ + struct v4l2_subdev_state *state; + struct v4l2_subdev_route *route; + u64 mask[CSI2RX_PAD_MAX] = {0}; + int i, ret; + + /* Find the stream mask on all source pads */ + state = v4l2_subdev_lock_and_get_active_state(sd); + for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) { + for_each_active_route(&state->routing, route) { + if (route->source_pad == i) + mask[i] |= BIT_ULL(route->source_stream); + } + } + v4l2_subdev_unlock_state(state); + + /* Start streaming on each pad */ + for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) { + if (enable) + ret = v4l2_subdev_enable_streams(sd, i, mask[i]); + else + ret = v4l2_subdev_disable_streams(sd, i, mask[i]); + if (ret) + return ret; + } + return ret; } @@ -557,15 +628,17 @@ static int csi2rx_get_frame_desc(struct v4l2_subdev *subdev, unsigned int pad, } static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = { - .enum_mbus_code = csi2rx_enum_mbus_code, - .get_fmt = v4l2_subdev_get_fmt, - .set_fmt = csi2rx_set_fmt, - .get_frame_desc = csi2rx_get_frame_desc, - .set_routing = csi2rx_set_routing, + .enum_mbus_code = csi2rx_enum_mbus_code, + .get_fmt = v4l2_subdev_get_fmt, + .set_fmt = csi2rx_set_fmt, + .get_frame_desc = csi2rx_get_frame_desc, + .set_routing = csi2rx_set_routing, + .enable_streams = csi2rx_enable_streams, + .disable_streams = csi2rx_disable_streams, }; static const struct v4l2_subdev_video_ops csi2rx_video_ops = { - .s_stream = csi2rx_s_stream, + .s_stream = csi2rx_s_stream_fallback, }; static const struct v4l2_subdev_ops csi2rx_subdev_ops = { From patchwork Thu Feb 22 11:31:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp190875dyb; Thu, 22 Feb 2024 03:38:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXphyAzhXgEv3ZSCyNE5U9eOMCq5zxQol+NS+O0L32VQ0SmcmBYU73FH3swc1+C0nRZZbwVYeOC4SZT6Shs6mzx1qVL1A== X-Google-Smtp-Source: AGHT+IFgdTz+Xi2OR5ZL/twwdXwgoFgdhN3BRnF649fVWOElK6MsddC9w4PuSPyop1YtecdcSXg+ X-Received: by 2002:a62:e70e:0:b0:6e4:6b6f:37dc with SMTP id s14-20020a62e70e000000b006e46b6f37dcmr8728688pfh.0.1708601900662; Thu, 22 Feb 2024 03:38:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601900; cv=pass; d=google.com; s=arc-20160816; b=sPa+ELU3QGoTt8nIhShxJ4Ohr8DJtvqD8G2zlVpo9CuZOLZmNLAeR1Sd0pTlLRo8XU tdG0s08TY5YikSq5azd1LwZMHzBGhMSmLo1gSxIxxFlb7PglK2NqPdl3OHrvPawKOzS+ evPLGtoU+OxIqy34k7Z5/bOLbxkJN6L4ICbJo6Nm5v4/xX4Fm6Fx3J4Qn1CmkEva2L3K UT/dCa7yuKp0H9nV7tCR6EfPVbNHqBM2ZnUXJfASLD9mO/SvcULwsyBSVUolZmxrs5aM u5ICWKDWxUmGtX2+3OMY+kmoLYkORBkljdp99wwEG223R3Y7hTCOW0K+dLZfBsjCDEfa vtTw== 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=fBRydw75ApRmvvqdKjFPWvCH74RUiQ+/VsEaFBfSZYQ=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=xPsZPEwTVwtiQTmfYmFnM9mFkABesK5RZ5l7k/MtDX0l20lWJMZv1nrOtey1fTV/Iy 7JoHrmZVMN/u3dVCOO5hmLFHszvX9gn6qKF7CHoXy9r/QkpBHpCONNj+MtwohzvF9/ZS iKtZZ3s7rXRvTMXlv/BpVeMPAStRomdXxM/m+mG7xKtil2Kfv+JHTPUeP/4g5eDmC3JL Og1jDi9yDTMi53kwP/LXVsprTMMyDJqNxVO/eeK1KtA///RLY8EnJojIbPStRHZW17jE RJk9E/7jBw7zhwPkl0E6T30+y7+QwvLkyOGaNOLm/sr9NzOF/v5sE8Wjq4WLKvUmosiX lA/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fseJfSx0; 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-76430-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76430-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r4-20020a632b04000000b005cdf37c9c29si9896492pgr.703.2024.02.22.03.38.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:38:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76430-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fseJfSx0; 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-76430-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76430-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6E715281621 for ; Thu, 22 Feb 2024 11:38:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC81A55E49; Thu, 22 Feb 2024 11:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="fseJfSx0" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 3641F54F94; Thu, 22 Feb 2024 11:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601630; cv=none; b=AtZWAL2JLp9lloBTFLhUIDM3yfXv/1QzMM3/Vdai/SQPBBAxF3NXwO2lBNx//bMJh4NUtMSyBSW68VJMb657SMgf04V6k572MHW8TFzw4T6opPdnUUixiMSKU8rXimmIRVUe/+Oyu8t4nKuGrA8tNV0Dz4AMCffdrUGrOAQj8gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601630; c=relaxed/simple; bh=WfP2M++UZHmobW4n0X1+ukfph/52tAvXyfl7uynbcSk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=IsDax/UlUd/CIoSnnBVPVBtchNg38utmofzTaHynCxeH5zyi4p+a4tYjhtnjRSyzF50t7iQvdHqT3OCQ8eeIIAYyhuNAoE6k3oiAgZ6Y5UWABmktA0uq2HEzs1DD7y5BVCY1usSNcLUtXJ8t5Y7ROEtpiffoVJA8FF6pfXIFCtY= 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=fseJfSx0; arc=none smtp.client-ip=198.47.23.248 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXarm018107; Thu, 22 Feb 2024 05:33:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601616; bh=fBRydw75ApRmvvqdKjFPWvCH74RUiQ+/VsEaFBfSZYQ=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=fseJfSx0IVJ0WMH/ZXJPYPZZqZtVgJhdsw5dp20GKwFVFKUdsyvpkzXdcTS/meRhx 8saQmKgi42TD7ah0JUN4dOLTR5jVhI1Veou6gL6pU3a9KGBFitmmfAOxUdvbV3B3q/ h8vLD53XcxqifI1LQSs5HsKZKcMCL1wcZDaUwoY0= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXaC5057384 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:36 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE112.ent.ti.com (157.170.170.23) 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:36 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE100.ent.ti.com (157.170.170.30) 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:36 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXZ25128867; Thu, 22 Feb 2024 05:33:35 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:32 +0530 Subject: [PATCH RFC 16/21] SQUASH: media: cadence: csi2rx: Filter using MIPI virtual channels Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-16-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=3355; i=j-luthra@ti.com; h=from:subject:message-id; bh=WfP2M++UZHmobW4n0X1+ukfph/52tAvXyfl7uynbcSk=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDp9MzO7AC1G2cfH2ka7czWOgG/S/zDVF1NY iY/HGsFre2JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw6QAKCRBD3pH5JJpx ReYdEADBa1DxNEj7OmBjq5CNyDEhfIMMTrPn4UDKlUTqbBr2SJKwr8uGhOctYxIoVz33ACealaj jzRzki2Gwd+0/gXS9yMB+yaz4Jvr1/gYxwNu8M3+ogXtwsasKwv99oJMPxdJ2wccLYCAhbzE9H2 xX7RYAmHaDmcjJ/m+q5oUORZ6CT/Uy5UjXZs8un6d1C+sv+aC6UVendjGT/2VcpLmAAgMwVil3p SsxG6uCygPmLMfEojoj/QuD7AZWYdbW/rT7CRIbu5SLAWUlgBqsh5RImckks2yEWaRAs8h2Nma+ i4FV0vuB7hafqdOM/R+Z85LpwiDm0wudfnA3ZtO79EV80BQUB+/aZrn2pfTwOLm3xAC4O343I6w wATolzrOwifl7N5blz1Uvf4WGkCWQIjUNzyVTGLMt6xV6V6SRVXQY6MBGMHIlla4epWh231tL6j fnN0sPZJtlvBFsWu6+hFpBHM38EI+ah553QgQKp6hLWgNi+g3NsXzlgHFPi4QyRbhQqtWc+vrc7 N7DSRz56YUOTWZiZCQQC6zUdKE3+jPwKSIr+KGaQm65AoXEQ06vF7noIrmb55h3sYQIkIKn50Qp JFT0h7CDs38/ez11xgX8PNElsJ4hqFOihX1Lj5tXWmdlYz8XYE+e0CNf77UZWXXyBqOXc0i7lcX COvJqKm8tPhPknQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791598946774645443 X-GMAIL-MSGID: 1791598946774645443 With stream routing now supported by the driver, we can check if the CSI-TX source provides extra bus information through frame descriptor entries, and use it to filter for particular VCs on the source pads. Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 59 +++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index f08d3b845dc9..f96638b9f252 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -90,6 +90,7 @@ struct csi2rx_priv { struct reset_control *pixel_rst[CSI2RX_STREAMS_MAX]; struct phy *dphy; + u32 vc_select[CSI2RX_STREAMS_MAX]; u8 lanes[CSI2RX_LANES_MAX]; u8 num_lanes; u8 max_lanes; @@ -312,11 +313,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF, csi2rx->base + CSI2RX_STREAM_CFG_REG(i)); - /* - * Enable one virtual channel. When multiple virtual channels - * are supported this will have to be changed. - */ - writel(CSI2RX_STREAM_DATA_CFG_VC_SELECT(0), + writel(csi2rx->vc_select[i], csi2rx->base + CSI2RX_STREAM_DATA_CFG_REG(i)); writel(CSI2RX_STREAM_CTRL_START, @@ -387,6 +384,48 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) } } +static void csi2rx_update_vc_select(struct csi2rx_priv *csi2rx, + struct v4l2_subdev_state *state) +{ + struct v4l2_mbus_frame_desc fd = {0}; + struct v4l2_subdev_route *route; + unsigned int i; + int ret; + + for (i = 0; i < CSI2RX_STREAMS_MAX; i++) + csi2rx->vc_select[i] = 0; + + ret = csi2rx_get_frame_desc_from_source(csi2rx, &fd); + if (ret || fd.type != V4L2_MBUS_FRAME_DESC_TYPE_CSI2) { + dev_dbg(csi2rx->dev, + "Failed to get source frame desc, allowing only VC=0\n"); + goto err_no_fd; + } + + /* If source provides per-stream VC info, use it to filter by VC */ + for_each_active_route(&state->routing, route) { + int cdns_stream = route->source_pad - CSI2RX_PAD_SOURCE_STREAM0; + u8 used_vc; + + for (i = 0; i < fd.num_entries; i++) { + if (fd.entry[i].stream == route->sink_stream) { + used_vc = fd.entry[i].bus.csi2.vc; + break; + } + } + csi2rx->vc_select[cdns_stream] |= + CSI2RX_STREAM_DATA_CFG_VC_SELECT(used_vc); + } + +err_no_fd: + for (i = 0; i < CSI2RX_STREAMS_MAX; i++) { + if (!csi2rx->vc_select[i]) { + csi2rx->vc_select[i] = + CSI2RX_STREAM_DATA_CFG_VC_SELECT(0); + } + } +} + static int csi2rx_enable_streams(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, u32 pad, u64 streams_mask) @@ -558,11 +597,19 @@ static int csi2rx_set_routing(struct v4l2_subdev *subdev, struct v4l2_subdev_krouting *routing) { struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); + int ret; if (which == V4L2_SUBDEV_FORMAT_ACTIVE && csi2rx->count) return -EBUSY; - return _csi2rx_set_routing(subdev, state, routing); + ret = _csi2rx_set_routing(subdev, state, routing); + + if (ret) + return ret; + + csi2rx_update_vc_select(csi2rx, state); + + return 0; } static int csi2rx_set_fmt(struct v4l2_subdev *subdev, From patchwork Thu Feb 22 11:31:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp195120dyb; Thu, 22 Feb 2024 03:47:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV71Dk2UEh+Kf36OF+LTPiPSlpwvQpYEtlsDJ+cZuTDhT/isX73IEyx5RES79hV1edWgRG7ePjkr2zkuQ92V//wQo8MHA== X-Google-Smtp-Source: AGHT+IFtQRch1IglAV+fK6S/w8rIkY1w8L3fkT2CklX88JJGA0Ydn/jKcOGg0Rx0aPwke4q2Eywd X-Received: by 2002:a17:906:cb96:b0:a3e:97d4:256b with SMTP id mf22-20020a170906cb9600b00a3e97d4256bmr6997956ejb.10.1708602467115; Thu, 22 Feb 2024 03:47:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602467; cv=pass; d=google.com; s=arc-20160816; b=YhG9i5lZx2IfyhoKB1SvjF1c6AUQLO6PAQugGB2jdwVoYUK4bFOS16aDduvgtmCMmn Jbur8m9dEMiG5iNmv0lk5V5Y0Rl6mKRIwFjcJZD5rXJeIWRvXSw+jy2vxryv/p5baOA5 /0qNBAxrPlQzEeD69Dgq1J7JS5vphWFs7y3jw2TUQ2Ooy+VQ5l8y2QOX4tIHOQ+JZxuS TC+RPs4UbHXhvSlp5u/OaogbgKXHYQYkv+DJCvqwK+zQxvfikfUQ3/nwtGgduxjznJJm rfAhMjtU8zcuwyFQbVSifbk5DASfBdqHTCLQs8GH+O9WlELWwlFLigFuOVI1FPwO+KHH 4goA== 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=07yIeWWliUpA8c0qdo5yfrxhS/SYHwPJZKzuICs0MDk=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=DRD/ml9j+j2bHLW0Hb92NAW+QIdXAZq2ok9WdCZixc1T4EB368SXSLr7DThCpqxCaG dn8iKomD5xgwxxAFT1slHrCZCAxA/LgVMMYfj5Nm/9Cm8x7KJdFlL9REj+/aJOxlIHeZ ExsP7Gad6QYoFbHamMCkNK0uHG5WhHcXwAQqguVD4+eDLcu/rT8M2mt9PDufAW0+InaX etw/PWWvCVmilcykX8AswaHo8N3KFb7kwulQ9kiLFsdY6w2wv6AI/faipQ9PS4st2cqz nyR73Rc+GFky8UHZSUhWG7wAEzdyYNzvsR0vK00sDxlGQUhSJU/4dboDxrYI8ooqmY5G Bqpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GGY8q2v0; 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-76431-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76431-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qw39-20020a1709066a2700b00a3e9a48cd38si3851712ejc.0.2024.02.22.03.47.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:47:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76431-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GGY8q2v0; 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-76431-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76431-ouuuleilei=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 42C061F28EE1 for ; Thu, 22 Feb 2024 11:38:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 116BD56466; Thu, 22 Feb 2024 11:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="GGY8q2v0" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 E1FB655C06; Thu, 22 Feb 2024 11:33:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601633; cv=none; b=jZ9mUwUjj6KEhHHzNbfeLv+g3L2gAQIqqopm+AJU4pge2Q+1kfZ5LrgQGEWOIcl7OTw2JKr80MaywUSXoNK8rTFnKw6Wve/3vkaIom1HUk2MZoFYVeItCBK5jEmvRRcFX7WeCroHeyeqHTP4wMA3lE/xwo7k5Ks0JbAVlpZ2j6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601633; c=relaxed/simple; bh=H/EkA7/3egmQtAVJ8kpXMhqh9m1rOR7HNqmR3Y2RSMQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=d8YmUMwbfaKKKeVLjjbG7sQyofVmC3vZAlqgh7noZln12yH+mJuMmGNEOGiDJhJ4MB30/Bxf1FfTKGIUp9Ef6Ffc1YOL9x/UUwo2aESi6lEdMBvR637vijrtyo6tJC7Q98i0RCegf/Pm6SXAPKWJgcyw5Weq5X1b9gnodYBsmOg= 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=GGY8q2v0; arc=none smtp.client-ip=198.47.23.249 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXcBr112384; Thu, 22 Feb 2024 05:33:38 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601618; bh=07yIeWWliUpA8c0qdo5yfrxhS/SYHwPJZKzuICs0MDk=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=GGY8q2v0GGG2TdAxW9e0rG32J/zPqicZB+4+qFFiW9SkrEoFIJgEHqBC3PU8Mnt2Q n1/oXVGZ3ud1xPKG0/96j8ZgI2vjf04AG/BPCzgS6Gm+OBHSWFK7BxRB3S/gasVW9I GDkdFcxBC3Urit6919wnDIexCd2B/OzziyowjJBw= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXcca057410 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:38 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE115.ent.ti.com (10.64.6.36) 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:38 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE108.ent.ti.com (10.64.6.29) 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:38 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXbdV128904; Thu, 22 Feb 2024 05:33:37 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:33 +0530 Subject: [PATCH RFC 17/21] SQUASH: media: cadence: csi2rx: Filter streams in get_frame_desc Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-17-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=2358; i=j-luthra@ti.com; h=from:subject:message-id; bh=H/EkA7/3egmQtAVJ8kpXMhqh9m1rOR7HNqmR3Y2RSMQ=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDqTSsc0XQfJv7yVhejPfmWz4ruBmlilBj4D RflUnBmTN2JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw6gAKCRBD3pH5JJpx RfMOD/wNoVMPKXlSXaKalMd1CChxqUuP4eilv37zylz9WI4RyefaWDUee+qinGlvXiedd013HV8 1LJs0krP7tOoB+X9XMG7znBKcgfxQUru3h2FM+AZ/DMHs9dWRKAP6Zsv1IouC71qSh4TwmorwJd nFMhXjHWq6YWIVInl8fsKNtl8/SSDth1AhoEkjQSZ1u53jFxyX56og38chxG1j4c3RWqkgN2MAn 4YfskgTHc03KdYjbRsB3bijc8yoGsUT5GNtg2du4FnsGdRR8RGFX4g20dHCgfspy6s50Qnh/m1w ajUbnTf/uvjEfmEB6ad0uyPfup5oGRAKF4WDJQp1KSkRW43kpcOU0qahPPXztZ+hcuGjnV5H1Qt 1nFNjwgePaITBeDcHDcIrkhvo5dlOWDys5B4i1ui/TyRBmHFUy1bryK6znl/22XHn1hZrS8bPYS gMIvgRTYJcnn9VkTg0YgEGCKpV8ZOdnPou/ncDArYGtst18cZ1Yr9B+hxnVyqNFF1JpnJeewT/Z oOM9JeOzJQKMoOHzzzH+VAcycOJhezpVB2B2ZD0TDGKNgRNb9oSCuuhTDBTMPqyNtsOrXOQoAg9 AUWUn9jSvYOQrMFDK5wp3cKTx0+PHk5dcN/emMeXont7Ogu1ySS3LSup5NHhlM72EfzPB8tC06U v/3T11rpsxwTkzQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599540460854630 X-GMAIL-MSGID: 1791599540460854630 With routing and stream-aware APIs support in place, make sure to propagate frame descriptor information for only the subset of streams that are routed to the particular source pad. Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 50 +++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index f96638b9f252..a0ccdf72a3b2 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -670,8 +670,56 @@ static int csi2rx_get_frame_desc(struct v4l2_subdev *subdev, unsigned int pad, struct v4l2_mbus_frame_desc *fd) { struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); + struct v4l2_mbus_frame_desc source_fd = {0}; + struct v4l2_subdev_route *route; + struct v4l2_subdev_state *state; + int ret; + + ret = csi2rx_get_frame_desc_from_source(csi2rx, &source_fd); + if (ret) + return ret; + + fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; + + state = v4l2_subdev_lock_and_get_active_state(subdev); + + for_each_active_route(&state->routing, route) { + struct v4l2_mbus_frame_desc_entry *source_entry = NULL; + unsigned int i; + + if (route->source_pad != pad) + continue; + + for (i = 0; i < source_fd.num_entries; i++) { + if (source_fd.entry[i].stream == route->sink_stream) { + source_entry = &source_fd.entry[i]; + break; + } + } + + if (!source_entry) { + dev_err(csi2rx->dev, + "Failed to find stream from source frame desc\n"); + ret = -EPIPE; + goto err_missing_stream; + } - return csi2rx_get_frame_desc_from_source(csi2rx, fd); + fd->entry[fd->num_entries].stream = route->source_stream; + fd->entry[fd->num_entries].flags = source_entry->flags; + fd->entry[fd->num_entries].length = source_entry->length; + fd->entry[fd->num_entries].pixelcode = source_entry->pixelcode; + fd->entry[fd->num_entries].bus.csi2.vc = + source_entry->bus.csi2.vc; + fd->entry[fd->num_entries].bus.csi2.dt = + source_entry->bus.csi2.dt; + + fd->num_entries++; + } + +err_missing_stream: + v4l2_subdev_unlock_state(state); + + return ret; } static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = { From patchwork Thu Feb 22 11:31:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp191340dyb; Thu, 22 Feb 2024 03:39:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUaTdRBpi3kRQ3RKZ91/e68n2qz0556zUdzkd65jmHccWFIiN3EXi4taMxn6HWAeDRvNTzllagDN6xqyM9fD87BtzEoVQ== X-Google-Smtp-Source: AGHT+IE+IAtuNm8p2b9jiaoLVPTiZLE7i6gEAboCA24WwzKWdMbflI+o2z0Ciiex/EZfa0r7eHlJ X-Received: by 2002:a17:902:e807:b0:1db:efef:f912 with SMTP id u7-20020a170902e80700b001dbefeff912mr13989707plg.2.1708601959486; Thu, 22 Feb 2024 03:39:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601959; cv=pass; d=google.com; s=arc-20160816; b=sE1LTxsJjVxDeNymvym/ZG7Agt3h0375rM/93xU1EgGq02ntUjwSZXQbr54pTj8dNu Z9xrdh8eYj20Jer4555iapKaX2/WBkpKihjCUh2ycRdohG+t0JIdNLWzyIZQr3MBvwQi yXlT3G+evhKJ+dTWuAvOja2EJoImS27yblYHrSMt7G0R+y7qyEb7C0UgG3G08EUqSJG/ 05pB7S6/7dy9LLnu74pXN9QM8/sv7gNfqOSqR+JIwv4joQSOKKtnGMTD20TaUr6L45KY Pm29W2RXeyJZjF7Adb+NIkVEAWs6QGOm++trh56RYD3FIeIuQhuV0pJcPaoUXzPXl0QD 4gqg== 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=E2sXMQeM24E290x6U+fxQQ3J78/9SfUpDvCVA4tYbmY=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=AZ3GNHw68Yrx6TYWwcjvHH3BbsXVRGJM9DjzQusHFLFVKvpX3DAuLzShNAImdLVga3 pSioiq5f62HOmPmoDjnJIc9f8Lz6uoLX84GCF5OlVsPXN6im8/HXPJFSngJ/5lEzxOX/ yTIDBzkTxdQkeVDtSMR4B+BgRLSjpC6+IRUH07ZbbstMHg6+/FscQVYDdGebwFgMVrbJ J3abVFfFg5cdS6DYV1f4R449rZFBFlFLIL2ID/CG/k58tGRRDKsS9lASR4181kaw2ZxN oic86fjOHmqgNO7Ghw3umWvrALB3Fa4IxjGxahQNqoN3tze60VC5OsfRFxbS4YKcw9ZR TMkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=D8ss3jhg; 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-76432-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76432-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j12-20020a170903028c00b001dc3437ccabsi2842875plr.580.2024.02.22.03.39.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:39:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76432-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=D8ss3jhg; 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-76432-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76432-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4ADE0281976 for ; Thu, 22 Feb 2024 11:39:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70C6B57335; Thu, 22 Feb 2024 11:34:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="D8ss3jhg" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 AB68256440; Thu, 22 Feb 2024 11:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601636; cv=none; b=BNp5XaQ+v+gwJs3eSKtC8/Qxj+07Utj4O4vCPNIzGzC/TY3aJ4ZFWYopMdC881JQRnhn+9XO0l/tgV4jrcoTW2ja+TcSa93QUFGLCCwehijSk23feTQ1eJaDLCthdFujVl8/QVWq7eqquT44F2FWclxymBWPdVvzH5v2ucLLDbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601636; c=relaxed/simple; bh=Uk6tns0lOkArX4B5O1OscMnEfvQbP1P99m1HGZqaO9k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=ohz/tqUd0hX46EtZrNxjIhAl7dDO4NC7K798J3VjIR9uvLxAxaapgs09F6r2welNJ4o7hahG/18ubWTReJG3Bflwo/pB5DGISt0+qn9V9uTnp/QlxhAJ5Fckcj9gr7VeWLbPaKam17F7/RdTBErqE34zTK/Zm2o/laFksamX8KY= 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=D8ss3jhg; arc=none smtp.client-ip=198.47.19.141 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 lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXfXi059181; Thu, 22 Feb 2024 05:33:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601621; bh=E2sXMQeM24E290x6U+fxQQ3J78/9SfUpDvCVA4tYbmY=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=D8ss3jhgjGeRH8ZWZx3x7TMwIfALFtCkE2OHdRkapF9FOm6Xss8NWIRCqLL5LjmIi KgfffziqT3G0sQI7gV5urirM8aKCV6+O11A7CNy2Y2f69nWsETC7cI5Q69rabsryT8 +mmY1mN8Pbqxqi9SF0JEdihXZFM/XFwPJ2ypTgJs= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXfIP008002 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:41 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE113.ent.ti.com (10.64.6.34) 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:40 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE105.ent.ti.com (10.64.6.26) 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:40 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXdP3128923; Thu, 22 Feb 2024 05:33:39 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:34 +0530 Subject: [PATCH RFC 18/21] media: ti: j721e-csi2rx: add multistream support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-18-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=5889; i=j-luthra@ti.com; h=from:subject:message-id; bh=Uk6tns0lOkArX4B5O1OscMnEfvQbP1P99m1HGZqaO9k=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDriY0aL26RG33DbX8+UJWo9eYF46K8+paTt VYsJTs9C6KJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw6wAKCRBD3pH5JJpx RVXyEACDi0DA7PqiRCqE8h72alwKttVtCliVrDLsmfOYmRcO4MMganEMxMcpklMgSpPSdlvIZhD 02i6vjEEKIg0U3cW139gb0NuMQ35JeTrNrLduZ4ScI3rkpQfWjoxOKjqgNPzbhysp428T8AY37p 3t8xGtDsTZLZBTHFd2V6mwEut9FLSbinWsyfwEFGzgBg8XgKe5H8xMj3iZ74i4chLiVQeYgSC6r nUkLL9Og1UWaF7REAywqxavAIAg3FtDsc7pxQsmyhTjUgQHMU2zRCyrQpcSC1fZlbnKmmM94qAk yG/+9OUrSRN/ZyV/+rGyCZkk1t46kW3SFMXdNq+UZ7GETg6EP3X3M77pVJsrTxMZuBAY6bkSu4C ImCIB7TFGG7XhbZmbOM+v8j1zZ7UHXS4S3LQfzXyqw39z9sdfCUngyQlvKj+5KFw0dv19f11644 ahSxyE+D7scxmG+iOWE0TAPVrocX7ie3rWNnREDM0ru+XAXHTaJDDHxxznPajZYktvfU76XVNSk JFplA9i6GMdWin1FJeXvxfSKQKFNwa+d9cg2I+DCytKW/JnrPOnMT4loO12J4OJd3+tGRpNuwLa dwloRFNaXBzT1qlofM9ZjrxDPh9TvP6ZsYadIqJpdLgBhSTTzNw/lLoQj9EdlsixXj054qv1GgJ 7YrN9bjF+fzwrPQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599008251494665 X-GMAIL-MSGID: 1791599008251494665 Each CSI2 stream can be multiplexed into 4 independent streams, each identified by its virtual channel number. To capture this multiplexed stream, the application needs to tell the driver how it wants to route the data. It needs to specify which context should process which stream. This is done via the new routing APIs. Add ioctls to accept routing information from the application and save that in the driver. This can be used when starting streaming on a context to determine which route and consequently which virtual channel it should process. Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 110 +++++++++++++++++---- 1 file changed, 93 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 4be8a306ac1f..b33681e1e2db 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -905,8 +905,12 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) struct ti_csi2rx_dev *csi = ctx->csi; struct ti_csi2rx_dma *dma = &ctx->dma; struct ti_csi2rx_buffer *buf; + struct v4l2_subdev_krouting *routing; + struct v4l2_subdev_route *route = NULL; + struct media_pad *remote_pad; unsigned long flags; - int ret = 0; + int ret = 0, i; + struct v4l2_subdev_state *state; spin_lock_irqsave(&dma->lock, flags); if (list_empty(&dma->queue)) @@ -919,6 +923,40 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) if (ret) goto err; + remote_pad = media_entity_remote_source_pad_unique(ctx->pad.entity); + if (!remote_pad) { + ret = -ENODEV; + goto err; + } + + state = v4l2_subdev_lock_and_get_active_state(&csi->subdev); + + routing = &state->routing; + + /* Find the stream to process. */ + for (i = 0; i < routing->num_routes; i++) { + struct v4l2_subdev_route *r = &routing->routes[i]; + + if (!(r->flags & V4L2_SUBDEV_ROUTE_FL_ACTIVE)) + continue; + + if (r->source_pad != remote_pad->index) + continue; + + route = r; + break; + } + + if (!route) { + ret = -ENODEV; + v4l2_subdev_unlock_state(state); + goto err; + } + + ctx->stream = route->sink_stream; + + v4l2_subdev_unlock_state(state); + ret = ti_csi2rx_get_vc(ctx); if (ret == -ENOIOCTLCMD) ctx->vc = 0; @@ -1019,8 +1057,8 @@ static int ti_csi2rx_sd_set_fmt(struct v4l2_subdev *sd, } *fmt = format->format; - fmt = v4l2_subdev_state_get_format(state, TI_CSI2RX_PAD_FIRST_SOURCE, - format->stream); + fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad, + format->stream); if (!fmt) { ret = -EINVAL; goto out; @@ -1031,24 +1069,61 @@ static int ti_csi2rx_sd_set_fmt(struct v4l2_subdev *sd, return ret; } +static int _ti_csi2rx_sd_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_krouting *routing) +{ + int ret; + + const struct v4l2_mbus_framefmt format = { + .width = 640, + .height = 480, + .code = MEDIA_BUS_FMT_UYVY8_1X16, + .field = V4L2_FIELD_NONE, + .colorspace = V4L2_COLORSPACE_SRGB, + .ycbcr_enc = V4L2_YCBCR_ENC_601, + .quantization = V4L2_QUANTIZATION_LIM_RANGE, + .xfer_func = V4L2_XFER_FUNC_SRGB, + }; + + ret = v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 | + V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING); + + if (ret) + return ret; + + ret = v4l2_subdev_set_routing_with_fmt(sd, state, routing, &format); + + return ret; +} + +static int ti_csi2rx_sd_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + enum v4l2_subdev_format_whence which, + struct v4l2_subdev_krouting *routing) +{ + return _ti_csi2rx_sd_set_routing(sd, state, routing); +} + static int ti_csi2rx_sd_init_state(struct v4l2_subdev *sd, struct v4l2_subdev_state *state) { - struct v4l2_subdev_format format = { - .pad = TI_CSI2RX_PAD_SINK, - .format = { - .width = 640, - .height = 480, - .code = MEDIA_BUS_FMT_UYVY8_1X16, - .field = V4L2_FIELD_NONE, - .colorspace = V4L2_COLORSPACE_SRGB, - .ycbcr_enc = V4L2_YCBCR_ENC_601, - .quantization = V4L2_QUANTIZATION_LIM_RANGE, - .xfer_func = V4L2_XFER_FUNC_SRGB, - }, + struct v4l2_subdev_route routes[] = { { + .sink_pad = 0, + .sink_stream = 0, + .source_pad = TI_CSI2RX_PAD_FIRST_SOURCE, + .source_stream = 0, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE, + } }; + + struct v4l2_subdev_krouting routing = { + .num_routes = 1, + .routes = routes, }; - return ti_csi2rx_sd_set_fmt(sd, state, &format); + /* Initialize routing to single route to the fist source pad */ + return _ti_csi2rx_sd_set_routing(sd, state, &routing); } static int ti_csi2rx_sd_s_stream(struct v4l2_subdev *sd, int enable) @@ -1087,6 +1162,7 @@ static int ti_csi2rx_sd_s_stream(struct v4l2_subdev *sd, int enable) } static const struct v4l2_subdev_pad_ops ti_csi2rx_subdev_pad_ops = { + .set_routing = ti_csi2rx_sd_set_routing, .get_fmt = v4l2_subdev_get_fmt, .set_fmt = ti_csi2rx_sd_set_fmt, }; @@ -1288,7 +1364,7 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) v4l2_subdev_init(sd, &ti_csi2rx_subdev_ops); sd->internal_ops = &ti_csi2rx_internal_ops; sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; - sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE; + sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_STREAMS; strscpy(sd->name, dev_name(csi->dev), sizeof(sd->name)); sd->dev = csi->dev; sd->entity.ops = &ti_csi2rx_subdev_entity_ops; From patchwork Thu Feb 22 11:31:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp191539dyb; Thu, 22 Feb 2024 03:39:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX1FzKJzbFM1qz7HoAi1K0uWICT4zprxkLAGTN2RAw4KJ8ObNgnTrpa9H9qcdUbX8AsqdajO/IHPdEp0Va8J/vIYaHNIw== X-Google-Smtp-Source: AGHT+IFTg3enYUc4syFHA3fCyVMH942rxbkS0JH+zqap5hiHcm+rmftj9ECE59eC7HpoXocFrzIE X-Received: by 2002:a0c:f147:0:b0:68f:477f:fb36 with SMTP id y7-20020a0cf147000000b0068f477ffb36mr14410736qvl.58.1708601984352; Thu, 22 Feb 2024 03:39:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601984; cv=pass; d=google.com; s=arc-20160816; b=UC3enFBDo20QODvmGxF4kNqqTG7iGYpEBkc/1S0N9VD2wVeJGqXcU9XF4IHR2hV6ka kH6zf/OduDFaRsv+MG54TPUhRznSUiruAovpm4HuDqrvA3eyNzaYTpGjMGbTPK5B052s UHfUg/rBX5aSJV/Th9Gzq3HTWcvR5Nn9SO8hT1pGanW8q9DVX6BRqJXCnvObPLMn4jPg kixX3+9+pD81ESuZ5+jr0LSHit1Pz0Cj41sNOnLHbITm72JLLhCef/OCPhqtgWPkWtrz Xg4UhBJWGJxgIeZZC/4NR+14jwsbWYkF6/1b0H5JEZaLMTxAk7z0b2S9wjIOw3/XrC1i 8J/A== 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=/i5M1vv4BeDdGkOVkUnx+Hn/FIm8GsBXtMFZcAlL/os=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=wWcbV8DtcCwUhufIiDpld+M3Jh78E8gNnAn7nvhQYrljVy1GpUZB4pCn07UDUd6q49 BMRyxAJBQlDqfdMYGCZU269Adyh9y03ih2rtl90QxjFM+pQOI3Z9/M9xsYkSTrVJCYnL K2xYjqviqsndLb472xB+J/CUBSeKryZ2cx/A8OarRmzb8eQWPVTSUBntt+nXg/G0NgNH MDouHHLSOG8FOTx0jip/ZPlhq0MfB4mcFa6YZmoIl0RH0XoJsft5rZc+EbmUX6sbjMcu vrmfsA/xwJIn0fqwiu/1ACux/kkPSHnexZE/f9Wqh2lsdLSC0CFYPjqtHrebx66nkCVK fEmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="Y1j/mfEO"; 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-76434-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76434-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id kd19-20020a056214401300b0068fcd33c8d7si26025qvb.91.2024.02.22.03.39.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:39:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76434-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="Y1j/mfEO"; 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-76434-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76434-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0DE701C23641 for ; Thu, 22 Feb 2024 11:39:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CB3058112; Thu, 22 Feb 2024 11:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Y1j/mfEO" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 8EC0756455; Thu, 22 Feb 2024 11:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601639; cv=none; b=JvhVGLaKDVHlbXqJxXZZ4J8jQ27GhUOLpeXcg3Bkayn2Rgb53sY8ZbLCp3xJ65yspZi8iDgkPYJtzr7j8lYD9q2zoONVgDvv/tRH+ccCLkllnkQpDYMV+2Fmn7Racjbj8DHu89SxgkEd16OONIUt143vsQKeZRhaC+1mgtO9Vlo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601639; c=relaxed/simple; bh=atXyNk7GB+hJTN0fsQot5GwC/uENkkECLZRLShv8k+I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=lcK4vcQKMv9k2FxAXBIgkGK2xV4QnAZERr9wfBFEOCXyM6ovh4e3LB4FVc3Ke3x/0t2+WEtdEFPfHuNW60AbghsvL10Vox1SCOGoxPL0jBheLBuHt9K0Pir7Zb7hpdwOHq6AmQqQ6nwWAeo4MjbdDtdA5QiPr+CQnR2ic37+n50= 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=Y1j/mfEO; arc=none smtp.client-ip=198.47.19.141 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 fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXgtJ059188; Thu, 22 Feb 2024 05:33:42 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601622; bh=/i5M1vv4BeDdGkOVkUnx+Hn/FIm8GsBXtMFZcAlL/os=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=Y1j/mfEO+3HvAox0QNPTQ/exhwgRQzS4J8ZxruB2AWbEIfXbrXHyNFXL/1YsCCN6d QxFKWPC4mbLQsoVt0WuQmPSctHRD7R15myyt1NI1XStnvwCwjJCAaYhmKmtDB0HpQM gwy0F4yIsRRZp7w6WBHoGt+Dyww3UpPovnrj/ZBM= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXgEV014411 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:42 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE112.ent.ti.com (10.64.6.33) 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:42 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE106.ent.ti.com (10.64.6.27) 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:42 -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 41MBXfFr091559; Thu, 22 Feb 2024 05:33:41 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:35 +0530 Subject: [PATCH RFC 19/21] SQUASH: media: ti: j721e-csi2rx: Enable per-stream controls Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-19-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=4259; i=j-luthra@ti.com; h=from:subject:message-id; bh=atXyNk7GB+hJTN0fsQot5GwC/uENkkECLZRLShv8k+I=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDspQ0qdgETFHF001RaowVVFDW+jd5UTTuLk tihlIECxAKJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw7AAKCRBD3pH5JJpx RV5GD/9wmuxokjgrkDCLH9qrTkzz1CdmlgTUYvg+3/n7gSkq0Hi/N29wErDzPMvvmj2LUcPU0fQ CwL+UOFYxCl2hID0WOFVvkklcoaXK0NC1V9ccT1METHPpK9/impOl5M4JqiJZTl8hoZetU8i1Ii 7Zq18Fn0IThRVPNHoCajGshkMcmP3twUlNGWRZGGawaVh+dBYfxo9hjgwHPvZhBNvYzQsWVwesm bTt2goc3J0UmEc7Yw8g3CbAZzUwHJMswXHKfTRR5RUzJF+Cf/tptSj3G9Mt6PadsrfmhUpTbSDb 8K8LGf0TJDbeWsnpGIaoRrG3xvKKOlImpIfAmm05/JgTrbgYXujD0bed9t9I7nrlNsCAbBBJH2E mfnfZ/r1y/ClFYs0zUVf7NgKTtPXxV9jlXI4XmuXzyUNKak7LufPtFu1urP0tltGIOyoHynB3D2 fSUzuZ+ux2YNTQByORtWh5UhqhgJ9uI7lpA4gwEZNxJHg8zuo2fTrQf+WamlDpSpMB8vvuVBw2Q WNFsBij1VDwJ/f6X4UM3U87119FuAN1dfZlgUAhtLxJ1t6Lhy8SbfGJyET6gfCdb8xJqs0IO1w2 278RgxZMilq9Ksv0dOlXfPd+Mkt/CY/S7cefYEPRlQuJpAyIK9sjnd8B7iO1ynEihV4mVe0bvy2 YtF062WkPh6pkNQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599034158514893 X-GMAIL-MSGID: 1791599034158514893 Use the new enable_streams() APIs to start/stop individual streams on the connected subdev when capture is initiated on the corresponding v4l2 device. Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 78 ++++++++++++++-------- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index b33681e1e2db..c2d47507b3a7 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -983,7 +983,9 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) dma->state = TI_CSI2RX_DMA_ACTIVE; spin_unlock_irqrestore(&dma->lock, flags); - ret = v4l2_subdev_call(&csi->subdev, video, s_stream, 1); + ret = v4l2_subdev_enable_streams(&csi->subdev, + TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx, + BIT(0)); if (ret) goto err_dma; @@ -1011,7 +1013,10 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); - ret = v4l2_subdev_call(&csi->subdev, video, s_stream, 0); + ret = v4l2_subdev_disable_streams(&csi->subdev, + TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx, + BIT(0)); + if (ret) dev_err(csi->dev, "Failed to stop subdev stream\n"); @@ -1126,36 +1131,60 @@ static int ti_csi2rx_sd_init_state(struct v4l2_subdev *sd, return _ti_csi2rx_sd_set_routing(sd, state, &routing); } -static int ti_csi2rx_sd_s_stream(struct v4l2_subdev *sd, int enable) +static int ti_csi2rx_sd_enable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + u32 pad, u64 streams_mask) { struct ti_csi2rx_dev *csi = to_csi2rx_dev(sd); + struct media_pad *remote_pad; + u64 sink_streams; int ret = 0; - mutex_lock(&csi->mutex); + remote_pad = media_entity_remote_source_pad_unique(&csi->subdev.entity); + if (!remote_pad) + return -ENODEV; + sink_streams = v4l2_subdev_state_xlate_streams(state, pad, + TI_CSI2RX_PAD_SINK, + &streams_mask); - if (enable) { - if (csi->enable_count > 0) { - csi->enable_count++; - goto out; - } + ret = v4l2_subdev_enable_streams(csi->source, remote_pad->index, + sink_streams); + if (ret) + return ret; - ret = v4l2_subdev_call(csi->source, video, s_stream, 1); - if (ret) - goto out; + mutex_lock(&csi->mutex); + csi->enable_count++; + mutex_unlock(&csi->mutex); - csi->enable_count++; - } else { - if (csi->enable_count == 0) { - ret = -EINVAL; - goto out; - } + return 0; +} + +static int ti_csi2rx_sd_disable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + u32 pad, u64 streams_mask) +{ + struct ti_csi2rx_dev *csi = to_csi2rx_dev(sd); + struct media_pad *remote_pad; + u64 sink_streams; + int ret = 0; - if (--csi->enable_count > 0) - goto out; + remote_pad = media_entity_remote_source_pad_unique(&csi->subdev.entity); + if (!remote_pad) + return -ENODEV; + sink_streams = v4l2_subdev_state_xlate_streams(state, pad, + TI_CSI2RX_PAD_SINK, + &streams_mask); - ret = v4l2_subdev_call(csi->source, video, s_stream, 0); + mutex_lock(&csi->mutex); + if (csi->enable_count == 0) { + ret = -EINVAL; + goto out; } + ret = v4l2_subdev_disable_streams(csi->source, remote_pad->index, + sink_streams); + if (!ret) + --csi->enable_count; out: mutex_unlock(&csi->mutex); return ret; @@ -1165,14 +1194,11 @@ static const struct v4l2_subdev_pad_ops ti_csi2rx_subdev_pad_ops = { .set_routing = ti_csi2rx_sd_set_routing, .get_fmt = v4l2_subdev_get_fmt, .set_fmt = ti_csi2rx_sd_set_fmt, -}; - -static const struct v4l2_subdev_video_ops ti_csi2rx_subdev_video_ops = { - .s_stream = ti_csi2rx_sd_s_stream, + .enable_streams = ti_csi2rx_sd_enable_streams, + .disable_streams = ti_csi2rx_sd_disable_streams, }; static const struct v4l2_subdev_ops ti_csi2rx_subdev_ops = { - .video = &ti_csi2rx_subdev_video_ops, .pad = &ti_csi2rx_subdev_pad_ops, }; From patchwork Thu Feb 22 11:31:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp195271dyb; Thu, 22 Feb 2024 03:48:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWpF1/1LIFYmH8JqFEg5fu32gaYBo1nAjy8rAD8MO6Rwi8LdUilRWOJREIrBQtMIOGdVYI+5l9fOiqFNNG22Rrf3jKExw== X-Google-Smtp-Source: AGHT+IGTCFJFvTq+a281qVhApsh7tG2l3SNT2NK/AYqemugKJQY1asfdF9Cc52zvu2SeAyOYmhhS X-Received: by 2002:aa7:dd02:0:b0:565:43e7:7b5f with SMTP id i2-20020aa7dd02000000b0056543e77b5fmr853592edv.5.1708602492711; Thu, 22 Feb 2024 03:48:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602492; cv=pass; d=google.com; s=arc-20160816; b=um5C3TNm7BdJN1guIarw+9gR7gtlTgINf6DPERVzqQW1XWgNIzdiPUPvUDuEIYkLRZ 4D7Yc3ied6uXutCFWvRuDs9/8NesFjR+G88x56V/LMZ0u7XS6zPYx9Y+z3x0sDiX89kJ pfYEMXYWB8wkjwj8PLFEWAqVAC++RS/xeu0HAypF8jstrXDBinVdDPUy58hK4dUyLV46 oCpQ0IR737doX0uNsJi6aiYPAVnWl3c4LEO7hsxHKn9iyfqZBPKuyrkA1NlpKCGCLuJO yMr1eRSfnQ8fyDdtg4FSKqfGg5xCK68Ro3IVr3pN443o3VLion1h7HHaDPIgcfsDdvM4 CDyQ== 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=h4Cf3SOkx3K5Auy7bEc25EsHCsaRMY7o1BWV1atNTG4=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=xaCoknkyMbwz2Fyujd8RXPlQdqFUiy73/CG7rnEU0IY3sP3NrrMKCAgFeNtwOMrdOD u6gym9jlh0dxYdPwKstRyhgZyRU47yssy/J4+9koMH95VXs5zm9uyhJQr4IlA4cVdGA9 kxhYNlhdJAwiwi1hiim2C/4poUaNvgxc4vnxTc8i50xGC1z/JZZKVrl12kH7cNLNHNci suOXZ0LCXZf9G9Cx3io06oxDjmIdmrsLdgNTXsVtW2Vw5lrqj+4WT52lfirs/oLNRVlj rb00GRe5EAfYWRUp8L2Njcy7rPkYLUloQECiIpifgoizt5cCcwCWmHqQBY/gptpbL9++ vjUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="kMqR/1EM"; 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-76433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76433-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n22-20020a509356000000b00563cfa60977si5286471eda.360.2024.02.22.03.48.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:48:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="kMqR/1EM"; 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-76433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76433-ouuuleilei=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 06D561F29A6B for ; Thu, 22 Feb 2024 11:39:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7FF757894; Thu, 22 Feb 2024 11:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="kMqR/1EM" 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 4395F5646A; Thu, 22 Feb 2024 11:33:56 +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=1708601638; cv=none; b=mi1Ve1womNP0/LtDzgpY36zaFLUNCIIYNpkttnSxTxLSgYAJ4HqqaqimsJCGbFpI/gAezr4pDlEuGzy2GR2DbXixu0sqhvym8uRtSBxQuNuLlXcBP4YIPNxUK/6ovL48pXCmrjXf96KBP0HLsqlC0V/YTowPwQG2TRncRKypm3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601638; c=relaxed/simple; bh=UHhcmDEpCe+fIBZF6t/hU6vqn9E2M2zqDvurAxx6H4c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=ZcutceKj2MWJSVaO8An4H6IykPmEZbK5yDFsAjWYN8TBh++qO7D2+yS91TFoHgwU9WocHpV70J+NILSeXEA23VQtjipdGUh+VyQGw9tzjDZ/8ihvpdw43keKmcd4mHcJP+zZtP1DZk2MKvrVS9WLHgJFw/Qp0BME4KgxVhHcAkw= 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=kMqR/1EM; 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 fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXif6027847; Thu, 22 Feb 2024 05:33:44 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601624; bh=h4Cf3SOkx3K5Auy7bEc25EsHCsaRMY7o1BWV1atNTG4=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=kMqR/1EMKXtPJF73iXF9EFR+Y8migT5oWQly0ShGGHk1tNyazg2dN9pf3i90iyyyq MlNY9Nxjw8/m/6Nfw8hCpWTvBVNgdY1Dzl43o5c2/Q4ASpnH9U7E3wUdrkOPm4+hJE +8Vp404BBqusysKBxjmaXPvmjJI0syFNGZby7PWU= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXiVH014442 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:44 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE102.ent.ti.com (10.64.6.23) 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:44 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE110.ent.ti.com (10.64.6.31) 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:44 -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 41MBXhGP091587; Thu, 22 Feb 2024 05:33:43 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:36 +0530 Subject: [PATCH RFC 20/21] SQUASH: media: ti: j721e-csi2rx: Assert pixel reset before stopping last stream Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-20-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=1832; i=j-luthra@ti.com; h=from:subject:message-id; bh=UHhcmDEpCe+fIBZF6t/hU6vqn9E2M2zqDvurAxx6H4c=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDtxulJ5vwh1hk7rUtv04y9hAoMjlAfOaM/I 946Exq1leuJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw7QAKCRBD3pH5JJpx RXT2EADGCihGFKE4jnCo389SggQfrAJRxINhD00hY+I8PSgr5Q8Dphg/C/Wjb8E0bPcqoebJLhs EWC+WB2CDiGO/GxMyeZiMxOHqVWOJeRXDEBaZzkaOzu0wCg8tb31WopXSrBvz9e7IcsTM6ilVSV mp7hlpiXzCofr/F/lAY3TWkKzkzgF3Ix8j6lZiO9l4JiMzduDQT4FlRcP1sV3Ay+mq5gxsbJnjQ fSpo9m3cO+YgY9p4+qhhekjagSAD/NG4QZ6TTdeYCnC0CBgb/6qRaznGv0EEIhilw6MCpkqGgME m/oBtaHC+lEViiolUOvsTOjv4Pm5aKRNhUC7YMMyET0H00qy8lSBbnd5bvib4W6icXUJd0Lz2TX Vlo/d0mx7s68KFtd+0E3uN77ni1AyR+uBZzW3qTZOq2Hf4pt/s9RBKG2DS59+cI0kMHmThgbUZZ T7iRcIKMgAHoA38iBktZToF+UC8VmAN6pqY9qVcQWLtGVNWz0BI24ZtuVkCL2DjEzpRcNY38jmn l1Xp0bhXL0dEwm3RwfvQbWYxYINVSalySZt4zFTmy0eVw6kNaly2Xfdw3FF3H6GVUJ3adN8hp17 9iFu2Z1XJgwv2Vr6xwCxqOa5T5LbU8Q37F79vnGJ/rztw/v8PbUycns2T8lQiYQm9HUYqjsjqje eMNosTG92fZifng== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599567234613416 X-GMAIL-MSGID: 1791599567234613416 With multi-stream support, make sure pixel reset is only asserted when last-stream is stopped. We assert this before stopping the stream to prevent issues with module unload/reload. As the device's power domain cannot be cleanly switched off by the firmware if stale data is present on the PSI-L endpoint, which can happen if source was streaming but we pulling data out through DMA. Signed-off-by: Jai Luthra --- drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index c2d47507b3a7..0b9e0852da9f 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -560,8 +560,10 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *ctx) fmt = find_format_by_fourcc(ctx->v_fmt.fmt.pix.pixelformat); /* De-assert the pixel interface reset. */ - reg = SHIM_CNTL_PIX_RST; - writel(reg, csi->shim + SHIM_CNTL); + if (!csi->enable_count) { + reg = SHIM_CNTL_PIX_RST; + writel(reg, csi->shim + SHIM_CNTL); + } reg = SHIM_DMACNTX_EN; reg |= FIELD_PREP(SHIM_DMACNTX_FMT, fmt->csi_dt); @@ -1008,9 +1010,11 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) struct ti_csi2rx_dev *csi = ctx->csi; int ret; - video_device_pipeline_stop(&ctx->vdev); + /* assert pixel reset to prevent stale data on stopping last stream */ + if (csi->enable_count == 1) + writel(0, csi->shim + SHIM_CNTL); - writel(0, csi->shim + SHIM_CNTL); + video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); ret = v4l2_subdev_disable_streams(&csi->subdev, From patchwork Thu Feb 22 11:31:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp191547dyb; Thu, 22 Feb 2024 03:39:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXw4Qg6d4fSl0ljnUeOjgTfb1mAWIWz94eWAdbLDPxqc+HI2j8eDSkTzpDGelhQdXjGgGC710EWj5K1xlmPoXwdp7UgIA== X-Google-Smtp-Source: AGHT+IHufBap1DUMKeO53MFwnIGLLmQVwOHnQdOrG6ATY66PxBywli9SHsaQEIklMr2tHBq3HTF+ X-Received: by 2002:a05:622a:40a:b0:42c:7ca2:8ab2 with SMTP id n10-20020a05622a040a00b0042c7ca28ab2mr27714013qtx.48.1708601985860; Thu, 22 Feb 2024 03:39:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601985; cv=pass; d=google.com; s=arc-20160816; b=aV7La13UJMN6iWrFymSLA46zNLLm1kcBR7Sj1af5DaVXVdU7eXS7eLOegRCrqqf+rP TKhL7qqr/xrE8l2SptNmruH/UuOMQTw94prWm8sj4cpD6cV5NCq3vIICbalOzyLeI3OP Zu54+tpo/Jm5eTkMVguEp8Ww2hATVq9WgqBfnGyjQ0u8EvVg/MM87TAOfGc0ymo6EhK5 opQV7K2YFhzgfV9ysTJdBSp+w9Ak4STFL2c/+eMB+/fVHnCl24bdPr6eVgUA8bXli6sL bX/H+6yFcry13LBztkJlUuUZT9hZrkc5jFQ0fXR3iyvyzgNTW2BZ8t5WRC9lccjPiBo/ 8DvQ== 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=Vlbz21goACtx1c8zMXtgD7uoZ9QnG6VdgKVSgHpupv8=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=Dnf0/v+7RVlbIMSXh6xezyB76estHc6DYho7tASeScLk/G4iijgIiu0yilQJpuvUBW yl1lbONdZ5mo8hPSFjlAONIDclHqQdOUztP2ttZOv51Zn1V3Twi/GeP+yBFyeFnZ/pov 6ojU9UQjWxwo79d1C9qv53MTZbDtaErfZPYvQlLF2a0bFaWLkHn+RFaat9CdyJHK7cd9 LZm4XP7hTHtffC71wAZzz5WAzFfoag5Ge421HNypFyliZDQQOLmETcVtwF5uxXqBzaPY ICJxGWVKr72haTMstoqEpDecSybdm5fh3XXJ248rRCWWj0UkKxarlfcn/Vg/qMb6O6k+ 8yUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WtlcC9am; 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-76435-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76435-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p9-20020ac87409000000b0042e286668fbsi5237243qtq.246.2024.02.22.03.39.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76435-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WtlcC9am; 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-76435-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76435-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 957A41C235DF for ; Thu, 22 Feb 2024 11:39:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C210E5811A; Thu, 22 Feb 2024 11:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="WtlcC9am" 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 EE9B856471; Thu, 22 Feb 2024 11:33:57 +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=1708601639; cv=none; b=UlJALKChW7b+AR1pM+qNepFcS9/vPdNUZMVB8wgb9tzJrJEgFn/m6JrP5zYOi0fxb7b0IytBfpk3Ohl4SRbWG8aOiflbcziQd1tajIbk5nosZDiUFbc+5O6peYhVQ1jrIZUdly53OUoiA4tdTfhC9O4IsCV09ToVJS1hYxeQHC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601639; c=relaxed/simple; bh=/GtmPjLiq5+SagkrfDQAkAZP5XRkWs7T9sGKIVhkkz4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Qo7sSWTGa5/6ESs+jIpER050MymYdiU0sBVLo2xfbUCRFMmPRS66NHAmHFXa+iYqgM3xtQDehEc71wiuGMBLDHTL7fNHSk52n4M0qmlU/QheDQruuenx70rZHPhaMmPEE7yEv87N1xN9FY0mlJbzkwcdorL9UfrZLObthY7/4WM= 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=WtlcC9am; 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 fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXk50027853; Thu, 22 Feb 2024 05:33:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601626; bh=Vlbz21goACtx1c8zMXtgD7uoZ9QnG6VdgKVSgHpupv8=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=WtlcC9amfGGCuR1WryWRG8vcT8UQA4iOk70DW9csiMHCyI5cwdZ/Rp7cLPJfN43+i owusU6Vw+I15sXQC5Mc2JEq+sWU42S/88MxS+rJzLeN0ai/BMQuxfwGpXzVMf86Iyj yheibmUbAhRe6TyZq+du3OSEEuWi8I0CmmjPP5ps= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXkVR014493 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:46 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE112.ent.ti.com (157.170.170.23) 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:46 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE113.ent.ti.com (157.170.170.24) 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:46 -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 41MBXi5B091622; Thu, 22 Feb 2024 05:33:45 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:37 +0530 Subject: [PATCH RFC 21/21] media: ti: j721e-csi2rx: Submit all available buffers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-21-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=3577; i=j-luthra@ti.com; h=from:subject:message-id; bh=/GtmPjLiq5+SagkrfDQAkAZP5XRkWs7T9sGKIVhkkz4=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDuro/ycwjO5PCLQrJiQETtI9R/Rz8V16qhH NGhUvuH9NSJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw7gAKCRBD3pH5JJpx RcEsEACXdlnzSwdPg09vRskjpB2V19aq2bTmJA5wMNKnsdqtyZms6Bks+K2NFIVccg7T1/kzOsW 21J9BXbvl9kotNHmiC9Dym6GGPX8PwSeER9ta/k67oEp+jcLqNYx013SDvmirXcBYKYrDjOb+ZK PyW8Aey4CRxqsLVo84BfWikCJuU6HNIE2puO47t+iTEm106GAwZLJpPDLJZjUfHd5FmEtJmwf07 GxK7+RFUfzaOkwgbNmg7qYMuL+UkMEBqONYDlMSopQhewlpGij1rsIVGsW5vLCcW1Dojq4WiPJj oItB+ePyFD9u5TGgSQM4oFeKZyDR5txG2VSuVbEkMlBWW6c/UVSIaNZppxUfDusr2DaOwYkpeJp LdfnNLEY75vdjHWlStzsNncC7n2ndrX3uHAs92XKsV8o7aXsfrHxOpl/xC/DbaPTVPVPMqt3Oce bTgrBXsX0fwr+um1f15uqHeXlGeDbEEtfBptF0zYPGutkfVdgDc1VcA5VP3NCHIVd7XCAIDinUT sNZWmtKUL5gU2x1/2bfEP7/C41y05IfuKLnqaTs4oTrkvp4QI7E1dA1+XZJiBo31NlTnxOuqKf+ 1s0zeZJK7Mk5e9BZ4FbNOSASxr64396RCo+TiU7XyvcpM2NKQ79DAybYUEbEzsIEDqPSXEY39rh +8lm46CyNyVOlnA== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599035755528112 X-GMAIL-MSGID: 1791599035755528112 We already make sure to submit all available buffers to DMA in each DMA completion callback. Move that logic in a separate function, and use it during stream start as well, as most application queue all their buffers before stream on. Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 43 ++++++++++++---------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 0b9e0852da9f..a682db099e6c 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -666,6 +666,27 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *ctx) return ret; } +static int ti_csi2rx_dma_submit_pending(struct ti_csi2rx_ctx *ctx) +{ + struct ti_csi2rx_dma *dma = &ctx->dma; + struct ti_csi2rx_buffer *buf; + int ret = 0; + + /* If there are more buffers to process then start their transfer. */ + while (!list_empty(&dma->queue)) { + buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); + ret = ti_csi2rx_start_dma(ctx, buf); + if (ret) { + dev_err(ctx->csi->dev, + "Failed to queue the next buffer for DMA\n"); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + break; + } + list_move_tail(&buf->list, &dma->submitted); + } + return ret; +} + static void ti_csi2rx_dma_callback(void *param) { struct ti_csi2rx_buffer *buf = param; @@ -686,18 +707,7 @@ static void ti_csi2rx_dma_callback(void *param) vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); list_del(&buf->list); - /* If there are more buffers to process then start their transfer. */ - while (!list_empty(&dma->queue)) { - buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); - - if (ti_csi2rx_start_dma(ctx, buf)) { - dev_err(ctx->csi->dev, - "Failed to queue the next buffer for DMA\n"); - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - } else { - list_move_tail(&buf->list, &dma->submitted); - } - } + ti_csi2rx_dma_submit_pending(ctx); if (list_empty(&dma->submitted)) dma->state = TI_CSI2RX_DMA_IDLE; @@ -906,7 +916,6 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vq); struct ti_csi2rx_dev *csi = ctx->csi; struct ti_csi2rx_dma *dma = &ctx->dma; - struct ti_csi2rx_buffer *buf; struct v4l2_subdev_krouting *routing; struct v4l2_subdev_route *route = NULL; struct media_pad *remote_pad; @@ -972,16 +981,13 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) ctx->sequence = 0; spin_lock_irqsave(&dma->lock, flags); - buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); - ret = ti_csi2rx_start_dma(ctx, buf); + ret = ti_csi2rx_dma_submit_pending(ctx); if (ret) { - dev_err(csi->dev, "Failed to start DMA: %d\n", ret); spin_unlock_irqrestore(&dma->lock, flags); - goto err_pipeline; + goto err_dma; } - list_move_tail(&buf->list, &dma->submitted); dma->state = TI_CSI2RX_DMA_ACTIVE; spin_unlock_irqrestore(&dma->lock, flags); @@ -995,7 +1001,6 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) err_dma: ti_csi2rx_stop_dma(ctx); -err_pipeline: video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX(ctx->idx));