[PATCH 02/36] drm/omap: subclass drm_crtc_state
Tomi Valkeinen
tomi.valkeinen at ti.com
Wed Nov 30 11:17:04 UTC 2016
We need to extend drm_crtc_state to be able to handle omap specific crtc
properties. This patch adds the necessary code to do the subclassing,
without adding any properties.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ti.com>
---
drivers/gpu/drm/omapdrm/omap_crtc.c | 54 ++++++++++++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 8dea89030e66..ff1570c096f8 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -27,6 +27,7 @@
#include "omap_drv.h"
#define to_omap_crtc(x) container_of(x, struct omap_crtc, base)
+#define to_omap_crtc_state(x) container_of(x, struct omap_crtc_state, base)
struct omap_crtc {
struct drm_crtc base;
@@ -45,6 +46,10 @@ struct omap_crtc {
wait_queue_head_t pending_wait;
};
+struct omap_crtc_state {
+ struct drm_crtc_state base;
+};
+
/* -----------------------------------------------------------------------------
* Helper Functions
*/
@@ -318,6 +323,49 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus)
* CRTC Functions
*/
+static struct drm_crtc_state *
+omap_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
+{
+ struct omap_crtc_state *state;
+ struct omap_crtc_state *copy;
+
+ if (WARN_ON(!crtc->state))
+ return NULL;
+
+ state = to_omap_crtc_state(crtc->state);
+ copy = kmemdup(state, sizeof(*state), GFP_KERNEL);
+ if (copy == NULL)
+ return NULL;
+
+ __drm_atomic_helper_crtc_duplicate_state(crtc, ©->base);
+
+ return ©->base;
+}
+
+static void omap_crtc_atomic_destroy_state(struct drm_crtc *crtc,
+ struct drm_crtc_state *state)
+{
+ __drm_atomic_helper_crtc_destroy_state(state);
+ kfree(to_omap_crtc_state(state));
+}
+
+static void omap_crtc_reset(struct drm_crtc *crtc)
+{
+ struct omap_crtc_state *omap_state;
+
+ if (crtc->state) {
+ omap_crtc_atomic_destroy_state(crtc, crtc->state);
+ crtc->state = NULL;
+ }
+
+ omap_state = kzalloc(sizeof(*omap_state), GFP_KERNEL);
+ if (omap_state == NULL)
+ return;
+
+ crtc->state = &omap_state->base;
+ crtc->state->crtc = crtc;
+}
+
static void omap_crtc_destroy(struct drm_crtc *crtc)
{
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
@@ -483,14 +531,14 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc,
}
static const struct drm_crtc_funcs omap_crtc_funcs = {
- .reset = drm_atomic_helper_crtc_reset,
+ .reset = omap_crtc_reset,
.set_config = drm_atomic_helper_set_config,
.destroy = omap_crtc_destroy,
.page_flip = drm_atomic_helper_page_flip,
.gamma_set = drm_atomic_helper_legacy_gamma_set,
.set_property = drm_atomic_helper_crtc_set_property,
- .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
- .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+ .atomic_duplicate_state = omap_crtc_atomic_duplicate_state,
+ .atomic_destroy_state = omap_crtc_atomic_destroy_state,
.atomic_set_property = omap_crtc_atomic_set_property,
.atomic_get_property = omap_crtc_atomic_get_property,
};
--
2.7.4
More information about the dri-devel
mailing list