linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] adv: fix G/S_EDID behavior
@ 2014-11-07 12:34 Hans Verkuil
  2014-11-07 12:34 ` [PATCH 1/3] adv7842: " Hans Verkuil
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-11-07 12:34 UTC (permalink / raw)
  To: linux-media; +Cc: jean-michel.hautbois

This patch series fixes the adv7604, adv7842 and adv7511 G/S_EDID behavior.
All three have been tested with v4l2-compliance and pass.

Jean-Michel, I based the adv7604 patch on your patch, but I reworked it a bit.
I hope you don't mind.

Regards,

	Hans


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] adv7842: fix G/S_EDID behavior
  2014-11-07 12:34 [PATCH 0/3] adv: fix G/S_EDID behavior Hans Verkuil
@ 2014-11-07 12:34 ` Hans Verkuil
  2014-11-07 12:34 ` [PATCH 2/3] adv7511: " Hans Verkuil
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-11-07 12:34 UTC (permalink / raw)
  To: linux-media; +Cc: jean-michel.hautbois, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Make this pass the v4l2-compliance test.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/adv7842.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 48b628b..bed0586 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2028,16 +2028,7 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 	struct adv7842_state *state = to_state(sd);
 	u8 *data = NULL;
 
-	if (edid->pad > ADV7842_EDID_PORT_VGA)
-		return -EINVAL;
-	if (edid->blocks == 0)
-		return -EINVAL;
-	if (edid->blocks > 2)
-		return -EINVAL;
-	if (edid->start_block > 1)
-		return -EINVAL;
-	if (edid->start_block == 1)
-		edid->blocks = 1;
+	memset(edid->reserved, 0, sizeof(edid->reserved));
 
 	switch (edid->pad) {
 	case ADV7842_EDID_PORT_A:
@@ -2052,12 +2043,23 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 	default:
 		return -EINVAL;
 	}
+
+	if (edid->start_block == 0 && edid->blocks == 0) {
+		edid->blocks = data ? 2 : 0;
+		return 0;
+	}
+
 	if (!data)
 		return -ENODATA;
 
-	memcpy(edid->edid,
-	       data + edid->start_block * 128,
-	       edid->blocks * 128);
+	if (edid->start_block >= 2)
+		return -EINVAL;
+
+	if (edid->start_block + edid->blocks > 2)
+		edid->blocks = 2 - edid->start_block;
+
+	memcpy(edid->edid, data + edid->start_block * 128, edid->blocks * 128);
+
 	return 0;
 }
 
@@ -2066,12 +2068,16 @@ static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *e)
 	struct adv7842_state *state = to_state(sd);
 	int err = 0;
 
+	memset(e->reserved, 0, sizeof(e->reserved));
+
 	if (e->pad > ADV7842_EDID_PORT_VGA)
 		return -EINVAL;
 	if (e->start_block != 0)
 		return -EINVAL;
-	if (e->blocks > 2)
+	if (e->blocks > 2) {
+		e->blocks = 2;
 		return -E2BIG;
+	}
 
 	/* todo, per edid */
 	state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15],
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] adv7511: fix G/S_EDID behavior
  2014-11-07 12:34 [PATCH 0/3] adv: fix G/S_EDID behavior Hans Verkuil
  2014-11-07 12:34 ` [PATCH 1/3] adv7842: " Hans Verkuil
