Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1405242

[PATCH 2/3] Define fb_open_adj_file()

From 'Max Staudt <mstaudt@suse.de>
Newsgroups linux.kernel
Subject [PATCH 2/3] Define fb_open_adj_file()
Date 2016-05-23 13:00 +0200
Message-ID <rBVKy-4Lf-27@gated-at.bofh.it> (permalink)
References <rBVKx-4Lf-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Max Staudt <mstaudt@suse.de>

This callback from fb_open() allows a fbdev driver to adjust things such
as file->f_mapping to better represent the internal structures.

This is needed to allow TTM drivers using ttm_fbdev_mmap() to properly
set file->f_mapping to TTM's address_space from bo->bdev->dev_mapping,
as is done form /dev/drm/card* in drm_open().

Currently, bochsdrmfb is the only driver requiring this, and this
patch is a prerequisite to implement this in bochsdrmfb.

Signed-off-by: Max Staudt <mstaudt@suse.de>
---
 drivers/video/fbdev/core/fbmem.c | 13 +++++++++++++
 include/linux/fb.h               |  7 +++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 913c496..ff5000e 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1471,6 +1471,19 @@ __releases(&info->lock)
 	if (info->fbdefio)
 		fb_deferred_io_open(info, inode, file);
 #endif
+	if (info->fbops->fb_open_adj_file) {
+		res = info->fbops->fb_open_adj_file(info, file);
+		if (res) {
+			/* If we got here, we also want to undo anything
+			 * that fbops->fb_open() may have done.
+			 */
+			if (info->fbops->fb_release)
+				info->fbops->fb_release(info,1);
+
+			module_put(info->fbops->owner);
+			goto out;
+		}
+	}
 out:
 	mutex_unlock(&info->lock);
 	if (res)
diff --git a/include/linux/fb.h b/include/linux/fb.h
index dfe8835..4131496 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -320,6 +320,13 @@ struct fb_ops {
 	/* called at KDB enter and leave time to prepare the console */
 	int (*fb_debug_enter)(struct fb_info *info);
 	int (*fb_debug_leave)(struct fb_info *info);
+
+	/* Called after fb_open() to adjust mappings when using
+	 * complex backends such as TTM.
+	 * For example, the bochsdrmfb driver needs to adjust
+	 * file->f_mapping so it can use ttm_fbdev_mmap().
+	 */
+	int (*fb_open_adj_file)(struct fb_info *info, struct file *file);
 };
 
 #ifdef CONFIG_FB_TILEBLITTING
-- 
2.6.6

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 2/3] Define fb_open_adj_file() 'Max Staudt <mstaudt@suse.de> - 2016-05-23 13:00 +0200
  Re: [PATCH 2/3] Define fb_open_adj_file() Daniel Vetter <daniel@ffwll.ch> - 2016-05-23 15:50 +0200
    Re: [PATCH 2/3] Define fb_open_adj_file() Max Staudt <mstaudt@suse.de> - 2016-05-24 18:30 +0200
      Re: [PATCH 2/3] Define fb_open_adj_file() Daniel Vetter <daniel@ffwll.ch> - 2016-05-24 19:00 +0200
        Re: [PATCH 2/3] Define fb_open_adj_file() Max Staudt <mstaudt@suse.de> - 2016-05-25 18:10 +0200

csiph-web