gma500: Add the HDMI bits
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / gma500 / psb_intel_drv.h
blob36b554b5c335fe54a9ac0ad993367045b5d365ed
1 /*
2 * Copyright (c) 2009-2011, Intel Corporation.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef __INTEL_DRV_H__
20 #define __INTEL_DRV_H__
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 <linux/gpio.h>
29 * Display related stuff
32 /* store information about an Ixxx DVO */
33 /* The i830->i865 use multiple DVOs with multiple i2cs */
34 /* the i915, i945 have a single sDVO i2c bus - which is different */
35 #define MAX_OUTPUTS 6
36 /* maximum connectors per crtcs in the mode set */
37 #define INTELFB_CONN_LIMIT 4
39 #define INTEL_I2C_BUS_DVO 1
40 #define INTEL_I2C_BUS_SDVO 2
42 /* these are outputs from the chip - integrated only
43 * external chips are via DVO or SDVO output */
44 #define INTEL_OUTPUT_UNUSED 0
45 #define INTEL_OUTPUT_ANALOG 1
46 #define INTEL_OUTPUT_DVO 2
47 #define INTEL_OUTPUT_SDVO 3
48 #define INTEL_OUTPUT_LVDS 4
49 #define INTEL_OUTPUT_TVOUT 5
50 #define INTEL_OUTPUT_HDMI 6
51 #define INTEL_OUTPUT_MIPI 7
52 #define INTEL_OUTPUT_MIPI2 8
54 #define INTEL_DVO_CHIP_NONE 0
55 #define INTEL_DVO_CHIP_LVDS 1
56 #define INTEL_DVO_CHIP_TMDS 2
57 #define INTEL_DVO_CHIP_TVOUT 4
60 * Hold information useally put on the device driver privates here,
61 * since it needs to be shared across multiple of devices drivers privates.
63 struct psb_intel_mode_device {
66 * Abstracted memory manager operations
68 size_t(*bo_offset) (struct drm_device *dev, void *bo);
71 * Cursor (Can go ?)
73 int cursor_needs_physical;
76 * LVDS info
78 int backlight_duty_cycle; /* restore backlight to this value */
79 bool panel_wants_dither;
80 struct drm_display_mode *panel_fixed_mode;
81 struct drm_display_mode *panel_fixed_mode2;
82 struct drm_display_mode *vbt_mode; /* if any */
84 uint32_t saveBLC_PWM_CTL;
87 struct psb_intel_i2c_chan {
88 /* for getting at dev. private (mmio etc.) */
89 struct drm_device *drm_dev;
90 u32 reg; /* GPIO reg */
91 struct i2c_adapter adapter;
92 struct i2c_algo_bit_data algo;
93 u8 slave_addr;
96 struct psb_intel_output {
97 struct drm_connector base;
99 struct drm_encoder enc;
100 int type;
102 struct psb_intel_i2c_chan *i2c_bus; /* for control functions */
103 struct psb_intel_i2c_chan *ddc_bus; /* for DDC only stuff */
104 bool load_detect_temp;
105 void *dev_priv;
107 struct psb_intel_mode_device *mode_dev;
108 struct i2c_adapter *hdmi_i2c_adapter; /* for control functions */
111 struct psb_intel_crtc_state {
112 uint32_t saveDSPCNTR;
113 uint32_t savePIPECONF;
114 uint32_t savePIPESRC;
115 uint32_t saveDPLL;
116 uint32_t saveFP0;
117 uint32_t saveFP1;
118 uint32_t saveHTOTAL;
119 uint32_t saveHBLANK;
120 uint32_t saveHSYNC;
121 uint32_t saveVTOTAL;
122 uint32_t saveVBLANK;
123 uint32_t saveVSYNC;
124 uint32_t saveDSPSTRIDE;
125 uint32_t saveDSPSIZE;
126 uint32_t saveDSPPOS;
127 uint32_t saveDSPBASE;
128 uint32_t savePalette[256];
131 struct psb_intel_crtc {
132 struct drm_crtc base;
133 int pipe;
134 int plane;
135 uint32_t cursor_addr;
136 u8 lut_r[256], lut_g[256], lut_b[256];
137 u8 lut_adj[256];
138 struct psb_intel_framebuffer *fbdev_fb;
139 /* a mode_set for fbdev users on this crtc */
140 struct drm_mode_set mode_set;
142 /* GEM object that holds our cursor */
143 struct drm_gem_object *cursor_obj;
145 struct drm_display_mode saved_mode;
146 struct drm_display_mode saved_adjusted_mode;
148 struct psb_intel_mode_device *mode_dev;
150 /*crtc mode setting flags*/
151 u32 mode_flags;
153 /* Saved Crtc HW states */
154 struct psb_intel_crtc_state *crtc_state;
157 #define to_psb_intel_crtc(x) \
158 container_of(x, struct psb_intel_crtc, base)
159 #define to_psb_intel_output(x) \
160 container_of(x, struct psb_intel_output, base)
161 #define enc_to_psb_intel_output(x) \
162 container_of(x, struct psb_intel_output, enc)
163 #define to_psb_intel_framebuffer(x) \
164 container_of(x, struct psb_intel_framebuffer, base)
166 struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev,
167 const u32 reg, const char *name);
168 void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan);
169 int psb_intel_ddc_get_modes(struct psb_intel_output *psb_intel_output);
170 extern bool psb_intel_ddc_probe(struct psb_intel_output *psb_intel_output);
172 extern void psb_intel_crtc_init(struct drm_device *dev, int pipe,
173 struct psb_intel_mode_device *mode_dev);
174 extern void psb_intel_crt_init(struct drm_device *dev);
175 extern void psb_intel_sdvo_init(struct drm_device *dev, int output_device);
176 extern void psb_intel_dvo_init(struct drm_device *dev);
177 extern void psb_intel_tv_init(struct drm_device *dev);
178 extern void psb_intel_lvds_init(struct drm_device *dev,
179 struct psb_intel_mode_device *mode_dev);
180 extern void psb_intel_lvds_set_brightness(struct drm_device *dev, int level);
181 extern void mrst_lvds_init(struct drm_device *dev,
182 struct psb_intel_mode_device *mode_dev);
183 extern void mrst_wait_for_INTR_PKT_SENT(struct drm_device *dev);
184 extern void mrst_dsi_init(struct drm_device *dev,
185 struct psb_intel_mode_device *mode_dev);
186 extern void mid_dsi_init(struct drm_device *dev,
187 struct psb_intel_mode_device *mode_dev, int dsi_num);
189 extern void psb_intel_crtc_load_lut(struct drm_crtc *crtc);
190 extern void psb_intel_encoder_prepare(struct drm_encoder *encoder);
191 extern void psb_intel_encoder_commit(struct drm_encoder *encoder);
193 extern struct drm_encoder *psb_intel_best_encoder(struct drm_connector
194 *connector);
196 extern struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
197 struct drm_crtc *crtc);
198 extern void psb_intel_wait_for_vblank(struct drm_device *dev);
199 extern int psb_intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
200 struct drm_file *file_priv);
201 extern struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev,
202 int pipe);
203 extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev,
204 int sdvoB);
205 extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector);
206 extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
207 int enable);
208 extern int intelfb_probe(struct drm_device *dev);
209 extern int intelfb_remove(struct drm_device *dev,
210 struct drm_framebuffer *fb);
211 extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
212 *dev, struct
213 drm_mode_fb_cmd
214 *mode_cmd,
215 void *mm_private);
216 extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
217 struct drm_display_mode *mode,
218 struct drm_display_mode *adjusted_mode);
219 extern int psb_intel_lvds_mode_valid(struct drm_connector *connector,
220 struct drm_display_mode *mode);
221 extern int psb_intel_lvds_set_property(struct drm_connector *connector,
222 struct drm_property *property,
223 uint64_t value);
224 extern void psb_intel_lvds_destroy(struct drm_connector *connector);
225 extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs;
227 extern void mdfldWaitForPipeDisable(struct drm_device *dev, int pipe);
228 extern void mdfldWaitForPipeEnable(struct drm_device *dev, int pipe);
230 #endif /* __INTEL_DRV_H__ */