Skip to content

Commit 88beb8c

Browse files
committed
drm: xlnx: zynqmp_dpsub: Move planes to zynqmp_dpsub structure
Decouple the zynqmp_disp, which handles the hardware configuration, from the DRM planes by moving the planes to the zynqmp_dpsub structure. The planes handling code will be moved to a separate file in a subsequent step. Signed-off-by: Laurent Pinchart <[email protected]>
1 parent 68dcffe commit 88beb8c

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

drivers/gpu/drm/xlnx/zynqmp_disp.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
#define ZYNQMP_DISP_AV_BUF_NUM_VID_GFX_BUFFERS 4
7373
#define ZYNQMP_DISP_AV_BUF_NUM_BUFFERS 6
7474

75-
#define ZYNQMP_DISP_NUM_LAYERS 2
7675
#define ZYNQMP_DISP_MAX_NUM_SUB_PLANES 3
7776

7877
/**
@@ -134,8 +133,7 @@ struct zynqmp_disp_layer_info {
134133
};
135134

136135
/**
137-
* struct zynqmp_disp_layer - Display layer (DRM plane)
138-
* @plane: DRM plane
136+
* struct zynqmp_disp_layer - Display layer
139137
* @id: Layer ID
140138
* @disp: Back pointer to struct zynqmp_disp
141139
* @info: Static layer information
@@ -145,7 +143,6 @@ struct zynqmp_disp_layer_info {
145143
* @mode: Current operation mode
146144
*/
147145
struct zynqmp_disp_layer {
148-
struct drm_plane plane;
149146
enum zynqmp_disp_layer_id id;
150147
struct zynqmp_disp *disp;
151148
const struct zynqmp_disp_layer_info *info;
@@ -182,7 +179,7 @@ struct zynqmp_disp {
182179
void __iomem *base;
183180
} audio;
184181

185-
struct zynqmp_disp_layer layers[ZYNQMP_DISP_NUM_LAYERS];
182+
struct zynqmp_disp_layer layers[ZYNQMP_DPSUB_NUM_LAYERS];
186183
};
187184

188185
/* -----------------------------------------------------------------------------
@@ -1091,11 +1088,6 @@ static int zynqmp_disp_layer_update(struct zynqmp_disp_layer *layer,
10911088
return 0;
10921089
}
10931090

1094-
static inline struct zynqmp_disp_layer *plane_to_layer(struct drm_plane *plane)
1095-
{
1096-
return container_of(plane, struct zynqmp_disp_layer, plane);
1097-
}
1098-
10991091
static int
11001092
zynqmp_disp_plane_atomic_check(struct drm_plane *plane,
11011093
struct drm_atomic_state *state)
@@ -1124,7 +1116,8 @@ zynqmp_disp_plane_atomic_disable(struct drm_plane *plane,
11241116
{
11251117
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
11261118
plane);
1127-
struct zynqmp_disp_layer *layer = plane_to_layer(plane);
1119+
struct zynqmp_dpsub *dpsub = to_zynqmp_dpsub(plane->dev);
1120+
struct zynqmp_disp_layer *layer = &dpsub->disp->layers[plane->index];
11281121

11291122
if (!old_state->fb)
11301123
return;
@@ -1142,7 +1135,8 @@ zynqmp_disp_plane_atomic_update(struct drm_plane *plane,
11421135
{
11431136
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
11441137
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
1145-
struct zynqmp_disp_layer *layer = plane_to_layer(plane);
1138+
struct zynqmp_dpsub *dpsub = to_zynqmp_dpsub(plane->dev);
1139+
struct zynqmp_disp_layer *layer = &dpsub->disp->layers[plane->index];
11461140
bool format_changed = false;
11471141

11481142
if (!old_state->fb ||
@@ -1194,6 +1188,7 @@ static int zynqmp_disp_create_planes(struct zynqmp_disp *disp)
11941188

11951189
for (i = 0; i < ARRAY_SIZE(disp->layers); i++) {
11961190
struct zynqmp_disp_layer *layer = &disp->layers[i];
1191+
struct drm_plane *plane = &disp->dpsub->planes[i];
11971192
enum drm_plane_type type;
11981193
unsigned int num_formats;
11991194
u32 *formats;
@@ -1205,20 +1200,19 @@ static int zynqmp_disp_create_planes(struct zynqmp_disp *disp)
12051200
/* Graphics layer is primary, and video layer is overlay. */
12061201
type = zynqmp_disp_layer_is_video(layer)
12071202
? DRM_PLANE_TYPE_OVERLAY : DRM_PLANE_TYPE_PRIMARY;
1208-
ret = drm_universal_plane_init(disp->drm, &layer->plane, 0,
1203+
ret = drm_universal_plane_init(disp->drm, plane, 0,
12091204
&zynqmp_disp_plane_funcs,
12101205
formats, num_formats,
12111206
NULL, type, NULL);
12121207
kfree(formats);
12131208
if (ret)
12141209
return ret;
12151210

1216-
drm_plane_helper_add(&layer->plane,
1217-
&zynqmp_disp_plane_helper_funcs);
1211+
drm_plane_helper_add(plane, &zynqmp_disp_plane_helper_funcs);
12181212

1219-
drm_plane_create_zpos_immutable_property(&layer->plane, i);
1213+
drm_plane_create_zpos_immutable_property(plane, i);
12201214
if (zynqmp_disp_layer_is_gfx(layer))
1221-
drm_plane_create_alpha_property(&layer->plane);
1215+
drm_plane_create_alpha_property(plane);
12221216
}
12231217

