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;