aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-08-10 05:07:12 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-13 15:07:24 -0400
commited45ce2cc0b31cb442685934b627916f83d1d7c6 (patch)
tree52edc4d9a2f533f9994506b6b26c70369057f686 /drivers/media/v4l2-core
parent1248c7cb66d734b60efed41be7c7b86909812c0e (diff)
[media] v4l2-subdev: add support for the new edid ioctls
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c57
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c13
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c6
3 files changed, 76 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 9ebd5c540d10..e8437051d3ef 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -16,6 +16,7 @@
16#include <linux/compat.h> 16#include <linux/compat.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/videodev2.h> 18#include <linux/videodev2.h>
19#include <linux/v4l2-subdev.h>
19#include <media/v4l2-dev.h> 20#include <media/v4l2-dev.h>
20#include <media/v4l2-ioctl.h> 21#include <media/v4l2-ioctl.h>
21 22
@@ -729,6 +730,44 @@ static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *u
729 return 0; 730 return 0;
730} 731}
731 732
733struct v4l2_subdev_edid32 {
734 __u32 pad;
735 __u32 start_block;
736 __u32 blocks;
737 __u32 reserved[5];
738 compat_caddr_t edid;
739};
740
741static int get_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subdev_edid32 __user *up)
742{
743 u32 tmp;
744
745 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_subdev_edid32)) ||
746 get_user(kp->pad, &up->pad) ||
747 get_user(kp->start_block, &up->start_block) ||
748 get_user(kp->blocks, &up->blocks) ||
749 get_user(tmp, &up->edid) ||
750 copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
751 return -EFAULT;
752 kp->edid = compat_ptr(tmp);
753 return 0;
754}
755
756static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subdev_edid32 __user *up)
757{
758 u32 tmp = (u32)((unsigned long)kp->edid);
759
760 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_subdev_edid32)) ||
761 put_user(kp->pad, &up->pad) ||
762 put_user(kp->start_block, &up->start_block) ||
763 put_user(kp->blocks, &up->blocks) ||
764 put_user(tmp, &up->edid) ||
765 copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
766 return -EFAULT;
767 return 0;
768}
769
770
732#define VIDIOC_G_FMT32 _IOWR('V', 4, struct v4l2_format32) 771#define VIDIOC_G_FMT32 _IOWR('V', 4, struct v4l2_format32)
733#define VIDIOC_S_FMT32 _IOWR('V', 5, struct v4l2_format32) 772#define VIDIOC_S_FMT32 _IOWR('V', 5, struct v4l2_format32)
734#define VIDIOC_QUERYBUF32 _IOWR('V', 9, struct v4l2_buffer32) 773#define VIDIOC_QUERYBUF32 _IOWR('V', 9, struct v4l2_buffer32)
@@ -738,6 +777,8 @@ static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *u
738#define VIDIOC_DQBUF32 _IOWR('V', 17, struct v4l2_buffer32) 777#define VIDIOC_DQBUF32 _IOWR('V', 17, struct v4l2_buffer32)
739#define VIDIOC_ENUMSTD32 _IOWR('V', 25, struct v4l2_standard32) 778#define VIDIOC_ENUMSTD32 _IOWR('V', 25, struct v4l2_standard32)
740#define VIDIOC_ENUMINPUT32 _IOWR('V', 26, struct v4l2_input32) 779#define VIDIOC_ENUMINPUT32 _IOWR('V', 26, struct v4l2_input32)
780#define VIDIOC_SUBDEV_G_EDID32 _IOWR('V', 63, struct v4l2_subdev_edid32)
781#define VIDIOC_SUBDEV_S_EDID32 _IOWR('V', 64, struct v4l2_subdev_edid32)
741#define VIDIOC_TRY_FMT32 _IOWR('V', 64, struct v4l2_format32) 782#define VIDIOC_TRY_FMT32 _IOWR('V', 64, struct v4l2_format32)
742#define VIDIOC_G_EXT_CTRLS32 _IOWR('V', 71, struct v4l2_ext_controls32) 783#define VIDIOC_G_EXT_CTRLS32 _IOWR('V', 71, struct v4l2_ext_controls32)
743#define VIDIOC_S_EXT_CTRLS32 _IOWR('V', 72, struct v4l2_ext_controls32) 784#define VIDIOC_S_EXT_CTRLS32 _IOWR('V', 72, struct v4l2_ext_controls32)
@@ -765,6 +806,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
765 struct v4l2_ext_controls v2ecs; 806 struct v4l2_ext_controls v2ecs;
766 struct v4l2_event v2ev; 807 struct v4l2_event v2ev;
767 struct v4l2_create_buffers v2crt; 808 struct v4l2_create_buffers v2crt;
809 struct v4l2_subdev_edid v2edid;
768 unsigned long vx; 810 unsigned long vx;
769 int vi; 811 int vi;
770 } karg; 812 } karg;
@@ -797,6 +839,8 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
797 case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break; 839 case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break;
798 case VIDIOC_CREATE_BUFS32: cmd = VIDIOC_CREATE_BUFS; break; 840 case VIDIOC_CREATE_BUFS32: cmd = VIDIOC_CREATE_BUFS; break;
799 case VIDIOC_PREPARE_BUF32: cmd = VIDIOC_PREPARE_BUF; break; 841 case VIDIOC_PREPARE_BUF32: cmd = VIDIOC_PREPARE_BUF; break;
842 case VIDIOC_SUBDEV_G_EDID32: cmd = VIDIOC_SUBDEV_G_EDID; break;
843 case VIDIOC_SUBDEV_S_EDID32: cmd = VIDIOC_SUBDEV_S_EDID; break;
800 } 844 }
801 845
802 switch (cmd) { 846 switch (cmd) {
@@ -814,6 +858,12 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
814 compatible_arg = 0; 858 compatible_arg = 0;
815 break; 859 break;
816 860
861 case VIDIOC_SUBDEV_G_EDID:
862 case VIDIOC_SUBDEV_S_EDID:
863 err = get_v4l2_subdev_edid32(&karg.v2edid, up);
864 compatible_arg = 0;
865 break;
866
817 case VIDIOC_G_FMT: 867 case VIDIOC_G_FMT:
818 case VIDIOC_S_FMT: 868 case VIDIOC_S_FMT:
819 case VIDIOC_TRY_FMT: 869 case VIDIOC_TRY_FMT:
@@ -906,6 +956,11 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
906 err = put_v4l2_event32(&karg.v2ev, up); 956 err = put_v4l2_event32(&karg.v2ev, up);
907 break; 957 break;
908 958
959 case VIDIOC_SUBDEV_G_EDID:
960 case VIDIOC_SUBDEV_S_EDID:
961 err = put_v4l2_subdev_edid32(&karg.v2edid, up);
962 break;
963
909 case VIDIOC_G_FMT: 964 case VIDIOC_G_FMT:
910 case VIDIOC_S_FMT: 965 case VIDIOC_S_FMT:
911 case VIDIOC_TRY_FMT: 966 case VIDIOC_TRY_FMT:
@@ -1026,6 +1081,8 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
1026 case VIDIOC_QUERY_DV_TIMINGS: 1081 case VIDIOC_QUERY_DV_TIMINGS:
1027 case VIDIOC_DV_TIMINGS_CAP: 1082 case VIDIOC_DV_TIMINGS_CAP:
1028 case VIDIOC_ENUM_FREQ_BANDS: 1083 case VIDIOC_ENUM_FREQ_BANDS:
1084 case VIDIOC_SUBDEV_G_EDID32:
1085 case VIDIOC_SUBDEV_S_EDID32:
1029 ret = do_video_ioctl(file, cmd, arg); 1086 ret = do_video_ioctl(file, cmd, arg);
1030 break; 1087 break;
1031 1088
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 6bc47fc82fe2..932d9bf5990a 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2191,6 +2191,19 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
2191 break; 2191 break;
2192 } 2192 }
2193 2193
2194 case VIDIOC_SUBDEV_G_EDID:
2195 case VIDIOC_SUBDEV_S_EDID: {
2196 struct v4l2_subdev_edid *edid = parg;
2197
2198 if (edid->blocks) {
2199 *user_ptr = (void __user *)edid->edid;
2200 *kernel_ptr = (void *)&edid->edid;
2201 *array_size = edid->blocks * 128;
2202 ret = 1;
2203 }
2204 break;
2205 }
2206
2194 case VIDIOC_S_EXT_CTRLS: 2207 case VIDIOC_S_EXT_CTRLS:
2195 case VIDIOC_G_EXT_CTRLS: 2208 case VIDIOC_G_EXT_CTRLS:
2196 case VIDIOC_TRY_EXT_CTRLS: { 2209 case VIDIOC_TRY_EXT_CTRLS: {
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 9182f81deb5b..dced41c1d993 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -348,6 +348,12 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
348 return v4l2_subdev_call( 348 return v4l2_subdev_call(
349 sd, pad, set_selection, subdev_fh, sel); 349 sd, pad, set_selection, subdev_fh, sel);
350 } 350 }
351
352 case VIDIOC_SUBDEV_G_EDID:
353 return v4l2_subdev_call(sd, pad, get_edid, arg);
354
355 case VIDIOC_SUBDEV_S_EDID:
356 return v4l2_subdev_call(sd, pad, set_edid, arg);
351#endif 357#endif
352 default: 358 default:
353 return v4l2_subdev_call(sd, core, ioctl, cmd, arg); 359 return v4l2_subdev_call(sd, core, ioctl, cmd, arg);