Retain the legacy definition for the obsolete child device block, at
least for now. No functional changes.

Signed-off-by: Jani Nikula <jani.nik...@intel.com>
---
 tools/intel_bios.h       | 58 +----------------------------
 tools/intel_vbt_decode.c | 45 ++++++++++-------------
 tools/intel_vbt_defs.h   | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+), 81 deletions(-)

diff --git a/tools/intel_bios.h b/tools/intel_bios.h
index 8d1bf7ae0c81..3f441a6da17b 100644
--- a/tools/intel_bios.h
+++ b/tools/intel_bios.h
@@ -72,7 +72,7 @@
 #define DEVICE_PORT_DPC                8
 #define DEVICE_PORT_DPD                9
 
-struct child_device_config {
+struct legacy_child_device_config {
        uint16_t handle;
        uint16_t device_type;   /* See DEVICE_TYPE_* above */
        uint8_t device_id[10];
@@ -94,65 +94,11 @@ struct child_device_config {
        uint8_t dvo_function;
 } __attribute__ ((packed));
 
-struct efp_child_device_config {
-       uint16_t handle;
-       uint16_t device_type;
-       uint8_t i2c_speed;
-       uint8_t dp_onboard_redriver; /* 158 */
-       uint8_t dp_ondock_redriver; /* 158 */
-       uint8_t hdmi_level_shifter_value:4; /* 169 */
-       uint8_t hdmi_max_data_rate:4; /* 204 */
-       uint16_t dtd_buf_ptr; /* 161 */
-       uint8_t edidless_efp:1; /* 161 */
-       uint8_t compression_enable:1; /* 198 */
-       uint8_t compression_method:1; /* 198 */
-       uint8_t ganged_edp:1; /* 202 */
-       uint8_t skip0:4;
-       uint8_t compression_structure_index:4; /* 198 */
-       uint8_t skip1:4;
-       uint8_t slave_port; /*  202 */
-       uint8_t skip2;
-       uint16_t addin_offset;
-       uint8_t port;
-       uint8_t i2c_pin; /* for add-in card */
-       uint8_t slave_addr; /* for add-in card */
-       uint8_t ddc_pin;
-       uint16_t edid_ptr;
-       uint8_t dvo_config;
-       uint8_t efp_docked_port:1; /* 158 */
-       uint8_t lane_reversal:1; /* 184 */
-       uint8_t onboard_lspcon:1; /* 192 */
-       uint8_t iboost_enable:1; /* 196 */
-       uint8_t hpd_invert:1; /* BXT 196 */
-       uint8_t slip3:3;
-       uint8_t hdmi_compat:1;
-       uint8_t dp_compat:1;
-       uint8_t tmds_compat:1;
-       uint8_t skip4:5;
-       uint8_t aux_chan;
-       uint8_t dongle_detect;
-       uint8_t pipe_cap:2;
-       uint8_t sdvo_stall:1; /* 158 */
-       uint8_t hpd_status:2;
-       uint8_t integrated_encoder:1;
-       uint8_t skip5:2;
-       uint8_t dvo_wiring;
-       uint8_t mipi_bridge_type; /* 171 */
-       uint16_t device_class_ext;
-       uint8_t dvo_function;
-       uint8_t dp_usb_type_c:1; /* 195 */
-       uint8_t skip6:7;
-       uint8_t dp_usb_type_c_2x_gpio_index; /* 195 */
-       uint16_t dp_usb_type_c_2x_gpio_pin; /* 195 */
-       uint8_t iboost_dp:4; /* 196 */
-       uint8_t iboost_hdmi:4; /* 196 */
-} __attribute__ ((packed));
-
 #define DEVICE_CHILD_SIZE 7
 
 struct bdb_child_devices {
        uint8_t child_structure_size;
-       struct child_device_config children[DEVICE_CHILD_SIZE];
+       struct legacy_child_device_config children[DEVICE_CHILD_SIZE];
 } __attribute__ ((packed));
 
 struct blc_struct {
diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
index beb33672835e..711f29979418 100644
--- a/tools/intel_vbt_decode.c
+++ b/tools/intel_vbt_decode.c
@@ -383,6 +383,7 @@ static const char *efp_port(uint8_t type)
 static void dump_child_device(struct context *context,
                              const struct child_device_config *child)
 {
+       const struct child_device_config *efp = child;
        char child_id[11];
 
        if (!child->device_type)
@@ -399,8 +400,6 @@ static void dump_child_device(struct context *context,
                printf("\t\tAIM offset: %d\n", child->addin_offset);
                printf("\t\tDVO port: 0x%02x\n", child->dvo_port);
        } else { /* 152+ have EFP blocks here */
-               const struct efp_child_device_config *efp =
-                       (const struct efp_child_device_config *)child;
                printf("\tEFP device info:\n");
                printf("\t\tDevice handle: 0x%04x (%s)\n", efp->handle,
                       child_device_handle(efp->handle));
@@ -420,21 +419,21 @@ static void dump_child_device(struct context *context,
                printf("\t\tCompression structure index: 0x%02x)\n", 
efp->compression_structure_index);
                printf("\t\tSlave DDI port: 0x%02x (%s)\n", efp->slave_port, 
efp_port(efp->slave_port));
                printf("\t\tAIM offset: %d\n", child->addin_offset);
-               printf("\t\tPort: 0x%02x (%s)\n", efp->port, 
efp_port(efp->port));
+               printf("\t\tPort: 0x%02x (%s)\n", efp->dvo_port, 
efp_port(efp->dvo_port));
                printf("\t\tAIM I2C pin: 0x%02x\n", efp->i2c_pin);
                printf("\t\tAIM Slave address: 0x%02x\n", efp->slave_addr);
                printf("\t\tDDC pin: 0x%02x\n", efp->ddc_pin);
                printf("\t\tEDID buffer ptr: 0x%02x\n", efp->edid_ptr);
-               printf("\t\tDVO config: 0x%02x\n", efp->dvo_config);
+               printf("\t\tDVO config: 0x%02x\n", efp->dvo_cfg);
                printf("\t\tHPD sense invert: %s\n", YESNO(efp->hpd_invert));
-               printf("\t\tIboost enable: %s\n", YESNO(efp->iboost_enable));
-               printf("\t\tOnboard LSPCON: %s\n", YESNO(efp->onboard_lspcon));
+               printf("\t\tIboost enable: %s\n", YESNO(efp->iboost));
+               printf("\t\tOnboard LSPCON: %s\n", YESNO(efp->lspcon));
                printf("\t\tLane reversal: %s\n", YESNO(efp->lane_reversal));
-               printf("\t\tEFP routed through dock: %s\n", 
YESNO(efp->efp_docked_port));
-               printf("\t\tHDMI compatible? %s\n", YESNO(efp->hdmi_compat));
-               printf("\t\tDP compatible? %s\n", YESNO(efp->dp_compat));
-               printf("\t\tTMDS compatible? %s\n", YESNO(efp->tmds_compat));
-               printf("\t\tAux channel: 0x%02x\n", efp->aux_chan);
+               printf("\t\tEFP routed through dock: %s\n", 
YESNO(efp->efp_routed));
+               printf("\t\tHDMI compatible? %s\n", YESNO(efp->hdmi_support));
+               printf("\t\tDP compatible? %s\n", YESNO(efp->dp_support));
+               printf("\t\tTMDS compatible? %s\n", YESNO(efp->tmds_support));
+               printf("\t\tAux channel: 0x%02x\n", efp->aux_channel);
                printf("\t\tDongle detect: 0x%02x\n", efp->dongle_detect);
                printf("\t\tIntegrated encoder instead of SDVO: %s\n", 
YESNO(efp->integrated_encoder));
                printf("\t\tHotplu connect status: 0x%02x\n", efp->hpd_status);
@@ -456,23 +455,19 @@ static void dump_child_device(struct context *context,
                        printf("(unknown value %d)\n", efp->mipi_bridge_type);
                        break;
                }
-               printf("\t\tDevice class extendsion: 0x%02x\n", 
efp->device_class_ext);
+               printf("\t\tDevice class extendsion: 0x%02x\n", 
efp->extended_type);
                printf("\t\tDVO function: 0x%02x\n", efp->dvo_function);
        }
 
        if (context->bdb->version >= 195) {
-               const struct efp_child_device_config *efp =
-                       (const struct efp_child_device_config *)child;
                printf("\t\tDP USB type C support: %s\n", 
YESNO(efp->dp_usb_type_c));
-               printf("\t\t2X DP GPIO index: 0x%02x\n", 
efp->dp_usb_type_c_2x_gpio_index);
-               printf("\t\t2X DP GPIO pin number: 0x%02x\n", 
efp->dp_usb_type_c_2x_gpio_pin);
+               printf("\t\t2X DP GPIO index: 0x%02x\n", efp->dp_gpio_index);
+               printf("\t\t2X DP GPIO pin number: 0x%02x\n", 
efp->dp_gpio_pin_num);
        }
 
        if (context->bdb->version >= 196) {
-               const struct efp_child_device_config *efp =
-                       (const struct efp_child_device_config *)child;
-               printf("\t\tIBoost level for HDMI: 0x%02x\n", efp->iboost_hdmi);
-               printf("\t\tIBoost level for DP/eDP: 0x%02x\n", efp->iboost_dp);
+               printf("\t\tIBoost level for HDMI: 0x%02x\n", 
efp->hdmi_iboost_level);
+               printf("\t\tIBoost level for DP/eDP: 0x%02x\n", 
efp->dp_iboost_level);
        }
 }
 
@@ -498,11 +493,11 @@ static void dump_general_definitions(struct context 
*context,
                dump_child_device(context, (const void*)&defs->devices[i * 
defs->child_dev_size]);
 }
 
-static void dump_child_devices(struct context *context,
-                              const struct bdb_block *block)
+static void dump_legacy_child_devices(struct context *context,
+                                     const struct bdb_block *block)
 {
        const struct bdb_child_devices *child_devs = block->data;
-       const struct child_device_config *child;
+       const struct legacy_child_device_config *child;
        int i;
 
        for (i = 0; i < DEVICE_CHILD_SIZE; i++) {
@@ -1517,8 +1512,8 @@ struct dumper dumpers[] = {
        },
        {
                .id = BDB_CHILD_DEVICE_TABLE,
-               .name = "Child devices block",
-               .dump = dump_child_devices,
+               .name = "Legacy child devices block",
+               .dump = dump_legacy_child_devices,
        },
        {
                .id = BDB_LVDS_OPTIONS,
diff --git a/tools/intel_vbt_defs.h b/tools/intel_vbt_defs.h
index 8bdb2292747b..dcb6f36443ad 100644
--- a/tools/intel_vbt_defs.h
+++ b/tools/intel_vbt_defs.h
@@ -290,6 +290,102 @@ struct bdb_general_features {
 
 #define LEGACY_CHILD_DEVICE_CONFIG_SIZE                33
 
+/*
+ * The child device config, aka the display device data structure, provides a
+ * description of a port and its configuration on the platform.
+ *
+ * The child device config size has been increased, and fields have been added
+ * and their meaning has changed over time. Care must be taken when accessing
+ * basically any of the fields to ensure the correct interpretation for the BDB
+ * version in question.
+ *
+ * When we copy the child device configs to dev_priv->vbt.child_dev, we reserve
+ * space for the full structure below, and initialize the tail not actually
+ * present in VBT to zeros. Accessing those fields is fine, as long as the
+ * default zero is taken into account, again according to the BDB version.
+ *
+ * BDB versions 155 and below are considered legacy, and version 155 seems to 
be
+ * a baseline for some of the VBT documentation. When adding new fields, please
+ * include the BDB version when the field was added, if it's above that.
+ */
+struct child_device_config {
+       u16 handle;
+       u16 device_type; /* See DEVICE_TYPE_* above */
+
+       union {
+               u8  device_id[10]; /* ascii string */
+               struct {
+                       u8 i2c_speed;
+                       u8 dp_onboard_redriver;                 /* 158 */
+                       u8 dp_ondock_redriver;                  /* 158 */
+                       u8 hdmi_level_shifter_value:4;          /* 169 */
+                       u8 hdmi_max_data_rate:4;                /* 204 */
+                       u16 dtd_buf_ptr;                        /* 161 */
+                       u8 edidless_efp:1;                      /* 161 */
+                       u8 compression_enable:1;                /* 198 */
+                       u8 compression_method:1;                /* 198 */
+                       u8 ganged_edp:1;                        /* 202 */
+                       u8 reserved0:4;
+                       u8 compression_structure_index:4;       /* 198 */
+                       u8 reserved1:4;
+                       u8 slave_port;                          /* 202 */
+                       u8 reserved2;
+               } __packed;
+       } __packed;
+
+       u16 addin_offset;
+       u8 dvo_port; /* See DEVICE_PORT_* and DVO_PORT_* above */
+       u8 i2c_pin;
+       u8 slave_addr;
+       u8 ddc_pin;
+       u16 edid_ptr;
+       u8 dvo_cfg; /* See DEVICE_CFG_* above */
+
+       union {
+               struct {
+                       u8 dvo2_port;
+                       u8 i2c2_pin;
+                       u8 slave2_addr;
+                       u8 ddc2_pin;
+               } __packed;
+               struct {
+                       u8 efp_routed:1;                        /* 158 */
+                       u8 lane_reversal:1;                     /* 184 */
+                       u8 lspcon:1;                            /* 192 */
+                       u8 iboost:1;                            /* 196 */
+                       u8 hpd_invert:1;                        /* 196 */
+                       u8 flag_reserved:3;
+                       u8 hdmi_support:1;                      /* 158 */
+                       u8 dp_support:1;                        /* 158 */
+                       u8 tmds_support:1;                      /* 158 */
+                       u8 support_reserved:5;
+                       u8 aux_channel;
+                       u8 dongle_detect;
+               } __packed;
+       } __packed;
+
+       u8 pipe_cap:2;
+       u8 sdvo_stall:1;                                        /* 158 */
+       u8 hpd_status:2;
+       u8 integrated_encoder:1;
+       u8 capabilities_reserved:2;
+       u8 dvo_wiring; /* See DEVICE_WIRE_* above */
+
+       union {
+               u8 dvo2_wiring;
+               u8 mipi_bridge_type;                            /* 171 */
+       } __packed;
+
+       u16 extended_type;
+       u8 dvo_function;
+       u8 dp_usb_type_c:1;                                     /* 195 */
+       u8 flags2_reserved:7;                                   /* 195 */
+       u8 dp_gpio_index;                                       /* 195 */
+       u16 dp_gpio_pin_num;                                    /* 195 */
+       u8 dp_iboost_level:4;                                   /* 196 */
+       u8 hdmi_iboost_level:4;                                 /* 196 */
+} __packed;
+
 struct bdb_general_definitions {
        /* DDC GPIO */
        u8 crt_ddc_gmbus_pin;
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to