[PATCH 1/2] drm: mali-dp: add malidp_crtc_state struct

Mihail Atanassov mihail.atanassov at arm.com
Wed Feb 1 10:16:57 UTC 2017


Add a custom CRTC state struct to enable storing driver-private per-CRTC
state. This patch only adds the base drm_crtc_state struct.

Signed-off-by: Mihail Atanassov <mihail.atanassov at arm.com>
---
 drivers/gpu/drm/arm/malidp_crtc.c | 39 +++++++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/arm/malidp_drv.h  |  6 ++++++
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_crtc.c b/drivers/gpu/drm/arm/malidp_crtc.c
index 08e6a71..d1cd0e7 100644
--- a/drivers/gpu/drm/arm/malidp_crtc.c
+++ b/drivers/gpu/drm/arm/malidp_crtc.c
@@ -160,6 +160,41 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
 	return 0;
 }
 
+static struct drm_crtc_state *malidp_crtc_duplicate_state(struct drm_crtc *crtc)
+{
+	struct malidp_crtc_state *cs;
+	struct malidp_crtc_state *state;
+
+	if (WARN_ON(!crtc->state))
+		return NULL;
+
+	cs = to_malidp_crtc_state(crtc->state);
+	state = kmalloc(sizeof(*state), GFP_KERNEL);
+	if (!state)
+		return NULL;
+
+	__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
+
+	return &state->base;
+}
+
+static void malidp_crtc_reset(struct drm_crtc *crtc)
+{
+	struct malidp_crtc_state *cs = (crtc->state) ?
+				       to_malidp_crtc_state(crtc->state) : NULL;
+
+	if (crtc->state)
+		__drm_atomic_helper_crtc_destroy_state(crtc->state);
+
+	kfree(cs);
+	cs = kzalloc(sizeof(*cs), GFP_KERNEL);
+	if (!cs)
+		return;
+
+	crtc->state = &cs->base;
+	crtc->state->crtc = crtc;
+}
+
 static const struct drm_crtc_helper_funcs malidp_crtc_helper_funcs = {
 	.mode_fixup = malidp_crtc_mode_fixup,
 	.enable = malidp_crtc_enable,
@@ -171,8 +206,8 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
 	.destroy = drm_crtc_cleanup,
 	.set_config = drm_atomic_helper_set_config,
 	.page_flip = drm_atomic_helper_page_flip,
-	.reset = drm_atomic_helper_crtc_reset,
-	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+	.reset = malidp_crtc_reset,
+	.atomic_duplicate_state = malidp_crtc_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };
 
diff --git a/drivers/gpu/drm/arm/malidp_drv.h b/drivers/gpu/drm/arm/malidp_drv.h
index 9fc8a2e..c7a69ae 100644
--- a/drivers/gpu/drm/arm/malidp_drv.h
+++ b/drivers/gpu/drm/arm/malidp_drv.h
@@ -47,6 +47,12 @@ struct malidp_plane_state {
 #define to_malidp_plane(x) container_of(x, struct malidp_plane, base)
 #define to_malidp_plane_state(x) container_of(x, struct malidp_plane_state, base)
 
+struct malidp_crtc_state {
+	struct drm_crtc_state base;
+};
+
+#define to_malidp_crtc_state(x) container_of(x, struct malidp_crtc_state, base)
+
 int malidp_de_planes_init(struct drm_device *drm);
 void malidp_de_planes_destroy(struct drm_device *drm);
 int malidp_crtc_init(struct drm_device *drm);
-- 
1.9.1



More information about the dri-devel mailing list