From patchwork Sat Jan 4 19:55:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 855209 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 956F41D5176; Sat, 4 Jan 2025 19:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736020630; cv=none; b=M8CnTw6f1wWPOksPeo9tsVmcRhbYkdI2110XVFGb7JfM+LX0QAVuLETn0hORgYc1jW6GmK3887kqfJIwq+eSqS1kXYwbb9f90P15ylXg/VGwbAxkkNXKwFwOk+odbjd1nohgKIHRZi7XyWwRkd+uunbNAcD25eEonBaghmsaAPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736020630; c=relaxed/simple; bh=aMVFk2kisgFiZN5UEwf2u3XzlP3yiei7z3fsZR6nlyM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W5tiCYSmhiBKLA0JQkAU7WGyZYZHZyppgkus4qTfnBxZFI0qXYbl0HBmV7rO5qes21Cgt4/eYUMndnjrPBGPHNBiYTKP6TrnzdiMYSARA3FyhX9mpTey+ZabFl2IkgN0+nEGiaNa0TVYDtzSKRKokQb7rTnJ7cxQpqyAiygLmEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=kJRgqm8G; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=gUsYZ+I8; arc=none smtp.client-ip=202.12.124.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="kJRgqm8G"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="gUsYZ+I8" Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.stl.internal (Postfix) with ESMTP id 83A02254019E; Sat, 4 Jan 2025 14:57:06 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Sat, 04 Jan 2025 14:57:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1736020626; x=1736107026; bh=DYe1f0hPxpFJJwRr2mpZngPc/oTBFdRdhPpk2dWYyAY=; b= kJRgqm8GIPbWLOgMFo4u3d1oq3Mcn2MDXjyDmmDVl0ZLPteepqJPS7m4UTF7RHA8 7xIhuQctod07IqOgDPsUkS2gWw6p5GLBx8etnnfw9ohXDGBHh86QD7t5IBk4eRwq sFTqe1WNxeAxi4HLjBo2cyQB3s5xANYCBhw/JyacsxI+5ffJRUQfk5XmB1BwRHMR +iq+G6ZNVwgS4TVut7saS3J8yQy0YF7xx8+KSbTzdzvHk8FsTpJ7AwUuqDtgnuOn tdfjKtIOoj/zyTLQAxJ0tZUJ9mdINLL7FcA9JALjd3Ovl6l0LayrCsOePotVP0Mt 0bRlg7P2/CDJplz4kRte5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736020626; x= 1736107026; bh=DYe1f0hPxpFJJwRr2mpZngPc/oTBFdRdhPpk2dWYyAY=; b=g UsYZ+I8uRWEo6qcMn1FrBdrT3nZg2RFydU04YlwysHkN3wq5wOovAHBszDCl0js6 2TPWYKAEDVc1F4XdAJ8ULqnlqmDedo45UbbzJk4HE42I5i9QvLjNeaoc6NAiC9z7 GMAJItWSDyS+x1nStHw/sczWEvyHzkwSvEIAdQq9z1A5mIlpqcuB8xp35clPb3f2 hQM5CUCGcHafrj4WYaPBImrRxxI9NgI0vAeQjhJwP1iEOq4L9+pqC00SNhtKutE8 mKrUjiNDoj7GAzjPka8Odbln5/pQrp2fQOvoq89GdbubZEYeVXw6I9ILWqLbCxSC UuDZ95JNUCxZE5ZLjIfnw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudefiedgudefudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredt jeenucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsoh guvghrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgr thhtvghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegff elfeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep nhhikhhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtg hpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrkhgrrhhirdgr ihhluhhssehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepghgvvghrtheslh hinhhugidqmheikehkrdhorhhgpdhrtghpthhtohepmhgthhgvhhgrsgeskhgvrhhnvghl rdhorhhgpdhrtghpthhtoheplhhinhhugidqmhgvughirgesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhrvghnvghsrghsqdhsohgtsehvghgvrhdr khgvrhhnvghlrdhorhhgpdhrtghpthhtohepnhhikhhlrghsrdhsohguvghrlhhunhguod hrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvg X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 4 Jan 2025 14:57:05 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Sakari Ailus , Geert Uytterhoeven , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 1/2] media: v4l: fwnode: Add definitions for CSI-2 C-PHY line-orders Date: Sat, 4 Jan 2025 20:55:47 +0100 Message-ID: <20250104195548.1915578-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250104195548.1915578-1-niklas.soderlund+renesas@ragnatech.se> References: <20250104195548.1915578-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add definitions to match the ones in video-interfaces.h for the C-PHY line orders defined in MIPI Discovery and Configuration (DisCo) Specification for Imaging. This provides a way smiler to what is done for media bus types which also have named defines in video-interfaces.h that benefit from having human readable defines in code and not just in device tree sources. Signed-off-by: Niklas Söderlund --- include/media/v4l2-fwnode.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index f7c57c776589..fda5d740ede5 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -180,6 +180,24 @@ enum v4l2_fwnode_bus_type { NR_OF_V4L2_FWNODE_BUS_TYPE }; +/** + * enum v4l2_fwnode_csi2_cphy_line_orders_type - CSI-2 C-PHY line order + * @V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_ABC: C-PHY line order ABC + * @V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_ACB: C-PHY line order ACB + * @V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_BAC: C-PHY line order BAC + * @V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_BCA: C-PHY line order BCA + * @V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_CAB: C-PHY line order CAB + * @V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_CBA: C-PHY line order CBA + */ +enum v4l2_fwnode_csi2_cphy_line_orders_type { + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_ABC = 0, + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_ACB, + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_BAC, + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_BCA, + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_CAB, + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_CBA +}; + /** * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties * @fwnode: pointer to the endpoint's fwnode handle From patchwork Sat Jan 4 19:55:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 855099 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 3EB664C9D; Sat, 4 Jan 2025 19:57:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736020632; cv=none; b=PW8ocbLb0TB8o6BjoCD6oMbXV12ua7WKffLEn3JlsaDp+ZNZl1qN88IazpOAmYel0H8ey49cC7PxTR8Jo+Pav8fcYNdih3unct5t3okqxr18ZmPHvr1yecXxqEPHTJAQECNGnyjKbEnoSITloDCyYXIKdm1t0lmPJYrjyknMO9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736020632; c=relaxed/simple; bh=GIqFPcIPDL8N3uqaFtGti7ZmkCBgON6sP2qJSYccXJU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y4Q7k5ySrWV6CLJZp0ymzdqiKEB72tsUdJ3Jq6M53jugWhVxWaELrIXBLl1RwkrQGUHqLb+dRcRNXfgJGbny0RSLJ9XSpCLgIBDskFH6HG5w/U2y6BhS47LmywY58czHkGA7xi0CzoWyUd+hHogIrMhi2mog/WVITBlRJZw7VRo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=JJR2OSsp; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ipCSNoz8; arc=none smtp.client-ip=202.12.124.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="JJR2OSsp"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ipCSNoz8" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id 50A71114010E; Sat, 4 Jan 2025 14:57:09 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Sat, 04 Jan 2025 14:57:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1736020629; x=1736107029; bh=r837jh24yXoA8gp2+I/Dys+rd+1nDgZ5PuemLQfc7f0=; b= JJR2OSspiV7Uh3CfpvEQGLYI6G/P15isaOgDsSp3Bj8D42/oG7mzVz9wZ5ShtzOo ZiicvMaF9dW7jdTG4p5oZVoAMeMN8U6nQp1mO62ET/zy7dy6ix63XrTHgtdytchE UbO/XnGeaY4e/9yXN4RzEs1FFLGSrVIq11hwsFzOwLrHbtB0qj+vthU2kePzPNpi FgiT1feG9mkry1nS7zWWmZ4SMKxMv98kwEtu6RDqMfkIT1bTJyobWsAv0Ojo5F4K nMCmH4ulVaHK+tVujqGhqg/bXR2wG6qI075AOO52vMJVnVWqzmZCqPkyt25Acgmn rJ0mlG4X00FKyjtdtlfXKA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736020629; x= 1736107029; bh=r837jh24yXoA8gp2+I/Dys+rd+1nDgZ5PuemLQfc7f0=; b=i pCSNoz8nv1EpDeuUpQSdpd4CABlowm0k7/lOj9l9GiZyhSsbVCqqV2Sn7dJh66oU a9KOfxUei3mqQ55yXiwbzqiBC5UT9wdwwqUGZ0ucAgFcAAiin68WmyIY8DpVy3uU Cld6oUjOFZ5IEXSIqZPj0R1OrybA5wmhG1DctcUrvuH+l0WKd9HGsPcHnnIOdETk LrbF4lpv7N1VdIQ1R/jeDpm1D1b1oVJ+5aJWTdSqqK1JysxXpksnHNAseZADdDeW brtd83ADEQeLzU3TggkJw6T7eg80cZ+XF7B0VILt7O9A+Lvt8JMBvW7f37mJxc8l 00xqwxNdBkHv9Q9Geke4g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudefiedgudefudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredt jeenucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsoh guvghrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgr thhtvghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegff elfeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep nhhikhhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtg hpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrkhgrrhhirdgr ihhluhhssehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepghgvvghrtheslh hinhhugidqmheikehkrdhorhhgpdhrtghpthhtohepmhgthhgvhhgrsgeskhgvrhhnvghl rdhorhhgpdhrtghpthhtoheplhhinhhugidqmhgvughirgesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhrvghnvghsrghsqdhsohgtsehvghgvrhdr khgvrhhnvghlrdhorhhgpdhrtghpthhtohepnhhikhhlrghsrdhsohguvghrlhhunhguod hrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvg X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 4 Jan 2025 14:57:08 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Sakari Ailus , Geert Uytterhoeven , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 2/2] media: v4l: fwnode: Parse CSI-2 C-PHY line-orders like bus-type Date: Sat, 4 Jan 2025 20:55:48 +0100 Message-ID: <20250104195548.1915578-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250104195548.1915578-1-niklas.soderlund+renesas@ragnatech.se> References: <20250104195548.1915578-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Provided a safe-guard from the raw values used in device tree sources and the in-kernel defines used to describe the different line orders. This mimics what have been done for the bus-type property to provide the same safe-guard. The macros used in device tree sources are defined in video-interfaces.h (MEDIA_BUS_CSI2_CPHY_LINE_ORDER_*) and are only visible to DTS source files. These raw values map directly to the in-kernel names by fwnode defines in v4l2-fwnode.h (V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_*). These fwnode defines are finally translated to defines which are exposed to drivers to act on (V4L2_MBUS_CSI2_CPHY_LINE_ORDER_*). Previously the translation to values provided to drivers have exploited the fact that the numerical value for each setting are the same for the defines used in device tree sources. While this is unlikely to change this harmonises the bus-type and line-orders parsing to work using the same mechanics, while at the same time make the large CSI-2 parsing function a little more readable. Suggested-by: Geert Uytterhoeven Signed-off-by: Niklas Söderlund --- drivers/media/v4l2-core/v4l2-fwnode.c | 80 ++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 14 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index cb153ce42c45..69f6d1df8c39 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -121,6 +121,70 @@ v4l2_fwnode_mbus_type_to_string(enum v4l2_mbus_type type) return conv ? conv->name : "not found"; } +static const struct v4l2_fwnode_csi2_cphy_line_orders_conv { + enum v4l2_fwnode_csi2_cphy_line_orders_type fwnode_order; + enum v4l2_mbus_csi2_cphy_line_orders_type mbus_order; + const char *name; +} csi2_cphy_line_orders[] = { + { + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_ABC, + V4L2_MBUS_CSI2_CPHY_LINE_ORDER_ABC, + "ABC", + }, { + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_ACB, + V4L2_MBUS_CSI2_CPHY_LINE_ORDER_ACB, + "ACB", + }, { + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_BAC, + V4L2_MBUS_CSI2_CPHY_LINE_ORDER_BAC, + "BAC", + }, { + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_BCA, + V4L2_MBUS_CSI2_CPHY_LINE_ORDER_BCA, + "BCA", + }, { + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_CAB, + V4L2_MBUS_CSI2_CPHY_LINE_ORDER_CAB, + "CAB", + }, { + V4L2_FWNODE_CSI2_CPHY_LINE_ORDER_CBA, + V4L2_MBUS_CSI2_CPHY_LINE_ORDER_CBA, + "CBA", + } +}; + +static const struct v4l2_fwnode_csi2_cphy_line_orders_conv * +get_v4l2_fwnode_line_order_conv_by_fwnode_order(enum v4l2_fwnode_csi2_cphy_line_orders_type order) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(csi2_cphy_line_orders); i++) + if (csi2_cphy_line_orders[i].fwnode_order == order) + return &csi2_cphy_line_orders[i]; + + /* The default line order is ABC */ + pr_warn("invalid line-order assuming ABC (got %u)\n", order); + return &csi2_cphy_line_orders[0]; +} + +static enum v4l2_mbus_csi2_cphy_line_orders_type +v4l2_fwnode_line_order_to_mbus(enum v4l2_fwnode_csi2_cphy_line_orders_type order) +{ + const struct v4l2_fwnode_csi2_cphy_line_orders_conv *conv = + get_v4l2_fwnode_line_order_conv_by_fwnode_order(order); + + return conv->mbus_order; +} + +static const char * +v4l2_fwnode_line_order_to_string(enum v4l2_fwnode_csi2_cphy_line_orders_type order) +{ + const struct v4l2_fwnode_csi2_cphy_line_orders_conv *conv = + get_v4l2_fwnode_line_order_conv_by_fwnode_order(order); + + return conv->name; +} + static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep, enum v4l2_mbus_type bus_type) @@ -268,21 +332,9 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, num_data_lanes); for (i = 0; i < num_data_lanes; i++) { - static const char * const orders[] = { - "ABC", "ACB", "BAC", "BCA", "CAB", "CBA" - }; - - if (array[i] >= ARRAY_SIZE(orders)) { - pr_warn("lane %u invalid line-order assuming ABC (got %u)\n", - i, array[i]); - bus->line_orders[i] = - V4L2_MBUS_CSI2_CPHY_LINE_ORDER_ABC; - continue; - } - - bus->line_orders[i] = array[i]; + bus->line_orders[i] = v4l2_fwnode_line_order_to_mbus(array[i]); pr_debug("lane %u line order %s", i, - orders[array[i]]); + v4l2_fwnode_line_order_to_string(array[i])); } } else { for (i = 0; i < num_data_lanes; i++)