0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _EXYNOS_DRM_DRV_H_
0012 #define _EXYNOS_DRM_DRV_H_
0013
0014 #include <linux/module.h>
0015
0016 #include <drm/drm_crtc.h>
0017 #include <drm/drm_device.h>
0018 #include <drm/drm_plane.h>
0019
0020 #define MAX_CRTC 3
0021 #define MAX_PLANE 5
0022 #define MAX_FB_BUFFER 4
0023
0024 #define DEFAULT_WIN 0
0025
0026 struct drm_crtc_state;
0027 struct drm_display_mode;
0028
0029 #define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc, base)
0030 #define to_exynos_plane(x) container_of(x, struct exynos_drm_plane, base)
0031
0032
0033 enum exynos_drm_output_type {
0034 EXYNOS_DISPLAY_TYPE_NONE,
0035
0036 EXYNOS_DISPLAY_TYPE_LCD,
0037
0038 EXYNOS_DISPLAY_TYPE_HDMI,
0039
0040 EXYNOS_DISPLAY_TYPE_VIDI,
0041 };
0042
0043 struct exynos_drm_rect {
0044 unsigned int x, y;
0045 unsigned int w, h;
0046 };
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 struct exynos_drm_plane_state {
0064 struct drm_plane_state base;
0065 struct exynos_drm_rect crtc;
0066 struct exynos_drm_rect src;
0067 unsigned int h_ratio;
0068 unsigned int v_ratio;
0069 };
0070
0071 static inline struct exynos_drm_plane_state *
0072 to_exynos_plane_state(struct drm_plane_state *state)
0073 {
0074 return container_of(state, struct exynos_drm_plane_state, base);
0075 }
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 struct exynos_drm_plane {
0088 struct drm_plane base;
0089 const struct exynos_drm_plane_config *config;
0090 unsigned int index;
0091 };
0092
0093 #define EXYNOS_DRM_PLANE_CAP_DOUBLE (1 << 0)
0094 #define EXYNOS_DRM_PLANE_CAP_SCALE (1 << 1)
0095 #define EXYNOS_DRM_PLANE_CAP_ZPOS (1 << 2)
0096 #define EXYNOS_DRM_PLANE_CAP_TILE (1 << 3)
0097 #define EXYNOS_DRM_PLANE_CAP_PIX_BLEND (1 << 4)
0098 #define EXYNOS_DRM_PLANE_CAP_WIN_BLEND (1 << 5)
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 struct exynos_drm_plane_config {
0111 unsigned int zpos;
0112 enum drm_plane_type type;
0113 const uint32_t *pixel_formats;
0114 unsigned int num_pixel_formats;
0115 unsigned int capabilities;
0116 };
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 struct exynos_drm_crtc;
0135 struct exynos_drm_crtc_ops {
0136 void (*atomic_enable)(struct exynos_drm_crtc *crtc);
0137 void (*atomic_disable)(struct exynos_drm_crtc *crtc);
0138 int (*enable_vblank)(struct exynos_drm_crtc *crtc);
0139 void (*disable_vblank)(struct exynos_drm_crtc *crtc);
0140 enum drm_mode_status (*mode_valid)(struct exynos_drm_crtc *crtc,
0141 const struct drm_display_mode *mode);
0142 bool (*mode_fixup)(struct exynos_drm_crtc *crtc,
0143 const struct drm_display_mode *mode,
0144 struct drm_display_mode *adjusted_mode);
0145 int (*atomic_check)(struct exynos_drm_crtc *crtc,
0146 struct drm_crtc_state *state);
0147 void (*atomic_begin)(struct exynos_drm_crtc *crtc);
0148 void (*update_plane)(struct exynos_drm_crtc *crtc,
0149 struct exynos_drm_plane *plane);
0150 void (*disable_plane)(struct exynos_drm_crtc *crtc,
0151 struct exynos_drm_plane *plane);
0152 void (*atomic_flush)(struct exynos_drm_crtc *crtc);
0153 void (*te_handler)(struct exynos_drm_crtc *crtc);
0154 };
0155
0156 struct exynos_drm_clk {
0157 void (*enable)(struct exynos_drm_clk *clk, bool enable);
0158 };
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169 struct exynos_drm_crtc {
0170 struct drm_crtc base;
0171 enum exynos_drm_output_type type;
0172 const struct exynos_drm_crtc_ops *ops;
0173 void *ctx;
0174 struct exynos_drm_clk *pipe_clk;
0175 bool i80_mode : 1;
0176 };
0177
0178 static inline void exynos_drm_pipe_clk_enable(struct exynos_drm_crtc *crtc,
0179 bool enable)
0180 {
0181 if (crtc->pipe_clk)
0182 crtc->pipe_clk->enable(crtc->pipe_clk, enable);
0183 }
0184
0185 struct drm_exynos_file_private {
0186
0187 struct list_head inuse_cmdlist;
0188 struct list_head event_list;
0189 struct list_head userptr_list;
0190 };
0191
0192
0193
0194
0195
0196
0197
0198
0199 struct exynos_drm_private {
0200 struct drm_fb_helper *fb_helper;
0201
0202 struct device *g2d_dev;
0203 struct device *dma_dev;
0204 void *mapping;
0205
0206
0207 u32 pending;
0208 spinlock_t lock;
0209 wait_queue_head_t wait;
0210 };
0211
0212 static inline struct device *to_dma_dev(struct drm_device *dev)
0213 {
0214 struct exynos_drm_private *priv = dev->dev_private;
0215
0216 return priv->dma_dev;
0217 }
0218
0219 static inline bool is_drm_iommu_supported(struct drm_device *drm_dev)
0220 {
0221 struct exynos_drm_private *priv = drm_dev->dev_private;
0222
0223 return priv->mapping ? true : false;
0224 }
0225
0226 int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,
0227 void **dma_priv);
0228 void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev,
0229 void **dma_priv);
0230 void exynos_drm_cleanup_dma(struct drm_device *drm);
0231
0232 #ifdef CONFIG_DRM_EXYNOS_DPI
0233 struct drm_encoder *exynos_dpi_probe(struct device *dev);
0234 int exynos_dpi_remove(struct drm_encoder *encoder);
0235 int exynos_dpi_bind(struct drm_device *dev, struct drm_encoder *encoder);
0236 #else
0237 static inline struct drm_encoder *
0238 exynos_dpi_probe(struct device *dev) { return NULL; }
0239 static inline int exynos_dpi_remove(struct drm_encoder *encoder)
0240 {
0241 return 0;
0242 }
0243 static inline int exynos_dpi_bind(struct drm_device *dev,
0244 struct drm_encoder *encoder)
0245 {
0246 return 0;
0247 }
0248 #endif
0249
0250 #ifdef CONFIG_DRM_EXYNOS_FIMC
0251 int exynos_drm_check_fimc_device(struct device *dev);
0252 #else
0253 static inline int exynos_drm_check_fimc_device(struct device *dev)
0254 {
0255 return 0;
0256 }
0257 #endif
0258
0259 int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state,
0260 bool nonblock);
0261
0262
0263 extern struct platform_driver fimd_driver;
0264 extern struct platform_driver exynos5433_decon_driver;
0265 extern struct platform_driver decon_driver;
0266 extern struct platform_driver dp_driver;
0267 extern struct platform_driver dsi_driver;
0268 extern struct platform_driver mixer_driver;
0269 extern struct platform_driver hdmi_driver;
0270 extern struct platform_driver vidi_driver;
0271 extern struct platform_driver g2d_driver;
0272 extern struct platform_driver fimc_driver;
0273 extern struct platform_driver rotator_driver;
0274 extern struct platform_driver scaler_driver;
0275 extern struct platform_driver gsc_driver;
0276 extern struct platform_driver mic_driver;
0277 #endif