Commit 5fb91a67 authored by Richard Hughes's avatar Richard Hughes Committed by Richard Hughes

Add a missing file (Marcel Telka)

2006-10-01  Richard Hughes  <richard@hughsie.com>

* po/POTFILES.in:
Add a missing file (Marcel Telka)

* src/Makefile.am:
* src/gpm-hal-brightness-kbd.c:
* src/gpm-hal-brightness-kbd.h:
* src/gpm-hal-light-sensor.c:
* src/gpm-hal-light-sensor.h:
* src/gpm-manager.c:
Merge some new light-sensor stuff based on a patch from David Zeuthen.
This isn't finished yet - I need to take some more ideas from David's
patch and merge them - along with some more ideas of my own on the
feedback mechanism for the LCD and keyboard backlight.
I've been busy this weekend - so coding will resume some point this
week.
parent 3bd9adfe
2006-10-01 Richard Hughes <richard@hughsie.com>
* po/POTFILES.in:
Add a missing file (Marcel Telka)
* src/Makefile.am:
* src/gpm-hal-brightness-kbd.c:
* src/gpm-hal-brightness-kbd.h:
* src/gpm-hal-light-sensor.c:
* src/gpm-hal-light-sensor.h:
* src/gpm-manager.c:
Merge some new light-sensor stuff based on a patch from David Zeuthen.
This isn't finished yet - I need to take some more ideas from David's
patch and merge them - along with some more ideas of my own on the
feedback mechanism for the LCD and keyboard backlight.
I've been busy this weekend - so coding will resume some point this
week.
2006-09-29 Richard Hughes <richard@hughsie.com>
* src/gpm-hal-brightness-sensor.c:
......
......@@ -4,6 +4,7 @@
data/gnome-power-manager.desktop.in
data/gnome-power-manager.schemas.in
data/gnome-power-preferences.desktop.in
data/gnome-power-statistics.desktop.in
data/gpm-feedback-widget.glade
data/gpm-graph.glade
data/gpm-inhibit-test.glade
......
......@@ -138,6 +138,8 @@ gnome_power_manager_SOURCES = \
gpm-hal-brightness-lcd.c \
gpm-hal-brightness-kbd.h \
gpm-hal-brightness-kbd.c \
gpm-hal-light-sensor.h \
gpm-hal-light-sensor.c \
gpm-main.c \
gpm-manager.h \
gpm-manager.c \
......
......@@ -48,6 +48,7 @@
#include "gpm-proxy.h"
#include "gpm-marshal.h"
#include "gpm-feedback-widget.h"
#include "gpm-hal-light-sensor.h"
#define DIM_INTERVAL 10 /* ms */
......@@ -58,6 +59,7 @@ struct GpmHalBrightnessKbdPrivate
gboolean does_own_updates; /* keys are hardwired */
gboolean does_own_dimming; /* hardware auto-fades */
gboolean is_dimmed;
gboolean is_disabled;
guint current_hw; /* hardware */
guint level_dim_hw;
guint level_std_hw;
......@@ -66,6 +68,7 @@ struct GpmHalBrightnessKbdPrivate
GpmProxy *gproxy;
GpmHal *hal;
GpmFeedback *feedback;
GpmHalLightSensor *sensor;
};
G_DEFINE_TYPE (GpmHalBrightnessKbd, gpm_hal_brightness_kbd, G_TYPE_OBJECT)
......@@ -97,7 +100,7 @@ gpm_hal_brightness_kbd_get_hw (GpmHalBrightnessKbd *brightness,
ret = dbus_g_proxy_call (proxy, "GetBrightness", &error,
G_TYPE_INVALID,
G_TYPE_UINT, brightness_level_hw,
G_TYPE_INT, brightness_level_hw,
G_TYPE_INVALID);
if (error) {
gpm_debug ("ERROR: %s", error->message);
......@@ -292,13 +295,13 @@ gpm_hal_brightness_kbd_set_dim (GpmHalBrightnessKbd *brightness,
}
/**
* gpm_hal_brightness_kbd_set_dim:
* gpm_hal_brightness_kbd_set_std:
* @brightness_kbd: This brightness_kbd class instance
* @brightness_level: The percentage brightness_kbd
**/
gboolean
gpm_hal_brightness_kbd_set_std (GpmHalBrightnessKbd *brightness,
guint brightness_level)
guint brightness_level)
{
guint level_hw;
......@@ -334,6 +337,7 @@ gpm_hal_brightness_kbd_dim (GpmHalBrightnessKbd *brightness)
return FALSE;
}
brightness->priv->is_dimmed = TRUE;
//need to save old value
return gpm_hal_brightness_kbd_dim_hw (brightness, brightness->priv->level_dim_hw);
}
......@@ -355,6 +359,7 @@ gpm_hal_brightness_kbd_undim (GpmHalBrightnessKbd *brightness)
return FALSE;
}
brightness->priv->is_dimmed = FALSE;
//need to restore old value
return gpm_hal_brightness_kbd_dim_hw (brightness, brightness->priv->level_std_hw);
}
......@@ -370,7 +375,7 @@ gboolean
gpm_hal_brightness_kbd_get (GpmHalBrightnessKbd *brightness,
guint *brightness_level)
{
gint percentage;
guint percentage;
g_return_val_if_fail (brightness != NULL, FALSE);
g_return_val_if_fail (GPM_IS_HAL_BRIGHTNESS_KBD (brightness), FALSE);
......@@ -484,6 +489,7 @@ gpm_hal_brightness_kbd_finalize (GObject *object)
g_object_unref (brightness->priv->gproxy);
g_object_unref (brightness->priv->hal);
g_object_unref (brightness->priv->feedback);
g_object_unref (brightness->priv->sensor);
g_return_if_fail (brightness->priv != NULL);
G_OBJECT_CLASS (gpm_hal_brightness_kbd_parent_class)->finalize (object);
......@@ -502,6 +508,154 @@ gpm_hal_brightness_kbd_class_init (GpmHalBrightnessKbdClass *klass)
g_type_class_add_private (klass, sizeof (GpmHalBrightnessKbdPrivate));
}
enum {
STATE_FORCED_UNKNOWN,
STATE_FORCED_ON,
STATE_FORCED_OFF
};
/**
* adjust_kbd_brightness_according_to_ambient_light:
* @brightness: class instance
* @startup: whether we should set the backlight depending on the
* current ambient light level
*
* This function adjusts the keyboard backlight according to ambient
* light. It tries to be smart about things. So, if we detect that
* the light changes to very dark (30%) we force the backlight on
* and if we detect that it changes to very bright (70%) we force
* the backlight off. The reason for this is that we want to
* respect the users settings and try to change as little as possible,
* e.g. should it get dark (30%) we know we've already forced it off
* so the user can e.g. change it himself too as we won't do anything
* until it's very bright again.
*
* For startup conditions we look at whether the ambient light is
* greater or lower than 50% to set force keyboard backlight on/off.
* Note that enabling the keyboard backlight after disabling it is
* a startup condition too.
*/
static gboolean
adjust_kbd_brightness_according_to_ambient_light (GpmHalBrightnessKbd *brightness,
gboolean startup)
{
guint ambient_light;
static int state = STATE_FORCED_UNKNOWN;
if (brightness->priv->sensor == NULL) {
return FALSE;
}
gpm_hal_light_sensor_get (brightness->priv->sensor, &ambient_light);
/* this is also used if user reenables the keyboard backlight */
if (startup) {
state = STATE_FORCED_UNKNOWN;
}
g_debug ("ambient light percent = %d", ambient_light);
if (state == STATE_FORCED_UNKNOWN) {
/* if this is the first time we're launched with ambient light data... */
if (ambient_light < 50 ) {
gpm_hal_brightness_kbd_set_std (brightness, 100);
state = STATE_FORCED_ON;
} else {
gpm_hal_brightness_kbd_set_std (brightness, 0);
state = STATE_FORCED_OFF;
}
} else {
if (ambient_light < 30 && state != STATE_FORCED_ON ) {
/* if it's dark.. and we haven't already turned light on...
* => turn it on.. full blast! */
gpm_hal_brightness_kbd_set_std (brightness, 100);
state = STATE_FORCED_ON;
} else if (ambient_light > 70 && state != STATE_FORCED_OFF) {
/* if it's bright... and we haven't already turned light off...
* => turn it off */
gpm_hal_brightness_kbd_set_std (brightness, 0);
state = STATE_FORCED_OFF;
}
}
return TRUE;
}
/**
* sensor_changed_cb:
* @sensor: the brightness sensor
* @ambient_light: ambient light percentage (0: dark, 100: bright)
* @brightness: the keyboard brightness instance
*
* Called when the reading from the ambient light sensor changes.
**/
static void
sensor_changed_cb (GpmHalLightSensor *sensor,
guint ambient_light,
GpmHalBrightnessKbd *brightness)
{
if (brightness->priv->is_disabled == FALSE) {
adjust_kbd_brightness_according_to_ambient_light (brightness, FALSE);
}
}
#if 0
/**
* gpm_hal_brightness_kbd_is_disabled:
* @brightness: the instance
* @is_disabled: out value
*
* Returns whether the keyboard backlight is disabled by the user
*/
gboolean
gpm_hal_brightness_kbd_is_disabled (GpmHalBrightnessKbd *brightness,
gboolean *is_disabled)
{
g_return_val_if_fail (brightness != NULL, FALSE);
g_return_val_if_fail (GPM_IS_HAL_BRIGHTNESS_KBD (brightness), FALSE);
g_return_val_if_fail (is_disabled != NULL, FALSE);
*is_disabled = brightness->priv->is_disabled;
return TRUE;
}
#endif
/**
* gpm_hal_brightness_kbd_toggle:
* @brightness: the instance
* @is_disabled: whether keyboard backlight is disabled by the user
* @do_startup_on_enable: whether we should automatically select the
* keyboard backlight depending on the ambient light when enabling it.
*
* Set whether keyboard backlight is disabled by the user. Note that
* do_startup_on_enable only makes sense if is_disables is FALSE. Typically
* one wants do_startup_on_enable=TRUE when handling the keyboard backlight
* is already disabled and the user presses illum+ and you want to enable
* the backlight in response to that.
**/
gboolean
gpm_hal_brightness_kbd_toggle (GpmHalBrightnessKbd *brightness)
{
g_return_val_if_fail (brightness != NULL, FALSE);
g_return_val_if_fail (GPM_IS_HAL_BRIGHTNESS_KBD (brightness), FALSE);
if (brightness->priv->is_disabled == FALSE) {
/* go dark, that's what the user wants */
gpm_hal_brightness_kbd_set_std (brightness, 0);
gpm_feedback_display_value (brightness->priv->feedback, 0.0f);
} else {
/* select the appropriate level just as when we're starting up */
// if (do_startup_on_enable) {
adjust_kbd_brightness_according_to_ambient_light (brightness, TRUE);
gpm_hal_brightness_kbd_get_hw (brightness, &brightness->priv->current_hw);
gpm_feedback_display_value (brightness->priv->feedback,
(gfloat) gpm_discrete_to_percent (brightness->priv->current_hw,
brightness->priv->levels) / 100.0f);
// }
}
return TRUE;
}
/**
* gpm_hal_brightness_kbd_init:
* @brightness_kbd: This brightness_kbd class instance
......@@ -523,6 +677,13 @@ gpm_hal_brightness_kbd_init (GpmHalBrightnessKbd *brightness)
gpm_feedback_set_icon_name (brightness->priv->feedback,
GPM_STOCK_BRIGHTNESS_KBD);
/* listen for ambient light changes.. if we have an ambient light sensor */
brightness->priv->sensor = gpm_hal_light_sensor_new ();
if (brightness->priv->sensor != NULL) {
g_signal_connect (brightness->priv->sensor, "brightness-changed",
G_CALLBACK (sensor_changed_cb), brightness);
}
/* save udi of kbd adapter */
gpm_hal_device_find_capability (brightness->priv->hal, "keyboard_backlight", &names);
if (names == NULL || names[0] == NULL) {
......@@ -536,6 +697,7 @@ gpm_hal_brightness_kbd_init (GpmHalBrightnessKbd *brightness)
brightness->priv->does_own_dimming = FALSE;
brightness->priv->does_own_updates = FALSE;
brightness->priv->is_disabled = FALSE;
/* get a managed proxy */
brightness->priv->gproxy = gpm_proxy_new ();
......@@ -559,6 +721,9 @@ gpm_hal_brightness_kbd_init (GpmHalBrightnessKbd *brightness)
gpm_debug ("Starting: (%i of %i)",
brightness->priv->current_hw,
brightness->priv->levels - 1);
/* choose a start value */
adjust_kbd_brightness_according_to_ambient_light (brightness, TRUE);
}
/**
......
......@@ -61,6 +61,7 @@ gboolean gpm_hal_brightness_kbd_set_std (GpmHalBrightnessKbd *brightness,
guint brightness_level);
gboolean gpm_hal_brightness_kbd_dim (GpmHalBrightnessKbd *brightness);
gboolean gpm_hal_brightness_kbd_undim (GpmHalBrightnessKbd *brightness);
gboolean gpm_hal_brightness_kbd_toggle (GpmHalBrightnessKbd *brightness);
G_END_DECLS
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2006 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
#include <gtk/gtk.h>
#include "gpm-common.h"
#include "gpm-debug.h"
#include "gpm-hal.h"
#include "gpm-hal-light-sensor.h"
#include "gpm-proxy.h"
#include "gpm-marshal.h"
#define POLL_INTERVAL 10000 /* ms */
#define GPM_HAL_LIGHT_SENSOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_HAL_LIGHT_SENSOR, GpmHalLightSensorPrivate))
struct GpmHalLightSensorPrivate
{
guint current_hw; /* hardware */
guint levels;
gchar *udi;
GpmProxy *gproxy;
GpmHal *hal;
};
enum {
BRIGHTNESS_CHANGED,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (GpmHalLightSensor, gpm_hal_light_sensor, G_TYPE_OBJECT)
/**
* gpm_hal_light_sensor_get_hw:
* @brightness: This brightness class instance
*
* Updates the private local value of brightness_level_hw as it may have
* changed on some h/w
* Return value: Success.
**/
static gboolean
gpm_hal_light_sensor_get_hw (GpmHalLightSensor *brightness,
guint *brightness_level_hw)
{
GError *error = NULL;
gboolean ret;
DBusGProxy *proxy;
GArray *levels;
int i;
g_return_val_if_fail (brightness != NULL, FALSE);
g_return_val_if_fail (GPM_IS_HAL_LIGHT_SENSOR (brightness), FALSE);
proxy = gpm_proxy_get_proxy (brightness->priv->gproxy);
if (proxy == NULL) {
gpm_warning ("not connected to HAL");
return FALSE;
}
ret = dbus_g_proxy_call (proxy, "GetBrightness", &error,
G_TYPE_INVALID,
DBUS_TYPE_G_INT_ARRAY, &levels,
G_TYPE_INVALID);
if (error) {
gpm_debug ("ERROR: %s", error->message);
g_error_free (error);
}
if (ret == FALSE) {
/* abort as the DBUS method failed */
gpm_warning ("GetBrightness failed!");
return FALSE;
}
*brightness_level_hw = 0;
for (i = 0; i < levels->len; i++ ) {
*brightness_level_hw += g_array_index (levels, gint, i);
}
*brightness_level_hw /= levels->len;
g_array_free (levels, TRUE);
return TRUE;
}
/**
* gpm_hal_light_sensor_get:
* @brightness: This brightness class instance
* Return value: The percentage brightness, or -1 for no hardware or error
*
* Gets the current (or at least what this class thinks is current) percentage
* brightness. This is quick as no HAL inquiry is done.
**/
gboolean
gpm_hal_light_sensor_get (GpmHalLightSensor *brightness,
guint *brightness_level)
{
gint percentage;
g_return_val_if_fail (brightness != NULL, FALSE);
g_return_val_if_fail (GPM_IS_HAL_LIGHT_SENSOR (brightness), FALSE);
percentage = gpm_discrete_to_percent (brightness->priv->current_hw,
brightness->priv->levels);
*brightness_level = percentage;
return TRUE;
}
/**
* gpm_hal_light_sensor_constructor:
**/
static GObject *
gpm_hal_light_sensor_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GpmHalLightSensor *brightness;
GpmHalLightSensorClass *klass;
klass = GPM_HAL_LIGHT_SENSOR_CLASS (g_type_class_peek (GPM_TYPE_HAL_LIGHT_SENSOR));
brightness = GPM_HAL_LIGHT_SENSOR (G_OBJECT_CLASS (gpm_hal_light_sensor_parent_class)->constructor
(type, n_construct_properties, construct_properties));
return G_OBJECT (brightness);
}
/**
* gpm_hal_light_sensor_finalize:
**/
static void
gpm_hal_light_sensor_finalize (GObject *object)
{
GpmHalLightSensor *brightness;
g_return_if_fail (object != NULL);
g_return_if_fail (GPM_IS_HAL_LIGHT_SENSOR (object));
brightness = GPM_HAL_LIGHT_SENSOR (object);
g_free (brightness->priv->udi);
g_object_unref (brightness->priv->gproxy);
g_object_unref (brightness->priv->hal);
g_return_if_fail (brightness->priv != NULL);
G_OBJECT_CLASS (gpm_hal_light_sensor_parent_class)->finalize (object);
}
/**
* gpm_hal_light_sensor_class_init:
**/
static void
gpm_hal_light_sensor_class_init (GpmHalLightSensorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gpm_hal_light_sensor_finalize;
object_class->constructor = gpm_hal_light_sensor_constructor;
signals [BRIGHTNESS_CHANGED] =
g_signal_new ("brightness-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GpmHalLightSensorClass, brightness_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE,
1,
G_TYPE_UINT);
g_type_class_add_private (klass, sizeof (GpmHalLightSensorPrivate));
}
/**
* gpm_hal_light_sensor_poll_hardware
* @brightness: This brightness class instance
*/
gboolean
gpm_hal_light_sensor_poll_hardware (GpmHalLightSensor *brightness)
{
gboolean ret;
guint old;
guint new;
gpm_hal_light_sensor_get (brightness, &old);
ret = gpm_hal_light_sensor_get_hw (brightness, &brightness->priv->current_hw);
if (ret) {
gpm_hal_light_sensor_get (brightness, &new);
if (new != old) {
g_signal_emit (brightness,
signals [BRIGHTNESS_CHANGED],
0,
new,
old);
}
}
return ret;
}
/**
* gpm_hal_light_sensor_poll_fn:
* @userdata: userdata; a brightness sensor class instance
*/
static gboolean
gpm_hal_light_sensor_poll_fn (gpointer userdata)
{
GpmHalLightSensor *brightness;
g_return_val_if_fail (userdata != NULL, TRUE);
g_return_val_if_fail (GPM_IS_HAL_LIGHT_SENSOR (userdata), TRUE);
brightness = GPM_HAL_LIGHT_SENSOR (userdata);
gpm_hal_light_sensor_poll_hardware (brightness);
return TRUE;
}
/**
* gpm_hal_light_sensor_init:
* @brightness: This brightness class instance
*
* initialises the brightness class. NOTE: We expect light_sensor objects
* to *NOT* be removed or added during the session.
* We only control the first light_sensor object if there are more than one.
**/
static void
gpm_hal_light_sensor_init (GpmHalLightSensor *brightness)
{
gchar **names;
brightness->priv = GPM_HAL_LIGHT_SENSOR_GET_PRIVATE (brightness);
brightness->priv->hal = gpm_hal_new ();
/* save udi of lcd adapter */
gpm_hal_device_find_capability (brightness->priv->hal, "light_sensor", &names);
if (names == NULL || names[0] == NULL) {
gpm_warning ("No devices of capability light_sensor");
return;
}
/* We only want first light_sensor object (should only be one) */
brightness->priv->udi = g_strdup (names[0]);
gpm_hal_free_capability (brightness->priv->hal, names);
/* get a managed proxy */
brightness->priv->gproxy = gpm_proxy_new ();
gpm_proxy_assign (brightness->priv->gproxy,
GPM_PROXY_SYSTEM,
HAL_DBUS_SERVICE,
brightness->priv->udi,
HAL_DBUS_INTERFACE_LIGHT_SENSOR);
/* get levels that the adapter supports -- this does not change ever */
gpm_hal_device_get_uint (brightness->priv->hal, brightness->priv->udi, "light_sensor.num_levels",
&brightness->priv->levels);
/* this changes under our feet */
gpm_hal_light_sensor_get_hw (brightness, &brightness->priv->current_hw);
g_timeout_add (2000,
gpm_hal_light_sensor_poll_fn,
brightness);
}
/**
* gpm_hal_light_sensor_has_hw:
*
* Self contained function that works out if we have the hardware.
* If not, we return FALSE and the module is unloaded.
**/
static gboolean
gpm_hal_light_sensor_has_hw (void)
{
GpmHal *hal;
gchar **names;
gboolean ret = TRUE;
/* okay, as singleton - so we don't allocate more memory */
hal = gpm_hal_new ();
gpm_hal_device_find_capability (hal, "light_sensor", &names);
/* nothing found */
if (names == NULL || names[0] == NULL) {
ret = FALSE;
}
gpm_hal_free_capability (hal, names);
g_object_unref (hal);
return ret;
}
/**
* gpm_hal_light_sensor_new:
* Return value: A new brightness class instance.
**/
GpmHalLightSensor *
gpm_hal_light_sensor_new (void)
{
static GpmHalLightSensor *brightness = NULL;
if (brightness != NULL) {
g_object_ref (brightness);
return brightness;
}
/* only load an instance of this module if we have the hardware */
if (gpm_hal_light_sensor_has_hw () == FALSE) {
return NULL;
}
brightness = g_object_new (GPM_TYPE_HAL_LIGHT_SENSOR, NULL);
return brightness;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
* Copyright (C) 2005-2006 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GPM_HAL_LIGHT_SENSOR_H
#define __GPM_HAL_LIGHT_SENSOR_H
#include <glib-object.h>
G_BEGIN_DECLS
#define GPM_TYPE_HAL_LIGHT_SENSOR (gpm_hal_light_sensor_get_type ())
#define GPM_HAL_LIGHT_SENSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_HAL_LIGHT_SENSOR, GpmHalLightSensor))
#define GPM_HAL_LIGHT_SENSOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_HAL_LIGHT_SENSOR, GpmHalLightSensorClass))
#define GPM_IS_HAL_LIGHT_SENSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_HAL_LIGHT_SENSOR))
#define GPM_IS_HAL_LIGHT_SENSOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_HAL_LIGHT_SENSOR))
#define GPM_HAL_LIGHT_SENSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_HAL_LIGHT_SENSOR, GpmHalLightSensorClass))
typedef struct GpmHalLightSensorPrivate GpmHalLightSensorPrivate;
typedef struct
{
GObject parent;
GpmHalLightSensorPrivate *priv;
} GpmHalLightSensor;
typedef struct
{
GObjectClass parent_class;
void (* brightness_changed) (GpmHalLightSensor *brightness_sensor,
guint brightness_level);
} GpmHalLightSensorClass;
GType gpm_hal_light_sensor_get_type (void);
GpmHalLightSensor *gpm_hal_light_sensor_new (void);
gboolean gpm_hal_light_sensor_poll_hardware (GpmHalLightSensor *brightness);
gboolean gpm_hal_light_sensor_get (GpmHalLightSensor *brightness,
guint *brightness_level);
G_END_DECLS
#endif /* __GPM_HAL_LIGHT_SENSOR_H */
......@@ -93,6 +93,7 @@ typedef enum {
#define GPM_BUTTON_BRIGHT_DOWN_DEP "brightnessdown" /* as these are the old names */
#define GPM_BUTTON_KBD_BRIGHT_UP "kbd-illum-up"
#define GPM_BUTTON_KBD_BRIGHT_DOWN "kbd-illum-down"
#define GPM_BUTTON_KBD_BRIGHT_TOGGLE "kbd-illum-toggle"
#define GPM_BUTTON_LOCK "lock"
#define GPM_BUTTON_BATTERY "battery"
......@@ -772,10 +773,12 @@ change_power_policy (GpmManager *manager,
}
/* change to the right governer and settings */
cpufreq_type = gpm_hal_cpufreq_string_to_enum (cpufreq_policy);
gpm_hal_cpufreq_set_consider_nice (manager->priv->hal_cpufreq, cpufreq_consider_nice);
gpm_hal_cpufreq_set_governor (manager->priv->hal_cpufreq, cpufreq_type);
gpm_hal_cpufreq_set_performance (manager->priv->hal_cpufreq, cpufreq_performance);
if (manager->priv->hal_cpufreq) {
cpufreq_type = gpm_hal_cpufreq_string_to_enum (cpufreq_policy);
gpm_hal_cpufreq_set_consider_nice (manager->priv->hal_cpufreq, cpufreq_consider_nice);
gpm_hal_cpufreq_set_governor (manager->priv->hal_cpufreq, cpufreq_type);
gpm_hal_cpufreq_set_performance (manager->priv->hal_cpufreq, cpufreq_performance);
}
g_free (cpufreq_policy);
gpm_hal_power_enable_power_save (manager->priv->hal_power, power_save);
......@@ -1509,6 +1512,11 @@ idle_changed_cb (GpmIdle *idle,
gpm_hal_brightness_lcd_undim (manager->priv->brightness_lcd);
}