Linux Samsung SOC development
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Sui Jingfeng <15330273260@189.cn>,
	daniel@ffwll.ch, airlied@gmail.com,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	javierm@redhat.com, sam@ravnborg.org
Cc: linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org,
	freedreno@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [v4,02/13] fbdev: Add initializer macros for struct fb_ops
Date: Fri, 26 May 2023 14:38:07 +0200	[thread overview]
Message-ID: <98ec3f40-1cd5-b40a-9fe7-e49f9d840f65@suse.de> (raw)
In-Reply-To: <07e6077f-8a5c-54b9-29d0-57f1bc868fef@189.cn>


[-- Attachment #1.1: Type: text/plain, Size: 8048 bytes --]

Hi

Am 24.05.23 um 22:57 schrieb Sui Jingfeng:
> Hi,
> 
> 
> we love your patch:
> 
> 
> On 2023/5/24 17:21, Thomas Zimmermann wrote:
>> For framebuffers in I/O and system memory, add macros that set
>> struct fb_ops to the respective callback functions.
>>
>> For deferred I/O, add macros that generate callback functions with
>> damage handling. Add initializer macros that set struct fb_ops to
>> the generated callbacks.
>>
>> These macros can remove a lot boilerplate code from fbdev drivers.
>> The drivers are supposed to use the macro that is required for its
>> framebuffer. Each macro is split into smaller helpers, so that
>> drivers with non-standard callbacks can pick and customize callbacks
>> as needed. There are individual helper macros for read/write, mmap
>> and drawing.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>>   include/linux/fb.h | 112 +++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 112 insertions(+)
>>
>> diff --git a/include/linux/fb.h b/include/linux/fb.h
>> index 2cf8efcb9e32..731472a2bb62 100644
>> --- a/include/linux/fb.h
>> +++ b/include/linux/fb.h
>> @@ -538,9 +538,31 @@ extern ssize_t fb_io_read(struct fb_info *info, 
>> char __user *buf,
>>   extern ssize_t fb_io_write(struct fb_info *info, const char __user 
>> *buf,
>>                  size_t count, loff_t *ppos);
>> +/*
>> + * Initializes struct fb_ops for framebuffers in I/O memory.
>> + */
>> +
>> +#define __FB_DEFAULT_IO_OPS_RDWR \
>> +    .fb_read    = fb_io_read, \
>> +    .fb_write    = fb_io_write
>> +
>> +#define __FB_DEFAULT_IO_OPS_DRAW \
>> +        .fb_fillrect    = cfb_fillrect, \
>> +        .fb_copyarea    = cfb_copyarea, \
>> +        .fb_imageblit    = cfb_imageblit
> 
> Here,  it seems that your text editor replace the tap with space, but 
> I'm OK.
> 
> I'm asking because I see other __FB__DEFAULT_* macro begin with tabs.

Yeah, these are mistakes. I'll fix that with the next version.

Best regards
Thomas

> 
>> +#define __FB_DEFAULT_IO_OPS_MMAP \
>> +    .fb_mmap    = NULL // default implementation
>> +
>> +#define FB_DEFAULT_IO_OPS \
>> +    __FB_DEFAULT_IO_OPS_RDWR, \
>> +    __FB_DEFAULT_IO_OPS_DRAW, \
>> +    __FB_DEFAULT_IO_OPS_MMAP
>> +
>>   /*
>>    * Drawing operations where framebuffer is in system RAM
>>    */
>> +
>>   extern void sys_fillrect(struct fb_info *info, const struct 
>> fb_fillrect *rect);
>>   extern void sys_copyarea(struct fb_info *info, const struct 
>> fb_copyarea *area);
>>   extern void sys_imageblit(struct fb_info *info, const struct 
>> fb_image *image);
>> @@ -549,6 +571,27 @@ extern ssize_t fb_sys_read(struct fb_info *info, 
>> char __user *buf,
>>   extern ssize_t fb_sys_write(struct fb_info *info, const char __user 
>> *buf,
>>                   size_t count, loff_t *ppos);
>> +/*
>> + * Initializes struct fb_ops for framebuffers in system memory.
>> + */
>> +
>> +#define __FB_DEFAULT_SYS_OPS_RDWR \
>> +    .fb_read    = fb_sys_read, \
>> +    .fb_write    = fb_sys_write
>> +
>> +#define __FB_DEFAULT_SYS_OPS_DRAW \
>> +        .fb_fillrect    = sys_fillrect, \
>> +        .fb_copyarea    = sys_copyarea, \
>> +        .fb_imageblit    = sys_imageblit
>> +
>> +#define __FB_DEFAULT_SYS_OPS_MMAP \
>> +    .fb_mmap    = NULL // default implementation
>> +
>> +#define FB_DEFAULT_SYS_OPS \
>> +    __FB_DEFAULT_SYS_OPS_RDWR, \
>> +    __FB_DEFAULT_SYS_OPS_DRAW, \
>> +    __FB_DEFAULT_SYS_OPS_MMAP
>> +
>>   /* drivers/video/fbmem.c */
>>   extern int register_framebuffer(struct fb_info *fb_info);
>>   extern void unregister_framebuffer(struct fb_info *fb_info);
>> @@ -604,6 +647,75 @@ extern void fb_deferred_io_cleanup(struct fb_info 
>> *info);
>>   extern int fb_deferred_io_fsync(struct file *file, loff_t start,
>>                   loff_t end, int datasync);
>> +/*
>> + * Generate callbacks for deferred I/O
>> + */
>> +
>> +#define __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, 
>> __mode) \
>> +    static ssize_t __prefix ## _defio_read(struct fb_info *info, char 
>> __user *buf, \
>> +                           size_t count, loff_t *ppos) \
>> +    { \
>> +        return fb_ ## __mode ## _read(info, buf, count, ppos); \
>> +    } \
>> +    static ssize_t __prefix ## _defio_write(struct fb_info *info, 
>> const char __user *buf, \
>> +                        size_t count, loff_t *ppos) \
>> +    { \
>> +        unsigned long offset = *ppos; \
>> +        ssize_t ret = fb_ ## __mode ## _write(info, buf, count, ppos); \
>> +        if (ret > 0) \
>> +            __damage_range(info, offset, ret); \
>> +        return ret; \
>> +    }
>> +
>> +#define __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, 
>> __mode) \
>> +    static void __prefix ## _defio_fillrect(struct fb_info *info, \
>> +                        const struct fb_fillrect *rect) \
>> +    { \
>> +        __mode ## _fillrect(info, rect); \
>> +        __damage_area(info, rect->dx, rect->dy, rect->width, 
>> rect->height); \
>> +    } \
>> +    static void __prefix ## _defio_copyarea(struct fb_info *info, \
>> +                        const struct fb_copyarea *area) \
>> +    { \
>> +        __mode ## _copyarea(info, area); \
>> +        __damage_area(info, area->dx, area->dy, area->width, 
>> area->height); \
>> +    } \
>> +    static void __prefix ## _defio_imageblit(struct fb_info *info, \
>> +                         const struct fb_image *image) \
>> +    { \
>> +        __mode ## _imageblit(info, image); \
>> +        __damage_area(info, image->dx, image->dy, image->width, 
>> image->height); \
>> +    }
>> +
>> +#define FB_GEN_DEFAULT_DEFERRED_IO_OPS(__prefix, __damage_range, 
>> __damage_area) \
>> +    __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, io) \
>> +    __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, cfb)
>> +
>> +#define FB_GEN_DEFAULT_DEFERRED_SYS_OPS(__prefix, __damage_range, 
>> __damage_area) \
>> +    __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, sys) \
>> +    __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, sys)
>> +
>> +/*
>> + * Initializes struct fb_ops for deferred I/O.
>> + */
>> +
>> +#define __FB_DEFAULT_DEFERRED_OPS_RDWR(__prefix) \
>> +    .fb_read    = __prefix ## _defio_read, \
>> +    .fb_write    = __prefix ## _defio_write
>> +
>> +#define __FB_DEFAULT_DEFERRED_OPS_DRAW(__prefix) \
>> +        .fb_fillrect    = __prefix ## _defio_fillrect, \
>> +        .fb_copyarea    = __prefix ## _defio_copyarea, \
>> +        .fb_imageblit    = __prefix ## _defio_imageblit
> 
> Here also,  '.fb_fillrect', '.fb_copyarea' and '.fb_imageblit' begin 
> with space, but I'm OK.
> 
> I'm asking because I see other __FB__DEFAULT_* macro begin with tabs.
> 
>> +#define __FB_DEFAULT_DEFERRED_OPS_MMAP(__prefix) \
>> +    .fb_mmap    = fb_deferred_io_mmap
>> +
>> +#define FB_DEFAULT_DEFERRED_OPS(__prefix) \
>> +    __FB_DEFAULT_DEFERRED_OPS_RDWR(__prefix), \
>> +    __FB_DEFAULT_DEFERRED_OPS_DRAW(__prefix), \
>> +    __FB_DEFAULT_DEFERRED_OPS_MMAP(__prefix)
>> +
>>   static inline bool fb_be_math(struct fb_info *info)
>>   {
>>   #ifdef CONFIG_FB_FOREIGN_ENDIAN

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2023-05-26 12:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24  9:21 [PATCH v4 00/13] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
2023-05-24  9:21 ` [PATCH v4 01/13] fbdev: Add Kconfig options to select different fb_ops helpers Thomas Zimmermann
2023-05-24 20:46   ` [v4,01/13] " Sui Jingfeng
2023-05-29 19:17   ` [PATCH v4 01/13] " Sam Ravnborg
2023-05-24  9:21 ` [PATCH v4 02/13] fbdev: Add initializer macros for struct fb_ops Thomas Zimmermann
2023-05-24 20:57   ` [v4,02/13] " Sui Jingfeng
2023-05-26 12:38     ` Thomas Zimmermann [this message]
2023-05-29 19:23   ` [PATCH v4 02/13] " Sam Ravnborg
2023-05-24  9:21 ` [PATCH v4 03/13] drm/armada: Use regular fbdev I/O helpers Thomas Zimmermann
2023-05-29 19:24   ` Sam Ravnborg
2023-05-24  9:21 ` [PATCH v4 04/13] drm/exynos: " Thomas Zimmermann
2023-05-24  9:21 ` [PATCH v4 05/13] drm/gma500: " Thomas Zimmermann
2023-05-24  9:21 ` [PATCH v4 06/13] drm/radeon: " Thomas Zimmermann
2023-05-24  9:21 ` [PATCH v4 07/13] drm/fbdev-dma: " Thomas Zimmermann
2023-05-24  9:21 ` [PATCH v4 08/13] drm/msm: " Thomas Zimmermann
2023-05-24  9:21 ` [PATCH v4 09/13] drm/omapdrm: " Thomas Zimmermann
2023-05-24  9:21 ` [PATCH v4 10/13] drm/tegra: " Thomas Zimmermann
2023-05-24  9:21 ` [PATCH v4 11/13] drm/fb-helper: Export helpers for marking damage areas Thomas Zimmermann
2023-05-29 19:38   ` Sam Ravnborg
2023-05-24  9:21 ` [PATCH v4 12/13] drm/fbdev-generic: Implement dedicated fbdev I/O helpers Thomas Zimmermann
2023-05-24 20:23   ` [v4,12/13] " Sui Jingfeng
2023-05-26 12:44     ` Thomas Zimmermann
2023-05-25  2:46   ` Sui Jingfeng
2023-05-24  9:21 ` [PATCH v4 13/13] drm/i915: " Thomas Zimmermann
2023-05-24 21:25   ` [v4,13/13] " Sui Jingfeng
2023-05-29 19:36   ` [PATCH v4 13/13] " Sam Ravnborg
2023-05-30  4:02     ` Sui Jingfeng
2023-05-30  7:12     ` Thomas Zimmermann
2023-05-30 15:37       ` Sam Ravnborg
2023-05-29 19:41   ` Sam Ravnborg
2023-05-29 19:37 ` [PATCH v4 00/13] drm/fbdev: Remove DRM's helpers for fbdev I/O Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98ec3f40-1cd5-b40a-9fe7-e49f9d840f65@suse.de \
    --to=tzimmermann@suse.de \
    --cc=15330273260@189.cn \
    --cc=airlied@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox