All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liviu Dudau <Liviu.Dudau@arm.com>
To: Brian Starkey <brian.starkey@arm.com>
Cc: Mihail Atanassov <mihail.atanassov@arm.com>,
	Mali DP Maintainers <malidp@foss.arm.com>,
	DRI devel <dri-devel@lists.freedesktop.org>
Subject: [PATCH 06/12] drm: mali-dp: add malidp_crtc_state struct
Date: Fri, 21 Apr 2017 10:18:42 +0100	[thread overview]
Message-ID: <20170421091848.4666-7-Liviu.Dudau@arm.com> (raw)
In-Reply-To: <20170421091848.4666-1-Liviu.Dudau@arm.com>

From: Mihail Atanassov <mihail.atanassov@arm.com>

Add a custom CRTC state struct to enable storing driver's private
state. This patch only adds the base drm_crtc_state struct and
the atomic functions that handle it.

Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
---
 drivers/gpu/drm/arm/malidp_crtc.c | 52 ++++++++++++++++++++++++++++++++++++---
 drivers/gpu/drm/arm/malidp_drv.h  |  6 +++++
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_crtc.c b/drivers/gpu/drm/arm/malidp_crtc.c
index fab776c37602..ec1396f79cbd 100644
--- a/drivers/gpu/drm/arm/malidp_crtc.c
+++ b/drivers/gpu/drm/arm/malidp_crtc.c
@@ -178,6 +178,52 @@ static const struct drm_crtc_helper_funcs malidp_crtc_helper_funcs = {
 	.atomic_check = malidp_crtc_atomic_check,
 };
 
+static struct drm_crtc_state *malidp_crtc_duplicate_state(struct drm_crtc *crtc)
+{
+	struct malidp_crtc_state *state;
+
+	if (WARN_ON(!crtc->state))
+		return NULL;
+
+	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 *state = NULL;
+
+	if (crtc->state) {
+		state = to_malidp_crtc_state(crtc->state);
+		__drm_atomic_helper_crtc_destroy_state(crtc->state);
+	}
+
+	kfree(state);
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
+	if (state) {
+		crtc->state = &state->base;
+		crtc->state->crtc = crtc;
+	}
+}
+
+static void malidp_crtc_destroy_state(struct drm_crtc *crtc,
+				      struct drm_crtc_state *state)
+{
+	struct malidp_crtc_state *mali_state = NULL;
+
+	if (state) {
+		mali_state = to_malidp_crtc_state(state);
+		__drm_atomic_helper_crtc_destroy_state(state);
+	}
+
+	kfree(mali_state);
+}
+
 static int malidp_crtc_enable_vblank(struct drm_crtc *crtc)
 {
 	struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
@@ -201,9 +247,9 @@ static const struct drm_crtc_funcs malidp_crtc_funcs = {
 	.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,
-	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+	.reset = malidp_crtc_reset,
+	.atomic_duplicate_state = malidp_crtc_duplicate_state,
+	.atomic_destroy_state = malidp_crtc_destroy_state,
 	.enable_vblank = malidp_crtc_enable_vblank,
 	.disable_vblank = malidp_crtc_disable_vblank,
 };
diff --git a/drivers/gpu/drm/arm/malidp_drv.h b/drivers/gpu/drm/arm/malidp_drv.h
index cd4c04c65ead..bdc26203a451 100644
--- a/drivers/gpu/drm/arm/malidp_drv.h
+++ b/drivers/gpu/drm/arm/malidp_drv.h
@@ -48,6 +48,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);
-- 
2.12.0

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

  parent reply	other threads:[~2017-04-21  9:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-21  9:18 [PATCH 00/12] drm/mali-dp: Collate the pending patches in a series Liviu Dudau
2017-04-21  9:18 ` [PATCH 01/12] drm: mali-dp: Update the state of all planes before re-enabling active CRTCs Liviu Dudau
2017-04-21  9:18 ` [PATCH 02/12] drm: mali-dp: Enable power management for the device Liviu Dudau
2017-04-21  9:18 ` [PATCH 03/12] drm: mali-dp: add atomic_print_state for planes Liviu Dudau
2017-04-21  9:18 ` [PATCH 04/12] drm: mali-dp: remove unused variable Liviu Dudau
2017-04-21  9:18 ` [PATCH 05/12] drm: mali-dp: add custom reset hook for planes Liviu Dudau
2017-04-21  9:18 ` Liviu Dudau [this message]
2017-04-21  9:18 ` [PATCH 07/12] drm: mali-dp: enable gamma support Liviu Dudau
2017-04-21  9:18 ` [PATCH 08/12] drm: mali-dp: Add CTM support Liviu Dudau
2017-04-21  9:18 ` [PATCH 09/12] drm/mali-dp: Add core_id file to the sysfs interface Liviu Dudau
2017-04-21  9:18 ` [PATCH 10/12] drm: mali-dp: Add plane upscaling support Liviu Dudau
2017-04-21  9:18 ` [PATCH 11/12] drm: mali-dp: Enable image enhancement when scaling Liviu Dudau
2017-04-21  9:18 ` [PATCH 12/12] drm: mali-dp: Check the mclk rate and allow up/down scaling Liviu Dudau

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=20170421091848.4666-7-Liviu.Dudau@arm.com \
    --to=liviu.dudau@arm.com \
    --cc=brian.starkey@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=malidp@foss.arm.com \
    --cc=mihail.atanassov@arm.com \
    /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.