Path: blob/master/drivers/gpu/drm/i915/intel_drv.h
15112 views
/*1* Copyright (c) 2006 Dave Airlie <[email protected]>2* Copyright (c) 2007-2008 Intel Corporation3* Jesse Barnes <[email protected]>4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the "Software"),7* to deal in the Software without restriction, including without limitation8* the rights to use, copy, modify, merge, publish, distribute, sublicense,9* and/or sell copies of the Software, and to permit persons to whom the10* Software is furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice (including the next13* paragraph) shall be included in all copies or substantial portions of the14* Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL19* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING21* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS22* IN THE SOFTWARE.23*/24#ifndef __INTEL_DRV_H__25#define __INTEL_DRV_H__2627#include <linux/i2c.h>28#include "i915_drv.h"29#include "drm_crtc.h"30#include "drm_crtc_helper.h"31#include "drm_fb_helper.h"3233#define _wait_for(COND, MS, W) ({ \34unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \35int ret__ = 0; \36while (! (COND)) { \37if (time_after(jiffies, timeout__)) { \38ret__ = -ETIMEDOUT; \39break; \40} \41if (W && !(in_atomic() || in_dbg_master())) msleep(W); \42} \43ret__; \44})4546#define wait_for(COND, MS) _wait_for(COND, MS, 1)47#define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)4849#define MSLEEP(x) do { \50if (in_dbg_master()) \51mdelay(x); \52else \53msleep(x); \54} while(0)5556#define KHz(x) (1000*x)57#define MHz(x) KHz(1000*x)5859/*60* Display related stuff61*/6263/* store information about an Ixxx DVO */64/* The i830->i865 use multiple DVOs with multiple i2cs */65/* the i915, i945 have a single sDVO i2c bus - which is different */66#define MAX_OUTPUTS 667/* maximum connectors per crtcs in the mode set */68#define INTELFB_CONN_LIMIT 46970#define INTEL_I2C_BUS_DVO 171#define INTEL_I2C_BUS_SDVO 27273/* these are outputs from the chip - integrated only74external chips are via DVO or SDVO output */75#define INTEL_OUTPUT_UNUSED 076#define INTEL_OUTPUT_ANALOG 177#define INTEL_OUTPUT_DVO 278#define INTEL_OUTPUT_SDVO 379#define INTEL_OUTPUT_LVDS 480#define INTEL_OUTPUT_TVOUT 581#define INTEL_OUTPUT_HDMI 682#define INTEL_OUTPUT_DISPLAYPORT 783#define INTEL_OUTPUT_EDP 88485/* Intel Pipe Clone Bit */86#define INTEL_HDMIB_CLONE_BIT 187#define INTEL_HDMIC_CLONE_BIT 288#define INTEL_HDMID_CLONE_BIT 389#define INTEL_HDMIE_CLONE_BIT 490#define INTEL_HDMIF_CLONE_BIT 591#define INTEL_SDVO_NON_TV_CLONE_BIT 692#define INTEL_SDVO_TV_CLONE_BIT 793#define INTEL_SDVO_LVDS_CLONE_BIT 894#define INTEL_ANALOG_CLONE_BIT 995#define INTEL_TV_CLONE_BIT 1096#define INTEL_DP_B_CLONE_BIT 1197#define INTEL_DP_C_CLONE_BIT 1298#define INTEL_DP_D_CLONE_BIT 1399#define INTEL_LVDS_CLONE_BIT 14100#define INTEL_DVO_TMDS_CLONE_BIT 15101#define INTEL_DVO_LVDS_CLONE_BIT 16102#define INTEL_EDP_CLONE_BIT 17103104#define INTEL_DVO_CHIP_NONE 0105#define INTEL_DVO_CHIP_LVDS 1106#define INTEL_DVO_CHIP_TMDS 2107#define INTEL_DVO_CHIP_TVOUT 4108109/* drm_display_mode->private_flags */110#define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0)111#define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT)112113static inline void114intel_mode_set_pixel_multiplier(struct drm_display_mode *mode,115int multiplier)116{117mode->clock *= multiplier;118mode->private_flags |= multiplier;119}120121static inline int122intel_mode_get_pixel_multiplier(const struct drm_display_mode *mode)123{124return (mode->private_flags & INTEL_MODE_PIXEL_MULTIPLIER_MASK) >> INTEL_MODE_PIXEL_MULTIPLIER_SHIFT;125}126127struct intel_framebuffer {128struct drm_framebuffer base;129struct drm_i915_gem_object *obj;130};131132struct intel_fbdev {133struct drm_fb_helper helper;134struct intel_framebuffer ifb;135struct list_head fbdev_list;136struct drm_display_mode *our_mode;137};138139struct intel_encoder {140struct drm_encoder base;141int type;142bool needs_tv_clock;143void (*hot_plug)(struct intel_encoder *);144int crtc_mask;145int clone_mask;146};147148struct intel_connector {149struct drm_connector base;150struct intel_encoder *encoder;151};152153struct intel_crtc {154struct drm_crtc base;155enum pipe pipe;156enum plane plane;157u8 lut_r[256], lut_g[256], lut_b[256];158int dpms_mode;159bool active; /* is the crtc on? independent of the dpms mode */160bool busy; /* is scanout buffer being updated frequently? */161struct timer_list idle_timer;162bool lowfreq_avail;163struct intel_overlay *overlay;164struct intel_unpin_work *unpin_work;165int fdi_lanes;166167struct drm_i915_gem_object *cursor_bo;168uint32_t cursor_addr;169int16_t cursor_x, cursor_y;170int16_t cursor_width, cursor_height;171bool cursor_visible;172};173174#define to_intel_crtc(x) container_of(x, struct intel_crtc, base)175#define to_intel_connector(x) container_of(x, struct intel_connector, base)176#define to_intel_encoder(x) container_of(x, struct intel_encoder, base)177#define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)178179#define DIP_TYPE_AVI 0x82180#define DIP_VERSION_AVI 0x2181#define DIP_LEN_AVI 13182183struct dip_infoframe {184uint8_t type; /* HB0 */185uint8_t ver; /* HB1 */186uint8_t len; /* HB2 - body len, not including checksum */187uint8_t ecc; /* Header ECC */188uint8_t checksum; /* PB0 */189union {190struct {191/* PB1 - Y 6:5, A 4:4, B 3:2, S 1:0 */192uint8_t Y_A_B_S;193/* PB2 - C 7:6, M 5:4, R 3:0 */194uint8_t C_M_R;195/* PB3 - ITC 7:7, EC 6:4, Q 3:2, SC 1:0 */196uint8_t ITC_EC_Q_SC;197/* PB4 - VIC 6:0 */198uint8_t VIC;199/* PB5 - PR 3:0 */200uint8_t PR;201/* PB6 to PB13 */202uint16_t top_bar_end;203uint16_t bottom_bar_start;204uint16_t left_bar_end;205uint16_t right_bar_start;206} avi;207uint8_t payload[27];208} __attribute__ ((packed)) body;209} __attribute__((packed));210211static inline struct drm_crtc *212intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)213{214struct drm_i915_private *dev_priv = dev->dev_private;215return dev_priv->pipe_to_crtc_mapping[pipe];216}217218static inline struct drm_crtc *219intel_get_crtc_for_plane(struct drm_device *dev, int plane)220{221struct drm_i915_private *dev_priv = dev->dev_private;222return dev_priv->plane_to_crtc_mapping[plane];223}224225struct intel_unpin_work {226struct work_struct work;227struct drm_device *dev;228struct drm_i915_gem_object *old_fb_obj;229struct drm_i915_gem_object *pending_flip_obj;230struct drm_pending_vblank_event *event;231int pending;232bool enable_stall_check;233};234235int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);236extern bool intel_ddc_probe(struct intel_encoder *intel_encoder, int ddc_bus);237238extern void intel_attach_force_audio_property(struct drm_connector *connector);239extern void intel_attach_broadcast_rgb_property(struct drm_connector *connector);240241extern void intel_crt_init(struct drm_device *dev);242extern void intel_hdmi_init(struct drm_device *dev, int sdvox_reg);243void intel_dip_infoframe_csum(struct dip_infoframe *avi_if);244extern bool intel_sdvo_init(struct drm_device *dev, int output_device);245extern void intel_dvo_init(struct drm_device *dev);246extern void intel_tv_init(struct drm_device *dev);247extern void intel_mark_busy(struct drm_device *dev,248struct drm_i915_gem_object *obj);249extern bool intel_lvds_init(struct drm_device *dev);250extern void intel_dp_init(struct drm_device *dev, int dp_reg);251void252intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,253struct drm_display_mode *adjusted_mode);254extern bool intel_dpd_is_edp(struct drm_device *dev);255extern void intel_edp_link_config (struct intel_encoder *, int *, int *);256extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);257258/* intel_panel.c */259extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,260struct drm_display_mode *adjusted_mode);261extern void intel_pch_panel_fitting(struct drm_device *dev,262int fitting_mode,263struct drm_display_mode *mode,264struct drm_display_mode *adjusted_mode);265extern u32 intel_panel_get_max_backlight(struct drm_device *dev);266extern u32 intel_panel_get_backlight(struct drm_device *dev);267extern void intel_panel_set_backlight(struct drm_device *dev, u32 level);268extern void intel_panel_setup_backlight(struct drm_device *dev);269extern void intel_panel_enable_backlight(struct drm_device *dev);270extern void intel_panel_disable_backlight(struct drm_device *dev);271extern enum drm_connector_status intel_panel_detect(struct drm_device *dev);272273extern void intel_crtc_load_lut(struct drm_crtc *crtc);274extern void intel_encoder_prepare (struct drm_encoder *encoder);275extern void intel_encoder_commit (struct drm_encoder *encoder);276extern void intel_encoder_destroy(struct drm_encoder *encoder);277278static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)279{280return to_intel_connector(connector)->encoder;281}282283extern void intel_connector_attach_encoder(struct intel_connector *connector,284struct intel_encoder *encoder);285extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);286287extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,288struct drm_crtc *crtc);289int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,290struct drm_file *file_priv);291extern void intel_wait_for_vblank(struct drm_device *dev, int pipe);292extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);293294struct intel_load_detect_pipe {295struct drm_framebuffer *release_fb;296bool load_detect_temp;297int dpms_mode;298};299extern bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,300struct drm_connector *connector,301struct drm_display_mode *mode,302struct intel_load_detect_pipe *old);303extern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,304struct drm_connector *connector,305struct intel_load_detect_pipe *old);306307extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB);308extern int intel_sdvo_supports_hotplug(struct drm_connector *connector);309extern void intel_sdvo_set_hotplug(struct drm_connector *connector, int enable);310extern void intelfb_restore(void);311extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,312u16 blue, int regno);313extern void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,314u16 *blue, int regno);315extern void intel_enable_clock_gating(struct drm_device *dev);316extern void ironlake_enable_drps(struct drm_device *dev);317extern void ironlake_disable_drps(struct drm_device *dev);318extern void gen6_enable_rps(struct drm_i915_private *dev_priv);319extern void gen6_disable_rps(struct drm_device *dev);320extern void intel_init_emon(struct drm_device *dev);321322extern int intel_pin_and_fence_fb_obj(struct drm_device *dev,323struct drm_i915_gem_object *obj,324struct intel_ring_buffer *pipelined);325326extern int intel_framebuffer_init(struct drm_device *dev,327struct intel_framebuffer *ifb,328struct drm_mode_fb_cmd *mode_cmd,329struct drm_i915_gem_object *obj);330extern int intel_fbdev_init(struct drm_device *dev);331extern void intel_fbdev_fini(struct drm_device *dev);332333extern void intel_prepare_page_flip(struct drm_device *dev, int plane);334extern void intel_finish_page_flip(struct drm_device *dev, int pipe);335extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);336337extern void intel_setup_overlay(struct drm_device *dev);338extern void intel_cleanup_overlay(struct drm_device *dev);339extern int intel_overlay_switch_off(struct intel_overlay *overlay);340extern int intel_overlay_put_image(struct drm_device *dev, void *data,341struct drm_file *file_priv);342extern int intel_overlay_attrs(struct drm_device *dev, void *data,343struct drm_file *file_priv);344345extern void intel_fb_output_poll_changed(struct drm_device *dev);346extern void intel_fb_restore_mode(struct drm_device *dev);347348extern void intel_init_clock_gating(struct drm_device *dev);349#endif /* __INTEL_DRV_H__ */350351352