From patchwork Thu Feb 20 14:17:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 866959 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A82B7204874; Thu, 20 Feb 2025 14:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740061074; cv=none; b=E4IC6dEovCe52qOVe4rEwSdhk1G2pj6Gs6fOLkRUu0gCOjWUxBrM2MhXecLE2ubHWFvYL8+WQgZibpYKqEmkIEsm+Sd+Q4UBLJDxdKdpnGx36gBWSDELL05tuYnnYlUaG6Hoj1n0hyXz/t9xvajhf/RHorbhM/YPoC67ByNmJmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740061074; c=relaxed/simple; bh=CWodvW4NCBIlUv6/PqgOLyTNVvQ6Z0Bh5b4w0MpQRQY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cmEbJO6ELEj+5ZtJQrKxF9uenuYuD7DUGHVHHKfxNf8i1goGeCzRHlSRBZkTuKM+n2h4OrTE0doH+UShmtVZVpJ2sE7ymGx8jW1rXkMUg7ovFy+rhoO5kF09bd0+Hd1s9yX/Q8ffz+HlLUdR/xrhgcTZJPnL4N0EdQPAjWzHdG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EtKKK1Dj; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EtKKK1Dj" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5e02eba02e8so1319409a12.0; Thu, 20 Feb 2025 06:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740061071; x=1740665871; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ku1J4a4L44q8po1KQAtOYx7Ff0tpcPyGvZxYWms+JUM=; b=EtKKK1DjPLxFEBj0SaypSltUTPnGYbR57ROQcrqr8F5X/uyzdUsQzCmK/1QJMPjMra AxmgVLoDPDYYus9/uxZPUqALav16u7BoQ73XELtKtQWIrqg1C+ElkU6Veu//TDp/P5l/ HRNLMkdRTus5Xw/YP3pG32b4irq7tWSSMAYZMU5eI5/XL6DZ3M7vaGE6iU2qh43WuOBt zpUrj3KUO1tfTeTOAfSH/kJpSes4yDYCHk2ribQ2VgnOgh6wdO0tDp7luG70FcE0P+oP bN/+THVh+6v9y2BDkP65LmZFo0r/rhztH513bl2a3PzhqLdpvDzGUak2bHfE8+dEv/Xp CzOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740061071; x=1740665871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ku1J4a4L44q8po1KQAtOYx7Ff0tpcPyGvZxYWms+JUM=; b=bpcU4YeWUveVjAw+LSDA3+v71VzLP1GeRNm2IzQRZnCwTyXZYHWB/qNVl5PN3Vg0Kh tGAHw0KvhDP+QbNXiEAB97SCUdByO3kS4ND106hCk4O4GCBxprG+hRcpDq6YwNir/VzG J1fVM33DTXnkG2I989R+xZs3eSwgFV2lXb9k8HCA5CRA3HYBVcN4/wsTvyQE6BIWKGbv GqFGK1jE1n7qrJPY3r71ZVEDXUq77exrThQlQj+R+6LOAFcxdHkHyLkHWINCZTqFu35u HY59V2dwcBfrdpoNb10SMDwn73W/NYmSSQ9yps3ALkWzBZNdLN8LOQCJDwYOhQiG7Rea ywTA== X-Forwarded-Encrypted: i=1; AJvYcCV68Ajc7FL0f0OomjPvc/4EliYTpuqE6niAvA3srOjKrV2DFXy/4DO0ev3Z779lJGWu7FM0KU0ElXRwHkw=@vger.kernel.org, AJvYcCVtg8tRChoQixFEYqDNTAkBlt/krcxs3A4JlfsX4CI/wQiVrcQ6m3HeMnRdPG9oflODef6AakUMZES3@vger.kernel.org, AJvYcCXVav0Msi6wCmeHB9QpAB6g15rFSgJ91rOy7OWajVTdMbrqJV1zEcpewzTudSpqigcoB7ZZwlvGWOj/PXSk@vger.kernel.org X-Gm-Message-State: AOJu0YxyH+KKrXuU0yZgf2d2MWD0ZphIx7aOi+pCIXjGJEr8d6P9acCR 7eczY/shrbZg+mNgaVvcXSg3c2Efzrw6KoEo/WTkaenYMTSKtsGL X-Gm-Gg: ASbGncvhSbBiVi4uwGtTwBpTzz+naBggiWSf+J7WNC3waZLDF0hw1rgOpF8MD3TnqHM 9EbRPzQLJqm8sv/9OzaDkI8pJtqJiGYqW8lse9UDwJdk//elRdnIv9NKl9m6aa9uxPC5qrYqBee MS8eR5DwkGTrtANefga7mMDa/EZ8aQ7AZV/k44+4yGt/hWogaviI/n+A8G2YA6MkH1+Hnp38E6H EF15FwNU2j1SBJ/bbgs1/gih7Ayoc+cMtXQkj0mQ3bm0H6L+CUWlMAGKzolUvyEuCtJJnExghYL 0zrf4DPL08aBq/IGg8orphdWd0i/ X-Google-Smtp-Source: AGHT+IF+XJVyqbiTAhRVT2DX5gAGDj/R1pffrBAQNQzM7DfV9u3X2EU5bwoluW7W/73TKgTxtEDY7Q== X-Received: by 2002:a05:6402:35c3:b0:5dc:1f35:563 with SMTP id 4fb4d7f45d1cf-5e08950fc04mr7944322a12.7.1740061070649; Thu, 20 Feb 2025 06:17:50 -0800 (PST) Received: from demon-pc.localdomain ([188.27.130.21]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dece1b4f59sm12124224a12.6.2025.02.20.06.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 06:17:49 -0800 (PST) From: Cosmin Tanislav To: Cc: Dave Stevenson , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sakari Ailus , Laurent Pinchart , linux-media@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Cosmin Tanislav Subject: [PATCH 2/6] media: v4l: fwnode: parse Virtual Channel IDs for CSI2 buses Date: Thu, 20 Feb 2025 16:17:24 +0200 Message-ID: <20250220141739.228714-3-demonsingur@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220141739.228714-1-demonsingur@gmail.com> References: <20250220141739.228714-1-demonsingur@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Multi-camera systems often have issues with receiving video streams from multiple cameras at the same time because the cameras use the same Virtual Channel IDs. CSI bridges might not support remapping the Virtual Channel IDs, making it impossible to receive the separate video streams at the same time, while the CSI receiver is able to de-mux streams based on VC IDs. Cameras sometimes have support for changing the VC IDs they output themselves. For a practical example, GMSL2 deserializer chips do not support VC ID remapping in tunnel mode, and neither do the serializers. Allowing the cameras to have their VC IDs configured would allow multi-camera setups to use tunnel mode. Add support for parsing VC IDs in v4l2_fwnode_endpoint_parse(). This allows us to retrieve the specified VC IDs in camera drivers and configure the hardware to use them. The supported values are 0 to 3, with a maximum of 4 values. Although the CSI-2 specification allows for up to 32 virtual channels, most hardware doesn't support more than 4. This can be extended later if need be. The driver must validate the number of VC IDs and the VC IDs themselves. Signed-off-by: Cosmin Tanislav --- drivers/media/v4l2-core/v4l2-fwnode.c | 15 +++++++++++++++ include/media/v4l2-mediabus.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index cb153ce42c45d..97ecc01e1e39e 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -129,8 +129,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, bool have_clk_lane = false, have_data_lanes = false, have_lane_polarities = false, have_line_orders = false; unsigned int flags = 0, lanes_used = 0; + u32 vc_ids_array[V4L2_MBUS_CSI2_MAX_VC_IDS]; u32 array[1 + V4L2_MBUS_CSI2_MAX_DATA_LANES]; u32 clock_lane = 0; + unsigned int num_vc_ids = 0; unsigned int num_data_lanes = 0; bool use_default_lane_mapping = false; unsigned int i; @@ -208,6 +210,15 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, have_line_orders = true; } + rval = fwnode_property_count_u32(fwnode, "vc-ids"); + if (rval > 0) { + num_vc_ids = + min_t(unsigned int, V4L2_MBUS_CSI2_MAX_VC_IDS, rval); + + fwnode_property_read_u32_array(fwnode, "vc-ids", vc_ids_array, + num_vc_ids); + } + if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v)) { clock_lane = v; pr_debug("clock lane position %u\n", v); @@ -248,6 +259,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, bus->data_lanes[i] = array[i]; } + bus->num_vc_ids = num_vc_ids; + for (i = 0; i < num_vc_ids; i++) + bus->vc_ids[i] = vc_ids_array[i]; + if (have_lane_polarities) { fwnode_property_read_u32_array(fwnode, "lane-polarities", array, diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index 24c738cd78940..291b680d2a845 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -72,6 +72,7 @@ #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(0) #define V4L2_MBUS_CSI2_MAX_DATA_LANES 8 +#define V4L2_MBUS_CSI2_MAX_VC_IDS 4 /** * enum v4l2_mbus_csi2_cphy_line_orders_type - CSI-2 C-PHY line order @@ -94,8 +95,10 @@ enum v4l2_mbus_csi2_cphy_line_orders_type { /** * struct v4l2_mbus_config_mipi_csi2 - MIPI CSI-2 data bus configuration * @flags: media bus (V4L2_MBUS_*) flags + * @vc_ids: an array of Virtual Channel IDs * @data_lanes: an array of physical data lane indexes * @clock_lane: physical lane index of the clock lane + * @num_vc_ids: number of Virtual Channel IDs * @num_data_lanes: number of data lanes * @lane_polarities: polarity of the lanes. The order is the same of * the physical lanes. @@ -104,8 +107,10 @@ enum v4l2_mbus_csi2_cphy_line_orders_type { */ struct v4l2_mbus_config_mipi_csi2 { unsigned int flags; + unsigned char vc_ids[V4L2_MBUS_CSI2_MAX_VC_IDS]; unsigned char data_lanes[V4L2_MBUS_CSI2_MAX_DATA_LANES]; unsigned char clock_lane; + unsigned char num_vc_ids; unsigned char num_data_lanes; bool lane_polarities[1 + V4L2_MBUS_CSI2_MAX_DATA_LANES]; enum v4l2_mbus_csi2_cphy_line_orders_type line_orders[V4L2_MBUS_CSI2_MAX_DATA_LANES]; From patchwork Thu Feb 20 14:17:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 866958 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 526C8204878; Thu, 20 Feb 2025 14:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740061078; cv=none; b=IhifaU2RaFwH4cKYdNWQEZzCyyCuPZX5grIJbGX5c9Y0s3qjGkvB8L3eVgBknMVwGLNbXr+Xfzl3DhBZTLRc/F8mHtcilH6T+HYP0FtC+Q35CxfaK/cWPawfwU+Z2Qiaj5zUu4JOnpdFKUi++4Vk3QY/ZgitjESqqCWJsQKMv/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740061078; c=relaxed/simple; bh=zAx5h3CW9uhScVCOaEZGPbZKRppELpmuFuRjU0AzcDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FraIscZ27YSi/7+AE/oyz5cqqvn8sfVmiQJwQN5oV+n156tp0JoBYBrkfUbfUsw5Or5V7OJKfnvDiCyBeI+YnOYOfYc+ohfWHGXQw0WHDW1Y/Rb09SE5NPQQWFXh2Odnz+Hid/VYewXy/DI7jVOJGyTq7SVFvwid9rXc1F58cEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Sy91NTFF; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Sy91NTFF" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5ded368fcd9so1464288a12.1; Thu, 20 Feb 2025 06:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740061075; x=1740665875; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1V5REDmi/qwmeZmzS61DPGBCJO64NPZWi8x4XF3HxB0=; b=Sy91NTFFduRuSa+T7eUTLMrHuF6EuLc/G+woHoj/PJ1oRFxskxbQHQBofcfTWAfoc0 6iNscuq2f7Wjztbfy6Gg1z6VE211LMGvWvdpS19C47HjLYMMqGmT9ZUppJEEPr/ht7be Vxpea8wJGtbr6r5Dt7zh/WH8sHJ6MhVYAslV8ciJkp1mFxXAZ6XmScHEjrf6exUrHEco Dh8EupjLA9aGuSUnXHu9YJlrHcJA03q1bNj/qdiO7Ek9lP8OUYuRrj6EGz1L2zsYmcBh CNl29yWOQGKMNrE1oGQrEwyy5+RllMMtOfZ0YJorL5HWEKEBAvZcxB9yRIEm6P4YPKvL uvRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740061075; x=1740665875; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1V5REDmi/qwmeZmzS61DPGBCJO64NPZWi8x4XF3HxB0=; b=pOx6cPOg9NNGau+nK7TQdPfK1B+JSLkYWKJJeF/K9aWQwzhZ76JB/O+UsdHk6ID+CF TiMgwssQWZXNQ7em8BYiDYf0IwLHjm4ea7g6IIzWfkndLcUrBbCJoxJttUaKBYMOZ80f rBeouGSh1dibxJGCE5w7JSrB0xGj6+LxXRc0SZw3uNoQLWoevZyniKzZ1fk0h5HTZs1p 9wI209H2pDFt8fNJYuVBrH0mK7wIR0RME02mcsGyPEQqZzY1sMuAg6n0aZL4jPWfM4hP nUL9hte4ALGBUk3Q29B1t+tOvbc6GaOZ1F6yxmNYWHFVDPrkUA27Ho8PKwlCim9GbprB ZR+w== X-Forwarded-Encrypted: i=1; AJvYcCV+rlQWfZkhc6J1St9OPCd9PyDUnB1mp6fatNv5acDPpoNj82NuHXI1qF6wMdXxfJ5rwmSjxTi/ur1w@vger.kernel.org, AJvYcCWF7Vc4bkT+mJMd/npw40cn/ujVl8a0MmGZDXqF+FC98SI0mXkJD6ios/hIywXx9dFUxMug7C1f0xvlUz81@vger.kernel.org, AJvYcCXKBBdn0Or8bRU1i0WUkBHpXG1Eei0Ciu5TSnG/Nzu2lzzz+boYwTHdRl1lLj9PcPY5Ihy3u7WKsxaGk6w=@vger.kernel.org X-Gm-Message-State: AOJu0YwTwB/nFUNoZWvazhq6lAXm3nZ/0iB0uwpNDd2j0xKIH+O91nzj Vf+41QgDdk9VO31GHVVedOjR1KDjNnAf/YmlJkAglK6rc39gtEXN X-Gm-Gg: ASbGnct2QZtE0k9JD11egNCflHxccqXWA6wAyyIz9qVL5QTLoCQavT4fpBPkZpWzNrY 5rqxXkqXE+5y6XDEI9KhuxarXsJQDelZS+G14m43iapNHY9p/qA/ZAMYyEiV03elriyo6PC/QOt 1I82yEl36sckTaVLxilnfGn+qTW4GUbvHhKqq+W/JdYSVWZejL/jJt5AnQGvpJCVIqrUgYE9wpd ClQWOodfk2Hk9LuDmsbuLyozbqWhWXKVXAR+nmmJ48z9CclPAMoNxqirm64siaFO7rQcVcISVhP 0t65U9xgdePEcV222bG4wjCZBiHv X-Google-Smtp-Source: AGHT+IFFJvKPRHucc1r4QGSkduMvmNCXiQ/0XGioq753EqOOggpo2+xqmAhfLNknWvVEGi+w56gFTw== X-Received: by 2002:a05:6402:a00e:b0:5dc:ebb8:fe64 with SMTP id 4fb4d7f45d1cf-5e089523080mr6461869a12.14.1740061074548; Thu, 20 Feb 2025 06:17:54 -0800 (PST) Received: from demon-pc.localdomain ([188.27.130.21]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dece1b4f59sm12124224a12.6.2025.02.20.06.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 06:17:54 -0800 (PST) From: Cosmin Tanislav To: Cc: Dave Stevenson , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sakari Ailus , Laurent Pinchart , linux-media@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Cosmin Tanislav Subject: [PATCH 4/6] media: i2c: imx219: pass format's code to imx219_get_format_bpp() Date: Thu, 20 Feb 2025 16:17:26 +0200 Message-ID: <20250220141739.228714-5-demonsingur@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220141739.228714-1-demonsingur@gmail.com> References: <20250220141739.228714-1-demonsingur@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 imx219_get_format_bpp() only uses the code of the format, pass it instead of the whole format to allow usage when the whole format is not available. Signed-off-by: Cosmin Tanislav --- drivers/media/i2c/imx219.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index fcd98ee54768e..ad1965a91ae3c 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -387,9 +387,9 @@ static u32 imx219_get_format_code(struct imx219 *imx219, u32 code) return imx219_mbus_formats[i]; } -static u32 imx219_get_format_bpp(const struct v4l2_mbus_framefmt *format) +static u32 imx219_get_format_bpp(u32 code) { - switch (format->code) { + switch (code) { case MEDIA_BUS_FMT_SRGGB8_1X8: case MEDIA_BUS_FMT_SGRBG8_1X8: case MEDIA_BUS_FMT_SGBRG8_1X8: @@ -680,7 +680,7 @@ static int imx219_set_framefmt(struct imx219 *imx219, format = v4l2_subdev_state_get_format(state, 0); crop = v4l2_subdev_state_get_crop(state, 0); - bpp = imx219_get_format_bpp(format); + bpp = imx219_get_format_bpp(format->code); cci_write(imx219->regmap, IMX219_REG_X_ADD_STA_A, crop->left - IMX219_PIXEL_ARRAY_LEFT, &ret); From patchwork Thu Feb 20 14:17:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 866957 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25A35211A2B; Thu, 20 Feb 2025 14:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740061084; cv=none; b=lZm4wrlfh6dcD/zcY9VRVZxvaY4TgEsXQ+/spBIi1p/ZK6M1Up93DlnpgtqtLzy/ofWRVYOofTNmLXI3z0QeJeao5cQdYzh2zDKfAVCas1bWLHcAnKSfT1oSsAFgVGT+1fWIfZ/fafcGybYRprx0GxUCdGHiLWxPKeQ1gx24o2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740061084; c=relaxed/simple; bh=02meRziosCIj5XMgGS3fhZ0M79JRqzLS+o9FESCTLZ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qZReCJCFpdgqjDSluPbwILS+i7svkJ4on4FBj2OZTUgtG61qEEniNsbp9WMonnuYJbAyVfCeJhpHoKXpZbjMGHOk3Km/u4167DBCBHFiw95DpZCnM7SnrpXJqbmMO2Jx+4HNh0RrLgJ1ZHwKIHPzbx5hSH43YwQCaFfIQkwFKjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NvrcDLxs; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NvrcDLxs" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5e095d47a25so1950135a12.0; Thu, 20 Feb 2025 06:18:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740061081; x=1740665881; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YrD6Cu+ma2ey5dVvO2q4VCmeyk9hPbaJ87jyuD084/E=; b=NvrcDLxsJ8pJJ1dsN57U7u+EMZK2lvin7Drs9os3aLF0knAdGH3oOHCcv/Gc5ww3V6 EwVO3hVNrGaovijtV+MzZR8bBpwiLH5DmRsJFAsRZ0Ryak8OkapGfJYmTQrQLNzO4JIP a1WP3wzbRwrFPNqxVc06frGG41K9wq+zIRWmk/Hsp+pG9bhmZAhLtSdZff2cklqrjzCc xboG3Y1ni1FsPeDpwbWitHy6Phzb+n3N1FYI5gEe2qYoehQAGXjsH5vlw47T3JMI1i5q addD0rhYpwSjLCGhJwNGFzlCGknIgauM8HOh3m3OLUWVg4q18OXcgvvLxYHUVlJXvSn6 PSWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740061081; x=1740665881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YrD6Cu+ma2ey5dVvO2q4VCmeyk9hPbaJ87jyuD084/E=; b=UYP5xNjxHv4DiIkiMyvPJN5CbEmPk94oIg8PmlVi+E8/FSabQ16UE5fv1vZYNju08L /ki8vV/B4LiOUy6/s9JhyuGV4sO5XF2qKpJMgFSHIp0l/x6Nr8E6AuWaCYUnly6MEC0+ 9jGLtOiY9ab0a8UVDvN1p84izDoCoO6TTPS3ISOvZe8j38CtgR3Iz4VRf1HFi0dO26YQ 67uztvYtgwZlKvlMjpAFDarDWXGdPSoW5zB0ao44cmgI7RO0+w5kzIRfkVzDyvqtAz4t 5ZBjrCXuTY/6maRFWCKWOzyblMaxrm9+baU+CsY4hkqfbFWfYDYVtHLpySPPAtpbt5gS EzgA== X-Forwarded-Encrypted: i=1; AJvYcCUAX5ZDsnoQpFmxovwUkSctEAqawEixc89Tah6whY3R0jPWVjG0rtMBZsuLIjCZjXESDhm2OwVFzDBx1Ys=@vger.kernel.org, AJvYcCW0EXlHYHGMa+okUPUNJB7SMK2IkHUI/EuMaNpNqOLFV2s5WYwYk7zNCewK5G86UAW9T52IcAfDZ63iDUW6@vger.kernel.org, AJvYcCXY+AN4GkflOumThMa/I1Rl3aC53dxlpmdzCfjUu5z0fwK2TAeAzHg+69Aby2u9FpqKKld1l0eSvCh/@vger.kernel.org X-Gm-Message-State: AOJu0YxxokrqSzJc0hztdVj21u+bn5N886pFOEt38iUdElrSlZ7zB0Nm 5KS8Wo2MPAsMsIiVRgjT08j+XdOhwa37Qu8oHkm1n3uY7kWKzc1q X-Gm-Gg: ASbGncsUI+sHudKEIqSYVvQG0X8eVw2SeVbg9N4C8Q28I1Mc+en77fG52tsJRiKF6ch vB60kqlovyg3XvGeDEIAP6NwE+5i7j5PkJA9hbxbNNSmbxyRStQ7zxFHxDnH6JYkR3pOfTHfsp5 y3XDjN1FvqTnyuNnfn1YPw5Dmtht75jNYD2NJtkivR5QoN2VXmbZSQBivptd1REzfTeZmbZVZmk MqpwDmSeiXW/9y75o3Az+eq2bXSD3Vp1Z0SEyklsbabCmMyVDdMRlCks/4sbNpxR55HZumSuE08 qSu+4oBP0GSeBiUJwD1ZyNT8dRsX X-Google-Smtp-Source: AGHT+IEI5BjiSueHGowWB7V0AX0jphOzOkC+hVJDCuWo2okxV45XHcKYucaW0FwCHe0/kc3RlhAM1g== X-Received: by 2002:a05:6402:35c1:b0:5e0:3f83:92ab with SMTP id 4fb4d7f45d1cf-5e0a4bcbb50mr2539326a12.30.1740061081463; Thu, 20 Feb 2025 06:18:01 -0800 (PST) Received: from demon-pc.localdomain ([188.27.130.21]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dece1b4f59sm12124224a12.6.2025.02.20.06.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 06:18:00 -0800 (PST) From: Cosmin Tanislav To: Cc: Dave Stevenson , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sakari Ailus , Laurent Pinchart , linux-media@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Cosmin Tanislav Subject: [PATCH 6/6] media: i2c: imx219: implement configurable VC ID Date: Thu, 20 Feb 2025 16:17:28 +0200 Message-ID: <20250220141739.228714-7-demonsingur@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220141739.228714-1-demonsingur@gmail.com> References: <20250220141739.228714-1-demonsingur@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 IMX219 supports configuring the Virtual Channel ID used for image and embedded data streams. Signed-off-by: Cosmin Tanislav --- drivers/media/i2c/imx219.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 4c4ebe54f191b..5790106b35936 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -38,6 +38,8 @@ #define IMX219_MODE_STANDBY 0x00 #define IMX219_MODE_STREAMING 0x01 +#define IMX219_REG_CSI_CH_ID CCI_REG8(0x0110) + #define IMX219_REG_CSI_LANE_MODE CCI_REG8(0x0114) #define IMX219_CSI_2_LANE_MODE 0x01 #define IMX219_CSI_4_LANE_MODE 0x03 @@ -363,6 +365,9 @@ struct imx219 { /* Two or Four lanes */ u8 lanes; + + /* Virtual channel ID */ + u8 vc_id; }; static inline struct imx219 *to_imx219(struct v4l2_subdev *_sd) @@ -724,6 +729,12 @@ static int imx219_configure_lanes(struct imx219 *imx219) ARRAY_SIZE(imx219_4lane_regs), NULL); }; +static int imx219_configure_vc(struct imx219 *imx219) +{ + return cci_write(imx219->regmap, IMX219_REG_CSI_CH_ID, + imx219->vc_id, NULL); +} + static int imx219_start_streaming(struct imx219 *imx219, struct v4l2_subdev_state *state) { @@ -749,6 +760,11 @@ static int imx219_start_streaming(struct imx219 *imx219, goto err_rpm_put; } + /* Configure Virtual Channel ID */ + ret = imx219_configure_vc(imx219); + if (ret) + return ret; + /* Apply format and crop settings. */ ret = imx219_set_framefmt(imx219, state); if (ret) { @@ -994,6 +1010,7 @@ static int imx219_init_state(struct v4l2_subdev *sd, static int imx219_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, struct v4l2_mbus_frame_desc *fd) { + struct imx219 *imx219 = to_imx219(sd); struct v4l2_subdev_state *state; u32 code; @@ -1006,7 +1023,7 @@ static int imx219_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->entry[0].pixelcode = code; fd->entry[0].stream = 0; - fd->entry[0].bus.csi2.vc = 0; + fd->entry[0].bus.csi2.vc = imx219->vc_id; fd->entry[0].bus.csi2.dt = imx219_get_format_bpp(code) == 8 ? MIPI_CSI2_DT_RAW8 : MIPI_CSI2_DT_RAW10; @@ -1149,6 +1166,13 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219) } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes; + if (ep_cfg.bus.mipi_csi2.num_vc_ids > 1) { + dev_err_probe(dev, -EINVAL, + "only 1 virtual channel id is supported\n"); + goto error_out; + } + imx219->vc_id = ep_cfg.bus.mipi_csi2.vc_ids[0]; + /* Check the link frequency set in device tree */ switch (imx219->lanes) { case 2: