]>
Commit | Line | Data |
---|---|---|
0867b421 AC |
1 | /* |
2 | * Copyright (c) 2009, Intel Corporation. | |
3 | * | |
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. | |
7 | * | |
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. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
5352161f | 14 | * this program; if not, write to the Free Software Foundation, Inc., |
0867b421 AC |
15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
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 <linux/gpio.h> | |
27 | ||
28 | /* | |
29 | * MOORESTOWN defines | |
30 | */ | |
31 | #define DELAY_TIME1 2000 /* 1000 = 1ms */ | |
32 | ||
33 | /* | |
34 | * Display related stuff | |
35 | */ | |
36 | ||
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 */ | |
40 | #define MAX_OUTPUTS 6 | |
41 | /* maximum connectors per crtcs in the mode set */ | |
42 | #define INTELFB_CONN_LIMIT 4 | |
43 | ||
44 | #define INTEL_I2C_BUS_DVO 1 | |
45 | #define INTEL_I2C_BUS_SDVO 2 | |
46 | ||
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 | |
58 | ||
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 | |
63 | ||
64 | enum mipi_panel_type { | |
65 | NSC_800X480 = 1, | |
66 | LGE_480X1024 = 2, | |
67 | TPO_864X480 = 3 | |
68 | }; | |
69 | ||
70 | /** | |
71 | * Hold information useally put on the device driver privates here, | |
72 | * since it needs to be shared across multiple of devices drivers privates. | |
73 | */ | |
74 | struct psb_intel_mode_device { | |
75 | ||
76 | /* | |
77 | * Abstracted memory manager operations | |
78 | */ | |
0867b421 | 79 | size_t(*bo_offset) (struct drm_device *dev, void *bo); |
0867b421 AC |
80 | |
81 | /* | |
82 | * Cursor | |
83 | */ | |
84 | int cursor_needs_physical; | |
85 | ||
86 | /* | |
87 | * LVDS info | |
88 | */ | |
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 */ | |
94 | ||
95 | uint32_t saveBLC_PWM_CTL; | |
96 | }; | |
97 | ||
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; | |
104 | u8 slave_addr; | |
105 | }; | |
106 | ||
107 | struct psb_intel_output { | |
108 | struct drm_connector base; | |
109 | ||
110 | struct drm_encoder enc; | |
111 | int type; | |
112 | ||
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; | |
116 | void *dev_priv; | |
117 | ||
118 | struct psb_intel_mode_device *mode_dev; | |
119 | ||
120 | }; | |
121 | ||
122 | struct psb_intel_crtc_state { | |
123 | uint32_t saveDSPCNTR; | |
124 | uint32_t savePIPECONF; | |
125 | uint32_t savePIPESRC; | |
126 | uint32_t saveDPLL; | |
127 | uint32_t saveFP0; | |
128 | uint32_t saveFP1; | |
129 | uint32_t saveHTOTAL; | |
130 | uint32_t saveHBLANK; | |
131 | uint32_t saveHSYNC; | |
132 | uint32_t saveVTOTAL; | |
133 | uint32_t saveVBLANK; | |
134 | uint32_t saveVSYNC; | |
135 | uint32_t saveDSPSTRIDE; | |
136 | uint32_t saveDSPSIZE; | |
137 | uint32_t saveDSPPOS; | |
138 | uint32_t saveDSPBASE; | |
139 | uint32_t savePalette[256]; | |
140 | }; | |
141 | ||
142 | struct psb_intel_crtc { | |
143 | struct drm_crtc base; | |
144 | int pipe; | |
145 | int plane; | |
146 | uint32_t cursor_addr; | |
147 | u8 lut_r[256], lut_g[256], lut_b[256]; | |
148 | u8 lut_adj[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; | |
152 | ||
0dfac1ce AC |
153 | /* GEM object that holds our cursor */ |
154 | struct drm_gem_object *cursor_obj; | |
0867b421 AC |
155 | |
156 | struct drm_display_mode saved_mode; | |
157 | struct drm_display_mode saved_adjusted_mode; | |
158 | ||
159 | struct psb_intel_mode_device *mode_dev; | |
160 | ||
161 | /*crtc mode setting flags*/ | |
162 | u32 mode_flags; | |
163 | ||
164 | /* Saved Crtc HW states */ | |
165 | struct psb_intel_crtc_state *crtc_state; | |
166 | }; | |
167 | ||
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) | |
176 | ||
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); | |
182 | ||
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); | |
199 | ||
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); | |
203 | ||
204 | extern struct drm_encoder *psb_intel_best_encoder(struct drm_connector | |
205 | *connector); | |
206 | ||
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, | |
213 | int pipe); | |
214 | extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev, | |
215 | int sdvoB); | |
216 | extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector); | |
217 | extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector, | |
218 | int enable); | |
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 | |
223 | *dev, struct | |
224 | drm_mode_fb_cmd | |
225 | *mode_cmd, | |
226 | void *mm_private); | |
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, | |
234 | uint64_t value); | |
235 | extern void psb_intel_lvds_destroy(struct drm_connector *connector); | |
236 | extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs; | |
237 | ||
238 | #endif /* __INTEL_DRV_H__ */ |