aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Bugge <marbugge@cisco.com>2013-12-05 10:14:02 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-07 03:36:03 -0500
commit245b2b678c6fc65f0265c55f7a4fa0155ad6b235 (patch)
tree596730407cc00ddd4a3caf10907512a72dc7bf91
parent6e9071f26864d83be6855f570a5ccc847b66028a (diff)
[media] adv7842: support g_edid ioctl
Signed-off-by: Martin Bugge <marbugge@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/i2c/adv7842.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index ae7252c1cd0c..2920e6b4536d 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -1910,6 +1910,46 @@ static int adv7842_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
1910 return 0; 1910 return 0;
1911} 1911}
1912 1912
1913static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid)
1914{
1915 struct adv7842_state *state = to_state(sd);
1916 u8 *data = NULL;
1917
1918 if (edid->pad > ADV7842_EDID_PORT_VGA)
1919 return -EINVAL;
1920 if (edid->blocks == 0)
1921 return -EINVAL;
1922 if (edid->blocks > 2)
1923 return -EINVAL;
1924 if (edid->start_block > 1)
1925 return -EINVAL;
1926 if (edid->start_block == 1)
1927 edid->blocks = 1;
1928 if (!edid->edid)
1929 return -EINVAL;
1930
1931 switch (edid->pad) {
1932 case ADV7842_EDID_PORT_A:
1933 case ADV7842_EDID_PORT_B:
1934 if (state->hdmi_edid.present & (0x04 << edid->pad))
1935 data = state->hdmi_edid.edid;
1936 break;
1937 case ADV7842_EDID_PORT_VGA:
1938 if (state->vga_edid.present)
1939 data = state->vga_edid.edid;
1940 break;
1941 default:
1942 return -EINVAL;
1943 }
1944 if (!data)
1945 return -ENODATA;
1946
1947 memcpy(edid->edid,
1948 data + edid->start_block * 128,
1949 edid->blocks * 128);
1950 return 0;
1951}
1952
1913static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *e) 1953static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *e)
1914{ 1954{
1915 struct adv7842_state *state = to_state(sd); 1955 struct adv7842_state *state = to_state(sd);
@@ -2722,6 +2762,7 @@ static const struct v4l2_subdev_video_ops adv7842_video_ops = {
2722}; 2762};
2723 2763
2724static const struct v4l2_subdev_pad_ops adv7842_pad_ops = { 2764static const struct v4l2_subdev_pad_ops adv7842_pad_ops = {
2765 .get_edid = adv7842_get_edid,
2725 .set_edid = adv7842_set_edid, 2766 .set_edid = adv7842_set_edid,
2726}; 2767};
2727 2768