Skip to content

Commit

Permalink
Implement color profiles based on display revision
Browse files Browse the repository at this point in the history
Implement different color profiles for different display revisions.
Based on an implementation by Victor Portnov <ext-victor.portnov@nokia.com>.

Move the profile configurations from separate configuration file to mce.ini,
default profile configuration remains in mce-color-profiles.ini. Move the
current profile setting from separate configuration file to GConf.
Color profile also settable via GConf. Add signal notifying about color
profile changes.
  • Loading branch information
Santtu Lakkala committed Sep 12, 2011
1 parent 70b7277 commit 4b06f31
Show file tree
Hide file tree
Showing 14 changed files with 449 additions and 225 deletions.
4 changes: 1 addition & 3 deletions Makefile
Expand Up @@ -3,7 +3,7 @@
# Written by David Weinehall
# Modified by Tuomo Tanskanen

VERSION := 1.11.1
VERSION := 1.11.2

INSTALL := install -o root -g root --mode=755
INSTALL_DIR := install -d
Expand Down Expand Up @@ -55,7 +55,6 @@ MODULES := \
CONFFILE := mce.ini
RADIOSTATESCONFFILE := mce-radio-states.ini
COLORPROFILESCONFFILE := mce-color-profiles.ini
CURRENTSETTINGSCONFFILE := mce-settings.ini
DBUSCONF := mce.conf mcetool.conf
GCONFSCHEMAS := display.schemas energymanagement.schemas
BACKUPCONF := mcebackup.conf
Expand Down Expand Up @@ -85,7 +84,6 @@ COMMON_CFLAGS += -DG_DISABLE_DEPRECATED
COMMON_CFLAGS += -DOSSOLOG_COMPILE
COMMON_CFLAGS += -DMCE_VAR_DIR=$(VARDIR) -DMCE_RUN_DIR=$(RUNDIR)
COMMON_CFLAGS += -DPRG_VERSION=$(VERSION)
COMMON_CFLAGS += -DMCE_CURRENT_SETTINGS_CONF_FILE=$(VARDIR)/$(CURRENTSETTINGSCONFFILE)

MCE_CFLAGS := $(COMMON_CFLAGS)
MCE_CFLAGS += -DMCE_CONF_FILE=$(CONFDIR)/$(CONFFILE)
Expand Down
8 changes: 7 additions & 1 deletion debian/changelog
@@ -1,9 +1,15 @@
mce (1.11.2) unstable; urgency=low