12241218
return 0;
@@ -1538,7 +1532,7 @@ static const struct drm_crtc_funcs zynqmp_disp_crtc_funcs = {
15381532

15391533
static int zynqmp_disp_create_crtc(struct zynqmp_disp *disp)
15401534
{
1541-
struct drm_plane *plane = &disp->layers[ZYNQMP_DISP_LAYER_GFX].plane;
1535+
struct drm_plane *plane = &disp->dpsub->planes[ZYNQMP_DISP_LAYER_GFX];
15421536
struct drm_crtc *crtc = &disp->dpsub->crtc;
15431537
int ret;
15441538

@@ -1561,7 +1555,7 @@ static void zynqmp_disp_map_crtc_to_plane(struct zynqmp_disp *disp)
15611555
unsigned int i;
15621556

15631557
for (i = 0; i < ARRAY_SIZE(disp->layers); i++)
1564-
disp->layers[i].plane.possible_crtcs = possible_crtcs;
1558+
disp->dpsub->planes[i].possible_crtcs = possible_crtcs;
15651559
}
15661560

15671561
/* -----------------------------------------------------------------------------

drivers/gpu/drm/xlnx/zynqmp_dpsub.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <drm/drm_crtc.h>
1616
#include <drm/drm_encoder.h>
17+
#include <drm/drm_plane.h>
1718

1819
struct clk;
1920
struct device;
@@ -22,6 +23,8 @@ struct drm_device;
2223
struct zynqmp_disp;
2324
struct zynqmp_dp;
2425

26+
#define ZYNQMP_DPSUB_NUM_LAYERS 2
27+
2528
enum zynqmp_dpsub_format {
2629
ZYNQMP_DPSUB_FORMAT_RGB,
2730
ZYNQMP_DPSUB_FORMAT_YCRCB444,
@@ -38,6 +41,7 @@ enum zynqmp_dpsub_format {
3841
* @vid_clk_from_ps: True of the video clock comes from PS, false from PL
3942
* @aud_clk: Audio clock
4043
* @aud_clk_from_ps: True of the audio clock comes from PS, false from PL
44+
* @planes: The DRM planes
4145
* @crtc: The DRM CRTC
4246
* @encoder: The dummy DRM encoder
4347
* @bridge: The DP encoder bridge
@@ -55,6 +59,7 @@ struct zynqmp_dpsub {
5559
struct clk *aud_clk;
5660
bool aud_clk_from_ps;
5761

62+
struct drm_plane planes[ZYNQMP_DPSUB_NUM_LAYERS];
5863
struct drm_crtc crtc;
5964
struct drm_encoder encoder;
6065
struct drm_bridge *bridge;

0 commit comments

Comments
 (0)