Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/fbdev-generic: Implement dedicated fbdev I/O helpers

Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. Use an fbdev generator macro for
deferred I/O to create the callbacks. Fbdev-generic was the
only caller of the DRM helpers, so remove them from the helper
module.

v4:
* generate deferred-I/O helpers
* use initializer macros for fb_ops
v2:
* use FB_SYS_HELPERS_DEFERRED option

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Tested-by: Sui Jingfeng <suijingfeng@loongson.cn>
Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
Link: https://patchwork.freedesktop.org/patch/msgid/20230530151228.22979-13-tzimmermann@suse.de

+6 -159
+1 -5
drivers/gpu/drm/Kconfig
··· 95 95 config DRM_KMS_HELPER 96 96 tristate 97 97 depends on DRM 98 + select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION 98 99 help 99 100 CRTC helpers for KMS drivers. 100 101 ··· 136 135 select FB_CFB_FILLRECT 137 136 select FB_CFB_COPYAREA 138 137 select FB_CFB_IMAGEBLIT 139 - select FB_DEFERRED_IO 140 - select FB_SYS_FOPS 141 - select FB_SYS_FILLRECT 142 - select FB_SYS_COPYAREA 143 - select FB_SYS_IMAGEBLIT 144 138 select FRAMEBUFFER_CONSOLE if !EXPERT 145 139 select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE 146 140 default y
-107
drivers/gpu/drm/drm_fb_helper.c
··· 737 737 EXPORT_SYMBOL(drm_fb_helper_deferred_io); 738 738 739 739 /** 740 - * drm_fb_helper_sys_read - Implements struct &fb_ops.fb_read for system memory 741 - * @info: fb_info struct pointer 742 - * @buf: userspace buffer to read from framebuffer memory 743 - * @count: number of bytes to read from framebuffer memory 744 - * @ppos: read offset within framebuffer memory 745 - * 746 - * Returns: 747 - * The number of bytes read on success, or an error code otherwise. 748 - */ 749 - ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf, 750 - size_t count, loff_t *ppos) 751 - { 752 - return fb_sys_read(info, buf, count, ppos); 753 - } 754 - EXPORT_SYMBOL(drm_fb_helper_sys_read); 755 - 756 - /** 757 - * drm_fb_helper_sys_write - Implements struct &fb_ops.fb_write for system memory 758 - * @info: fb_info struct pointer 759 - * @buf: userspace buffer to write to framebuffer memory 760 - * @count: number of bytes to write to framebuffer memory 761 - * @ppos: write offset within framebuffer memory 762 - * 763 - * Returns: 764 - * The number of bytes written on success, or an error code otherwise. 765 - */ 766 - ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf, 767 - size_t count, loff_t *ppos) 768 - { 769 - struct drm_fb_helper *helper = info->par; 770 - loff_t pos = *ppos; 771 - ssize_t ret; 772 - struct drm_rect damage_area; 773 - 774 - ret = fb_sys_write(info, buf, count, ppos); 775 - if (ret <= 0) 776 - return ret; 777 - 778 - if (helper->funcs->fb_dirty) { 779 - drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area); 780 - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, 781 - drm_rect_width(&damage_area), 782 - drm_rect_height(&damage_area)); 783 - } 784 - 785 - return ret; 786 - } 787 - EXPORT_SYMBOL(drm_fb_helper_sys_write); 788 - 789 - /** 790 - * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect 791 - * @info: fbdev registered by the helper 792 - * @rect: info about rectangle to fill 793 - * 794 - * A wrapper around sys_fillrect implemented by fbdev core 795 - */ 796 - void drm_fb_helper_sys_fillrect(struct fb_info *info, 797 - const struct fb_fillrect *rect) 798 - { 799 - struct drm_fb_helper *helper = info->par; 800 - 801 - sys_fillrect(info, rect); 802 - 803 - if (helper->funcs->fb_dirty) 804 - drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height); 805 - } 806 - EXPORT_SYMBOL(drm_fb_helper_sys_fillrect); 807 - 808 - /** 809 - * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea 810 - * @info: fbdev registered by the helper 811 - * @area: info about area to copy 812 - * 813 - * A wrapper around sys_copyarea implemented by fbdev core 814 - */ 815 - void drm_fb_helper_sys_copyarea(struct fb_info *info, 816 - const struct fb_copyarea *area) 817 - { 818 - struct drm_fb_helper *helper = info->par; 819 - 820 - sys_copyarea(info, area); 821 - 822 - if (helper->funcs->fb_dirty) 823 - drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height); 824 - } 825 - EXPORT_SYMBOL(drm_fb_helper_sys_copyarea); 826 - 827 - /** 828 - * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit 829 - * @info: fbdev registered by the helper 830 - * @image: info about image to blit 831 - * 832 - * A wrapper around sys_imageblit implemented by fbdev core 833 - */ 834 - void drm_fb_helper_sys_imageblit(struct fb_info *info, 835 - const struct fb_image *image) 836 - { 837 - struct drm_fb_helper *helper = info->par; 838 - 839 - sys_imageblit(info, image); 840 - 841 - if (helper->funcs->fb_dirty) 842 - drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height); 843 - } 844 - EXPORT_SYMBOL(drm_fb_helper_sys_imageblit); 845 - 846 - /** 847 740 * drm_fb_helper_cfb_read - Implements struct &fb_ops.fb_read for I/O memory 848 741 * @info: fb_info struct pointer 849 742 * @buf: userspace buffer to read from framebuffer memory
+5 -6
drivers/gpu/drm/drm_fbdev_generic.c
··· 34 34 return 0; 35 35 } 36 36 37 + FB_GEN_DEFAULT_DEFERRED_SYS_OPS(drm_fbdev_generic, 38 + drm_fb_helper_damage_range, 39 + drm_fb_helper_damage_area); 40 + 37 41 static void drm_fbdev_generic_fb_destroy(struct fb_info *info) 38 42 { 39 43 struct drm_fb_helper *fb_helper = info->par; ··· 60 56 .owner = THIS_MODULE, 61 57 .fb_open = drm_fbdev_generic_fb_open, 62 58 .fb_release = drm_fbdev_generic_fb_release, 63 - .fb_read = drm_fb_helper_sys_read, 64 - .fb_write = drm_fb_helper_sys_write, 59 + FB_DEFAULT_DEFERRED_OPS(drm_fbdev_generic), 65 60 DRM_FB_HELPER_DEFAULT_OPS, 66 - .fb_fillrect = drm_fb_helper_sys_fillrect, 67 - .fb_copyarea = drm_fb_helper_sys_copyarea, 68 - .fb_imageblit = drm_fb_helper_sys_imageblit, 69 - .fb_mmap = fb_deferred_io_mmap, 70 61 .fb_destroy = drm_fbdev_generic_fb_destroy, 71 62 }; 72 63
-41
include/drm/drm_fb_helper.h
··· 258 258 259 259 void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist); 260 260 261 - ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf, 262 - size_t count, loff_t *ppos); 263 - ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf, 264 - size_t count, loff_t *ppos); 265 - 266 - void drm_fb_helper_sys_fillrect(struct fb_info *info, 267 - const struct fb_fillrect *rect); 268 - void drm_fb_helper_sys_copyarea(struct fb_info *info, 269 - const struct fb_copyarea *area); 270 - void drm_fb_helper_sys_imageblit(struct fb_info *info, 271 - const struct fb_image *image); 272 - 273 261 ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf, 274 262 size_t count, loff_t *ppos); 275 263 ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf, ··· 383 395 static inline int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper) 384 396 { 385 397 return -ENODEV; 386 - } 387 - 388 - static inline ssize_t drm_fb_helper_sys_read(struct fb_info *info, 389 - char __user *buf, size_t count, 390 - loff_t *ppos) 391 - { 392 - return -ENODEV; 393 - } 394 - 395 - static inline ssize_t drm_fb_helper_sys_write(struct fb_info *info, 396 - const char __user *buf, 397 - size_t count, loff_t *ppos) 398 - { 399 - return -ENODEV; 400 - } 401 - 402 - static inline void drm_fb_helper_sys_fillrect(struct fb_info *info, 403 - const struct fb_fillrect *rect) 404 - { 405 - } 406 - 407 - static inline void drm_fb_helper_sys_copyarea(struct fb_info *info, 408 - const struct fb_copyarea *area) 409 - { 410 - } 411 - 412 - static inline void drm_fb_helper_sys_imageblit(struct fb_info *info, 413 - const struct fb_image *image) 414 - { 415 398 } 416 399 417 400 static inline ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,