Commit c909e5ba authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] adv7842: fix G/S_EDID behavior

Make this pass the v4l2-compliance test.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 47efeb52
...@@ -2028,16 +2028,7 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) ...@@ -2028,16 +2028,7 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
struct adv7842_state *state = to_state(sd); struct adv7842_state *state = to_state(sd);
u8 *data = NULL; u8 *data = NULL;
if (edid->pad > ADV7842_EDID_PORT_VGA) memset(edid->reserved, 0, sizeof(edid->reserved));
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;
switch (edid->pad) { switch (edid->pad) {
case ADV7842_EDID_PORT_A: case ADV7842_EDID_PORT_A:
...@@ -2052,12 +2043,23 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) ...@@ -2052,12 +2043,23 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
default: default:
return -EINVAL; return -EINVAL;
} }
if (edid->start_block == 0 && edid->blocks == 0) {
edid->blocks = data ? 2 : 0;
return 0;
}
if (!data) if (!data)
return -ENODATA; return -ENODATA;
memcpy(edid->edid, if (edid->start_block >= 2)
data + edid->start_block * 128, return -EINVAL;
edid->blocks * 128);
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; return 0;
} }
...@@ -2066,12 +2068,16 @@ static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *e) ...@@ -2066,12 +2068,16 @@ static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *e)
struct adv7842_state *state = to_state(sd); struct adv7842_state *state = to_state(sd);
int err = 0; int err = 0;
memset(e->reserved, 0, sizeof(e->reserved));
if (e->pad > ADV7842_EDID_PORT_VGA) if (e->pad > ADV7842_EDID_PORT_VGA)
return -EINVAL; return -EINVAL;
if (e->start_block != 0) if (e->start_block != 0)
return -EINVAL; return -EINVAL;
if (e->blocks > 2) if (e->blocks > 2) {
e->blocks = 2;
return -E2BIG; return -E2BIG;
}
/* todo, per edid */ /* todo, per edid */
state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15], state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment