Commit 25326590 authored by Dave Airlie's avatar Dave Airlie

Merge branch 'for-upstream/hdlcd' of git://linux-arm.org/linux-ld into drm-next

From: Liviu Dudau <Liviu.Dudau@arm.com>
"I managed to loose track of a few patches for HDLCD while focusing
on Mali DP and found them again when investigating an issue with
the way HDLCD behaves on teardown. They can go into drm-next for
one of the v4.19-rcX if you're not going to do another pull request
before the merge window."
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180731170831.GF17455@e110455-lin.cambridge.arm.com
parents 15da0950 d664b851
...@@ -229,6 +229,8 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = { ...@@ -229,6 +229,8 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = {
static int hdlcd_plane_atomic_check(struct drm_plane *plane, static int hdlcd_plane_atomic_check(struct drm_plane *plane,
struct drm_plane_state *state) struct drm_plane_state *state)
{ {
int i;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
u32 src_h = state->src_h >> 16; u32 src_h = state->src_h >> 16;
...@@ -238,20 +240,17 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane, ...@@ -238,20 +240,17 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane,
return -EINVAL; return -EINVAL;
} }
if (!state->fb || !state->crtc) for_each_new_crtc_in_state(state->state, crtc, crtc_state, i) {
return 0; /* we cannot disable the plane while the CRTC is active */
if (!state->fb && crtc_state->active)
crtc_state = drm_atomic_get_existing_crtc_state(state->state,
state->crtc);
if (!crtc_state) {
DRM_DEBUG_KMS("Invalid crtc state\n");
return -EINVAL; return -EINVAL;
}
return drm_atomic_helper_check_plane_state(state, crtc_state, return drm_atomic_helper_check_plane_state(state, crtc_state,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
false, true); false, true);
}
return 0;
} }
static void hdlcd_plane_atomic_update(struct drm_plane *plane, static void hdlcd_plane_atomic_update(struct drm_plane *plane,
...@@ -280,16 +279,10 @@ static const struct drm_plane_helper_funcs hdlcd_plane_helper_funcs = { ...@@ -280,16 +279,10 @@ static const struct drm_plane_helper_funcs hdlcd_plane_helper_funcs = {
.atomic_update = hdlcd_plane_atomic_update, .atomic_update = hdlcd_plane_atomic_update,
}; };
static void hdlcd_plane_destroy(struct drm_plane *plane)
{
drm_plane_helper_disable(plane, NULL);
drm_plane_cleanup(plane);
}
static const struct drm_plane_funcs hdlcd_plane_funcs = { static const struct drm_plane_funcs hdlcd_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane, .update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane, .disable_plane = drm_atomic_helper_disable_plane,
.destroy = hdlcd_plane_destroy, .destroy = drm_plane_cleanup,
.reset = drm_atomic_helper_plane_reset, .reset = drm_atomic_helper_plane_reset,
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
...@@ -334,10 +327,8 @@ int hdlcd_setup_crtc(struct drm_device *drm) ...@@ -334,10 +327,8 @@ int hdlcd_setup_crtc(struct drm_device *drm)
ret = drm_crtc_init_with_planes(drm, &hdlcd->crtc, primary, NULL, ret = drm_crtc_init_with_planes(drm, &hdlcd->crtc, primary, NULL,
&hdlcd_crtc_funcs, NULL); &hdlcd_crtc_funcs, NULL);
if (ret) { if (ret)
hdlcd_plane_destroy(primary);
return ret; return ret;
}
drm_crtc_helper_add(&hdlcd->crtc, &hdlcd_crtc_helper_funcs); drm_crtc_helper_add(&hdlcd->crtc, &hdlcd_crtc_helper_funcs);
return 0; return 0;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <drm/drm_fb_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_modeset_helper.h>
#include <drm/drm_of.h> #include <drm/drm_of.h>
#include "hdlcd_drv.h" #include "hdlcd_drv.h"
...@@ -100,16 +101,9 @@ static int hdlcd_load(struct drm_device *drm, unsigned long flags) ...@@ -100,16 +101,9 @@ static int hdlcd_load(struct drm_device *drm, unsigned long flags)
return ret; return ret;
} }
static void hdlcd_fb_output_poll_changed(struct drm_device *drm)
{
struct hdlcd_drm_private *hdlcd = drm->dev_private;
drm_fbdev_cma_hotplug_event(hdlcd->fbdev);
}
static const struct drm_mode_config_funcs hdlcd_mode_config_funcs = { static const struct drm_mode_config_funcs hdlcd_mode_config_funcs = {
.fb_create = drm_gem_fb_create, .fb_create = drm_gem_fb_create,
.output_poll_changed = hdlcd_fb_output_poll_changed, .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,
}; };
...@@ -124,13 +118,6 @@ static void hdlcd_setup_mode_config(struct drm_device *drm) ...@@ -124,13 +118,6 @@ static void hdlcd_setup_mode_config(struct drm_device *drm)
drm->mode_config.funcs = &hdlcd_mode_config_funcs; drm->mode_config.funcs = &hdlcd_mode_config_funcs;
} }
static void hdlcd_lastclose(struct drm_device *drm)
{
struct hdlcd_drm_private *hdlcd = drm->dev_private;
drm_fbdev_cma_restore_mode(hdlcd->fbdev);
}
static irqreturn_t hdlcd_irq(int irq, void *arg) static irqreturn_t hdlcd_irq(int irq, void *arg)
{ {
struct drm_device *drm = arg; struct drm_device *drm = arg;
...@@ -246,7 +233,7 @@ static struct drm_driver hdlcd_driver = { ...@@ -246,7 +233,7 @@ static struct drm_driver hdlcd_driver = {
.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM | .driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
DRIVER_MODESET | DRIVER_PRIME | DRIVER_MODESET | DRIVER_PRIME |
DRIVER_ATOMIC, DRIVER_ATOMIC,
.lastclose = hdlcd_lastclose, .lastclose = drm_fb_helper_lastclose,
.irq_handler = hdlcd_irq, .irq_handler = hdlcd_irq,
.irq_preinstall = hdlcd_irq_preinstall, .irq_preinstall = hdlcd_irq_preinstall,
.irq_postinstall = hdlcd_irq_postinstall, .irq_postinstall = hdlcd_irq_postinstall,
...@@ -321,14 +308,9 @@ static int hdlcd_drm_bind(struct device *dev) ...@@ -321,14 +308,9 @@ static int hdlcd_drm_bind(struct device *dev)
drm_mode_config_reset(drm); drm_mode_config_reset(drm);
drm_kms_helper_poll_init(drm); drm_kms_helper_poll_init(drm);
hdlcd->fbdev = drm_fbdev_cma_init(drm, 32, ret = drm_fb_cma_fbdev_init(drm, 32, 0);
drm->mode_config.num_connector); if (ret)
if (IS_ERR(hdlcd->fbdev)) {
ret = PTR_ERR(hdlcd->fbdev);
hdlcd->fbdev = NULL;
goto err_fbdev; goto err_fbdev;
}
ret = drm_dev_register(drm, 0); ret = drm_dev_register(drm, 0);
if (ret) if (ret)
...@@ -337,15 +319,13 @@ static int hdlcd_drm_bind(struct device *dev) ...@@ -337,15 +319,13 @@ static int hdlcd_drm_bind(struct device *dev)
return 0; return 0;
err_register: err_register:
if (hdlcd->fbdev) { drm_fb_cma_fbdev_fini(drm);
drm_fbdev_cma_fini(hdlcd->fbdev);
hdlcd->fbdev = NULL;
}
err_fbdev: err_fbdev:
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
err_vblank: err_vblank:
pm_runtime_disable(drm->dev); pm_runtime_disable(drm->dev);
err_pm_active: err_pm_active:
drm_atomic_helper_shutdown(drm);
component_unbind_all(dev, drm); component_unbind_all(dev, drm);
err_unload: err_unload:
of_node_put(hdlcd->crtc.port); of_node_put(hdlcd->crtc.port);
...@@ -366,23 +346,23 @@ static void hdlcd_drm_unbind(struct device *dev) ...@@ -366,23 +346,23 @@ static void hdlcd_drm_unbind(struct device *dev)
struct hdlcd_drm_private *hdlcd = drm->dev_private; struct hdlcd_drm_private *hdlcd = drm->dev_private;
drm_dev_unregister(drm); drm_dev_unregister(drm);
if (hdlcd->fbdev) { drm_fb_cma_fbdev_fini(drm);
drm_fbdev_cma_fini(hdlcd->fbdev);
hdlcd->fbdev = NULL;
}
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
component_unbind_all(dev, drm); component_unbind_all(dev, drm);
of_node_put(hdlcd->crtc.port); of_node_put(hdlcd->crtc.port);
hdlcd->crtc.port = NULL; hdlcd->crtc.port = NULL;
pm_runtime_get_sync(drm->dev); pm_runtime_get_sync(dev);
drm_crtc_vblank_off(&hdlcd->crtc);
drm_irq_uninstall(drm); drm_irq_uninstall(drm);
pm_runtime_put_sync(drm->dev); drm_atomic_helper_shutdown(drm);
pm_runtime_disable(drm->dev); pm_runtime_put(dev);
of_reserved_mem_device_release(drm->dev); if (pm_runtime_enabled(dev))
pm_runtime_disable(dev);
of_reserved_mem_device_release(dev);
drm_mode_config_cleanup(drm); drm_mode_config_cleanup(drm);
drm_dev_put(drm);
drm->dev_private = NULL; drm->dev_private = NULL;
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
drm_dev_put(drm);
} }
static const struct component_master_ops hdlcd_master_ops = { static const struct component_master_ops hdlcd_master_ops = {
...@@ -427,35 +407,15 @@ MODULE_DEVICE_TABLE(of, hdlcd_of_match); ...@@ -427,35 +407,15 @@ MODULE_DEVICE_TABLE(of, hdlcd_of_match);
static int __maybe_unused hdlcd_pm_suspend(struct device *dev) static int __maybe_unused hdlcd_pm_suspend(struct device *dev)
{ {
struct drm_device *drm = dev_get_drvdata(dev); struct drm_device *drm = dev_get_drvdata(dev);
struct hdlcd_drm_private *hdlcd = drm ? drm->dev_private : NULL;
if (!hdlcd)
return 0;
drm_kms_helper_poll_disable(drm); return drm_mode_config_helper_suspend(drm);
drm_fbdev_cma_set_suspend_unlocked(hdlcd->fbdev, 1);
hdlcd->state = drm_atomic_helper_suspend(drm);
if (IS_ERR(hdlcd->state)) {
drm_fbdev_cma_set_suspend_unlocked(hdlcd->fbdev, 0);
drm_kms_helper_poll_enable(drm);
return PTR_ERR(hdlcd->state);
}
return 0;
} }
static int __maybe_unused hdlcd_pm_resume(struct device *dev) static int __maybe_unused hdlcd_pm_resume(struct device *dev)
{ {
struct drm_device *drm = dev_get_drvdata(dev); struct drm_device *drm = dev_get_drvdata(dev);
struct hdlcd_drm_private *hdlcd = drm ? drm->dev_private : NULL;
if (!hdlcd)
return 0;
drm_atomic_helper_resume(drm, hdlcd->state); drm_mode_config_helper_resume(drm);
drm_fbdev_cma_set_suspend_unlocked(hdlcd->fbdev, 0);
drm_kms_helper_poll_enable(drm);
return 0; return 0;
} }
......
...@@ -9,10 +9,8 @@ ...@@ -9,10 +9,8 @@
struct hdlcd_drm_private { struct hdlcd_drm_private {
void __iomem *mmio; void __iomem *mmio;
struct clk *clk; struct clk *clk;
struct drm_fbdev_cma *fbdev;
struct drm_crtc crtc; struct drm_crtc crtc;
struct drm_plane *plane; struct drm_plane *plane;
struct drm_atomic_state *state;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
atomic_t buffer_underrun_count; atomic_t buffer_underrun_count;
atomic_t bus_error_count; atomic_t bus_error_count;
......
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