* Implement color profile changing (Fixes: NB#269000)
* Implement separate color profiles for displays (Fixes: NB#268997)

-- Santtu Lakkala <ext-santtu.1.lakkala@nokia.com> Mon, 12 Sep 2011 11:56:42 +0300

mce (1.11.1) unstable; urgency=low

* Fixed ALS threshold limit setting when ALS disabled by D-Bus

-- Jukka Turunen <ext-jukka.t.turunen@nokia.com> Tue, 30 Aug 2011 16:03:45 +0300

mce (1.11.0) unstable; urgency=low

* Clear brightness stepdown timer callback id (Fixes: NB#266540)
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Expand Up @@ -3,7 +3,7 @@ Section: misc
Priority: optional
Maintainer: Santtu Lakkala <ext-santtu.1.lakkala@nokia.com>
Uploaders: Philippe De Swert <philippe.de-swert@nokia.com>, Pekka Lundström <pekka.lundstrom@nokia.com>, Tuomo Tanskanen <ext-tuomo.1.tanskanen@nokia.com>, Jukka Turunen <ext-jukka.t.turunen@nokia.com>, Jyrki Hämäläinen <ext-jyrki.pe.hamalainen@nokia.com>
Build-Depends: debhelper (>= 5.0.0), mce-dev (>= 1.10.28), pkg-config, libglib2.0-dev (>= 2.18.0), libdbus-1-dev (>= 1.0.2), libdbus-glib-1-dev, libdsme0.2.0-dev (>= 0.58), libgconf2-dev, linux-kernel-headers (>= 2.6.32-20100102) | linux-libc-dev (>= 2.6.32), dpkg-dev (>= 1.13.19), libi2c-dev, aegis-builder (>= 1.4), libcal-dev (>= 0.2.4)
Build-Depends: debhelper (>= 5.0.0), mce-dev (>= 1.11.0), pkg-config, libglib2.0-dev (>= 2.18.0), libdbus-1-dev (>= 1.0.2), libdbus-glib-1-dev, libdsme0.2.0-dev (>= 0.58), libgconf2-dev, linux-kernel-headers (>= 2.6.32-20100102) | linux-libc-dev (>= 2.6.32), dpkg-dev (>= 1.13.19), libi2c-dev, aegis-builder (>= 1.4), libcal-dev (>= 0.2.4)
Standards-Version: 3.8.4

Package: mce
Expand Down
4 changes: 0 additions & 4 deletions debian/mce.aegis
Expand Up @@ -5,7 +5,6 @@
<credential name="LEDControl" />
<credential name="TKLockControl" />
<credential name="SensorControl" />
<credential name="ColorProfileControl" />

<dbus name="com.nokia.mce" own="SELF" bus="system">
<node name="/">
Expand Down Expand Up @@ -53,9 +52,6 @@
<method name="req_led_disable">
<annotation name="com.maemo.Aegis" value="LEDControl"/>
</method>
<method name="req_color_profile_change">
<annotation name="com.maemo.Aegis" value="ColorProfileControl"/>
</method>
</interface>
</node>
</dbus>
Expand Down
1 change: 0 additions & 1 deletion debian/mcetools.aegis
Expand Up @@ -7,7 +7,6 @@
<credential name="mce::DeviceModeControl" />
<credential name="mce::LEDControl" />
<credential name="mce::TKLockControl" />
<credential name="mce::ColorProfileControl" />
<for path="/sbin/mcetool" />
</request>
</aegis>
34 changes: 34 additions & 0 deletions mce-conf.c
Expand Up @@ -258,6 +258,40 @@ gchar **mce_conf_get_string_list(const gchar *group, const gchar *key,
return tmp;
}

gchar **mce_conf_get_keys(const gchar *group, gsize *length,
gpointer keyfileptr)
{
gchar **tmp = NULL;
GError *error = NULL;

if (keyfileptr == NULL) {
if (keyfile == NULL) {
mce_log(LL_ERR,
"Could not get config keys %s; "
"no configuration file initialised",
group);
*length = 0;
goto EXIT;
} else {
keyfileptr = keyfile;
}
}

tmp = g_key_file_get_keys(keyfileptr, group, length, &error);

if (error != NULL) {
mce_log(LL_WARN,
"Could not get config keys %s; %s",
group, error->message);
*length = 0;
}

g_clear_error(&error);

EXIT:
return tmp;
}

/**
* Free configuration file
*
Expand Down
2 changes: 2 additions & 0 deletions mce-conf.h
Expand Up @@ -33,6 +33,8 @@ gchar *mce_conf_get_string(const gchar *group, const gchar *key,
const gchar *defaultval, gpointer keyfileptr);
gchar **mce_conf_get_string_list(const gchar *group, const gchar *key,
gsize *length, gpointer keyfileptr);
gchar **mce_conf_get_keys(const gchar *group, gsize *length,
gpointer keyfileptr);

gpointer mce_conf_read_conf_file(const gchar *const conffile);
void mce_conf_free_conf_file(gpointer keyfileptr);
Expand Down
3 changes: 2 additions & 1 deletion mce-device-clear
Expand Up @@ -2,4 +2,5 @@

gconftool-2 -u /system/osso/dsm/locks/tklock_double_tap_gesture
gconftool-2 -u /system/osso/dsm/display/use_low_power_mode
(touch /var/run/mce/restored) && (rm -f /var/lib/mce/radio_states.offline /var/lib/mce/radio_states.online /var/lib/mce/mce-settings.ini)
gconftool-2 -u /system/osso/dsm/display/color_profile
(touch /var/run/mce/restored) && (rm -f /var/lib/mce/radio_states.offline /var/lib/mce/radio_states.online)
65 changes: 65 additions & 0 deletions mce-gconf.c
Expand Up @@ -58,6 +58,31 @@ gboolean mce_gconf_set_int(const gchar *const key, const gint value)
return status;
}

/**
* Set an string GConf key to the specified value
*
* @param key The GConf key to set the value of
* @param value The value to set the key to
* @return TRUE on success, FALSE on failure
*/
gboolean mce_gconf_set_string(const gchar *const key, const gchar *const value)
{
gboolean status = FALSE;

if (gconf_client_set_string(gconf_client, key, value, NULL) == FALSE) {
mce_log(LL_WARN, "Failed to write %s to GConf", key);
goto EXIT;
}

/* synchronise if possible, ignore errors */
gconf_client_suggest_sync(gconf_client, NULL);

status = TRUE;

EXIT:
return status;
}

/**
* Return a boolean from the specified GConf key
*
Expand Down Expand Up @@ -194,6 +219,46 @@ gboolean mce_gconf_get_int_list(const gchar *const key, GSList **values)
return status;
}

/**
* Return an string from the specified GConf key
*
* @param key The GConf key to get the values from
* @param[out] value Will contain a newly allocated string with the value
* @return TRUE on success, FALSE on failure
*/
gboolean mce_gconf_get_string(const gchar *const key, gchar **value)
{
gboolean status = FALSE;
GError *error = NULL;
GConfValue *gcv;

gcv = gconf_client_get(gconf_client, key, &error);

if (gcv == NULL) {
mce_log((error != NULL) ? LL_WARN : LL_INFO,
"Could not retrieve %s from GConf; %s",
key, (error != NULL) ? error->message : "Key not set");
goto EXIT;
}

if ((gcv->type != GCONF_VALUE_STRING)) {
mce_log(LL_ERR,
"GConf key %s should have type: %d, but has type: %d",
key, GCONF_VALUE_STRING, gcv->type);
goto EXIT;
}

*value = g_strdup(gconf_value_get_string(gcv));
gconf_value_free(gcv);

status = TRUE;

EXIT:
g_clear_error(&error);

return status;
}

/**
* Add a GConf notifier
*
Expand Down
2 changes: 2 additions & 0 deletions mce-gconf.h
Expand Up @@ -31,6 +31,8 @@ gboolean mce_gconf_set_int(const gchar *const key, const gint value);
gboolean mce_gconf_get_bool(const gchar *const key, gboolean *value);
gboolean mce_gconf_get_int(const gchar *const key, gint *value);
gboolean mce_gconf_get_int_list(const gchar *const key, GSList **values);
gboolean mce_gconf_get_string(const gchar *const key, gchar **value);
gboolean mce_gconf_set_string(const gchar *const key, const gchar *const value);
gboolean mce_gconf_notifier_add(const gchar *path, const gchar *key,
const GConfClientNotifyFunc callback,
guint *cb_id);
Expand Down
26 changes: 26 additions & 0 deletions mce.ini
Expand Up @@ -620,3 +620,29 @@ CombinationCommunicationAndBatteryFull=PatternCommunicationAndBatteryFull;Patter
# priority value will have precedence), and will flash
# This pattern will be visible even when the display is on.
PatternExample=42;1;30;4000427f427f42ff42ff0000

[Display-c0]

# Color phase adjustments for the c0.* display revision
# Each value consists of sets of 12 numbers, each forming a entry for certain
# brightness range, the sets contain, brightness values in lux*3.3
# (330 = 100 lux):
# - brightness range lower limit (one of the ranges should start from 0)
# - brightness range upper limit (one of the ranges should have -1 = unlimited)
# - high brightness mode level
# - 3 coefficients for output red channel (red, green, blue)
# - 3 coefficients for output green channel (red, green, blue)
# - 3 coefficients for output blue channel (red, green, blue)

Neutral=0;330;0;199;28;28;8;209;8;8;8;239;330;3300;0;199;28;28;8;209;8;8;8;239
Vivid=0;33000;0;255;0;0;0;255;0;0;0;255;33000;-1;0;275;-10;-10;-10;275;-10;-10;-10;275;33000;-1;1;295;-20;-20;-20;295;-20;-20;-20;295;33000;-10;2;315;-30;-30;-30;315;-30;-30;-30;315
Muted=0;-1;0;85;85;85;85;85;85;85;85;85

[Display-fe]

# Color phase adjustments for the fe.* display revision
# See above for details

Neutral=0;330;0;199;28;28;8;209;8;8;8;239;330;3300;0;199;28;28;8;209;8;8;8;239
Vivid=0;33000;0;255;0;0;0;255;0;0;0;255;33000;-1;0;275;-10;-10;-10;275;-10;-10;-10;275;33000;-1;1;295;-20;-20;-20;295;-20;-20;-20;295;33000;-10;2;315;-30;-30;-30;315;-30;-30;-30;315
Muted=0;-1;0;85;85;85;85;85;85;85;85;85
3 changes: 2 additions & 1 deletion modules/display.c
Expand Up @@ -2104,7 +2104,8 @@ static gboolean display_off_req_dbus_cb(DBusMessage *const msg)
gboolean status = FALSE;

mce_log(LL_DEBUG,
"Received display off request");
"Received display off request from %s",
dbus_message_get_sender(msg));

(void)execute_datapipe(&display_state_pipe,
GINT_TO_POINTER(MCE_DISPLAY_OFF),
Expand Down

0 comments on commit 4b06f31

Please sign in to comment.