Commit f7c710d1 authored by Sean Paul's avatar Sean Paul Committed by CK Hu
Browse files

drm/mediatek: Add plumbing for layer_check hook



This allows components to implement a .layer_check callback for their
layers which is called during atomic_check.

Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarCK Hu <ck.hu@mediatek.com>
parent d6b53f68
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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)
{
+2 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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,
@@ -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)
+6 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ 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;
@@ -97,6 +98,11 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
	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);