diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-11-07 07:34:55 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-11-11 05:57:43 -0500 |
commit | c909e5ba6b1d79edfa809150da36a2c0c9cb095e (patch) | |
tree | 7a1d48eba0c94609f32a0bd55935ed1ffb2968d5 | |
parent | 47efeb52f78fd37df91d13e15296f8070d549f81 (diff) |
[media] adv7842: fix G/S_EDID behavior
Make this pass the v4l2-compliance test.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/i2c/adv7842.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 48b628bc6714..bed0586f72eb 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) | |||
2028 | struct adv7842_state *state = to_state(sd); | 2028 | struct adv7842_state *state = to_state(sd); |
2029 | u8 *data = NULL; | 2029 | u8 *data = NULL; |
2030 | 2030 | ||
2031 | if (edid->pad > ADV7842_EDID_PORT_VGA) | 2031 | memset(edid->reserved, 0, sizeof(edid->reserved)); |
2032 | return -EINVAL; | ||
2033 | if (edid->blocks == 0) | ||
2034 | return -EINVAL; | ||
2035 | if (edid->blocks > 2) | ||
2036 | return -EINVAL; | ||
2037 | if (edid->start_block > 1) | ||
2038 | return -EINVAL; | ||
2039 | if (edid->start_block == 1) | ||
2040 | edid->blocks = 1; | ||
2041 | 2032 | ||
2042 | switch (edid->pad) { | 2033 | switch (edid->pad) { |
2043 | case ADV7842_EDID_PORT_A: | 2034 | case ADV7842_EDID_PORT_A: |
@@ -2052,12 +2043,23 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) | |||
2052 | default: | 2043 | default: |
2053 | return -EINVAL; | 2044 | return -EINVAL; |
2054 | } | 2045 | } |
2046 | |||
2047 | if (edid->start_block == 0 && edid->blocks == 0) { | ||
2048 | edid->blocks = data ? 2 : 0; | ||
2049 | return 0; | ||
2050 | } | ||
2051 | |||
2055 | if (!data) | 2052 | if (!data) |
2056 | return -ENODATA; | 2053 | return -ENODATA; |
2057 | 2054 | ||
2058 | memcpy(edid->edid, | 2055 | if (edid->start_block >= 2) |
2059 | data + edid->start_block * 128, | 2056 | return -EINVAL; |
2060 | edid->blocks * 128); | 2057 | |
2058 | if (edid->start_block + edid->blocks > 2) | ||
2059 | edid->blocks = 2 - edid->start_block; | ||
2060 | |||
2061 | memcpy(edid->edid, data + edid->start_block * 128, edid->blocks * 128); | ||
2062 | |||
2061 | return 0; | 2063 | return 0; |
2062 | } | 2064 | } |
2063 | 2065 | ||
@@ -2066,12 +2068,16 @@ static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *e) | |||
2066 | struct adv7842_state *state = to_state(sd); | 2068 | struct adv7842_state *state = to_state(sd); |
2067 | int err = 0; | 2069 | int err = 0; |
2068 | 2070 | ||
2071 | memset(e->reserved, 0, sizeof(e->reserved)); | ||
2072 | |||
2069 | if (e->pad > ADV7842_EDID_PORT_VGA) | 2073 | if (e->pad > ADV7842_EDID_PORT_VGA) |
2070 | return -EINVAL; | 2074 | return -EINVAL; |
2071 | if (e->start_block != 0) | 2075 | if (e->start_block != 0) |
2072 | return -EINVAL; | 2076 | return -EINVAL; |
2073 | if (e->blocks > 2) | 2077 | if (e->blocks > 2) { |
2078 | e->blocks = 2; | ||
2074 | return -E2BIG; | 2079 | return -E2BIG; |
2080 | } | ||
2075 | 2081 | ||
2076 | /* todo, per edid */ | 2082 | /* todo, per edid */ |
2077 | state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15], | 2083 | state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15], |