@ 2014-11-07 12:34 ` Hans Verkuil
  2014-11-07 12:34 ` [PATCH 3/3] adv7604: Correct G/S_EDID behaviour Hans Verkuil
  2014-11-07 13:25 ` [PATCH 0/3] adv: fix G/S_EDID behavior Jean-Michel Hautbois
  3 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-11-07 12:34 UTC (permalink / raw)
  To: linux-media; +Cc: jean-michel.hautbois, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

This fixes the v4l2-compliance failures.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/adv7511.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index f98acf4..8acc8c5 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -779,21 +779,28 @@ static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 {
 	struct adv7511_state *state = get_adv7511_state(sd);
 
+	memset(edid->reserved, 0, sizeof(edid->reserved));
+
 	if (edid->pad != 0)
 		return -EINVAL;
-	if ((edid->blocks == 0) || (edid->blocks > 256))
-		return -EINVAL;
-	if (!state->edid.segments) {
-		v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
-		return -ENODATA;
+
+	if (edid->start_block == 0 && edid->blocks == 0) {
+		edid->blocks = state->edid.segments * 2;
+		return 0;
 	}
+
+	if (state->edid.segments == 0)
+		return -ENODATA;
+
 	if (edid->start_block >= state->edid.segments * 2)
-		return -E2BIG;
-	if ((edid->blocks + edid->start_block) >= state->edid.segments * 2)
+		return -EINVAL;
+
+	if (edid->start_block + edid->blocks > state->edid.segments * 2)
 		edid->blocks = state->edid.segments * 2 - edid->start_block;
 
 	memcpy(edid->edid, &state->edid.data[edid->start_block * 128],
 			128 * edid->blocks);
+
 	return 0;
 }
 
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] adv7604: Correct G/S_EDID behaviour
  2014-11-07 12:34 [PATCH 0/3] adv: fix G/S_EDID behavior Hans Verkuil
  2014-11-07 12:34 ` [PATCH 1/3] adv7842: " Hans Verkuil
  2014-11-07 12:34 ` [PATCH 2/3] adv7511: " Hans Verkuil
@ 2014-11-07 12:34 ` Hans Verkuil
  2014-11-07 20:34   ` Jean-Michel Hautbois
  2014-11-07 13:25 ` [PATCH 0/3] adv: fix G/S_EDID behavior Jean-Michel Hautbois
  3 siblings, 1 reply; 7+ messages in thread
From: Hans Verkuil @ 2014-11-07 12:34 UTC (permalink / raw)
  To: linux-media; +Cc: jean-michel.hautbois, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

In order to have v4l2-compliance tool pass the G/S_EDID some modifications
where needed in the driver.
In particular, the edid.reserved zone must be blanked.

Based on a patch from Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>,
but reworked it a bit. It should use edid.present instead of edid.blocks as the
check whether edid data is present.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/adv7604.c | 37 ++++++++++++++++++-------------------
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 47795ff..d64fbd9 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1997,19 +1997,7 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 	struct adv7604_state *state = to_state(sd);
 	u8 *data = NULL;
 
-	if (edid->pad > ADV7604_PAD_HDMI_PORT_D)
-		return -EINVAL;
-	if (edid->blocks == 0)
-		return -EINVAL;
-	if (edid->blocks > 2)
-		return -EINVAL;
-	if (edid->start_block > 1)
-		return -EINVAL;
-	if (edid->start_block == 1)
-		edid->blocks = 1;
-
-	if (edid->blocks > state->edid.blocks)
-		edid->blocks = state->edid.blocks;
+	memset(edid->reserved, 0, sizeof(edid->reserved));
 
 	switch (edid->pad) {
 	case ADV7604_PAD_HDMI_PORT_A:
@@ -2021,14 +2009,24 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 		break;
 	default:
 		return -EINVAL;
-		break;
 	}
-	if (!data)
+
+	if (edid->start_block == 0 && edid->blocks == 0) {
+		edid->blocks = state->edid.blocks;
+		return 0;
+	}
+
+	if (data == NULL)
 		return -ENODATA;
 
-	memcpy(edid->edid,
-	       data + edid->start_block * 128,
-	       edid->blocks * 128);
+	if (edid->start_block >= state->edid.blocks)
+		return -EINVAL;
+
+	if (edid->start_block + edid->blocks > state->edid.blocks)
+		edid->blocks = state->edid.blocks - edid->start_block;
+
+	memcpy(edid->edid, data + edid->start_block * 128, edid->blocks * 128);
+
 	return 0;
 }
 
@@ -2068,6 +2066,8 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 	int err;
 	int i;
 
+	memset(edid->reserved, 0, sizeof(edid->reserved));
+
 	if (edid->pad > ADV7604_PAD_HDMI_PORT_D)
 		return -EINVAL;
 	if (edid->start_block != 0)
@@ -2164,7 +2164,6 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 		return -EIO;
 	}
 
-
 	/* enable hotplug after 100 ms */
 	queue_delayed_work(state->work_queues,
 			&state->delayed_work_enable_hotplug, HZ / 10);
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] adv: fix G/S_EDID behavior
  2014-11-07 12:34 [PATCH 0/3] adv: fix G/S_EDID behavior Hans Verkuil
                   ` (2 preceding siblings ...)
  2014-11-07 12:34 ` [PATCH 3/3] adv7604: Correct G/S_EDID behaviour Hans Verkuil
