[PATCH 51/70] drm/loongson: Convert to atomic_create_state

Maxime Ripard <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel
Message-ID <[email protected]>
The loongsoon crtc implementation provides a custom reset hook. However,
this hook only allocates the state, initializes it with
__drm_atomic_helper_crtc_reset(), and frees the previous state. It does
not perform any hardware reset.

Since the atomic_create_state hook is only meant to deal with state
allocation and initialization, convert it accordingly. The hardware
reset through ops->reset() is kept as part of the state creation
since the core currently calls atomic_create_state in the same
context where the reset hook was called.

Signed-off-by: Maxime Ripard <[email protected]>
---
Cc: Huacai Chen <[email protected]>
Cc: Icenowy Zheng <[email protected]>
Cc: Jianmin Lv <[email protected]>
Cc: Mingcong Bai <[email protected]>
Cc: Qianhai Wu <[email protected]>
Cc: Xi Ruoyao <[email protected]>
---
 drivers/gpu/drm/loongson/lsdc_crtc.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c b/drivers/gpu/drm/loongson/lsdc_crtc.c
index 97a3443739e1..2815366abc14 100644
--- a/drivers/gpu/drm/loongson/lsdc_crtc.c
+++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
@@ -386,23 +386,22 @@ static const struct lsdc_crtc_hw_ops ls7a2000_crtc_hw_ops[2] = {
 		.get_vblank_counter = lsdc_crtc1_get_vblank_count,
 		.reset = lsdc_crtc1_reset,
 	},
 };
 
-static void lsdc_crtc_reset(struct drm_crtc *crtc)
+static struct drm_crtc_state *lsdc_crtc_create_state(struct drm_crtc *crtc)
 {
 	struct lsdc_crtc_state *priv_crtc_state;
 
-	if (crtc->state)
-		crtc->funcs->atomic_destroy_state(crtc, crtc->state);
-
 	priv_crtc_state = kzalloc_obj(*priv_crtc_state);
 
 	if (!priv_crtc_state)
-		__drm_atomic_helper_crtc_reset(crtc, NULL);
-	else
-		__drm_atomic_helper_crtc_reset(crtc, &priv_crtc_state->base);
+		return ERR_PTR(-ENOMEM);
+
+	__drm_atomic_helper_crtc_state_init(&priv_crtc_state->base, crtc);
+
+	return &priv_crtc_state->base;
 }
 
 static void lsdc_crtc_atomic_destroy_state(struct drm_crtc *crtc,
 					   struct drm_crtc_state *state)
 {
@@ -705,11 +704,11 @@ static void lsdc_crtc_atomic_print_state(struct drm_printer *p,
 	drm_printf(p, "\tMedium clock multiplier = %u\n", pparms->loopc);
 	drm_printf(p, "\tOutput clock divider = %u\n", pparms->div_out);
 }
 
 static const struct drm_crtc_funcs ls7a1000_crtc_funcs = {
-	.reset = lsdc_crtc_reset,
+	.atomic_create_state = lsdc_crtc_create_state,
 	.destroy = drm_crtc_cleanup,
 	.set_config = drm_atomic_helper_set_config,
 	.page_flip = drm_atomic_helper_page_flip,
 	.atomic_duplicate_state = lsdc_crtc_atomic_duplicate_state,
 	.atomic_destroy_state = lsdc_crtc_atomic_destroy_state,
@@ -719,11 +718,11 @@ static const struct drm_crtc_funcs ls7a1000_crtc_funcs = {
 	.get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
 	.atomic_print_state = lsdc_crtc_atomic_print_state,
 };
 
 static const struct drm_crtc_funcs ls7a2000_crtc_funcs = {
-	.reset = lsdc_crtc_reset,
+	.atomic_create_state = lsdc_crtc_create_state,
 	.destroy = drm_crtc_cleanup,
 	.set_config = drm_atomic_helper_set_config,
 	.page_flip = drm_atomic_helper_page_flip,
 	.atomic_duplicate_state = lsdc_crtc_atomic_duplicate_state,
 	.atomic_destroy_state = lsdc_crtc_atomic_destroy_state,

-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.