Re: [PATCH v4 12/15] drm/bridge: megachips: add get_edid bridge operation

2020-07-26 Thread Laurent Pinchart
Hi Sam,

Thank you for the patch.

On Sun, Jul 26, 2020 at 10:33:21PM +0200, Sam Ravnborg wrote:
> To prepare for a chained bridge setup add support for the
> get_edid bridge operation.
> There is no need for a copy of the edid - so drop
> the pointer to the copy.
> 
> v2:
>   - Fix so we do not leak memory (Laurent)
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Peter Senna Tschudin 
> Cc: Martin Donnelly 
> Cc: Martyn Welch 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 

Reviewed-by: Laurent Pinchart 

> ---
>  .../bridge/megachips-stdp-ge-b850v3-fw.c  | 31 ++-
>  1 file changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
> b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> index 450dca33ea48..f7b55dc374ac 100644
> --- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> +++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
> @@ -61,7 +61,6 @@ struct ge_b850v3_lvds {
>   struct drm_bridge bridge;
>   struct i2c_client *stdp4028_i2c;
>   struct i2c_client *stdp2690_i2c;
> - struct edid *edid;
>  };
>  
>  static struct ge_b850v3_lvds *ge_b850v3_lvds_ptr;
> @@ -131,22 +130,26 @@ static u8 *stdp2690_get_edid(struct i2c_client *client)
>   return NULL;
>  }
>  
> -static int ge_b850v3_lvds_get_modes(struct drm_connector *connector)
> +static struct edid *ge_b850v3_lvds_get_edid(struct drm_bridge *bridge,
> + struct drm_connector *connector)
>  {
>   struct i2c_client *client;
> - int num_modes = 0;
>  
>   client = ge_b850v3_lvds_ptr->stdp2690_i2c;
>  
> - kfree(ge_b850v3_lvds_ptr->edid);
> - ge_b850v3_lvds_ptr->edid = (struct edid *)stdp2690_get_edid(client);
> + return (struct edid *)stdp2690_get_edid(client);
> +}
>  
> - if (ge_b850v3_lvds_ptr->edid) {
> - drm_connector_update_edid_property(connector,
> -   ge_b850v3_lvds_ptr->edid);
> - num_modes = drm_add_edid_modes(connector,
> -ge_b850v3_lvds_ptr->edid);
> - }
> +static int ge_b850v3_lvds_get_modes(struct drm_connector *connector)
> +{
> + struct edid *edid;
> + int num_modes;
> +
> + edid = ge_b850v3_lvds_get_edid(&ge_b850v3_lvds_ptr->bridge, connector);
> +
> + drm_connector_update_edid_property(connector, edid);
> + num_modes = drm_add_edid_modes(connector, edid);
> + kfree(edid);
>  
>   return num_modes;
>  }
> @@ -269,6 +272,7 @@ static int ge_b850v3_lvds_attach(struct drm_bridge 
> *bridge,
>  static const struct drm_bridge_funcs ge_b850v3_lvds_funcs = {
>   .attach = ge_b850v3_lvds_attach,
>   .detect = ge_b850v3_lvds_bridge_detect,
> + .get_edid = ge_b850v3_lvds_get_edid,
>  };
>  
>  static int ge_b850v3_lvds_init(struct device *dev)
> @@ -304,8 +308,6 @@ static void ge_b850v3_lvds_remove(void)
>  
>   drm_bridge_remove(&ge_b850v3_lvds_ptr->bridge);
>  
> - kfree(ge_b850v3_lvds_ptr->edid);
> -
>   ge_b850v3_lvds_ptr = NULL;
>  out:
>   mutex_unlock(&ge_b850v3_lvds_dev_mutex);
> @@ -323,7 +325,8 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client 
> *stdp4028_i2c,
>  
>   /* drm bridge initialization */
>   ge_b850v3_lvds_ptr->bridge.funcs = &ge_b850v3_lvds_funcs;
> - ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT;
> + ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
> +  DRM_BRIDGE_OP_EDID;
>   ge_b850v3_lvds_ptr->bridge.of_node = dev->of_node;
>   drm_bridge_add(&ge_b850v3_lvds_ptr->bridge);
>  

-- 
Regards,

Laurent Pinchart
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 12/15] drm/bridge: megachips: add get_edid bridge operation

