1254885Sdumbbell/*
2254885Sdumbbell * Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
3254885Sdumbbell * Copyright (c) 2007-2008 Intel Corporation
4254885Sdumbbell *   Jesse Barnes <jesse.barnes@intel.com>
5254885Sdumbbell *
6254885Sdumbbell * Permission is hereby granted, free of charge, to any person obtaining a
7254885Sdumbbell * copy of this software and associated documentation files (the "Software"),
8254885Sdumbbell * to deal in the Software without restriction, including without limitation
9254885Sdumbbell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10254885Sdumbbell * and/or sell copies of the Software, and to permit persons to whom the
11254885Sdumbbell * Software is furnished to do so, subject to the following conditions:
12254885Sdumbbell *
13254885Sdumbbell * The above copyright notice and this permission notice (including the next
14254885Sdumbbell * paragraph) shall be included in all copies or substantial portions of the
15254885Sdumbbell * Software.
16254885Sdumbbell *
17254885Sdumbbell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18254885Sdumbbell * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19254885Sdumbbell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20254885Sdumbbell * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21254885Sdumbbell * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22254885Sdumbbell * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23254885Sdumbbell * IN THE SOFTWARE.
24254885Sdumbbell *
25254885Sdumbbell * $FreeBSD$
26254885Sdumbbell */
27254885Sdumbbell
28254885Sdumbbell#ifndef DRM_INTEL_DRV_H
29254885Sdumbbell#define	DRM_INTEL_DRV_H
30254885Sdumbbell
31254885Sdumbbell#include <dev/drm2/i915/i915_drm.h>
32254885Sdumbbell#include <dev/drm2/i915/i915_drv.h>
33254885Sdumbbell#include <dev/drm2/drm_crtc.h>
34254885Sdumbbell#include <dev/drm2/drm_crtc_helper.h>
35254885Sdumbbell#include <dev/drm2/drm_fb_helper.h>
36254885Sdumbbell
37254885Sdumbbell#define _intel_wait_for(DEV, COND, MS, W, WMSG)				\
38254885Sdumbbell({									\
39254885Sdumbbell	int end, ret;							\
40254885Sdumbbell									\
41254885Sdumbbell	end = ticks + (MS) * hz / 1000;					\
42254885Sdumbbell	ret = 0;							\
43254885Sdumbbell									\
44254885Sdumbbell	while (!(COND)) {						\
45254885Sdumbbell		if (time_after(ticks, end)) {				\
46254885Sdumbbell			ret = -ETIMEDOUT;				\
47254885Sdumbbell			break;						\
48254885Sdumbbell		}							\
49254885Sdumbbell		if (W)							\
50254885Sdumbbell			pause((WMSG), 1);				\
51254885Sdumbbell		else							\
52254885Sdumbbell			DELAY(1000);					\
53254885Sdumbbell	}								\
54254885Sdumbbell									\
55254885Sdumbbell	ret;								\
56254885Sdumbbell})
57254885Sdumbbell
58254885Sdumbbell#define KHz(x) (1000*x)
59254885Sdumbbell#define MHz(x) KHz(1000*x)
60254885Sdumbbell
61254885Sdumbbell/* store information about an Ixxx DVO */
62254885Sdumbbell/* The i830->i865 use multiple DVOs with multiple i2cs */
63254885Sdumbbell/* the i915, i945 have a single sDVO i2c bus - which is different */
64254885Sdumbbell#define MAX_OUTPUTS 6
65254885Sdumbbell/* maximum connectors per crtcs in the mode set */
66254885Sdumbbell#define INTELFB_CONN_LIMIT 4
67254885Sdumbbell
68254885Sdumbbell#define INTEL_I2C_BUS_DVO 1
69254885Sdumbbell#define INTEL_I2C_BUS_SDVO 2
70254885Sdumbbell
71254885Sdumbbell/* these are outputs from the chip - integrated only
72254885Sdumbbell   external chips are via DVO or SDVO output */
73254885Sdumbbell#define INTEL_OUTPUT_UNUSED 0
74254885Sdumbbell#define INTEL_OUTPUT_ANALOG 1
75254885Sdumbbell#define INTEL_OUTPUT_DVO 2
76254885Sdumbbell#define INTEL_OUTPUT_SDVO 3
77254885Sdumbbell#define INTEL_OUTPUT_LVDS 4
78254885Sdumbbell#define INTEL_OUTPUT_TVOUT 5
79254885Sdumbbell#define INTEL_OUTPUT_HDMI 6
80254885Sdumbbell#define INTEL_OUTPUT_DISPLAYPORT 7
81254885Sdumbbell#define INTEL_OUTPUT_EDP 8
82254885Sdumbbell
83254885Sdumbbell/* Intel Pipe Clone Bit */
84254885Sdumbbell#define INTEL_HDMIB_CLONE_BIT 1
85254885Sdumbbell#define INTEL_HDMIC_CLONE_BIT 2
86254885Sdumbbell#define INTEL_HDMID_CLONE_BIT 3
87254885Sdumbbell#define INTEL_HDMIE_CLONE_BIT 4
88254885Sdumbbell#define INTEL_HDMIF_CLONE_BIT 5
89254885Sdumbbell#define INTEL_SDVO_NON_TV_CLONE_BIT 6
90254885Sdumbbell#define INTEL_SDVO_TV_CLONE_BIT 7
91254885Sdumbbell#define INTEL_SDVO_LVDS_CLONE_BIT 8
92254885Sdumbbell#define INTEL_ANALOG_CLONE_BIT 9
93254885Sdumbbell#define INTEL_TV_CLONE_BIT 10
94254885Sdumbbell#define INTEL_DP_B_CLONE_BIT 11
95254885Sdumbbell#define INTEL_DP_C_CLONE_BIT 12
96254885Sdumbbell#define INTEL_DP_D_CLONE_BIT 13
97254885Sdumbbell#define INTEL_LVDS_CLONE_BIT 14
98254885Sdumbbell#define INTEL_DVO_TMDS_CLONE_BIT 15
99254885Sdumbbell#define INTEL_DVO_LVDS_CLONE_BIT 16
100254885Sdumbbell#define INTEL_EDP_CLONE_BIT 17
101254885Sdumbbell
102254885Sdumbbell#define INTEL_DVO_CHIP_NONE 0
103254885Sdumbbell#define INTEL_DVO_CHIP_LVDS 1
104254885Sdumbbell#define INTEL_DVO_CHIP_TMDS 2
105254885Sdumbbell#define INTEL_DVO_CHIP_TVOUT 4
106254885Sdumbbell
107254885Sdumbbell/* drm_display_mode->private_flags */
108254885Sdumbbell#define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0)
109254885Sdumbbell#define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT)
110254885Sdumbbell#define INTEL_MODE_DP_FORCE_6BPC (0x10)
111254885Sdumbbell/* This flag must be set by the encoder's mode_fixup if it changes the crtc
112254885Sdumbbell * timings in the mode to prevent the crtc fixup from overwriting them.
113254885Sdumbbell * Currently only lvds needs that. */
114254885Sdumbbell#define INTEL_MODE_CRTC_TIMINGS_SET (0x20)
115254885Sdumbbell
116254885Sdumbbellstatic inline void
117254885Sdumbbellintel_mode_set_pixel_multiplier(struct drm_display_mode *mode,
118254885Sdumbbell				int multiplier)
119254885Sdumbbell{
120254885Sdumbbell	mode->clock *= multiplier;
121254885Sdumbbell	mode->private_flags |= multiplier;
122254885Sdumbbell}
123254885Sdumbbell
124254885Sdumbbellstatic inline int
125254885Sdumbbellintel_mode_get_pixel_multiplier(const struct drm_display_mode *mode)
126254885Sdumbbell{
127254885Sdumbbell	return (mode->private_flags & INTEL_MODE_PIXEL_MULTIPLIER_MASK) >> INTEL_MODE_PIXEL_MULTIPLIER_SHIFT;
128254885Sdumbbell}
129254885Sdumbbell
130254885Sdumbbellstruct intel_framebuffer {
131254885Sdumbbell	struct drm_framebuffer base;
132254885Sdumbbell	struct drm_i915_gem_object *obj;
133254885Sdumbbell};
134254885Sdumbbell
135254885Sdumbbellstruct intel_fbdev {
136254885Sdumbbell	struct drm_fb_helper helper;
137254885Sdumbbell	struct intel_framebuffer ifb;
138254885Sdumbbell	struct list_head fbdev_list;
139254885Sdumbbell	struct drm_display_mode *our_mode;
140254885Sdumbbell};
141254885Sdumbbell
142254885Sdumbbellstruct intel_encoder {
143254885Sdumbbell	struct drm_encoder base;
144254885Sdumbbell	int type;
145254885Sdumbbell	bool needs_tv_clock;
146254885Sdumbbell	void (*hot_plug)(struct intel_encoder *);
147254885Sdumbbell	int crtc_mask;
148254885Sdumbbell	int clone_mask;
149254885Sdumbbell};
150254885Sdumbbell
151254885Sdumbbellstruct intel_connector {
152254885Sdumbbell	struct drm_connector base;
153254885Sdumbbell	struct intel_encoder *encoder;
154254885Sdumbbell};
155254885Sdumbbell
156254885Sdumbbellstruct intel_crtc {
157254885Sdumbbell	struct drm_crtc base;
158254885Sdumbbell	enum pipe pipe;
159254885Sdumbbell	enum plane plane;
160254885Sdumbbell	u8 lut_r[256], lut_g[256], lut_b[256];
161254885Sdumbbell	int dpms_mode;
162254885Sdumbbell	bool active; /* is the crtc on? independent of the dpms mode */
163254885Sdumbbell	bool busy; /* is scanout buffer being updated frequently? */
164254885Sdumbbell	struct callout idle_callout;
165254885Sdumbbell	bool lowfreq_avail;
166254885Sdumbbell	struct intel_overlay *overlay;
167254885Sdumbbell	struct intel_unpin_work *unpin_work;
168254885Sdumbbell	int fdi_lanes;
169254885Sdumbbell
170254885Sdumbbell	struct drm_i915_gem_object *cursor_bo;
171254885Sdumbbell	uint32_t cursor_addr;
172254885Sdumbbell	int16_t cursor_x, cursor_y;
173254885Sdumbbell	int16_t cursor_width, cursor_height;
174254885Sdumbbell	bool cursor_visible;
175254885Sdumbbell	unsigned int bpp;
176254885Sdumbbell
177254885Sdumbbell	bool no_pll; /* tertiary pipe for IVB */
178254885Sdumbbell	bool use_pll_a;
179254885Sdumbbell};
180254885Sdumbbell
181254885Sdumbbellstruct intel_plane {
182254885Sdumbbell	struct drm_plane base;
183254885Sdumbbell	enum pipe pipe;
184254885Sdumbbell	struct drm_i915_gem_object *obj;
185254885Sdumbbell	bool primary_disabled;
186254885Sdumbbell	int max_downscale;
187254885Sdumbbell	u32 lut_r[1024], lut_g[1024], lut_b[1024];
188254885Sdumbbell	void (*update_plane)(struct drm_plane *plane,
189254885Sdumbbell			     struct drm_framebuffer *fb,
190254885Sdumbbell			     struct drm_i915_gem_object *obj,
191254885Sdumbbell			     int crtc_x, int crtc_y,
192254885Sdumbbell			     unsigned int crtc_w, unsigned int crtc_h,
193254885Sdumbbell			     uint32_t x, uint32_t y,
194254885Sdumbbell			     uint32_t src_w, uint32_t src_h);
195254885Sdumbbell	void (*disable_plane)(struct drm_plane *plane);
196254885Sdumbbell	int (*update_colorkey)(struct drm_plane *plane,
197254885Sdumbbell			       struct drm_intel_sprite_colorkey *key);
198254885Sdumbbell	void (*get_colorkey)(struct drm_plane *plane,
199254885Sdumbbell			     struct drm_intel_sprite_colorkey *key);
200254885Sdumbbell};
201254885Sdumbbell
202254885Sdumbbell#define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
203254885Sdumbbell#define to_intel_connector(x) container_of(x, struct intel_connector, base)
204254885Sdumbbell#define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
205254885Sdumbbell#define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
206254885Sdumbbell#define to_intel_plane(x) container_of(x, struct intel_plane, base)
207254885Sdumbbell
208254885Sdumbbell#define DIP_HEADER_SIZE	5
209254885Sdumbbell
210254885Sdumbbell#define DIP_TYPE_AVI    0x82
211254885Sdumbbell#define DIP_VERSION_AVI 0x2
212254885Sdumbbell#define DIP_LEN_AVI     13
213254885Sdumbbell
214254885Sdumbbell#define DIP_TYPE_SPD	0x83
215254885Sdumbbell#define DIP_VERSION_SPD	0x1
216254885Sdumbbell#define DIP_LEN_SPD	25
217254885Sdumbbell#define DIP_SPD_UNKNOWN	0
218254885Sdumbbell#define DIP_SPD_DSTB	0x1
219254885Sdumbbell#define DIP_SPD_DVDP	0x2
220254885Sdumbbell#define DIP_SPD_DVHS	0x3
221254885Sdumbbell#define DIP_SPD_HDDVR	0x4
222254885Sdumbbell#define DIP_SPD_DVC	0x5
223254885Sdumbbell#define DIP_SPD_DSC	0x6
224254885Sdumbbell#define DIP_SPD_VCD	0x7
225254885Sdumbbell#define DIP_SPD_GAME	0x8
226254885Sdumbbell#define DIP_SPD_PC	0x9
227254885Sdumbbell#define DIP_SPD_BD	0xa
228254885Sdumbbell#define DIP_SPD_SCD	0xb
229254885Sdumbbell
230254885Sdumbbellstruct dip_infoframe {
231254885Sdumbbell	uint8_t type;		/* HB0 */
232254885Sdumbbell	uint8_t ver;		/* HB1 */
233254885Sdumbbell	uint8_t len;		/* HB2 - body len, not including checksum */
234254885Sdumbbell	uint8_t ecc;		/* Header ECC */
235254885Sdumbbell	uint8_t checksum;	/* PB0 */
236254885Sdumbbell	union {
237254885Sdumbbell		struct {
238254885Sdumbbell			/* PB1 - Y 6:5, A 4:4, B 3:2, S 1:0 */
239254885Sdumbbell			uint8_t Y_A_B_S;
240254885Sdumbbell			/* PB2 - C 7:6, M 5:4, R 3:0 */
241254885Sdumbbell			uint8_t C_M_R;
242254885Sdumbbell			/* PB3 - ITC 7:7, EC 6:4, Q 3:2, SC 1:0 */
243254885Sdumbbell			uint8_t ITC_EC_Q_SC;
244261455Seadler			/* PB4 - VIC 6:0 */
245254885Sdumbbell			uint8_t VIC;
246254885Sdumbbell			/* PB5 - PR 3:0 */
247254885Sdumbbell			uint8_t PR;
248254885Sdumbbell			/* PB6 to PB13 */
249261455Seadler			uint16_t top_bar_end;
250254885Sdumbbell			uint16_t bottom_bar_start;
251254885Sdumbbell			uint16_t left_bar_end;
252254885Sdumbbell			uint16_t right_bar_start;
253254885Sdumbbell		} avi;
254254885Sdumbbell		struct {
255254885Sdumbbell			uint8_t vn[8];
256254885Sdumbbell			uint8_t pd[16];
257254885Sdumbbell			uint8_t sdi;
258254885Sdumbbell		} spd;
259254885Sdumbbell		uint8_t payload[27];
260254885Sdumbbell	} __attribute__ ((packed)) body;
261254885Sdumbbell} __attribute__((packed));
262254885Sdumbbell
263254885Sdumbbellstatic inline struct drm_crtc *
264254885Sdumbbellintel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
265254885Sdumbbell{
266254885Sdumbbell	struct drm_i915_private *dev_priv = dev->dev_private;
267254885Sdumbbell	return dev_priv->pipe_to_crtc_mapping[pipe];
268254885Sdumbbell}
269254885Sdumbbell
270254885Sdumbbellstatic inline struct drm_crtc *
271254885Sdumbbellintel_get_crtc_for_plane(struct drm_device *dev, int plane)
272254885Sdumbbell{
273254885Sdumbbell	struct drm_i915_private *dev_priv = dev->dev_private;
274254885Sdumbbell	return dev_priv->plane_to_crtc_mapping[plane];
275254885Sdumbbell}
276254885Sdumbbell
277254885Sdumbbellstruct intel_unpin_work {
278254885Sdumbbell	struct task task;
279254885Sdumbbell	struct drm_device *dev;
280254885Sdumbbell	struct drm_i915_gem_object *old_fb_obj;
281254885Sdumbbell	struct drm_i915_gem_object *pending_flip_obj;
282254885Sdumbbell	struct drm_pending_vblank_event *event;
283254885Sdumbbell	int pending;
284254885Sdumbbell	bool enable_stall_check;
285254885Sdumbbell};
286254885Sdumbbell
287254885Sdumbbellstruct intel_fbc_work {
288254885Sdumbbell	struct timeout_task task;
289254885Sdumbbell	struct drm_crtc *crtc;
290254885Sdumbbell	struct drm_framebuffer *fb;
291254885Sdumbbell	int interval;
292254885Sdumbbell};
293254885Sdumbbell
294254885Sdumbbellint intel_ddc_get_modes(struct drm_connector *c, device_t adapter);
295254885Sdumbbellextern bool intel_ddc_probe(struct intel_encoder *intel_encoder, int ddc_bus);
296254885Sdumbbell
297254885Sdumbbellextern void intel_attach_force_audio_property(struct drm_connector *connector);
298254885Sdumbbellextern void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
299254885Sdumbbell
300254885Sdumbbellextern void intel_crt_init(struct drm_device *dev);
301254885Sdumbbellextern void intel_hdmi_init(struct drm_device *dev, int sdvox_reg);
302254885Sdumbbellvoid intel_dip_infoframe_csum(struct dip_infoframe *avi_if);
303254885Sdumbbellextern bool intel_sdvo_init(struct drm_device *dev, int output_device);
304254885Sdumbbellextern void intel_dvo_init(struct drm_device *dev);
305254885Sdumbbellextern void intel_tv_init(struct drm_device *dev);
306254885Sdumbbellextern void intel_mark_busy(struct drm_device *dev,
307254885Sdumbbell			    struct drm_i915_gem_object *obj);
308254885Sdumbbellextern bool intel_lvds_init(struct drm_device *dev);
309254885Sdumbbellextern void intel_dp_init(struct drm_device *dev, int dp_reg);
310254885Sdumbbellvoid
311254885Sdumbbellintel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
312254885Sdumbbell		 struct drm_display_mode *adjusted_mode);
313254885Sdumbbellextern bool intel_dpd_is_edp(struct drm_device *dev);
314254885Sdumbbellextern void intel_edp_link_config(struct intel_encoder *, int *, int *);
315254885Sdumbbellextern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
316254885Sdumbbellextern int intel_plane_init(struct drm_device *dev, enum pipe pipe);
317254885Sdumbbell
318254885Sdumbbell/* intel_panel.c */
319254885Sdumbbellextern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
320254885Sdumbbell				   struct drm_display_mode *adjusted_mode);
321254885Sdumbbellextern void intel_pch_panel_fitting(struct drm_device *dev,
322254885Sdumbbell				    int fitting_mode,
323254885Sdumbbell				    const struct drm_display_mode *mode,
324254885Sdumbbell				    struct drm_display_mode *adjusted_mode);
325254885Sdumbbellextern u32 intel_panel_get_max_backlight(struct drm_device *dev);
326254885Sdumbbellextern u32 intel_panel_get_backlight(struct drm_device *dev);
327254885Sdumbbellextern void intel_panel_set_backlight(struct drm_device *dev, u32 level);
328254885Sdumbbellextern int intel_panel_setup_backlight(struct drm_device *dev);
329254885Sdumbbellextern void intel_panel_enable_backlight(struct drm_device *dev);
330254885Sdumbbellextern void intel_panel_disable_backlight(struct drm_device *dev);
331254885Sdumbbellextern void intel_panel_destroy_backlight(struct drm_device *dev);
332254885Sdumbbellextern enum drm_connector_status intel_panel_detect(struct drm_device *dev);
333254885Sdumbbell
334254885Sdumbbellextern void intel_crtc_load_lut(struct drm_crtc *crtc);
335254885Sdumbbellextern void intel_encoder_prepare(struct drm_encoder *encoder);
336254885Sdumbbellextern void intel_encoder_commit(struct drm_encoder *encoder);
337254885Sdumbbellextern void intel_encoder_destroy(struct drm_encoder *encoder);
338254885Sdumbbell
339254885Sdumbbellstatic inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)
340254885Sdumbbell{
341254885Sdumbbell	return to_intel_connector(connector)->encoder;
342254885Sdumbbell}
343254885Sdumbbell
344254885Sdumbbellextern void intel_connector_attach_encoder(struct intel_connector *connector,
345254885Sdumbbell					   struct intel_encoder *encoder);
346254885Sdumbbellextern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
347254885Sdumbbell
348254885Sdumbbellextern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
349254885Sdumbbell						    struct drm_crtc *crtc);
350254885Sdumbbellint intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
351254885Sdumbbell				struct drm_file *file_priv);
352254885Sdumbbellextern void intel_wait_for_vblank(struct drm_device *dev, int pipe);
353254885Sdumbbellextern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
354254885Sdumbbell
355254885Sdumbbellstruct intel_load_detect_pipe {
356254885Sdumbbell	struct drm_framebuffer *release_fb;
357254885Sdumbbell	bool load_detect_temp;
358254885Sdumbbell	int dpms_mode;
359254885Sdumbbell};
360254885Sdumbbellextern bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
361254885Sdumbbell				       struct drm_connector *connector,
362254885Sdumbbell				       struct drm_display_mode *mode,
363254885Sdumbbell				       struct intel_load_detect_pipe *old);
364254885Sdumbbellextern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
365254885Sdumbbell					   struct drm_connector *connector,
366254885Sdumbbell					   struct intel_load_detect_pipe *old);
367254885Sdumbbell
368254885Sdumbbellextern void intelfb_restore(void);
369254885Sdumbbellextern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
370254885Sdumbbell				    u16 blue, int regno);
371254885Sdumbbellextern void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
372254885Sdumbbell				    u16 *blue, int regno);
373254885Sdumbbellextern void intel_enable_clock_gating(struct drm_device *dev);
374254885Sdumbbellextern void ironlake_enable_drps(struct drm_device *dev);
375254885Sdumbbellextern void ironlake_disable_drps(struct drm_device *dev);
376254885Sdumbbellextern void gen6_enable_rps(struct drm_i915_private *dev_priv);
377254885Sdumbbellextern void gen6_update_ring_freq(struct drm_i915_private *dev_priv);
378254885Sdumbbellextern void gen6_disable_rps(struct drm_device *dev);
379254885Sdumbbellextern void intel_init_emon(struct drm_device *dev);
380254885Sdumbbell
381254885Sdumbbellextern int intel_pin_and_fence_fb_obj(struct drm_device *dev,
382254885Sdumbbell				      struct drm_i915_gem_object *obj,
383254885Sdumbbell				      struct intel_ring_buffer *pipelined);
384254885Sdumbbellextern void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
385254885Sdumbbell
386254885Sdumbbellextern int intel_framebuffer_init(struct drm_device *dev,
387254885Sdumbbell				  struct intel_framebuffer *ifb,
388254885Sdumbbell				  struct drm_mode_fb_cmd2 *mode_cmd,
389254885Sdumbbell				  struct drm_i915_gem_object *obj);
390254885Sdumbbellextern int intel_fbdev_init(struct drm_device *dev);
391254885Sdumbbellextern void intel_fbdev_fini(struct drm_device *dev);
392254885Sdumbbell
393254885Sdumbbellextern void intel_prepare_page_flip(struct drm_device *dev, int plane);
394254885Sdumbbellextern void intel_finish_page_flip(struct drm_device *dev, int pipe);
395254885Sdumbbellextern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
396254885Sdumbbell
397254885Sdumbbellextern void intel_setup_overlay(struct drm_device *dev);
398254885Sdumbbellextern void intel_cleanup_overlay(struct drm_device *dev);
399254885Sdumbbellextern int intel_overlay_switch_off(struct intel_overlay *overlay);
400254885Sdumbbellextern int intel_overlay_put_image(struct drm_device *dev, void *data,
401254885Sdumbbell				   struct drm_file *file_priv);
402254885Sdumbbellextern int intel_overlay_attrs(struct drm_device *dev, void *data,
403254885Sdumbbell			       struct drm_file *file_priv);
404254885Sdumbbell
405254885Sdumbbellextern void intel_fb_output_poll_changed(struct drm_device *dev);
406254885Sdumbbellextern void intel_fb_restore_mode(struct drm_device *dev);
407254885Sdumbbell
408254885Sdumbbellextern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
409254885Sdumbbell			bool state);
410254885Sdumbbell#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
411254885Sdumbbell#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
412254885Sdumbbell
413254885Sdumbbellextern void intel_init_clock_gating(struct drm_device *dev);
414254885Sdumbbellextern void intel_write_eld(struct drm_encoder *encoder,
415254885Sdumbbell			    struct drm_display_mode *mode);
416254885Sdumbbellextern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
417254885Sdumbbell
418254885Sdumbbell/* For use by IVB LP watermark workaround in intel_sprite.c */
419254885Sdumbbellextern void sandybridge_update_wm(struct drm_device *dev);
420254885Sdumbbellextern void intel_update_sprite_watermarks(struct drm_device *dev, int pipe,
421254885Sdumbbell					   uint32_t sprite_width,
422254885Sdumbbell					   int pixel_size);
423254885Sdumbbellextern int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
424254885Sdumbbell				     struct drm_file *file_priv);
425254885Sdumbbellextern int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
426254885Sdumbbell				     struct drm_file *file_priv);
427254885Sdumbbell
428254885Sdumbbell#endif
429254885Sdumbbell