All of lore.kernel.org
 help / color / mirror / Atom feed
From: Archit Taneja <architt@codeaurora.org>
To: dri-devel@lists.freedesktop.org, daniel@ffwll.ch
Subject: [PATCH RESEND v2 01/25] drm/fb_helper: Add drm_fb_helper functions to manage fb_info creation
Date: Wed, 22 Jul 2015 14:57:56 +0530	[thread overview]
Message-ID: <1437557300-3280-2-git-send-email-architt@codeaurora.org> (raw)
In-Reply-To: <1437557300-3280-1-git-send-email-architt@codeaurora.org>

Every drm driver calls framebuffer_alloc, fb_alloc_cmap,
unregister_framebuffer, fb_dealloc_cmap and framebuffer_release in
order to emulate fbdev support.

Create drm_fb_helper functions that perform the above operations.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly. It also removes repetitive code from drivers.

There are some drivers that call alloc_apertures after framebuffer_alloc
and some that don't. Make the helper always call alloc_apertures. This
would make certain drivers allocate memory for apertures but not use
them. Since it's a small amount of memory, it shouldn't be an issue.

v2:
- Added kerneldocs
- Added a check for non-NULL fb_helper before proceeding. This will
  make the helpers work when we have a module param for fbdev emulation

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/gpu/drm/drm_fb_helper.c | 80 +++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_fb_helper.h     |  4 +++
 2 files changed, 84 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index cac4229..a5ae64a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -667,6 +667,86 @@ out_free:
 }
 EXPORT_SYMBOL(drm_fb_helper_init);
 
+/**
+ * drm_fb_helper_alloc_fbi - allocate fb_info and some of its members
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A helper to alloc fb_info and the members cmap and apertures. Called
+ * by the driver within the fb_probe fb_helper callback function.
+ *
+ * RETURNS:
+ * fb_info pointer if things went okay, pointer containing error code
+ * otherwise
+ */
+struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper)
+{
+	struct device *dev = fb_helper->dev->dev;
+	struct fb_info *info;
+	int ret;
+
+	info = framebuffer_alloc(0, dev);
+	if (!info)
+		return ERR_PTR(-ENOMEM);
+
+	ret = fb_alloc_cmap(&info->cmap, 256, 0);
+	if (ret)
+		goto err_release;
+
+	info->apertures = alloc_apertures(1);
+	if (!info->apertures) {
+		ret = -ENOMEM;
+		goto err_free_cmap;
+	}
+
+	fb_helper->fbdev = info;
+
+	return info;
+
+err_free_cmap:
+	fb_dealloc_cmap(&info->cmap);
+err_release:
+	framebuffer_release(info);
+	return ERR_PTR(ret);
+}
+EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
+
+/**
+ * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A wrapper around unregister_framebuffer, to release the fb_info
+ * framebuffer device
+ */
+void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
+{
+	if (fb_helper && fb_helper->fbdev)
+		unregister_framebuffer(fb_helper->fbdev);
+}
+EXPORT_SYMBOL(drm_fb_helper_unregister_fbi);
+
+/**
+ * drm_fb_helper_release_fbi - dealloc fb_info and its members
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * A helper to free memory taken by fb_info and the members cmap and
+ * apertures
+ */
+void drm_fb_helper_release_fbi(struct drm_fb_helper *fb_helper)
+{
+	if (fb_helper) {
+		struct fb_info *info = fb_helper->fbdev;
+
+		if (info) {
+			if (info->cmap.len)
+				fb_dealloc_cmap(&info->cmap);
+			framebuffer_release(info);
+		}
+
+		fb_helper->fbdev = NULL;
+	}
+}
+EXPORT_SYMBOL(drm_fb_helper_release_fbi);
+
 void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 {
 	if (!list_empty(&fb_helper->kernel_fb_list)) {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 0dfd94def..2ee4ec5 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -136,6 +136,10 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
 			    struct fb_info *info);
 
 bool drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper);
+
+struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper);
+void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper);
+void drm_fb_helper_release_fbi(struct drm_fb_helper *fb_helper);
 void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper,
 			    uint32_t fb_width, uint32_t fb_height);
 void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-07-22  9:28 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1437548401-10125-1-git-send-email-architt@codeaurora.or>
2015-07-22  9:27 ` [PATCH RESEND v2 00/25] drm: fb emulation: Step 1: Create new drm_fb_helper wrapper funcs Archit Taneja
2015-07-22  9:27   ` Archit Taneja [this message]
2015-07-22  9:27   ` [PATCH RESEND v2 02/25] drm/fb_helper: Create a wrapper for unlink_framebuffer Archit Taneja
2015-07-22  9:27   ` [PATCH RESEND v2 03/25] drm/fb_helper: Create wrappers for fb_sys_read/write funcs Archit Taneja
2015-07-22  9:27   ` [PATCH RESEND v2 04/25] drm/fb_helper: Create wrappers for blit, copyarea and fillrect funcs Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 05/25] drm/fb_helper: Create a wrapper for fb_set_suspend Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 06/25] drm/fb_helper: Create a wrapper for remove_conflicting_framebuffers Archit Taneja
2015-07-28 18:46     ` Daniel Vetter
2015-07-28 18:49       ` Daniel Vetter
2015-07-29  4:20         ` Archit Taneja
2015-07-29  6:30           ` Daniel Vetter
2015-07-29  4:19       ` Archit Taneja
2015-07-29  6:30         ` Daniel Vetter
2015-07-22  9:28   ` [PATCH RESEND v2 07/25] drm/cirrus: Use new drm_fb_helper functions Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 08/25] drm/rockchip: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 09/25] drm/armada: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 10/25] drm/ast: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 11/25] drm/omap: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 12/25] drm/tegra: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 13/25] drm/msm: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 14/25] drm/exynos: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 15/25] drm/gma500: " Archit Taneja
2015-07-22 20:59     ` Patrik Jakobsson
2015-07-22  9:28   ` [PATCH RESEND v2 16/25] drm/mgag200: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 17/25] drm/radeon: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 18/25] drm/qxl: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 19/25] drm/i915: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 20/25] drm/nouveau: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 21/25] drm/udl: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 22/25] drm/bochs: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 23/25] drm/amdgpu: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 24/25] drm/virtio: " Archit Taneja
2015-07-22  9:28   ` [PATCH RESEND v2 25/25] drm/fb_cma_helper: " Archit Taneja
2015-07-31 10:51   ` [PATCH v3 00/24] drm: fb emulation: Step 1: Create new drm_fb_helper wrapper funcs Archit Taneja
2015-07-31 10:51     ` [PATCH v3 00/24] rm: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 01/24] drm/fb_helper: Add drm_fb_helper functions to manage fb_info creation Archit Taneja
2015-07-31 10:51     ` [PATCH v3 02/24] drm/fb_helper: Create a wrapper for unlink_framebuffer Archit Taneja
2015-07-31 10:51     ` [PATCH v3 03/24] drm/fb_helper: Create wrappers for fb_sys_read/write funcs Archit Taneja
2015-07-31 10:51     ` [PATCH v3 04/24] drm/fb_helper: Create wrappers for blit, copyarea and fillrect funcs Archit Taneja
2015-07-31 10:51     ` [PATCH v3 05/24] drm/fb_helper: Create a wrapper for fb_set_suspend Archit Taneja
2015-07-31 10:51     ` [PATCH v3 06/24] drm/cirrus: Use new drm_fb_helper functions Archit Taneja
2015-07-31 10:51     ` [PATCH v3 07/24] drm/rockchip: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 08/24] drm/armada: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 09/24] drm/ast: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 10/24] drm/omap: " Archit Taneja
2015-08-01  9:55       ` Laurent Pinchart
2015-08-20 10:38       ` Tomi Valkeinen
2015-07-31 10:51     ` [PATCH v3 11/24] drm/tegra: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 12/24] drm/msm: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 13/24] drm/exynos: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 14/24] drm/gma500: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 15/24] drm/mgag200: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 16/24] drm/radeon: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 17/24] drm/qxl: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 18/24] drm/i915: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 19/24] drm/nouveau: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 20/24] drm/udl: " Archit Taneja
2015-07-31 10:51     ` [PATCH v3 21/24] drm/bochs: " Archit Taneja
2015-07-31 10:52     ` [PATCH v3 22/24] drm/amdgpu: " Archit Taneja
2015-07-31 10:52     ` [PATCH v3 23/24] drm/virtio: " Archit Taneja
2015-07-31 10:52     ` [PATCH v3 24/24] drm/fb_cma_helper: " Archit Taneja

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=1437557300-3280-2-git-send-email-architt@codeaurora.org \
    --to=architt@codeaurora.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.