* [PATCH] drm: tda998x: Use drm_do_get_edid()
@ 2014-11-26 19:04 Laurent Pinchart
2014-11-26 19:59 ` Rob Clark
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Laurent Pinchart @ 2014-11-26 19:04 UTC (permalink / raw)
To: dri-devel; +Cc: Russell King
Replace the internal EDID read implementation by a call to the new EDID
read core function.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/gpu/drm/i2c/tda998x_drv.c | 86 ++++++++-------------------------------
1 file changed, 18 insertions(+), 68 deletions(-)
This patch has been compile-tested only as I lack test hardware. It depends on
"[PATCH v4 6/9] drm: Decouple EDID parsing from I2C adapter" previously posted
to the dri-devel mailing list.
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index d4762799351d..a267a78a0d0a 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1011,8 +1011,9 @@ tda998x_encoder_detect(struct tda998x_priv *priv)
connector_status_disconnected;
}
-static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk)
+static int read_edid_block(void *data, u8 *buf, unsigned int blk, size_t length)
{
+ struct tda998x_priv *priv = data;
uint8_t offset, segptr;
int ret, i;
@@ -1056,8 +1057,8 @@ static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk)
return -ETIMEDOUT;
}
- ret = reg_read_range(priv, REG_EDID_DATA_0, buf, EDID_LENGTH);
- if (ret != EDID_LENGTH) {
+ ret = reg_read_range(priv, REG_EDID_DATA_0, buf, length);
+ if (ret != length) {
dev_err(&priv->hdmi->dev, "failed to read edid block %d: %d\n",
blk, ret);
return ret;
@@ -1066,82 +1067,31 @@ static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk)
return 0;
}
-static uint8_t *do_get_edid(struct tda998x_priv *priv)
+static int
+tda998x_encoder_get_modes(struct tda998x_priv *priv,
+ struct drm_connector *connector)
{
- int j, valid_extensions = 0;
- uint8_t *block, *new;
- bool print_bad_edid = drm_debug & DRM_UT_KMS;
-
- if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
- return NULL;
+ struct edid *edid;
+ int n;
if (priv->rev == TDA19988)
reg_clear(priv, REG_TX4, TX4_PD_RAM);
- /* base block fetch */
- if (read_edid_block(priv, block, 0))
- goto fail;
-
- if (!drm_edid_block_valid(block, 0, print_bad_edid))
- goto fail;
-
- /* if there's no extensions, we're done */
- if (block[0x7e] == 0)
- goto done;
-
- new = krealloc(block, (block[0x7e] + 1) * EDID_LENGTH, GFP_KERNEL);
- if (!new)
- goto fail;
- block = new;
-
- for (j = 1; j <= block[0x7e]; j++) {
- uint8_t *ext_block = block + (valid_extensions + 1) * EDID_LENGTH;
- if (read_edid_block(priv, ext_block, j))
- goto fail;
-
- if (!drm_edid_block_valid(ext_block, j, print_bad_edid))
- goto fail;
+ edid = drm_do_get_edid(connector, read_edid_block, priv);
- valid_extensions++;
- }
-
- if (valid_extensions != block[0x7e]) {
- block[EDID_LENGTH-1] += block[0x7e] - valid_extensions;
- block[0x7e] = valid_extensions;
- new = krealloc(block, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL);
- if (!new)
- goto fail;
- block = new;
- }
-
-done:
if (priv->rev == TDA19988)
reg_set(priv, REG_TX4, TX4_PD_RAM);
- return block;
-
-fail:
- if (priv->rev == TDA19988)
- reg_set(priv, REG_TX4, TX4_PD_RAM);
- dev_warn(&priv->hdmi->dev, "failed to read EDID\n");
- kfree(block);
- return NULL;
-}
-
-static int
-tda998x_encoder_get_modes(struct tda998x_priv *priv,
- struct drm_connector *connector)
-{
- struct edid *edid = (struct edid *)do_get_edid(priv);
- int n = 0;
-
- if (edid) {
- drm_mode_connector_update_edid_property(connector, edid);
- n = drm_add_edid_modes(connector, edid);
- priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid);
- kfree(edid);
+ if (!edid) {
+ dev_warn(&priv->hdmi->dev, "failed to read EDID\n");
+ return 0;
}
+ drm_mode_connector_update_edid_property(connector, edid);
+ n = drm_add_edid_modes(connector, edid);
+ priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid);
+ kfree(edid);
+
return n;
}
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: tda998x: Use drm_do_get_edid()
2014-11-26 19:04 [PATCH] drm: tda998x: Use drm_do_get_edid() Laurent Pinchart
@ 2014-11-26 19:59 ` Rob Clark
2014-11-27 10:42 ` Jean-Francois Moine
2014-12-23 9:46 ` Laurent Pinchart
2 siblings, 0 replies; 4+ messages in thread
From: Rob Clark @ 2014-11-26 19:59 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Russell King, dri-devel
On Wed, Nov 26, 2014 at 2:04 PM, Laurent Pinchart
<laurent.pinchart+renesas@ideasonboard.com> wrote:
> Replace the internal EDID read implementation by a call to the new EDID
> read core function.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Thanks!
Reviewed-by: Rob Clark <robdclark@gmail.com>
> ---
> drivers/gpu/drm/i2c/tda998x_drv.c | 86 ++++++++-------------------------------
> 1 file changed, 18 insertions(+), 68 deletions(-)
>
> This patch has been compile-tested only as I lack test hardware. It depends on
> "[PATCH v4 6/9] drm: Decouple EDID parsing from I2C adapter" previously posted
> to the dri-devel mailing list.
>
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
> index d4762799351d..a267a78a0d0a 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -1011,8 +1011,9 @@ tda998x_encoder_detect(struct tda998x_priv *priv)
> connector_status_disconnected;
> }
>
> -static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk)
> +static int read_edid_block(void *data, u8 *buf, unsigned int blk, size_t length)
> {
> + struct tda998x_priv *priv = data;
> uint8_t offset, segptr;
> int ret, i;
>
> @@ -1056,8 +1057,8 @@ static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk)
> return -ETIMEDOUT;
> }
>
> - ret = reg_read_range(priv, REG_EDID_DATA_0, buf, EDID_LENGTH);
> - if (ret != EDID_LENGTH) {
> + ret = reg_read_range(priv, REG_EDID_DATA_0, buf, length);
> + if (ret != length) {
> dev_err(&priv->hdmi->dev, "failed to read edid block %d: %d\n",
> blk, ret);
> return ret;
> @@ -1066,82 +1067,31 @@ static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk)
> return 0;
> }
>
> -static uint8_t *do_get_edid(struct tda998x_priv *priv)
> +static int
> +tda998x_encoder_get_modes(struct tda998x_priv *priv,
> + struct drm_connector *connector)
> {
> - int j, valid_extensions = 0;
> - uint8_t *block, *new;
> - bool print_bad_edid = drm_debug & DRM_UT_KMS;
> -
> - if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
> - return NULL;
> + struct edid *edid;
> + int n;
>
> if (priv->rev == TDA19988)
> reg_clear(priv, REG_TX4, TX4_PD_RAM);
>
> - /* base block fetch */
> - if (read_edid_block(priv, block, 0))
> - goto fail;
> -
> - if (!drm_edid_block_valid(block, 0, print_bad_edid))
> - goto fail;
> -
> - /* if there's no extensions, we're done */
> - if (block[0x7e] == 0)
> - goto done;
> -
> - new = krealloc(block, (block[0x7e] + 1) * EDID_LENGTH, GFP_KERNEL);
> - if (!new)
> - goto fail;
> - block = new;
> -
> - for (j = 1; j <= block[0x7e]; j++) {
> - uint8_t *ext_block = block + (valid_extensions + 1) * EDID_LENGTH;
> - if (read_edid_block(priv, ext_block, j))
> - goto fail;
> -
> - if (!drm_edid_block_valid(ext_block, j, print_bad_edid))
> - goto fail;
> + edid = drm_do_get_edid(connector, read_edid_block, priv);
>
> - valid_extensions++;
> - }
> -
> - if (valid_extensions != block[0x7e]) {
> - block[EDID_LENGTH-1] += block[0x7e] - valid_extensions;
> - block[0x7e] = valid_extensions;
> - new = krealloc(block, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL);
> - if (!new)
> - goto fail;
> - block = new;
> - }
> -
> -done:
> if (priv->rev == TDA19988)
> reg_set(priv, REG_TX4, TX4_PD_RAM);
>
> - return block;
> -
> -fail:
> - if (priv->rev == TDA19988)
> - reg_set(priv, REG_TX4, TX4_PD_RAM);
> - dev_warn(&priv->hdmi->dev, "failed to read EDID\n");
> - kfree(block);
> - return NULL;
> -}
> -
> -static int
> -tda998x_encoder_get_modes(struct tda998x_priv *priv,
> - struct drm_connector *connector)
> -{
> - struct edid *edid = (struct edid *)do_get_edid(priv);
> - int n = 0;
> -
> - if (edid) {
> - drm_mode_connector_update_edid_property(connector, edid);
> - n = drm_add_edid_modes(connector, edid);
> - priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid);
> - kfree(edid);
> + if (!edid) {
> + dev_warn(&priv->hdmi->dev, "failed to read EDID\n");
> + return 0;
> }
>
> + drm_mode_connector_update_edid_property(connector, edid);
> + n = drm_add_edid_modes(connector, edid);
> + priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid);
> + kfree(edid);
> +
> return n;
> }
>
> --
> Regards,
>
> Laurent Pinchart
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: tda998x: Use drm_do_get_edid()
2014-11-26 19:04 [PATCH] drm: tda998x: Use drm_do_get_edid() Laurent Pinchart
2014-11-26 19:59 ` Rob Clark
@ 2014-11-27 10:42 ` Jean-Francois Moine
2014-12-23 9:46 ` Laurent Pinchart
2 siblings, 0 replies; 4+ messages in thread
From: Jean-Francois Moine @ 2014-11-27 10:42 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Russell King, dri-devel
On Wed, 26 Nov 2014 21:04:15 +0200
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> wrote:
> Replace the internal EDID read implementation by a call to the new EDID
> read core function.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/gpu/drm/i2c/tda998x_drv.c | 86 ++++++++-------------------------------
> 1 file changed, 18 insertions(+), 68 deletions(-)
>
> This patch has been compile-tested only as I lack test hardware. It depends on
> "[PATCH v4 6/9] drm: Decouple EDID parsing from I2C adapter" previously posted
> to the dri-devel mailing list.
Tested-by: Jean-Francois Moine <moinejf@free.fr>
on the Dove Cubox.
--
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef | http://moinejf.free.fr/
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: tda998x: Use drm_do_get_edid()
2014-11-26 19:04 [PATCH] drm: tda998x: Use drm_do_get_edid() Laurent Pinchart
2014-11-26 19:59 ` Rob Clark
2014-11-27 10:42 ` Jean-Francois Moine
@ 2014-12-23 9:46 ` Laurent Pinchart
2 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2014-12-23 9:46 UTC (permalink / raw)
To: Russell King; +Cc: Laurent Pinchart, dri-devel
Hi Russell,
On Wednesday 26 November 2014 21:04:15 Laurent Pinchart wrote:
> Replace the internal EDID read implementation by a call to the new EDID
> read core function.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Do you plan to take this patch in your tree or should I send a pull request to
Dave directly ?
> ---
> drivers/gpu/drm/i2c/tda998x_drv.c | 86 +++++++-----------------------------
> 1 file changed, 18 insertions(+), 68 deletions(-)
>
> This patch has been compile-tested only as I lack test hardware. It depends
> on "[PATCH v4 6/9] drm: Decouple EDID parsing from I2C adapter" previously
> posted to the dri-devel mailing list.
>
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c
> b/drivers/gpu/drm/i2c/tda998x_drv.c index d4762799351d..a267a78a0d0a 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -1011,8 +1011,9 @@ tda998x_encoder_detect(struct tda998x_priv *priv)
> connector_status_disconnected;
> }
>
> -static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int
> blk) +static int read_edid_block(void *data, u8 *buf, unsigned int blk,
> size_t length) {
> + struct tda998x_priv *priv = data;
> uint8_t offset, segptr;
> int ret, i;
>
> @@ -1056,8 +1057,8 @@ static int read_edid_block(struct tda998x_priv *priv,
> uint8_t *buf, int blk) return -ETIMEDOUT;
> }
>
> - ret = reg_read_range(priv, REG_EDID_DATA_0, buf, EDID_LENGTH);
> - if (ret != EDID_LENGTH) {
> + ret = reg_read_range(priv, REG_EDID_DATA_0, buf, length);
> + if (ret != length) {
> dev_err(&priv->hdmi->dev, "failed to read edid block %d: %d\n",
> blk, ret);
> return ret;
> @@ -1066,82 +1067,31 @@ static int read_edid_block(struct tda998x_priv
> *priv, uint8_t *buf, int blk) return 0;
> }
>
> -static uint8_t *do_get_edid(struct tda998x_priv *priv)
> +static int
> +tda998x_encoder_get_modes(struct tda998x_priv *priv,
> + struct drm_connector *connector)
> {
> - int j, valid_extensions = 0;
> - uint8_t *block, *new;
> - bool print_bad_edid = drm_debug & DRM_UT_KMS;
> -
> - if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
> - return NULL;
> + struct edid *edid;
> + int n;
>
> if (priv->rev == TDA19988)
> reg_clear(priv, REG_TX4, TX4_PD_RAM);
>
> - /* base block fetch */
> - if (read_edid_block(priv, block, 0))
> - goto fail;
> -
> - if (!drm_edid_block_valid(block, 0, print_bad_edid))
> - goto fail;
> -
> - /* if there's no extensions, we're done */
> - if (block[0x7e] == 0)
> - goto done;
> -
> - new = krealloc(block, (block[0x7e] + 1) * EDID_LENGTH, GFP_KERNEL);
> - if (!new)
> - goto fail;
> - block = new;
> -
> - for (j = 1; j <= block[0x7e]; j++) {
> - uint8_t *ext_block = block + (valid_extensions + 1) * EDID_LENGTH;
> - if (read_edid_block(priv, ext_block, j))
> - goto fail;
> -
> - if (!drm_edid_block_valid(ext_block, j, print_bad_edid))
> - goto fail;
> + edid = drm_do_get_edid(connector, read_edid_block, priv);
>
> - valid_extensions++;
> - }
> -
> - if (valid_extensions != block[0x7e]) {
> - block[EDID_LENGTH-1] += block[0x7e] - valid_extensions;
> - block[0x7e] = valid_extensions;
> - new = krealloc(block, (valid_extensions + 1) * EDID_LENGTH,
GFP_KERNEL);
> - if (!new)
> - goto fail;
> - block = new;
> - }
> -
> -done:
> if (priv->rev == TDA19988)
> reg_set(priv, REG_TX4, TX4_PD_RAM);
>
> - return block;
> -
> -fail:
> - if (priv->rev == TDA19988)
> - reg_set(priv, REG_TX4, TX4_PD_RAM);
> - dev_warn(&priv->hdmi->dev, "failed to read EDID\n");
> - kfree(block);
> - return NULL;
> -}
> -
> -static int
> -tda998x_encoder_get_modes(struct tda998x_priv *priv,
> - struct drm_connector *connector)
> -{
> - struct edid *edid = (struct edid *)do_get_edid(priv);
> - int n = 0;
> -
> - if (edid) {
> - drm_mode_connector_update_edid_property(connector, edid);
> - n = drm_add_edid_modes(connector, edid);
> - priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid);
> - kfree(edid);
> + if (!edid) {
> + dev_warn(&priv->hdmi->dev, "failed to read EDID\n");
> + return 0;
> }
>
> + drm_mode_connector_update_edid_property(connector, edid);
> + n = drm_add_edid_modes(connector, edid);
> + priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid);
> + kfree(edid);
> +
> return n;
> }
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-23 9:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26 19:04 [PATCH] drm: tda998x: Use drm_do_get_edid() Laurent Pinchart
2014-11-26 19:59 ` Rob Clark
2014-11-27 10:42 ` Jean-Francois Moine
2014-12-23 9:46 ` Laurent Pinchart
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.