rockchip_ebc: rework ebc_off_screen ioctl

changes in uAPI:
- Change IOCTL define from IOWR to IOW

changes in driver:
- Instead of packed Y4 use 1 byte per pixel similar to the rest of the
  driver
- Enhance error handling
This commit is contained in:
hrdl 2025-05-04 13:34:30 +02:00 committed by Antoine Martin
parent a99b1a4503
commit 1a54f28a13
2 changed files with 21 additions and 13 deletions

View file

@ -342,17 +342,18 @@ static int ioctl_set_off_screen(struct drm_device *dev, void *data,
{ {
struct drm_rockchip_ebc_off_screen *args = data; struct drm_rockchip_ebc_off_screen *args = data;
struct rockchip_ebc *ebc = dev_get_drvdata(dev->dev); struct rockchip_ebc *ebc = dev_get_drvdata(dev->dev);
int copy_result; int res = 0;
pr_info("rockchip-ebc: ioctl_set_off_screen"); void __user *ptr_off_screen = u64_to_user_ptr(args->ptr_screen_content);
// TODO: blit if (access_ok(ptr_off_screen, ebc->num_pixels)) {
copy_result = copy_from_user(&ebc->final_off_screen, args->ptr_screen_content, 1313144); res = copy_from_user(ebc->final_off_screen,
copy_result = copy_from_user(&ebc->final_off_screen + 1313144, args->ptr_screen_content, 1313144); ptr_off_screen, ebc->num_pixels);
if (copy_result != 0){ if (res)
pr_err("Could not copy off screen content from user-supplied data pointer (bytes not copied: %d)", copy_result); pr_err("Could not copy off screen content from user-supplied data pointer (bytes not copied: %d)",
} res);
} else
return 0; res = -EFAULT;
return res;
} }
struct ebc_crtc_state { struct ebc_crtc_state {

View file

@ -24,9 +24,16 @@ struct drm_rockchip_ebc_trigger_global_refresh {
bool trigger_global_refresh; bool trigger_global_refresh;
}; };
/**
* struct drm_rockchip_ebc_off_screen - Pointer to userspace buffer.
* @info1: unused.
* @ptr_screen_content: pointer to width * height * buffer containing
* the horizontally flipped off screen. The highest four bits of each
* byte are ignored.
*/
struct drm_rockchip_ebc_off_screen { struct drm_rockchip_ebc_off_screen {
__u64 info1; __u64 info1;
char *ptr_screen_content; __u64 ptr_screen_content;
}; };
/** /**
@ -94,7 +101,7 @@ struct drm_rockchip_ebc_mode {
#define DRM_ROCKCHIP_EBC_NUM_IOCTLS 0x05 #define DRM_ROCKCHIP_EBC_NUM_IOCTLS 0x05
#define DRM_IOCTL_ROCKCHIP_EBC_GLOBAL_REFRESH DRM_IOWR(DRM_COMMAND_BASE + 0x00, struct drm_rockchip_ebc_trigger_global_refresh) #define DRM_IOCTL_ROCKCHIP_EBC_GLOBAL_REFRESH DRM_IOWR(DRM_COMMAND_BASE + 0x00, struct drm_rockchip_ebc_trigger_global_refresh)
#define DRM_IOCTL_ROCKCHIP_EBC_OFF_SCREEN DRM_IOWR(DRM_COMMAND_BASE + 0x01, struct drm_rockchip_ebc_off_screen) #define DRM_IOCTL_ROCKCHIP_EBC_OFF_SCREEN DRM_IOW(DRM_COMMAND_BASE + 0x01, struct drm_rockchip_ebc_off_screen)
#define DRM_IOCTL_ROCKCHIP_EBC_EXTRACT_FBS DRM_IOWR(DRM_COMMAND_BASE + 0x02, struct drm_rockchip_ebc_extract_fbs) #define DRM_IOCTL_ROCKCHIP_EBC_EXTRACT_FBS DRM_IOWR(DRM_COMMAND_BASE + 0x02, struct drm_rockchip_ebc_extract_fbs)
#define DRM_IOCTL_ROCKCHIP_EBC_RECT_HINTS DRM_IOW(DRM_COMMAND_BASE + 0x03, struct drm_rockchip_ebc_rect_hints) #define DRM_IOCTL_ROCKCHIP_EBC_RECT_HINTS DRM_IOW(DRM_COMMAND_BASE + 0x03, struct drm_rockchip_ebc_rect_hints)
#define DRM_IOCTL_ROCKCHIP_EBC_MODE DRM_IOWR(DRM_COMMAND_BASE + 0x04, struct drm_rockchip_ebc_mode) #define DRM_IOCTL_ROCKCHIP_EBC_MODE DRM_IOWR(DRM_COMMAND_BASE + 0x04, struct drm_rockchip_ebc_mode)