@ 2014-11-07 13:25 ` Jean-Michel Hautbois
  3 siblings, 0 replies; 7+ messages in thread
From: Jean-Michel Hautbois @ 2014-11-07 13:25 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List

2014-11-07 13:34 GMT+01:00 Hans Verkuil <hverkuil@xs4all.nl>:
> This patch series fixes the adv7604, adv7842 and adv7511 G/S_EDID behavior.
> All three have been tested with v4l2-compliance and pass.
>
> Jean-Michel, I based the adv7604 patch on your patch, but I reworked it a bit.
> I hope you don't mind.

No problem for me, I applied your version and it works on my board.
Thanks,
JM

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] adv7604: Correct G/S_EDID behaviour
  2014-11-07 12:34 ` [PATCH 3/3] adv7604: Correct G/S_EDID behaviour Hans Verkuil
@ 2014-11-07 20:34   ` Jean-Michel Hautbois
  2014-11-10  9:13     ` Hans Verkuil
  0 siblings, 1 reply; 7+ messages in thread
From: Jean-Michel Hautbois @ 2014-11-07 20:34 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List, Hans Verkuil

Hi Hans,

2014-11-07 13:34 GMT+01:00 Hans Verkuil <hverkuil@xs4all.nl>:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> In order to have v4l2-compliance tool pass the G/S_EDID some modifications
> where needed in the driver.
> In particular, the edid.reserved zone must be blanked.
>
> Based on a patch from Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>,
> but reworked it a bit. It should use edid.present instead of edid.blocks as the
> check whether edid data is present.

I may have missed it, but you did not implement it using edid.present
in the code below... ?

> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/i2c/adv7604.c | 37 ++++++++++++++++++-------------------
>  1 file changed, 18 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index 47795ff..d64fbd9 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -1997,19 +1997,7 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>         struct adv7604_state *state = to_state(sd);
>         u8 *data = NULL;
>
> -       if (edid->pad > ADV7604_PAD_HDMI_PORT_D)
> -               return -EINVAL;
> -       if (edid->blocks == 0)
> -               return -EINVAL;
> -       if (edid->blocks > 2)
> -               return -EINVAL;
> -       if (edid->start_block > 1)
> -               return -EINVAL;
> -       if (edid->start_block == 1)
> -               edid->blocks = 1;
> -
> -       if (edid->blocks > state->edid.blocks)
> -               edid->blocks = state->edid.blocks;
> +       memset(edid->reserved, 0, sizeof(edid->reserved));
>
>         switch (edid->pad) {
>         case ADV7604_PAD_HDMI_PORT_A:
> @@ -2021,14 +2009,24 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>                 break;
>         default:
>                 return -EINVAL;
> -               break;
>         }
> -       if (!data)
> +
> +       if (edid->start_block == 0 && edid->blocks == 0) {
> +               edid->blocks = state->edid.blocks;
> +               return 0;
> +       }
> +
> +       if (data == NULL)
>                 return -ENODATA;
>
> -       memcpy(edid->edid,
> -              data + edid->start_block * 128,
> -              edid->blocks * 128);
> +       if (edid->start_block >= state->edid.blocks)
> +               return -EINVAL;
> +
> +       if (edid->start_block + edid->blocks > state->edid.blocks)
> +               edid->blocks = state->edid.blocks - edid->start_block;
> +
> +       memcpy(edid->edid, data + edid->start_block * 128, edid->blocks * 128);
> +
>         return 0;
>  }
>
> @@ -2068,6 +2066,8 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>         int err;
>         int i;
>
> +       memset(edid->reserved, 0, sizeof(edid->reserved));
> +
>         if (edid->pad > ADV7604_PAD_HDMI_PORT_D)
>                 return -EINVAL;
>         if (edid->start_block != 0)
> @@ -2164,7 +2164,6 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>                 return -EIO;
>         }
>
> -
>         /* enable hotplug after 100 ms */
>         queue_delayed_work(state->work_queues,
>                         &state->delayed_work_enable_hotplug, HZ / 10);
> --
> 2.1.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] adv7604: Correct G/S_EDID behaviour
  2014-11-07 20:34   ` Jean-Michel Hautbois
@ 2014-11-10  9:13     ` Hans Verkuil
  0 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-11-10  9:13 UTC (permalink / raw)
  To: Jean-Michel Hautbois; +Cc: Linux Media Mailing List, Hans Verkuil

