a9da3307db733eb1739ba859952610bba3d894abnp/***************************************************************************
a9da3307db733eb1739ba859952610bba3d894abnp * addon-cpufreq.c : Routines to support CPUFreq interface
de7d23d85e06f547e8cd4ed4bce494209d63612aLin Guo - Sun Microsystems * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
a9da3307db733eb1739ba859952610bba3d894abnp * Use is subject to license terms.
a9da3307db733eb1739ba859952610bba3d894abnp * Licensed under the Academic Free License version 2.1
a9da3307db733eb1739ba859952610bba3d894abnp ***************************************************************************/
a9da3307db733eb1739ba859952610bba3d894abnp#include "../../hald/logger.h"
a9da3307db733eb1739ba859952610bba3d894abnp#include "../../utils/adt_data.h"
a9da3307db733eb1739ba859952610bba3d894abnp * Specify different CPUFreq related HAL activities that can be done
a9da3307db733eb1739ba859952610bba3d894abnp * Various CPUFreq related editable parameters in the power.conf file
a9da3307db733eb1739ba859952610bba3d894abnptypedef struct {
a9da3307db733eb1739ba859952610bba3d894abnp * CPUFreq interospect XML that exports the various CPUFreq HAL interface
a9da3307db733eb1739ba859952610bba3d894abnp * supported methods
a9da3307db733eb1739ba859952610bba3d894abnp " <method name= \"SetCPUFreqGovernor\">\n \
a9da3307db733eb1739ba859952610bba3d894abnp <arg type= \"s\" name= \"governor\" direction= \"in\"/>\n \
a9da3307db733eb1739ba859952610bba3d894abnp </method>\n \
a9da3307db733eb1739ba859952610bba3d894abnp <method name= \"GetCPUFreqGovernor\">\n \
a9da3307db733eb1739ba859952610bba3d894abnp <type= \"s\" direction= \"out\"/>\n \
a9da3307db733eb1739ba859952610bba3d894abnp </method>\n \
a9da3307db733eb1739ba859952610bba3d894abnp <method name= \"SetCPUFreqPerformance\">\n \
a9da3307db733eb1739ba859952610bba3d894abnp <arg type=\"i\" direction=\"in\"/>\n \
a9da3307db733eb1739ba859952610bba3d894abnp </method>\n \
a9da3307db733eb1739ba859952610bba3d894abnp <method name= \"GetCPUFreqPerformance\">\n \
a9da3307db733eb1739ba859952610bba3d894abnp <type=\"i\" direction=\"out\"/>\n \
a9da3307db733eb1739ba859952610bba3d894abnp </method>\n \
a9da3307db733eb1739ba859952610bba3d894abnp <method name= \"GetCPUFreqAvailableGovernors\">\n \
de7d23d85e06f547e8cd4ed4bce494209d63612aLin Guo - Sun Microsystems <type=\"s\" direction=\"out\"/>\n \
a9da3307db733eb1739ba859952610bba3d894abnp </method>\n";
a9da3307db733eb1739ba859952610bba3d894abnp * List of governors that are currently supported
a9da3307db733eb1739ba859952610bba3d894abnp "ondemand",
a9da3307db733eb1739ba859952610bba3d894abnp "performance",
a9da3307db733eb1739ba859952610bba3d894abnp * Free up the mem allocated to hold the DBusError
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnp * Edit the /etc/power.conf file to update the cpupm and cpupm_threshold values
a9da3307db733eb1739ba859952610bba3d894abnp * Return 0 on success
a9da3307db733eb1739ba859952610bba3d894abnp * 1 if the governor is not available or supported
a9da3307db733eb1739ba859952610bba3d894abnp * -1 all other errors
a9da3307db733eb1739ba859952610bba3d894abnp * NOTE: Before modifying power.conf, it is first copied into a temp file, and
a9da3307db733eb1739ba859952610bba3d894abnp * pmconfig is executed on the temp file with -f option, which uses temp file
a9da3307db733eb1739ba859952610bba3d894abnp * to set the PM config and then replaces power.conf with the temp file.
a9da3307db733eb1739ba859952610bba3d894abnp * Copy /etc/power.conf to temp file
a9da3307db733eb1739ba859952610bba3d894abnp sprintf (cp_cmd_str, "/usr/bin/cp %s %s", POWER_CONF_FILE, tmp_file);
a9da3307db733eb1739ba859952610bba3d894abnp " Should be either ondemand or performance"));
a9da3307db733eb1739ba859952610bba3d894abnp sprintf (file_edit_threshold, "%d", pc_edit_type.cpu_th);
a9da3307db733eb1739ba859952610bba3d894abnp " made to /etc/power.conf"));
a9da3307db733eb1739ba859952610bba3d894abnp * Look for line containing "cpupm" or "cpu-threshold"
a9da3307db733eb1739ba859952610bba3d894abnp * If the required value already present. Just
a9da3307db733eb1739ba859952610bba3d894abnp * Update the file with new values
a9da3307db733eb1739ba859952610bba3d894abnp * Check if the currrent line is the last one. If not,
a9da3307db733eb1739ba859952610bba3d894abnp * to avoid overwriting and wasting space, move remaining
a9da3307db733eb1739ba859952610bba3d894abnp * lines upwards and update at the end
a9da3307db733eb1739ba859952610bba3d894abnp * If the pointer comes here, then the property is not already present.
a9da3307db733eb1739ba859952610bba3d894abnp * Have to append to the file
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("\n Passed value not found. Will append to the file"));
a9da3307db733eb1739ba859952610bba3d894abnp * Update the file with new values
a9da3307db733eb1739ba859952610bba3d894abnp sprintf (file_update_str, "%s %s \n", file_edit_type, file_edit_value);
a9da3307db733eb1739ba859952610bba3d894abnp * Depending on the type(cpupm or cpu-threshold) to read, check if they are
a9da3307db733eb1739ba859952610bba3d894abnp * present. If present, return the corresponding value through pc_value arg
a9da3307db733eb1739ba859952610bba3d894abnp * and return 1 from the function. If there is no corresponding entry,return 0.
a9da3307db733eb1739ba859952610bba3d894abnp * Return -1 on error
a9da3307db733eb1739ba859952610bba3d894abnp return (-1);
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("Cannot recognize the HAL type to get value"));
a9da3307db733eb1739ba859952610bba3d894abnp * Look for line containing "cpupm" or "cpu-threshold"
a9da3307db733eb1739ba859952610bba3d894abnp * If the required value already present. Just
a9da3307db733eb1739ba859952610bba3d894abnp * get the value
a9da3307db733eb1739ba859952610bba3d894abnp * Copy the corresponding governor
a9da3307db733eb1739ba859952610bba3d894abnp * Entry not found in the file
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG ((" No entry of %s in %s", file_edit_type, POWER_CONF_FILE));
a9da3307db733eb1739ba859952610bba3d894abnp * Depending on the type(Governor or Perfromance) to read, get the current
a9da3307db733eb1739ba859952610bba3d894abnp * values through PM ioctls().
a9da3307db733eb1739ba859952610bba3d894abnp * For "Governor", return the cpupm state and for "Performance" return the
a9da3307db733eb1739ba859952610bba3d894abnp * current cpu threshold.
a9da3307db733eb1739ba859952610bba3d894abnp * Return the corresponding value through cur_value and return 1 from the
a9da3307db733eb1739ba859952610bba3d894abnp * function for success. Return -1 on error
a9da3307db733eb1739ba859952610bba3d894abnp HAL_ERROR (("Error opening %s: %s \n", PM, strerror (errno)));
a9da3307db733eb1739ba859952610bba3d894abnp * First check the PM_GET_CPUPM_STATE. If it is not available
a9da3307db733eb1739ba859952610bba3d894abnp * then check PM_GET_PM_STATE
a9da3307db733eb1739ba859952610bba3d894abnp if (pm_ret < 0) {
a9da3307db733eb1739ba859952610bba3d894abnp switch (pm_ret) {
a9da3307db733eb1739ba859952610bba3d894abnp * Check for PM_GET_PM_STATE
a9da3307db733eb1739ba859952610bba3d894abnp if (pm_ret < 0) {
a9da3307db733eb1739ba859952610bba3d894abnp switch (pm_ret) {
a9da3307db733eb1739ba859952610bba3d894abnp "performance");
a9da3307db733eb1739ba859952610bba3d894abnp "PM_GET_PM_STATE"));
a9da3307db733eb1739ba859952610bba3d894abnp * First check the PM_GET_CPU_THRESHOLD. If it is not available
a9da3307db733eb1739ba859952610bba3d894abnp * then check PM_GET_SYSTEM_THRESHOLD
a9da3307db733eb1739ba859952610bba3d894abnp if (pm_ret >= 0) {
a9da3307db733eb1739ba859952610bba3d894abnp * PM_GET_CPU_THRESHOLD is not available
a9da3307db733eb1739ba859952610bba3d894abnp if (res >= 0) {
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("Cannot recognize the HAL type to get value"));
a9da3307db733eb1739ba859952610bba3d894abnp * Send an error message as a response to the pending call
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnp const char *err_name,
a9da3307db733eb1739ba859952610bba3d894abnp char *fmt, ...)
a9da3307db733eb1739ba859952610bba3d894abnp err_msg = dbus_message_new_error (msg, err_name, err_buf);
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.CPUFreq.UnknownGovernor",
a9da3307db733eb1739ba859952610bba3d894abnp "Unknown CPUFreq Governor: %s",
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.CPUFreq.NoSuitableGovernor",
a9da3307db733eb1739ba859952610bba3d894abnp "Could not find a suitable governor: %s",
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.CPUFreq.Error",
a9da3307db733eb1739ba859952610bba3d894abnp "%s: Syslog might give more information",
a9da3307db733eb1739ba859952610bba3d894abnp * Puts the required cpufreq audit data and calls adt_put_event()
a9da3307db733eb1739ba859952610bba3d894abnp * to generate auditing
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnpaudit_cpufreq(const adt_export_data_t *imported_state, au_event_t event_id,
a9da3307db733eb1739ba859952610bba3d894abnp int result, const char *auth_used, const int cpu_thr_value)
a9da3307db733eb1739ba859952610bba3d894abnp HAL_INFO (("adt_start_session failed: %s", strerror (errno)));
a9da3307db733eb1739ba859952610bba3d894abnp event->adt_cpu_performance.auth_used = (char *)auth_used;
a9da3307db733eb1739ba859952610bba3d894abnp if (result == 0) {
a9da3307db733eb1739ba859952610bba3d894abnp if (adt_put_event (event, ADT_SUCCESS, ADT_SUCCESS) != 0) {
a9da3307db733eb1739ba859952610bba3d894abnp * Check if the cpufreq related operations are authorized
a9da3307db733eb1739ba859952610bba3d894abnpcheck_authorization(DBusConnection *con, DBusMessage *msg)
a9da3307db733eb1739ba859952610bba3d894abnp * Check for authorization before proceeding
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Cannot connect to the system bus");
a9da3307db733eb1739ba859952610bba3d894abnp "Could not get the sender of the message");
a9da3307db733eb1739ba859952610bba3d894abnp uid = dbus_bus_get_unix_user (system_bus, sender, &error);
a9da3307db733eb1739ba859952610bba3d894abnp "Could not get the user id of the message sender");
a9da3307db733eb1739ba859952610bba3d894abnp "Cannot get libpolkit context to check privileges");
a9da3307db733eb1739ba859952610bba3d894abnp "Error looking up privileges from Policykit");
a9da3307db733eb1739ba859952610bba3d894abnp HAL_INFO (("Caller doesn't possess required privilege to"
a9da3307db733eb1739ba859952610bba3d894abnp " change the governor"));
a9da3307db733eb1739ba859952610bba3d894abnp "Caller doesn't possess required "
a9da3307db733eb1739ba859952610bba3d894abnp "privilege to change the governor");
a9da3307db733eb1739ba859952610bba3d894abnp * Sets the CPU Freq governor. It sets the gov name in the /etc/power.conf
a9da3307db733eb1739ba859952610bba3d894abnp * and executes pmconfig. If governor is "ondemand" then "cpupm" is enabled in
a9da3307db733eb1739ba859952610bba3d894abnp * and if governor is performance, then "cpupm" is disabled
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnpset_cpufreq_gov(DBusConnection *con, DBusMessage *msg, void *udata)
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("Incomming message arg type is not string"));
a9da3307db733eb1739ba859952610bba3d894abnp "Specified governor is not a string");
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("Could not get SetCPUFreqGov from message iter"));
a9da3307db733eb1739ba859952610bba3d894abnp if (adt_res != 0) {
a9da3307db733eb1739ba859952610bba3d894abnp * Update the /etc/power.conf file.
a9da3307db733eb1739ba859952610bba3d894abnp adt_res = edit_power_conf_file (pc_edit_type, CPU_GOV, tmp_conf_file);
a9da3307db733eb1739ba859952610bba3d894abnp if (adt_res != 0) {
a9da3307db733eb1739ba859952610bba3d894abnp "Internal Error while setting the governor");
a9da3307db733eb1739ba859952610bba3d894abnp * Execute pmconfig
a9da3307db733eb1739ba859952610bba3d894abnp sprintf (pmconfig_cmd, "%s %s", PMCONFIG, tmp_conf_file);
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Error in executing pmconfig");
a9da3307db733eb1739ba859952610bba3d894abnp * Just return an empty response, so that if the client
a9da3307db733eb1739ba859952610bba3d894abnp * is waiting for any response will not keep waiting
a9da3307db733eb1739ba859952610bba3d894abnp "Out of memory to create a response");
a9da3307db733eb1739ba859952610bba3d894abnp "Out of memory to create a response");
a9da3307db733eb1739ba859952610bba3d894abnp * Audit the new governor change
a9da3307db733eb1739ba859952610bba3d894abnp adt_data = get_audit_export_data (system_bus, sender, &adt_data_size);
a9da3307db733eb1739ba859952610bba3d894abnp#endif /* sun */
a9da3307db733eb1739ba859952610bba3d894abnp * Sets the CPU Freq performance. It sets the cpu-threshold in the
a9da3307db733eb1739ba859952610bba3d894abnp * /etc/power.conf and executes pmconfig. The performnace value should
a9da3307db733eb1739ba859952610bba3d894abnp * be between 1 to 100. The cpu-threshold = ((performance val) * 15) secs.
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnpset_cpufreq_performance(DBusConnection *con, DBusMessage *msg, void *udata)
a9da3307db733eb1739ba859952610bba3d894abnp if (adt_res != 0) {
a9da3307db733eb1739ba859952610bba3d894abnp * Performance can only be set to dynamic governors. Currently the
a9da3307db733eb1739ba859952610bba3d894abnp * only supported dynamic governor is ondemand.
a9da3307db733eb1739ba859952610bba3d894abnp if (current_gov[0] == 0) {
a9da3307db733eb1739ba859952610bba3d894abnp * Read the current governor from /etc/power.conf
a9da3307db733eb1739ba859952610bba3d894abnp if (read_power_conf_file (&pc_edit_type, CPU_GOV) != 1) {
a9da3307db733eb1739ba859952610bba3d894abnp "getting the governor");
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("To set performance the current gov should be "
a9da3307db733eb1739ba859952610bba3d894abnp "dynamic like ondemand"));
a9da3307db733eb1739ba859952610bba3d894abnp gen_no_suitable_gov_err (con, msg, "Cannot set performance "
a9da3307db733eb1739ba859952610bba3d894abnp "to the current governor");
a9da3307db733eb1739ba859952610bba3d894abnp gen_no_suitable_gov_err(con, msg, "No performance specified");
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("Incomming message arg type is not Integer"));
a9da3307db733eb1739ba859952610bba3d894abnp "Specified performance is not a Integer");
a9da3307db733eb1739ba859952610bba3d894abnp HAL_INFO (("SetCPUFreqPerformance should be between 1 to 100"
a9da3307db733eb1739ba859952610bba3d894abnp "Performance value should be between 1 and 100");
a9da3307db733eb1739ba859952610bba3d894abnp * Update the /etc/power.conf file
a9da3307db733eb1739ba859952610bba3d894abnp adt_res = edit_power_conf_file (pc_edit_type, CPU_PERFORMANCE,
a9da3307db733eb1739ba859952610bba3d894abnp if (adt_res != 0) {
a9da3307db733eb1739ba859952610bba3d894abnp "Internal error while setting the performance");
a9da3307db733eb1739ba859952610bba3d894abnp * Execute pmconfig
a9da3307db733eb1739ba859952610bba3d894abnp sprintf (pmconfig_cmd, "%s %s", PMCONFIG, tmp_conf_file);
a9da3307db733eb1739ba859952610bba3d894abnp "Internal error while setting the performance");
a9da3307db733eb1739ba859952610bba3d894abnp * Just return an empty response, so that if the client
a9da3307db733eb1739ba859952610bba3d894abnp * is waiting for any response will not keep waiting
a9da3307db733eb1739ba859952610bba3d894abnp "Out of memory to create a response");
a9da3307db733eb1739ba859952610bba3d894abnp "Out of memory to create a response");
a9da3307db733eb1739ba859952610bba3d894abnp * Audit the new performance change
a9da3307db733eb1739ba859952610bba3d894abnp adt_data = get_audit_export_data (system_bus, sender, &adt_data_size);
a9da3307db733eb1739ba859952610bba3d894abnp#endif /* sun */
a9da3307db733eb1739ba859952610bba3d894abnp * Returns in the dbus message the current gov.
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnpget_cpufreq_gov(DBusConnection *con, DBusMessage *msg, void *udata)
a9da3307db733eb1739ba859952610bba3d894abnp * Get the governor type from /etc/power.conf if it is present.
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the governor");
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG ((" Current governor is: %s", pc_type.cpu_gov));
a9da3307db733eb1739ba859952610bba3d894abnp "Internal error while getting the governor");
a9da3307db733eb1739ba859952610bba3d894abnp * Append reply arguments
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the governor");
a9da3307db733eb1739ba859952610bba3d894abnp if (!dbus_message_iter_append_basic (&rep_iter, DBUS_TYPE_STRING,
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the governor");
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the governor");
a9da3307db733eb1739ba859952610bba3d894abnp * Returns in the dbus message the current performance value
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnpget_cpufreq_performance(DBusConnection *con, DBusMessage *msg, void *udata)
a9da3307db733eb1739ba859952610bba3d894abnp * Get the performance value
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the performance value");
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG ((" The current performance: %d", pc_type.cpu_th));
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the performance value");
a9da3307db733eb1739ba859952610bba3d894abnp * Append reply arguments.pc_type.cpu_th gives the current cputhreshold
a9da3307db733eb1739ba859952610bba3d894abnp * vlaue in seconds. Have to convert it into CPU HAL interface
a9da3307db733eb1739ba859952610bba3d894abnp * performance value
a9da3307db733eb1739ba859952610bba3d894abnp if (!dbus_message_iter_append_basic (&rep_iter, DBUS_TYPE_INT32,
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the performance value");
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the performance value");
a9da3307db733eb1739ba859952610bba3d894abnp * Returns list of available governors. Currently just two governors are
a9da3307db733eb1739ba859952610bba3d894abnp * supported. They are "ondemand" and "performance"
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnpget_cpufreq_avail_gov(DBusConnection *con, DBusMessage *msg, void *udata)
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the list of governors");
a9da3307db733eb1739ba859952610bba3d894abnp * Append reply arguments
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the list of governors");
a9da3307db733eb1739ba859952610bba3d894abnp dbus_message_iter_close_container (&rep_iter, &array_iter);
a9da3307db733eb1739ba859952610bba3d894abnp gen_cpufreq_err (con, msg, "Internal error while getting"
a9da3307db733eb1739ba859952610bba3d894abnp " the list of governors");
a9da3307db733eb1739ba859952610bba3d894abnphald_dbus_cpufreq_filter(DBusConnection *con, DBusMessage *msg, void *udata)
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG ((" Inside CPUFreq filter:%s", dbus_message_get_path(msg)));
a9da3307db733eb1739ba859952610bba3d894abnp * Check for method types
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("Connection disconnected in cpufreq addon"));
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.Device.CPUFreq",
a9da3307db733eb1739ba859952610bba3d894abnp "SetCPUFreqGovernor")) {
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.Device.CPUFreq",
a9da3307db733eb1739ba859952610bba3d894abnp "GetCPUFreqGovernor")) {
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.Device.CPUFreq",
a9da3307db733eb1739ba859952610bba3d894abnp "GetCPUFreqAvailableGovernors")) {
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("---- GetCPUFreqAvailableGovernors is called "));
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.Device.CPUFreq",
a9da3307db733eb1739ba859952610bba3d894abnp "SetCPUFreqPerformance")) {
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.Device.CPUFreq",
a9da3307db733eb1739ba859952610bba3d894abnp "GetCPUFreqPerformance")) {
a9da3307db733eb1739ba859952610bba3d894abnpstatic void
a9da3307db733eb1739ba859952610bba3d894abnp * Start with the 'basic' privilege set and then add any
a9da3307db733eb1739ba859952610bba3d894abnp * of the privileges that will be required.
a9da3307db733eb1739ba859952610bba3d894abnp if ((pPrivSet = priv_str_to_set ("basic", ",", NULL)) == NULL) {
a9da3307db733eb1739ba859952610bba3d894abnp if (setppriv (PRIV_SET, PRIV_INHERITABLE, pPrivSet) != 0) {
a9da3307db733eb1739ba859952610bba3d894abnp if (setppriv (PRIV_SET, PRIV_PERMITTED, pPrivSet) != 0) {
a9da3307db733eb1739ba859952610bba3d894abnp HAL_INFO (("\n Could not get the UDI in addon-cpufreq"));
a9da3307db733eb1739ba859952610bba3d894abnp return (0);
a9da3307db733eb1739ba859952610bba3d894abnp return (0);
a9da3307db733eb1739ba859952610bba3d894abnp if (!libhal_device_addon_is_ready (ctx, getenv ("UDI"), &error)) {
a9da3307db733eb1739ba859952610bba3d894abnp return (0);
a9da3307db733eb1739ba859952610bba3d894abnp * Claim the cpufreq interface
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG (("cpufreq Introspect XML: %s", cpufreq_introspect_xml));
a9da3307db733eb1739ba859952610bba3d894abnp "org.freedesktop.Hal.Device.CPUFreq",
a9da3307db733eb1739ba859952610bba3d894abnp return (0);
a9da3307db733eb1739ba859952610bba3d894abnp * Add the cpufreq capability
a9da3307db733eb1739ba859952610bba3d894abnp "cpufreq_control",
a9da3307db733eb1739ba859952610bba3d894abnp HAL_DEBUG ((" Could not add cpufreq_control capability"));
a9da3307db733eb1739ba859952610bba3d894abnp return (0);
a9da3307db733eb1739ba859952610bba3d894abnp * Watches and times incoming messages
a9da3307db733eb1739ba859952610bba3d894abnp * Add a filter function which gets called when a message comes in
a9da3307db733eb1739ba859952610bba3d894abnp * and processes the message
a9da3307db733eb1739ba859952610bba3d894abnp return (0);