#ifdef CONFIG_AMD_PMF_DEBUG staticconstchar *platform_type_as_str(u16 platform_type)
{ switch (platform_type) { case CLAMSHELL: return"CLAMSHELL"; case FLAT: return"FLAT"; case TENT: return"TENT"; case STAND: return"STAND"; case TABLET: return"TABLET"; case BOOK: return"BOOK"; case PRESENTATION: return"PRESENTATION"; case PULL_FWD: return"PULL_FWD"; default: return"UNKNOWN";
}
}
staticconstchar *laptop_placement_as_str(u16 device_state)
{ switch (device_state) { case ON_TABLE: return"ON_TABLE"; case ON_LAP_MOTION: return"ON_LAP_MOTION"; case IN_BAG: return"IN_BAG"; case OUT_OF_BAG: return"OUT_OF_BAG"; default: return"UNKNOWN";
}
}
staticconstchar *ta_slider_as_str(unsignedint state)
{ switch (state) { case TA_BEST_PERFORMANCE: return"PERFORMANCE"; case TA_BETTER_PERFORMANCE: return"BALANCED"; case TA_BEST_BATTERY: return"POWER_SAVER"; default: return"Unknown TA Slider State";
}
}
/* * This helper function sets the appropriate BIOS input value in the TA enact * table based on the provided index. We need this approach because the custom * BIOS input array is not continuous, due to the existing TA structure layout.
*/ staticvoid amd_pmf_set_ta_custom_bios_input(struct ta_pmf_enact_table *in, int index, u32 value)
{ switch (index) { case 0 ... 1:
in->ev_info.bios_input_1[index] = value; break; default: return;
}
}
for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) { if (!(pdev->req.pending_req & custom_bios_inputs[i].bit_mask)) continue;
amd_pmf_set_ta_custom_bios_input(in, i, pdev->req.custom_policy[i]);
}
/* Get the avg and max C0 residency of all the cores */
max = *core_res; for (i = 0; i < size; i++) {
avg += core_res[i]; if (core_res[i] > max)
max = core_res[i];
}
avg = DIV_ROUND_CLOSEST(avg, size);
in->ev_info.avg_c0residency = avg;
in->ev_info.max_c0residency = max;
}
staticvoid amd_pmf_get_smu_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{ /* Get the updated metrics table data */
memset(dev->buf, 0, dev->mtable_size);
amd_pmf_send_cmd(dev, SET_TRANSFER_TABLE, 0, 7, NULL);
staticint amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{ int val;
switch (dev->current_profile) { case PLATFORM_PROFILE_PERFORMANCE: case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
val = TA_BEST_PERFORMANCE; break; case PLATFORM_PROFILE_BALANCED:
val = TA_BETTER_PERFORMANCE; break; case PLATFORM_PROFILE_LOW_POWER: case PLATFORM_PROFILE_QUIET:
val = TA_BEST_BATTERY; break; default:
dev_err(dev->dev, "Unknown Platform Profile.\n"); return -EOPNOTSUPP;
}
in->ev_info.power_slider = val;
/* Get the latest information from SFH */
in->ev_info.user_present = false;
/* Get ALS data */ if (!amd_get_sfh_info(&sfh_info, MT_ALS))
in->ev_info.ambient_light = sfh_info.ambient_light; else
dev_dbg(dev->dev, "ALS is not enabled/detected\n");
/* get HPD data */ if (!amd_get_sfh_info(&sfh_info, MT_HPD)) { if (sfh_info.user_present == SFH_USER_PRESENT)
in->ev_info.user_present = true;
} else {
dev_dbg(dev->dev, "HPD is not enabled/detected\n");
}
/* Get SRA (Secondary Accelerometer) data */ if (!amd_get_sfh_info(&sfh_info, MT_SRA)) {
in->ev_info.platform_type = sfh_info.platform_type;
in->ev_info.device_state = sfh_info.laptop_placement;
} else {
dev_dbg(dev->dev, "SRA is not enabled/detected\n");
}
}
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{ /* TA side lid open is 1 and close is 0, hence the ! here */
in->ev_info.lid_state = !acpi_lid_open();
in->ev_info.power_source = amd_pmf_get_power_source();
amd_pmf_get_smu_info(dev, in);
amd_pmf_get_battery_info(dev, in);
amd_pmf_get_slider_info(dev, in);
amd_pmf_get_sensor_info(dev, in);
amd_pmf_get_custom_bios_inputs(dev, in);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.