staging/fbtft: Use fb_ops helpers for deferred I/O
authorThomas Zimmermann <tzimmermann@suse.de>
Mon, 28 Aug 2023 13:14:24 +0000 (15:14 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Tue, 5 Sep 2023 12:14:04 +0000 (14:14 +0200)
Generate callback functions for struct fb_ops with the fbdev macro
FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to
the generated functions with an fbdev initializer macro.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230828132131.29295-9-tzimmermann@suse.de
drivers/staging/fbtft/Kconfig
drivers/staging/fbtft/fbtft-core.c

index 5dda3c65a38e7ed37312cf4e0a66c49f8023082f..77ab44362f167e2a6b92672fc9739565d35e3aa2 100644 (file)
@@ -4,12 +4,8 @@ menuconfig FB_TFT
        depends on FB && SPI
        depends on FB_DEVICE
        depends on GPIOLIB || COMPILE_TEST
-       select FB_SYS_FILLRECT
-       select FB_SYS_COPYAREA
-       select FB_SYS_IMAGEBLIT
-       select FB_SYS_FOPS
-       select FB_DEFERRED_IO
        select FB_BACKLIGHT
+       select FB_SYSMEM_HELPERS_DEFERRED
 
 config FB_TFT_AGM1264K_FL
        tristate "FB driver for the AGM1264K-FL LCD display"
index e4a77a4e7be6f3e01e3b95172cc014bd8c4ac4e2..3626f429b002c0aa4c0cb386d342aab3b2085323 100644 (file)
@@ -357,61 +357,6 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagereflis
                                        dirty_lines_start, dirty_lines_end);
 }
 
-static void fbtft_fb_fillrect(struct fb_info *info,
-                             const struct fb_fillrect *rect)
-{
-       struct fbtft_par *par = info->par;
-
-       dev_dbg(info->dev,
-               "%s: dx=%d, dy=%d, width=%d, height=%d\n",
-               __func__, rect->dx, rect->dy, rect->width, rect->height);
-       sys_fillrect(info, rect);
-
-       par->fbtftops.mkdirty(info, rect->dy, rect->height);
-}
-
-static void fbtft_fb_copyarea(struct fb_info *info,
-                             const struct fb_copyarea *area)
-{
-       struct fbtft_par *par = info->par;
-
-       dev_dbg(info->dev,
-               "%s: dx=%d, dy=%d, width=%d, height=%d\n",
-               __func__,  area->dx, area->dy, area->width, area->height);
-       sys_copyarea(info, area);
-
-       par->fbtftops.mkdirty(info, area->dy, area->height);
-}
-
-static void fbtft_fb_imageblit(struct fb_info *info,
-                              const struct fb_image *image)
-{
-       struct fbtft_par *par = info->par;
-
-       dev_dbg(info->dev,
-               "%s: dx=%d, dy=%d, width=%d, height=%d\n",
-               __func__,  image->dx, image->dy, image->width, image->height);
-       sys_imageblit(info, image);
-
-       par->fbtftops.mkdirty(info, image->dy, image->height);
-}
-
-static ssize_t fbtft_fb_write(struct fb_info *info, const char __user *buf,
-                             size_t count, loff_t *ppos)
-{
-       struct fbtft_par *par = info->par;
-       ssize_t res;
-
-       dev_dbg(info->dev,
-               "%s: count=%zd, ppos=%llu\n", __func__,  count, *ppos);
-       res = fb_sys_write(info, buf, count, ppos);
-
-       /* TODO: only mark changed area update all for now */
-       par->fbtftops.mkdirty(info, -1, 0);
-
-       return res;
-}
-
 /* from pxafb.c */
 static unsigned int chan_to_field(unsigned int chan, struct fb_bitfield *bf)
 {
@@ -473,16 +418,30 @@ static int fbtft_fb_blank(int blank, struct fb_info *info)
        return ret;
 }
 
+static void fbtft_ops_damage_range(struct fb_info *info, off_t off, size_t len)
+{
+       struct fbtft_par *par = info->par;
+
+       /* TODO: only mark changed area update all for now */
+       par->fbtftops.mkdirty(info, -1, 0);
+}
+
+static void fbtft_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u32 height)
+{
+       struct fbtft_par *par = info->par;
+
+       par->fbtftops.mkdirty(info, y, height);
+}
+
+FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(fbtft_ops,
+                                  fbtft_ops_damage_range,
+                                  fbtft_ops_damage_area)
+
 static const struct fb_ops fbtft_ops = {
-       .owner        = THIS_MODULE;
-       .fb_read      = fb_sys_read;
-       .fb_write     = fbtft_fb_write;
-       .fb_fillrect  = fbtft_fb_fillrect;
-       .fb_copyarea  = fbtft_fb_copyarea;
-       .fb_imageblit = fbtft_fb_imageblit;
-       .fb_setcolreg = fbtft_fb_setcolreg;
-       .fb_blank     = fbtft_fb_blank;
-       .fb_mmap      = fb_deferred_io_mmap;
+       .owner        = THIS_MODULE,
+       FB_DEFAULT_DEFERRED_OPS(fbtft_ops),
+       .fb_setcolreg = fbtft_fb_setcolreg,
+       .fb_blank     = fbtft_fb_blank,
 };
 
 static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)