dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: daniel@ffwll.ch
Cc: linux-fbdev@vger.kernel.org, b.zolnierkie@samsung.com,
	jani.nikula@intel.com, dri-devel@lists.freedesktop.org,
	kraxel@redhat.com, airlied@redhat.com, natechancellor@gmail.com,
	sam@ravnborg.org, peda@axentia.se, dan.carpenter@oracle.com
Subject: Re: [PATCH 2/5] fbdev/core: Export framebuffer read and write code as cfb_ function
Date: Wed, 29 Jul 2020 15:53:28 +0200	[thread overview]
Message-ID: <20200729135328.GP6419@phenom.ffwll.local> (raw)
In-Reply-To: <20200729134148.6855-3-tzimmermann@suse.de>

On Wed, Jul 29, 2020 at 03:41:45PM +0200, Thomas Zimmermann wrote:
> DRM fb helpers require read and write functions for framebuffer
> memory. Export the existing code from fbdev.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

Hm I'm not super sure whether we want to actually reuse this stuff ... We
kinda don't care about the sparc special case, and just having an fbdev
implementation witch has the switch between memcpy and memcpy_to/from_io
in one single place sounds a lot simpler ...

This way we can have a clean split between the old horrors of real fbdev
drivers, and a much cleaner world in drm. It would mean a bit of
copypasting, but I think that's actually a good thing.

In general my idea for drm fbdev emulation is that for any area we have a
problem we just ignore the entire fbmem.c code and write our own: mmap,
backlight handling (still unsolved, and horrible), cfb vs sys here. This
entire fbmem.c stuff is pretty bad midlayer, trying to avoid code
duplication here doesn't seem worth it imo.

Thoughts?
-Daniel

> ---
>  drivers/video/fbdev/core/fbmem.c | 53 ++++++++++++++++++++++----------
>  include/linux/fb.h               |  5 +++
>  2 files changed, 41 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index dd0ccf35f7b7..b496ff90db3e 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -759,25 +759,18 @@ static struct fb_info *file_fb_info(struct file *file)
>  	return info;
>  }
>  
> -static ssize_t
> -fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
> +ssize_t fb_cfb_read(struct fb_info *info, char __user *buf, size_t count,
> +		    loff_t *ppos)
>  {
>  	unsigned long p = *ppos;
> -	struct fb_info *info = file_fb_info(file);
>  	u8 *buffer, *dst;
>  	u8 __iomem *src;
>  	int c, cnt = 0, err = 0;
>  	unsigned long total_size;
>  
> -	if (!info || ! info->screen_base)
> -		return -ENODEV;
> -
>  	if (info->state != FBINFO_STATE_RUNNING)
>  		return -EPERM;
>  
> -	if (info->fbops->fb_read)
> -		return info->fbops->fb_read(info, buf, count, ppos);
> -
>  	total_size = info->screen_size;
>  
>  	if (total_size == 0)
> @@ -823,16 +816,12 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
>  
>  	return (err) ? err : cnt;
>  }
> +EXPORT_SYMBOL(fb_cfb_read);
>  
>  static ssize_t
> -fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
> +fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
>  {
> -	unsigned long p = *ppos;
>  	struct fb_info *info = file_fb_info(file);
> -	u8 *buffer, *src;
> -	u8 __iomem *dst;
> -	int c, cnt = 0, err = 0;
> -	unsigned long total_size;
>  
>  	if (!info || !info->screen_base)
>  		return -ENODEV;
> @@ -840,8 +829,20 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
>  	if (info->state != FBINFO_STATE_RUNNING)
>  		return -EPERM;
>  
> -	if (info->fbops->fb_write)
> -		return info->fbops->fb_write(info, buf, count, ppos);
> +	if (info->fbops->fb_read)
> +		return info->fbops->fb_read(info, buf, count, ppos);
> +	else
> +		return fb_cfb_read(info, buf, count, ppos);
> +}
> +
> +ssize_t fb_cfb_write(struct fb_info *info, const char __user *buf,
> +		     size_t count, loff_t *ppos)
> +{
> +	unsigned long p = *ppos;
> +	u8 *buffer, *src;
> +	u8 __iomem *dst;
> +	int c, cnt = 0, err = 0;
> +	unsigned long total_size;
>  
>  	total_size = info->screen_size;
>  
> @@ -895,6 +896,24 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
>  
>  	return (cnt) ? cnt : err;
>  }
> +EXPORT_SYMBOL(fb_cfb_write);
> +
> +static ssize_t
> +fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
> +{
> +	struct fb_info *info = file_fb_info(file);
> +
> +	if (!info || !info->screen_base)
> +		return -ENODEV;
> +
> +	if (info->state != FBINFO_STATE_RUNNING)
> +		return -EPERM;
> +
> +	if (info->fbops->fb_write)
> +		return info->fbops->fb_write(info, buf, count, ppos);
> +	else
> +		return fb_cfb_write(info, buf, count, ppos);
> +}
>  
>  int
>  fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index 714187bc13ac..12ad83963db5 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -593,6 +593,11 @@ extern int fb_blank(struct fb_info *info, int blank);
>  extern void cfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
>  extern void cfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
>  extern void cfb_imageblit(struct fb_info *info, const struct fb_image *image);
> +extern ssize_t fb_cfb_read(struct fb_info *info, char __user *buf,
> +			   size_t count, loff_t *ppos);
> +extern ssize_t fb_cfb_write(struct fb_info *info, const char __user *buf,
> +			    size_t count, loff_t *ppos);
> +
>  /*
>   * Drawing operations where framebuffer is in system RAM
>   */
> -- 
> 2.27.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-07-29 13:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 13:41 [RFC][PATCH 0/5] Support GEM object mappings from I/O memory Thomas Zimmermann
2020-07-29 13:41 ` [PATCH 1/5] fbdev: Remove trailing whitespace Thomas Zimmermann
2020-07-29 13:47   ` daniel
2020-07-29 13:41 ` [PATCH 2/5] fbdev/core: Export framebuffer read and write code as cfb_ function Thomas Zimmermann
2020-07-29 13:53   ` daniel [this message]
2020-07-29 16:36     ` Sam Ravnborg
2020-07-31  9:20       ` daniel
2020-08-02 20:01         ` Sam Ravnborg
2020-08-03  6:46           ` Thomas Zimmermann
2020-08-04  9:27             ` daniel
2020-08-04  9:41               ` Thomas Zimmermann
2020-07-29 13:41 ` [PATCH 3/5] drm: Add infrastructure for vmap operations of I/O memory Thomas Zimmermann
2020-07-29 13:57   ` daniel
2020-07-30  8:14     ` Thomas Zimmermann
2020-07-31  9:22       ` daniel
2020-07-29 13:41 ` [PATCH 4/5] drm/fb_helper: Use I/O-memory mappings if available Thomas Zimmermann
2020-07-29 13:41 ` [PATCH 5/5] drm/vram_helper: Implement struct drm_gem_object_funcs.vmap_iomem Thomas Zimmermann

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=20200729135328.GP6419@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@redhat.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=kraxel@redhat.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=peda@axentia.se \
    --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;
as well as URLs for NNTP newsgroup(s).