Commit 289af455 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'exynos-drm-next-for-v6.4-2' of...

Merge tag 'exynos-drm-next-for-v6.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos into drm-next

A patch series for implementing fbdev emulation as in-kernel client.

- This patch series refactors fbdev callbacks to DRM client functions and
  simplifies fbdev emulation initialization including some code cleanups.
  The changes make fbdev emulation behave like a regular DRM client.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>

From: Inki Dae <inki.dae@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230417100624.35229-1-inki.dae@samsung.com
parents 02a8ae72 49953b70
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <drm/drm_atomic.h> #include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_drv.h> #include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_file.h> #include <drm/drm_file.h>
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include <drm/drm_ioctl.h> #include <drm/drm_ioctl.h>
...@@ -108,7 +107,6 @@ static const struct drm_driver exynos_drm_driver = { ...@@ -108,7 +107,6 @@ static const struct drm_driver exynos_drm_driver = {
.driver_features = DRIVER_MODESET | DRIVER_GEM .driver_features = DRIVER_MODESET | DRIVER_GEM
| DRIVER_ATOMIC | DRIVER_RENDER, | DRIVER_ATOMIC | DRIVER_RENDER,
.open = exynos_drm_open, .open = exynos_drm_open,
.lastclose = drm_fb_helper_lastclose,
.postclose = exynos_drm_postclose, .postclose = exynos_drm_postclose,
.dumb_create = exynos_drm_gem_dumb_create, .dumb_create = exynos_drm_gem_dumb_create,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
...@@ -288,19 +286,15 @@ static int exynos_drm_bind(struct device *dev) ...@@ -288,19 +286,15 @@ static int exynos_drm_bind(struct device *dev)
/* init kms poll for handling hpd */ /* init kms poll for handling hpd */
drm_kms_helper_poll_init(drm); drm_kms_helper_poll_init(drm);
ret = exynos_drm_fbdev_init(drm);
if (ret)
goto err_cleanup_poll;
/* register the DRM device */ /* register the DRM device */
ret = drm_dev_register(drm, 0); ret = drm_dev_register(drm, 0);
if (ret < 0) if (ret < 0)
goto err_cleanup_fbdev; goto err_cleanup_poll;
exynos_drm_fbdev_setup(drm);
return 0; return 0;
err_cleanup_fbdev:
exynos_drm_fbdev_fini(drm);
err_cleanup_poll: err_cleanup_poll:
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
err_unbind_all: err_unbind_all:
...@@ -321,7 +315,6 @@ static void exynos_drm_unbind(struct device *dev) ...@@ -321,7 +315,6 @@ static void exynos_drm_unbind(struct device *dev)
drm_dev_unregister(drm); drm_dev_unregister(drm);
exynos_drm_fbdev_fini(drm);
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
component_unbind_all(drm->dev, drm); component_unbind_all(drm->dev, drm);
......
...@@ -197,8 +197,6 @@ struct drm_exynos_file_private { ...@@ -197,8 +197,6 @@ struct drm_exynos_file_private {
* @wait: wait an atomic commit to finish * @wait: wait an atomic commit to finish
*/ */
struct exynos_drm_private { struct exynos_drm_private {
struct drm_fb_helper *fb_helper;
struct device *g2d_dev; struct device *g2d_dev;
struct device *dma_dev; struct device *dma_dev;
void *mapping; void *mapping;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <drm/drm_atomic.h> #include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h> #include <drm/drm_crtc.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_framebuffer.h> #include <drm/drm_framebuffer.h>
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
...@@ -157,7 +156,6 @@ static struct drm_mode_config_helper_funcs exynos_drm_mode_config_helpers = { ...@@ -157,7 +156,6 @@ static struct drm_mode_config_helper_funcs exynos_drm_mode_config_helpers = {
static const struct drm_mode_config_funcs exynos_drm_mode_config_funcs = { static const struct drm_mode_config_funcs exynos_drm_mode_config_funcs = {
.fb_create = exynos_user_fb_create, .fb_create = exynos_user_fb_create,
.output_poll_changed = drm_fb_helper_output_poll_changed,
.atomic_check = drm_atomic_helper_check, .atomic_check = drm_atomic_helper_check,
.atomic_commit = drm_atomic_helper_commit, .atomic_commit = drm_atomic_helper_commit,
}; };
......
...@@ -8,16 +8,12 @@ ...@@ -8,16 +8,12 @@
* Seung-Woo Kim <sw0312.kim@samsung.com> * Seung-Woo Kim <sw0312.kim@samsung.com>
*/ */
#include <linux/console.h> #include <drm/drm_crtc_helper.h>
#include <linux/dma-mapping.h> #include <drm/drm_drv.h>
#include <linux/vmalloc.h>
#include <drm/drm_crtc.h>
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h> #include <drm/drm_framebuffer.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_prime.h> #include <drm/drm_prime.h>
#include <drm/drm_probe_helper.h>
#include <drm/exynos_drm.h> #include <drm/exynos_drm.h>
#include "exynos_drm_drv.h" #include "exynos_drm_drv.h"
...@@ -27,22 +23,26 @@ ...@@ -27,22 +23,26 @@
#define MAX_CONNECTOR 4 #define MAX_CONNECTOR 4
#define PREFERRED_BPP 32 #define PREFERRED_BPP 32
#define to_exynos_fbdev(x) container_of(x, struct exynos_drm_fbdev,\ static int exynos_drm_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
drm_fb_helper) {
struct drm_fb_helper *helper = info->par;
struct drm_gem_object *obj = drm_gem_fb_get_obj(helper->fb, 0);
struct exynos_drm_fbdev { return drm_gem_prime_mmap(obj, vma);
struct drm_fb_helper drm_fb_helper; }
struct exynos_drm_gem *exynos_gem;
};
static int exynos_drm_fb_mmap(struct fb_info *info, static void exynos_drm_fb_destroy(struct fb_info *info)
struct vm_area_struct *vma)
{ {
struct drm_fb_helper *helper = info->par; struct drm_fb_helper *fb_helper = info->par;
struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(helper); struct drm_framebuffer *fb = fb_helper->fb;
struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;
drm_fb_helper_fini(fb_helper);
return drm_gem_prime_mmap(&exynos_gem->base, vma); drm_framebuffer_remove(fb);
drm_client_release(&fb_helper->client);
drm_fb_helper_unprepare(fb_helper);
kfree(fb_helper);
} }
static const struct fb_ops exynos_drm_fb_ops = { static const struct fb_ops exynos_drm_fb_ops = {
...@@ -54,6 +54,7 @@ static const struct fb_ops exynos_drm_fb_ops = { ...@@ -54,6 +54,7 @@ static const struct fb_ops exynos_drm_fb_ops = {
.fb_fillrect = drm_fb_helper_cfb_fillrect, .fb_fillrect = drm_fb_helper_cfb_fillrect,
.fb_copyarea = drm_fb_helper_cfb_copyarea, .fb_copyarea = drm_fb_helper_cfb_copyarea,
.fb_imageblit = drm_fb_helper_cfb_imageblit, .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_destroy = exynos_drm_fb_destroy,
}; };
static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
...@@ -89,7 +90,6 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, ...@@ -89,7 +90,6 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper);
struct exynos_drm_gem *exynos_gem; struct exynos_drm_gem *exynos_gem;
struct drm_device *dev = helper->dev; struct drm_device *dev = helper->dev;
struct drm_mode_fb_cmd2 mode_cmd = { 0 }; struct drm_mode_fb_cmd2 mode_cmd = { 0 };
...@@ -113,8 +113,6 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -113,8 +113,6 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
if (IS_ERR(exynos_gem)) if (IS_ERR(exynos_gem))
return PTR_ERR(exynos_gem); return PTR_ERR(exynos_gem);
exynos_fbdev->exynos_gem = exynos_gem;
helper->fb = helper->fb =
exynos_drm_framebuffer_init(dev, &mode_cmd, &exynos_gem, 1); exynos_drm_framebuffer_init(dev, &mode_cmd, &exynos_gem, 1);
if (IS_ERR(helper->fb)) { if (IS_ERR(helper->fb)) {
...@@ -127,19 +125,13 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -127,19 +125,13 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
if (ret < 0) if (ret < 0)
goto err_destroy_framebuffer; goto err_destroy_framebuffer;
return ret; return 0;
err_destroy_framebuffer: err_destroy_framebuffer:
drm_framebuffer_cleanup(helper->fb); drm_framebuffer_cleanup(helper->fb);
helper->fb = NULL;
err_destroy_gem: err_destroy_gem:
exynos_drm_gem_destroy(exynos_gem); exynos_drm_gem_destroy(exynos_gem);
/*
* if failed, all resources allocated above would be released by
* drm_mode_config_cleanup() when drm_load() had been called prior
* to any specific driver such as fimd or hdmi driver.
*/
return ret; return ret;
} }
...@@ -147,80 +139,92 @@ static const struct drm_fb_helper_funcs exynos_drm_fb_helper_funcs = { ...@@ -147,80 +139,92 @@ static const struct drm_fb_helper_funcs exynos_drm_fb_helper_funcs = {
.fb_probe = exynos_drm_fbdev_create, .fb_probe = exynos_drm_fbdev_create,
}; };
int exynos_drm_fbdev_init(struct drm_device *dev) /*
* struct drm_client
*/
static void exynos_drm_fbdev_client_unregister(struct drm_client_dev *client)
{ {
struct exynos_drm_fbdev *fbdev; struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
struct exynos_drm_private *private = dev->dev_private;
struct drm_fb_helper *helper; if (fb_helper->info) {
int ret; drm_fb_helper_unregister_info(fb_helper);
} else {
drm_client_release(&fb_helper->client);
drm_fb_helper_unprepare(fb_helper);
kfree(fb_helper);
}
}
static int exynos_drm_fbdev_client_restore(struct drm_client_dev *client)
{
drm_fb_helper_lastclose(client->dev);
if (!dev->mode_config.num_crtc)
return 0; return 0;
}
fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); static int exynos_drm_fbdev_client_hotplug(struct drm_client_dev *client)
if (!fbdev) {
return -ENOMEM; struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
struct drm_device *dev = client->dev;
int ret;
private->fb_helper = helper = &fbdev->drm_fb_helper; if (dev->fb_helper)
return drm_fb_helper_hotplug_event(dev->fb_helper);
drm_fb_helper_prepare(dev, helper, PREFERRED_BPP, &exynos_drm_fb_helper_funcs); ret = drm_fb_helper_init(dev, fb_helper);
if (ret)
goto err_drm_err;
ret = drm_fb_helper_init(dev, helper); if (!drm_drv_uses_atomic_modeset(dev))
if (ret < 0) { drm_helper_disable_unused_functions(dev);
DRM_DEV_ERROR(dev->dev,
"failed to initialize drm fb helper.\n");
goto err_init;
}
ret = drm_fb_helper_initial_config(helper); ret = drm_fb_helper_initial_config(fb_helper);
if (ret < 0) { if (ret)
DRM_DEV_ERROR(dev->dev, goto err_drm_fb_helper_fini;
"failed to set up hw configuration.\n");
goto err_setup;
}
return 0; return 0;
err_setup: err_drm_fb_helper_fini:
drm_fb_helper_fini(helper); drm_fb_helper_fini(fb_helper);
err_init: err_drm_err:
drm_fb_helper_unprepare(helper); drm_err(dev, "Failed to setup fbdev emulation (ret=%d)\n", ret);
private->fb_helper = NULL;
kfree(fbdev);
return ret; return ret;
} }
static void exynos_drm_fbdev_destroy(struct drm_device *dev, static const struct drm_client_funcs exynos_drm_fbdev_client_funcs = {
struct drm_fb_helper *fb_helper) .owner = THIS_MODULE,
.unregister = exynos_drm_fbdev_client_unregister,
.restore = exynos_drm_fbdev_client_restore,
.hotplug = exynos_drm_fbdev_client_hotplug,
};
void exynos_drm_fbdev_setup(struct drm_device *dev)
{ {
struct drm_framebuffer *fb; struct drm_fb_helper *fb_helper;
int ret;
/* release drm framebuffer and real buffer */ drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
if (fb_helper->fb && fb_helper->fb->funcs) { drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
fb = fb_helper->fb;
if (fb)
drm_framebuffer_remove(fb);
}
drm_fb_helper_unregister_info(fb_helper); fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
if (!fb_helper)
return;
drm_fb_helper_prepare(dev, fb_helper, PREFERRED_BPP, &exynos_drm_fb_helper_funcs);
drm_fb_helper_fini(fb_helper); ret = drm_client_init(dev, &fb_helper->client, "fbdev", &exynos_drm_fbdev_client_funcs);
} if (ret)
goto err_drm_client_init;
void exynos_drm_fbdev_fini(struct drm_device *dev) ret = exynos_drm_fbdev_client_hotplug(&fb_helper->client);
{ if (ret)
struct exynos_drm_private *private = dev->dev_private; drm_dbg_kms(dev, "client hotplug ret=%d\n", ret);
struct exynos_drm_fbdev *fbdev;
if (!private || !private->fb_helper) drm_client_register(&fb_helper->client);
return;
fbdev = to_exynos_fbdev(private->fb_helper); return;
exynos_drm_fbdev_destroy(dev, private->fb_helper); err_drm_client_init:
drm_fb_helper_unprepare(private->fb_helper); drm_fb_helper_unprepare(fb_helper);
kfree(fbdev); kfree(fb_helper);
private->fb_helper = NULL;
} }
...@@ -12,27 +12,11 @@ ...@@ -12,27 +12,11 @@
#define _EXYNOS_DRM_FBDEV_H_ #define _EXYNOS_DRM_FBDEV_H_
#ifdef CONFIG_DRM_FBDEV_EMULATION #ifdef CONFIG_DRM_FBDEV_EMULATION
void exynos_drm_fbdev_setup(struct drm_device *dev);
int exynos_drm_fbdev_init(struct drm_device *dev);
void exynos_drm_fbdev_fini(struct drm_device *dev);
#else #else
static inline void exynos_drm_fbdev_setup(struct drm_device *dev)
static inline int exynos_drm_fbdev_init(struct drm_device *dev)
{
return 0;
}
static inline void exynos_drm_fbdev_fini(struct drm_device *dev)
{ {
} }
static inline void exynos_drm_fbdev_restore_mode(struct drm_device *dev)
{
}
#define exynos_drm_output_poll_changed (NULL)
#endif #endif
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment