diff options
Diffstat (limited to 'drivers/media/i2c/adv7842.c')
-rw-r--r-- | drivers/media/i2c/adv7842.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 48b628bc6714..75d26dfd0939 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c | |||
@@ -1877,12 +1877,12 @@ static int adv7842_s_routing(struct v4l2_subdev *sd, | |||
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | static int adv7842_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, | 1879 | static int adv7842_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, |
1880 | enum v4l2_mbus_pixelcode *code) | 1880 | u32 *code) |
1881 | { | 1881 | { |
1882 | if (index) | 1882 | if (index) |
1883 | return -EINVAL; | 1883 | return -EINVAL; |
1884 | /* Good enough for now */ | 1884 | /* Good enough for now */ |
1885 | *code = V4L2_MBUS_FMT_FIXED; | 1885 | *code = MEDIA_BUS_FMT_FIXED; |
1886 | return 0; | 1886 | return 0; |
1887 | } | 1887 | } |
1888 | 1888 | ||
@@ -1893,7 +1893,7 @@ static int adv7842_g_mbus_fmt(struct v4l2_subdev *sd, | |||
1893 | 1893 | ||
1894 | fmt->width = state->timings.bt.width; | 1894 | fmt->width = state->timings.bt.width; |
1895 | fmt->height = state->timings.bt.height; | 1895 | fmt->height = state->timings.bt.height; |
1896 | fmt->code = V4L2_MBUS_FMT_FIXED; | 1896 | fmt->code = MEDIA_BUS_FMT_FIXED; |
1897 | fmt->field = V4L2_FIELD_NONE; | 1897 | fmt->field = V4L2_FIELD_NONE; |
1898 | 1898 | ||
1899 | if (state->mode == ADV7842_MODE_SDP) { | 1899 | if (state->mode == ADV7842_MODE_SDP) { |
@@ -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], |