Commit 418fa908 authored by Daniel Vetter's avatar Daniel Vetter

drm/arc: Embedded a drm_simple_display_pipe

This is a prep step to convert arc over to the simple kms helpers, for
now we just use this as an embedding container to drop all the various
allocations. Big change is the removal of the various devm_kzalloc,
which have the wrong lifetimes anyway.
Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210112084358.2771527-4-daniel.vetter@ffwll.ch
parent 4eaf70d4
...@@ -8,17 +8,18 @@ ...@@ -8,17 +8,18 @@
#ifndef _ARCPGU_H_ #ifndef _ARCPGU_H_
#define _ARCPGU_H_ #define _ARCPGU_H_
#include <drm/drm_simple_kms_helper.h>
struct arcpgu_drm_private { struct arcpgu_drm_private {
struct drm_device drm; struct drm_device drm;
void __iomem *regs; void __iomem *regs;
struct clk *clk; struct clk *clk;
struct drm_crtc crtc; struct drm_simple_display_pipe pipe;
struct drm_plane *plane;
}; };
#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm) #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc) #define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu, static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
unsigned int reg, u32 value) unsigned int reg, u32 value)
......
...@@ -180,9 +180,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm) ...@@ -180,9 +180,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
struct drm_plane *plane = NULL; struct drm_plane *plane = NULL;
int ret; int ret;
plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL); plane = &arcpgu->pipe.plane;
if (!plane)
return ERR_PTR(-ENOMEM);
ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs, ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
arc_pgu_supported_formats, arc_pgu_supported_formats,
...@@ -193,7 +191,6 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm) ...@@ -193,7 +191,6 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
return ERR_PTR(ret); return ERR_PTR(ret);
drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs); drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
arcpgu->plane = plane;
return plane; return plane;
} }
...@@ -208,13 +205,13 @@ int arc_pgu_setup_crtc(struct drm_device *drm) ...@@ -208,13 +205,13 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
if (IS_ERR(primary)) if (IS_ERR(primary))
return PTR_ERR(primary); return PTR_ERR(primary);
ret = drm_crtc_init_with_planes(drm, &arcpgu->crtc, primary, NULL, ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
&arc_pgu_crtc_funcs, NULL); &arc_pgu_crtc_funcs, NULL);
if (ret) { if (ret) {
drm_plane_cleanup(primary); drm_plane_cleanup(primary);
return ret; return ret;
} }
drm_crtc_helper_add(&arcpgu->crtc, &arc_pgu_crtc_helper_funcs); drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
return 0; return 0;
} }
...@@ -120,7 +120,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg) ...@@ -120,7 +120,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
struct drm_device *drm = node->minor->dev; struct drm_device *drm = node->minor->dev;
struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
unsigned long clkrate = clk_get_rate(arcpgu->clk); unsigned long clkrate = clk_get_rate(arcpgu->clk);
unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000; unsigned long mode_clock = arcpgu->pipe.crtc.mode.crtc_clock * 1000;
seq_printf(m, "hw : %lu\n", clkrate); seq_printf(m, "hw : %lu\n", clkrate);
seq_printf(m, "mode: %lu\n", mode_clock); seq_printf(m, "mode: %lu\n", mode_clock);
......
...@@ -18,14 +18,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = { ...@@ -18,14 +18,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np) int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
{ {
struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_bridge *bridge; struct drm_bridge *bridge;
int ret = 0; int ret = 0;
encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL); encoder = &arcpgu->pipe.encoder;
if (encoder == NULL)
return -ENOMEM;
/* Locate drm bridge from the hdmi encoder DT node */ /* Locate drm bridge from the hdmi encoder DT node */
bridge = of_drm_find_bridge(np); bridge = of_drm_find_bridge(np);
......
...@@ -56,14 +56,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = { ...@@ -56,14 +56,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np) int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
{ {
struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
struct arcpgu_drm_connector *arcpgu_connector; struct arcpgu_drm_connector *arcpgu_connector;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_connector *connector; struct drm_connector *connector;
int ret; int ret;
encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL); encoder = &arcpgu->pipe.encoder;
if (encoder == NULL)
return -ENOMEM;
encoder->possible_crtcs = 1; encoder->possible_crtcs = 1;
encoder->possible_clones = 0; encoder->possible_clones = 0;
......
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