2 * Copyright (c) 2009, 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
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>
31 #define DELAY_TIME1 2000 /* 1000 = 1ms */
34 * Display related stuff
37 /* store information about an Ixxx DVO */
38 /* The i830->i865 use multiple DVOs with multiple i2cs */
39 /* the i915, i945 have a single sDVO i2c bus - which is different */
41 /* maximum connectors per crtcs in the mode set */
42 #define INTELFB_CONN_LIMIT 4
44 #define INTEL_I2C_BUS_DVO 1
45 #define INTEL_I2C_BUS_SDVO 2
47 /* these are outputs from the chip - integrated only
48 * external chips are via DVO or SDVO output */
49 #define INTEL_OUTPUT_UNUSED 0
50 #define INTEL_OUTPUT_ANALOG 1
51 #define INTEL_OUTPUT_DVO 2
52 #define INTEL_OUTPUT_SDVO 3
53 #define INTEL_OUTPUT_LVDS 4
54 #define INTEL_OUTPUT_TVOUT 5
55 #define INTEL_OUTPUT_HDMI 6
56 #define INTEL_OUTPUT_MIPI 7
57 #define INTEL_OUTPUT_MIPI2 8
59 #define INTEL_DVO_CHIP_NONE 0
60 #define INTEL_DVO_CHIP_LVDS 1
61 #define INTEL_DVO_CHIP_TMDS 2
62 #define INTEL_DVO_CHIP_TVOUT 4
64 enum mipi_panel_type
{
71 * Hold information useally put on the device driver privates here,
72 * since it needs to be shared across multiple of devices drivers privates.
74 struct psb_intel_mode_device
{
77 * Abstracted memory manager operations
79 size_t(*bo_offset
) (struct drm_device
*dev
, void *bo
);
84 int cursor_needs_physical
;
89 int backlight_duty_cycle
; /* restore backlight to this value */
90 bool panel_wants_dither
;
91 struct drm_display_mode
*panel_fixed_mode
;
92 struct drm_display_mode
*panel_fixed_mode2
;
93 struct drm_display_mode
*vbt_mode
; /* if any */
95 uint32_t saveBLC_PWM_CTL
;
98 struct psb_intel_i2c_chan
{
99 /* for getting at dev. private (mmio etc.) */
100 struct drm_device
*drm_dev
;
101 u32 reg
; /* GPIO reg */
102 struct i2c_adapter adapter
;
103 struct i2c_algo_bit_data algo
;
107 struct psb_intel_output
{
108 struct drm_connector base
;
110 struct drm_encoder enc
;
113 struct psb_intel_i2c_chan
*i2c_bus
; /* for control functions */
114 struct psb_intel_i2c_chan
*ddc_bus
; /* for DDC only stuff */
115 bool load_detect_temp
;
118 struct psb_intel_mode_device
*mode_dev
;
122 struct psb_intel_crtc_state
{
123 uint32_t saveDSPCNTR
;
124 uint32_t savePIPECONF
;
125 uint32_t savePIPESRC
;
135 uint32_t saveDSPSTRIDE
;
136 uint32_t saveDSPSIZE
;
138 uint32_t saveDSPBASE
;
139 uint32_t savePalette
[256];
142 struct psb_intel_crtc
{
143 struct drm_crtc base
;
146 uint32_t cursor_addr
;
147 u8 lut_r
[256], lut_g
[256], lut_b
[256];
149 struct psb_intel_framebuffer
*fbdev_fb
;
150 /* a mode_set for fbdev users on this crtc */
151 struct drm_mode_set mode_set
;
153 /* GEM object that holds our cursor */
154 struct drm_gem_object
*cursor_obj
;
156 struct drm_display_mode saved_mode
;
157 struct drm_display_mode saved_adjusted_mode
;
159 struct psb_intel_mode_device
*mode_dev
;
161 /*crtc mode setting flags*/
164 /* Saved Crtc HW states */
165 struct psb_intel_crtc_state
*crtc_state
;
168 #define to_psb_intel_crtc(x) \
169 container_of(x, struct psb_intel_crtc, base)
170 #define to_psb_intel_output(x) \
171 container_of(x, struct psb_intel_output, base)
172 #define enc_to_psb_intel_output(x) \
173 container_of(x, struct psb_intel_output, enc)
174 #define to_psb_intel_framebuffer(x) \
175 container_of(x, struct psb_intel_framebuffer, base)
177 struct psb_intel_i2c_chan
*psb_intel_i2c_create(struct drm_device
*dev
,
178 const u32 reg
, const char *name
);
179 void psb_intel_i2c_destroy(struct psb_intel_i2c_chan
*chan
);
180 int psb_intel_ddc_get_modes(struct psb_intel_output
*psb_intel_output
);
181 extern bool psb_intel_ddc_probe(struct psb_intel_output
*psb_intel_output
);
183 extern void psb_intel_crtc_init(struct drm_device
*dev
, int pipe
,
184 struct psb_intel_mode_device
*mode_dev
);
185 extern void psb_intel_crt_init(struct drm_device
*dev
);
186 extern void psb_intel_sdvo_init(struct drm_device
*dev
, int output_device
);
187 extern void psb_intel_dvo_init(struct drm_device
*dev
);
188 extern void psb_intel_tv_init(struct drm_device
*dev
);
189 extern void psb_intel_lvds_init(struct drm_device
*dev
,
190 struct psb_intel_mode_device
*mode_dev
);
191 extern void psb_intel_lvds_set_brightness(struct drm_device
*dev
, int level
);
192 extern void mrst_lvds_init(struct drm_device
*dev
,
193 struct psb_intel_mode_device
*mode_dev
);
194 extern void mrst_wait_for_INTR_PKT_SENT(struct drm_device
*dev
);
195 extern void mrst_dsi_init(struct drm_device
*dev
,
196 struct psb_intel_mode_device
*mode_dev
);
197 extern void mid_dsi_init(struct drm_device
*dev
,
198 struct psb_intel_mode_device
*mode_dev
, int dsi_num
);
200 extern void psb_intel_crtc_load_lut(struct drm_crtc
*crtc
);
201 extern void psb_intel_encoder_prepare(struct drm_encoder
*encoder
);
202 extern void psb_intel_encoder_commit(struct drm_encoder
*encoder
);
204 extern struct drm_encoder
*psb_intel_best_encoder(struct drm_connector
207 extern struct drm_display_mode
*psb_intel_crtc_mode_get(struct drm_device
*dev
,
208 struct drm_crtc
*crtc
);
209 extern void psb_intel_wait_for_vblank(struct drm_device
*dev
);
210 extern int psb_intel_get_pipe_from_crtc_id(struct drm_device
*dev
, void *data
,
211 struct drm_file
*file_priv
);
212 extern struct drm_crtc
*psb_intel_get_crtc_from_pipe(struct drm_device
*dev
,
214 extern struct drm_connector
*psb_intel_sdvo_find(struct drm_device
*dev
,
216 extern int psb_intel_sdvo_supports_hotplug(struct drm_connector
*connector
);
217 extern void psb_intel_sdvo_set_hotplug(struct drm_connector
*connector
,
219 extern int intelfb_probe(struct drm_device
*dev
);
220 extern int intelfb_remove(struct drm_device
*dev
,
221 struct drm_framebuffer
*fb
);
222 extern struct drm_framebuffer
*psb_intel_framebuffer_create(struct drm_device
227 extern bool psb_intel_lvds_mode_fixup(struct drm_encoder
*encoder
,
228 struct drm_display_mode
*mode
,
229 struct drm_display_mode
*adjusted_mode
);
230 extern int psb_intel_lvds_mode_valid(struct drm_connector
*connector
,
231 struct drm_display_mode
*mode
);
232 extern int psb_intel_lvds_set_property(struct drm_connector
*connector
,
233 struct drm_property
*property
,
235 extern void psb_intel_lvds_destroy(struct drm_connector
*connector
);
236 extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs
;
238 #endif /* __INTEL_DRV_H__ */