Skip to content

Commit d540f82

Browse files
committed
drm/sun4i: backend: Add a custom plane state
We will need to store some additional data in the future to the state. Create a custom plane state that will embed those data, in order to store the pipe or whether or not that plane should use the frontend. Reviewed-by: Chen-Yu Tsai <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/88dd9c2b0caa550595e7b2ff37dc9d0af2c78609.1516613040.git-series.maxime.ripard@free-electrons.com
1 parent 9f4ebf6 commit d540f82

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

drivers/gpu/drm/sun4i/sun4i_layer.c

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,50 @@ struct sun4i_plane_desc {
2525
uint32_t nformats;
2626
};
2727

28+
static void sun4i_backend_layer_reset(struct drm_plane *plane)
29+
{
30+
struct sun4i_layer_state *state;
31+
32+
if (plane->state) {
33+
state = state_to_sun4i_layer_state(plane->state);
34+
35+
__drm_atomic_helper_plane_destroy_state(&state->state);
36+
37+
kfree(state);
38+
plane->state = NULL;
39+
}
40+
41+
state = kzalloc(sizeof(*state), GFP_KERNEL);
42+
if (state) {
43+
plane->state = &state->state;
44+
plane->state->plane = plane;
45+
}
46+
}
47+
48+
static struct drm_plane_state *
49+
sun4i_backend_layer_duplicate_state(struct drm_plane *plane)
50+
{
51+
struct sun4i_layer_state *copy;
52+
53+
copy = kzalloc(sizeof(*copy), GFP_KERNEL);
54+
if (!copy)
55+
return NULL;
56+
57+
__drm_atomic_helper_plane_duplicate_state(plane, &copy->state);
58+
59+
return &copy->state;
60+
}
61+
62+
static void sun4i_backend_layer_destroy_state(struct drm_plane *plane,
63+
struct drm_plane_state *state)
64+
{
65+
struct sun4i_layer_state *s_state = state_to_sun4i_layer_state(state);
66+
67+
__drm_atomic_helper_plane_destroy_state(state);
68+
69+
kfree(s_state);
70+
}
71+
2872
static void sun4i_backend_layer_atomic_disable(struct drm_plane *plane,
2973
struct drm_plane_state *old_state)
3074
{
@@ -52,11 +96,11 @@ static const struct drm_plane_helper_funcs sun4i_backend_layer_helper_funcs = {
5296
};
5397

5498
static const struct drm_plane_funcs sun4i_backend_layer_funcs = {
55-
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
56-
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
99+
.atomic_destroy_state = sun4i_backend_layer_destroy_state,
100+
.atomic_duplicate_state = sun4i_backend_layer_duplicate_state,
57101
.destroy = drm_plane_cleanup,
58102
.disable_plane = drm_atomic_helper_disable_plane,
59-
.reset = drm_atomic_helper_plane_reset,
103+
.reset = sun4i_backend_layer_reset,
60104
.update_plane = drm_atomic_helper_update_plane,
61105
};
62106

drivers/gpu/drm/sun4i/sun4i_layer.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@ struct sun4i_layer {
2222
int id;
2323
};
2424

25+
struct sun4i_layer_state {
26+
struct drm_plane_state state;
27+
};
28+
2529
static inline struct sun4i_layer *
2630
plane_to_sun4i_layer(struct drm_plane *plane)
2731
{
2832
return container_of(plane, struct sun4i_layer, plane);
2933
}
3034

35+
static inline struct sun4i_layer_state *
36+
state_to_sun4i_layer_state(struct drm_plane_state *state)
37+
{
38+
return container_of(state, struct sun4i_layer_state, state);
39+
}
40+
3141
struct drm_plane **sun4i_layers_init(struct drm_device *drm,
3242
struct sunxi_engine *engine);
3343

0 commit comments

Comments
 (0)