2 * Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
3 * Copyright (c) 2007 Intel Corporation
4 * Jesse Barnes <jesse.barnes@intel.com>
6 #ifndef __INTEL_DRV_H__
7 #define __INTEL_DRV_H__
10 #include <linux/i2c-id.h>
11 #include <linux/i2c-algo-bit.h>
14 #include "drm_crtc_helper.h"
16 * Display related stuff
19 /* store information about an Ixxx DVO */
20 /* The i830->i865 use multiple DVOs with multiple i2cs */
21 /* the i915, i945 have a single sDVO i2c bus - which is different */
23 /* maximum connectors per crtcs in the mode set */
24 #define INTELFB_CONN_LIMIT 4
26 #define INTEL_I2C_BUS_DVO 1
27 #define INTEL_I2C_BUS_SDVO 2
29 /* these are outputs from the chip - integrated only
30 external chips are via DVO or SDVO output */
31 #define INTEL_OUTPUT_UNUSED 0
32 #define INTEL_OUTPUT_ANALOG 1
33 #define INTEL_OUTPUT_DVO 2
34 #define INTEL_OUTPUT_SDVO 3
35 #define INTEL_OUTPUT_LVDS 4
36 #define INTEL_OUTPUT_TVOUT 5
38 #define INTEL_DVO_CHIP_NONE 0
39 #define INTEL_DVO_CHIP_LVDS 1
40 #define INTEL_DVO_CHIP_TMDS 2
41 #define INTEL_DVO_CHIP_TVOUT 4
43 struct intel_i2c_chan {
44 struct drm_device *drm_dev; /* for getting at dev. private (mmio etc.) */
45 u32 reg; /* GPIO reg */
46 struct i2c_adapter adapter;
47 struct i2c_algo_bit_data algo;
51 struct intel_framebuffer {
52 struct drm_framebuffer base;
53 struct drm_buffer_object *bo;
54 struct drm_bo_kmap_obj kmap;
59 struct drm_connector base;
61 struct drm_encoder enc;
63 struct intel_i2c_chan *i2c_bus; /* for control functions */
64 struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */
65 bool load_detect_temp;
74 u8 lut_r[256], lut_g[256], lut_b[256];
76 struct intel_framebuffer *fbdev_fb;
77 /* a mode_set for fbdev users on this crtc */
78 struct drm_mode_set mode_set;
81 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
82 #define to_intel_output(x) container_of(x, struct intel_output, base)
83 #define enc_to_intel_output(x) container_of(x, struct intel_output, enc)
84 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
86 struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg,
88 void intel_i2c_destroy(struct intel_i2c_chan *chan);
89 int intel_ddc_get_modes(struct intel_output *intel_output);
90 extern bool intel_ddc_probe(struct intel_output *intel_output);
92 extern void intel_crt_init(struct drm_device *dev);
93 extern void intel_sdvo_init(struct drm_device *dev, int output_device);
94 extern void intel_dvo_init(struct drm_device *dev);
95 extern void intel_tv_init(struct drm_device *dev);
96 extern void intel_lvds_init(struct drm_device *dev);
98 extern void intel_crtc_load_lut(struct drm_crtc *crtc);
99 extern void intel_encoder_prepare (struct drm_encoder *encoder);
100 extern void intel_encoder_commit (struct drm_encoder *encoder);
102 extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
104 extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
105 struct drm_crtc *crtc);
106 extern void intel_wait_for_vblank(struct drm_device *dev);
107 extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe);
108 extern struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output,
109 struct drm_display_mode *mode,
111 extern void intel_release_load_detect_pipe(struct intel_output *intel_output,
114 extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB);
115 extern int intel_sdvo_supports_hotplug(struct drm_connector *connector);
116 extern void intel_sdvo_set_hotplug(struct drm_connector *connector, int enable);
117 extern int intelfb_probe(struct drm_device *dev);
118 extern int intelfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
119 extern int intelfb_resize(struct drm_device *dev, struct drm_crtc *crtc);
120 extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
121 u16 blue, int regno);
123 extern struct drm_framebuffer *intel_user_framebuffer_create(struct drm_device *dev,
124 struct drm_file *file_priv,
125 struct drm_mode_fb_cmd *mode_cmd);
126 #endif /* __INTEL_DRV_H__ */