2019-05-27 08:55:21 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2016-01-04 18:36:34 +01:00
/*
* Copyright ( c ) 2015 MediaTek Inc .
*/
# ifndef MTK_DRM_DDP_COMP_H
# define MTK_DRM_DDP_COMP_H
# include <linux/io.h>
struct device ;
struct device_node ;
struct drm_crtc ;
struct drm_device ;
struct mtk_plane_state ;
2016-07-28 10:22:54 +08:00
struct drm_crtc_state ;
2016-01-04 18:36:34 +01:00
enum mtk_ddp_comp_type {
MTK_DISP_OVL ,
2019-08-29 22:50:37 +08:00
MTK_DISP_OVL_2L ,
2016-01-04 18:36:34 +01:00
MTK_DISP_RDMA ,
MTK_DISP_WDMA ,
MTK_DISP_COLOR ,
2019-08-29 22:50:36 +08:00
MTK_DISP_CCORR ,
2019-08-29 22:50:39 +08:00
MTK_DISP_DITHER ,
2016-01-04 18:36:34 +01:00
MTK_DISP_AAL ,
MTK_DISP_GAMMA ,
MTK_DISP_UFOE ,
MTK_DSI ,
MTK_DPI ,
MTK_DISP_PWM ,
MTK_DISP_MUTEX ,
MTK_DISP_OD ,
2017-03-31 19:30:32 +08:00
MTK_DISP_BLS ,
2016-01-04 18:36:34 +01:00
MTK_DDP_COMP_TYPE_MAX ,
} ;
enum mtk_ddp_comp_id {
2018-06-20 16:19:05 +08:00
DDP_COMPONENT_AAL0 ,
DDP_COMPONENT_AAL1 ,
2017-03-31 19:30:32 +08:00
DDP_COMPONENT_BLS ,
2019-08-29 22:50:36 +08:00
DDP_COMPONENT_CCORR ,
2016-01-04 18:36:34 +01:00
DDP_COMPONENT_COLOR0 ,
DDP_COMPONENT_COLOR1 ,
2019-08-29 22:50:39 +08:00
DDP_COMPONENT_DITHER ,
2016-01-04 18:36:34 +01:00
DDP_COMPONENT_DPI0 ,
2018-06-20 16:19:09 +08:00
DDP_COMPONENT_DPI1 ,
2016-01-04 18:36:34 +01:00
DDP_COMPONENT_DSI0 ,
DDP_COMPONENT_DSI1 ,
2018-06-20 16:19:10 +08:00
DDP_COMPONENT_DSI2 ,
2018-06-20 16:19:11 +08:00
DDP_COMPONENT_DSI3 ,
2016-01-04 18:36:34 +01:00
DDP_COMPONENT_GAMMA ,
2018-06-20 16:19:06 +08:00
DDP_COMPONENT_OD0 ,
DDP_COMPONENT_OD1 ,
2016-01-04 18:36:34 +01:00
DDP_COMPONENT_OVL0 ,
2019-08-29 22:50:37 +08:00
DDP_COMPONENT_OVL_2L0 ,
2019-08-29 22:50:38 +08:00
DDP_COMPONENT_OVL_2L1 ,
2016-01-04 18:36:34 +01:00
DDP_COMPONENT_OVL1 ,
DDP_COMPONENT_PWM0 ,
DDP_COMPONENT_PWM1 ,
2018-06-20 16:19:08 +08:00
DDP_COMPONENT_PWM2 ,
2016-01-04 18:36:34 +01:00
DDP_COMPONENT_RDMA0 ,
DDP_COMPONENT_RDMA1 ,
DDP_COMPONENT_RDMA2 ,
DDP_COMPONENT_UFOE ,
DDP_COMPONENT_WDMA0 ,
DDP_COMPONENT_WDMA1 ,
DDP_COMPONENT_ID_MAX ,
} ;
struct mtk_ddp_comp ;
struct mtk_ddp_comp_funcs {
void ( * config ) ( struct mtk_ddp_comp * comp , unsigned int w ,
2016-07-28 10:22:55 +08:00
unsigned int h , unsigned int vrefresh , unsigned int bpc ) ;
2016-01-04 18:36:34 +01:00
void ( * start ) ( struct mtk_ddp_comp * comp ) ;
void ( * stop ) ( struct mtk_ddp_comp * comp ) ;
void ( * enable_vblank ) ( struct mtk_ddp_comp * comp , struct drm_crtc * crtc ) ;
void ( * disable_vblank ) ( struct mtk_ddp_comp * comp ) ;
2019-11-05 16:10:21 -05:00
unsigned int ( * supported_rotations ) ( struct mtk_ddp_comp * comp ) ;
2018-08-09 10:15:44 +08:00
unsigned int ( * layer_nr ) ( struct mtk_ddp_comp * comp ) ;
2016-01-04 18:36:34 +01:00
void ( * layer_on ) ( struct mtk_ddp_comp * comp , unsigned int idx ) ;
void ( * layer_off ) ( struct mtk_ddp_comp * comp , unsigned int idx ) ;
2019-11-05 16:10:20 -05:00
int ( * layer_check ) ( struct mtk_ddp_comp * comp ,
unsigned int idx ,
struct mtk_plane_state * state ) ;
2016-01-04 18:36:34 +01:00
void ( * layer_config ) ( struct mtk_ddp_comp * comp , unsigned int idx ,
struct mtk_plane_state * state ) ;
2016-07-28 10:22:54 +08:00
void ( * gamma_set ) ( struct mtk_ddp_comp * comp ,
struct drm_crtc_state * state ) ;
2019-08-29 22:50:42 +08:00
void ( * bgclr_in_on ) ( struct mtk_ddp_comp * comp ) ;
void ( * bgclr_in_off ) ( struct mtk_ddp_comp * comp ) ;
2016-01-04 18:36:34 +01:00
} ;
struct mtk_ddp_comp {
struct clk * clk ;
void __iomem * regs ;
int irq ;
struct device * larb_dev ;
enum mtk_ddp_comp_id id ;
const struct mtk_ddp_comp_funcs * funcs ;
} ;
static inline void mtk_ddp_comp_config ( struct mtk_ddp_comp * comp ,
unsigned int w , unsigned int h ,
2016-07-28 10:22:55 +08:00
unsigned int vrefresh , unsigned int bpc )
2016-01-04 18:36:34 +01:00
{
if ( comp - > funcs & & comp - > funcs - > config )
2016-07-28 10:22:55 +08:00
comp - > funcs - > config ( comp , w , h , vrefresh , bpc ) ;
2016-01-04 18:36:34 +01:00
}
static inline void mtk_ddp_comp_start ( struct mtk_ddp_comp * comp )
{
if ( comp - > funcs & & comp - > funcs - > start )
comp - > funcs - > start ( comp ) ;
}
static inline void mtk_ddp_comp_stop ( struct mtk_ddp_comp * comp )
{
if ( comp - > funcs & & comp - > funcs - > stop )
comp - > funcs - > stop ( comp ) ;
}
static inline void mtk_ddp_comp_enable_vblank ( struct mtk_ddp_comp * comp ,
struct drm_crtc * crtc )
{
if ( comp - > funcs & & comp - > funcs - > enable_vblank )
comp - > funcs - > enable_vblank ( comp , crtc ) ;
}
static inline void mtk_ddp_comp_disable_vblank ( struct mtk_ddp_comp * comp )
{
if ( comp - > funcs & & comp - > funcs - > disable_vblank )
comp - > funcs - > disable_vblank ( comp ) ;
}
2019-11-05 16:10:21 -05:00
static inline
unsigned int mtk_ddp_comp_supported_rotations ( struct mtk_ddp_comp * comp )
{
if ( comp - > funcs & & comp - > funcs - > supported_rotations )
return comp - > funcs - > supported_rotations ( comp ) ;
return 0 ;
}
2018-08-09 10:15:44 +08:00
static inline unsigned int mtk_ddp_comp_layer_nr ( struct mtk_ddp_comp * comp )
{
if ( comp - > funcs & & comp - > funcs - > layer_nr )
return comp - > funcs - > layer_nr ( comp ) ;
return 0 ;
}
2016-01-04 18:36:34 +01:00
static inline void mtk_ddp_comp_layer_on ( struct mtk_ddp_comp * comp ,
unsigned int idx )
{
if ( comp - > funcs & & comp - > funcs - > layer_on )
comp - > funcs - > layer_on ( comp , idx ) ;
}
static inline void mtk_ddp_comp_layer_off ( struct mtk_ddp_comp * comp ,
unsigned int idx )
{
if ( comp - > funcs & & comp - > funcs - > layer_off )
comp - > funcs - > layer_off ( comp , idx ) ;
}
2019-11-05 16:10:20 -05:00
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 ;
}
2016-01-04 18:36:34 +01:00
static inline void mtk_ddp_comp_layer_config ( struct mtk_ddp_comp * comp ,
unsigned int idx ,
struct mtk_plane_state * state )
{
if ( comp - > funcs & & comp - > funcs - > layer_config )
comp - > funcs - > layer_config ( comp , idx , state ) ;
}
2016-07-28 10:22:54 +08:00
static inline void mtk_ddp_gamma_set ( struct mtk_ddp_comp * comp ,
struct drm_crtc_state * state )
{
if ( comp - > funcs & & comp - > funcs - > gamma_set )
comp - > funcs - > gamma_set ( comp , state ) ;
}
2019-08-29 22:50:42 +08:00
static inline void mtk_ddp_comp_bgclr_in_on ( struct mtk_ddp_comp * comp )
{
if ( comp - > funcs & & comp - > funcs - > bgclr_in_on )
comp - > funcs - > bgclr_in_on ( comp ) ;
}
static inline void mtk_ddp_comp_bgclr_in_off ( struct mtk_ddp_comp * comp )
{
if ( comp - > funcs & & comp - > funcs - > bgclr_in_off )
comp - > funcs - > bgclr_in_off ( comp ) ;
}
2016-01-04 18:36:34 +01:00
int mtk_ddp_comp_get_id ( struct device_node * node ,
enum mtk_ddp_comp_type comp_type ) ;
int mtk_ddp_comp_init ( struct device * dev , struct device_node * comp_node ,
struct mtk_ddp_comp * comp , enum mtk_ddp_comp_id comp_id ,
const struct mtk_ddp_comp_funcs * funcs ) ;
int mtk_ddp_comp_register ( struct drm_device * drm , struct mtk_ddp_comp * comp ) ;
void mtk_ddp_comp_unregister ( struct drm_device * drm , struct mtk_ddp_comp * comp ) ;
2016-07-28 10:22:55 +08:00
void mtk_dither_set ( struct mtk_ddp_comp * comp , unsigned int bpc ,
unsigned int CFG ) ;
2016-01-04 18:36:34 +01:00
# endif /* MTK_DRM_DDP_COMP_H */