aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/bios/bios_parser.c')
-rw-r--r--drivers/gpu/drm/amd/display/dc/bios/bios_parser.c1181
1 files changed, 1 insertions, 1180 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
index be8a2494355a..0e1dc1b1a48d 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
@@ -42,7 +42,7 @@
#include "bios_parser_interface.h"
#include "bios_parser_common.h"
-/* TODO remove - only needed for default i2c speed */
+
#include "dc.h"
#define THREE_PERCENT_OF_10000 300
@@ -52,24 +52,13 @@
#define DC_LOGGER \
bp->base.ctx->logger
-/* GUID to validate external display connection info table (aka OPM module) */
-static const uint8_t ext_display_connection_guid[NUMBER_OF_UCHAR_FOR_GUID] = {
- 0x91, 0x6E, 0x57, 0x09,
- 0x3F, 0x6D, 0xD2, 0x11,
- 0x39, 0x8E, 0x00, 0xA0,
- 0xC9, 0x69, 0x72, 0x3B};
-
#define DATA_TABLES(table) (bp->master_data_tbl->ListOfDataTables.table)
static void get_atom_data_table_revision(
ATOM_COMMON_TABLE_HEADER *atom_data_tbl,
struct atom_data_revision *tbl_revision);
-static uint32_t get_dst_number_from_object(struct bios_parser *bp,
- ATOM_OBJECT *object);
static uint32_t get_src_obj_list(struct bios_parser *bp, ATOM_OBJECT *object,
uint16_t **id_list);
-static uint32_t get_dest_obj_list(struct bios_parser *bp,
- ATOM_OBJECT *object, uint16_t **id_list);
static ATOM_OBJECT *get_bios_object(struct bios_parser *bp,
struct graphics_object_id id);
static enum bp_result get_gpio_i2c_info(struct bios_parser *bp,
@@ -163,29 +152,6 @@ static uint8_t bios_parser_get_connectors_number(struct dc_bios *dcb)
le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset));
}
-static struct graphics_object_id bios_parser_get_encoder_id(
- struct dc_bios *dcb,
- uint32_t i)
-{
- struct bios_parser *bp = BP_FROM_DCB(dcb);
- struct graphics_object_id object_id = dal_graphics_object_id_init(
- 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN);
-
- uint32_t encoder_table_offset = bp->object_info_tbl_offset
- + le16_to_cpu(bp->object_info_tbl.v1_1->usEncoderObjectTableOffset);
-
- ATOM_OBJECT_TABLE *tbl =
- GET_IMAGE(ATOM_OBJECT_TABLE, encoder_table_offset);
-
- if (tbl && tbl->ucNumberOfObjects > i) {
- const uint16_t id = le16_to_cpu(tbl->asObjects[i].usObjectID);
-
- object_id = object_id_from_bios_object_id(id);
- }
-
- return object_id;
-}
-
static struct graphics_object_id bios_parser_get_connector_id(
struct dc_bios *dcb,
uint8_t i)
@@ -217,15 +183,6 @@ static struct graphics_object_id bios_parser_get_connector_id(
return object_id;
}
-static uint32_t bios_parser_get_dst_number(struct dc_bios *dcb,
- struct graphics_object_id id)
-{
- struct bios_parser *bp = BP_FROM_DCB(dcb);
- ATOM_OBJECT *object = get_bios_object(bp, id);
-
- return get_dst_number_from_object(bp, object);
-}
-
static enum bp_result bios_parser_get_src_obj(struct dc_bios *dcb,
struct graphics_object_id object_id, uint32_t index,
struct graphics_object_id *src_object_id)
@@ -255,30 +212,6 @@ static enum bp_result bios_parser_get_src_obj(struct dc_bios *dcb,
return BP_RESULT_OK;
}
-static enum bp_result bios_parser_get_dst_obj(struct dc_bios *dcb,
- struct graphics_object_id object_id, uint32_t index,
- struct graphics_object_id *dest_object_id)
-{
- uint32_t number;
- uint16_t *id = NULL;
- ATOM_OBJECT *object;
- struct bios_parser *bp = BP_FROM_DCB(dcb);
-
- if (!dest_object_id)
- return BP_RESULT_BADINPUT;
-
- object = get_bios_object(bp, object_id);
-
- number = get_dest_obj_list(bp, object, &id);
-
- if (number <= index || !id)
- return BP_RESULT_BADINPUT;
-
- *dest_object_id = object_id_from_bios_object_id(id[index]);
-
- return BP_RESULT_OK;
-}
-
static enum bp_result bios_parser_get_i2c_info(struct dc_bios *dcb,
struct graphics_object_id id,
struct graphics_object_i2c_info *info)
@@ -325,196 +258,6 @@ static enum bp_result bios_parser_get_i2c_info(struct dc_bios *dcb,
return BP_RESULT_NORECORD;
}
-static enum bp_result get_voltage_ddc_info_v1(uint8_t *i2c_line,
- ATOM_COMMON_TABLE_HEADER *header,
- uint8_t *address)
-{
- enum bp_result result = BP_RESULT_NORECORD;
- ATOM_VOLTAGE_OBJECT_INFO *info =
- (ATOM_VOLTAGE_OBJECT_INFO *) address;
-
- uint8_t *voltage_current_object = (uint8_t *) &info->asVoltageObj[0];
-
- while ((address + le16_to_cpu(header->usStructureSize)) > voltage_current_object) {
- ATOM_VOLTAGE_OBJECT *object =
- (ATOM_VOLTAGE_OBJECT *) voltage_current_object;
-
- if ((object->ucVoltageType == SET_VOLTAGE_INIT_MODE) &&
- (object->ucVoltageType &
- VOLTAGE_CONTROLLED_BY_I2C_MASK)) {
-
- *i2c_line = object->asControl.ucVoltageControlI2cLine
- ^ 0x90;
- result = BP_RESULT_OK;
- break;
- }
-
- voltage_current_object += object->ucSize;
- }
- return result;
-}
-
-static enum bp_result get_voltage_ddc_info_v3(uint8_t *i2c_line,
- uint32_t index,
- ATOM_COMMON_TABLE_HEADER *header,
- uint8_t *address)
-{
- enum bp_result result = BP_RESULT_NORECORD;
- ATOM_VOLTAGE_OBJECT_INFO_V3_1 *info =
- (ATOM_VOLTAGE_OBJECT_INFO_V3_1 *) address;
-
- uint8_t *voltage_current_object =
- (uint8_t *) (&(info->asVoltageObj[0]));
-
- while ((address + le16_to_cpu(header->usStructureSize)) > voltage_current_object) {
- ATOM_I2C_VOLTAGE_OBJECT_V3 *object =
- (ATOM_I2C_VOLTAGE_OBJECT_V3 *) voltage_current_object;
-
- if (object->sHeader.ucVoltageMode ==
- ATOM_INIT_VOLTAGE_REGULATOR) {
- if (object->sHeader.ucVoltageType == index) {
- *i2c_line = object->ucVoltageControlI2cLine
- ^ 0x90;
- result = BP_RESULT_OK;
- break;
- }
- }
-
- voltage_current_object += le16_to_cpu(object->sHeader.usSize);
- }
- return result;
-}
-
-static enum bp_result bios_parser_get_thermal_ddc_info(
- struct dc_bios *dcb,
- uint32_t i2c_channel_id,
- struct graphics_object_i2c_info *info)
-{
- struct bios_parser *bp = BP_FROM_DCB(dcb);
- ATOM_I2C_ID_CONFIG_ACCESS *config;
- ATOM_I2C_RECORD record;
-
- if (!info)
- return BP_RESULT_BADINPUT;
-
- config = (ATOM_I2C_ID_CONFIG_ACCESS *) &i2c_channel_id;
-
- record.sucI2cId.bfHW_Capable = config->sbfAccess.bfHW_Capable;
- record.sucI2cId.bfI2C_LineMux = config->sbfAccess.bfI2C_LineMux;
- record.sucI2cId.bfHW_EngineID = config->sbfAccess.bfHW_EngineID;
-
- return get_gpio_i2c_info(bp, &record, info);
-}
-
-static enum bp_result bios_parser_get_voltage_ddc_info(struct dc_bios *dcb,
- uint32_t index,
- struct graphics_object_i2c_info *info)
-{
- uint8_t i2c_line = 0;
- enum bp_result result = BP_RESULT_NORECORD;
- uint8_t *voltage_info_address;
- ATOM_COMMON_TABLE_HEADER *header;
- struct atom_data_revision revision = {0};
- struct bios_parser *bp = BP_FROM_DCB(dcb);
-
- if (!DATA_TABLES(VoltageObjectInfo))
- return result;
-
- voltage_info_address = bios_get_image(&bp->base, DATA_TABLES(VoltageObjectInfo), sizeof(ATOM_COMMON_TABLE_HEADER));
-
- header = (ATOM_COMMON_TABLE_HEADER *) voltage_info_address;
-
- get_atom_data_table_revision(header, &revision);
-
- switch (revision.major) {
- case 1:
- case 2:
- result = get_voltage_ddc_info_v1(&i2c_line, header,
- voltage_info_address);
- break;
- case 3:
- if (revision.minor != 1)
- break;
- result = get_voltage_ddc_info_v3(&i2c_line, index, header,
- voltage_info_address);
- break;
- }
-
- if (result == BP_RESULT_OK)
- result = bios_parser_get_thermal_ddc_info(dcb,
- i2c_line, info);
-
- return result;
-}
-
-/* TODO: temporary commented out to suppress 'defined but not used' warning */
-#if 0
-static enum bp_result bios_parser_get_ddc_info_for_i2c_line(
- struct bios_parser *bp,
- uint8_t i2c_line, struct graphics_object_i2c_info *info)
-{
- uint32_t offset;
- ATOM_OBJECT *object;
- ATOM_OBJECT_TABLE *table;
- uint32_t i;
-
- if (!info)
- return BP_RESULT_BADINPUT;
-
- offset = le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset);
-
- offset += bp->object_info_tbl_offset;
-
- table = GET_IMAGE(ATOM_OBJECT_TABLE, offset);
-
- if (!table)
- return BP_RESULT_BADBIOSTABLE;
-
- for (i = 0; i < table->ucNumberOfObjects; i++) {
- object = &table->asObjects[i];
-
- if (!object) {
- BREAK_TO_DEBUGGER(); /* Invalid object id */
- return BP_RESULT_BADINPUT;
- }
-
- offset = le16_to_cpu(object->usRecordOffset)
- + bp->object_info_tbl_offset;
-
- for (;;) {
- ATOM_COMMON_RECORD_HEADER *header =
- GET_IMAGE(ATOM_COMMON_RECORD_HEADER, offset);
-
- if (!header)
- return BP_RESULT_BADBIOSTABLE;
-
- offset += header->ucRecordSize;
-
- if (LAST_RECORD_TYPE == header->ucRecordType ||
- !header->ucRecordSize)
- break;
-
- if (ATOM_I2C_RECORD_TYPE == header->ucRecordType
- && sizeof(ATOM_I2C_RECORD) <=
- header->ucRecordSize) {
- ATOM_I2C_RECORD *record =
- (ATOM_I2C_RECORD *) header;
-
- if (i2c_line != record->sucI2cId.bfI2C_LineMux)
- continue;
-
- /* get the I2C info */
- if (get_gpio_i2c_info(bp, record, info) ==
- BP_RESULT_OK)
- return BP_RESULT_OK;
- }
- }
- }
-
- return BP_RESULT_NORECORD;
-}
-#endif
-
static enum bp_result bios_parser_get_hpd_info(struct dc_bios *dcb,
struct graphics_object_id id,
struct graphics_object_hpd_info *info)
@@ -1129,62 +872,6 @@ static bool bios_parser_is_device_id_supported(
return (le16_to_cpu(bp->object_info_tbl.v1_1->usDeviceSupport) & mask) != 0;
}
-static enum bp_result bios_parser_crt_control(
- struct dc_bios *dcb,
- enum engine_id engine_id,
- bool enable,
- uint32_t pixel_clock)
-{
- struct bios_parser *bp = BP_FROM_DCB(dcb);
- uint8_t standard;
-
- if (!bp->cmd_tbl.dac1_encoder_control &&
- engine_id == ENGINE_ID_DACA)
- return BP_RESULT_FAILURE;
- if (!bp->cmd_tbl.dac2_encoder_control &&
- engine_id == ENGINE_ID_DACB)
- return BP_RESULT_FAILURE;
- /* validate params */
- switch (engine_id) {
- case ENGINE_ID_DACA:
- case ENGINE_ID_DACB:
- break;
- default:
- /* unsupported engine */
- return BP_RESULT_FAILURE;
- }
-
- standard = ATOM_DAC1_PS2; /* == ATOM_DAC2_PS2 */
-
- if (enable) {
- if (engine_id == ENGINE_ID_DACA) {
- bp->cmd_tbl.dac1_encoder_control(bp, enable,
- pixel_clock, standard);
- if (bp->cmd_tbl.dac1_output_control != NULL)
- bp->cmd_tbl.dac1_output_control(bp, enable);
- } else {
- bp->cmd_tbl.dac2_encoder_control(bp, enable,
- pixel_clock, standard);
- if (bp->cmd_tbl.dac2_output_control != NULL)
- bp->cmd_tbl.dac2_output_control(bp, enable);
- }
- } else {
- if (engine_id == ENGINE_ID_DACA) {
- if (bp->cmd_tbl.dac1_output_control != NULL)
- bp->cmd_tbl.dac1_output_control(bp, enable);
- bp->cmd_tbl.dac1_encoder_control(bp, enable,
- pixel_clock, standard);
- } else {
- if (bp->cmd_tbl.dac2_output_control != NULL)
- bp->cmd_tbl.dac2_output_control(bp, enable);
- bp->cmd_tbl.dac2_encoder_control(bp, enable,
- pixel_clock, standard);
- }
- }
-
- return BP_RESULT_OK;
-}
-
static ATOM_HPD_INT_RECORD *get_hpd_record(struct bios_parser *bp,
ATOM_OBJECT *object)
{
@@ -1219,49 +906,6 @@ static ATOM_HPD_INT_RECORD *get_hpd_record(struct bios_parser *bp,
return NULL;
}
-/**
- * Get I2C information of input object id
- *
- * search all records to find the ATOM_I2C_RECORD_TYPE record IR
- */
-static ATOM_I2C_RECORD *get_i2c_record(
- struct bios_parser *bp,
- ATOM_OBJECT *object)
-{
- uint32_t offset;
- ATOM_COMMON_RECORD_HEADER *record_header;
-
- if (!object) {
- BREAK_TO_DEBUGGER();
- /* Invalid object */
- return NULL;
- }
-
- offset = le16_to_cpu(object->usRecordOffset)
- + bp->object_info_tbl_offset;
-
- for (;;) {
- record_header = GET_IMAGE(ATOM_COMMON_RECORD_HEADER, offset);
-
- if (!record_header)
- return NULL;
-
- if (LAST_RECORD_TYPE == record_header->ucRecordType ||
- 0 == record_header->ucRecordSize)
- break;
-
- if (ATOM_I2C_RECORD_TYPE == record_header->ucRecordType &&
- sizeof(ATOM_I2C_RECORD) <=
- record_header->ucRecordSize) {
- return (ATOM_I2C_RECORD *)record_header;
- }
-
- offset += record_header->ucRecordSize;
- }
-
- return NULL;
-}
-
static enum bp_result get_ss_info_from_ss_info_table(
struct bios_parser *bp,
uint32_t id,
@@ -2356,40 +2000,6 @@ static ATOM_OBJECT *get_bios_object(struct bios_parser *bp,
return NULL;
}
-static uint32_t get_dest_obj_list(struct bios_parser *bp,
- ATOM_OBJECT *object, uint16_t **id_list)
-{
- uint32_t offset;
- uint8_t *number;
-
- if (!object) {
- BREAK_TO_DEBUGGER(); /* Invalid object id */
- return 0;
- }
-
- offset = le16_to_cpu(object->usSrcDstTableOffset)
- + bp->object_info_tbl_offset;
-
- number = GET_IMAGE(uint8_t, offset);
- if (!number)
- return 0;
-
- offset += sizeof(uint8_t);
- offset += sizeof(uint16_t) * (*number);
-
- number = GET_IMAGE(uint8_t, offset);
- if ((!number) || (!*number))
- return 0;
-
- offset += sizeof(uint8_t);
- *id_list = (uint16_t *)bios_get_image(&bp->base, offset, *number * sizeof(uint16_t));
-
- if (!*id_list)
- return 0;
-
- return *number;
-}
-
static uint32_t get_src_obj_list(struct bios_parser *bp, ATOM_OBJECT *object,
uint16_t **id_list)
{
@@ -2417,35 +2027,6 @@ static uint32_t get_src_obj_list(struct bios_parser *bp, ATOM_OBJECT *object,
return *number;
}
-static uint32_t get_dst_number_from_object(struct bios_parser *bp,
- ATOM_OBJECT *object)
-{
- uint32_t offset;
- uint8_t *number;
-
- if (!object) {
- BREAK_TO_DEBUGGER(); /* Invalid encoder object id*/
- return 0;
- }
-
- offset = le16_to_cpu(object->usSrcDstTableOffset)
- + bp->object_info_tbl_offset;
-
- number = GET_IMAGE(uint8_t, offset);
- if (!number)
- return 0;
-
- offset += sizeof(uint8_t);
- offset += sizeof(uint16_t) * (*number);
-
- number = GET_IMAGE(uint8_t, offset);
-
- if (!number)
- return 0;
-
- return *number;
-}
-
static struct device_id device_type_from_device_id(uint16_t device_id)
{
@@ -2625,752 +2206,6 @@ static uint32_t get_support_mask_for_device_id(struct device_id device_id)
}
/**
- * HwContext interface for writing MM registers
- */
-
-static bool i2c_read(
- struct bios_parser *bp,
- struct graphics_object_i2c_info *i2c_info,
- uint8_t *buffer,
- uint32_t length)
-{
- struct ddc *ddc;
- uint8_t offset[2] = { 0, 0 };
- bool result = false;
- struct i2c_command cmd;
- struct gpio_ddc_hw_info hw_info = {
- i2c_info->i2c_hw_assist,
- i2c_info->i2c_line };
-
- ddc = dal_gpio_create_ddc(bp->base.ctx->gpio_service,
- i2c_info->gpio_info.clk_a_register_index,
- (1 << i2c_info->gpio_info.clk_a_shift), &hw_info);
-
- if (!ddc)
- return result;
-
- /*Using SW engine */
- cmd.engine = I2C_COMMAND_ENGINE_SW;
- cmd.speed = ddc->ctx->dc->caps.i2c_speed_in_khz;
-
- {
- struct i2c_payload payloads[] = {
- {
- .address = i2c_info->i2c_slave_address >> 1,
- .data = offset,
- .length = sizeof(offset),
- .write = true
- },
- {
- .address = i2c_info->i2c_slave_address >> 1,
- .data = buffer,
- .length = length,
- .write = false
- }
- };
-
- cmd.payloads = payloads;
- cmd.number_of_payloads = ARRAY_SIZE(payloads);
-
- /* TODO route this through drm i2c_adapter */
- result = dal_i2caux_submit_i2c_command(
- ddc->ctx->i2caux,
- ddc,
- &cmd);
- }
-
- dal_gpio_destroy_ddc(&ddc);
-
- return result;
-}
-
-/**
- * Read external display connection info table through i2c.
- * validate the GUID and checksum.
- *
- * @return enum bp_result whether all data was sucessfully read
- */
-static enum bp_result get_ext_display_connection_info(
- struct bios_parser *bp,
- ATOM_OBJECT *opm_object,
- ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO *ext_display_connection_info_tbl)
-{
- bool config_tbl_present = false;
- ATOM_I2C_RECORD *i2c_record = NULL;
- uint32_t i = 0;
-
- if (opm_object == NULL)
- return BP_RESULT_BADINPUT;
-
- i2c_record = get_i2c_record(bp, opm_object);
-
- if (i2c_record != NULL) {
- ATOM_GPIO_I2C_INFO *gpio_i2c_header;
- struct graphics_object_i2c_info i2c_info;
-
- gpio_i2c_header = GET_IMAGE(ATOM_GPIO_I2C_INFO,
- bp->master_data_tbl->ListOfDataTables.GPIO_I2C_Info);
-
- if (NULL == gpio_i2c_header)
- return BP_RESULT_BADBIOSTABLE;
-
- if (get_gpio_i2c_info(bp, i2c_record, &i2c_info) !=
- BP_RESULT_OK)
- return BP_RESULT_BADBIOSTABLE;
-
- if (i2c_read(bp,
- &i2c_info,
- (uint8_t *)ext_display_connection_info_tbl,
- sizeof(ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO))) {
- config_tbl_present = true;
- }
- }
-
- /* Validate GUID */
- if (config_tbl_present)
- for (i = 0; i < NUMBER_OF_UCHAR_FOR_GUID; i++) {
- if (ext_display_connection_info_tbl->ucGuid[i]
- != ext_display_connection_guid[i]) {
- config_tbl_present = false;
- break;
- }
- }
-
- /* Validate checksum */
- if (config_tbl_present) {
- uint8_t check_sum = 0;
- uint8_t *buf =
- (uint8_t *)ext_display_connection_info_tbl;
-
- for (i = 0; i < sizeof(ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO);
- i++) {
- check_sum += buf[i];
- }
-
- if (check_sum != 0)
- config_tbl_present = false;
- }
-
- if (config_tbl_present)
- return BP_RESULT_OK;
- else
- return BP_RESULT_FAILURE;
-}
-
-/*
- * Gets the first device ID in the same group as the given ID for enumerating.
- * For instance, if any DFP device ID is passed, returns the device ID for DFP1.
- *
- * The first device ID in the same group as the passed device ID, or 0 if no
- * matching device group found.
- */
-static uint32_t enum_first_device_id(uint32_t dev_id)
-{
- /* Return the first in the group that this ID belongs to. */
- if (dev_id & ATOM_DEVICE_CRT_SUPPORT)
- return ATOM_DEVICE_CRT1_SUPPORT;
- else if (dev_id & ATOM_DEVICE_DFP_SUPPORT)
- return ATOM_DEVICE_DFP1_SUPPORT;
- else if (dev_id & ATOM_DEVICE_LCD_SUPPORT)
- return ATOM_DEVICE_LCD1_SUPPORT;
- else if (dev_id & ATOM_DEVICE_TV_SUPPORT)
- return ATOM_DEVICE_TV1_SUPPORT;
- else if (dev_id & ATOM_DEVICE_CV_SUPPORT)
- return ATOM_DEVICE_CV_SUPPORT;
-
- /* No group found for this device ID. */
-
- dm_error("%s: incorrect input %d\n", __func__, dev_id);
- /* No matching support flag for given device ID */
- return 0;
-}
-
-/*
- * Gets the next device ID in the group for a given device ID.
- *
- * The current device ID being enumerated on.
- *
- * The next device ID in the group, or 0 if no device exists.
- */
-static uint32_t enum_next_dev_id(uint32_t dev_id)
-{
- /* Get next device ID in the group. */
- switch (dev_id) {
- case ATOM_DEVICE_CRT1_SUPPORT:
- return ATOM_DEVICE_CRT2_SUPPORT;
- case ATOM_DEVICE_LCD1_SUPPORT:
- return ATOM_DEVICE_LCD2_SUPPORT;
- case ATOM_DEVICE_DFP1_SUPPORT:
- return ATOM_DEVICE_DFP2_SUPPORT;
- case ATOM_DEVICE_DFP2_SUPPORT:
- return ATOM_DEVICE_DFP3_SUPPORT;
- case ATOM_DEVICE_DFP3_SUPPORT:
- return ATOM_DEVICE_DFP4_SUPPORT;
- case ATOM_DEVICE_DFP4_SUPPORT:
- return ATOM_DEVICE_DFP5_SUPPORT;
- case ATOM_DEVICE_DFP5_SUPPORT:
- return ATOM_DEVICE_DFP6_SUPPORT;
- }
-
- /* Done enumerating through devices. */
- return 0;
-}
-
-/*
- * Returns the new device tag record for patched BIOS object.
- *
- * [IN] pExtDisplayPath - External display path to copy device tag from.
- * [IN] deviceSupport - Bit vector for device ID support flags.
- * [OUT] pDeviceTag - Device tag structure to fill with patched data.
- *
- * True if a compatible device ID was found, false otherwise.
- */
-static bool get_patched_device_tag(
- struct bios_parser *bp,
- EXT_DISPLAY_PATH *ext_display_path,
- uint32_t device_support,
- ATOM_CONNECTOR_DEVICE_TAG *device_tag)
-{
- uint32_t dev_id;
- /* Use fallback behaviour if not supported. */
- if (!bp->remap_device_tags) {
- device_tag->ulACPIDeviceEnum =
- cpu_to_le32((uint32_t) le16_to_cpu(ext_display_path->usDeviceACPIEnum));
- device_tag->usDeviceID =
- cpu_to_le16(le16_to_cpu(ext_display_path->usDeviceTag));
- return true;
- }
-
- /* Find the first unused in the same group. */
- dev_id = enum_first_device_id(le16_to_cpu(ext_display_path->usDeviceTag));
- while (dev_id != 0) {
- /* Assign this device ID if supported. */
- if ((device_support & dev_id) != 0) {
- device_tag->ulACPIDeviceEnum =
- cpu_to_le32((uint32_t) le16_to_cpu(ext_display_path->usDeviceACPIEnum));
- device_tag->usDeviceID = cpu_to_le16((USHORT) dev_id);
- return true;
- }
-
- dev_id = enum_next_dev_id(dev_id);
- }
-
- /* No compatible device ID found. */
- return false;
-}
-
-/*
- * Adds a device tag to a BIOS object's device tag record if there is
- * matching device ID supported.
- *
- * pObject - Pointer to the BIOS object to add the device tag to.
- * pExtDisplayPath - Display path to retrieve base device ID from.
- * pDeviceSupport - Pointer to bit vector for supported device IDs.
- */
-static void add_device_tag_from_ext_display_path(
- struct bios_parser *bp,
- ATOM_OBJECT *object,
- EXT_DISPLAY_PATH *ext_display_path,
- uint32_t *device_support)
-{
- /* Get device tag record for object. */
- ATOM_CONNECTOR_DEVICE_TAG *device_tag = NULL;
- ATOM_CONNECTOR_DEVICE_TAG_RECORD *device_tag_record = NULL;
- enum bp_result result =
- bios_parser_get_device_tag_record(
- bp, object, &device_tag_record);
-
- if ((le16_to_cpu(ext_display_path->usDeviceTag) != CONNECTOR_OBJECT_ID_NONE)
- && (result == BP_RESULT_OK)) {
- uint8_t index;
-
- if ((device_tag_record->ucNumberOfDevice == 1) &&
- (le16_to_cpu(device_tag_record->asDeviceTag[0].usDeviceID) == 0)) {
- /*Workaround bug in current VBIOS releases where
- * ucNumberOfDevice = 1 but there is no actual device
- * tag data. This w/a is temporary until the updated
- * VBIOS is distributed. */
- device_tag_record->ucNumberOfDevice =
- device_tag_record->ucNumberOfDevice - 1;
- }
-
- /* Attempt to find a matching device ID. */
- index = device_tag_record->ucNumberOfDevice;
- device_tag = &device_tag_record->asDeviceTag[index];
- if (get_patched_device_tag(
- bp,
- ext_display_path,
- *device_support,
- device_tag)) {
- /* Update cached device support to remove assigned ID.
- */
- *device_support &= ~le16_to_cpu(device_tag->usDeviceID);
- device_tag_record->ucNumberOfDevice++;
- }
- }
-}
-
-/*
- * Read out a single EXT_DISPLAY_PATH from the external display connection info
- * table. The specific entry in the table is determined by the enum_id passed
- * in.
- *
- * EXT_DISPLAY_PATH describing a single Configuration table entry
- */
-
-#define INVALID_CONNECTOR 0xffff
-
-static EXT_DISPLAY_PATH *get_ext_display_path_entry(
- ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO *config_table,
- uint32_t bios_object_id)
-{
- EXT_DISPLAY_PATH *ext_display_path;
- uint32_t ext_display_path_index =
- ((bios_object_id & ENUM_ID_MASK) >> ENUM_ID_SHIFT) - 1;
-
- if (ext_display_path_index >= MAX_NUMBER_OF_EXT_DISPLAY_PATH)
- return NULL;
-
- ext_display_path = &config_table->sPath[ext_display_path_index];
-
- if (le16_to_cpu(ext_display_path->usDeviceConnector) == INVALID_CONNECTOR)
- ext_display_path->usDeviceConnector = cpu_to_le16(0);
-
- return ext_display_path;
-}
-
-/*
- * Get AUX/DDC information of input object id
- *
- * search all records to find the ATOM_CONNECTOR_AUXDDC_LUT_RECORD_TYPE record
- * IR
- */
-static ATOM_CONNECTOR_AUXDDC_LUT_RECORD *get_ext_connector_aux_ddc_lut_record(
- struct bios_parser *bp,
- ATOM_OBJECT *object)
-{
- uint32_t offset;
- ATOM_COMMON_RECORD_HEADER *header;
-
- if (!object) {
- BREAK_TO_DEBUGGER();
- /* Invalid object */
- return NULL;
- }
-
- offset = le16_to_cpu(object->usRecordOffset)
- + bp->object_info_tbl_offset;
-
- for (;;) {
- header = GET_IMAGE(ATOM_COMMON_RECORD_HEADER, offset);
-
- if (!header)
- return NULL;
-
- if (LAST_RECORD_TYPE == header->ucRecordType ||
- 0 == header->ucRecordSize)
- break;
-
- if (ATOM_CONNECTOR_AUXDDC_LUT_RECORD_TYPE ==
- header->ucRecordType &&
- sizeof(ATOM_CONNECTOR_AUXDDC_LUT_RECORD) <=
- header->ucRecordSize)
- return (ATOM_CONNECTOR_AUXDDC_LUT_RECORD *)(header);
-
- offset += header->ucRecordSize;
- }
-
- return NULL;
-}
-
-/*
- * Get AUX/DDC information of input object id
- *
- * search all records to find the ATOM_CONNECTOR_AUXDDC_LUT_RECORD_TYPE record
- * IR
- */
-static ATOM_CONNECTOR_HPDPIN_LUT_RECORD *get_ext_connector_hpd_pin_lut_record(
- struct bios_parser *bp,
- ATOM_OBJECT *object)
-{
- uint32_t offset;
- ATOM_COMMON_RECORD_HEADER *header;
-
- if (!object) {
- BREAK_TO_DEBUGGER();
- /* Invalid object */
- return NULL;
- }
-
- offset = le16_to_cpu(object->usRecordOffset)
- + bp->object_info_tbl_offset;
-
- for (;;) {
- header = GET_IMAGE(ATOM_COMMON_RECORD_HEADER, offset);
-
- if (!header)
- return NULL;
-
- if (LAST_RECORD_TYPE == header->ucRecordType ||
- 0 == header->ucRecordSize)
- break;
-
- if (ATOM_CONNECTOR_HPDPIN_LUT_RECORD_TYPE ==
- header->ucRecordType &&
- sizeof(ATOM_CONNECTOR_HPDPIN_LUT_RECORD) <=
- header->ucRecordSize)
- return (ATOM_CONNECTOR_HPDPIN_LUT_RECORD *)header;
-
- offset += header->ucRecordSize;
- }
-
- return NULL;
-}
-
-/*
- * Check whether we need to patch the VBIOS connector info table with
- * data from an external display connection info table. This is
- * necessary to support MXM boards with an OPM (output personality
- * module). With these designs, the VBIOS connector info table
- * specifies an MXM_CONNECTOR with a unique ID. The driver retrieves
- * the external connection info table through i2c and then looks up the
- * connector ID to find the real connector type (e.g. DFP1).
- *
- */
-static enum bp_result patch_bios_image_from_ext_display_connection_info(
- struct bios_parser *bp)
-{
- ATOM_OBJECT_TABLE *connector_tbl;
- uint32_t connector_tbl_offset;
- struct graphics_object_id object_id;
- ATOM_OBJECT *object;
- ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO ext_display_connection_info_tbl;
- EXT_DISPLAY_PATH *ext_display_path;
- ATOM_CONNECTOR_AUXDDC_LUT_RECORD *aux_ddc_lut_record = NULL;
- ATOM_I2C_RECORD *i2c_record = NULL;
- ATOM_CONNECTOR_HPDPIN_LUT_RECORD *hpd_pin_lut_record = NULL;
- ATOM_HPD_INT_RECORD *hpd_record = NULL;
- ATOM_OBJECT_TABLE *encoder_table;
- uint32_t encoder_table_offset;
- ATOM_OBJECT *opm_object = NULL;
- uint32_t i = 0;
- struct graphics_object_id opm_object_id =
- dal_graphics_object_id_init(
- GENERIC_ID_MXM_OPM,
- ENUM_ID_1,
- OBJECT_TYPE_GENERIC);
- ATOM_CONNECTOR_DEVICE_TAG_RECORD *dev_tag_record;
- uint32_t cached_device_support =
- le16_to_cpu(bp->object_info_tbl.v1_1->usDeviceSupport);
-
- uint32_t dst_number;
- uint16_t *dst_object_id_list;
-
- opm_object = get_bios_object(bp, opm_object_id);
- if (!opm_object)
- return BP_RESULT_UNSUPPORTED;
-
- memset(&ext_display_connection_info_tbl, 0,
- sizeof(ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO));
-
- connector_tbl_offset = bp->object_info_tbl_offset
- + le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset);
- connector_tbl = GET_IMAGE(ATOM_OBJECT_TABLE, connector_tbl_offset);
-
- /* Read Connector info table from EEPROM through i2c */
- if (get_ext_display_connection_info(bp,
- opm_object,
- &ext_display_connection_info_tbl) != BP_RESULT_OK) {
-
- DC_LOG_WARNING("%s: Failed to read Connection Info Table", __func__);
- return BP_RESULT_UNSUPPORTED;
- }
-
- /* Get pointer to AUX/DDC and HPD LUTs */
- aux_ddc_lut_record =
- get_ext_connector_aux_ddc_lut_record(bp, opm_object);
- hpd_pin_lut_record =
- get_ext_connector_hpd_pin_lut_record(bp, opm_object);
-
- if ((aux_ddc_lut_record == NULL) || (hpd_pin_lut_record == NULL))
- return BP_RESULT_UNSUPPORTED;
-
- /* Cache support bits for currently unmapped device types. */
- if (bp->remap_device_tags) {
- for (i = 0; i < connector_tbl->ucNumberOfObjects; ++i) {
- uint32_t j;
- /* Remove support for all non-MXM connectors. */
- object = &connector_tbl->asObjects[i];
- object_id = object_id_from_bios_object_id(
- le16_to_cpu(object->usObjectID));
- if ((OBJECT_TYPE_CONNECTOR != object_id.type) ||
- (CONNECTOR_ID_MXM == object_id.id))
- continue;
-
- /* Remove support for all device tags. */
- if (bios_parser_get_device_tag_record(
- bp, object, &dev_tag_record) != BP_RESULT_OK)
- continue;
-
- for (j = 0; j < dev_tag_record->ucNumberOfDevice; ++j) {
- ATOM_CONNECTOR_DEVICE_TAG *device_tag =
- &dev_tag_record->asDeviceTag[j];
- cached_device_support &=
- ~le16_to_cpu(device_tag->usDeviceID);
- }
- }
- }
-
- /* Find all MXM connector objects and patch them with connector info
- * from the external display connection info table. */
- for (i = 0; i < connector_tbl->ucNumberOfObjects; i++) {
- uint32_t j;
-
- object = &connector_tbl->asObjects[i];
- object_id = object_id_from_bios_object_id(le16_to_cpu(object->usObjectID));
- if ((OBJECT_TYPE_CONNECTOR != object_id.type) ||
- (CONNECTOR_ID_MXM != object_id.id))
- continue;
-
- /* Get the correct connection info table entry based on the enum
- * id. */
- ext_display_path = get_ext_display_path_entry(
- &ext_display_connection_info_tbl,
- le16_to_cpu(object->usObjectID));
- if (!ext_display_path)
- return BP_RESULT_FAILURE;
-
- /* Patch device connector ID */
- object->usObjectID =
- cpu_to_le16(le16_to_cpu(ext_display_path->usDeviceConnector));
-
- /* Patch device tag, ulACPIDeviceEnum. */
- add_device_tag_from_ext_display_path(
- bp,
- object,
- ext_display_path,
- &cached_device_support);
-
- /* Patch HPD info */
- if (ext_display_path->ucExtHPDPINLutIndex <
- MAX_NUMBER_OF_EXT_HPDPIN_LUT_ENTRIES) {
- hpd_record = get_hpd_record(bp, object);
- if (hpd_record) {
- uint8_t index =
- ext_display_path->ucExtHPDPINLutIndex;
- hpd_record->ucHPDIntGPIOID =
- hpd_pin_lut_record->ucHPDPINMap[index];
- } else {
- BREAK_TO_DEBUGGER();
- /* Invalid hpd record */
- return BP_RESULT_FAILURE;
- }
- }
-
- /* Patch I2C/AUX info */
- if (ext_display_path->ucExtHPDPINLutIndex <
- MAX_NUMBER_OF_EXT_AUXDDC_LUT_ENTRIES) {
- i2c_record = get_i2c_record(bp, object);
- if (i2c_record) {
- uint8_t index =
- ext_display_path->ucExtAUXDDCLutIndex;
- i2c_record->sucI2cId =
- aux_ddc_lut_record->ucAUXDDCMap[index];
- } else {
- BREAK_TO_DEBUGGER();
- /* Invalid I2C record */
- return BP_RESULT_FAILURE;
- }
- }
-
- /* Merge with other MXM connectors that map to the same physical
- * connector. */
- for (j = i + 1;
- j < connector_tbl->ucNumberOfObjects; j++) {
- ATOM_OBJECT *next_object;
- struct graphics_object_id next_object_id;
- EXT_DISPLAY_PATH *next_ext_display_path;
-
- next_object = &connector_tbl->asObjects[j];
- next_object_id = object_id_from_bios_object_id(
- le16_to_cpu(next_object->usObjectID));
-
- if ((OBJECT_TYPE_CONNECTOR != next_object_id.type) &&
- (CONNECTOR_ID_MXM == next_object_id.id))
- continue;
-
- next_ext_display_path = get_ext_display_path_entry(
- &ext_display_connection_info_tbl,
- le16_to_cpu(next_object->usObjectID));
-
- if (next_ext_display_path == NULL)
- return BP_RESULT_FAILURE;
-
- /* Merge if using same connector. */
- if ((le16_to_cpu(next_ext_display_path->usDeviceConnector) ==
- le16_to_cpu(ext_display_path->usDeviceConnector)) &&
- (le16_to_cpu(ext_display_path->usDeviceConnector) != 0)) {
- /* Clear duplicate connector from table. */
- next_object->usObjectID = cpu_to_le16(0);
- add_device_tag_from_ext_display_path(
- bp,
- object,
- ext_display_path,
- &cached_device_support);
- }
- }
- }
-
- /* Find all encoders which have an MXM object as their destination.
- * Replace the MXM object with the real connector Id from the external
- * display connection info table */
-
- encoder_table_offset = bp->object_info_tbl_offset
- + le16_to_cpu(bp->object_info_tbl.v1_1->usEncoderObjectTableOffset);
- encoder_table = GET_IMAGE(ATOM_OBJECT_TABLE, encoder_table_offset);
-
- for (i = 0; i < encoder_table->ucNumberOfObjects; i++) {
- uint32_t j;
-
- object = &encoder_table->asObjects[i];
-
- dst_number = get_dest_obj_list(bp, object, &dst_object_id_list);
-
- for (j = 0; j < dst_number; j++) {
- object_id = object_id_from_bios_object_id(
- dst_object_id_list[j]);
-
- if ((OBJECT_TYPE_CONNECTOR != object_id.type) ||
- (CONNECTOR_ID_MXM != object_id.id))
- continue;
-
- /* Get the correct connection info table entry based on
- * the enum id. */
- ext_display_path =
- get_ext_display_path_entry(
- &ext_display_connection_info_tbl,
- dst_object_id_list[j]);
-
- if (ext_display_path == NULL)
- return BP_RESULT_FAILURE;
-
- dst_object_id_list[j] =
- le16_to_cpu(ext_display_path->usDeviceConnector);
- }
- }
-
- return BP_RESULT_OK;
-}
-
-/*
- * Check whether we need to patch the VBIOS connector info table with
- * data from an external display connection info table. This is
- * necessary to support MXM boards with an OPM (output personality
- * module). With these designs, the VBIOS connector info table
- * specifies an MXM_CONNECTOR with a unique ID. The driver retrieves
- * the external connection info table through i2c and then looks up the
- * connector ID to find the real connector type (e.g. DFP1).
- *
- */
-
-static void process_ext_display_connection_info(struct bios_parser *bp)
-{
- ATOM_OBJECT_TABLE *connector_tbl;
- uint32_t connector_tbl_offset;
- struct graphics_object_id object_id;
- ATOM_OBJECT *object;
- bool mxm_connector_found = false;
- bool null_entry_found = false;
- uint32_t i = 0;
-
- connector_tbl_offset = bp->object_info_tbl_offset +
- le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset);
- connector_tbl = GET_IMAGE(ATOM_OBJECT_TABLE, connector_tbl_offset);
-
- /* Look for MXM connectors to determine whether we need patch the VBIOS
- * connector info table. Look for null entries to determine whether we
- * need to compact connector table. */
- for (i = 0; i < connector_tbl->ucNumberOfObjects; i++) {
- object = &connector_tbl->asObjects[i];
- object_id = object_id_from_bios_object_id(le16_to_cpu(object->usObjectID));
-
- if ((OBJECT_TYPE_CONNECTOR == object_id.type) &&
- (CONNECTOR_ID_MXM == object_id.id)) {
- /* Once we found MXM connector - we can break */
- mxm_connector_found = true;
- break;
- } else if (OBJECT_TYPE_CONNECTOR != object_id.type) {
- /* We need to continue looping - to check if MXM
- * connector present */
- null_entry_found = true;
- }
- }
-
- /* Patch BIOS image */
- if (mxm_connector_found || null_entry_found) {
- uint32_t connectors_num = 0;
- uint8_t *original_bios;
- /* Step 1: Replace bios image with the new copy which will be
- * patched */
- bp->base.bios_local_image = kzalloc(bp->base.bios_size,
- GFP_KERNEL);
- if (bp->base.bios_local_image == NULL) {
- BREAK_TO_DEBUGGER();
- /* Failed to alloc bp->base.bios_local_image */
- return;
- }
-
- memmove(bp->base.bios_local_image, bp->base.bios, bp->base.bios_size);
- original_bios = bp->base.bios;
- bp->base.bios = bp->base.bios_local_image;
- connector_tbl =
- GET_IMAGE(ATOM_OBJECT_TABLE, connector_tbl_offset);
-
- /* Step 2: (only if MXM connector found) Patch BIOS image with
- * info from external module */
- if (mxm_connector_found &&
- patch_bios_image_from_ext_display_connection_info(bp) !=
- BP_RESULT_OK) {
- /* Patching the bios image has failed. We will copy
- * again original image provided and afterwards
- * only remove null entries */
- memmove(
- bp->base.bios_local_image,
- original_bios,
- bp->base.bios_size);
- }
-
- /* Step 3: Compact connector table (remove null entries, valid
- * entries moved to beginning) */
- for (i = 0; i < connector_tbl->ucNumberOfObjects; i++) {
- object = &connector_tbl->asObjects[i];
- object_id = object_id_from_bios_object_id(
- le16_to_cpu(object->usObjectID));
-
- if (OBJECT_TYPE_CONNECTOR != object_id.type)
- continue;
-
- if (i != connectors_num) {
- memmove(
- &connector_tbl->
- asObjects[connectors_num],
- object,
- sizeof(ATOM_OBJECT));
- }
- ++connectors_num;
- }
- connector_tbl->ucNumberOfObjects = (uint8_t)connectors_num;
- }
-}
-
-static void bios_parser_post_init(struct dc_bios *dcb)
-{
- struct bios_parser *bp = BP_FROM_DCB(dcb);
-
- process_ext_display_connection_info(bp);
-}
-
-/**
* bios_parser_set_scratch_critical_state
*
* @brief
@@ -3961,22 +2796,12 @@ static enum bp_result bios_get_board_layout_info(
static const struct dc_vbios_funcs vbios_funcs = {
.get_connectors_number = bios_parser_get_connectors_number,
- .get_encoder_id = bios_parser_get_encoder_id,
-
.get_connector_id = bios_parser_get_connector_id,
- .get_dst_number = bios_parser_get_dst_number,
-
.get_src_obj = bios_parser_get_src_obj,
- .get_dst_obj = bios_parser_get_dst_obj,
-
.get_i2c_info = bios_parser_get_i2c_info,
- .get_voltage_ddc_info = bios_parser_get_voltage_ddc_info,
-
- .get_thermal_ddc_info = bios_parser_get_thermal_ddc_info,
-
.get_hpd_info = bios_parser_get_hpd_info,
.get_device_tag = bios_parser_get_device_tag,
@@ -3995,7 +2820,6 @@ static const struct dc_vbios_funcs vbios_funcs = {
/* bios scratch register communication */
.is_accelerated_mode = bios_is_accelerated_mode,
- .get_vga_enabled_displays = bios_get_vga_enabled_displays,
.set_scratch_critical_state = bios_parser_set_scratch_critical_state,
@@ -4006,8 +2830,6 @@ static const struct dc_vbios_funcs vbios_funcs = {
.transmitter_control = bios_parser_transmitter_control,
- .crt_control = bios_parser_crt_control, /* not used in DAL3. keep for now in case we need to support VGA on Bonaire */
-
.enable_crtc = bios_parser_enable_crtc,
.adjust_pixel_clock = bios_parser_adjust_pixel_clock,
@@ -4027,7 +2849,6 @@ static const struct dc_vbios_funcs vbios_funcs = {
.enable_disp_power_gating = bios_parser_enable_disp_power_gating,
/* SW init and patch */
- .post_init = bios_parser_post_init, /* patch vbios table for mxm module by reading i2c */
.bios_parser_destroy = bios_parser_destroy,