All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damon Ding <damon.ding@rock-chips.com>
To: Luca Ceresoli <luca.ceresoli@bootlin.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Sandy Huang <hjc@rock-chips.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Andy Yan <andy.yan@rock-chips.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping
Date: Fri, 21 Aug 2026 16:09:40 +0800	[thread overview]
Message-ID: <c5fba12d-487c-46ee-8ea3-3a844f383555@rock-chips.com> (raw)
In-Reply-To: <178714408666.358642.10737743872246645132.b4-review@b4>

Hi Luca,

On 8/19/2026 8:54 PM, Luca Ceresoli wrote:
> Hello,
> 
>> Parse the optional 'data-lanes' device tree property to support
>> custom physical lane mapping configuration.
>>
>> If no valid configuration is found, fall back to the default
>> lane map (0, 1, 2, 3) automatically and keep the driver running.
>>
>> Lane mapping is mainly used for below scenarios:
>> 1. Correct PCB lane swap and differential line routing crossover
>>     without hardware changes;
>> 2. Adapt mismatched lane pin definitions between SoC and eDP panel;
>> 3. Support multiple panel hardware variants on the same board
>>     by configuring data-lanes in device tree only.
>>
>> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
>> Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
>>
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> index 117448b854db..4aa444858bb6 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> @@ -1240,6 +1240,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
>>   	.detect = analogix_dp_bridge_detect,
>>   };
>>
>> +static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp)
>> +{
>> +	struct video_info *video_info = &dp->video_info;
>> +	struct device_node *endpoint;
>> +	u32 tmp[LANE_COUNT4];
> 
> The 'tmp' name is not very useful to understand what it's for. Based on the
> code I'd say it stores a lane index, so what about 'lane_idx', unless you
> can propose a better name.

Good idea, will fix in v8.

> 
>> +	u32 map[LANE_COUNT4] = {0, 1, 2, 3};
>> +	bool used[LANE_COUNT4] = {false};
>> +	int num_lanes;
>> +	int ret, i;
>> +
>> +	memcpy(video_info->lane_map, map, sizeof(map));
>> +
>> +	num_lanes = drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, 1,
>> +						   video_info->max_lane_count);
>> +	if (num_lanes < 0)
>> +		return -EINVAL;
>> +
>> +	endpoint = of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1);
> 
> 
>> +	if (!endpoint)
>> +		return -EINVAL;
>> +
>> +	ret = of_property_read_u32_array(endpoint, "data-lanes", tmp, num_lanes);
>> +	of_node_put(endpoint);
>> +	if (ret)
>> +		return -EINVAL;
>> +
>> +	for (i = 0; i < num_lanes; i++) {
>> +		if (tmp[i] >= LANE_COUNT4) {
>> +			dev_dbg(dp->dev, "data-lanes[%d] = %u is out of range\n", i, tmp[i]);
>> +			return -EINVAL;
>> +		}
>> +
>> +		if (used[tmp[i]]) {
>> +			dev_dbg(dp->dev, "data-lanes[%d] = %u is duplicate\n", i, tmp[i]);
>> +			return -EINVAL;
>> +		}
>> +
>> +		used[tmp[i]] = true;
>> +		map[i] = tmp[i];
>> +	}
>> +
>> +	for (i = 0; i < LANE_COUNT4 && num_lanes < LANE_COUNT4; i++) {
>> +		if (!used[i])
>> +			map[num_lanes++] = i;
>> +	}
> 
> This loop is a bit obscure to me. After reading it a few times I _think_ it
> does the following:
> 
>   /*
>    * Fill the unused map[] entries with the unused lane indices <reason?>. E.g.:
>    * used[] values = {0,1,0,1} // Only lanes 1 and 3 are used
>    * map[] before  = {3,1,x,x} // x = unassigned
>    * map[] after   = {3,1,0,2} // filled last 2 entries with the unused lane indices
>    */
> 
> Is my understanding correct? If it is, please fill <reason?> and add the
> above comment (possibly improved) before the loop.
> 
> 

You are right.

The hardware register defaults to 0xE4, which corresponds to map = {0, 
1, 2, 3}. Functionally, writing duplicate mappings for unused lanes 
would not cause issues.

Unused lanes are populated with non‑duplicated physical lane indices to 
support DP HPD scenarios where different devices with varying lane 
counts may be connected, as well as to keep the register content reasonable.

The comment will be added in v8.

Best regards,
Damon


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Damon Ding <damon.ding@rock-chips.com>
To: Luca Ceresoli <luca.ceresoli@bootlin.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Sandy Huang <hjc@rock-chips.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Andy Yan <andy.yan@rock-chips.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping
Date: Fri, 21 Aug 2026 16:09:40 +0800	[thread overview]
Message-ID: <c5fba12d-487c-46ee-8ea3-3a844f383555@rock-chips.com> (raw)
In-Reply-To: <178714408666.358642.10737743872246645132.b4-review@b4>

Hi Luca,

On 8/19/2026 8:54 PM, Luca Ceresoli wrote:
> Hello,
> 
>> Parse the optional 'data-lanes' device tree property to support
>> custom physical lane mapping configuration.
>>
>> If no valid configuration is found, fall back to the default
>> lane map (0, 1, 2, 3) automatically and keep the driver running.
>>
>> Lane mapping is mainly used for below scenarios:
>> 1. Correct PCB lane swap and differential line routing crossover
>>     without hardware changes;
>> 2. Adapt mismatched lane pin definitions between SoC and eDP panel;
>> 3. Support multiple panel hardware variants on the same board
>>     by configuring data-lanes in device tree only.
>>
>> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
>> Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
>>
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> index 117448b854db..4aa444858bb6 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> @@ -1240,6 +1240,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
>>   	.detect = analogix_dp_bridge_detect,
>>   };
>>
>> +static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp)
>> +{
>> +	struct video_info *video_info = &dp->video_info;
>> +	struct device_node *endpoint;
>> +	u32 tmp[LANE_COUNT4];
> 
> The 'tmp' name is not very useful to understand what it's for. Based on the
> code I'd say it stores a lane index, so what about 'lane_idx', unless you
> can propose a better name.

Good idea, will fix in v8.

> 
>> +	u32 map[LANE_COUNT4] = {0, 1, 2, 3};
>> +	bool used[LANE_COUNT4] = {false};
>> +	int num_lanes;
>> +	int ret, i;
>> +
>> +	memcpy(video_info->lane_map, map, sizeof(map));
>> +
>> +	num_lanes = drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, 1,
>> +						   video_info->max_lane_count);
>> +	if (num_lanes < 0)
>> +		return -EINVAL;
>> +
>> +	endpoint = of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1);
> 
> 
>> +	if (!endpoint)
>> +		return -EINVAL;
>> +
>> +	ret = of_property_read_u32_array(endpoint, "data-lanes", tmp, num_lanes);
>> +	of_node_put(endpoint);
>> +	if (ret)
>> +		return -EINVAL;
>> +
>> +	for (i = 0; i < num_lanes; i++) {
>> +		if (tmp[i] >= LANE_COUNT4) {
>> +			dev_dbg(dp->dev, "data-lanes[%d] = %u is out of range\n", i, tmp[i]);
>> +			return -EINVAL;
>> +		}
>> +
>> +		if (used[tmp[i]]) {
>> +			dev_dbg(dp->dev, "data-lanes[%d] = %u is duplicate\n", i, tmp[i]);
>> +			return -EINVAL;
>> +		}
>> +
>> +		used[tmp[i]] = true;
>> +		map[i] = tmp[i];
>> +	}
>> +
>> +	for (i = 0; i < LANE_COUNT4 && num_lanes < LANE_COUNT4; i++) {
>> +		if (!used[i])
>> +			map[num_lanes++] = i;
>> +	}
> 
> This loop is a bit obscure to me. After reading it a few times I _think_ it
> does the following:
> 
>   /*
>    * Fill the unused map[] entries with the unused lane indices <reason?>. E.g.:
>    * used[] values = {0,1,0,1} // Only lanes 1 and 3 are used
>    * map[] before  = {3,1,x,x} // x = unassigned
>    * map[] after   = {3,1,0,2} // filled last 2 entries with the unused lane indices
>    */
> 
> Is my understanding correct? If it is, please fill <reason?> and add the
> above comment (possibly improved) before the loop.
> 
> 

You are right.

The hardware register defaults to 0xE4, which corresponds to map = {0, 
1, 2, 3}. Functionally, writing duplicate mappings for unused lanes 
would not cause issues.

Unused lanes are populated with non‑duplicated physical lane indices to 
support DP HPD scenarios where different devices with varying lane 
counts may be connected, as well as to keep the register content reasonable.

The comment will be added in v8.

Best regards,
Damon


  reply	other threads:[~2026-08-21  8:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19  7:52 [PATCH v7 0/5] Add eDP lane mapping support Damon Ding
2026-08-19  7:52 ` Damon Ding
2026-08-19  7:52 ` [PATCH v7 1/5] dt-bindings: display: bridge: analogix-dp: Add data-lanes support for endpoint Damon Ding
2026-08-19  7:52   ` Damon Ding
2026-08-19 12:54   ` Luca Ceresoli
2026-08-19 12:54     ` Luca Ceresoli
2026-08-19  7:52 ` [PATCH v7 2/5] drm/dp: Add helper to validate DP lane counts Damon Ding
2026-08-19  7:52   ` Damon Ding
2026-08-19  7:52 ` [PATCH v7 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties Damon Ding
2026-08-19  7:52   ` Damon Ding
2026-08-19 12:54   ` Luca Ceresoli
2026-08-19 12:54     ` Luca Ceresoli
2026-08-21  7:37     ` Damon Ding
2026-08-21  7:37       ` Damon Ding
2026-08-19  7:52 ` [PATCH v7 4/5] drm/bridge: analogix_dp: Add validation for samsung, lane-count property Damon Ding
2026-08-19  7:52   ` [PATCH v7 4/5] drm/bridge: analogix_dp: Add validation for samsung,lane-count property Damon Ding
2026-08-19  7:52   ` Damon Ding
2026-08-19  7:52 ` [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping Damon Ding
2026-08-19  7:52   ` Damon Ding
2026-08-19  8:04   ` sashiko-bot
2026-08-19  8:53     ` Damon Ding
2026-08-19 12:58       ` Luca Ceresoli
2026-08-21  7:16         ` Damon Ding
2026-08-19 12:54   ` Luca Ceresoli
2026-08-19 12:54     ` Luca Ceresoli
2026-08-21  8:09     ` Damon Ding [this message]
2026-08-21  8:09       ` Damon Ding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c5fba12d-487c-46ee-8ea3-3a844f383555@rock-chips.com \
    --to=damon.ding@rock-chips.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=andy.yan@rock-chips.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=m.szyprowski@samsung.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=robh@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.