From patchwork Wed Nov 6 09:31:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 11229769 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 588A915AB for ; Wed, 6 Nov 2019 09:31:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 410DA2075C for ; Wed, 6 Nov 2019 09:31:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 410DA2075C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD5CF6EC7E; Wed, 6 Nov 2019 09:31:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 775396EC7A for ; Wed, 6 Nov 2019 09:31:28 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DDB67B415; Wed, 6 Nov 2019 09:31:25 +0000 (UTC) From: Thomas Zimmermann To: daniel@ffwll.ch, christian.koenig@amd.com, noralf@tronnes.org Subject: [PATCH 6/8] fbdev: Export default read and write operations as fb_cfb_{read, write}() Date: Wed, 6 Nov 2019 10:31:19 +0100 Message-Id: <20191106093121.21762-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191106093121.21762-1-tzimmermann@suse.de> References: <20191106093121.21762-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Read and write operations on the fbdev framebuffer can now be called by in-kernel users. This is required by DRM's fbdev helpers. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/core/fbmem.c | 53 ++++++++++++++++++++++++-------- include/linux/fb.h | 5 +++ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 95c32952fa8a..e49cf2988001 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -754,11 +754,10 @@ 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; @@ -770,9 +769,6 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 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) @@ -818,12 +814,13 @@ 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) +ssize_t +fb_cfb_write(struct fb_info *info, const 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; @@ -835,9 +832,6 @@ 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); - total_size = info->screen_size; if (total_size == 0) @@ -890,6 +884,41 @@ 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_read(struct file *file, 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_read) + return info->fbops->fb_read(info, buf, count, ppos); + + return fb_cfb_read(info, buf, count, ppos); +} + +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); + + 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 41e0069eca0a..c69e098e6dc5 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -592,6 +592,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 */