From patchwork Thu Feb 20 23:08:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 866951 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.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 29263265627; Thu, 20 Feb 2025 23:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740092928; cv=none; b=bLGXuhzeEg8Fh7B2IrGljAfACkG4kSDZqZrCNwOm61gPk86vH0A4FtORXkP+3Y5SaxttANyX8ELk3yG/MWL+E9H3Ae3w0ixNQhC0zlqGuJsqq8TdMsamQT1KM9J3N5kpchjvIhtZR9B8s+JjAPRfjdyTyjtkKYDbvkXVJRPPyeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740092928; c=relaxed/simple; bh=CWodvW4NCBIlUv6/PqgOLyTNVvQ6Z0Bh5b4w0MpQRQY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fP3Gd5e+9pQGaBIIugrFQQ+YPqgNEwcp+P8bm4Labm4z5ezPOs1W3Ag20kcX6ZtD1/4mpr6cCoE+unNwJ2iCyiZ/e+zDxCGNOxyiWryx300KlGF/7jRKhWeR+TezjUYUOWPZ+LpabXrdvGUwNMJTC7ufSNJ2yOaqcIFrFYlpTrI= 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=RXWPrRNV; arc=none smtp.client-ip=209.85.218.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="RXWPrRNV" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-abb892fe379so258865466b.0; Thu, 20 Feb 2025 15:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740092924; x=1740697724; 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=RXWPrRNVbjkaE7btJpvzR5Ifsjwudb3mrAZkQj6/o81J25VFg7xKynl0/jdG8bWQEE Cx1YXuXn+NLuD6QNZERbYeAIhYG8W96NGwRsBkE+BTSNMeq5tblQ0SIFUCJVe+m5XryP yK7qHelT4jClnbvNKBfaLKWplA523ckjgwaIewOlhdnkGpXMsytq6LQ+0iDcnolVYO6i 17kxSqcnOodmmlDTeGG0L6XI1gBhLdsUxrRnY5K/Q0F+WfaVbUEhVGnmG0mKMwLCCegN 8tFAAuw7QX97MkW8yPEL+BJdaf0LcrOUY0bulZVAC92+BNrX+YjY0Kg3tYl8K5VE/491 A2eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740092924; x=1740697724; 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=RMpdmbRprva6F+ej2D8vwwB5C1aK5WytZ8rhFkgIkR3UaASS5YScN+0OTpWHZW2/Fn V49PHHKb40hlN95GICB7F0o0MIVSIsMfSAbNOn2Zw0CMb4OUwR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WeSz2Mp+/p5CWLAdYA/aqo1g== X-Received: by 2002:a05:6402:27d3:b0:5e0:7510:5787 with SMTP id 4fb4d7f45d1cf-5e0b720ae8emr1532105a12.19.1740092924094; Thu, 20 Feb 2025 15:08:44 -0800 (PST) Received: from demon-pc.localdomain ([188.27.130.21]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb9654a6b2sm909107066b.135.2025.02.20.15.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 15:08:43 -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 v2 2/6] media: v4l: fwnode: parse Virtual Channel IDs for CSI2 buses Date: Fri, 21 Feb 2025 01:08:10 +0200 Message-ID: <20250220230818.275262-3-demonsingur@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220230818.275262-1-demonsingur@gmail.com> References: <20250220230818.275262-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 23:08:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 866950 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 B098E2676D0; Thu, 20 Feb 2025 23:08:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740092932; cv=none; b=f8GrU0KOorQa96KI9IJVjALRn2vJvWvLsHh9+pvcbzSmE/MW0TCPqOhzXjzkq2NehIgVb5okB1cVTZb/zyxf7xMtg8/NXiwb4fRLyzmT4UFWcefR7x+Eu7SZMPIXMfe68ov+T7EoGCpdDglZj90AzEJ5/zgeYoST+GZ5X8Z2Iok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740092932; c=relaxed/simple; bh=zAx5h3CW9uhScVCOaEZGPbZKRppELpmuFuRjU0AzcDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VA59lZAso7BVOsBdtfkzibvXSRotesh6CKeRB/7OodEtK23sjSjokvQwT869XenECumZ1fiR2IKzqoHG56eBdEkdzETA+8wJDHJQjXRDJZ2SIt83ifW3//4pUl1alErqmjYKw1+hjHcuppqNjZwBieFYXosLBu0EbCDy/l5moJ4= 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=lQcBHz2e; arc=none smtp.client-ip=209.85.208.49 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="lQcBHz2e" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5dee1626093so4848980a12.1; Thu, 20 Feb 2025 15:08:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740092929; x=1740697729; 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=lQcBHz2eBCTn4v06JON/Oz46HFuK2u/4D/zoqCal124/TprXsDPCQUCzVJyYckW+8/ o/Un1BO33mdXXUMXfBiZDNz01aKitnq5YximRGvhYk3XU4n07enp5nQn/FMMZsqcFRwe 7rvVIGTNC9pVFRIXPm2/RGh1LH5xX560awpPiqEAH7RFb7Etlxav4LRXKbP5Ie7jEC6I DstdDvj4G7MtdW2hhnoHkIsrMFCIKwdLyYOOsJY9aLen3tBPhmItD639oawB3VmcwI5U IkYiyvyt1+WfhlbzktkLUjoK6MkldQmdDW8WFaMuuKCPNVlcpW4lkHpEwNpJW66YxcJ4 GY4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740092929; x=1740697729; 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=Cenj2941wzGT9UiyVfpPxa9bdhLxllLHGlKZDovm16hrtzhhtVTw+qNphbND4JAbij 53EqC17EMFhLz9vrXanu1W9jvsCSPzBFTnfSj5O0FIsQ/MY8qjsXej9rYkGN0an68my7 PRg1YaCyq5dOtEdCslcX3DiWuF6IwBgR0f6LWRk8HzsT+MsQ8yXp0XNp618wNffk9j1L KEb5frheuFS/cDi5osvkOgHt5OGh0TWjwJ8cjCyBIPL4qq4HqS2rr2B3RNTd3idp4yyK 9SRut23aCWkT5ak5qXpOWvY69K6ocwkeqC64GXhLiIg3LaVbF6zzx9gVwPvVjfXRgnbH +mFg== X-Forwarded-Encrypted: i=1; AJvYcCU+5//bOjkthRuDEq7rRks4K4jqG4Gf7ra0PmbpP8P3x10kYN2HcJqvSemZc0BcVZhYKTKn0+s7nHwqL+NL@vger.kernel.org, AJvYcCVjKwYfLDFFRsFICdtFHjHsr2+VWVU3I5kze8VX9vpXykovrwKkVsNXdbgTK5gqM8wwxgTQCjLk/0RJXzU=@vger.kernel.org, AJvYcCWxU7KwMm1IFv6oTsBcZEmwBdVUfG3U7u9xD/s66nd0uWKKPW6Szcz5wOJ1q6N6gKsxOXDhb6lBhbQW@vger.kernel.org X-Gm-Message-State: AOJu0Yw23c/1Epvr4ISi5geDbi32aonRIjMCyln3emsSqYyYGvMgfPpU 3swkxiy4WmPXC/6nx+6MUnX4OT/yncEj1PsSBq1AJmoqNz+ARPdp X-Gm-Gg: ASbGncsw7mefWo8bBCWwDvttcgad9yGDt6+CVXEky6UpkKT9Yoh5AtggacklHBoqW7/ W0aO/ieDIe6Fhnh0rfqEn4OEDVzJZ1KIFUoiABIhjKqs7zzysQH33YdXDuk7vRNhJeH/4kOFU8m G/F3nbsXjbX2+2pMH1Ga/I12OGuddS8wBY+wD35TOLW3oEYWDSntgsPv1EHpNC3KrizyzJAlR1W SnfpXurnYqV+6xBPH6ShdcBbmSz0TBGXRbCGxHcWN3Sg+3Tl2Kcb5lI9ftOQ9L0i/RmHGY321F3 6pV+nPgWzvxoi22zv17eNbnSFJLW X-Google-Smtp-Source: AGHT+IEydEuTk0agw+AF9f8wYzDAN5oKuTWK4h1DVKaFvIYPrYzGCYHJkQgTkbLioaZGj3jOXXoyBA== X-Received: by 2002:a17:906:318b:b0:ab7:b7b5:2a0c with SMTP id a640c23a62f3a-abc0ae1b6e9mr76032266b.6.1740092928857; Thu, 20 Feb 2025 15:08:48 -0800 (PST) Received: from demon-pc.localdomain ([188.27.130.21]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb9654a6b2sm909107066b.135.2025.02.20.15.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 15:08:48 -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 v2 4/6] media: i2c: imx219: pass format's code to imx219_get_format_bpp() Date: Fri, 21 Feb 2025 01:08:12 +0200 Message-ID: <20250220230818.275262-5-demonsingur@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220230818.275262-1-demonsingur@gmail.com> References: <20250220230818.275262-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 23:08:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 866949 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 297462673B9; Thu, 20 Feb 2025 23:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740092937; cv=none; b=g4WGmU5Aw4pm3LaxXxbsCSncjH60CeIftu7kVJSuup91gNxT5y9Ws2MfvvYh0FQpfujEgBzsTFHqdbqpF0UtMgk8RUKaFUtFY0p2JGDM+k7tKGPS9frs/2u1KxR3Qvd9NE1CMdaQI0BhchSpeBR4wdSS6vblhYxVmTd2xlRqmF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740092937; c=relaxed/simple; bh=EzZQSdIx5D7T5oRoBm/8fSqgGLdREtHQcr2NCdkG5fY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b3A8D9J872/1Jo8RaA4UWMeVmGG0Bn9l0nnR/QhySB/oDEkBH6InCBxP2nrVRj7dKHfwRFDHz+1ye0b+KMgRp2+JxdkTNBOMccCX7zBbe9wCspvxarJTVN+cb+xLvqY4JQDlhUG1aS2su4we6R8tqzusAdYjWkjdUu2RLRxF7Kc= 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=JhpKyQGn; arc=none smtp.client-ip=209.85.218.53 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="JhpKyQGn" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-abb86beea8cso297436366b.1; Thu, 20 Feb 2025 15:08:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740092934; x=1740697734; 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=NhX43RkJeHOzyL9QEiVx31rF6Y6JmPRuPUbmR6ly4C4=; b=JhpKyQGnhPqI3qjFdQzZxaioSIdAJ9zjg8NHP7vpsUAzx/7oiI0MoBrLfHmhO3/vZj 4cWg7foxXP4uG+R/ig+qGWpxFBnZ2LqLe7YM+zDTlFSxxnwQoKWf7K9P2BrFZVC009ck WtoTmynAHzFCnagdDTtRIvQzeSVOjOuAqIAiYAae3jZ8OdvVI24va8Ocn14DgrXGzhZn LP/0OfIlugcUlxgX2HRIXzYioSpRcfk0n0xjKFNLBwl93O4nmrcMhJXGfdetpTb+OyWW FX3sfiVgDKlrGfW6bUL+i4gTaSAO6VFJ06IYJlfMGmZgMgUB6PcwBdSeUyrcWJJUL7mA kdZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740092934; x=1740697734; 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=NhX43RkJeHOzyL9QEiVx31rF6Y6JmPRuPUbmR6ly4C4=; b=Gz6WdJAtP6R65zVm2LFxV5yuxJitWAbiIZwUn7i4Jm4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source: AGHT+IHN9q1K9iy2cJqlLoBVyZt+NIVwf4Z/pfv0pnr1nZE9X5wgZJrRlMItfXGJSo5vo2ienwvsKA== X-Received: by 2002:a17:906:4fc7:b0:ab6:dbd2:df78 with SMTP id a640c23a62f3a-abc09d31cd2mr102596866b.35.1740092934282; Thu, 20 Feb 2025 15:08:54 -0800 (PST) Received: from demon-pc.localdomain ([188.27.130.21]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb9654a6b2sm909107066b.135.2025.02.20.15.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 15:08:53 -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 v2 6/6] media: i2c: imx219: implement configurable VC ID Date: Fri, 21 Feb 2025 01:08:14 +0200 Message-ID: <20250220230818.275262-7-demonsingur@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220230818.275262-1-demonsingur@gmail.com> References: <20250220230818.275262-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 | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 4c4ebe54f191b..ae93ac2bbe367 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,13 @@ static int imx219_start_streaming(struct imx219 *imx219, goto err_rpm_put; } + /* Configure Virtual Channel ID */ + ret = imx219_configure_vc(imx219); + if (ret) { + dev_err(&client->dev, "%s failed to configure vc\n", __func__); + goto err_rpm_put; + } + /* Apply format and crop settings. */ ret = imx219_set_framefmt(imx219, state); if (ret) { @@ -994,6 +1012,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 +1025,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 +1168,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: