drm: attach an encoder.
[platform/upstream/libdrm.git] / linux-core / intel_drv.h
1 /*
2  * Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
3  * Copyright (c) 2007 Intel Corporation
4  *   Jesse Barnes <jesse.barnes@intel.com>
5  */
6 #ifndef __INTEL_DRV_H__
7 #define __INTEL_DRV_H__
8
9 #include <linux/i2c.h>
10 #include <linux/i2c-id.h>
11 #include <linux/i2c-algo-bit.h>
12 #include "drm_crtc.h"
13
14 #include "drm_crtc_helper.h"
15 /*
16  * Display related stuff
17  */
18
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 */
22 #define MAX_OUTPUTS 6
23
24 #define INTEL_I2C_BUS_DVO 1
25 #define INTEL_I2C_BUS_SDVO 2
26
27 /* these are outputs from the chip - integrated only 
28    external chips are via DVO or SDVO output */
29 #define INTEL_OUTPUT_UNUSED 0
30 #define INTEL_OUTPUT_ANALOG 1
31 #define INTEL_OUTPUT_DVO 2
32 #define INTEL_OUTPUT_SDVO 3
33 #define INTEL_OUTPUT_LVDS 4
34 #define INTEL_OUTPUT_TVOUT 5
35
36 #define INTEL_DVO_CHIP_NONE 0
37 #define INTEL_DVO_CHIP_LVDS 1
38 #define INTEL_DVO_CHIP_TMDS 2
39 #define INTEL_DVO_CHIP_TVOUT 4
40
41 struct intel_i2c_chan {
42         struct drm_device *drm_dev; /* for getting at dev. private (mmio etc.) */
43         u32 reg; /* GPIO reg */
44         struct i2c_adapter adapter;
45         struct i2c_algo_bit_data algo;
46         u8 slave_addr;
47 };
48
49 struct intel_output {
50         struct drm_output base;
51
52         struct drm_encoder enc;
53         int type;
54         struct intel_i2c_chan *i2c_bus; /* for control functions */
55         struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */
56         bool load_detect_temp;
57         void *dev_priv;
58 };
59
60 struct intel_crtc {
61         struct drm_crtc base;
62         int pipe;
63         int plane;
64         uint32_t cursor_addr;
65         u8 lut_r[256], lut_g[256], lut_b[256];
66         int dpms_mode;
67 };
68
69 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
70 #define to_intel_output(x) container_of(x, struct intel_output, base)
71
72 struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg,
73                                         const char *name);
74 void intel_i2c_destroy(struct intel_i2c_chan *chan);
75 int intel_ddc_get_modes(struct drm_output *output);
76 extern bool intel_ddc_probe(struct drm_output *output);
77
78 extern void intel_crt_init(struct drm_device *dev);
79 extern void intel_sdvo_init(struct drm_device *dev, int output_device);
80 extern void intel_dvo_init(struct drm_device *dev);
81 extern void intel_tv_init(struct drm_device *dev);
82 extern void intel_lvds_init(struct drm_device *dev);
83
84 extern void intel_crtc_load_lut(struct drm_crtc *crtc);
85 extern void intel_output_prepare (struct drm_output *output);
86 extern void intel_output_commit (struct drm_output *output);
87 extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
88                                                     struct drm_crtc *crtc);
89 extern void intel_wait_for_vblank(struct drm_device *dev);
90 extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe);
91 extern struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output,
92                                                    struct drm_display_mode *mode,
93                                                    int *dpms_mode);
94 extern void intel_release_load_detect_pipe(struct drm_output *output,
95                                            int dpms_mode);
96
97 extern struct drm_output* intel_sdvo_find(struct drm_device *dev, int sdvoB);
98 extern int intel_sdvo_supports_hotplug(struct drm_output *output);
99 extern void intel_sdvo_set_hotplug(struct drm_output *output, int enable);
100
101 extern int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc, struct drm_output *output);
102 extern int intelfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
103 extern int intelfb_resize(struct drm_device *dev, struct drm_crtc *crtc);
104
105 #endif /* __INTEL_DRV_H__ */