On 11/07/2014 09:34 PM, Jean-Michel Hautbois wrote:
> Hi Hans,
> 
> 2014-11-07 13:34 GMT+01:00 Hans Verkuil <hverkuil@xs4all.nl>:
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> In order to have v4l2-compliance tool pass the G/S_EDID some modifications
>> where needed in the driver.
>> In particular, the edid.reserved zone must be blanked.
>>
>> Based on a patch from Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>,
>> but reworked it a bit. It should use edid.present instead of edid.blocks as the
>> check whether edid data is present.
> 
> I may have missed it, but you did not implement it using edid.present
> in the code below... ?

I should have said: 'It should use 'data' (which depends on edid.present) instead of...'

The edid.present usage is not seen in this patch, so that was a bit confusing.
I've updated the commit log for the final version I'm using in my pull request.

Regards,

	Hans

> 
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>> ---
>>  drivers/media/i2c/adv7604.c | 37 ++++++++++++++++++-------------------
>>  1 file changed, 18 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
>> index 47795ff..d64fbd9 100644
>> --- a/drivers/media/i2c/adv7604.c
>> +++ b/drivers/media/i2c/adv7604.c
>> @@ -1997,19 +1997,7 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>>         struct adv7604_state *state = to_state(sd);
>>         u8 *data = NULL;
>>
>> -       if (edid->pad > ADV7604_PAD_HDMI_PORT_D)
>> -               return -EINVAL;
>> -       if (edid->blocks == 0)
>> -               return -EINVAL;
>> -       if (edid->blocks > 2)
>> -               return -EINVAL;
>> -       if (edid->start_block > 1)
>> -               return -EINVAL;
>> -       if (edid->start_block == 1)
>> -               edid->blocks = 1;
>> -
>> -       if (edid->blocks > state->edid.blocks)
>> -               edid->blocks = state->edid.blocks;
>> +       memset(edid->reserved, 0, sizeof(edid->reserved));
>>
>>         switch (edid->pad) {
>>         case ADV7604_PAD_HDMI_PORT_A:
>> @@ -2021,14 +2009,24 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>>                 break;
>>         default:
>>                 return -EINVAL;
>> -               break;
>>         }
>> -       if (!data)
>> +
>> +       if (edid->start_block == 0 && edid->blocks == 0) {
>> +               edid->blocks = state->edid.blocks;
>> +               return 0;
>> +       }
>> +
>> +       if (data == NULL)
>>                 return -ENODATA;
>>
>> -       memcpy(edid->edid,
>> -              data + edid->start_block * 128,
>> -              edid->blocks * 128);
>> +       if (edid->start_block >= state->edid.blocks)
>> +               return -EINVAL;
>> +
>> +       if (edid->start_block + edid->blocks > state->edid.blocks)
>> +               edid->blocks = state->edid.blocks - edid->start_block;
>> +
>> +       memcpy(edid->edid, data + edid->start_block * 128, edid->blocks * 128);
>> +
>>         return 0;
>>  }
>>
>> @@ -2068,6 +2066,8 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>>         int err;
>>         int i;
>>
>> +       memset(edid->reserved, 0, sizeof(edid->reserved));
>> +
>>         if (edid->pad > ADV7604_PAD_HDMI_PORT_D)
>>                 return -EINVAL;
>>         if (edid->start_block != 0)
>> @@ -2164,7 +2164,6 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
>>                 return -EIO;
>>         }
>>
>> -
>>         /* enable hotplug after 100 ms */
>>         queue_delayed_work(state->work_queues,
>>                         &state->delayed_work_enable_hotplug, HZ / 10);
>> --
>> 2.1.1
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-10  9:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-07 12:34 [PATCH 0/3] adv: fix G/S_EDID behavior Hans Verkuil
2014-11-07 12:34 ` [PATCH 1/3] adv7842: " Hans Verkuil
2014-11-07 12:34 ` [PATCH 2/3] adv7511: " Hans Verkuil
2014-11-07 12:34 ` [PATCH 3/3] adv7604: Correct G/S_EDID behaviour Hans Verkuil
2014-11-07 20:34   ` Jean-Michel Hautbois
2014-11-10  9:13     ` Hans Verkuil
2014-11-07 13:25 ` [PATCH 0/3] adv: fix G/S_EDID behavior Jean-Michel Hautbois

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).