Skip to content

Commit 43049f1

Browse files
author
Thomas Zimmermann
committed
drm/i915: 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 fbdev callbacks. i915 was the only caller of the DRM helpers, so remove them from the helper module. i915's fbdev emulation is still incomplete as it doesn't implement deferred I/O and damage handling for mmaped pages. v4: * generate deferred-I/O helpers * use initializer macros for fb_ops v2: * use FB_IO_HELPERS options Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Sam Ravnborg <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Joonas Lahtinen <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: "Ville Syrjälä" <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c6baad6 commit 43049f1

File tree

5 files changed

+9
-155
lines changed

5 files changed

+9
-155
lines changed

drivers/gpu/drm/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION
133133
bool "Enable legacy fbdev support for your modesetting driver"
134134
depends on DRM_KMS_HELPER
135135
depends on FB=y || FB=DRM_KMS_HELPER
136-
select FB_CFB_FILLRECT
137-
select FB_CFB_COPYAREA
138-
select FB_CFB_IMAGEBLIT
139136
select FRAMEBUFFER_CONSOLE if !EXPERT
140137
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
141138
default y

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli
736736
}
737737
EXPORT_SYMBOL(drm_fb_helper_deferred_io);
738738

739-
/**
740-
* drm_fb_helper_cfb_read - Implements struct &fb_ops.fb_read for I/O 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_cfb_read(struct fb_info *info, char __user *buf,
750-
size_t count, loff_t *ppos)
751-
{
752-
return fb_io_read(info, buf, count, ppos);
753-
}
754-
EXPORT_SYMBOL(drm_fb_helper_cfb_read);
755-
756-
/**
757-
* drm_fb_helper_cfb_write - Implements struct &fb_ops.fb_write for I/O 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_cfb_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_io_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_cfb_write);
788-
789-
/**
790-
* drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect
791-
* @info: fbdev registered by the helper
792-
* @rect: info about rectangle to fill
793-
*
794-
* A wrapper around cfb_fillrect implemented by fbdev core
795-
*/
796-
void drm_fb_helper_cfb_fillrect(struct fb_info *info,
797-
const struct fb_fillrect *rect)
798-
{
799-
struct drm_fb_helper *helper = info->par;
800-
801-
cfb_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_cfb_fillrect);
807-
808-
/**
809-
* drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea
810-
* @info: fbdev registered by the helper
811-
* @area: info about area to copy
812-
*
813-
* A wrapper around cfb_copyarea implemented by fbdev core
814-
*/
815-
void drm_fb_helper_cfb_copyarea(struct fb_info *info,
816-
const struct fb_copyarea *area)
817-
{
818-
struct drm_fb_helper *helper = info->par;
819-
820-
cfb_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_cfb_copyarea);
826-
827-
/**
828-
* drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit
829-
* @info: fbdev registered by the helper
830-
* @image: info about image to blit
831-
*
832-
* A wrapper around cfb_imageblit implemented by fbdev core
833-
*/
834-
void drm_fb_helper_cfb_imageblit(struct fb_info *info,
835-
const struct fb_image *image)
836-
{
837-
struct drm_fb_helper *helper = info->par;
838-
839-
cfb_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_cfb_imageblit);
845-
846739
/**
847740
* drm_fb_helper_set_suspend - wrapper around fb_set_suspend
848741
* @fb_helper: driver-allocated fbdev helper, can be NULL

drivers/gpu/drm/i915/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ config DRM_I915
1717
select DRM_KMS_HELPER
1818
select DRM_PANEL
1919
select DRM_MIPI_DSI
20+
select FB_IO_HELPERS if DRM_FBDEV_EMULATION
2021
select RELAY
2122
select I2C
2223
select I2C_ALGOBIT

drivers/gpu/drm/i915/display/intel_fbdev.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/console.h>
2929
#include <linux/delay.h>
3030
#include <linux/errno.h>
31+
#include <linux/fb.h>
3132
#include <linux/init.h>
3233
#include <linux/kernel.h>
3334
#include <linux/mm.h>
@@ -84,6 +85,10 @@ static void intel_fbdev_invalidate(struct intel_fbdev *ifbdev)
8485
intel_frontbuffer_invalidate(to_frontbuffer(ifbdev), ORIGIN_CPU);
8586
}
8687

88+
FB_GEN_DEFAULT_DEFERRED_IO_OPS(intel_fbdev,
89+
drm_fb_helper_damage_range,
90+
drm_fb_helper_damage_area)
91+
8792
static int intel_fbdev_set_par(struct fb_info *info)
8893
{
8994
struct intel_fbdev *ifbdev = to_intel_fbdev(info->par);
@@ -132,15 +137,12 @@ static int intel_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)
132137

133138
static const struct fb_ops intelfb_ops = {
134139
.owner = THIS_MODULE,
140+
__FB_DEFAULT_DEFERRED_OPS_RDWR(intel_fbdev),
135141
DRM_FB_HELPER_DEFAULT_OPS,
136142
.fb_set_par = intel_fbdev_set_par,
137-
.fb_read = drm_fb_helper_cfb_read,
138-
.fb_write = drm_fb_helper_cfb_write,
139-
.fb_fillrect = drm_fb_helper_cfb_fillrect,
140-
.fb_copyarea = drm_fb_helper_cfb_copyarea,
141-
.fb_imageblit = drm_fb_helper_cfb_imageblit,
142-
.fb_pan_display = intel_fbdev_pan_display,
143143
.fb_blank = intel_fbdev_blank,
144+
.fb_pan_display = intel_fbdev_pan_display,
145+
__FB_DEFAULT_DEFERRED_OPS_DRAW(intel_fbdev),
144146
.fb_mmap = intel_fbdev_mmap,
145147
};
146148

include/drm/drm_fb_helper.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,6 @@ void drm_fb_helper_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u3
258258

259259
void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist);
260260

261-
ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
262-
size_t count, loff_t *ppos);
263-
ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
264-
size_t count, loff_t *ppos);
265-
266-
void drm_fb_helper_cfb_fillrect(struct fb_info *info,
267-
const struct fb_fillrect *rect);
268-
void drm_fb_helper_cfb_copyarea(struct fb_info *info,
269-
const struct fb_copyarea *area);
270-
void drm_fb_helper_cfb_imageblit(struct fb_info *info,
271-
const struct fb_image *image);
272-
273261
void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend);
274262
void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper,
275263
bool suspend);
@@ -385,33 +373,6 @@ static inline int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper)
385373
return -ENODEV;
386374
}
387375

388-
static inline ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
389-
size_t count, loff_t *ppos)
390-
{
391-
return -ENODEV;
392-
}
393-
394-
static inline ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
395-
size_t count, loff_t *ppos)
396-
{
397-
return -ENODEV;
398-
}
399-
400-
static inline void drm_fb_helper_cfb_fillrect(struct fb_info *info,
401-
const struct fb_fillrect *rect)
402-
{
403-
}
404-
405-
static inline void drm_fb_helper_cfb_copyarea(struct fb_info *info,
406-
const struct fb_copyarea *area)
407-
{
408-
}
409-
410-
static inline void drm_fb_helper_cfb_imageblit(struct fb_info *info,
411-
const struct fb_image *image)
412-
{
413-
}
414-
415376
static inline void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper,
416377
bool suspend)
417378
{

0 commit comments

Comments
 (0)