mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-24 08:16:10 +00:00
Pull bios_reader program from Xorg driver
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
This commit is contained in:
parent
087d74b335
commit
97ffee66ae
1
.gitignore
vendored
1
.gitignore
vendored
@ -56,3 +56,4 @@ tools/intel_reg_write
|
||||
tools/intel_stepping
|
||||
tools/intel_audio_dump
|
||||
tools/intel_reg_read
|
||||
tools/intel_bios_reader
|
||||
|
@ -7,7 +7,8 @@ bin_PROGRAMS = \
|
||||
intel_stepping \
|
||||
intel_reg_dumper \
|
||||
intel_reg_write \
|
||||
intel_reg_read
|
||||
intel_reg_read \
|
||||
intel_bios_reader
|
||||
|
||||
intel_gpu_dump_SOURCES = \
|
||||
intel_gpu_dump.c \
|
||||
@ -19,6 +20,10 @@ intel_decode_SOURCES = \
|
||||
intel_decode.c \
|
||||
intel_decode.h
|
||||
|
||||
intel_bios_reader_SOURCES = \
|
||||
intel_bios_reader.c \
|
||||
intel_bios.h
|
||||
|
||||
LDADD = ../lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS)
|
||||
|
||||
AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(WARN_CFLAGS) \
|
||||
|
664
tools/intel_bios.h
Normal file
664
tools/intel_bios.h
Normal file
@ -0,0 +1,664 @@
|
||||
/*
|
||||
* Copyright © 2006 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _INTEL_BIOS_H_
|
||||
#define _INTEL_BIOS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct vbt_header {
|
||||
char signature[20]; /**< Always starts with 'VBT$' */
|
||||
uint16_t version; /**< decimal */
|
||||
uint16_t header_size; /**< in bytes */
|
||||
uint16_t vbt_size; /**< in bytes */
|
||||
uint8_t vbt_checksum;
|
||||
uint8_t reserved0;
|
||||
uint32_t bdb_offset; /**< from beginning of VBT */
|
||||
uint32_t aim_offset[4]; /**< from beginning of VBT */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_header {
|
||||
char signature[16]; /**< Always 'BIOS_DATA_BLOCK' */
|
||||
uint16_t version; /**< decimal */
|
||||
uint16_t header_size; /**< in bytes */
|
||||
uint16_t bdb_size; /**< in bytes */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* There are several types of BIOS data blocks (BDBs), each block has
|
||||
* an ID and size in the first 3 bytes (ID in first, size in next 2).
|
||||
* Known types are listed below.
|
||||
*/
|
||||
#define BDB_GENERAL_FEATURES 1
|
||||
#define BDB_GENERAL_DEFINITIONS 2
|
||||
#define BDB_OLD_TOGGLE_LIST 3
|
||||
#define BDB_MODE_SUPPORT_LIST 4
|
||||
#define BDB_GENERIC_MODE_TABLE 5
|
||||
#define BDB_EXT_MMIO_REGS 6
|
||||
#define BDB_SWF_IO 7
|
||||
#define BDB_SWF_MMIO 8
|
||||
#define BDB_DOT_CLOCK_TABLE 9
|
||||
#define BDB_MODE_REMOVAL_TABLE 10
|
||||
#define BDB_CHILD_DEVICE_TABLE 11
|
||||
#define BDB_DRIVER_FEATURES 12
|
||||
#define BDB_DRIVER_PERSISTENCE 13
|
||||
#define BDB_EXT_TABLE_PTRS 14
|
||||
#define BDB_DOT_CLOCK_OVERRIDE 15
|
||||
#define BDB_DISPLAY_SELECT 16
|
||||
/* 17 rsvd */
|
||||
#define BDB_DRIVER_ROTATION 18
|
||||
#define BDB_DISPLAY_REMOVE 19
|
||||
#define BDB_OEM_CUSTOM 20
|
||||
#define BDB_EFP_LIST 21 /* workarounds for VGA hsync/vsync */
|
||||
#define BDB_SDVO_LVDS_OPTIONS 22
|
||||
#define BDB_SDVO_PANEL_DTDS 23
|
||||
#define BDB_SDVO_LVDS_PNP_IDS 24
|
||||
#define BDB_SDVO_LVDS_POWER_SEQ 25
|
||||
#define BDB_TV_OPTIONS 26
|
||||
#define BDB_EDP 27
|
||||
#define BDB_LVDS_OPTIONS 40
|
||||
#define BDB_LVDS_LFP_DATA_PTRS 41
|
||||
#define BDB_LVDS_LFP_DATA 42
|
||||
#define BDB_LVDS_BACKLIGHT 43
|
||||
#define BDB_LVDS_POWER 44
|
||||
#define BDB_SKIP 254 /* VBIOS private block, ignore */
|
||||
|
||||
struct bdb_general_features {
|
||||
/* bits 1 */
|
||||
unsigned char panel_fitting:2;
|
||||
unsigned char flexaim:1;
|
||||
unsigned char msg_enable:1;
|
||||
unsigned char clear_screen:3;
|
||||
unsigned char color_flip:1;
|
||||
|
||||
/* bits 2 */
|
||||
unsigned char download_ext_vbt:1;
|
||||
unsigned char enable_ssc:1;
|
||||
unsigned char ssc_freq:1;
|
||||
unsigned char enable_lfp_on_override:1;
|
||||
unsigned char disable_ssc_ddt:1;
|
||||
unsigned char rsvd8:3; /* finish byte */
|
||||
|
||||
/* bits 3 */
|
||||
unsigned char disable_smooth_vision:1;
|
||||
unsigned char single_dvi:1;
|
||||
unsigned char rsvd9:6; /* finish byte */
|
||||
|
||||
/* bits 4 */
|
||||
unsigned char legacy_monitor_detect;
|
||||
|
||||
/* bits 5 */
|
||||
unsigned char int_crt_support:1;
|
||||
unsigned char int_tv_support:1;
|
||||
unsigned char rsvd11:6; /* finish byte */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define GPIO_PIN_NONE 0x00 /* "N/A" */
|
||||
#define GPIO_PIN_I2C 0x01 /* "I2C GPIO pins" */
|
||||
#define GPIO_PIN_CRT_DDC 0x02 /* "Analog CRT DDC GPIO pins" */
|
||||
/* 915+ */
|
||||
#define GPIO_PIN_LVDS 0x03 /* "Integrated LVDS DDC GPIO pins" */
|
||||
#define GPIO_PIN_SDVO_I2C 0x05 /* "sDVO I2C GPIO pins" */
|
||||
#define GPIO_PIN_SDVO_DDC1 0x1D /* "SDVO DDC1 GPIO pins" */
|
||||
#define GPIO_PIN_SDVO_DDC2 0x2D /* "SDVO DDC2 GPIO pins" */
|
||||
/* pre-915 */
|
||||
#define GPIO_PIN_DVI_LVDS 0x03 /* "DVI/LVDS DDC GPIO pins" */
|
||||
#define GPIO_PIN_ADD_I2C 0x05 /* "ADDCARD I2C GPIO pins" */
|
||||
#define GPIO_PIN_ADD_DDC 0x04 /* "ADDCARD DDC GPIO pins" */
|
||||
#define GPIO_PIN_ADD_DDC_I2C 0x06 /* "ADDCARD DDC/I2C GPIO pins" */
|
||||
|
||||
/* Pre 915 */
|
||||
#define DEVICE_TYPE_NONE 0x00
|
||||
#define DEVICE_TYPE_CRT 0x01
|
||||
#define DEVICE_TYPE_TV 0x09
|
||||
#define DEVICE_TYPE_EFP 0x12
|
||||
#define DEVICE_TYPE_LFP 0x22
|
||||
/* On 915+ */
|
||||
#define DEVICE_TYPE_CRT_DPMS 0x6001
|
||||
#define DEVICE_TYPE_CRT_DPMS_HOTPLUG 0x4001
|
||||
#define DEVICE_TYPE_TV_COMPOSITE 0x0209
|
||||
#define DEVICE_TYPE_TV_MACROVISION 0x0289
|
||||
#define DEVICE_TYPE_TV_RF_COMPOSITE 0x020c
|
||||
#define DEVICE_TYPE_TV_SVIDEO_COMPOSITE 0x0609
|
||||
#define DEVICE_TYPE_TV_SCART 0x0209
|
||||
#define DEVICE_TYPE_TV_CODEC_HOTPLUG_PWR 0x6009
|
||||
#define DEVICE_TYPE_EFP_HOTPLUG_PWR 0x6012
|
||||
#define DEVICE_TYPE_EFP_DVI_HOTPLUG_PWR 0x6052
|
||||
#define DEVICE_TYPE_EFP_DVI_I 0x6053
|
||||
#define DEVICE_TYPE_EFP_DVI_D_DUAL 0x6152
|
||||
#define DEVICE_TYPE_EFP_DVI_D_HDCP 0x60d2
|
||||
#define DEVICE_TYPE_OPENLDI_HOTPLUG_PWR 0x6062
|
||||
#define DEVICE_TYPE_OPENLDI_DUALPIX 0x6162
|
||||
#define DEVICE_TYPE_LFP_PANELLINK 0x5012
|
||||
#define DEVICE_TYPE_LFP_CMOS_PWR 0x5042
|
||||
#define DEVICE_TYPE_LFP_LVDS_PWR 0x5062
|
||||
#define DEVICE_TYPE_LFP_LVDS_DUAL 0x5162
|
||||
#define DEVICE_TYPE_LFP_LVDS_DUAL_HDCP 0x51e2
|
||||
|
||||
#define DEVICE_CFG_NONE 0x00
|
||||
#define DEVICE_CFG_12BIT_DVOB 0x01
|
||||
#define DEVICE_CFG_12BIT_DVOC 0x02
|
||||
#define DEVICE_CFG_24BIT_DVOBC 0x09
|
||||
#define DEVICE_CFG_24BIT_DVOCB 0x0a
|
||||
#define DEVICE_CFG_DUAL_DVOB 0x11
|
||||
#define DEVICE_CFG_DUAL_DVOC 0x12
|
||||
#define DEVICE_CFG_DUAL_DVOBC 0x13
|
||||
#define DEVICE_CFG_DUAL_LINK_DVOBC 0x19
|
||||
#define DEVICE_CFG_DUAL_LINK_DVOCB 0x1a
|
||||
|
||||
#define DEVICE_WIRE_NONE 0x00
|
||||
#define DEVICE_WIRE_DVOB 0x01
|
||||
#define DEVICE_WIRE_DVOC 0x02
|
||||
#define DEVICE_WIRE_DVOBC 0x03
|
||||
#define DEVICE_WIRE_DVOBB 0x05
|
||||
#define DEVICE_WIRE_DVOCC 0x06
|
||||
#define DEVICE_WIRE_DVOB_MASTER 0x0d
|
||||
#define DEVICE_WIRE_DVOC_MASTER 0x0e
|
||||
|
||||
#define DEVICE_PORT_DVOA 0x00 /* none on 845+ */
|
||||
#define DEVICE_PORT_DVOB 0x01
|
||||
#define DEVICE_PORT_DVOC 0x02
|
||||
|
||||
struct child_device_config {
|
||||
uint16_t handle;
|
||||
uint16_t device_type; /* See DEVICE_TYPE_* above */
|
||||
uint8_t device_id[10];
|
||||
uint16_t addin_offset;
|
||||
uint8_t dvo_port; /* See DEVICE_PORT_* above */
|
||||
uint8_t i2c_pin;
|
||||
uint8_t slave_addr;
|
||||
uint8_t ddc_pin;
|
||||
uint16_t edid_ptr;
|
||||
uint8_t dvo_cfg; /* See DEVICE_CFG_* above */
|
||||
uint8_t dvo2_port;
|
||||
uint8_t i2c2_pin;
|
||||
uint8_t slave2_addr;
|
||||
uint8_t ddc2_pin;
|
||||
uint8_t capabilities;
|
||||
uint8_t dvo_wiring; /* See DEVICE_WIRE_* above */
|
||||
uint8_t dvo2_wiring;
|
||||
uint16_t extended_type;
|
||||
uint8_t dvo_function;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_general_definitions {
|
||||
unsigned char crt_ddc_gmbus_pin; /* see GPIO_PIN_* above */
|
||||
|
||||
/* DPMS bits */
|
||||
unsigned char dpms_acpi:1;
|
||||
unsigned char skip_boot_crt_detect:1;
|
||||
unsigned char dpms_aim:1;
|
||||
unsigned char rsvd1:5; /* finish byte */
|
||||
|
||||
/* boot device bits */
|
||||
unsigned char boot_display[2];
|
||||
unsigned char child_dev_size;
|
||||
|
||||
/*
|
||||
* Device info:
|
||||
* If TV is present, it'll be at devices[0]
|
||||
* LVDS will be next, either devices[0] or [1], if present
|
||||
* Max total will be 6, but could be as few as 4 if both
|
||||
* TV and LVDS are missing, so be careful when interpreting
|
||||
* [4] and [5].
|
||||
*/
|
||||
struct child_device_config devices[0];
|
||||
/* may be another device block here on some platforms */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define DEVICE_CHILD_SIZE 7
|
||||
|
||||
struct bdb_child_devices {
|
||||
uint8_t child_structure_size;
|
||||
struct child_device_config children[DEVICE_CHILD_SIZE];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_lvds_options {
|
||||
uint8_t panel_type;
|
||||
uint8_t rsvd1;
|
||||
/* LVDS capabilities, stored in a dword */
|
||||
uint8_t pfit_mode:2;
|
||||
uint8_t pfit_text_mode_enhanced:1;
|
||||
uint8_t pfit_gfx_mode_enhanced:1;
|
||||
uint8_t pfit_ratio_auto:1;
|
||||
uint8_t pixel_dither:1;
|
||||
uint8_t lvds_edid:1;
|
||||
uint8_t rsvd2:1;
|
||||
uint8_t rsvd4;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* 915+ only */
|
||||
struct bdb_tv_features {
|
||||
/* need to verify bit ordering */
|
||||
uint16_t under_over_scan_via_yprpb:2;
|
||||
uint16_t rsvd1:10;
|
||||
uint16_t under_over_scan_via_dvi:2;
|
||||
uint16_t add_overscan_mode:1;
|
||||
uint16_t rsvd2:1;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct lvds_fp_timing {
|
||||
uint16_t x_res;
|
||||
uint16_t y_res;
|
||||
uint32_t lvds_reg;
|
||||
uint32_t lvds_reg_val;
|
||||
uint32_t pp_on_reg;
|
||||
uint32_t pp_on_reg_val;
|
||||
uint32_t pp_off_reg;
|
||||
uint32_t pp_off_reg_val;
|
||||
uint32_t pp_cycle_reg;
|
||||
uint32_t pp_cycle_reg_val;
|
||||
uint32_t pfit_reg;
|
||||
uint32_t pfit_reg_val;
|
||||
uint16_t terminator;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct lvds_dvo_timing {
|
||||
uint16_t dclk; /**< In 10khz */
|
||||
uint8_t hactive;
|
||||
uint8_t hblank;
|
||||
uint8_t high_h; /**< 7:4 = hactive 11:8, 3:0 = hblank 11:8 */
|
||||
uint8_t vactive;
|
||||
uint8_t vblank;
|
||||
uint8_t high_v; /**< 7:4 = vactive 11:8, 3:0 = vblank 11:8 */
|
||||
uint8_t hsync_off;
|
||||
uint8_t hsync_pulse_width;
|
||||
uint8_t vsync_off;
|
||||
uint8_t high_hsync_off; /**< 7:6 = hsync off 9:8 */
|
||||
uint8_t h_image;
|
||||
uint8_t v_image;
|
||||
uint8_t max_hv;
|
||||
uint8_t h_border;
|
||||
uint8_t v_border;
|
||||
uint8_t flags;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct lvds_pnp_id {
|
||||
uint16_t mfg_name;
|
||||
uint16_t product_code;
|
||||
uint32_t serial;
|
||||
uint8_t mfg_week;
|
||||
uint8_t mfg_year;
|
||||
} __attribute__ ((packed));;
|
||||
|
||||
/* LFP pointer table contains entries to the struct below */
|
||||
struct bdb_lvds_lfp_data_ptr {
|
||||
uint16_t fp_timing_offset; /* offsets are from start of bdb */
|
||||
uint8_t fp_table_size;
|
||||
uint16_t dvo_timing_offset;
|
||||
uint8_t dvo_table_size;
|
||||
uint16_t panel_pnp_id_offset;
|
||||
uint8_t pnp_table_size;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_lvds_lfp_data_ptrs {
|
||||
uint8_t lvds_entries;
|
||||
struct bdb_lvds_lfp_data_ptr ptr[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_lvds_lfp_data_entry {
|
||||
struct lvds_fp_timing fp_timing;
|
||||
struct lvds_dvo_timing dvo_timing;
|
||||
struct lvds_pnp_id pnp_id;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_lvds_lfp_data {
|
||||
struct bdb_lvds_lfp_data_entry data[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define BACKLIGHT_TYPE_NONE 0
|
||||
#define BACKLIGHT_TYPE_I2C 1
|
||||
#define BACKLIGHT_TYPE_PWM 2
|
||||
|
||||
#define BACKLIGHT_GMBUS_100KHZ 0
|
||||
#define BACKLIGHT_GMBUS_50KHZ 1
|
||||
#define BACKLIGHT_GMBUS_400KHZ 2
|
||||
#define BACKLIGHT_GMBUS_1MHZ 3
|
||||
|
||||
struct backlight_info {
|
||||
uint8_t inverter_type:2; /* see BACKLIGHT_TYPE_* above */
|
||||
uint8_t inverter_polarity:1; /* 1 means 0 is max, 255 is min */
|
||||
uint8_t gpio_pins:3; /* see GPIO_PIN_* above */
|
||||
uint8_t gmbus_speed:2;
|
||||
uint16_t pwm_frequency; /* in Hz */
|
||||
uint8_t min_brightness;
|
||||
/* Next two are only for 915+ systems */
|
||||
uint8_t i2c_addr;
|
||||
uint8_t i2c_cmd;
|
||||
} __attribute((packed));
|
||||
|
||||
struct bdb_backlight_control {
|
||||
uint8_t row_size;
|
||||
struct backlight_info lfps[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_bia {
|
||||
uint8_t bia_enable:1;
|
||||
uint8_t bia_level:3;
|
||||
uint8_t rsvd1:3;
|
||||
uint8_t als_enable:1;
|
||||
uint8_t als_response_data[20];
|
||||
} __attribute((packed));
|
||||
|
||||
struct aimdb_header {
|
||||
char signature[16];
|
||||
char oem_device[20];
|
||||
uint16_t aimdb_version;
|
||||
uint16_t aimdb_header_size;
|
||||
uint16_t aimdb_size;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct aimdb_block {
|
||||
uint8_t aimdb_id;
|
||||
uint16_t aimdb_size;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct vch_panel_data {
|
||||
uint16_t fp_timing_offset;
|
||||
uint8_t fp_timing_size;
|
||||
uint16_t dvo_timing_offset;
|
||||
uint8_t dvo_timing_size;
|
||||
uint16_t text_fitting_offset;
|
||||
uint8_t text_fitting_size;
|
||||
uint16_t graphics_fitting_offset;
|
||||
uint8_t graphics_fitting_size;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct vch_bdb_22 {
|
||||
struct aimdb_block aimdb_block;
|
||||
struct vch_panel_data panels[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define BLC_INVERTER_TYPE_NONE 0
|
||||
#define BLC_INVERTER_TYPE_I2C 1
|
||||
#define BLC_INVERTER_TYPE_PWM 2
|
||||
|
||||
#define BLC_GPIO_NONE 0
|
||||
#define BLC_GPIO_I2C 1
|
||||
#define BLC_GPIO_CRT_DDC 2
|
||||
#define BLC_GPIO_DVI_DDC 3
|
||||
#define BLC_GPIO_SDVO_I2C 5
|
||||
|
||||
struct blc_struct {
|
||||
uint8_t inverter_type:2;
|
||||
uint8_t inverter_polarity:1; /* 1 means inverted (0 = max brightness) */
|
||||
uint8_t gpio_pins:3;
|
||||
uint8_t gmbus_speed:2;
|
||||
uint16_t pwm_freq; /* in Hz */
|
||||
uint8_t min_brightness; /* (0-255) */
|
||||
uint8_t i2c_slave_addr;
|
||||
uint8_t i2c_cmd;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_lvds_backlight {
|
||||
uint8_t blcstruct_size;
|
||||
struct blc_struct panels[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_lvds_power {
|
||||
uint8_t dpst_enabled:1;
|
||||
uint8_t pwr_prefs:3;
|
||||
uint8_t rsvd1:3;
|
||||
uint8_t als_enabled:1;
|
||||
uint16_t als_backlight1;
|
||||
uint16_t als_backlight2;
|
||||
uint16_t als_backlight3;
|
||||
uint16_t als_backlight4;
|
||||
uint16_t als_backlight5;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define BDB_DRIVER_NO_LVDS 0
|
||||
#define BDB_DRIVER_INT_LVDS 1
|
||||
#define BDB_DRIVER_SDVO_LVDS 2
|
||||
#define BDB_DRIVER_EDP 3
|
||||
|
||||
struct bdb_driver_feature {
|
||||
uint8_t boot_dev_algorithm:1;
|
||||
uint8_t block_display_switch:1;
|
||||
uint8_t allow_display_switch:1;
|
||||
uint8_t hotplug_dvo:1;
|
||||
uint8_t dual_view_zoom:1;
|
||||
uint8_t int15h_hook:1;
|
||||
uint8_t sprite_in_clone:1;
|
||||
uint8_t primary_lfp_id:1;
|
||||
|
||||
uint16_t boot_mode_x;
|
||||
uint16_t boot_mode_y;
|
||||
uint8_t boot_mode_bpp;
|
||||
uint8_t boot_mode_refresh;
|
||||
|
||||
uint16_t enable_lfp_primary:1;
|
||||
uint16_t selective_mode_pruning:1;
|
||||
uint16_t dual_frequency:1;
|
||||
uint16_t render_clock_freq:1; /* 0: high freq; 1: low freq */
|
||||
uint16_t nt_clone_support:1;
|
||||
uint16_t power_scheme_ui:1; /* 0: CUI; 1: 3rd party */
|
||||
uint16_t sprite_display_assign:1; /* 0: secondary; 1: primary */
|
||||
uint16_t cui_aspect_scaling:1;
|
||||
uint16_t preserve_aspect_ratio:1;
|
||||
uint16_t sdvo_device_power_down:1;
|
||||
uint16_t crt_hotplug:1;
|
||||
uint16_t lvds_config:2;
|
||||
uint16_t reserved:3;
|
||||
|
||||
uint8_t static_display:1;
|
||||
uint8_t reserved2:7;
|
||||
uint16_t legacy_crt_max_x;
|
||||
uint16_t legacy_crt_max_y;
|
||||
uint8_t legacy_crt_max_refresh;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_sdvo_lvds_options {
|
||||
uint8_t panel_backlight;
|
||||
uint8_t h40_set_panel_type;
|
||||
uint8_t panel_type;
|
||||
uint8_t ssc_clk_freq;
|
||||
uint16_t als_low_trip;
|
||||
uint16_t als_high_trip;
|
||||
uint8_t sclalarcoeff_tab_row_num;
|
||||
uint8_t sclalarcoeff_tab_row_size;
|
||||
uint8_t coefficient[8];
|
||||
uint8_t panel_misc_bits_1;
|
||||
uint8_t panel_misc_bits_2;
|
||||
uint8_t panel_misc_bits_3;
|
||||
uint8_t panel_misc_bits_4;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define EDP_18BPP 0
|
||||
#define EDP_24BPP 1
|
||||
#define EDP_30BPP 2
|
||||
#define EDP_RATE_1_62 0
|
||||
#define EDP_RATE_2_7 1
|
||||
#define EDP_LANE_1 0
|
||||
#define EDP_LANE_2 1
|
||||
#define EDP_LANE_4 3
|
||||
#define EDP_PREEMPHASIS_NONE 0
|
||||
#define EDP_PREEMPHASIS_3_5dB 1
|
||||
#define EDP_PREEMPHASIS_6dB 2
|
||||
#define EDP_PREEMPHASIS_9_5dB 3
|
||||
#define EDP_VSWING_0_4V 0
|
||||
#define EDP_VSWING_0_6V 1
|
||||
#define EDP_VSWING_0_8V 2
|
||||
#define EDP_VSWING_1_2V 3
|
||||
|
||||
struct edp_power_seq {
|
||||
uint16_t t3;
|
||||
uint16_t t7;
|
||||
uint16_t t9;
|
||||
uint16_t t10;
|
||||
uint16_t t12;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct edp_link_params {
|
||||
uint8_t rate:4;
|
||||
uint8_t lanes:4;
|
||||
uint8_t preemphasis:4;
|
||||
uint8_t vswing:4;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bdb_edp {
|
||||
struct edp_power_seq power_seqs[16];
|
||||
uint32_t color_depth;
|
||||
uint32_t sdrrs_msa_timing_delay;
|
||||
struct edp_link_params link_params[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* Driver<->VBIOS interaction occurs through scratch bits in
|
||||
* GR18 & SWF*.
|
||||
*
|
||||
* The VBIOS/firmware will signal to the gfx driver through the ASLE interrupt
|
||||
* (visible in the interupt regs at bit 0) when it wants something done.
|
||||
*
|
||||
* Pre-965:
|
||||
* The gfx driver can make calls to the VBIOS/firmware through an SMI request,
|
||||
* generated by writing to offset 0xe0 of the device's config space (see the
|
||||
* publically available 915 PRM for details).
|
||||
*
|
||||
* 965 and above:
|
||||
* IGD OpRegion requests to the VBIOS/firmware are made using SWSCI, which can
|
||||
* be triggered by writing to offset 0xe4 (see the publically available
|
||||
* 965 graphics PRM for details).
|
||||
*/
|
||||
|
||||
/* GR18 bits are set on display switch and hotkey events */
|
||||
#define GR18_DRIVER_SWITCH_EN (1<<7) /* 0: VBIOS control, 1: driver control */
|
||||
#define GR18_HOTKEY_MASK 0x78 /* See also SWF4 15:0 */
|
||||
#define GR18_HK_NONE (0x0<<3)
|
||||
#define GR18_HK_LFP_STRETCH (0x1<<3)
|
||||
#define GR18_HK_TOGGLE_DISP (0x2<<3)
|
||||
#define GR18_HK_DISP_SWITCH (0x4<<3) /* see SWF14 15:0 for what to enable */
|
||||
#define GR18_HK_POPUP_DISABLED (0x6<<3)
|
||||
#define GR18_HK_POPUP_ENABLED (0x7<<3)
|
||||
#define GR18_HK_PFIT (0x8<<3)
|
||||
#define GR18_HK_APM_CHANGE (0xa<<3)
|
||||
#define GR18_HK_MULTIPLE (0xc<<3)
|
||||
#define GR18_USER_INT_EN (1<<2)
|
||||
#define GR18_A0000_FLUSH_EN (1<<1)
|
||||
#define GR18_SMM_EN (1<<0)
|
||||
|
||||
/* Set by driver, cleared by VBIOS */
|
||||
#define SWF00_YRES_SHIFT 16
|
||||
#define SWF00_XRES_SHIFT 0
|
||||
#define SWF00_RES_MASK 0xffff
|
||||
|
||||
/* Set by VBIOS at boot time and driver at runtime */
|
||||
#define SWF01_TV2_FORMAT_SHIFT 8
|
||||
#define SWF01_TV1_FORMAT_SHIFT 0
|
||||
#define SWF01_TV_FORMAT_MASK 0xffff
|
||||
|
||||
#define SWF10_VBIOS_BLC_I2C_EN (1<<29)
|
||||
#define SWF10_GTT_OVERRIDE_EN (1<<28)
|
||||
#define SWF10_LFP_DPMS_OVR (1<<27) /* override DPMS on display switch */
|
||||
#define SWF10_ACTIVE_TOGGLE_LIST_MASK (7<<24)
|
||||
#define SWF10_OLD_TOGGLE 0x0
|
||||
#define SWF10_TOGGLE_LIST_1 0x1
|
||||
#define SWF10_TOGGLE_LIST_2 0x2
|
||||
#define SWF10_TOGGLE_LIST_3 0x3
|
||||
#define SWF10_TOGGLE_LIST_4 0x4
|
||||
#define SWF10_PANNING_EN (1<<23)
|
||||
#define SWF10_DRIVER_LOADED (1<<22)
|
||||
#define SWF10_EXTENDED_DESKTOP (1<<21)
|
||||
#define SWF10_EXCLUSIVE_MODE (1<<20)
|
||||
#define SWF10_OVERLAY_EN (1<<19)
|
||||
#define SWF10_PLANEB_HOLDOFF (1<<18)
|
||||
#define SWF10_PLANEA_HOLDOFF (1<<17)
|
||||
#define SWF10_VGA_HOLDOFF (1<<16)
|
||||
#define SWF10_ACTIVE_DISP_MASK 0xffff
|
||||
#define SWF10_PIPEB_LFP2 (1<<15)
|
||||
#define SWF10_PIPEB_EFP2 (1<<14)
|
||||
#define SWF10_PIPEB_TV2 (1<<13)
|
||||
#define SWF10_PIPEB_CRT2 (1<<12)
|
||||
#define SWF10_PIPEB_LFP (1<<11)
|
||||
#define SWF10_PIPEB_EFP (1<<10)
|
||||
#define SWF10_PIPEB_TV (1<<9)
|
||||
#define SWF10_PIPEB_CRT (1<<8)
|
||||
#define SWF10_PIPEA_LFP2 (1<<7)
|
||||
#define SWF10_PIPEA_EFP2 (1<<6)
|
||||
#define SWF10_PIPEA_TV2 (1<<5)
|
||||
#define SWF10_PIPEA_CRT2 (1<<4)
|
||||
#define SWF10_PIPEA_LFP (1<<3)
|
||||
#define SWF10_PIPEA_EFP (1<<2)
|
||||
#define SWF10_PIPEA_TV (1<<1)
|
||||
#define SWF10_PIPEA_CRT (1<<0)
|
||||
|
||||
#define SWF11_MEMORY_SIZE_SHIFT 16
|
||||
#define SWF11_SV_TEST_EN (1<<15)
|
||||
#define SWF11_IS_AGP (1<<14)
|
||||
#define SWF11_DISPLAY_HOLDOFF (1<<13)
|
||||
#define SWF11_DPMS_REDUCED (1<<12)
|
||||
#define SWF11_IS_VBE_MODE (1<<11)
|
||||
#define SWF11_PIPEB_ACCESS (1<<10) /* 0 here means pipe a */
|
||||
#define SWF11_DPMS_MASK 0x07
|
||||
#define SWF11_DPMS_OFF (1<<2)
|
||||
#define SWF11_DPMS_SUSPEND (1<<1)
|
||||
#define SWF11_DPMS_STANDBY (1<<0)
|
||||
#define SWF11_DPMS_ON 0
|
||||
|
||||
#define SWF14_GFX_PFIT_EN (1<<31)
|
||||
#define SWF14_TEXT_PFIT_EN (1<<30)
|
||||
#define SWF14_LID_SWITCH_EN (1<<29)
|
||||
#define SWF14_POPUP_EN (1<<28)
|
||||
#define SWF14_DISPLAY_HOLDOFF (1<<27)
|
||||
#define SWF14_DISP_DETECT_EN (1<<26)
|
||||
#define SWF14_DOCKING_STATUS_DOCKED (1<<25) /* 0 here means undocked */
|
||||
#define SWF14_DRIVER_STATUS (1<<24)
|
||||
#define SWF14_OS_TYPE_WIN9X (1<<23)
|
||||
#define SWF14_OS_TYPE_WINNT (1<<22)
|
||||
/* 21:19 rsvd */
|
||||
#define SWF14_PM_TYPE_MASK 0x00070000
|
||||
#define SWF14_PM_ACPI_VIDEO (0x4 << 16)
|
||||
#define SWF14_PM_ACPI (0x3 << 16)
|
||||
#define SWF14_PM_APM_12 (0x2 << 16)
|
||||
#define SWF14_PM_APM_11 (0x1 << 16)
|
||||
#define SWF14_HK_REQUEST_MASK 0x0000ffff /* see GR18 6:3 for event type */
|
||||
/* if GR18 indicates a display switch */
|
||||
#define SWF14_DS_PIPEB_LFP2_EN (1<<15)
|
||||
#define SWF14_DS_PIPEB_EFP2_EN (1<<14)
|
||||
#define SWF14_DS_PIPEB_TV2_EN (1<<13)
|
||||
#define SWF14_DS_PIPEB_CRT2_EN (1<<12)
|
||||
#define SWF14_DS_PIPEB_LFP_EN (1<<11)
|
||||
#define SWF14_DS_PIPEB_EFP_EN (1<<10)
|
||||
#define SWF14_DS_PIPEB_TV_EN (1<<9)
|
||||
#define SWF14_DS_PIPEB_CRT_EN (1<<8)
|
||||
#define SWF14_DS_PIPEA_LFP2_EN (1<<7)
|
||||
#define SWF14_DS_PIPEA_EFP2_EN (1<<6)
|
||||
#define SWF14_DS_PIPEA_TV2_EN (1<<5)
|
||||
#define SWF14_DS_PIPEA_CRT2_EN (1<<4)
|
||||
#define SWF14_DS_PIPEA_LFP_EN (1<<3)
|
||||
#define SWF14_DS_PIPEA_EFP_EN (1<<2)
|
||||
#define SWF14_DS_PIPEA_TV_EN (1<<1)
|
||||
#define SWF14_DS_PIPEA_CRT_EN (1<<0)
|
||||
/* if GR18 indicates a panel fitting request */
|
||||
#define SWF14_PFIT_EN (1<<0) /* 0 means disable */
|
||||
/* if GR18 indicates an APM change request */
|
||||
#define SWF14_APM_HIBERNATE 0x4
|
||||
#define SWF14_APM_SUSPEND 0x3
|
||||
#define SWF14_APM_STANDBY 0x1
|
||||
#define SWF14_APM_RESTORE 0x0
|
||||
|
||||
#endif /* _INTEL_BIOS_H_ */
|
680
tools/intel_bios_reader.c
Normal file
680
tools/intel_bios_reader.c
Normal file
@ -0,0 +1,680 @@
|
||||
/*
|
||||
* Copyright © 2006 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "intel_bios.h"
|
||||
|
||||
/* no bother to include "edid.h" */
|
||||
#define _H_ACTIVE(x) (x[2] + ((x[4] & 0xF0) << 4))
|
||||
#define _H_SYNC_OFF(x) (x[8] + ((x[11] & 0xC0) << 2))
|
||||
#define _H_SYNC_WIDTH(x) (x[9] + ((x[11] & 0x30) << 4))
|
||||
#define _H_BLANK(x) (x[3] + ((x[4] & 0x0F) << 8))
|
||||
#define _V_ACTIVE(x) (x[5] + ((x[7] & 0xF0) << 4))
|
||||
#define _V_SYNC_OFF(x) ((x[10] >> 4) + ((x[11] & 0x0C) << 2))
|
||||
#define _V_SYNC_WIDTH(x) ((x[10] & 0x0F) + ((x[11] & 0x03) << 4))
|
||||
#define _V_BLANK(x) (x[6] + ((x[7] & 0x0F) << 8))
|
||||
#define _PIXEL_CLOCK(x) (x[0] + (x[1] << 8)) * 10000
|
||||
|
||||
/* Make a fake pI830 so we can easily pull i830_bios.c code in here. */
|
||||
struct _fake_i830 {
|
||||
uint8_t *VBIOS;
|
||||
};
|
||||
struct _fake_i830 I830;
|
||||
struct _fake_i830 *pI830 = &I830;
|
||||
|
||||
#define INTEL_BIOS_8(_addr) (pI830->VBIOS[_addr])
|
||||
#define INTEL_BIOS_16(_addr) (pI830->VBIOS[_addr] | \
|
||||
(pI830->VBIOS[_addr + 1] << 8))
|
||||
#define INTEL_BIOS_32(_addr) (pI830->VBIOS[_addr] | \
|
||||
(pI830->VBIOS[_addr + 1] << 8) | \
|
||||
(pI830->VBIOS[_addr + 2] << 16) | \
|
||||
(pI830->VBIOS[_addr + 3] << 24))
|
||||
|
||||
#define YESNO(val) ((val) ? "yes" : "no")
|
||||
|
||||
struct bdb_block {
|
||||
uint8_t id;
|
||||
uint16_t size;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct bdb_header *bdb;
|
||||
static int tv_present;
|
||||
static int lvds_present;
|
||||
static int panel_type;
|
||||
|
||||
static struct bdb_block *find_section(int section_id)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
unsigned char *base = (unsigned char *)bdb;
|
||||
int index = 0;
|
||||
uint16_t total, current_size;
|
||||
unsigned char current_id;
|
||||
|
||||
/* skip to first section */
|
||||
index += bdb->header_size;
|
||||
total = bdb->bdb_size;
|
||||
|
||||
block = malloc(sizeof(*block));
|
||||
if (!block) {
|
||||
fprintf(stderr, "out of memory\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* walk the sections looking for section_id */
|
||||
while (index < total) {
|
||||
current_id = *(base + index);
|
||||
index++;
|
||||
current_size = *((uint16_t *) (base + index));
|
||||
index += 2;
|
||||
if (current_id == section_id) {
|
||||
block->id = current_id;
|
||||
block->size = current_size;
|
||||
block->data = base + index;
|
||||
return block;
|
||||
}
|
||||
index += current_size;
|
||||
}
|
||||
|
||||
free(block);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void dump_general_features(void)
|
||||
{
|
||||
struct bdb_general_features *features;
|
||||
struct bdb_block *block;
|
||||
|
||||
block = find_section(BDB_GENERAL_FEATURES);
|
||||
|
||||
if (!block)
|
||||
return;
|
||||
|
||||
features = block->data;
|
||||
|
||||
printf("General features block:\n");
|
||||
|
||||
printf("\tPanel fitting: ");
|
||||
switch (features->panel_fitting) {
|
||||
case 0:
|
||||
printf("disabled\n");
|
||||
break;
|
||||
case 1:
|
||||
printf("text only\n");
|
||||
break;
|
||||
case 2:
|
||||
printf("graphics only\n");
|
||||
break;
|
||||
case 3:
|
||||
printf("text & graphics\n");
|
||||
break;
|
||||
}
|
||||
printf("\tFlexaim: %s\n", YESNO(features->flexaim));
|
||||
printf("\tMessage: %s\n", YESNO(features->msg_enable));
|
||||
printf("\tClear screen: %d\n", features->clear_screen);
|
||||
printf("\tDVO color flip required: %s\n", YESNO(features->color_flip));
|
||||
printf("\tExternal VBT: %s\n", YESNO(features->download_ext_vbt));
|
||||
printf("\tEnable SSC: %s\n", YESNO(features->enable_ssc));
|
||||
if (features->enable_ssc)
|
||||
printf("\tSSC frequency: %s\n", features->ssc_freq ?
|
||||
"100 MHz (66 MHz on 855)" : "96 MHz (48 MHz on 855)");
|
||||
printf("\tLFP on override: %s\n",
|
||||
YESNO(features->enable_lfp_on_override));
|
||||
printf("\tDisable SSC on clone: %s\n",
|
||||
YESNO(features->disable_ssc_ddt));
|
||||
printf("\tDisable smooth vision: %s\n",
|
||||
YESNO(features->disable_smooth_vision));
|
||||
printf("\tSingle DVI for CRT/DVI: %s\n", YESNO(features->single_dvi));
|
||||
printf("\tLegacy monitor detect: %s\n",
|
||||
YESNO(features->legacy_monitor_detect));
|
||||
printf("\tIntegrated CRT: %s\n", YESNO(features->int_crt_support));
|
||||
printf("\tIntegrated TV: %s\n", YESNO(features->int_tv_support));
|
||||
|
||||
tv_present = 1; /* should be based on whether TV DAC exists */
|
||||
lvds_present = 1; /* should be based on IS_MOBILE() */
|
||||
|
||||
free(block);
|
||||
}
|
||||
|
||||
static void dump_backlight_info(void)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
struct bdb_lvds_backlight *backlight;
|
||||
struct blc_struct *blc;
|
||||
|
||||
block = find_section(BDB_LVDS_BACKLIGHT);
|
||||
|
||||
if (!block)
|
||||
return;
|
||||
|
||||
backlight = block->data;
|
||||
|
||||
printf("Backlight info block (len %d):\n", block->size);
|
||||
|
||||
if (sizeof(struct blc_struct) != backlight->blcstruct_size) {
|
||||
printf("\tBacklight struct sizes don't match (expected %u, got %u), skipping\n",
|
||||
sizeof(struct blc_struct), backlight->blcstruct_size);
|
||||
return;
|
||||
}
|
||||
|
||||
blc = &backlight->panels[panel_type];
|
||||
|
||||
printf("\tInverter type: %d\n", blc->inverter_type);
|
||||
printf("\t polarity: %d\n", blc->inverter_polarity);
|
||||
printf("\t GPIO pins: %d\n", blc->gpio_pins);
|
||||
printf("\t GMBUS speed: %d\n", blc->gmbus_speed);
|
||||
printf("\t PWM freq: %d\n", blc->pwm_freq);
|
||||
printf("\tMinimum brightness: %d\n", blc->min_brightness);
|
||||
printf("\tI2C slave addr: 0x%02x\n", blc->i2c_slave_addr);
|
||||
printf("\tI2C command: 0x%02x\n", blc->i2c_cmd);
|
||||
}
|
||||
|
||||
static void dump_general_definitions(void)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
struct bdb_general_definitions *defs;
|
||||
struct child_device_config *child;
|
||||
int i;
|
||||
char child_id[11];
|
||||
int child_device_num;
|
||||
|
||||
block = find_section(BDB_GENERAL_DEFINITIONS);
|
||||
|
||||
if (!block)
|
||||
return;
|
||||
|
||||
defs = block->data;
|
||||
|
||||
printf("General definitions block:\n");
|
||||
|
||||
printf("\tCRT DDC GMBUS addr: 0x%02x\n", defs->crt_ddc_gmbus_pin);
|
||||
printf("\tUse ACPI DPMS CRT power states: %s\n",
|
||||
YESNO(defs->dpms_acpi));
|
||||
printf("\tSkip CRT detect at boot: %s\n",
|
||||
YESNO(defs->skip_boot_crt_detect));
|
||||
printf("\tUse DPMS on AIM devices: %s\n", YESNO(defs->dpms_aim));
|
||||
printf("\tBoot display type: 0x%02x%02x\n", defs->boot_display[1],
|
||||
defs->boot_display[0]);
|
||||
printf("\tTV data block present: %s\n", YESNO(tv_present));
|
||||
child_device_num = (block->size - sizeof(*defs)) / sizeof(*child);
|
||||
for (i = 0; i < child_device_num; i++) {
|
||||
child = &defs->devices[i];
|
||||
if (!child->device_type) {
|
||||
printf("\tChild device %d not present\n", i);
|
||||
continue;
|
||||
}
|
||||
strncpy(child_id, (char *)child->device_id, 10);
|
||||
child_id[10] = 0;
|
||||
printf("\tChild %d device info:\n", i);
|
||||
printf("\t\tSignature: %s\n", child_id);
|
||||
printf("\t\tAIM offset: %d\n", child->addin_offset);
|
||||
printf("\t\tDVO port: 0x%02x\n", child->dvo_port);
|
||||
}
|
||||
|
||||
free(block);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void dump_child_devices(void)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
struct bdb_child_devices *child_devs;
|
||||
struct child_device_config *child;
|
||||
int i;
|
||||
|
||||
block = find_section(BDB_CHILD_DEVICE_TABLE);
|
||||
if (!block) {
|
||||
printf("No child device table found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
child_devs = block->data;
|
||||
|
||||
printf("Child devices block:\n");
|
||||
for (i = 0; i < DEVICE_CHILD_SIZE; i++) {
|
||||
child = &child_devs->children[i];
|
||||
/* Skip nonexistent children */
|
||||
if (!child->device_type)
|
||||
continue;
|
||||
printf("\tChild device %d\n", i);
|
||||
printf("\t\tType: 0x%04x\n", child->device_type);
|
||||
printf("\t\tDVO port: 0x%02x\n", child->dvo_port);
|
||||
printf("\t\tI2C pin: 0x%02x\n", child->i2c_pin);
|
||||
printf("\t\tSlave addr: 0x%02x\n", child->slave_addr);
|
||||
printf("\t\tDDC pin: 0x%02x\n", child->ddc_pin);
|
||||
printf("\t\tDVO config: 0x%02x\n", child->dvo_cfg);
|
||||
printf("\t\tDVO wiring: 0x%02x\n", child->dvo_wiring);
|
||||
}
|
||||
|
||||
free(block);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void dump_lvds_options(void)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
struct bdb_lvds_options *options;
|
||||
|
||||
block = find_section(BDB_LVDS_OPTIONS);
|
||||
if (!block) {
|
||||
printf("No LVDS options block\n");
|
||||
return;
|
||||
}
|
||||
|
||||
options = block->data;
|
||||
|
||||
printf("LVDS options block:\n");
|
||||
|
||||
panel_type = options->panel_type;
|
||||
printf("\tPanel type: %d\n", panel_type);
|
||||
printf("\tLVDS EDID available: %s\n", YESNO(options->lvds_edid));
|
||||
printf("\tPixel dither: %s\n", YESNO(options->pixel_dither));
|
||||
printf("\tPFIT auto ratio: %s\n", YESNO(options->pfit_ratio_auto));
|
||||
printf("\tPFIT enhanced graphics mode: %s\n",
|
||||
YESNO(options->pfit_gfx_mode_enhanced));
|
||||
printf("\tPFIT enhanced text mode: %s\n",
|
||||
YESNO(options->pfit_text_mode_enhanced));
|
||||
printf("\tPFIT mode: %d\n", options->pfit_mode);
|
||||
|
||||
free(block);
|
||||
}
|
||||
|
||||
static void dump_lvds_ptr_data(void)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
struct bdb_lvds_lfp_data *lvds_data;
|
||||
struct bdb_lvds_lfp_data_ptrs *ptrs;
|
||||
struct lvds_fp_timing *fp_timing;
|
||||
struct bdb_lvds_lfp_data_entry *entry;
|
||||
int lfp_data_size;
|
||||
|
||||
block = find_section(BDB_LVDS_LFP_DATA_PTRS);
|
||||
if (!block) {
|
||||
printf("No LFP data pointers block\n");
|
||||
return;
|
||||
}
|
||||
ptrs = block->data;
|
||||
|
||||
block = find_section(BDB_LVDS_LFP_DATA);
|
||||
if (!block) {
|
||||
printf("No LVDS data block\n");
|
||||
return;
|
||||
}
|
||||
lvds_data = block->data;
|
||||
|
||||
lfp_data_size =
|
||||
ptrs->ptr[1].fp_timing_offset - ptrs->ptr[0].fp_timing_offset;
|
||||
entry =
|
||||
(struct bdb_lvds_lfp_data_entry *)((uint8_t *) lvds_data->data +
|
||||
(lfp_data_size * panel_type));
|
||||
fp_timing = &entry->fp_timing;
|
||||
|
||||
printf("LVDS timing pointer data:\n");
|
||||
printf(" Number of entries: %d\n", ptrs->lvds_entries);
|
||||
|
||||
printf("\tpanel type %02i: %dx%d\n", panel_type, fp_timing->x_res,
|
||||
fp_timing->y_res);
|
||||
|
||||
free(block);
|
||||
}
|
||||
|
||||
static void dump_lvds_data(void)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
struct bdb_lvds_lfp_data *lvds_data;
|
||||
struct bdb_lvds_lfp_data_ptrs *ptrs;
|
||||
int num_entries;
|
||||
int i;
|
||||
int hdisplay, hsyncstart, hsyncend, htotal;
|
||||
int vdisplay, vsyncstart, vsyncend, vtotal;
|
||||
float clock;
|
||||
int lfp_data_size, dvo_offset;
|
||||
|
||||
block = find_section(BDB_LVDS_LFP_DATA_PTRS);
|
||||
if (!block) {
|
||||
printf("No LVDS ptr block\n");
|
||||
return;
|
||||
}
|
||||
ptrs = block->data;
|
||||
lfp_data_size =
|
||||
ptrs->ptr[1].fp_timing_offset - ptrs->ptr[0].fp_timing_offset;
|
||||
dvo_offset =
|
||||
ptrs->ptr[0].dvo_timing_offset - ptrs->ptr[0].fp_timing_offset;
|
||||
free(block);
|
||||
|
||||
block = find_section(BDB_LVDS_LFP_DATA);
|
||||
if (!block) {
|
||||
printf("No LVDS data block\n");
|
||||
return;
|
||||
}
|
||||
|
||||
lvds_data = block->data;
|
||||
num_entries = block->size / lfp_data_size;
|
||||
|
||||
printf("LVDS panel data block (preferred block marked with '*'):\n");
|
||||
printf(" Number of entries: %d\n", num_entries);
|
||||
|
||||
for (i = 0; i < num_entries; i++) {
|
||||
uint8_t *lfp_data_ptr =
|
||||
(uint8_t *) lvds_data->data + lfp_data_size * i;
|
||||
uint8_t *timing_data = lfp_data_ptr + dvo_offset;
|
||||
struct bdb_lvds_lfp_data_entry *lfp_data =
|
||||
(struct bdb_lvds_lfp_data_entry *)lfp_data_ptr;
|
||||
char marker;
|
||||
|
||||
if (i == panel_type)
|
||||
marker = '*';
|
||||
else
|
||||
marker = ' ';
|
||||
|
||||
hdisplay = _H_ACTIVE(timing_data);
|
||||
hsyncstart = hdisplay + _H_SYNC_OFF(timing_data);
|
||||
hsyncend = hsyncstart + _H_SYNC_WIDTH(timing_data);
|
||||
htotal = hdisplay + _H_BLANK(timing_data);
|
||||
|
||||
vdisplay = _V_ACTIVE(timing_data);
|
||||
vsyncstart = vdisplay + _V_SYNC_OFF(timing_data);
|
||||
vsyncend = vsyncstart + _V_SYNC_WIDTH(timing_data);
|
||||
vtotal = vdisplay + _V_BLANK(timing_data);
|
||||
clock = _PIXEL_CLOCK(timing_data) / 1000;
|
||||
|
||||
printf("%c\tpanel type %02i: %dx%d clock %d\n", marker,
|
||||
i, lfp_data->fp_timing.x_res, lfp_data->fp_timing.y_res,
|
||||
_PIXEL_CLOCK(timing_data));
|
||||
printf("\t\tinfo:\n");
|
||||
printf("\t\t LVDS: 0x%08lx\n",
|
||||
(unsigned long)lfp_data->fp_timing.lvds_reg_val);
|
||||
printf("\t\t PP_ON_DELAYS: 0x%08lx\n",
|
||||
(unsigned long)lfp_data->fp_timing.pp_on_reg_val);
|
||||
printf("\t\t PP_OFF_DELAYS: 0x%08lx\n",
|
||||
(unsigned long)lfp_data->fp_timing.pp_off_reg_val);
|
||||
printf("\t\t PP_DIVISOR: 0x%08lx\n",
|
||||
(unsigned long)lfp_data->fp_timing.pp_cycle_reg_val);
|
||||
printf("\t\t PFIT: 0x%08lx\n",
|
||||
(unsigned long)lfp_data->fp_timing.pfit_reg_val);
|
||||
printf("\t\ttimings: %d %d %d %d %d %d %d %d %.2f (%s)\n",
|
||||
hdisplay, hsyncstart, hsyncend, htotal,
|
||||
vdisplay, vsyncstart, vsyncend, vtotal, clock,
|
||||
(hsyncend > htotal || vsyncend > vtotal) ?
|
||||
"BAD!" : "good");
|
||||
}
|
||||
free(block);
|
||||
}
|
||||
|
||||
static void dump_driver_feature(void)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
struct bdb_driver_feature *feature;
|
||||
|
||||
block = find_section(BDB_DRIVER_FEATURES);
|
||||
if (!block) {
|
||||
printf("No Driver feature data block\n");
|
||||
return;
|
||||
}
|
||||
feature = block->data;
|
||||
|
||||
printf("Driver feature Data Block:\n");
|
||||
printf("\tBoot Device Algorithm: %s\n", feature->boot_dev_algorithm ?
|
||||
"driver default" : "os default");
|
||||
printf("\tBlock display switching when DVD active: %s\n",
|
||||
YESNO(feature->block_display_switch));
|
||||
printf("\tAllow display switching when in Full Screen DOS: %s\n",
|
||||
YESNO(feature->allow_display_switch));
|
||||
printf("\tHot Plug DVO: %s\n", YESNO(feature->hotplug_dvo));
|
||||
printf("\tDual View Zoom: %s\n", YESNO(feature->dual_view_zoom));
|
||||
printf("\tDriver INT 15h hook: %s\n", YESNO(feature->int15h_hook));
|
||||
printf("\tEnable Sprite in Clone Mode: %s\n",
|
||||
YESNO(feature->sprite_in_clone));
|
||||
printf("\tUse 00000110h ID for Primary LFP: %s\n",
|
||||
YESNO(feature->primary_lfp_id));
|
||||
printf("\tBoot Mode X: %u\n", feature->boot_mode_x);
|
||||
printf("\tBoot Mode Y: %u\n", feature->boot_mode_y);
|
||||
printf("\tBoot Mode Bpp: %u\n", feature->boot_mode_bpp);
|
||||
printf("\tBoot Mode Refresh: %u\n", feature->boot_mode_refresh);
|
||||
printf("\tEnable LFP as primary: %s\n",
|
||||
YESNO(feature->enable_lfp_primary));
|
||||
printf("\tSelective Mode Pruning: %s\n",
|
||||
YESNO(feature->selective_mode_pruning));
|
||||
printf("\tDual-Frequency Graphics Technology: %s\n",
|
||||
YESNO(feature->dual_frequency));
|
||||
printf("\tDefault Render Clock Frequency: %s\n",
|
||||
feature->render_clock_freq ? "low" : "high");
|
||||
printf("\tNT 4.0 Dual Display Clone Support: %s\n",
|
||||
YESNO(feature->nt_clone_support));
|
||||
printf("\tDefault Power Scheme user interface: %s\n",
|
||||
feature->power_scheme_ui ? "3rd party" : "CUI");
|
||||
printf
|
||||
("\tSprite Display Assignment when Overlay is Active in Clone Mode: %s\n",
|
||||
feature->sprite_display_assign ? "primary" : "secondary");
|
||||
printf("\tDisplay Maintain Aspect Scaling via CUI: %s\n",
|
||||
YESNO(feature->cui_aspect_scaling));
|
||||
printf("\tPreserve Aspect Ratio: %s\n",
|
||||
YESNO(feature->preserve_aspect_ratio));
|
||||
printf("\tEnable SDVO device power down: %s\n",
|
||||
YESNO(feature->sdvo_device_power_down));
|
||||
printf("\tCRT hotplug: %s\n", YESNO(feature->crt_hotplug));
|
||||
printf("\tLVDS config: ");
|
||||
switch (feature->lvds_config) {
|
||||
case BDB_DRIVER_NO_LVDS:
|
||||
printf("No LVDS\n");
|
||||
break;
|
||||
case BDB_DRIVER_INT_LVDS:
|
||||
printf("Integrated LVDS\n");
|
||||
break;
|
||||
case BDB_DRIVER_SDVO_LVDS:
|
||||
printf("SDVO LVDS\n");
|
||||
break;
|
||||
case BDB_DRIVER_EDP:
|
||||
printf("Embedded DisplayPort\n");
|
||||
break;
|
||||
}
|
||||
printf("\tDefine Display statically: %s\n",
|
||||
YESNO(feature->static_display));
|
||||
printf("\tLegacy CRT max X: %d\n", feature->legacy_crt_max_x);
|
||||
printf("\tLegacy CRT max Y: %d\n", feature->legacy_crt_max_y);
|
||||
printf("\tLegacy CRT max refresh: %d\n",
|
||||
feature->legacy_crt_max_refresh);
|
||||
free(block);
|
||||
}
|
||||
|
||||
static void dump_edp(void)
|
||||
{
|
||||
struct bdb_block *block;
|
||||
struct bdb_edp *edp;
|
||||
int bpp;
|
||||
|
||||
block = find_section(BDB_EDP);
|
||||
if (!block) {
|
||||
printf("No EDP data block\n");
|
||||
return;
|
||||
}
|
||||
edp = block->data;
|
||||
|
||||
printf("eDP block: type %d\n", panel_type);
|
||||
printf("\tPower Sequence: T3 %d T7 %d T9 %d T10 %d T12 %d\n",
|
||||
edp->power_seqs[panel_type].t3,
|
||||
edp->power_seqs[panel_type].t7,
|
||||
edp->power_seqs[panel_type].t9,
|
||||
edp->power_seqs[panel_type].t10,
|
||||
edp->power_seqs[panel_type].t12);
|
||||
|
||||
bpp = (edp->color_depth >> (panel_type * 2)) & 3;
|
||||
|
||||
printf("\tPanel color depth: ");
|
||||
switch (bpp) {
|
||||
case EDP_18BPP:
|
||||
printf("18bpp\n");
|
||||
break;
|
||||
case EDP_24BPP:
|
||||
printf("24bpp\n");
|
||||
break;
|
||||
case EDP_30BPP:
|
||||
printf("30bpp\n");
|
||||
break;
|
||||
}
|
||||
printf("\teDP sDRRs MSA timing delay: %d\n", edp->sdrrs_msa_timing_delay);
|
||||
printf("\tLink params:\n");
|
||||
printf("\t\trate: ");
|
||||
if (edp->link_params[panel_type].rate == EDP_RATE_1_62)
|
||||
printf("1.62G\n");
|
||||
else if (edp->link_params[panel_type].rate == EDP_RATE_2_7)
|
||||
printf("2.7G\n");
|
||||
printf("\t\tlanes: ");
|
||||
switch (edp->link_params[panel_type].lanes) {
|
||||
case EDP_LANE_1:
|
||||
printf("x1 mode\n");
|
||||
break;
|
||||
case EDP_LANE_2:
|
||||
printf("x2 mode\n");
|
||||
break;
|
||||
case EDP_LANE_4:
|
||||
printf("x4 mode\n");
|
||||
break;
|
||||
}
|
||||
printf("\t\tpre-emphasis: ");
|
||||
switch (edp->link_params[panel_type].preemphasis) {
|
||||
case EDP_PREEMPHASIS_NONE:
|
||||
printf("none\n");
|
||||
break;
|
||||
case EDP_PREEMPHASIS_3_5dB:
|
||||
printf("3.5dB\n");
|
||||
break;
|
||||
case EDP_PREEMPHASIS_6dB:
|
||||
printf("6dB\n");
|
||||
break;
|
||||
case EDP_PREEMPHASIS_9_5dB:
|
||||
printf("9.5dB\n");
|
||||
break;
|
||||
}
|
||||
printf("\t\tvswing: ");
|
||||
switch (edp->link_params[panel_type].vswing) {
|
||||
case EDP_VSWING_0_4V:
|
||||
printf("0.4V\n");
|
||||
break;
|
||||
case EDP_VSWING_0_6V:
|
||||
printf("0.6V\n");
|
||||
break;
|
||||
case EDP_VSWING_0_8V:
|
||||
printf("0.8V\n");
|
||||
break;
|
||||
case EDP_VSWING_1_2V:
|
||||
printf("1.2V\n");
|
||||
break;
|
||||
}
|
||||
free(block);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
struct vbt_header *vbt = NULL;
|
||||
int vbt_off, bdb_off, i;
|
||||
char *filename = "bios";
|
||||
struct stat finfo;
|
||||
struct bdb_block *block;
|
||||
char signature[17];
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: %s <rom file>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
filename = argv[1];
|
||||
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
printf("Couldn't open \"%s\": %s\n", filename, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (stat(filename, &finfo)) {
|
||||
printf("failed to stat \"%s\": %s\n", filename,
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
pI830->VBIOS = mmap(NULL, finfo.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (pI830->VBIOS == MAP_FAILED) {
|
||||
printf("failed to map \"%s\": %s\n", filename, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Scour memory looking for the VBT signature */
|
||||
for (i = 0; i + 4 < finfo.st_size; i++) {
|
||||
if (!memcmp(pI830->VBIOS + i, "$VBT", 4)) {
|
||||
vbt_off = i;
|
||||
vbt = (struct vbt_header *)(pI830->VBIOS + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vbt) {
|
||||
printf("VBT signature missing\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("VBT vers: %d.%d\n", vbt->version / 100, vbt->version % 100);
|
||||
|
||||
bdb_off = vbt_off + vbt->bdb_offset;
|
||||
bdb = (struct bdb_header *)(pI830->VBIOS + bdb_off);
|
||||
strncpy(signature, (char *)bdb->signature, 16);
|
||||
signature[16] = 0;
|
||||
printf("BDB sig: %s\n", signature);
|
||||
printf("BDB vers: %d.%d\n", bdb->version / 100, bdb->version % 100);
|
||||
|
||||
printf("Available sections: ");
|
||||
for (i = 0; i < 256; i++) {
|
||||
block = find_section(i);
|
||||
if (!block)
|
||||
continue;
|
||||
printf("%d ", i);
|
||||
free(block);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
dump_general_features();
|
||||
dump_general_definitions();
|
||||
// dump_child_devices();
|
||||
dump_lvds_options();
|
||||
dump_lvds_data();
|
||||
dump_lvds_ptr_data();
|
||||
dump_backlight_info();
|
||||
|
||||
dump_driver_feature();
|
||||
dump_edp();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user