1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __INTEL_DRV_H__
20#define __INTEL_DRV_H__
21
22#include <linux/i2c.h>
23#include <linux/i2c-algo-bit.h>
24#include <drm/drm_crtc.h>
25#include <drm/drm_crtc_helper.h>
26#include <drm/drm_encoder.h>
27#include <drm/drm_probe_helper.h>
28#include <linux/gpio.h>
29#include "gma_display.h"
30
31
32
33
34
35
36#define INTELFB_CONN_LIMIT 4
37
38
39#define INTEL_HDMIB_CLONE_BIT 1
40#define INTEL_HDMIC_CLONE_BIT 2
41#define INTEL_HDMID_CLONE_BIT 3
42#define INTEL_HDMIE_CLONE_BIT 4
43#define INTEL_HDMIF_CLONE_BIT 5
44#define INTEL_SDVO_NON_TV_CLONE_BIT 6
45#define INTEL_SDVO_TV_CLONE_BIT 7
46#define INTEL_SDVO_LVDS_CLONE_BIT 8
47#define INTEL_ANALOG_CLONE_BIT 9
48#define INTEL_TV_CLONE_BIT 10
49#define INTEL_DP_B_CLONE_BIT 11
50#define INTEL_DP_C_CLONE_BIT 12
51#define INTEL_DP_D_CLONE_BIT 13
52#define INTEL_LVDS_CLONE_BIT 14
53#define INTEL_DVO_TMDS_CLONE_BIT 15
54#define INTEL_DVO_LVDS_CLONE_BIT 16
55#define INTEL_EDP_CLONE_BIT 17
56
57
58
59#define INTEL_OUTPUT_UNUSED 0
60#define INTEL_OUTPUT_ANALOG 1
61#define INTEL_OUTPUT_DVO 2
62#define INTEL_OUTPUT_SDVO 3
63#define INTEL_OUTPUT_LVDS 4
64#define INTEL_OUTPUT_TVOUT 5
65#define INTEL_OUTPUT_HDMI 6
66#define INTEL_OUTPUT_MIPI 7
67#define INTEL_OUTPUT_MIPI2 8
68#define INTEL_OUTPUT_DISPLAYPORT 9
69#define INTEL_OUTPUT_EDP 10
70
71#define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0)
72#define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT)
73
74static inline void
75psb_intel_mode_set_pixel_multiplier(struct drm_display_mode *mode,
76 int multiplier)
77{
78 mode->clock *= multiplier;
79 mode->private_flags |= multiplier;
80}
81
82static inline int
83psb_intel_mode_get_pixel_multiplier(const struct drm_display_mode *mode)
84{
85 return (mode->private_flags & INTEL_MODE_PIXEL_MULTIPLIER_MASK)
86 >> INTEL_MODE_PIXEL_MULTIPLIER_SHIFT;
87}
88
89
90
91
92
93
94struct psb_intel_mode_device {
95
96
97
98
99 size_t(*bo_offset) (struct drm_device *dev, void *bo);
100
101
102
103
104 int backlight_duty_cycle;
105 bool panel_wants_dither;
106 struct drm_display_mode *panel_fixed_mode;
107 struct drm_display_mode *panel_fixed_mode2;
108 struct drm_display_mode *vbt_mode;
109
110 uint32_t saveBLC_PWM_CTL;
111};
112
113struct psb_intel_i2c_chan {
114
115 struct drm_device *drm_dev;
116 u32 reg;
117 struct i2c_adapter adapter;
118 struct i2c_algo_bit_data algo;
119 u8 slave_addr;
120};
121
122struct gma_encoder {
123 struct drm_encoder base;
124 int type;
125 bool needs_tv_clock;
126 void (*hot_plug)(struct gma_encoder *);
127 int crtc_mask;
128 int clone_mask;
129 u32 ddi_select;
130#define DDI0_SELECT 0x01
131#define DDI1_SELECT 0x02
132#define DP_MASK 0x8000
133#define DDI_MASK 0x03
134 void *dev_priv;
135
136
137
138 struct psb_intel_i2c_chan *i2c_bus;
139 struct psb_intel_i2c_chan *ddc_bus;
140};
141
142struct gma_connector {
143 struct drm_connector base;
144 struct gma_encoder *encoder;
145
146 void (*save)(struct drm_connector *connector);
147 void (*restore)(struct drm_connector *connector);
148};
149
150struct psb_intel_crtc_state {
151 uint32_t saveDSPCNTR;
152 uint32_t savePIPECONF;
153 uint32_t savePIPESRC;
154 uint32_t saveDPLL;
155 uint32_t saveFP0;
156 uint32_t saveFP1;
157 uint32_t saveHTOTAL;
158 uint32_t saveHBLANK;
159 uint32_t saveHSYNC;
160 uint32_t saveVTOTAL;
161 uint32_t saveVBLANK;
162 uint32_t saveVSYNC;
163 uint32_t saveDSPSTRIDE;
164 uint32_t saveDSPSIZE;
165 uint32_t saveDSPPOS;
166 uint32_t saveDSPBASE;
167 uint32_t savePalette[256];
168};
169
170struct gma_crtc {
171 struct drm_crtc base;
172 int pipe;
173 int plane;
174 uint32_t cursor_addr;
175 struct gtt_range *cursor_gt;
176 u8 lut_adj[256];
177 struct psb_intel_framebuffer *fbdev_fb;
178
179 struct drm_mode_set mode_set;
180
181
182 struct drm_gem_object *cursor_obj;
183
184 struct drm_display_mode saved_mode;
185 struct drm_display_mode saved_adjusted_mode;
186
187 struct psb_intel_mode_device *mode_dev;
188
189
190 u32 mode_flags;
191
192 bool active;
193
194
195 struct psb_intel_crtc_state *crtc_state;
196
197 const struct gma_clock_funcs *clock_funcs;
198};
199
200#define to_gma_crtc(x) \
201 container_of(x, struct gma_crtc, base)
202#define to_gma_connector(x) \
203 container_of(x, struct gma_connector, base)
204#define to_gma_encoder(x) \
205 container_of(x, struct gma_encoder, base)
206#define to_psb_intel_framebuffer(x) \
207 container_of(x, struct psb_intel_framebuffer, base)
208
209struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev,
210 const u32 reg, const char *name);
211void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan);
212int psb_intel_ddc_get_modes(struct drm_connector *connector,
213 struct i2c_adapter *adapter);
214extern bool psb_intel_ddc_probe(struct i2c_adapter *adapter);
215
216extern void psb_intel_crtc_init(struct drm_device *dev, int pipe,
217 struct psb_intel_mode_device *mode_dev);
218extern void psb_intel_crt_init(struct drm_device *dev);
219extern bool psb_intel_sdvo_init(struct drm_device *dev, int output_device);
220extern void psb_intel_dvo_init(struct drm_device *dev);
221extern void psb_intel_tv_init(struct drm_device *dev);
222extern void psb_intel_lvds_init(struct drm_device *dev,
223 struct psb_intel_mode_device *mode_dev);
224extern void psb_intel_lvds_set_brightness(struct drm_device *dev, int level);
225extern void oaktrail_lvds_init(struct drm_device *dev,
226 struct psb_intel_mode_device *mode_dev);
227extern void oaktrail_wait_for_INTR_PKT_SENT(struct drm_device *dev);
228extern void oaktrail_dsi_init(struct drm_device *dev,
229 struct psb_intel_mode_device *mode_dev);
230extern void oaktrail_lvds_i2c_init(struct drm_encoder *encoder);
231extern void mid_dsi_init(struct drm_device *dev,
232 struct psb_intel_mode_device *mode_dev, int dsi_num);
233
234extern struct drm_encoder *gma_best_encoder(struct drm_connector *connector);
235extern void gma_connector_attach_encoder(struct gma_connector *connector,
236 struct gma_encoder *encoder);
237
238static inline struct gma_encoder *gma_attached_encoder(
239 struct drm_connector *connector)
240{
241 return to_gma_connector(connector)->encoder;
242}
243
244extern struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
245 struct drm_crtc *crtc);
246extern struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev,
247 int pipe);
248extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev,
249 int sdvoB);
250extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector);
251extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
252 int enable);
253extern int intelfb_probe(struct drm_device *dev);
254extern int intelfb_remove(struct drm_device *dev,
255 struct drm_framebuffer *fb);
256extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
257 const struct drm_display_mode *mode,
258 struct drm_display_mode *adjusted_mode);
259extern enum drm_mode_status psb_intel_lvds_mode_valid(struct drm_connector *connector,
260 struct drm_display_mode *mode);
261extern int psb_intel_lvds_set_property(struct drm_connector *connector,
262 struct drm_property *property,
263 uint64_t value);
264extern void psb_intel_lvds_destroy(struct drm_connector *connector);
265extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs;
266
267
268extern void gma_intel_i2c_reset(struct drm_device *dev);
269extern int gma_intel_setup_gmbus(struct drm_device *dev);
270extern void gma_intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
271extern void gma_intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
272extern void gma_intel_teardown_gmbus(struct drm_device *dev);
273
274
275extern void cdv_intel_dp_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev, int output_reg);
276extern void cdv_intel_dp_set_m_n(struct drm_crtc *crtc,
277 struct drm_display_mode *mode,
278 struct drm_display_mode *adjusted_mode);
279
280extern void psb_intel_attach_force_audio_property(struct drm_connector *connector);
281extern void psb_intel_attach_broadcast_rgb_property(struct drm_connector *connector);
282
283extern int cdv_sb_read(struct drm_device *dev, u32 reg, u32 *val);
284extern int cdv_sb_write(struct drm_device *dev, u32 reg, u32 val);
285extern void cdv_sb_reset(struct drm_device *dev);
286
287extern void cdv_intel_attach_force_audio_property(struct drm_connector *connector);
288extern void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector);
289
290#endif
291