2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef __MDP5_KMS_H__
19 #define __MDP5_KMS_H__
23 #include "mdp/mdp_kms.h"
24 #include "mdp5_cfg.h" /* must be included before mdp5.xml.h */
32 struct drm_device *dev;
34 struct mdp5_cfg_handler *cfg;
36 /* mapper-id used to request GEM buffer mapped for scanout: */
41 struct mdp5_ctl_manager *ctlm;
43 /* io/register spaces: */
44 void __iomem *mmio, *vbif;
46 struct regulator *vdd;
53 struct clk *vsync_clk;
56 * lock to protect access to global resources: ie., following register:
57 * - REG_MDP5_DISP_INTF_SEL
59 spinlock_t resource_lock;
61 struct mdp_irq error_handler;
64 volatile unsigned long enabled_mask;
65 struct irq_domain *domain;
68 #define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
70 struct mdp5_overlay_info {
71 enum mdp_mixer_stage_id zorder;
74 static inline void mdp5_write(struct mdp5_kms *mdp5_kms, u32 reg, u32 data)
76 msm_writel(data, mdp5_kms->mmio + reg);
79 static inline u32 mdp5_read(struct mdp5_kms *mdp5_kms, u32 reg)
81 return msm_readl(mdp5_kms->mmio + reg);
84 static inline const char *pipe2name(enum mdp5_pipe pipe)
86 static const char *names[] = {
87 #define NAME(n) [SSPP_ ## n] = #n
88 NAME(VIG0), NAME(VIG1), NAME(VIG2),
89 NAME(RGB0), NAME(RGB1), NAME(RGB2),
90 NAME(DMA0), NAME(DMA1),
91 NAME(VIG3), NAME(RGB3),
97 static inline int pipe2nclients(enum mdp5_pipe pipe)
110 static inline uint32_t intf2err(int intf)
113 case 0: return MDP5_IRQ_INTF0_UNDER_RUN;
114 case 1: return MDP5_IRQ_INTF1_UNDER_RUN;
115 case 2: return MDP5_IRQ_INTF2_UNDER_RUN;
116 case 3: return MDP5_IRQ_INTF3_UNDER_RUN;
121 static inline uint32_t intf2vblank(int intf)
124 case 0: return MDP5_IRQ_INTF0_VSYNC;
125 case 1: return MDP5_IRQ_INTF1_VSYNC;
126 case 2: return MDP5_IRQ_INTF2_VSYNC;
127 case 3: return MDP5_IRQ_INTF3_VSYNC;
132 int mdp5_disable(struct mdp5_kms *mdp5_kms);
133 int mdp5_enable(struct mdp5_kms *mdp5_kms);
135 void mdp5_set_irqmask(struct mdp_kms *mdp_kms, uint32_t irqmask);
136 void mdp5_irq_preinstall(struct msm_kms *kms);
137 int mdp5_irq_postinstall(struct msm_kms *kms);
138 void mdp5_irq_uninstall(struct msm_kms *kms);
139 irqreturn_t mdp5_irq(struct msm_kms *kms);
140 int mdp5_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
141 void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
142 int mdp5_irq_domain_init(struct mdp5_kms *mdp5_kms);
143 void mdp5_irq_domain_fini(struct mdp5_kms *mdp5_kms);
146 uint32_t mdp5_get_formats(enum mdp5_pipe pipe, uint32_t *pixel_formats,
147 uint32_t max_formats)
149 /* TODO when we have YUV, we need to filter supported formats
152 return mdp_get_formats(pixel_formats, max_formats);
155 void mdp5_plane_install_properties(struct drm_plane *plane,
156 struct drm_mode_object *obj);
157 void mdp5_plane_set_overlay_info(struct drm_plane *plane,
158 const struct mdp5_overlay_info *overlay_info);
159 struct mdp5_overlay_info *mdp5_plane_get_overlay_info(struct drm_plane *plane);
160 uint32_t mdp5_plane_get_flush(struct drm_plane *plane);
161 void mdp5_plane_set_scanout(struct drm_plane *plane,
162 struct drm_framebuffer *fb);
163 int mdp5_plane_mode_set(struct drm_plane *plane,
164 struct drm_crtc *crtc, struct drm_framebuffer *fb,
165 int crtc_x, int crtc_y,
166 unsigned int crtc_w, unsigned int crtc_h,
167 uint32_t src_x, uint32_t src_y,
168 uint32_t src_w, uint32_t src_h);
169 void mdp5_plane_complete_flip(struct drm_plane *plane);
170 enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
171 struct drm_plane *mdp5_plane_init(struct drm_device *dev,
172 enum mdp5_pipe pipe, bool private_plane, uint32_t reg_offset);
174 uint32_t mdp5_crtc_vblank(struct drm_crtc *crtc);
176 int mdp5_crtc_get_lm(struct drm_crtc *crtc);
177 void mdp5_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
178 void mdp5_crtc_set_intf(struct drm_crtc *crtc, int intf,
179 enum mdp5_intf intf_id);
180 int mdp5_crtc_attach(struct drm_crtc *crtc, struct drm_plane *plane);
181 void mdp5_crtc_detach(struct drm_crtc *crtc, struct drm_plane *plane);
182 struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
183 struct drm_plane *plane, int id);
185 struct drm_encoder *mdp5_encoder_init(struct drm_device *dev, int intf,
186 enum mdp5_intf intf_id);
188 #endif /* __MDP5_KMS_H__ */