Correct .gbs.conf settings
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / gpu / drm / i915 / intel_drv.h
1 /*
2  * Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
3  * Copyright (c) 2007-2008 Intel Corporation
4  *   Jesse Barnes <jesse.barnes@intel.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the next
14  * paragraph) shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23  * IN THE SOFTWARE.
24  */
25 #ifndef __INTEL_DRV_H__
26 #define __INTEL_DRV_H__
27
28 #include <linux/i2c.h>
29 #include <linux/hdmi.h>
30 #include <drm/i915_drm.h>
31 #include "i915_drv.h"
32 #include <drm/drm_crtc.h>
33 #include <drm/drm_crtc_helper.h>
34 #include <drm/drm_fb_helper.h>
35 #include <drm/drm_dp_helper.h>
36
37 /**
38  * _wait_for - magic (register) wait macro
39  *
40  * Does the right thing for modeset paths when run under kdgb or similar atomic
41  * contexts. Note that it's important that we check the condition again after
42  * having timed out, since the timeout could be due to preemption or similar and
43  * we've never had a chance to check the condition before the timeout.
44  */
45 #define _wait_for(COND, MS, W) ({ \
46         unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1;   \
47         int ret__ = 0;                                                  \
48         while (!(COND)) {                                               \
49                 if (time_after(jiffies, timeout__)) {                   \
50                         if (!(COND))                                    \
51                                 ret__ = -ETIMEDOUT;                     \
52                         break;                                          \
53                 }                                                       \
54                 if (W && drm_can_sleep())  {                            \
55                         msleep(W);                                      \
56                 } else {                                                \
57                         cpu_relax();                                    \
58                 }                                                       \
59         }                                                               \
60         ret__;                                                          \
61 })
62
63 #define wait_for(COND, MS) _wait_for(COND, MS, 1)
64 #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)
65 #define wait_for_atomic_us(COND, US) _wait_for((COND), \
66                                                DIV_ROUND_UP((US), 1000), 0)
67
68 #define KHz(x) (1000 * (x))
69 #define MHz(x) KHz(1000 * (x))
70
71 /*
72  * Display related stuff
73  */
74
75 /* store information about an Ixxx DVO */
76 /* The i830->i865 use multiple DVOs with multiple i2cs */
77 /* the i915, i945 have a single sDVO i2c bus - which is different */
78 #define MAX_OUTPUTS 6
79 /* maximum connectors per crtcs in the mode set */
80
81 #define INTEL_I2C_BUS_DVO 1
82 #define INTEL_I2C_BUS_SDVO 2
83
84 /* these are outputs from the chip - integrated only
85    external chips are via DVO or SDVO output */
86 #define INTEL_OUTPUT_UNUSED 0
87 #define INTEL_OUTPUT_ANALOG 1
88 #define INTEL_OUTPUT_DVO 2
89 #define INTEL_OUTPUT_SDVO 3
90 #define INTEL_OUTPUT_LVDS 4
91 #define INTEL_OUTPUT_TVOUT 5
92 #define INTEL_OUTPUT_HDMI 6
93 #define INTEL_OUTPUT_DISPLAYPORT 7
94 #define INTEL_OUTPUT_EDP 8
95 #define INTEL_OUTPUT_DSI 9
96 #define INTEL_OUTPUT_UNKNOWN 10
97
98 #define INTEL_DVO_CHIP_NONE 0
99 #define INTEL_DVO_CHIP_LVDS 1
100 #define INTEL_DVO_CHIP_TMDS 2
101 #define INTEL_DVO_CHIP_TVOUT 4
102
103 #define INTEL_DSI_COMMAND_MODE  0
104 #define INTEL_DSI_VIDEO_MODE    1
105
106 struct intel_framebuffer {
107         struct drm_framebuffer base;
108         struct drm_i915_gem_object *obj;
109 };
110
111 struct intel_fbdev {
112         struct drm_fb_helper helper;
113         struct intel_framebuffer ifb;
114         struct list_head fbdev_list;
115         struct drm_display_mode *our_mode;
116 };
117
118 struct intel_encoder {
119         struct drm_encoder base;
120         /*
121          * The new crtc this encoder will be driven from. Only differs from
122          * base->crtc while a modeset is in progress.
123          */
124         struct intel_crtc *new_crtc;
125
126         int type;
127         /*
128          * Intel hw has only one MUX where encoders could be clone, hence a
129          * simple flag is enough to compute the possible_clones mask.
130          */
131         bool cloneable;
132         bool connectors_active;
133         void (*hot_plug)(struct intel_encoder *);
134         bool (*compute_config)(struct intel_encoder *,
135                                struct intel_crtc_config *);
136         void (*pre_pll_enable)(struct intel_encoder *);
137         void (*pre_enable)(struct intel_encoder *);
138         void (*enable)(struct intel_encoder *);
139         void (*mode_set)(struct intel_encoder *intel_encoder);
140         void (*disable)(struct intel_encoder *);
141         void (*post_disable)(struct intel_encoder *);
142         /* Read out the current hw state of this connector, returning true if
143          * the encoder is active. If the encoder is enabled it also set the pipe
144          * it is connected to in the pipe parameter. */
145         bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
146         /* Reconstructs the equivalent mode flags for the current hardware
147          * state. This must be called _after_ display->get_pipe_config has
148          * pre-filled the pipe config. Note that intel_encoder->base.crtc must
149          * be set correctly before calling this function. */
150         void (*get_config)(struct intel_encoder *,
151                            struct intel_crtc_config *pipe_config);
152         int crtc_mask;
153         enum hpd_pin hpd_pin;
154 };
155
156 struct intel_panel {
157         struct drm_display_mode *fixed_mode;
158         struct drm_display_mode *downclock_mode;
159         int fitting_mode;
160
161         /* backlight */
162         struct {
163                 bool present;
164                 u32 level;
165                 u32 max;
166                 bool enabled;
167                 bool combination_mode;  /* gen 2/4 only */
168                 bool active_low_pwm;
169                 struct backlight_device *device;
170         } backlight;
171 };
172
173 struct intel_connector {
174         struct drm_connector base;
175         /*
176          * The fixed encoder this connector is connected to.
177          */
178         struct intel_encoder *encoder;
179
180         /*
181          * The new encoder this connector will be driven. Only differs from
182          * encoder while a modeset is in progress.
183          */
184         struct intel_encoder *new_encoder;
185
186         /* Reads out the current hw, returning true if the connector is enabled
187          * and active (i.e. dpms ON state). */
188         bool (*get_hw_state)(struct intel_connector *);
189
190         /*
191          * Removes all interfaces through which the connector is accessible
192          * - like sysfs, debugfs entries -, so that no new operations can be
193          * started on the connector. Also makes sure all currently pending
194          * operations finish before returing.
195          */
196         void (*unregister)(struct intel_connector *);
197
198         /* Panel info for eDP and LVDS */
199         struct intel_panel panel;
200
201         /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
202         struct edid *edid;
203
204         /* since POLL and HPD connectors may use the same HPD line keep the native
205            state of connector->polled in case hotplug storm detection changes it */
206         u8 polled;
207 };
208
209 typedef struct dpll {
210         /* given values */
211         int n;
212         int m1, m2;
213         int p1, p2;
214         /* derived values */
215         int     dot;
216         int     vco;
217         int     m;
218         int     p;
219 } intel_clock_t;
220
221 struct intel_crtc_config {
222         /**
223          * quirks - bitfield with hw state readout quirks
224          *
225          * For various reasons the hw state readout code might not be able to
226          * completely faithfully read out the current state. These cases are
227          * tracked with quirk flags so that fastboot and state checker can act
228          * accordingly.
229          */
230 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS       (1<<0) /* unreliable sync mode.flags */
231 #define PIPE_CONFIG_QUIRK_INHERITED_MODE        (1<<1) /* mode inherited from firmware */
232         unsigned long quirks;
233
234         /* User requested mode, only valid as a starting point to
235          * compute adjusted_mode, except in the case of (S)DVO where
236          * it's also for the output timings of the (S)DVO chip.
237          * adjusted_mode will then correspond to the S(DVO) chip's
238          * preferred input timings. */
239         struct drm_display_mode requested_mode;
240         /* Actual pipe timings ie. what we program into the pipe timing
241          * registers. adjusted_mode.crtc_clock is the pipe pixel clock. */
242         struct drm_display_mode adjusted_mode;
243
244         /* Pipe source size (ie. panel fitter input size)
245          * All planes will be positioned inside this space,
246          * and get clipped at the edges. */
247         int pipe_src_w, pipe_src_h;
248
249         /* Whether to set up the PCH/FDI. Note that we never allow sharing
250          * between pch encoders and cpu encoders. */
251         bool has_pch_encoder;
252
253         /* CPU Transcoder for the pipe. Currently this can only differ from the
254          * pipe on Haswell (where we have a special eDP transcoder). */
255         enum transcoder cpu_transcoder;
256
257         /*
258          * Use reduced/limited/broadcast rbg range, compressing from the full
259          * range fed into the crtcs.
260          */
261         bool limited_color_range;
262
263         /* DP has a bunch of special case unfortunately, so mark the pipe
264          * accordingly. */
265         bool has_dp_encoder;
266
267         /*
268          * Enable dithering, used when the selected pipe bpp doesn't match the
269          * plane bpp.
270          */
271         bool dither;
272
273         /* Controls for the clock computation, to override various stages. */
274         bool clock_set;
275
276         /* SDVO TV has a bunch of special case. To make multifunction encoders
277          * work correctly, we need to track this at runtime.*/
278         bool sdvo_tv_clock;
279
280         /*
281          * crtc bandwidth limit, don't increase pipe bpp or clock if not really
282          * required. This is set in the 2nd loop of calling encoder's
283          * ->compute_config if the first pick doesn't work out.
284          */
285         bool bw_constrained;
286
287         /* Settings for the intel dpll used on pretty much everything but
288          * haswell. */
289         struct dpll dpll;
290
291         /* Selected dpll when shared or DPLL_ID_PRIVATE. */
292         enum intel_dpll_id shared_dpll;
293
294         /* Actual register state of the dpll, for shared dpll cross-checking. */
295         struct intel_dpll_hw_state dpll_hw_state;
296
297         int pipe_bpp;
298         struct intel_link_m_n dp_m_n;
299
300         /*
301          * Frequence the dpll for the port should run at. Differs from the
302          * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
303          * already multiplied by pixel_multiplier.
304          */
305         int port_clock;
306
307         /* Used by SDVO (and if we ever fix it, HDMI). */
308         unsigned pixel_multiplier;
309
310         /* Panel fitter controls for gen2-gen4 + VLV */
311         struct {
312                 u32 control;
313                 u32 pgm_ratios;
314                 u32 lvds_border_bits;
315         } gmch_pfit;
316
317         /* Panel fitter placement and size for Ironlake+ */
318         struct {
319                 u32 pos;
320                 u32 size;
321                 bool enabled;
322         } pch_pfit;
323
324         /* FDI configuration, only valid if has_pch_encoder is set. */
325         int fdi_lanes;
326         struct intel_link_m_n fdi_m_n;
327
328         bool ips_enabled;
329
330         bool double_wide;
331 };
332
333 struct intel_pipe_wm {
334         struct intel_wm_level wm[5];
335         uint32_t linetime;
336         bool fbc_wm_enabled;
337 };
338
339 struct intel_crtc {
340         struct drm_crtc base;
341         enum pipe pipe;
342         enum plane plane;
343         u8 lut_r[256], lut_g[256], lut_b[256];
344         /*
345          * Whether the crtc and the connected output pipeline is active. Implies
346          * that crtc->enabled is set, i.e. the current mode configuration has
347          * some outputs connected to this crtc.
348          */
349         bool active;
350         unsigned long enabled_power_domains;
351         bool eld_vld;
352         bool primary_enabled; /* is the primary plane (partially) visible? */
353         bool lowfreq_avail;
354         struct intel_overlay *overlay;
355         struct intel_unpin_work *unpin_work;
356
357         atomic_t unpin_work_count;
358
359         /* Display surface base address adjustement for pageflips. Note that on
360          * gen4+ this only adjusts up to a tile, offsets within a tile are
361          * handled in the hw itself (with the TILEOFF register). */
362         unsigned long dspaddr_offset;
363
364         struct drm_i915_gem_object *cursor_bo;
365         uint32_t cursor_addr;
366         int16_t cursor_x, cursor_y;
367         int16_t cursor_width, cursor_height;
368         bool cursor_visible;
369
370         struct intel_crtc_config config;
371
372         uint32_t ddi_pll_sel;
373
374         /* reset counter value when the last flip was submitted */
375         unsigned int reset_counter;
376
377         /* Access to these should be protected by dev_priv->irq_lock. */
378         bool cpu_fifo_underrun_disabled;
379         bool pch_fifo_underrun_disabled;
380
381         /* per-pipe watermark state */
382         struct {
383                 /* watermarks currently being used  */
384                 struct intel_pipe_wm active;
385         } wm;
386 };
387
388 struct intel_plane_wm_parameters {
389         uint32_t horiz_pixels;
390         uint8_t bytes_per_pixel;
391         bool enabled;
392         bool scaled;
393 };
394
395 struct intel_plane {
396         struct drm_plane base;
397         int plane;
398         enum pipe pipe;
399         struct drm_i915_gem_object *obj;
400         bool can_scale;
401         int max_downscale;
402         u32 lut_r[1024], lut_g[1024], lut_b[1024];
403         int crtc_x, crtc_y;
404         unsigned int crtc_w, crtc_h;
405         uint32_t src_x, src_y;
406         uint32_t src_w, src_h;
407
408         /* Since we need to change the watermarks before/after
409          * enabling/disabling the planes, we need to store the parameters here
410          * as the other pieces of the struct may not reflect the values we want
411          * for the watermark calculations. Currently only Haswell uses this.
412          */
413         struct intel_plane_wm_parameters wm;
414
415         void (*update_plane)(struct drm_plane *plane,
416                              struct drm_crtc *crtc,
417                              struct drm_framebuffer *fb,
418                              struct drm_i915_gem_object *obj,
419                              int crtc_x, int crtc_y,
420                              unsigned int crtc_w, unsigned int crtc_h,
421                              uint32_t x, uint32_t y,
422                              uint32_t src_w, uint32_t src_h);
423         void (*disable_plane)(struct drm_plane *plane,
424                               struct drm_crtc *crtc);
425         int (*update_colorkey)(struct drm_plane *plane,
426                                struct drm_intel_sprite_colorkey *key);
427         void (*get_colorkey)(struct drm_plane *plane,
428                              struct drm_intel_sprite_colorkey *key);
429 };
430
431 struct intel_watermark_params {
432         unsigned long fifo_size;
433         unsigned long max_wm;
434         unsigned long default_wm;
435         unsigned long guard_size;
436         unsigned long cacheline_size;
437 };
438
439 struct cxsr_latency {
440         int is_desktop;
441         int is_ddr3;
442         unsigned long fsb_freq;
443         unsigned long mem_freq;
444         unsigned long display_sr;
445         unsigned long display_hpll_disable;
446         unsigned long cursor_sr;
447         unsigned long cursor_hpll_disable;
448 };
449
450 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
451 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
452 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
453 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
454 #define to_intel_plane(x) container_of(x, struct intel_plane, base)
455
456 struct intel_hdmi {
457         u32 hdmi_reg;
458         int ddc_bus;
459         uint32_t color_range;
460         bool color_range_auto;
461         bool has_hdmi_sink;
462         bool has_audio;
463         enum hdmi_force_audio force_audio;
464         bool rgb_quant_range_selectable;
465         void (*write_infoframe)(struct drm_encoder *encoder,
466                                 enum hdmi_infoframe_type type,
467                                 const void *frame, ssize_t len);
468         void (*set_infoframes)(struct drm_encoder *encoder,
469                                struct drm_display_mode *adjusted_mode);
470 };
471
472 #define DP_MAX_DOWNSTREAM_PORTS         0x10
473
474 struct intel_dp {
475         uint32_t output_reg;
476         uint32_t aux_ch_ctl_reg;
477         uint32_t DP;
478         bool has_audio;
479         enum hdmi_force_audio force_audio;
480         uint32_t color_range;
481         bool color_range_auto;
482         uint8_t link_bw;
483         uint8_t lane_count;
484         uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
485         uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
486         uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
487         struct i2c_adapter adapter;
488         struct i2c_algo_dp_aux_data algo;
489         uint8_t train_set[4];
490         int panel_power_up_delay;
491         int panel_power_down_delay;
492         int panel_power_cycle_delay;
493         int backlight_on_delay;
494         int backlight_off_delay;
495         struct delayed_work panel_vdd_work;
496         bool want_panel_vdd;
497         bool psr_setup_done;
498         struct intel_connector *attached_connector;
499 };
500
501 struct intel_digital_port {
502         struct intel_encoder base;
503         enum port port;
504         u32 saved_port_bits;
505         struct intel_dp dp;
506         struct intel_hdmi hdmi;
507 };
508
509 static inline int
510 vlv_dport_to_channel(struct intel_digital_port *dport)
511 {
512         switch (dport->port) {
513         case PORT_B:
514                 return DPIO_CH0;
515         case PORT_C:
516                 return DPIO_CH1;
517         default:
518                 BUG();
519         }
520 }
521
522 static inline struct drm_crtc *
523 intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
524 {
525         struct drm_i915_private *dev_priv = dev->dev_private;
526         return dev_priv->pipe_to_crtc_mapping[pipe];
527 }
528
529 static inline struct drm_crtc *
530 intel_get_crtc_for_plane(struct drm_device *dev, int plane)
531 {
532         struct drm_i915_private *dev_priv = dev->dev_private;
533         return dev_priv->plane_to_crtc_mapping[plane];
534 }
535
536 struct intel_unpin_work {
537         struct work_struct work;
538         struct drm_crtc *crtc;
539         struct drm_i915_gem_object *old_fb_obj;
540         struct drm_i915_gem_object *pending_flip_obj;
541         struct drm_pending_vblank_event *event;
542         atomic_t pending;
543 #define INTEL_FLIP_INACTIVE     0
544 #define INTEL_FLIP_PENDING      1
545 #define INTEL_FLIP_COMPLETE     2
546         bool enable_stall_check;
547 };
548
549 struct intel_set_config {
550         struct drm_encoder **save_connector_encoders;
551         struct drm_crtc **save_encoder_crtcs;
552
553         bool fb_changed;
554         bool mode_changed;
555 };
556
557 struct intel_load_detect_pipe {
558         struct drm_framebuffer *release_fb;
559         bool load_detect_temp;
560         int dpms_mode;
561 };
562
563 static inline struct intel_encoder *
564 intel_attached_encoder(struct drm_connector *connector)
565 {
566         return to_intel_connector(connector)->encoder;
567 }
568
569 static inline struct intel_digital_port *
570 enc_to_dig_port(struct drm_encoder *encoder)
571 {
572         return container_of(encoder, struct intel_digital_port, base.base);
573 }
574
575 static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
576 {
577         return &enc_to_dig_port(encoder)->dp;
578 }
579
580 static inline struct intel_digital_port *
581 dp_to_dig_port(struct intel_dp *intel_dp)
582 {
583         return container_of(intel_dp, struct intel_digital_port, dp);
584 }
585
586 static inline struct intel_digital_port *
587 hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
588 {
589         return container_of(intel_hdmi, struct intel_digital_port, hdmi);
590 }
591
592
593 /* i915_irq.c */
594 bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
595                                            enum pipe pipe, bool enable);
596 bool intel_set_pch_fifo_underrun_reporting(struct drm_device *dev,
597                                            enum transcoder pch_transcoder,
598                                            bool enable);
599 void ilk_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
600 void ilk_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
601 void snb_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
602 void snb_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
603 void hsw_pc8_disable_interrupts(struct drm_device *dev);
604 void hsw_pc8_restore_interrupts(struct drm_device *dev);
605
606
607 /* intel_crt.c */
608 void intel_crt_init(struct drm_device *dev);
609
610
611 /* intel_ddi.c */
612 void intel_prepare_ddi(struct drm_device *dev);
613 void hsw_fdi_link_train(struct drm_crtc *crtc);
614 void intel_ddi_init(struct drm_device *dev, enum port port);
615 enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
616 bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
617 int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
618 void intel_ddi_pll_init(struct drm_device *dev);
619 void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
620 void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
621                                        enum transcoder cpu_transcoder);
622 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
623 void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
624 void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
625 bool intel_ddi_pll_select(struct intel_crtc *crtc);
626 void intel_ddi_pll_enable(struct intel_crtc *crtc);
627 void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
628 void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
629 void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
630 bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
631 void intel_ddi_fdi_disable(struct drm_crtc *crtc);
632 void intel_ddi_get_config(struct intel_encoder *encoder,
633                           struct intel_crtc_config *pipe_config);
634
635
636 /* intel_display.c */
637 const char *intel_output_name(int output);
638 bool intel_has_pending_fb_unpin(struct drm_device *dev);
639 int intel_pch_rawclk(struct drm_device *dev);
640 void intel_mark_busy(struct drm_device *dev);
641 void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
642                         struct intel_ring_buffer *ring);
643 void intel_mark_idle(struct drm_device *dev);
644 void intel_crtc_restore_mode(struct drm_crtc *crtc);
645 void intel_crtc_update_dpms(struct drm_crtc *crtc);
646 void intel_encoder_destroy(struct drm_encoder *encoder);
647 void intel_connector_dpms(struct drm_connector *, int mode);
648 bool intel_connector_get_hw_state(struct intel_connector *connector);
649 void intel_modeset_check_state(struct drm_device *dev);
650 bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
651                                 struct intel_digital_port *port);
652 void intel_connector_attach_encoder(struct intel_connector *connector,
653                                     struct intel_encoder *encoder);
654 struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
655 struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
656                                              struct drm_crtc *crtc);
657 enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
658 int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
659                                 struct drm_file *file_priv);
660 enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
661                                              enum pipe pipe);
662 void intel_wait_for_vblank(struct drm_device *dev, int pipe);
663 void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
664 int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
665 void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
666                          struct intel_digital_port *dport);
667 bool intel_get_load_detect_pipe(struct drm_connector *connector,
668                                 struct drm_display_mode *mode,
669                                 struct intel_load_detect_pipe *old);
670 void intel_release_load_detect_pipe(struct drm_connector *connector,
671                                     struct intel_load_detect_pipe *old);
672 int intel_pin_and_fence_fb_obj(struct drm_device *dev,
673                                struct drm_i915_gem_object *obj,
674                                struct intel_ring_buffer *pipelined);
675 void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
676 int intel_framebuffer_init(struct drm_device *dev,
677                            struct intel_framebuffer *ifb,
678                            struct drm_mode_fb_cmd2 *mode_cmd,
679                            struct drm_i915_gem_object *obj);
680 void intel_framebuffer_fini(struct intel_framebuffer *fb);
681 void intel_prepare_page_flip(struct drm_device *dev, int plane);
682 void intel_finish_page_flip(struct drm_device *dev, int pipe);
683 void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
684 struct intel_shared_dpll *intel_crtc_to_shared_dpll(struct intel_crtc *crtc);
685 void assert_shared_dpll(struct drm_i915_private *dev_priv,
686                         struct intel_shared_dpll *pll,
687                         bool state);
688 #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
689 #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
690 void assert_pll(struct drm_i915_private *dev_priv,
691                 enum pipe pipe, bool state);
692 #define assert_pll_enabled(d, p) assert_pll(d, p, true)
693 #define assert_pll_disabled(d, p) assert_pll(d, p, false)
694 void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
695                        enum pipe pipe, bool state);
696 #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
697 #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
698 void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
699 #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
700 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
701 void intel_write_eld(struct drm_encoder *encoder,
702                      struct drm_display_mode *mode);
703 unsigned long intel_gen4_compute_page_offset(int *x, int *y,
704                                              unsigned int tiling_mode,
705                                              unsigned int bpp,
706                                              unsigned int pitch);
707 void intel_display_handle_reset(struct drm_device *dev);
708 void hsw_enable_pc8_work(struct work_struct *__work);
709 void hsw_enable_package_c8(struct drm_i915_private *dev_priv);
710 void hsw_disable_package_c8(struct drm_i915_private *dev_priv);
711 void intel_dp_get_m_n(struct intel_crtc *crtc,
712                       struct intel_crtc_config *pipe_config);
713 int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
714 void
715 ironlake_check_encoder_dotclock(const struct intel_crtc_config *pipe_config,
716                                 int dotclock);
717 bool intel_crtc_active(struct drm_crtc *crtc);
718 void hsw_enable_ips(struct intel_crtc *crtc);
719 void hsw_disable_ips(struct intel_crtc *crtc);
720 void intel_display_set_init_power(struct drm_device *dev, bool enable);
721 int valleyview_get_vco(struct drm_i915_private *dev_priv);
722
723 /* intel_dp.c */
724 void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
725 bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
726                              struct intel_connector *intel_connector);
727 void intel_dp_start_link_train(struct intel_dp *intel_dp);
728 void intel_dp_complete_link_train(struct intel_dp *intel_dp);
729 void intel_dp_stop_link_train(struct intel_dp *intel_dp);
730 void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
731 void intel_dp_encoder_destroy(struct drm_encoder *encoder);
732 void intel_dp_check_link_status(struct intel_dp *intel_dp);
733 bool intel_dp_compute_config(struct intel_encoder *encoder,
734                              struct intel_crtc_config *pipe_config);
735 bool intel_dp_is_edp(struct drm_device *dev, enum port port);
736 void ironlake_edp_backlight_on(struct intel_dp *intel_dp);
737 void ironlake_edp_backlight_off(struct intel_dp *intel_dp);
738 void ironlake_edp_panel_on(struct intel_dp *intel_dp);
739 void ironlake_edp_panel_off(struct intel_dp *intel_dp);
740 void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
741 void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
742 void intel_edp_psr_enable(struct intel_dp *intel_dp);
743 void intel_edp_psr_disable(struct intel_dp *intel_dp);
744 void intel_edp_psr_update(struct drm_device *dev);
745
746
747 /* intel_dsi.c */
748 bool intel_dsi_init(struct drm_device *dev);
749
750
751 /* intel_dvo.c */
752 void intel_dvo_init(struct drm_device *dev);
753
754
755 /* legacy fbdev emulation in intel_fbdev.c */
756 #ifdef CONFIG_DRM_I915_FBDEV
757 extern int intel_fbdev_init(struct drm_device *dev);
758 extern void intel_fbdev_initial_config(struct drm_device *dev);
759 extern void intel_fbdev_fini(struct drm_device *dev);
760 extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
761 extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
762 extern void intel_fbdev_restore_mode(struct drm_device *dev);
763 #else
764 static inline int intel_fbdev_init(struct drm_device *dev)
765 {
766         return 0;
767 }
768
769 static inline void intel_fbdev_initial_config(struct drm_device *dev)
770 {
771 }
772
773 static inline void intel_fbdev_fini(struct drm_device *dev)
774 {
775 }
776
777 static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state)
778 {
779 }
780
781 static inline void intel_fbdev_restore_mode(struct drm_device *dev)
782 {
783 }
784 #endif
785
786 /* intel_hdmi.c */
787 void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port);
788 void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
789                                struct intel_connector *intel_connector);
790 struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
791 bool intel_hdmi_compute_config(struct intel_encoder *encoder,
792                                struct intel_crtc_config *pipe_config);
793
794
795 /* intel_lvds.c */
796 void intel_lvds_init(struct drm_device *dev);
797 bool intel_is_dual_link_lvds(struct drm_device *dev);
798
799
800 /* intel_modes.c */
801 int intel_connector_update_modes(struct drm_connector *connector,
802                                  struct edid *edid);
803 int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
804 void intel_attach_force_audio_property(struct drm_connector *connector);
805 void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
806
807
808 /* intel_overlay.c */
809 void intel_setup_overlay(struct drm_device *dev);
810 void intel_cleanup_overlay(struct drm_device *dev);
811 int intel_overlay_switch_off(struct intel_overlay *overlay);
812 int intel_overlay_put_image(struct drm_device *dev, void *data,
813                             struct drm_file *file_priv);
814 int intel_overlay_attrs(struct drm_device *dev, void *data,
815                         struct drm_file *file_priv);
816
817
818 /* intel_panel.c */
819 int intel_panel_init(struct intel_panel *panel,
820                      struct drm_display_mode *fixed_mode);
821 void intel_panel_fini(struct intel_panel *panel);
822 void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
823                             struct drm_display_mode *adjusted_mode);
824 void intel_pch_panel_fitting(struct intel_crtc *crtc,
825                              struct intel_crtc_config *pipe_config,
826                              int fitting_mode);
827 void intel_gmch_panel_fitting(struct intel_crtc *crtc,
828                               struct intel_crtc_config *pipe_config,
829                               int fitting_mode);
830 void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
831                                u32 max);
832 int intel_panel_setup_backlight(struct drm_connector *connector);
833 void intel_panel_enable_backlight(struct intel_connector *connector);
834 void intel_panel_disable_backlight(struct intel_connector *connector);
835 void intel_panel_destroy_backlight(struct drm_connector *connector);
836 void intel_panel_init_backlight_funcs(struct drm_device *dev);
837 enum drm_connector_status intel_panel_detect(struct drm_device *dev);
838 extern struct drm_display_mode *intel_find_panel_downclock(
839                                 struct drm_device *dev,
840                                 struct drm_display_mode *fixed_mode,
841                                 struct drm_connector *connector);
842
843 /* intel_pm.c */
844 void intel_init_clock_gating(struct drm_device *dev);
845 void intel_suspend_hw(struct drm_device *dev);
846 void intel_update_watermarks(struct drm_crtc *crtc);
847 void intel_update_sprite_watermarks(struct drm_plane *plane,
848                                     struct drm_crtc *crtc,
849                                     uint32_t sprite_width, int pixel_size,
850                                     bool enabled, bool scaled);
851 void intel_init_pm(struct drm_device *dev);
852 void intel_pm_setup(struct drm_device *dev);
853 bool intel_fbc_enabled(struct drm_device *dev);
854 void intel_update_fbc(struct drm_device *dev);
855 void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
856 void intel_gpu_ips_teardown(void);
857 int intel_power_domains_init(struct drm_device *dev);
858 void intel_power_domains_remove(struct drm_device *dev);
859 bool intel_display_power_enabled(struct drm_device *dev,
860                                  enum intel_display_power_domain domain);
861 bool intel_display_power_enabled_sw(struct drm_device *dev,
862                                     enum intel_display_power_domain domain);
863 void intel_display_power_get(struct drm_device *dev,
864                              enum intel_display_power_domain domain);
865 void intel_display_power_put(struct drm_device *dev,
866                              enum intel_display_power_domain domain);
867 void intel_power_domains_init_hw(struct drm_device *dev);
868 void intel_set_power_well(struct drm_device *dev, bool enable);
869 void intel_enable_gt_powersave(struct drm_device *dev);
870 void intel_disable_gt_powersave(struct drm_device *dev);
871 void ironlake_teardown_rc6(struct drm_device *dev);
872 void gen6_update_ring_freq(struct drm_device *dev);
873 void gen6_rps_idle(struct drm_i915_private *dev_priv);
874 void gen6_rps_boost(struct drm_i915_private *dev_priv);
875 void intel_aux_display_runtime_get(struct drm_i915_private *dev_priv);
876 void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv);
877 void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
878 void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
879 void intel_init_runtime_pm(struct drm_i915_private *dev_priv);
880 void intel_fini_runtime_pm(struct drm_i915_private *dev_priv);
881 void ilk_wm_get_hw_state(struct drm_device *dev);
882
883
884 /* intel_sdvo.c */
885 bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
886
887
888 /* intel_sprite.c */
889 int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
890 void intel_flush_primary_plane(struct drm_i915_private *dev_priv,
891                                enum plane plane);
892 void intel_plane_restore(struct drm_plane *plane);
893 void intel_plane_disable(struct drm_plane *plane);
894 int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
895                               struct drm_file *file_priv);
896 int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
897                               struct drm_file *file_priv);
898
899
900 /* intel_tv.c */
901 void intel_tv_init(struct drm_device *dev);
902
903 #endif /* __INTEL_DRV_H__ */