19c92ab61SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 22048e328SMark Yao /* 32048e328SMark Yao * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd 42048e328SMark Yao * Author:Mark Yao <mark.yao@rock-chips.com> 52048e328SMark Yao * 62048e328SMark Yao * based on exynos_drm_drv.h 72048e328SMark Yao */ 82048e328SMark Yao 92048e328SMark Yao #ifndef _ROCKCHIP_DRM_DRV_H 102048e328SMark Yao #define _ROCKCHIP_DRM_DRV_H 112048e328SMark Yao 1263ebb9faSMark Yao #include <drm/drm_atomic_helper.h> 132048e328SMark Yao #include <drm/drm_gem.h> 142048e328SMark Yao 15*ab03974dSCristian Ciocaltea #include <linux/bits.h> 16*ab03974dSCristian Ciocaltea #include <linux/component.h> 1745b64fd9SThomas Zimmermann #include <linux/i2c.h> 182048e328SMark Yao #include <linux/module.h> 192048e328SMark Yao 202048e328SMark Yao #define ROCKCHIP_MAX_FB_BUFFER 3 212048e328SMark Yao #define ROCKCHIP_MAX_CONNECTOR 2 22604be855SAndy Yan #define ROCKCHIP_MAX_CRTC 4 232048e328SMark Yao 248c854654SAndy Yan /* 258c854654SAndy Yan * display output interface supported by rockchip lcdc 268c854654SAndy Yan */ 278c854654SAndy Yan #define ROCKCHIP_OUT_MODE_P888 0 288c854654SAndy Yan #define ROCKCHIP_OUT_MODE_BT1120 0 298c854654SAndy Yan #define ROCKCHIP_OUT_MODE_P666 1 308c854654SAndy Yan #define ROCKCHIP_OUT_MODE_P565 2 318c854654SAndy Yan #define ROCKCHIP_OUT_MODE_BT656 5 328c854654SAndy Yan #define ROCKCHIP_OUT_MODE_S888 8 338c854654SAndy Yan #define ROCKCHIP_OUT_MODE_S888_DUMMY 12 348c854654SAndy Yan #define ROCKCHIP_OUT_MODE_YUV420 14 358c854654SAndy Yan /* for use special outface */ 368c854654SAndy Yan #define ROCKCHIP_OUT_MODE_AAAA 15 378c854654SAndy Yan 388c854654SAndy Yan /* output flags */ 398c854654SAndy Yan #define ROCKCHIP_OUTPUT_DSI_DUAL BIT(0) 408c854654SAndy Yan 412048e328SMark Yao struct drm_device; 422048e328SMark Yao struct drm_connector; 4338f993b7STomasz Figa struct iommu_domain; 442048e328SMark Yao 454e257d9eSMark Yao struct rockchip_crtc_state { 464e257d9eSMark Yao struct drm_crtc_state base; 474e257d9eSMark Yao int output_type; 484e257d9eSMark Yao int output_mode; 496bda8112SMark Yao int output_bpc; 50cf6d100dSHeiko Stuebner int output_flags; 517707f722SAndrzej Pietrasiewicz bool enable_afbc; 52dd49ee46SAndy Yan bool yuv_overlay; 53604be855SAndy Yan u32 bus_format; 54604be855SAndy Yan u32 bus_flags; 55604be855SAndy Yan int color_space; 564e257d9eSMark Yao }; 574e257d9eSMark Yao #define to_rockchip_crtc_state(s) \ 584e257d9eSMark Yao container_of(s, struct rockchip_crtc_state, base) 594e257d9eSMark Yao 602048e328SMark Yao /* 612048e328SMark Yao * Rockchip drm private structure. 622048e328SMark Yao * 632048e328SMark Yao * @crtc: array of enabled CRTCs, used to map from "pipe" to drm_crtc. 642048e328SMark Yao * @num_pipe: number of pipes for this device. 652d7b5637SCaesar Wang * @mm_lock: protect drm_mm on multi-threads. 662048e328SMark Yao */ 672048e328SMark Yao struct rockchip_drm_private { 6838f993b7STomasz Figa struct iommu_domain *domain; 69421be3eeSRobin Murphy struct device *iommu_dev; 7038f993b7STomasz Figa struct mutex mm_lock; 7138f993b7STomasz Figa struct drm_mm mm; 722048e328SMark Yao }; 732048e328SMark Yao 74540b8f27SSascha Hauer struct rockchip_encoder { 75cf544c6aSSascha Hauer int crtc_endpoint_id; 76540b8f27SSascha Hauer struct drm_encoder encoder; 77540b8f27SSascha Hauer }; 78540b8f27SSascha Hauer 792048e328SMark Yao int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, 802048e328SMark Yao struct device *dev); 812048e328SMark Yao void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, 822048e328SMark Yao struct device *dev); 83421be3eeSRobin Murphy void rockchip_drm_dma_init_device(struct drm_device *drm_dev, 84421be3eeSRobin Murphy struct device *dev); 85459b086dSJeffy Chen int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout); 86cf544c6aSSascha Hauer int rockchip_drm_encoder_set_crtc_endpoint_id(struct rockchip_encoder *rencoder, 87cf544c6aSSascha Hauer struct device_node *np, int port, int reg); 883880f62eSHeiko Stuebner int rockchip_drm_endpoint_is_subdriver(struct device_node *ep); 898820b68bSJeffy Chen extern struct platform_driver cdn_dp_driver; 908820b68bSJeffy Chen extern struct platform_driver dw_hdmi_rockchip_pltfm_driver; 912d4f7bdaSNickey Yang extern struct platform_driver dw_mipi_dsi_rockchip_driver; 928820b68bSJeffy Chen extern struct platform_driver inno_hdmi_driver; 938820b68bSJeffy Chen extern struct platform_driver rockchip_dp_driver; 9434cc0aa2SSandy Huang extern struct platform_driver rockchip_lvds_driver; 958820b68bSJeffy Chen extern struct platform_driver vop_platform_driver; 96f84d3d37SZheng Yang extern struct platform_driver rk3066_hdmi_driver; 97604be855SAndy Yan extern struct platform_driver vop2_platform_driver; 98540b8f27SSascha Hauer 99540b8f27SSascha Hauer static inline struct rockchip_encoder *to_rockchip_encoder(struct drm_encoder *encoder) 100540b8f27SSascha Hauer { 101540b8f27SSascha Hauer return container_of(encoder, struct rockchip_encoder, encoder); 102540b8f27SSascha Hauer } 103540b8f27SSascha Hauer 1042048e328SMark Yao #endif /* _ROCKCHIP_DRM_DRV_H_ */ 105