Skip to content

Commit 4a116a3

Browse files
committed
drm: spacemit: port K3 display driver to 7.4 DRM atomic state API
The K3 display v2 series targets the legacy DRM CRTC/plane reset callbacks, which were removed in the 7.4 kernel in favor of the atomic_create_state() hooks. - spacemit_crtc.c: replace .reset with .atomic_create_state and create the initial state with drm_mode_config_create_initial_state() before drm_dev_register(). - spacemit_planes.c: replace .reset with .atomic_create_state, using __drm_atomic_helper_plane_state_init(). Also fix a mangled dev_err() format string introduced during the port.
1 parent cfc6bd0 commit 4a116a3

2 files changed

Lines changed: 26 additions & 23 deletions

File tree

‎drivers/gpu/drm/spacemit/spacemit_crtc.c‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,29 +273,27 @@ static void spacemit_crtc_destroy_state(struct drm_crtc *crtc,
273273
}
274274
}
275275

276-
static void spacemit_crtc_reset(struct drm_crtc *crtc)
276+
static struct drm_crtc_state *
277+
spacemit_crtc_create_state(struct drm_crtc *crtc)
277278
{
278279
struct spacemit_drm_private *priv = crtc->dev->dev_private;
279280
struct spacemit_hw_device *hwdev = priv->hwdev;
280281
struct spacemit_crtc_state *state;
281282

282-
if (crtc->state)
283-
spacemit_crtc_destroy_state(crtc, crtc->state);
284-
285283
state = kzalloc_obj(*state);
286-
if (!state) {
287-
__drm_atomic_helper_crtc_reset(crtc, NULL);
288-
return;
289-
}
284+
if (!state)
285+
return ERR_PTR(-ENOMEM);
290286

291287
state->rdmas = kzalloc_objs(*state->rdmas, hwdev->rdma_nums);
292288
if (!state->rdmas) {
293289
kfree(state);
294-
__drm_atomic_helper_crtc_reset(crtc, NULL);
295-
return;
290+
return ERR_PTR(-ENOMEM);
296291
}
297292

298-
__drm_atomic_helper_crtc_reset(crtc, &state->base);
293+
state->cl.type = CMDLIST_CRTC;
294+
__drm_atomic_helper_crtc_state_init(&state->base, crtc);
295+
296+
return &state->base;
299297
}
300298

301299
static int spacemit_crtc_enable_vblank(struct drm_crtc *crtc)
@@ -332,7 +330,7 @@ static const struct drm_crtc_funcs spacemit_crtc_funcs = {
332330
.destroy = drm_crtc_cleanup,
333331
.set_config = drm_atomic_helper_set_config,
334332
.page_flip = drm_atomic_helper_page_flip,
335-
.reset = spacemit_crtc_reset,
333+
.atomic_create_state = spacemit_crtc_create_state,
336334
.atomic_duplicate_state = spacemit_crtc_duplicate_state,
337335
.atomic_destroy_state = spacemit_crtc_destroy_state,
338336
.enable_vblank = spacemit_crtc_enable_vblank,
@@ -590,6 +588,12 @@ static int spacemit_drm_master_bind(struct device *dev)
590588
drmm_kms_helper_poll_init(drm);
591589
drm_helper_hpd_irq_event(drm);
592590

591+
ret = drm_mode_config_create_initial_state(drm);
592+
if (ret) {
593+
dev_err(dev, "failed to create initial state: %d\n", ret);
594+
goto err_unbind_all;
595+
}
596+
593597
enable_irq(priv->irq_online);
594598

595599
ret = drm_dev_register(drm, 0);

‎drivers/gpu/drm/spacemit/spacemit_planes.c‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,19 @@ static void spacemit_plane_atomic_disable(struct drm_plane *plane,
209209
drm_dev_exit(idx);
210210
}
211211

212-
static void spacemit_plane_reset(struct drm_plane *plane)
212+
static struct drm_plane_state *
213+
spacemit_plane_create_state(struct drm_plane *plane)
213214
{
214215
struct spacemit_plane_state *s;
215216

216-
if (plane->state) {
217-
spacemit_plane_atomic_destroy_state(plane, plane->state);
218-
plane->state = NULL;
219-
}
220-
221217
s = kzalloc(sizeof(*s), GFP_KERNEL);
222-
if (s) {
223-
__drm_atomic_helper_plane_reset(plane, &s->state);
224-
s->rdma_id = RDMA_INVALID_ID;
225-
}
218+
if (!s)
219+
return ERR_PTR(-ENOMEM);
220+
221+
__drm_atomic_helper_plane_state_init(&s->state, plane);
222+
s->rdma_id = RDMA_INVALID_ID;
223+
224+
return &s->state;
226225
}
227226

228227
static struct drm_plane_state *
@@ -304,7 +303,7 @@ static const struct drm_plane_funcs spacemit_plane_funcs = {
304303
.update_plane = drm_atomic_helper_update_plane,
305304
.disable_plane = drm_atomic_helper_disable_plane,
306305
.destroy = drm_plane_cleanup,
307-
.reset = spacemit_plane_reset,
306+
.atomic_create_state = spacemit_plane_create_state,
308307
.atomic_duplicate_state = spacemit_plane_atomic_duplicate_state,
309308
.atomic_destroy_state = spacemit_plane_atomic_destroy_state,
310309
};

0 commit comments

Comments
 (0)