2020-07-26 Thread Sam Ravnborg
To prepare for a chained bridge setup add support for the
get_edid bridge operation.
There is no need for a copy of the edid - so drop
the pointer to the copy.

v2:
  - Fix so we do not leak memory (Laurent)

Signed-off-by: Sam Ravnborg 
Cc: Peter Senna Tschudin 
Cc: Martin Donnelly 
Cc: Martyn Welch 
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
---
 .../bridge/megachips-stdp-ge-b850v3-fw.c  | 31 ++-
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
index 450dca33ea48..f7b55dc374ac 100644
--- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
+++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
@@ -61,7 +61,6 @@ struct ge_b850v3_lvds {
struct drm_bridge bridge;
struct i2c_client *stdp4028_i2c;
struct i2c_client *stdp2690_i2c;
-   struct edid *edid;
 };
 
 static struct ge_b850v3_lvds *ge_b850v3_lvds_ptr;
@@ -131,22 +130,26 @@ static u8 *stdp2690_get_edid(struct i2c_client *client)
return NULL;
 }
 
-static int ge_b850v3_lvds_get_modes(struct drm_connector *connector)
+static struct edid *ge_b850v3_lvds_get_edid(struct drm_bridge *bridge,
+   struct drm_connector *connector)
 {
struct i2c_client *client;
-   int num_modes = 0;
 
client = ge_b850v3_lvds_ptr->stdp2690_i2c;
 
-   kfree(ge_b850v3_lvds_ptr->edid);
-   ge_b850v3_lvds_ptr->edid = (struct edid *)stdp2690_get_edid(client);
+   return (struct edid *)stdp2690_get_edid(client);
+}
 
-   if (ge_b850v3_lvds_ptr->edid) {
-   drm_connector_update_edid_property(connector,
- ge_b850v3_lvds_ptr->edid);
-   num_modes = drm_add_edid_modes(connector,
-  ge_b850v3_lvds_ptr->edid);
-   }
+static int ge_b850v3_lvds_get_modes(struct drm_connector *connector)
+{
+   struct edid *edid;
+   int num_modes;
+
+   edid = ge_b850v3_lvds_get_edid(&ge_b850v3_lvds_ptr->bridge, connector);
+
+   drm_connector_update_edid_property(connector, edid);
+   num_modes = drm_add_edid_modes(connector, edid);
+   kfree(edid);
 
return num_modes;
 }
@@ -269,6 +272,7 @@ static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
 static const struct drm_bridge_funcs ge_b850v3_lvds_funcs = {
.attach = ge_b850v3_lvds_attach,
.detect = ge_b850v3_lvds_bridge_detect,
+   .get_edid = ge_b850v3_lvds_get_edid,
 };
 
 static int ge_b850v3_lvds_init(struct device *dev)
@@ -304,8 +308,6 @@ static void ge_b850v3_lvds_remove(void)
 
drm_bridge_remove(&ge_b850v3_lvds_ptr->bridge);
 
-   kfree(ge_b850v3_lvds_ptr->edid);
-
ge_b850v3_lvds_ptr = NULL;
 out:
mutex_unlock(&ge_b850v3_lvds_dev_mutex);
@@ -323,7 +325,8 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client 
*stdp4028_i2c,
 
/* drm bridge initialization */
ge_b850v3_lvds_ptr->bridge.funcs = &ge_b850v3_lvds_funcs;
-   ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT;
+   ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
+DRM_BRIDGE_OP_EDID;
ge_b850v3_lvds_ptr->bridge.of_node = dev->of_node;
drm_bridge_add(&ge_b850v3_lvds_ptr->bridge);
 
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel