Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / gma500 / psb_intel_drv.h
blob5340225d6997b9d0cf3a359075b869f2a76c5b57
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2009-2011, Intel Corporation.
4 */
6 #ifndef __INTEL_DRV_H__
7 #define __INTEL_DRV_H__
9 #include <linux/i2c.h>
10 #include <linux/i2c-algo-bit.h>
11 #include <drm/drm_crtc.h>
12 #include <drm/drm_crtc_helper.h>
13 #include <drm/drm_encoder.h>
14 #include <drm/drm_probe_helper.h>
15 #include <drm/drm_vblank.h>
16 #include "gma_display.h"
19 * Display related stuff
22 /* maximum connectors per crtcs in the mode set */
23 #define INTELFB_CONN_LIMIT 4
25 /* Intel Pipe Clone Bit */
26 #define INTEL_HDMIB_CLONE_BIT 1
27 #define INTEL_HDMIC_CLONE_BIT 2
28 #define INTEL_HDMID_CLONE_BIT 3
29 #define INTEL_HDMIE_CLONE_BIT 4
30 #define INTEL_HDMIF_CLONE_BIT 5
31 #define INTEL_SDVO_NON_TV_CLONE_BIT 6
32 #define INTEL_SDVO_TV_CLONE_BIT 7
33 #define INTEL_SDVO_LVDS_CLONE_BIT 8
34 #define INTEL_ANALOG_CLONE_BIT 9
35 #define INTEL_TV_CLONE_BIT 10
36 #define INTEL_DP_B_CLONE_BIT 11
37 #define INTEL_DP_C_CLONE_BIT 12
38 #define INTEL_DP_D_CLONE_BIT 13
39 #define INTEL_LVDS_CLONE_BIT 14
40 #define INTEL_DVO_TMDS_CLONE_BIT 15
41 #define INTEL_DVO_LVDS_CLONE_BIT 16
42 #define INTEL_EDP_CLONE_BIT 17
44 /* these are outputs from the chip - integrated only
45 * external chips are via DVO or SDVO output */
46 #define INTEL_OUTPUT_UNUSED 0
47 #define INTEL_OUTPUT_ANALOG 1
48 #define INTEL_OUTPUT_DVO 2
49 #define INTEL_OUTPUT_SDVO 3
50 #define INTEL_OUTPUT_LVDS 4
51 #define INTEL_OUTPUT_TVOUT 5
52 #define INTEL_OUTPUT_HDMI 6
53 #define INTEL_OUTPUT_MIPI 7
54 #define INTEL_OUTPUT_MIPI2 8
55 #define INTEL_OUTPUT_DISPLAYPORT 9
56 #define INTEL_OUTPUT_EDP 10
59 * Hold information useally put on the device driver privates here,
60 * since it needs to be shared across multiple of devices drivers privates.
62 struct psb_intel_mode_device {
65 * Abstracted memory manager operations
67 size_t(*bo_offset) (struct drm_device *dev, void *bo);
70 * LVDS info
72 int backlight_duty_cycle; /* restore backlight to this value */
73 bool panel_wants_dither;
74 struct drm_display_mode *panel_fixed_mode;
75 struct drm_display_mode *panel_fixed_mode2;
76 struct drm_display_mode *vbt_mode; /* if any */
78 uint32_t saveBLC_PWM_CTL;
81 struct psb_intel_i2c_chan {
82 /* for getting at dev. private (mmio etc.) */
83 struct drm_device *drm_dev;
84 u32 reg; /* GPIO reg */
85 struct i2c_adapter adapter;
86 struct i2c_algo_bit_data algo;
87 u8 slave_addr;
90 struct gma_encoder {
91 struct drm_encoder base;
92 int type;
93 bool needs_tv_clock;
94 void (*hot_plug)(struct gma_encoder *);
95 int crtc_mask;
96 int clone_mask;
97 u32 ddi_select; /* Channel info */
98 #define DDI0_SELECT 0x01
99 #define DDI1_SELECT 0x02
100 #define DP_MASK 0x8000
101 #define DDI_MASK 0x03
102 void *dev_priv; /* For sdvo_priv, lvds_priv, etc... */
104 /* FIXME: Either make SDVO and LVDS store it's i2c here or give CDV it's
105 own set of output privates */
106 struct psb_intel_i2c_chan *i2c_bus;
107 struct psb_intel_i2c_chan *ddc_bus;
110 struct gma_connector {
111 struct drm_connector base;
112 struct gma_encoder *encoder;
114 void (*save)(struct drm_connector *connector);
115 void (*restore)(struct drm_connector *connector);
118 struct psb_intel_crtc_state {
119 uint32_t saveDSPCNTR;
120 uint32_t savePIPECONF;
121 uint32_t savePIPESRC;
122 uint32_t saveDPLL;
123 uint32_t saveFP0;
124 uint32_t saveFP1;
125 uint32_t saveHTOTAL;
126 uint32_t saveHBLANK;
127 uint32_t saveHSYNC;
128 uint32_t saveVTOTAL;
129 uint32_t saveVBLANK;
130 uint32_t saveVSYNC;
131 uint32_t saveDSPSTRIDE;
132 uint32_t saveDSPSIZE;
133 uint32_t saveDSPPOS;
134 uint32_t saveDSPBASE;
135 uint32_t savePalette[256];
138 struct gma_crtc {
139 struct drm_crtc base;
140 int pipe;
141 int plane;
142 uint32_t cursor_addr;
143 struct gtt_range *cursor_gt;
144 u8 lut_adj[256];
145 struct psb_intel_framebuffer *fbdev_fb;
146 /* a mode_set for fbdev users on this crtc */
147 struct drm_mode_set mode_set;
149 /* GEM object that holds our cursor */
150 struct drm_gem_object *cursor_obj;
152 struct drm_display_mode saved_mode;
153 struct drm_display_mode saved_adjusted_mode;
155 struct psb_intel_mode_device *mode_dev;
157 /*crtc mode setting flags*/
158 u32 mode_flags;
160 bool active;
162 /* Saved Crtc HW states */
163 struct psb_intel_crtc_state *crtc_state;
165 const struct gma_clock_funcs *clock_funcs;
167 struct drm_pending_vblank_event *page_flip_event;
170 #define to_gma_crtc(x) \
171 container_of(x, struct gma_crtc, base)
172 #define to_gma_connector(x) \
173 container_of(x, struct gma_connector, base)
174 #define to_gma_encoder(x) \
175 container_of(x, struct gma_encoder, base)
176 #define to_psb_intel_framebuffer(x) \
177 container_of(x, struct psb_intel_framebuffer, base)
179 struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev,
180 const u32 reg, const char *name);
181 void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan);
182 int psb_intel_ddc_get_modes(struct drm_connector *connector,
183 struct i2c_adapter *adapter);
184 extern bool psb_intel_ddc_probe(struct i2c_adapter *adapter);
186 extern void psb_intel_crtc_init(struct drm_device *dev, int pipe,
187 struct psb_intel_mode_device *mode_dev);
188 extern void psb_intel_crt_init(struct drm_device *dev);
189 extern bool psb_intel_sdvo_init(struct drm_device *dev, int output_device);
190 extern void psb_intel_dvo_init(struct drm_device *dev);
191 extern void psb_intel_tv_init(struct drm_device *dev);
192 extern void psb_intel_lvds_init(struct drm_device *dev,
193 struct psb_intel_mode_device *mode_dev);
194 extern void psb_intel_lvds_set_brightness(struct drm_device *dev, int level);
195 extern void oaktrail_lvds_init(struct drm_device *dev,
196 struct psb_intel_mode_device *mode_dev);
197 extern void oaktrail_wait_for_INTR_PKT_SENT(struct drm_device *dev);
198 extern void oaktrail_dsi_init(struct drm_device *dev,
199 struct psb_intel_mode_device *mode_dev);
200 extern void oaktrail_lvds_i2c_init(struct drm_encoder *encoder);
201 extern void mid_dsi_init(struct drm_device *dev,
202 struct psb_intel_mode_device *mode_dev, int dsi_num);
204 extern struct drm_encoder *gma_best_encoder(struct drm_connector *connector);
205 extern void gma_connector_attach_encoder(struct gma_connector *connector,
206 struct gma_encoder *encoder);
208 static inline struct gma_encoder *gma_attached_encoder(
209 struct drm_connector *connector)
211 return to_gma_connector(connector)->encoder;
214 extern struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
215 struct drm_crtc *crtc);
216 extern struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev,
217 int pipe);
218 extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev,
219 int sdvoB);
220 extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector);
221 extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
222 int enable);
223 extern int intelfb_probe(struct drm_device *dev);
224 extern int intelfb_remove(struct drm_device *dev,
225 struct drm_framebuffer *fb);
226 extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
227 const struct drm_display_mode *mode,
228 struct drm_display_mode *adjusted_mode);
229 extern enum drm_mode_status psb_intel_lvds_mode_valid(struct drm_connector *connector,
230 struct drm_display_mode *mode);
231 extern int psb_intel_lvds_set_property(struct drm_connector *connector,
232 struct drm_property *property,
233 uint64_t value);
234 extern void psb_intel_lvds_destroy(struct drm_connector *connector);
236 /* intel_gmbus.c */
237 extern void gma_intel_i2c_reset(struct drm_device *dev);
238 extern int gma_intel_setup_gmbus(struct drm_device *dev);
239 extern void gma_intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
240 extern void gma_intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
241 extern void gma_intel_teardown_gmbus(struct drm_device *dev);
243 /* DP support */
244 extern void cdv_intel_dp_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev, int output_reg);
245 extern void cdv_intel_dp_set_m_n(struct drm_crtc *crtc,
246 struct drm_display_mode *mode,
247 struct drm_display_mode *adjusted_mode);
249 extern void psb_intel_attach_force_audio_property(struct drm_connector *connector);
250 extern void psb_intel_attach_broadcast_rgb_property(struct drm_connector *connector);
252 extern int cdv_sb_read(struct drm_device *dev, u32 reg, u32 *val);
253 extern int cdv_sb_write(struct drm_device *dev, u32 reg, u32 val);
254 extern void cdv_sb_reset(struct drm_device *dev);
256 extern void cdv_intel_attach_force_audio_property(struct drm_connector *connector);
257 extern void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector);
259 #endif /* __INTEL_DRV_H__ */