Skip to content

Commit

Permalink
drm/mediatek: Add plumbing for layer_check hook
Browse files Browse the repository at this point in the history
This allows components to implement a .layer_check callback for their
layers which is called during atomic_check.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: CK Hu <ck.hu@mediatek.com>
  • Loading branch information
Sean Paul authored and CK Hu committed Nov 6, 2019
1 parent d6b53f6 commit f7c710d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/gpu/drm/mediatek/mtk_drm_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,16 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc)
}
}

int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane,
struct mtk_plane_state *state)
{
unsigned int local_layer;
struct mtk_ddp_comp *comp;

comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer);
return mtk_ddp_comp_layer_check(comp, local_layer, state);
}

static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/mediatek/mtk_drm_crtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *comp);
int mtk_drm_crtc_create(struct drm_device *drm_dev,
const enum mtk_ddp_comp_id *path,
unsigned int path_len);
int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane,
struct mtk_plane_state *state);

#endif /* MTK_DRM_CRTC_H */
12 changes: 12 additions & 0 deletions drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ struct mtk_ddp_comp_funcs {
unsigned int (*layer_nr)(struct mtk_ddp_comp *comp);
void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx);
void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx);
int (*layer_check)(struct mtk_ddp_comp *comp,
unsigned int idx,
struct mtk_plane_state *state);
void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx,
struct mtk_plane_state *state);
void (*gamma_set)(struct mtk_ddp_comp *comp,
Expand Down Expand Up @@ -152,6 +155,15 @@ static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp,
comp->funcs->layer_off(comp, idx);
}

static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp *comp,
unsigned int idx,
struct mtk_plane_state *state)
{
if (comp->funcs && comp->funcs->layer_check)
return comp->funcs->layer_check(comp, idx, state);
return 0;
}

static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
unsigned int idx,
struct mtk_plane_state *state)
Expand Down
6 changes: 6 additions & 0 deletions drivers/gpu/drm/mediatek/mtk_drm_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,19 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
{
struct drm_framebuffer *fb = state->fb;
struct drm_crtc_state *crtc_state;
int ret;

if (!fb)
return 0;

if (!state->crtc)
return 0;

ret = mtk_drm_crtc_plane_check(state->crtc, plane,
to_mtk_plane_state(state));
if (ret)
return ret;

crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
if (IS_ERR(crtc_state))
return PTR_ERR(crtc_state);
Expand Down

0 comments on commit f7c710d

Please sign in to comment.