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 void *(*bo_from_handle
) (struct drm_device
*dev
,
80 struct drm_file
*file_priv
,
82 size_t(*bo_size
) (struct drm_device
*dev
, void *bo
);
83 size_t(*bo_offset
) (struct drm_device
*dev
, void *bo
);
84 int (*bo_pin_for_scanout
) (struct drm_device
*dev
, void *bo
);
85 int (*bo_unpin_for_scanout
) (struct drm_device
*dev
, void *bo
);
90 int cursor_needs_physical
;
95 int backlight_duty_cycle
; /* restore backlight to this value */
96 bool panel_wants_dither
;
97 struct drm_display_mode
*panel_fixed_mode
;
98 struct drm_display_mode
*panel_fixed_mode2
;
99 struct drm_display_mode
*vbt_mode
; /* if any */
101 uint32_t saveBLC_PWM_CTL
;
104 struct psb_intel_i2c_chan
{
105 /* for getting at dev. private (mmio etc.) */
106 struct drm_device
*drm_dev
;
107 u32 reg
; /* GPIO reg */
108 struct i2c_adapter adapter
;
109 struct i2c_algo_bit_data algo
;
113 struct psb_intel_output
{
114 struct drm_connector base
;
116 struct drm_encoder enc
;
119 struct psb_intel_i2c_chan
*i2c_bus
; /* for control functions */
120 struct psb_intel_i2c_chan
*ddc_bus
; /* for DDC only stuff */
121 bool load_detect_temp
;
124 struct psb_intel_mode_device
*mode_dev
;
128 struct psb_intel_crtc_state
{
129 uint32_t saveDSPCNTR
;
130 uint32_t savePIPECONF
;
131 uint32_t savePIPESRC
;
141 uint32_t saveDSPSTRIDE
;
142 uint32_t saveDSPSIZE
;
144 uint32_t saveDSPBASE
;
145 uint32_t savePalette
[256];
148 struct psb_intel_crtc
{
149 struct drm_crtc base
;
152 uint32_t cursor_addr
;
153 u8 lut_r
[256], lut_g
[256], lut_b
[256];
155 struct psb_intel_framebuffer
*fbdev_fb
;
156 /* a mode_set for fbdev users on this crtc */
157 struct drm_mode_set mode_set
;
159 /* current bo we scanout from */
162 /* current bo we cursor from */
165 struct drm_display_mode saved_mode
;
166 struct drm_display_mode saved_adjusted_mode
;
168 struct psb_intel_mode_device
*mode_dev
;
170 /*crtc mode setting flags*/
173 /* Saved Crtc HW states */
174 struct psb_intel_crtc_state
*crtc_state
;
177 #define to_psb_intel_crtc(x) \
178 container_of(x, struct psb_intel_crtc, base)
179 #define to_psb_intel_output(x) \
180 container_of(x, struct psb_intel_output, base)
181 #define enc_to_psb_intel_output(x) \
182 container_of(x, struct psb_intel_output, enc)
183 #define to_psb_intel_framebuffer(x) \
184 container_of(x, struct psb_intel_framebuffer, base)
186 struct psb_intel_i2c_chan
*psb_intel_i2c_create(struct drm_device
*dev
,
187 const u32 reg
, const char *name
);
188 void psb_intel_i2c_destroy(struct psb_intel_i2c_chan
*chan
);
189 int psb_intel_ddc_get_modes(struct psb_intel_output
*psb_intel_output
);
190 extern bool psb_intel_ddc_probe(struct psb_intel_output
*psb_intel_output
);
192 extern void psb_intel_crtc_init(struct drm_device
*dev
, int pipe
,
193 struct psb_intel_mode_device
*mode_dev
);
194 extern void psb_intel_crt_init(struct drm_device
*dev
);
195 extern void psb_intel_sdvo_init(struct drm_device
*dev
, int output_device
);
196 extern void psb_intel_dvo_init(struct drm_device
*dev
);
197 extern void psb_intel_tv_init(struct drm_device
*dev
);
198 extern void psb_intel_lvds_init(struct drm_device
*dev
,
199 struct psb_intel_mode_device
*mode_dev
);
200 extern void psb_intel_lvds_set_brightness(struct drm_device
*dev
, int level
);
201 extern void mrst_lvds_init(struct drm_device
*dev
,
202 struct psb_intel_mode_device
*mode_dev
);
203 extern void mrst_wait_for_INTR_PKT_SENT(struct drm_device
*dev
);
204 extern void mrst_dsi_init(struct drm_device
*dev
,
205 struct psb_intel_mode_device
*mode_dev
);
206 extern void mid_dsi_init(struct drm_device
*dev
,
207 struct psb_intel_mode_device
*mode_dev
, int dsi_num
);
209 extern void psb_intel_crtc_load_lut(struct drm_crtc
*crtc
);
210 extern void psb_intel_encoder_prepare(struct drm_encoder
*encoder
);
211 extern void psb_intel_encoder_commit(struct drm_encoder
*encoder
);
213 extern struct drm_encoder
*psb_intel_best_encoder(struct drm_connector
216 extern struct drm_display_mode
*psb_intel_crtc_mode_get(struct drm_device
*dev
,
217 struct drm_crtc
*crtc
);
218 extern void psb_intel_wait_for_vblank(struct drm_device
*dev
);
219 extern int psb_intel_get_pipe_from_crtc_id(struct drm_device
*dev
, void *data
,
220 struct drm_file
*file_priv
);
221 extern struct drm_crtc
*psb_intel_get_crtc_from_pipe(struct drm_device
*dev
,
223 extern struct drm_connector
*psb_intel_sdvo_find(struct drm_device
*dev
,
225 extern int psb_intel_sdvo_supports_hotplug(struct drm_connector
*connector
);
226 extern void psb_intel_sdvo_set_hotplug(struct drm_connector
*connector
,
228 extern int intelfb_probe(struct drm_device
*dev
);
229 extern int intelfb_remove(struct drm_device
*dev
,
230 struct drm_framebuffer
*fb
);
231 extern struct drm_framebuffer
*psb_intel_framebuffer_create(struct drm_device
236 extern bool psb_intel_lvds_mode_fixup(struct drm_encoder
*encoder
,
237 struct drm_display_mode
*mode
,
238 struct drm_display_mode
*adjusted_mode
);
239 extern int psb_intel_lvds_mode_valid(struct drm_connector
*connector
,
240 struct drm_display_mode
*mode
);
241 extern int psb_intel_lvds_set_property(struct drm_connector
*connector
,
242 struct drm_property
*property
,
244 extern void psb_intel_lvds_destroy(struct drm_connector
*connector
);
245 extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs
;
247 #endif /* __INTEL_DRV_H__ */