Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / gvt / edid.h
blobdfe0cbc6aad85ca3a6f190df1b2c3d890a0ef793
1 /*
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
13 * Software.
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
21 * SOFTWARE.
23 * Authors:
24 * Ke Yu
25 * Zhiyuan Lv <zhiyuan.lv@intel.com>
27 * Contributors:
28 * Terrence Xu <terrence.xu@intel.com>
29 * Changbin Du <changbin.du@intel.com>
30 * Bing Niu <bing.niu@intel.com>
31 * Zhi Wang <zhi.a.wang@intel.com>
35 #ifndef _GVT_EDID_H_
36 #define _GVT_EDID_H_
38 #include <linux/types.h>
40 struct intel_vgpu;
42 #define EDID_SIZE 128
43 #define EDID_ADDR 0x50 /* Linux hvm EDID addr */
45 #define GVT_AUX_NATIVE_WRITE 0x8
46 #define GVT_AUX_NATIVE_READ 0x9
47 #define GVT_AUX_I2C_WRITE 0x0
48 #define GVT_AUX_I2C_READ 0x1
49 #define GVT_AUX_I2C_STATUS 0x2
50 #define GVT_AUX_I2C_MOT 0x4
51 #define GVT_AUX_I2C_REPLY_ACK 0x0
53 struct intel_vgpu_edid_data {
54 bool data_valid;
55 unsigned char edid_block[EDID_SIZE];
58 enum gmbus_cycle_type {
59 GMBUS_NOCYCLE = 0x0,
60 NIDX_NS_W = 0x1,
61 IDX_NS_W = 0x3,
62 GMBUS_STOP = 0x4,
63 NIDX_STOP = 0x5,
64 IDX_STOP = 0x7
68 * States of GMBUS
70 * GMBUS0-3 could be related to the EDID virtualization. Another two GMBUS
71 * registers, GMBUS4 (interrupt mask) and GMBUS5 (2 byte indes register), are
72 * not considered here. Below describes the usage of GMBUS registers that are
73 * cared by the EDID virtualization
75 * GMBUS0:
76 * R/W
77 * port selection. value of bit0 - bit2 corresponds to the GPIO registers.
79 * GMBUS1:
80 * R/W Protect
81 * Command and Status.
82 * bit0 is the direction bit: 1 is read; 0 is write.
83 * bit1 - bit7 is slave 7-bit address.
84 * bit16 - bit24 total byte count (ignore?)
86 * GMBUS2:
87 * Most of bits are read only except bit 15 (IN_USE)
88 * Status register
89 * bit0 - bit8 current byte count
90 * bit 11: hardware ready;
92 * GMBUS3:
93 * Read/Write
94 * Data for transfer
97 /* From hw specs, Other phases like START, ADDRESS, INDEX
98 * are invisible to GMBUS MMIO interface. So no definitions
99 * in below enum types
101 enum gvt_gmbus_phase {
102 GMBUS_IDLE_PHASE = 0,
103 GMBUS_DATA_PHASE,
104 GMBUS_WAIT_PHASE,
105 //GMBUS_STOP_PHASE,
106 GMBUS_MAX_PHASE
109 struct intel_vgpu_i2c_gmbus {
110 unsigned int total_byte_count; /* from GMBUS1 */
111 enum gmbus_cycle_type cycle_type;
112 enum gvt_gmbus_phase phase;
115 struct intel_vgpu_i2c_aux_ch {
116 bool i2c_over_aux_ch;
117 bool aux_ch_mot;
120 enum i2c_state {
121 I2C_NOT_SPECIFIED = 0,
122 I2C_GMBUS = 1,
123 I2C_AUX_CH = 2
126 /* I2C sequences cannot interleave.
127 * GMBUS and AUX_CH sequences cannot interleave.
129 struct intel_vgpu_i2c_edid {
130 enum i2c_state state;
132 unsigned int port;
133 bool slave_selected;
134 bool edid_available;
135 unsigned int current_edid_read;
137 struct intel_vgpu_i2c_gmbus gmbus;
138 struct intel_vgpu_i2c_aux_ch aux_ch;
141 void intel_vgpu_init_i2c_edid(struct intel_vgpu *vgpu);
143 int intel_gvt_i2c_handle_gmbus_read(struct intel_vgpu *vgpu,
144 unsigned int offset, void *p_data, unsigned int bytes);
146 int intel_gvt_i2c_handle_gmbus_write(struct intel_vgpu *vgpu,
147 unsigned int offset, void *p_data, unsigned int bytes);
149 void intel_gvt_i2c_handle_aux_ch_write(struct intel_vgpu *vgpu,
150 int port_idx,
151 unsigned int offset,
152 void *p_data);
154 #endif /*_GVT_EDID_H_*/