2 * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 #ifndef _GVT_DISPLAY_H_
36 #define _GVT_DISPLAY_H_
38 #include <linux/types.h>
39 #include <linux/hrtimer.h>
44 #define SBI_REG_MAX 20
45 #define DPCD_SIZE 0x700
47 #define intel_vgpu_port(vgpu, port) \
48 (&(vgpu->display.ports[port]))
50 #define intel_vgpu_has_monitor_on_port(vgpu, port) \
51 (intel_vgpu_port(vgpu, port)->edid && \
52 intel_vgpu_port(vgpu, port)->edid->data_valid)
54 #define intel_vgpu_port_is_dp(vgpu, port) \
55 ((intel_vgpu_port(vgpu, port)->type == GVT_DP_A) || \
56 (intel_vgpu_port(vgpu, port)->type == GVT_DP_B) || \
57 (intel_vgpu_port(vgpu, port)->type == GVT_DP_C) || \
58 (intel_vgpu_port(vgpu, port)->type == GVT_DP_D))
60 #define INTEL_GVT_MAX_UEVENT_VARS 3
62 #define AUX_NATIVE_REPLY_NAK (0x1 << 4)
64 #define AUX_BURST_SIZE 20
66 #define SBI_RESPONSE_MASK 0x3
67 #define SBI_RESPONSE_SHIFT 0x1
68 #define SBI_STAT_MASK 0x1
69 #define SBI_STAT_SHIFT 0x0
70 #define SBI_OPCODE_SHIFT 8
71 #define SBI_OPCODE_MASK (0xff << SBI_OPCODE_SHIFT)
72 #define SBI_CMD_IORD 2
73 #define SBI_CMD_IOWR 3
74 #define SBI_CMD_CRRD 6
75 #define SBI_CMD_CRWR 7
76 #define SBI_ADDR_OFFSET_SHIFT 16
77 #define SBI_ADDR_OFFSET_MASK (0xffff << SBI_ADDR_OFFSET_SHIFT)
79 struct intel_vgpu_sbi_register {
84 struct intel_vgpu_sbi {
86 struct intel_vgpu_sbi_register registers[SBI_REG_MAX];
89 enum intel_gvt_plane_type {
96 struct intel_vgpu_dpcd_data {
101 enum intel_vgpu_port_type {
113 enum intel_vgpu_edid {
119 #define GVT_DEFAULT_REFRESH_RATE 60
120 struct intel_vgpu_port {
121 /* per display EDID information */
122 struct intel_vgpu_edid_data *edid;
123 /* per display DPCD information */
124 struct intel_vgpu_dpcd_data *dpcd;
126 enum intel_vgpu_edid id;
127 /* x1000 to get accurate 59.94, 24.976, 29.94, etc. in timing std. */
131 struct intel_vgpu_vblank_timer {
132 struct hrtimer timer;
137 static inline char *vgpu_edid_str(enum intel_vgpu_edid id)
140 case GVT_EDID_1024_768:
142 case GVT_EDID_1920_1200:
149 static inline unsigned int vgpu_edid_xres(enum intel_vgpu_edid id)
152 case GVT_EDID_1024_768:
154 case GVT_EDID_1920_1200:
161 static inline unsigned int vgpu_edid_yres(enum intel_vgpu_edid id)
164 case GVT_EDID_1024_768:
166 case GVT_EDID_1920_1200:
173 void intel_vgpu_emulate_vblank(struct intel_vgpu *vgpu);
174 void vgpu_update_vblank_emulation(struct intel_vgpu *vgpu, bool turnon);
176 int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 resolution);
177 void intel_vgpu_reset_display(struct intel_vgpu *vgpu);
178 void intel_vgpu_clean_display(struct intel_vgpu *vgpu);
180 int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe);