Skip to content

Commit a474ef8

Browse files
chadmedjannau
authored andcommitted
drm: apple: move dcp rectangle creation to atomic_plane_update
We should not be programming rectangles in atomic_flush. Move this step to atomic_plane_update and store the resultant rectangles with the rest of the surface's state. Signed-off-by: James Calligeros <[email protected]> Signed-off-by: Janne Grunau <[email protected]>
1 parent 18315ee commit a474ef8

8 files changed

Lines changed: 36 additions & 32 deletions

File tree

drivers/gpu/drm/apple/iomfb.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -343,19 +343,6 @@ static void dcpep_got_msg(struct apple_dcp *dcp, u64 message)
343343
dcpep_handle_cb(dcp, ctx_id, data, length, offset);
344344
}
345345

346-
/*
347-
* DRM specifies rectangles as start and end coordinates. DCP specifies
348-
* rectangles as a start coordinate and a width/height. Convert a DRM rectangle
349-
* to a DCP rectangle.
350-
*/
351-
struct dcp_rect drm_to_dcp_rect(struct drm_rect *rect)
352-
{
353-
return (struct dcp_rect){ .x = rect->x1,
354-
.y = rect->y1,
355-
.w = drm_rect_width(rect),
356-
.h = drm_rect_height(rect) };
357-
}
358-
359346
int dcp_get_modes(struct drm_connector *connector)
360347
{
361348
struct apple_connector *apple_connector = to_apple_connector(connector);

drivers/gpu/drm/apple/iomfb.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,6 @@ struct dcp_iouserclient {
100100
u8 padding[2];
101101
} __packed;
102102

103-
struct dcp_rect {
104-
u32 x;
105-
u32 y;
106-
u32 w;
107-
u32 h;
108-
} __packed;
109-
110103
/*
111104
* Update background color to struct dcp_swap.bg_color
112105
*/

drivers/gpu/drm/apple/iomfb_internal.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ int dcp_parse_tag(char tag[4]);
109109

110110
void dcp_ack(struct apple_dcp *dcp, enum dcp_context_id context);
111111

112-
/*
113-
* DRM specifies rectangles as start and end coordinates. DCP specifies
114-
* rectangles as a start coordinate and a width/height. Convert a DRM rectangle
115-
* to a DCP rectangle.
116-
*/
117-
struct dcp_rect drm_to_dcp_rect(struct drm_rect *rect);
118-
119112
/* The user may own drm_display_mode, so we need to search for our copy */
120113
struct dcp_display_mode *lookup_mode(struct apple_dcp *dcp,
121114
const struct drm_display_mode *mode);

drivers/gpu/drm/apple/iomfb_plane.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
#define DCP_SURF_MAX_PLANES 3
1313

14+
struct dcp_rect {
15+
u32 x;
16+
u32 y;
17+
u32 w;
18+
u32 h;
19+
} __packed;
20+
1421
/* Information describing a plane of a planar compressed surface */
1522
struct dcp_plane_info {
1623
u32 width;

drivers/gpu/drm/apple/iomfb_template.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,6 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
13081308
struct apple_plane_state *apple_state = to_apple_plane_state(new_state);
13091309
struct drm_framebuffer *fb = new_state->fb;
13101310
struct drm_gem_dma_object *obj;
1311-
struct drm_rect src_rect;
13121311

13131312
/* skip planes not for this crtc */
13141313
if (old_state->crtc != crtc && new_state->crtc != crtc)
@@ -1357,10 +1356,8 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
13571356
req->surf_null[l] = false;
13581357
has_surface = 1;
13591358

1360-
drm_rect_fp_to_int(&src_rect, &new_state->src);
1361-
1362-
req->swap.src_rect[l] = drm_to_dcp_rect(&src_rect);
1363-
req->swap.dst_rect[l] = drm_to_dcp_rect(&new_state->dst);
1359+
req->swap.src_rect[l] = apple_state->src_rect;
1360+
req->swap.dst_rect[l] = apple_state->dst_rect;
13641361

13651362
if (dcp->notch_height > 0)
13661363
req->swap.dst_rect[l].y += dcp->notch_height;

drivers/gpu/drm/apple/iomfb_template.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/types.h>
1414

1515
#include "iomfb.h"
16+
#include "iomfb_plane.h"
1617
#include "plane.h"
1718
#include "version_utils.h"
1819

drivers/gpu/drm/apple/plane.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ static int apple_plane_atomic_check(struct drm_plane *plane,
8383
return 0;
8484
}
8585

86+
/*
87+
* DRM specifies rectangles as start and end coordinates. DCP specifies
88+
* rectangles as a start coordinate and a width/height. Convert a DRM rectangle
89+
* to a DCP rectangle.
90+
*/
91+
static struct dcp_rect drm_to_dcp_rect(const struct drm_rect *rect)
92+
{
93+
return (struct dcp_rect){ .x = rect->x1,
94+
.y = rect->y1,
95+
.w = drm_rect_width(rect),
96+
.h = drm_rect_height(rect),
97+
};
98+
}
99+
100+
static struct dcp_rect drm_to_dcp_rect_fp(const struct drm_rect *fp_rect)
101+
{
102+
struct drm_rect rect;
103+
drm_rect_fp_to_int(&rect, fp_rect);
104+
return drm_to_dcp_rect(&rect);
105+
}
106+
86107
static u32 drm_format_to_dcp(u32 drm)
87108
{
88109
switch (drm) {
@@ -129,6 +150,9 @@ static void apple_plane_atomic_update(struct drm_plane *plane,
129150
fb->format->format == DRM_FORMAT_XBGR8888)
130151
is_premultiplied = true;
131152

153+
new_state->src_rect = drm_to_dcp_rect_fp(&base->src);
154+
new_state->dst_rect = drm_to_dcp_rect(&base->dst);
155+
132156
new_state->surf = (struct dcp_surface){
133157
.is_premultiplied = is_premultiplied,
134158
.format = drm_format_to_dcp(fb->format->format),

drivers/gpu/drm/apple/plane.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
struct apple_plane_state {
1616
struct drm_plane_state base;
1717
struct dcp_surface surf;
18+
struct dcp_rect src_rect;
19+
struct dcp_rect dst_rect;
1820
};
1921

2022
#define to_apple_plane_state(x) container_of(x, struct apple_plane_state, base)

0 commit comments

Comments
 (0)