Skip to content

Commit cb1d6bc

Browse files
Nancy.LinChun-Kuang Hu
authored andcommitted
drm/mediatek: Add dma dev get function
This is a preparation for adding support for the ovl_adaptor sub driver Ovl_adaptor is a DRM sub driver, which doesn't have dma dev. Add dma_dev_get function for getting representative dma dev in ovl_adaptor. Signed-off-by: Nancy.Lin <[email protected]> Reviewed-by: AngeloGioachino Del Regno <[email protected]> Tested-by: AngeloGioacchino Del Regno <[email protected]> Tested-by: Bo-Chen Chen <[email protected]> Link: https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 453c336 commit cb1d6bc

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

drivers/gpu/drm/mediatek/mtk_drm_crtc.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct mtk_drm_crtc {
5858
#endif
5959

6060
struct device *mmsys_dev;
61+
struct device *dma_dev;
6162
struct mtk_mutex *mutex;
6263
unsigned int ddp_comp_nr;
6364
struct mtk_ddp_comp **ddp_comp;
@@ -867,6 +868,13 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev,
867868
return 0;
868869
}
869870

871+
struct device *mtk_drm_crtc_dma_dev_get(struct drm_crtc *crtc)
872+
{
873+
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
874+
875+
return mtk_crtc->dma_dev;
876+
}
877+
870878
int mtk_drm_crtc_create(struct drm_device *drm_dev,
871879
const enum mtk_ddp_comp_id *path, unsigned int path_len)
872880
{
@@ -957,6 +965,13 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
957965
return ret;
958966
}
959967

968+
/*
969+
* Default to use the first component as the dma dev.
970+
* In the case of ovl_adaptor sub driver, it needs to use the
971+
* dma_dev_get function to get representative dma dev.
972+
*/
973+
mtk_crtc->dma_dev = mtk_ddp_comp_dma_dev_get(&priv->ddp_comp[path[0]]);
974+
960975
ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
961976
if (ret < 0)
962977
return ret;

drivers/gpu/drm/mediatek/mtk_drm_crtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane,
2222
struct mtk_plane_state *state);
2323
void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
2424
struct drm_atomic_state *plane_state);
25+
struct device *mtk_drm_crtc_dma_dev_get(struct drm_crtc *crtc);
2526

2627
#endif /* MTK_DRM_CRTC_H */

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct mtk_ddp_comp_funcs {
7171
void (*bgclr_in_off)(struct device *dev);
7272
void (*ctm_set)(struct device *dev,
7373
struct drm_crtc_state *state);
74+
struct device * (*dma_dev_get)(struct device *dev);
7475
const u32 *(*get_formats)(struct device *dev);
7576
size_t (*get_num_formats)(struct device *dev);
7677
};
@@ -205,6 +206,13 @@ static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp *comp,
205206
comp->funcs->ctm_set(comp->dev, state);
206207
}
207208

209+
static inline struct device *mtk_ddp_comp_dma_dev_get(struct mtk_ddp_comp *comp)
210+
{
211+
if (comp->funcs && comp->funcs->dma_dev_get)
212+
return comp->funcs->dma_dev_get(comp->dev);
213+
return comp->dev;
214+
}
215+
208216
static inline
209217
const u32 *mtk_ddp_comp_get_formats(struct mtk_ddp_comp *comp)
210218
{

0 commit comments

Comments
 (0)