Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp279324rdb; Thu, 22 Feb 2024 03:37:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUjHQdCvwwXXNrB4t+2+AY7ya5HZ+1Jkf6e3JVmOhaOoLT/IiwqIE5jtcckpRxQd/i8K40dnZxb7EuhLY5/s9vD+FLQi0yJuQnzi18ncw== X-Google-Smtp-Source: AGHT+IFARRclVmXPVTk4hKyhWf5UKzcHjjNgnDyZT/OcXhT7wixyJaGIqzQXuwyemnNCv7GGNrY2 X-Received: by 2002:a17:902:d484:b0:1d8:ff72:eef8 with SMTP id c4-20020a170902d48400b001d8ff72eef8mr3054644plg.18.1708601837574; Thu, 22 Feb 2024 03:37:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601837; cv=pass; d=google.com; s=arc-20160816; b=rAHRNWpLr1FQmv5oWd5crfqBNS2Ew9IGcfvCF3L+AK8t3ZoZEu546E3OMz1vtLWEn1 jnxA28GbNlaYeI0DEQV2gb94LU86aBrxdEDU+8tT1v1vApR7LAzYeAWo4XBATqBwaZIV qsff/DgDqEAG8Rykxzghyn6V7zpXH+rvCLQOevA3m65WAtVrDgUUYHkqHPoRAQzWoTQd AUhytXTQkNXb/69FY1lyqmn/QsUCwulRg57CXUArD1QZ3lxRg5eQXexI/2LHThMnQ6Lt lfdgTc2itvRi7Ds7qNRMvinfG3+SgXeTzm1wdF6iX87SEujG1gOwo3TRpA9Z7G47qLsn emkQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76428-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e8-20020a170902b78800b001dc4a8d0dc0si1209828pls.8.2024.02.22.03.37.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:37:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76428-linux.lists.archive=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=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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76428-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 447B5281976 for ; Thu, 22 Feb 2024 11:37:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5768553398; 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="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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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; -- 2.43.0