drm/radeon/kms: add voltage type to atom set voltage function
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / radeon / radeon_atombios.c
index 02d5c415f499304633eae62289a7eba1ff11c3a3..330a5b56602b3af47ed5f9dc9d89a4831926e4d9 100644 (file)
@@ -675,7 +675,8 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
                                                        ATOM_ENCODER_CAP_RECORD *cap_record;
                                                        u16 caps = 0;
 
-                                                       while (record->ucRecordType > 0 &&
+                                                       while (record->ucRecordSize > 0 &&
+                                                              record->ucRecordType > 0 &&
                                                               record->ucRecordType <= ATOM_MAX_OBJECT_RECORD_NUMBER) {
                                                                switch (record->ucRecordType) {
                                                                case ATOM_ENCODER_CAP_RECORD_TYPE:
@@ -720,7 +721,8 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
                                                                        break;
                                                        }
 
-                                                       while (record->ucRecordType > 0 &&
+                                                       while (record->ucRecordSize > 0 &&
+                                                              record->ucRecordType > 0 &&
                                                               record->ucRecordType <= ATOM_MAX_OBJECT_RECORD_NUMBER) {
                                                                switch (record->ucRecordType) {
                                                                case ATOM_I2C_RECORD_TYPE:
@@ -782,10 +784,9 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
                                                ATOM_HPD_INT_RECORD *hpd_record;
                                                ATOM_I2C_ID_CONFIG_ACCESS *i2c_config;
 
-                                               while (record->ucRecordType > 0
-                                                      && record->
-                                                      ucRecordType <=
-                                                      ATOM_MAX_OBJECT_RECORD_NUMBER) {
+                                               while (record->ucRecordSize > 0 &&
+                                                      record->ucRecordType > 0 &&
+                                                      record->ucRecordType <= ATOM_MAX_OBJECT_RECORD_NUMBER) {
                                                        switch (record->ucRecordType) {
                                                        case ATOM_I2C_RECORD_TYPE:
                                                                i2c_record =
@@ -2576,25 +2577,25 @@ union set_voltage {
        struct _SET_VOLTAGE_PARAMETERS_V2 v2;
 };
 
-void radeon_atom_set_voltage(struct radeon_device *rdev, u16 level)
+void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type)
 {
        union set_voltage args;
        int index = GetIndexIntoMasterTable(COMMAND, SetVoltage);
-       u8 frev, crev, volt_index = level;
+       u8 frev, crev, volt_index = voltage_level;
 
        if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
                return;
 
        switch (crev) {
        case 1:
-               args.v1.ucVoltageType = SET_VOLTAGE_TYPE_ASIC_VDDC;
+               args.v1.ucVoltageType = voltage_type;
                args.v1.ucVoltageMode = SET_ASIC_VOLTAGE_MODE_ALL_SOURCE;
                args.v1.ucVoltageIndex = volt_index;
                break;
        case 2:
-               args.v2.ucVoltageType = SET_VOLTAGE_TYPE_ASIC_VDDC;
+               args.v2.ucVoltageType = voltage_type;
                args.v2.ucVoltageMode = SET_ASIC_VOLTAGE_MODE_SET_VOLTAGE;
-               args.v2.usVoltageLevel = cpu_to_le16(level);
+               args.v2.usVoltageLevel = cpu_to_le16(voltage_level);
                break;
        default:
                DRM_ERROR("Unknown table version %d, %d\n", frev, crev);