diff mbox series

[05/60] drm/bridge: simple-bridge: Add support for non-VGA bridges

Message ID 20190707181937.6250-2-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series drm/omap: Replace custom display drivers with drm_bridge and drm_panel | expand

Commit Message

Laurent Pinchart July 7, 2019, 6:18 p.m. UTC
Create a new simple_bridge_info structure that stores information about
the bridge model, and store the bridge timings in there, along with the
connector type. Use that new structure for of_device_id data. This
enables support for non-VGA bridges.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/bridge/simple-bridge.c | 41 ++++++++++++++++++--------
 1 file changed, 29 insertions(+), 12 deletions(-)

Comments

Andrzej Hajda July 9, 2019, 2:08 p.m. UTC | #1
On 07.07.2019 20:18, Laurent Pinchart wrote:
> Create a new simple_bridge_info structure that stores information about
> the bridge model, and store the bridge timings in there, along with the
> connector type. Use that new structure for of_device_id data. This
> enables support for non-VGA bridges.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>

 --
Regards
Andrzej


> ---
>  drivers/gpu/drm/bridge/simple-bridge.c | 41 ++++++++++++++++++--------
>  1 file changed, 29 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
> index da5479bd5878..bff240cf283d 100644
> --- a/drivers/gpu/drm/bridge/simple-bridge.c
> +++ b/drivers/gpu/drm/bridge/simple-bridge.c
> @@ -16,10 +16,17 @@
>  #include <drm/drm_print.h>
>  #include <drm/drm_probe_helper.h>
>  
> +struct simple_bridge_info {
> +	const struct drm_bridge_timings *timings;
> +	unsigned int type;
> +};
> +
>  struct simple_bridge {
>  	struct drm_bridge	bridge;
>  	struct drm_connector	connector;
>  
> +	const struct simple_bridge_info *info;
> +
>  	struct i2c_adapter	*ddc;
>  	struct regulator	*vdd;
>  };
> @@ -113,7 +120,7 @@ static int simple_bridge_attach(struct drm_bridge *bridge)
>  				 &simple_bridge_con_helper_funcs);
>  	ret = drm_connector_init(bridge->dev, &sbridge->connector,
>  				 &simple_bridge_con_funcs,
> -				 DRM_MODE_CONNECTOR_VGA);
> +				 sbridge->info->type);
>  	if (ret) {
>  		DRM_ERROR("Failed to initialize connector\n");
>  		return ret;
> @@ -182,6 +189,8 @@ static int simple_bridge_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	platform_set_drvdata(pdev, sbridge);
>  
> +	sbridge->info = of_device_get_match_data(&pdev->dev);
> +
>  	sbridge->vdd = devm_regulator_get_optional(&pdev->dev, "vdd");
>  	if (IS_ERR(sbridge->vdd)) {
>  		int ret = PTR_ERR(sbridge->vdd);
> @@ -204,7 +213,7 @@ static int simple_bridge_probe(struct platform_device *pdev)
>  
>  	sbridge->bridge.funcs = &simple_bridge_bridge_funcs;
>  	sbridge->bridge.of_node = pdev->dev.of_node;
> -	sbridge->bridge.timings = of_device_get_match_data(&pdev->dev);
> +	sbridge->bridge.timings = sbridge->info->timings;
>  
>  	drm_bridge_add(&sbridge->bridge);
>  
> @@ -264,19 +273,27 @@ static const struct drm_bridge_timings ti_ths8135_bridge_timings = {
>  static const struct of_device_id simple_bridge_match[] = {
>  	{
>  		.compatible = "dumb-vga-dac",
> -		.data = NULL,
> -	},
> -	{
> +		.data = &(const struct simple_bridge_info) {
> +			.type = DRM_MODE_CONNECTOR_VGA,
> +		},
> +	}, {
>  		.compatible = "adi,adv7123",
> -		.data = &default_bridge_timings,
> -	},
> -	{
> +		.data = &(const struct simple_bridge_info) {
> +			.timings = &default_bridge_timings,
> +			.type = DRM_MODE_CONNECTOR_VGA,
> +		},
> +	}, {
>  		.compatible = "ti,ths8135",
> -		.data = &ti_ths8135_bridge_timings,
> -	},
> -	{
> +		.data = &(const struct simple_bridge_info) {
> +			.timings = &ti_ths8135_bridge_timings,
> +			.type = DRM_MODE_CONNECTOR_VGA,
> +		},
> +	}, {
>  		.compatible = "ti,ths8134",
> -		.data = &ti_ths8134_bridge_timings,
> +		.data = &(const struct simple_bridge_info) {
> +			.timings = &ti_ths8134_bridge_timings,
> +			.type = DRM_MODE_CONNECTOR_VGA,
> +		},
>  	},
>  	{},
>  };
Stefan Agner July 26, 2019, 1:24 p.m. UTC | #2
On 2019-07-07 20:18, Laurent Pinchart wrote:
> Create a new simple_bridge_info structure that stores information about
> the bridge model, and store the bridge timings in there, along with the
> connector type. Use that new structure for of_device_id data. This
> enables support for non-VGA bridges.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/bridge/simple-bridge.c | 41 ++++++++++++++++++--------
>  1 file changed, 29 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/simple-bridge.c
> b/drivers/gpu/drm/bridge/simple-bridge.c
> index da5479bd5878..bff240cf283d 100644
> --- a/drivers/gpu/drm/bridge/simple-bridge.c
> +++ b/drivers/gpu/drm/bridge/simple-bridge.c
> @@ -16,10 +16,17 @@
>  #include <drm/drm_print.h>
>  #include <drm/drm_probe_helper.h>
>  
> +struct simple_bridge_info {
> +	const struct drm_bridge_timings *timings;
> +	unsigned int type;

How about connector_type? That is how this field is named in other
places.

Otherwise looks good to me.

Reviewed-by: Stefan Agner <stefan@agner.ch>

--
Stefan

> +};
> +
>  struct simple_bridge {
>  	struct drm_bridge	bridge;
>  	struct drm_connector	connector;
>  
> +	const struct simple_bridge_info *info;
> +
>  	struct i2c_adapter	*ddc;
>  	struct regulator	*vdd;
>  };
> @@ -113,7 +120,7 @@ static int simple_bridge_attach(struct drm_bridge *bridge)
>  				 &simple_bridge_con_helper_funcs);
>  	ret = drm_connector_init(bridge->dev, &sbridge->connector,
>  				 &simple_bridge_con_funcs,
> -				 DRM_MODE_CONNECTOR_VGA);
> +				 sbridge->info->type);
>  	if (ret) {
>  		DRM_ERROR("Failed to initialize connector\n");
>  		return ret;
> @@ -182,6 +189,8 @@ static int simple_bridge_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	platform_set_drvdata(pdev, sbridge);
>  
> +	sbridge->info = of_device_get_match_data(&pdev->dev);
> +
>  	sbridge->vdd = devm_regulator_get_optional(&pdev->dev, "vdd");
>  	if (IS_ERR(sbridge->vdd)) {
>  		int ret = PTR_ERR(sbridge->vdd);
> @@ -204,7 +213,7 @@ static int simple_bridge_probe(struct platform_device *pdev)
>  
>  	sbridge->bridge.funcs = &simple_bridge_bridge_funcs;
>  	sbridge->bridge.of_node = pdev->dev.of_node;
> -	sbridge->bridge.timings = of_device_get_match_data(&pdev->dev);
> +	sbridge->bridge.timings = sbridge->info->timings;
>  
>  	drm_bridge_add(&sbridge->bridge);
>  
> @@ -264,19 +273,27 @@ static const struct drm_bridge_timings
> ti_ths8135_bridge_timings = {
>  static const struct of_device_id simple_bridge_match[] = {
>  	{
>  		.compatible = "dumb-vga-dac",
> -		.data = NULL,
> -	},
> -	{
> +		.data = &(const struct simple_bridge_info) {
> +			.type = DRM_MODE_CONNECTOR_VGA,
> +		},
> +	}, {
>  		.compatible = "adi,adv7123",
> -		.data = &default_bridge_timings,
> -	},
> -	{
> +		.data = &(const struct simple_bridge_info) {
> +			.timings = &default_bridge_timings,
> +			.type = DRM_MODE_CONNECTOR_VGA,
> +		},
> +	}, {
>  		.compatible = "ti,ths8135",
> -		.data = &ti_ths8135_bridge_timings,
> -	},
> -	{
> +		.data = &(const struct simple_bridge_info) {
> +			.timings = &ti_ths8135_bridge_timings,
> +			.type = DRM_MODE_CONNECTOR_VGA,
> +		},
> +	}, {
>  		.compatible = "ti,ths8134",
> -		.data = &ti_ths8134_bridge_timings,
> +		.data = &(const struct simple_bridge_info) {
> +			.timings = &ti_ths8134_bridge_timings,
> +			.type = DRM_MODE_CONNECTOR_VGA,
> +		},
>  	},
>  	{},
>  };
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
index da5479bd5878..bff240cf283d 100644
--- a/drivers/gpu/drm/bridge/simple-bridge.c
+++ b/drivers/gpu/drm/bridge/simple-bridge.c
@@ -16,10 +16,17 @@ 
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 
+struct simple_bridge_info {
+	const struct drm_bridge_timings *timings;
+	unsigned int type;
+};
+
 struct simple_bridge {
 	struct drm_bridge	bridge;
 	struct drm_connector	connector;
 
+	const struct simple_bridge_info *info;
+
 	struct i2c_adapter	*ddc;
 	struct regulator	*vdd;
 };
@@ -113,7 +120,7 @@  static int simple_bridge_attach(struct drm_bridge *bridge)
 				 &simple_bridge_con_helper_funcs);
 	ret = drm_connector_init(bridge->dev, &sbridge->connector,
 				 &simple_bridge_con_funcs,
-				 DRM_MODE_CONNECTOR_VGA);
+				 sbridge->info->type);
 	if (ret) {
 		DRM_ERROR("Failed to initialize connector\n");
 		return ret;
@@ -182,6 +189,8 @@  static int simple_bridge_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	platform_set_drvdata(pdev, sbridge);
 
+	sbridge->info = of_device_get_match_data(&pdev->dev);
+
 	sbridge->vdd = devm_regulator_get_optional(&pdev->dev, "vdd");
 	if (IS_ERR(sbridge->vdd)) {
 		int ret = PTR_ERR(sbridge->vdd);
@@ -204,7 +213,7 @@  static int simple_bridge_probe(struct platform_device *pdev)
 
 	sbridge->bridge.funcs = &simple_bridge_bridge_funcs;
 	sbridge->bridge.of_node = pdev->dev.of_node;
-	sbridge->bridge.timings = of_device_get_match_data(&pdev->dev);
+	sbridge->bridge.timings = sbridge->info->timings;
 
 	drm_bridge_add(&sbridge->bridge);
 
@@ -264,19 +273,27 @@  static const struct drm_bridge_timings ti_ths8135_bridge_timings = {
 static const struct of_device_id simple_bridge_match[] = {
 	{
 		.compatible = "dumb-vga-dac",
-		.data = NULL,
-	},
-	{
+		.data = &(const struct simple_bridge_info) {
+			.type = DRM_MODE_CONNECTOR_VGA,
+		},
+	}, {
 		.compatible = "adi,adv7123",
-		.data = &default_bridge_timings,
-	},
-	{
+		.data = &(const struct simple_bridge_info) {
+			.timings = &default_bridge_timings,
+			.type = DRM_MODE_CONNECTOR_VGA,
+		},
+	}, {
 		.compatible = "ti,ths8135",
-		.data = &ti_ths8135_bridge_timings,
-	},
-	{
+		.data = &(const struct simple_bridge_info) {
+			.timings = &ti_ths8135_bridge_timings,
+			.type = DRM_MODE_CONNECTOR_VGA,
+		},
+	}, {
 		.compatible = "ti,ths8134",
-		.data = &ti_ths8134_bridge_timings,
+		.data = &(const struct simple_bridge_info) {
+			.timings = &ti_ths8134_bridge_timings,
+			.type = DRM_MODE_CONNECTOR_VGA,
+		},
 	},
 	{},
 };