1 /*
2  * Copyright © 2006-2016 Intel Corporation
3  *
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:
10  *
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.
14  *
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.
22  *
23  * Authors:
24  *    Eric Anholt <eric@anholt.net>
25  *
26  */
27 
28 /*
29  * This information is private to VBT parsing in intel_bios.c.
30  *
31  * Please do NOT include anywhere else.
32  */
33 #ifndef _INTEL_BIOS_PRIVATE
34 #error "intel_vbt_defs.h is private to intel_bios.c"
35 #endif
36 
37 #ifndef _INTEL_VBT_DEFS_H_
38 #define _INTEL_VBT_DEFS_H_
39 
40 #include "intel_bios.h"
41 
42 /**
43  * struct vbt_header - VBT Header structure
44  * @signature:		VBT signature, always starts with "$VBT"
45  * @version:		Version of this structure
46  * @header_size:	Size of this structure
47  * @vbt_size:		Size of VBT (VBT Header, BDB Header and data blocks)
48  * @vbt_checksum:	Checksum
49  * @reserved0:		Reserved
50  * @bdb_offset:		Offset of &struct bdb_header from beginning of VBT
51  * @aim_offset:		Offsets of add-in data blocks from beginning of VBT
52  */
53 struct vbt_header {
54 	u8 signature[20];
55 	u16 version;
56 	u16 header_size;
57 	u16 vbt_size;
58 	u8 vbt_checksum;
59 	u8 reserved0;
60 	u32 bdb_offset;
61 	u32 aim_offset[4];
62 } __packed;
63 
64 /**
65  * struct bdb_header - BDB Header structure
66  * @signature:		BDB signature "BIOS_DATA_BLOCK"
67  * @version:		Version of the data block definitions
68  * @header_size:	Size of this structure
69  * @bdb_size:		Size of BDB (BDB Header and data blocks)
70  */
71 struct bdb_header {
72 	u8 signature[16];
73 	u16 version;
74 	u16 header_size;
75 	u16 bdb_size;
76 } __packed;
77 
78 /*
79  * There are several types of BIOS data blocks (BDBs), each block has
80  * an ID and size in the first 3 bytes (ID in first, size in next 2).
81  * Known types are listed below.
82  */
83 enum bdb_block_id {
84 	BDB_GENERAL_FEATURES		= 1,
85 	BDB_GENERAL_DEFINITIONS		= 2,
86 	BDB_OLD_TOGGLE_LIST		= 3,
87 	BDB_MODE_SUPPORT_LIST		= 4,
88 	BDB_GENERIC_MODE_TABLE		= 5,
89 	BDB_EXT_MMIO_REGS		= 6,
90 	BDB_SWF_IO			= 7,
91 	BDB_SWF_MMIO			= 8,
92 	BDB_PSR				= 9,
93 	BDB_MODE_REMOVAL_TABLE		= 10,
94 	BDB_CHILD_DEVICE_TABLE		= 11,
95 	BDB_DRIVER_FEATURES		= 12,
96 	BDB_DRIVER_PERSISTENCE		= 13,
97 	BDB_EXT_TABLE_PTRS		= 14,
98 	BDB_DOT_CLOCK_OVERRIDE		= 15,
99 	BDB_DISPLAY_SELECT		= 16,
100 	BDB_DRIVER_ROTATION		= 18,
101 	BDB_DISPLAY_REMOVE		= 19,
102 	BDB_OEM_CUSTOM			= 20,
103 	BDB_EFP_LIST			= 21, /* workarounds for VGA hsync/vsync */
104 	BDB_SDVO_LVDS_OPTIONS		= 22,
105 	BDB_SDVO_PANEL_DTDS		= 23,
106 	BDB_SDVO_LVDS_PNP_IDS		= 24,
107 	BDB_SDVO_LVDS_POWER_SEQ		= 25,
108 	BDB_TV_OPTIONS			= 26,
109 	BDB_EDP				= 27,
110 	BDB_LVDS_OPTIONS		= 40,
111 	BDB_LVDS_LFP_DATA_PTRS		= 41,
112 	BDB_LVDS_LFP_DATA		= 42,
113 	BDB_LVDS_BACKLIGHT		= 43,
114 	BDB_LFP_POWER			= 44,
115 	BDB_MIPI_CONFIG			= 52,
116 	BDB_MIPI_SEQUENCE		= 53,
117 	BDB_COMPRESSION_PARAMETERS	= 56,
118 	BDB_GENERIC_DTD			= 58,
119 	BDB_SKIP			= 254, /* VBIOS private block, ignore */
120 };
121 
122 /*
123  * Block 1 - General Bit Definitions
124  */
125 
126 struct bdb_general_features {
127         /* bits 1 */
128 	u8 panel_fitting:2;
129 	u8 flexaim:1;
130 	u8 msg_enable:1;
131 	u8 clear_screen:3;
132 	u8 color_flip:1;
133 
134         /* bits 2 */
135 	u8 download_ext_vbt:1;
136 	u8 enable_ssc:1;
137 	u8 ssc_freq:1;
138 	u8 enable_lfp_on_override:1;
139 	u8 disable_ssc_ddt:1;
140 	u8 underscan_vga_timings:1;
141 	u8 display_clock_mode:1;
142 	u8 vbios_hotplug_support:1;
143 
144         /* bits 3 */
145 	u8 disable_smooth_vision:1;
146 	u8 single_dvi:1;
147 	u8 rotate_180:1;					/* 181 */
148 	u8 fdi_rx_polarity_inverted:1;
149 	u8 vbios_extended_mode:1;				/* 160 */
150 	u8 copy_ilfp_dtd_to_sdvo_lvds_dtd:1;			/* 160 */
151 	u8 panel_best_fit_timing:1;				/* 160 */
152 	u8 ignore_strap_state:1;				/* 160 */
153 
154         /* bits 4 */
155 	u8 legacy_monitor_detect;
156 
157         /* bits 5 */
158 	u8 int_crt_support:1;
159 	u8 int_tv_support:1;
160 	u8 int_efp_support:1;
161 	u8 dp_ssc_enable:1;	/* PCH attached eDP supports SSC */
162 	u8 dp_ssc_freq:1;	/* SSC freq for PCH attached eDP */
163 	u8 dp_ssc_dongle_supported:1;
164 	u8 rsvd11:2; /* finish byte */
165 } __packed;
166 
167 /*
168  * Block 2 - General Bytes Definition
169  */
170 
171 /* pre-915 */
172 #define GPIO_PIN_DVI_LVDS	0x03 /* "DVI/LVDS DDC GPIO pins" */
173 #define GPIO_PIN_ADD_I2C	0x05 /* "ADDCARD I2C GPIO pins" */
174 #define GPIO_PIN_ADD_DDC	0x04 /* "ADDCARD DDC GPIO pins" */
175 #define GPIO_PIN_ADD_DDC_I2C	0x06 /* "ADDCARD DDC/I2C GPIO pins" */
176 
177 /* Pre 915 */
178 #define DEVICE_TYPE_NONE	0x00
179 #define DEVICE_TYPE_CRT		0x01
180 #define DEVICE_TYPE_TV		0x09
181 #define DEVICE_TYPE_EFP		0x12
182 #define DEVICE_TYPE_LFP		0x22
183 /* On 915+ */
184 #define DEVICE_TYPE_CRT_DPMS		0x6001
185 #define DEVICE_TYPE_CRT_DPMS_HOTPLUG	0x4001
186 #define DEVICE_TYPE_TV_COMPOSITE	0x0209
187 #define DEVICE_TYPE_TV_MACROVISION	0x0289
188 #define DEVICE_TYPE_TV_RF_COMPOSITE	0x020c
189 #define DEVICE_TYPE_TV_SVIDEO_COMPOSITE	0x0609
190 #define DEVICE_TYPE_TV_SCART		0x0209
191 #define DEVICE_TYPE_TV_CODEC_HOTPLUG_PWR 0x6009
192 #define DEVICE_TYPE_EFP_HOTPLUG_PWR	0x6012
193 #define DEVICE_TYPE_EFP_DVI_HOTPLUG_PWR	0x6052
194 #define DEVICE_TYPE_EFP_DVI_I		0x6053
195 #define DEVICE_TYPE_EFP_DVI_D_DUAL	0x6152
196 #define DEVICE_TYPE_EFP_DVI_D_HDCP	0x60d2
197 #define DEVICE_TYPE_OPENLDI_HOTPLUG_PWR	0x6062
198 #define DEVICE_TYPE_OPENLDI_DUALPIX	0x6162
199 #define DEVICE_TYPE_LFP_PANELLINK	0x5012
200 #define DEVICE_TYPE_LFP_CMOS_PWR	0x5042
201 #define DEVICE_TYPE_LFP_LVDS_PWR	0x5062
202 #define DEVICE_TYPE_LFP_LVDS_DUAL	0x5162
203 #define DEVICE_TYPE_LFP_LVDS_DUAL_HDCP	0x51e2
204 
205 /* Add the device class for LFP, TV, HDMI */
206 #define DEVICE_TYPE_INT_LFP		0x1022
207 #define DEVICE_TYPE_INT_TV		0x1009
208 #define DEVICE_TYPE_HDMI		0x60D2
209 #define DEVICE_TYPE_DP			0x68C6
210 #define DEVICE_TYPE_DP_DUAL_MODE	0x60D6
211 #define DEVICE_TYPE_eDP			0x78C6
212 
213 #define DEVICE_TYPE_CLASS_EXTENSION	(1 << 15)
214 #define DEVICE_TYPE_POWER_MANAGEMENT	(1 << 14)
215 #define DEVICE_TYPE_HOTPLUG_SIGNALING	(1 << 13)
216 #define DEVICE_TYPE_INTERNAL_CONNECTOR	(1 << 12)
217 #define DEVICE_TYPE_NOT_HDMI_OUTPUT	(1 << 11)
218 #define DEVICE_TYPE_MIPI_OUTPUT		(1 << 10)
219 #define DEVICE_TYPE_COMPOSITE_OUTPUT	(1 << 9)
220 #define DEVICE_TYPE_DUAL_CHANNEL	(1 << 8)
221 #define DEVICE_TYPE_HIGH_SPEED_LINK	(1 << 6)
222 #define DEVICE_TYPE_LVDS_SIGNALING	(1 << 5)
223 #define DEVICE_TYPE_TMDS_DVI_SIGNALING	(1 << 4)
224 #define DEVICE_TYPE_VIDEO_SIGNALING	(1 << 3)
225 #define DEVICE_TYPE_DISPLAYPORT_OUTPUT	(1 << 2)
226 #define DEVICE_TYPE_DIGITAL_OUTPUT	(1 << 1)
227 #define DEVICE_TYPE_ANALOG_OUTPUT	(1 << 0)
228 
229 /*
230  * Bits we care about when checking for DEVICE_TYPE_eDP. Depending on the
231  * system, the other bits may or may not be set for eDP outputs.
232  */
233 #define DEVICE_TYPE_eDP_BITS \
234 	(DEVICE_TYPE_INTERNAL_CONNECTOR |	\
235 	 DEVICE_TYPE_MIPI_OUTPUT |		\
236 	 DEVICE_TYPE_COMPOSITE_OUTPUT |		\
237 	 DEVICE_TYPE_DUAL_CHANNEL |		\
238 	 DEVICE_TYPE_LVDS_SIGNALING |		\
239 	 DEVICE_TYPE_TMDS_DVI_SIGNALING |	\
240 	 DEVICE_TYPE_VIDEO_SIGNALING |		\
241 	 DEVICE_TYPE_DISPLAYPORT_OUTPUT |	\
242 	 DEVICE_TYPE_ANALOG_OUTPUT)
243 
244 #define DEVICE_TYPE_DP_DUAL_MODE_BITS \
245 	(DEVICE_TYPE_INTERNAL_CONNECTOR |	\
246 	 DEVICE_TYPE_MIPI_OUTPUT |		\
247 	 DEVICE_TYPE_COMPOSITE_OUTPUT |		\
248 	 DEVICE_TYPE_LVDS_SIGNALING |		\
249 	 DEVICE_TYPE_TMDS_DVI_SIGNALING |	\
250 	 DEVICE_TYPE_VIDEO_SIGNALING |		\
251 	 DEVICE_TYPE_DISPLAYPORT_OUTPUT |	\
252 	 DEVICE_TYPE_DIGITAL_OUTPUT |		\
253 	 DEVICE_TYPE_ANALOG_OUTPUT)
254 
255 #define DEVICE_CFG_NONE		0x00
256 #define DEVICE_CFG_12BIT_DVOB	0x01
257 #define DEVICE_CFG_12BIT_DVOC	0x02
258 #define DEVICE_CFG_24BIT_DVOBC	0x09
259 #define DEVICE_CFG_24BIT_DVOCB	0x0a
260 #define DEVICE_CFG_DUAL_DVOB	0x11
261 #define DEVICE_CFG_DUAL_DVOC	0x12
262 #define DEVICE_CFG_DUAL_DVOBC	0x13
263 #define DEVICE_CFG_DUAL_LINK_DVOBC	0x19
264 #define DEVICE_CFG_DUAL_LINK_DVOCB	0x1a
265 
266 #define DEVICE_WIRE_NONE	0x00
267 #define DEVICE_WIRE_DVOB	0x01
268 #define DEVICE_WIRE_DVOC	0x02
269 #define DEVICE_WIRE_DVOBC	0x03
270 #define DEVICE_WIRE_DVOBB	0x05
271 #define DEVICE_WIRE_DVOCC	0x06
272 #define DEVICE_WIRE_DVOB_MASTER 0x0d
273 #define DEVICE_WIRE_DVOC_MASTER 0x0e
274 
275 /* dvo_port pre BDB 155 */
276 #define DEVICE_PORT_DVOA	0x00 /* none on 845+ */
277 #define DEVICE_PORT_DVOB	0x01
278 #define DEVICE_PORT_DVOC	0x02
279 
280 /* dvo_port BDB 155+ */
281 #define DVO_PORT_HDMIA		0
282 #define DVO_PORT_HDMIB		1
283 #define DVO_PORT_HDMIC		2
284 #define DVO_PORT_HDMID		3
285 #define DVO_PORT_LVDS		4
286 #define DVO_PORT_TV		5
287 #define DVO_PORT_CRT		6
288 #define DVO_PORT_DPB		7
289 #define DVO_PORT_DPC		8
290 #define DVO_PORT_DPD		9
291 #define DVO_PORT_DPA		10
292 #define DVO_PORT_DPE		11				/* 193 */
293 #define DVO_PORT_HDMIE		12				/* 193 */
294 #define DVO_PORT_DPF		13				/* N/A */
295 #define DVO_PORT_HDMIF		14				/* N/A */
296 #define DVO_PORT_DPG		15				/* 217 */
297 #define DVO_PORT_HDMIG		16				/* 217 */
298 #define DVO_PORT_DPH		17				/* 217 */
299 #define DVO_PORT_HDMIH		18				/* 217 */
300 #define DVO_PORT_DPI		19				/* 217 */
301 #define DVO_PORT_HDMII		20				/* 217 */
302 #define DVO_PORT_MIPIA		21				/* 171 */
303 #define DVO_PORT_MIPIB		22				/* 171 */
304 #define DVO_PORT_MIPIC		23				/* 171 */
305 #define DVO_PORT_MIPID		24				/* 171 */
306 
307 #define HDMI_MAX_DATA_RATE_PLATFORM	0			/* 204 */
308 #define HDMI_MAX_DATA_RATE_297		1			/* 204 */
309 #define HDMI_MAX_DATA_RATE_165		2			/* 204 */
310 
311 #define LEGACY_CHILD_DEVICE_CONFIG_SIZE		33
312 
313 /* DDC Bus DDI Type 155+ */
314 enum vbt_gmbus_ddi {
315 	DDC_BUS_DDI_B = 0x1,
316 	DDC_BUS_DDI_C,
317 	DDC_BUS_DDI_D,
318 	DDC_BUS_DDI_F,
319 	ICL_DDC_BUS_DDI_A = 0x1,
320 	ICL_DDC_BUS_DDI_B,
321 	TGL_DDC_BUS_DDI_C,
322 	RKL_DDC_BUS_DDI_D = 0x3,
323 	RKL_DDC_BUS_DDI_E,
324 	ICL_DDC_BUS_PORT_1 = 0x4,
325 	ICL_DDC_BUS_PORT_2,
326 	ICL_DDC_BUS_PORT_3,
327 	ICL_DDC_BUS_PORT_4,
328 	TGL_DDC_BUS_PORT_5,
329 	TGL_DDC_BUS_PORT_6,
330 	ADLS_DDC_BUS_PORT_TC1 = 0x2,
331 	ADLS_DDC_BUS_PORT_TC2,
332 	ADLS_DDC_BUS_PORT_TC3,
333 	ADLS_DDC_BUS_PORT_TC4,
334 	ADLP_DDC_BUS_PORT_TC1 = 0x3,
335 	ADLP_DDC_BUS_PORT_TC2,
336 	ADLP_DDC_BUS_PORT_TC3,
337 	ADLP_DDC_BUS_PORT_TC4
338 
339 };
340 
341 #define DP_AUX_A 0x40
342 #define DP_AUX_B 0x10
343 #define DP_AUX_C 0x20
344 #define DP_AUX_D 0x30
345 #define DP_AUX_E 0x50
346 #define DP_AUX_F 0x60
347 #define DP_AUX_G 0x70
348 #define DP_AUX_H 0x80
349 #define DP_AUX_I 0x90
350 
351 /* DP max link rate 216+ */
352 #define BDB_216_VBT_DP_MAX_LINK_RATE_HBR3	0
353 #define BDB_216_VBT_DP_MAX_LINK_RATE_HBR2	1
354 #define BDB_216_VBT_DP_MAX_LINK_RATE_HBR	2
355 #define BDB_216_VBT_DP_MAX_LINK_RATE_LBR	3
356 
357 /* DP max link rate 230+ */
358 #define BDB_230_VBT_DP_MAX_LINK_RATE_DEF	0
359 #define BDB_230_VBT_DP_MAX_LINK_RATE_LBR	1
360 #define BDB_230_VBT_DP_MAX_LINK_RATE_HBR	2
361 #define BDB_230_VBT_DP_MAX_LINK_RATE_HBR2	3
362 #define BDB_230_VBT_DP_MAX_LINK_RATE_HBR3	4
363 #define BDB_230_VBT_DP_MAX_LINK_RATE_UHBR10	5
364 #define BDB_230_VBT_DP_MAX_LINK_RATE_UHBR13P5	6
365 #define BDB_230_VBT_DP_MAX_LINK_RATE_UHBR20	7
366 
367 /*
368  * The child device config, aka the display device data structure, provides a
369  * description of a port and its configuration on the platform.
370  *
371  * The child device config size has been increased, and fields have been added
372  * and their meaning has changed over time. Care must be taken when accessing
373  * basically any of the fields to ensure the correct interpretation for the BDB
374  * version in question.
375  *
376  * When we copy the child device configs to dev_priv->vbt.child_dev, we reserve
377  * space for the full structure below, and initialize the tail not actually
378  * present in VBT to zeros. Accessing those fields is fine, as long as the
379  * default zero is taken into account, again according to the BDB version.
380  *
381  * BDB versions 155 and below are considered legacy, and version 155 seems to be
382  * a baseline for some of the VBT documentation. When adding new fields, please
383  * include the BDB version when the field was added, if it's above that.
384  */
385 struct child_device_config {
386 	u16 handle;
387 	u16 device_type; /* See DEVICE_TYPE_* above */
388 
389 	union {
390 		u8  device_id[10]; /* ascii string */
391 		struct {
392 			u8 i2c_speed;
393 			u8 dp_onboard_redriver;			/* 158 */
394 			u8 dp_ondock_redriver;			/* 158 */
395 			u8 hdmi_level_shifter_value:5;		/* 169 */
396 			u8 hdmi_max_data_rate:3;		/* 204 */
397 			u16 dtd_buf_ptr;			/* 161 */
398 			u8 edidless_efp:1;			/* 161 */
399 			u8 compression_enable:1;		/* 198 */
400 			u8 compression_method_cps:1;		/* 198 */
401 			u8 ganged_edp:1;			/* 202 */
402 			u8 reserved0:4;
403 			u8 compression_structure_index:4;	/* 198 */
404 			u8 reserved1:4;
405 			u8 slave_port;				/* 202 */
406 			u8 reserved2;
407 		} __packed;
408 	} __packed;
409 
410 	u16 addin_offset;
411 	u8 dvo_port; /* See DEVICE_PORT_* and DVO_PORT_* above */
412 	u8 i2c_pin;
413 	u8 slave_addr;
414 	u8 ddc_pin;
415 	u16 edid_ptr;
416 	u8 dvo_cfg; /* See DEVICE_CFG_* above */
417 
418 	union {
419 		struct {
420 			u8 dvo2_port;
421 			u8 i2c2_pin;
422 			u8 slave2_addr;
423 			u8 ddc2_pin;
424 		} __packed;
425 		struct {
426 			u8 efp_routed:1;			/* 158 */
427 			u8 lane_reversal:1;			/* 184 */
428 			u8 lspcon:1;				/* 192 */
429 			u8 iboost:1;				/* 196 */
430 			u8 hpd_invert:1;			/* 196 */
431 			u8 use_vbt_vswing:1;			/* 218 */
432 			u8 flag_reserved:2;
433 			u8 hdmi_support:1;			/* 158 */
434 			u8 dp_support:1;			/* 158 */
435 			u8 tmds_support:1;			/* 158 */
436 			u8 support_reserved:5;
437 			u8 aux_channel;
438 			u8 dongle_detect;
439 		} __packed;
440 	} __packed;
441 
442 	u8 pipe_cap:2;
443 	u8 sdvo_stall:1;					/* 158 */
444 	u8 hpd_status:2;
445 	u8 integrated_encoder:1;
446 	u8 capabilities_reserved:2;
447 	u8 dvo_wiring; /* See DEVICE_WIRE_* above */
448 
449 	union {
450 		u8 dvo2_wiring;
451 		u8 mipi_bridge_type;				/* 171 */
452 	} __packed;
453 
454 	u16 extended_type;
455 	u8 dvo_function;
456 	u8 dp_usb_type_c:1;					/* 195 */
457 	u8 tbt:1;						/* 209 */
458 	u8 flags2_reserved:2;					/* 195 */
459 	u8 dp_port_trace_length:4;				/* 209 */
460 	u8 dp_gpio_index;					/* 195 */
461 	u16 dp_gpio_pin_num;					/* 195 */
462 	u8 dp_iboost_level:4;					/* 196 */
463 	u8 hdmi_iboost_level:4;					/* 196 */
464 	u8 dp_max_link_rate:3;					/* 216/230 GLK+ */
465 	u8 dp_max_link_rate_reserved:5;				/* 216/230 */
466 } __packed;
467 
468 struct bdb_general_definitions {
469 	/* DDC GPIO */
470 	u8 crt_ddc_gmbus_pin;
471 
472 	/* DPMS bits */
473 	u8 dpms_acpi:1;
474 	u8 skip_boot_crt_detect:1;
475 	u8 dpms_aim:1;
476 	u8 rsvd1:5; /* finish byte */
477 
478 	/* boot device bits */
479 	u8 boot_display[2];
480 	u8 child_dev_size;
481 
482 	/*
483 	 * Device info:
484 	 * If TV is present, it'll be at devices[0].
485 	 * LVDS will be next, either devices[0] or [1], if present.
486 	 * On some platforms the number of device is 6. But could be as few as
487 	 * 4 if both TV and LVDS are missing.
488 	 * And the device num is related with the size of general definition
489 	 * block. It is obtained by using the following formula:
490 	 * number = (block_size - sizeof(bdb_general_definitions))/
491 	 *	     defs->child_dev_size;
492 	 */
493 	u8 devices[];
494 } __packed;
495 
496 /*
497  * Block 9 - SRD Feature Block
498  */
499 
500 struct psr_table {
501 	/* Feature bits */
502 	u8 full_link:1;
503 	u8 require_aux_to_wakeup:1;
504 	u8 feature_bits_rsvd:6;
505 
506 	/* Wait times */
507 	u8 idle_frames:4;
508 	u8 lines_to_wait:3;
509 	u8 wait_times_rsvd:1;
510 
511 	/* TP wake up time in multiple of 100 */
512 	u16 tp1_wakeup_time;
513 	u16 tp2_tp3_wakeup_time;
514 } __packed;
515 
516 struct bdb_psr {
517 	struct psr_table psr_table[16];
518 
519 	/* PSR2 TP2/TP3 wakeup time for 16 panels */
520 	u32 psr2_tp2_tp3_wakeup_time;
521 } __packed;
522 
523 /*
524  * Block 12 - Driver Features Data Block
525  */
526 
527 #define BDB_DRIVER_FEATURE_NO_LVDS		0
528 #define BDB_DRIVER_FEATURE_INT_LVDS		1
529 #define BDB_DRIVER_FEATURE_SDVO_LVDS		2
530 #define BDB_DRIVER_FEATURE_INT_SDVO_LVDS	3
531 
532 struct bdb_driver_features {
533 	u8 boot_dev_algorithm:1;
534 	u8 block_display_switch:1;
535 	u8 allow_display_switch:1;
536 	u8 hotplug_dvo:1;
537 	u8 dual_view_zoom:1;
538 	u8 int15h_hook:1;
539 	u8 sprite_in_clone:1;
540 	u8 primary_lfp_id:1;
541 
542 	u16 boot_mode_x;
543 	u16 boot_mode_y;
544 	u8 boot_mode_bpp;
545 	u8 boot_mode_refresh;
546 
547 	u16 enable_lfp_primary:1;
548 	u16 selective_mode_pruning:1;
549 	u16 dual_frequency:1;
550 	u16 render_clock_freq:1; /* 0: high freq; 1: low freq */
551 	u16 nt_clone_support:1;
552 	u16 power_scheme_ui:1; /* 0: CUI; 1: 3rd party */
553 	u16 sprite_display_assign:1; /* 0: secondary; 1: primary */
554 	u16 cui_aspect_scaling:1;
555 	u16 preserve_aspect_ratio:1;
556 	u16 sdvo_device_power_down:1;
557 	u16 crt_hotplug:1;
558 	u16 lvds_config:2;
559 	u16 tv_hotplug:1;
560 	u16 hdmi_config:2;
561 
562 	u8 static_display:1;
563 	u8 reserved2:7;
564 	u16 legacy_crt_max_x;
565 	u16 legacy_crt_max_y;
566 	u8 legacy_crt_max_refresh;
567 
568 	u8 hdmi_termination;
569 	u8 custom_vbt_version;
570 	/* Driver features data block */
571 	u16 rmpm_enabled:1;
572 	u16 s2ddt_enabled:1;
573 	u16 dpst_enabled:1;
574 	u16 bltclt_enabled:1;
575 	u16 adb_enabled:1;
576 	u16 drrs_enabled:1;
577 	u16 grs_enabled:1;
578 	u16 gpmt_enabled:1;
579 	u16 tbt_enabled:1;
580 	u16 psr_enabled:1;
581 	u16 ips_enabled:1;
582 	u16 reserved3:4;
583 	u16 pc_feature_valid:1;
584 } __packed;
585 
586 /*
587  * Block 22 - SDVO LVDS General Options
588  */
589 
590 struct bdb_sdvo_lvds_options {
591 	u8 panel_backlight;
592 	u8 h40_set_panel_type;
593 	u8 panel_type;
594 	u8 ssc_clk_freq;
595 	u16 als_low_trip;
596 	u16 als_high_trip;
597 	u8 sclalarcoeff_tab_row_num;
598 	u8 sclalarcoeff_tab_row_size;
599 	u8 coefficient[8];
600 	u8 panel_misc_bits_1;
601 	u8 panel_misc_bits_2;
602 	u8 panel_misc_bits_3;
603 	u8 panel_misc_bits_4;
604 } __packed;
605 
606 /*
607  * Block 23 - SDVO LVDS Panel DTDs
608  */
609 
610 struct lvds_dvo_timing {
611 	u16 clock;		/**< In 10khz */
612 	u8 hactive_lo;
613 	u8 hblank_lo;
614 	u8 hblank_hi:4;
615 	u8 hactive_hi:4;
616 	u8 vactive_lo;
617 	u8 vblank_lo;
618 	u8 vblank_hi:4;
619 	u8 vactive_hi:4;
620 	u8 hsync_off_lo;
621 	u8 hsync_pulse_width_lo;
622 	u8 vsync_pulse_width_lo:4;
623 	u8 vsync_off_lo:4;
624 	u8 vsync_pulse_width_hi:2;
625 	u8 vsync_off_hi:2;
626 	u8 hsync_pulse_width_hi:2;
627 	u8 hsync_off_hi:2;
628 	u8 himage_lo;
629 	u8 vimage_lo;
630 	u8 vimage_hi:4;
631 	u8 himage_hi:4;
632 	u8 h_border;
633 	u8 v_border;
634 	u8 rsvd1:3;
635 	u8 digital:2;
636 	u8 vsync_positive:1;
637 	u8 hsync_positive:1;
638 	u8 non_interlaced:1;
639 } __packed;
640 
641 struct bdb_sdvo_panel_dtds {
642 	struct lvds_dvo_timing dtds[4];
643 } __packed;
644 
645 /*
646  * Block 27 - eDP VBT Block
647  */
648 
649 #define EDP_18BPP	0
650 #define EDP_24BPP	1
651 #define EDP_30BPP	2
652 #define EDP_RATE_1_62	0
653 #define EDP_RATE_2_7	1
654 #define EDP_LANE_1	0
655 #define EDP_LANE_2	1
656 #define EDP_LANE_4	3
657 #define EDP_PREEMPHASIS_NONE	0
658 #define EDP_PREEMPHASIS_3_5dB	1
659 #define EDP_PREEMPHASIS_6dB	2
660 #define EDP_PREEMPHASIS_9_5dB	3
661 #define EDP_VSWING_0_4V		0
662 #define EDP_VSWING_0_6V		1
663 #define EDP_VSWING_0_8V		2
664 #define EDP_VSWING_1_2V		3
665 
666 
667 struct edp_fast_link_params {
668 	u8 rate:4;
669 	u8 lanes:4;
670 	u8 preemphasis:4;
671 	u8 vswing:4;
672 } __packed;
673 
674 struct edp_pwm_delays {
675 	u16 pwm_on_to_backlight_enable;
676 	u16 backlight_disable_to_pwm_off;
677 } __packed;
678 
679 struct edp_full_link_params {
680 	u8 preemphasis:4;
681 	u8 vswing:4;
682 } __packed;
683 
684 struct bdb_edp {
685 	struct edp_power_seq power_seqs[16];
686 	u32 color_depth;
687 	struct edp_fast_link_params fast_link_params[16];
688 	u32 sdrrs_msa_timing_delay;
689 
690 	/* ith bit indicates enabled/disabled for (i+1)th panel */
691 	u16 edp_s3d_feature;					/* 162 */
692 	u16 edp_t3_optimization;				/* 165 */
693 	u64 edp_vswing_preemph;					/* 173 */
694 	u16 fast_link_training;					/* 182 */
695 	u16 dpcd_600h_write_required;				/* 185 */
696 	struct edp_pwm_delays pwm_delays[16];			/* 186 */
697 	u16 full_link_params_provided;				/* 199 */
698 	struct edp_full_link_params full_link_params[16];	/* 199 */
699 } __packed;
700 
701 /*
702  * Block 40 - LFP Data Block
703  */
704 
705 /* Mask for DRRS / Panel Channel / SSC / BLT control bits extraction */
706 #define MODE_MASK		0x3
707 
708 struct bdb_lvds_options {
709 	u8 panel_type;
710 	u8 panel_type2;						/* 212 */
711 	/* LVDS capabilities, stored in a dword */
712 	u8 pfit_mode:2;
713 	u8 pfit_text_mode_enhanced:1;
714 	u8 pfit_gfx_mode_enhanced:1;
715 	u8 pfit_ratio_auto:1;
716 	u8 pixel_dither:1;
717 	u8 lvds_edid:1;
718 	u8 rsvd2:1;
719 	u8 rsvd4;
720 	/* LVDS Panel channel bits stored here */
721 	u32 lvds_panel_channel_bits;
722 	/* LVDS SSC (Spread Spectrum Clock) bits stored here. */
723 	u16 ssc_bits;
724 	u16 ssc_freq;
725 	u16 ssc_ddt;
726 	/* Panel color depth defined here */
727 	u16 panel_color_depth;
728 	/* LVDS panel type bits stored here */
729 	u32 dps_panel_type_bits;
730 	/* LVDS backlight control type bits stored here */
731 	u32 blt_control_type_bits;
732 
733 	u16 lcdvcc_s0_enable;					/* 200 */
734 	u32 rotation;						/* 228 */
735 } __packed;
736 
737 /*
738  * Block 41 - LFP Data Table Pointers
739  */
740 
741 /* LFP pointer table contains entries to the struct below */
742 struct lvds_lfp_data_ptr {
743 	u16 fp_timing_offset; /* offsets are from start of bdb */
744 	u8 fp_table_size;
745 	u16 dvo_timing_offset;
746 	u8 dvo_table_size;
747 	u16 panel_pnp_id_offset;
748 	u8 pnp_table_size;
749 } __packed;
750 
751 struct bdb_lvds_lfp_data_ptrs {
752 	u8 lvds_entries; /* followed by one or more lvds_data_ptr structs */
753 	struct lvds_lfp_data_ptr ptr[16];
754 } __packed;
755 
756 /*
757  * Block 42 - LFP Data Tables
758  */
759 
760 /* LFP data has 3 blocks per entry */
761 struct lvds_fp_timing {
762 	u16 x_res;
763 	u16 y_res;
764 	u32 lvds_reg;
765 	u32 lvds_reg_val;
766 	u32 pp_on_reg;
767 	u32 pp_on_reg_val;
768 	u32 pp_off_reg;
769 	u32 pp_off_reg_val;
770 	u32 pp_cycle_reg;
771 	u32 pp_cycle_reg_val;
772 	u32 pfit_reg;
773 	u32 pfit_reg_val;
774 	u16 terminator;
775 } __packed;
776 
777 struct lvds_pnp_id {
778 	u16 mfg_name;
779 	u16 product_code;
780 	u32 serial;
781 	u8 mfg_week;
782 	u8 mfg_year;
783 } __packed;
784 
785 struct lvds_lfp_data_entry {
786 	struct lvds_fp_timing fp_timing;
787 	struct lvds_dvo_timing dvo_timing;
788 	struct lvds_pnp_id pnp_id;
789 } __packed;
790 
791 struct bdb_lvds_lfp_data {
792 	struct lvds_lfp_data_entry data[16];
793 } __packed;
794 
795 /*
796  * Block 43 - LFP Backlight Control Data Block
797  */
798 
799 #define BDB_BACKLIGHT_TYPE_NONE	0
800 #define BDB_BACKLIGHT_TYPE_PWM	2
801 
802 struct lfp_backlight_data_entry {
803 	u8 type:2;
804 	u8 active_low_pwm:1;
805 	u8 obsolete1:5;
806 	u16 pwm_freq_hz;
807 	u8 min_brightness; /* Obsolete from 234+ */
808 	u8 obsolete2;
809 	u8 obsolete3;
810 } __packed;
811 
812 struct lfp_backlight_control_method {
813 	u8 type:4;
814 	u8 controller:4;
815 } __packed;
816 
817 struct lfp_brightness_level {
818 	u16 level;
819 	u16 reserved;
820 } __packed;
821 
822 #define EXP_BDB_LFP_BL_DATA_SIZE_REV_191 \
823 	offsetof(struct bdb_lfp_backlight_data, brightness_level)
824 #define EXP_BDB_LFP_BL_DATA_SIZE_REV_234 \
825 	offsetof(struct bdb_lfp_backlight_data, brightness_precision_bits)
826 
827 struct bdb_lfp_backlight_data {
828 	u8 entry_size;
829 	struct lfp_backlight_data_entry data[16];
830 	u8 level[16]; /* Obsolete from 234+ */
831 	struct lfp_backlight_control_method backlight_control[16];
832 	struct lfp_brightness_level brightness_level[16];		/* 234+ */
833 	struct lfp_brightness_level brightness_min_level[16];	/* 234+ */
834 	u8 brightness_precision_bits[16];						/* 236+ */
835 } __packed;
836 
837 /*
838  * Block 44 - LFP Power Conservation Features Block
839  */
840 
841 struct als_data_entry {
842 	u16 backlight_adjust;
843 	u16 lux;
844 } __packed;
845 
846 struct agressiveness_profile_entry {
847 	u8 dpst_agressiveness : 4;
848 	u8 lace_agressiveness : 4;
849 } __packed;
850 
851 struct bdb_lfp_power {
852 	u8 lfp_feature_bits;
853 	struct als_data_entry als[5];
854 	u8 lace_aggressiveness_profile;
855 	u16 dpst;
856 	u16 psr;
857 	u16 drrs;
858 	u16 lace_support;
859 	u16 adt;
860 	u16 dmrrs;
861 	u16 adb;
862 	u16 lace_enabled_status;
863 	struct agressiveness_profile_entry aggressivenes[16];
864 	u16 hobl; /* 232+ */
865 	u16 vrr_feature_enabled; /* 233+ */
866 } __packed;
867 
868 /*
869  * Block 52 - MIPI Configuration Block
870  */
871 
872 #define MAX_MIPI_CONFIGURATIONS	6
873 
874 struct bdb_mipi_config {
875 	struct mipi_config config[MAX_MIPI_CONFIGURATIONS];
876 	struct mipi_pps_data pps[MAX_MIPI_CONFIGURATIONS];
877 } __packed;
878 
879 /*
880  * Block 53 - MIPI Sequence Block
881  */
882 
883 struct bdb_mipi_sequence {
884 	u8 version;
885 	u8 data[]; /* up to 6 variable length blocks */
886 } __packed;
887 
888 /*
889  * Block 56 - Compression Parameters
890  */
891 
892 #define VBT_RC_BUFFER_BLOCK_SIZE_1KB	0
893 #define VBT_RC_BUFFER_BLOCK_SIZE_4KB	1
894 #define VBT_RC_BUFFER_BLOCK_SIZE_16KB	2
895 #define VBT_RC_BUFFER_BLOCK_SIZE_64KB	3
896 
897 #define VBT_DSC_LINE_BUFFER_DEPTH(vbt_value)	((vbt_value) + 8) /* bits */
898 #define VBT_DSC_MAX_BPP(vbt_value)		(6 + (vbt_value) * 2)
899 
900 struct dsc_compression_parameters_entry {
901 	u8 version_major:4;
902 	u8 version_minor:4;
903 
904 	u8 rc_buffer_block_size:2;
905 	u8 reserved1:6;
906 
907 	/*
908 	 * Buffer size in bytes:
909 	 *
910 	 * 4 ^ rc_buffer_block_size * 1024 * (rc_buffer_size + 1) bytes
911 	 */
912 	u8 rc_buffer_size;
913 	u32 slices_per_line;
914 
915 	u8 line_buffer_depth:4;
916 	u8 reserved2:4;
917 
918 	/* Flag Bits 1 */
919 	u8 block_prediction_enable:1;
920 	u8 reserved3:7;
921 
922 	u8 max_bpp; /* mapping */
923 
924 	/* Color depth capabilities */
925 	u8 reserved4:1;
926 	u8 support_8bpc:1;
927 	u8 support_10bpc:1;
928 	u8 support_12bpc:1;
929 	u8 reserved5:4;
930 
931 	u16 slice_height;
932 } __packed;
933 
934 struct bdb_compression_parameters {
935 	u16 entry_size;
936 	struct dsc_compression_parameters_entry data[16];
937 } __packed;
938 
939 /*
940  * Block 58 - Generic DTD Block
941  */
942 
943 struct generic_dtd_entry {
944 	u32 pixel_clock;
945 	u16 hactive;
946 	u16 hblank;
947 	u16 hfront_porch;
948 	u16 hsync;
949 	u16 vactive;
950 	u16 vblank;
951 	u16 vfront_porch;
952 	u16 vsync;
953 	u16 width_mm;
954 	u16 height_mm;
955 
956 	/* Flags */
957 	u8 rsvd_flags:6;
958 	u8 vsync_positive_polarity:1;
959 	u8 hsync_positive_polarity:1;
960 
961 	u8 rsvd[3];
962 } __packed;
963 
964 struct bdb_generic_dtd {
965 	u16 gdtd_size;
966 	struct generic_dtd_entry dtd[];	/* up to 24 DTD's */
967 } __packed;
968 
969 #endif /* _INTEL_VBT_DEFS_H_ */
970