[PATCH] drm: bridge: ldb: add support for using channel 1 only

Marek Vasut marex at denx.de
Wed Apr 5 03:28:16 UTC 2023


On 4/4/23 09:37, Luca Ceresoli wrote:

[...]

> @@ -177,28 +183,25 @@ static void fsl_ldb_atomic_enable(struct drm_bridge *bridge,
>   	clk_prepare_enable(fsl_ldb->clk);
>   
>   	/* Program LDB_CTRL */
> -	reg = LDB_CTRL_CH0_ENABLE;
> -
> -	if (fsl_ldb->lvds_dual_link)
> -		reg |= LDB_CTRL_CH1_ENABLE | LDB_CTRL_SPLIT_MODE;
> -
> -	if (lvds_format_24bpp) {
> -		reg |= LDB_CTRL_CH0_DATA_WIDTH;
> -		if (fsl_ldb->lvds_dual_link)
> -			reg |= LDB_CTRL_CH1_DATA_WIDTH;
> -	}
> -
> -	if (lvds_format_jeida) {
> -		reg |= LDB_CTRL_CH0_BIT_MAPPING;
> -		if (fsl_ldb->lvds_dual_link)
> -			reg |= LDB_CTRL_CH1_BIT_MAPPING;
> -	}
> -
> -	if (mode->flags & DRM_MODE_FLAG_PVSYNC) {
> -		reg |= LDB_CTRL_DI0_VSYNC_POLARITY;
> -		if (fsl_ldb->lvds_dual_link)
> -			reg |= LDB_CTRL_DI1_VSYNC_POLARITY;
> -	}
> +	reg =

Cosmetic nit, do we need the newline here , can't we just move the first 
'(fsl_ldb->ch0_enabled ? LDB_CTRL_CH0_ENABLE : 0) |' on the same line as 
'reg =' ? It might need a bit of indent with spaces, but that should be OK.

> +		(fsl_ldb->ch0_enabled ? LDB_CTRL_CH0_ENABLE : 0) |
> +		(fsl_ldb->ch1_enabled ? LDB_CTRL_CH1_ENABLE : 0) |
> +		(fsl_ldb_is_dual(fsl_ldb) ? LDB_CTRL_SPLIT_MODE : 0);
> +
> +	if (lvds_format_24bpp)
> +		reg |=
> +			(fsl_ldb->ch0_enabled ? LDB_CTRL_CH0_DATA_WIDTH : 0) |
> +			(fsl_ldb->ch1_enabled ? LDB_CTRL_CH1_DATA_WIDTH : 0);
> +
> +	if (lvds_format_jeida)
> +		reg |=
> +			(fsl_ldb->ch0_enabled ? LDB_CTRL_CH0_BIT_MAPPING : 0) |
> +			(fsl_ldb->ch1_enabled ? LDB_CTRL_CH1_BIT_MAPPING : 0);
> +
> +	if (mode->flags & DRM_MODE_FLAG_PVSYNC)
> +		reg |=
> +			(fsl_ldb->ch0_enabled ? LDB_CTRL_DI0_VSYNC_POLARITY : 0) |
> +			(fsl_ldb->ch1_enabled ? LDB_CTRL_DI1_VSYNC_POLARITY : 0);
>   
>   	regmap_write(fsl_ldb->regmap, fsl_ldb->devdata->ldb_ctrl, reg);

[...]

> @@ -311,10 +314,23 @@ static int fsl_ldb_probe(struct platform_device *pdev)
>   	if (IS_ERR(fsl_ldb->regmap))
>   		return PTR_ERR(fsl_ldb->regmap);
>   
> -	/* Locate the panel DT node. */
> -	panel_node = of_graph_get_remote_node(dev->of_node, 1, 0);
> -	if (!panel_node)
> -		return -ENXIO;
> +	/* Locate the remote ports and the panel node */
> +	remote1 = of_graph_get_remote_node(dev->of_node, 1, 0);
> +	remote2 = of_graph_get_remote_node(dev->of_node, 2, 0);
> +	fsl_ldb->ch0_enabled = (remote1 != NULL);
> +	fsl_ldb->ch1_enabled = (remote2 != NULL);
> +	panel_node = of_node_get(remote1 ? remote1 : remote2);

You can even do this without the middle 'remote1' I think:

panel_node = of_node_get(remote1 ? : remote2);

> +	of_node_put(remote1);
> +	of_node_put(remote2);
> +
> +	if (!fsl_ldb->ch0_enabled && !fsl_ldb->ch1_enabled) {
> +		of_node_put(panel_node);
> +		return dev_err_probe(dev, -ENXIO, "No panel node found");
> +	}
> +
> +	dev_dbg(dev, "Using %s\n",
> +		fsl_ldb_is_dual(fsl_ldb) ? "dual mode" :

I think this is called "dual-link mode" , maybe update the string .

> +		fsl_ldb->ch0_enabled ? "channel 0" : "channel 1");
>   
>   	panel = of_drm_find_panel(panel_node);
>   	of_node_put(panel_node);
> @@ -325,20 +341,26 @@ static int fsl_ldb_probe(struct platform_device *pdev)
>   	if (IS_ERR(fsl_ldb->panel_bridge))
>   		return PTR_ERR(fsl_ldb->panel_bridge);
>   
> -	/* Determine whether this is dual-link configuration */
> -	port1 = of_graph_get_port_by_id(dev->of_node, 1);
> -	port2 = of_graph_get_port_by_id(dev->of_node, 2);
> -	dual_link = drm_of_lvds_get_dual_link_pixel_order(port1, port2);
> -	of_node_put(port1);
> -	of_node_put(port2);
>   
> -	if (dual_link == DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS) {
> -		dev_err(dev, "LVDS channel pixel swap not supported.\n");
> -		return -EINVAL;
> -	}
> +	if (fsl_ldb_is_dual(fsl_ldb)) {
> +		struct device_node *port1, *port2;
> +
> +		port1 = of_graph_get_port_by_id(dev->of_node, 1);
> +		port2 = of_graph_get_port_by_id(dev->of_node, 2);
> +		dual_link = drm_of_lvds_get_dual_link_pixel_order(port1, port2);
> +		of_node_put(port1);
> +		of_node_put(port2);
>   
> -	if (dual_link == DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS)
> -		fsl_ldb->lvds_dual_link = true;
> +		if (dual_link < 0)
> +			return dev_err_probe(dev, dual_link,
> +					     "Error getting dual link configuration");

Does this need a trailing '\n' in the formatting string or not ? I think 
yes.

The rest looks good, with the few details fixed:

Reviewed-by: Marek Vasut <marex at denx.de>


More information about the dri-devel mailing list