aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_ioc32.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_ioc32.c')
-rw-r--r--drivers/gpu/drm/drm_ioc32.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index aa8bbb460c57..9cfcd0aef0df 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -70,6 +70,8 @@
70 70
71#define DRM_IOCTL_WAIT_VBLANK32 DRM_IOWR(0x3a, drm_wait_vblank32_t) 71#define DRM_IOCTL_WAIT_VBLANK32 DRM_IOWR(0x3a, drm_wait_vblank32_t)
72 72
73#define DRM_IOCTL_MODE_ADDFB232 DRM_IOWR(0xb8, drm_mode_fb_cmd232_t)
74
73typedef struct drm_version_32 { 75typedef struct drm_version_32 {
74 int version_major; /**< Major version */ 76 int version_major; /**< Major version */
75 int version_minor; /**< Minor version */ 77 int version_minor; /**< Minor version */
@@ -1016,6 +1018,63 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
1016 return 0; 1018 return 0;
1017} 1019}
1018 1020
1021typedef struct drm_mode_fb_cmd232 {
1022 u32 fb_id;
1023 u32 width;
1024 u32 height;
1025 u32 pixel_format;
1026 u32 flags;
1027 u32 handles[4];
1028 u32 pitches[4];
1029 u32 offsets[4];
1030 u64 modifier[4];
1031} __attribute__((packed)) drm_mode_fb_cmd232_t;
1032
1033static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
1034 unsigned long arg)
1035{
1036 struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
1037 struct drm_mode_fb_cmd232 req32;
1038 struct drm_mode_fb_cmd2 __user *req64;
1039 int i;
1040 int err;
1041
1042 if (copy_from_user(&req32, argp, sizeof(req32)))
1043 return -EFAULT;
1044
1045 req64 = compat_alloc_user_space(sizeof(*req64));
1046
1047 if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
1048 || __put_user(req32.width, &req64->width)
1049 || __put_user(req32.height, &req64->height)
1050 || __put_user(req32.pixel_format, &req64->pixel_format)
1051 || __put_user(req32.flags, &req64->flags))
1052 return -EFAULT;
1053
1054 for (i = 0; i < 4; i++) {
1055 if (__put_user(req32.handles[i], &req64->handles[i]))
1056 return -EFAULT;
1057 if (__put_user(req32.pitches[i], &req64->pitches[i]))
1058 return -EFAULT;
1059 if (__put_user(req32.offsets[i], &req64->offsets[i]))
1060 return -EFAULT;
1061 if (__put_user(req32.modifier[i], &req64->modifier[i]))
1062 return -EFAULT;
1063 }
1064
1065 err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
1066 if (err)
1067 return err;
1068
1069 if (__get_user(req32.fb_id, &req64->fb_id))
1070 return -EFAULT;
1071
1072 if (copy_to_user(argp, &req32, sizeof(req32)))
1073 return -EFAULT;
1074
1075 return 0;
1076}
1077
1019static drm_ioctl_compat_t *drm_compat_ioctls[] = { 1078static drm_ioctl_compat_t *drm_compat_ioctls[] = {
1020 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version, 1079 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
1021 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique, 1080 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
@@ -1048,6 +1107,7 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
1048 [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw, 1107 [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
1049#endif 1108#endif
1050 [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank, 1109 [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
1110 [DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
1051}; 1111};
1052 1112
1053/** 1113/**