Skip to content

Commit 32cc115

Browse files
chadmedjannau
authored andcommitted
drm: apple: get framebuffer iova in atomic_plane_update
Signed-off-by: James Calligeros <jcalligeros99@gmail.com> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 0cb7041 commit 32cc115

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

drivers/gpu/drm/apple/iomfb_template.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <drm/drm_fb_dma_helper.h>
2121
#include <drm/drm_fourcc.h>
2222
#include <drm/drm_framebuffer.h>
23-
#include <drm/drm_gem_dma_helper.h>
2423
#include <drm/drm_probe_helper.h>
2524
#include <drm/drm_vblank.h>
2625

@@ -1306,8 +1305,6 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
13061305

13071306
for_each_oldnew_plane_in_state(state, plane, old_state, new_state, plane_idx) {
13081307
struct apple_plane_state *apple_state = to_apple_plane_state(new_state);
1309-
struct drm_framebuffer *fb = new_state->fb;
1310-
struct drm_gem_dma_object *obj;
13111308

13121309
/* skip planes not for this crtc */
13131310
if (old_state->crtc != crtc && new_state->crtc != crtc)
@@ -1329,7 +1326,7 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
13291326

13301327
req->swap.swap_enabled |= BIT(l);
13311328

1332-
if (old_state->fb && fb != old_state->fb) {
1329+
if (old_state->fb && new_state->fb != old_state->fb) {
13331330
/*
13341331
* Race condition between a framebuffer unbind getting
13351332
* swapped out and GEM unreferencing a framebuffer. If
@@ -1362,14 +1359,7 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
13621359
if (dcp->notch_height > 0)
13631360
req->swap.dst_rect[l].y += dcp->notch_height;
13641361

1365-
/* the obvious helper call drm_fb_dma_get_gem_addr() adjusts
1366-
* the address for source x/y offsets. Since IOMFB has a direct
1367-
* support source position prefer that.
1368-
*/
1369-
obj = drm_fb_dma_get_gem_obj(fb, 0);
1370-
if (obj)
1371-
req->surf_iova[l] = obj->dma_addr + fb->offsets[0];
1372-
1362+
req->surf_iova[l] = apple_state->iova;
13731363
req->surf[l].base = apple_state->surf;
13741364

13751365
}

drivers/gpu/drm/apple/plane.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <drm/drm_fourcc.h>
1313
#include <drm/drm_fb_dma_helper.h>
1414
#include <drm/drm_framebuffer.h>
15+
#include <drm/drm_gem_dma_helper.h>
1516
#include <drm/drm_plane.h>
1617

1718
#define FRAC_16_16(mult, div) (((mult) << 16) / (div))
@@ -128,6 +129,7 @@ static void apple_plane_atomic_update(struct drm_plane *plane,
128129
{
129130
struct drm_plane_state *base = drm_atomic_get_new_plane_state(state, plane);
130131
struct apple_plane_state *new_state;
132+
struct drm_gem_dma_object *obj;
131133
bool is_premultiplied = false;
132134

133135
if (!base)
@@ -171,6 +173,14 @@ static void apple_plane_atomic_update(struct drm_plane *plane,
171173
.has_comp = 1,
172174
.has_planes = 1,
173175
};
176+
177+
/* the obvious helper call drm_fb_dma_get_gem_addr() adjusts
178+
* the address for source x/y offsets. Since IOMFB has a direct
179+
* support source position prefer that.
180+
*/
181+
obj = drm_fb_dma_get_gem_obj(base->fb, 0);
182+
if (obj)
183+
new_state->iova = obj->dma_addr + base->fb->offsets[0];
174184
}
175185

176186
static const struct drm_plane_helper_funcs apple_primary_plane_helper_funcs = {

drivers/gpu/drm/apple/plane.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct apple_plane_state {
1717
struct dcp_surface surf;
1818
struct dcp_rect src_rect;
1919
struct dcp_rect dst_rect;
20+
u64 iova;
2021
};
2122

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

0 commit comments

Comments
 (0)