[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -1,6 +1,6 @@
<services>
<service name="tar_git">
- <param name="url">https://github.com/nemomobile/mce-plugin-libhybris.git</param>
+ <param name="url">https://github.com/mer-hybris/mce-plugin-libhybris.git</param>
<param name="branch">master</param>
<param name="revision">HEAD</param>
</service>
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/Makefile
^
|
@@ -9,6 +9,16 @@
_LIBDIR ?= /usr/lib
# ----------------------------------------------------------------------------
+# CONFIG
+# ----------------------------------------------------------------------------
+
+ENABLE_HYBRIS_SUPPPORT ?= 0
+
+ifeq ($(ENABLE_HYBRIS_SUPPORT),1)
+CPPFLAGS += -DENABLE_HYBRIS_SUPPORT
+endif
+
+# ----------------------------------------------------------------------------
# List of targets to build
# ----------------------------------------------------------------------------
@@ -64,8 +74,10 @@
# ----------------------------------------------------------------------------
PKG_NAMES += glib-2.0
+ifeq ($(ENABLE_HYBRIS_SUPPORT),1)
PKG_NAMES += libhardware
PKG_NAMES += android-headers
+endif
maintenance = normalize clean distclean mostlyclean
intersection = $(strip $(foreach w,$1, $(filter $w,$2)))
@@ -114,10 +126,12 @@
# Explicit dependencies
# ----------------------------------------------------------------------------
+ifeq ($(ENABLE_HYBRIS_SUPPORT),1)
hybris_OBJS += hybris-fb.pic.o
hybris_OBJS += hybris-lights.pic.o
hybris_OBJS += hybris-sensors.pic.o
hybris_OBJS += hybris-thread.pic.o
+endif
hybris_OBJS += plugin-api.pic.o
hybris_OBJS += plugin-config.pic.o
hybris_OBJS += plugin-logging.pic.o
@@ -134,12 +148,15 @@
hybris_OBJS += sysfs-led-white.pic.o
hybris_OBJS += sysfs-val.pic.o
-hybris.so : LDLIBS += -lhardware -lm
+ifeq ($(ENABLE_HYBRIS_SUPPORT),1)
+hybris.so : LDLIBS += -lhardware
+endif
+hybris.so : LDLIBS += -lm
hybris.so : $(hybris_OBJS)
install:: hybris.so
install -d -m755 $(DESTDIR)$(_LIBDIR)/mce/modules
- install -m644 hybris.so $(DESTDIR)$(_LIBDIR)/mce/modules/
+ install -m755 hybris.so $(DESTDIR)$(_LIBDIR)/mce/modules/
# ----------------------------------------------------------------------------
# Source code normalization
@@ -149,6 +166,7 @@
normalize::
normalize_whitespace -M Makefile
normalize_whitespace -a $(wildcard *.[ch] *.cc *.cpp)
+ normalize_whitespace -a $(wildcard inifiles/*.ini)
# ----------------------------------------------------------------------------
# AUTOMATIC HEADER DEPENDENCIES
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/hybris-fb.c
^
|
@@ -26,8 +26,41 @@
#include "plugin-api.h"
+#include <android-config.h>
#include <system/window.h>
+#include <hardware/gralloc.h>
#include <hardware/fb.h>
+#include <hardware/hwcomposer.h>
+
+/* ========================================================================= *
+ * Types
+ * ========================================================================= */
+
+/* When building for older devices, hwcomposer2.h header might not
+ * be available -> duplicate essential bits here, warts and all.
+ */
+
+typedef enum {
+ HWC2_FUNCTION_SET_POWER_MODE = 41,
+} hwc2_function_descriptor_t;
+
+typedef void (*hwc2_function_pointer_t)();
+
+typedef uint64_t hwc2_display_t;
+
+typedef struct hwc2_device
+{
+ struct hw_device_t common;
+ void (*getCapabilities)(struct hwc2_device *device,
+ uint32_t *outCount,
+ int32_t *outCapabilities);
+ hwc2_function_pointer_t (*getFunction)(struct hwc2_device *device,
+ int32_t descriptor);
+} hwc2_device_t;
+
+typedef int32_t (*HWC2_PFN_SET_POWER_MODE)(hwc2_device_t *device,
+ hwc2_display_t display,
+ int32_t mode);
/* ========================================================================= *
* PROTOTYPES
@@ -40,9 +73,6 @@
bool hybris_plugin_fb_load (void);
void hybris_plugin_fb_unload (void);
-static int hybris_plugin_fb_open_device (struct framebuffer_device_t **pdevice);
-static void hybris_plugin_fb_close_device (struct framebuffer_device_t **pdevice);
-
/* ------------------------------------------------------------------------- *
* FRAMEBUFFER_DEVICE
* ------------------------------------------------------------------------- */
@@ -58,6 +88,9 @@
/** Handle for libhybris framebuffer plugin */
static const struct hw_module_t *hybris_plugin_fb_handle = 0;
+/** Handle for libhybris hw composer plugin */
+static const struct hw_module_t *hybris_plugin_hwc_handle = 0;
+
/** Load libhybris framebuffer plugin
*
* @return true on success, false on failure
@@ -73,19 +106,33 @@
done = true;
- hw_get_module(GRALLOC_HARDWARE_FB0, &hybris_plugin_fb_handle);
-
+ /* Load framebuffer module */
+ hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hybris_plugin_fb_handle);
if( !hybris_plugin_fb_handle ) {
- mce_log(LL_WARN, "failed to open frame buffer module");
- goto cleanup;
+ mce_log(LL_DEBUG, "failed to open frame buffer module");
}
- mce_log(LL_DEBUG, "hybris_plugin_fb_handle = %p",
- hybris_plugin_fb_handle);
+ /* Load hw composer module */
+#ifdef HWC_DEVICE_API_VERSION_1_0
+ hw_get_module(HWC_HARDWARE_MODULE_ID, &hybris_plugin_hwc_handle);
+ if( !hybris_plugin_hwc_handle ) {
+ mce_log(LL_DEBUG, "failed to open hw composer module");
+ }
+#else
+ /* When compiling with really old hwcompser.h in place, assume
+ * that the target device is not going to have the hwc methods we
+ * are interested in -> skip module load -> hwc device loading and
+ * related cleanup turns into a nop without further #ifdeffing.
+ */
+#endif
+
+ /* Both fb and hwc are optional, but having neither is unexpected */
+ if( !hybris_plugin_fb_handle && !hybris_plugin_hwc_handle ) {
+ mce_log(LL_WARN, "could not open neither fb nor hwc module");
+ }
cleanup:
-
- return hybris_plugin_fb_handle != 0;
+ return hybris_plugin_fb_handle || hybris_plugin_hwc_handle;
}
/** Unload libhybris framebuffer plugin
@@ -93,55 +140,13 @@
void
hybris_plugin_fb_unload(void)
{
- /* Close devices related to the plugin */
+ /* Close open devices */
hybris_device_fb_quit();
- /* actually unload the module */
+ /* Unload modules */
// FIXME: how to unload libhybris modules?
-}
-
-/** Convenience function for opening frame buffer device
- *
- * Similar to what we might or might not have available from hardware/fb.h
- */
-static int
-hybris_plugin_fb_open_device(struct framebuffer_device_t ** pdevice)
-{
- int ack = false;
-
- if( !hybris_plugin_fb_load() ) {
- goto cleanup;
- }
-
- const struct hw_module_t *mod = hybris_plugin_fb_handle;
- const char *id = GRALLOC_HARDWARE_FB0;
- struct hw_device_t *dev = 0;
-
- if( !mod->methods->open(mod, id, &dev) ) {
- goto cleanup;
- }
-
- *pdevice = (struct framebuffer_device_t*)dev;
-
- ack = true;
-
-cleanup:
-
- return ack;
-}
-
-/** Convenience function for closing frame buffer device
- *
- * Similar to what we might or might not have available from hardware/fb.h
- */
-static void
-hybris_plugin_fb_close_device(struct framebuffer_device_t **pdevice)
-{
- struct framebuffer_device_t *device;
-
- if( (device = *pdevice) ) {
- *pdevice = 0, device->common.close(&device->common);
- }
+ hybris_plugin_fb_handle = 0;
+ hybris_plugin_hwc_handle = 0;
}
/* ========================================================================= *
@@ -149,7 +154,10 @@
* ========================================================================= */
/** Pointer to libhybris frame buffer device object */
-static struct framebuffer_device_t *hybris_device_fb_handle = 0;
+static hw_device_t *hybris_device_fb_handle = 0;
+
+/** Pointer to libhybris frame buffer device object */
+static hw_device_t *hybris_device_hwc_handle = 0;
/** Initialize libhybris frame buffer device object
*
@@ -158,6 +166,7 @@
bool
hybris_device_fb_init(void)
{
+ static bool ack = false;
static bool done = false;
if( done ) {
@@ -166,19 +175,116 @@
done = true;
- hybris_plugin_fb_open_device(&hybris_device_fb_handle);
-
- if( !hybris_device_fb_handle ) {
- mce_log(LL_ERR, "failed to open framebuffer device");
+ if( !hybris_plugin_fb_load() ) {
goto cleanup;
}
- mce_log(LL_DEBUG, "hybris_device_fb_handle = %p",
- hybris_device_fb_handle);
+ /* What we'd like to use is:
+ *
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/hybris-lights.c
^
|
@@ -26,6 +26,7 @@
#include "plugin-api.h"
+#include <android-config.h>
#include <system/window.h>
#include <hardware/lights.h>
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/hybris-sensors.c
^
|
@@ -25,6 +25,7 @@
#include "plugin-logging.h"
#include "hybris-thread.h"
+#include <android-config.h>
#include <hardware/sensors.h>
#include <glib.h>
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/inifiles/60-binary.ini
^
|
@@ -3,7 +3,7 @@
# Choose binary backend
BackEnd=binary
-# Configure base directories for binary channel
+# Configure base directory for binary channel
LedDirectory=/sys/class/leds/binary
# Built-in defaults for directory relative paths
@@ -13,3 +13,13 @@
# Optional channel specific overrides
#LedBrightnessFile=/sys/class/leds/binary/brightness
#LedMaxBrightnessFile=/sys/class/leds/binary/max_brightness
+
+# Optional on/off value overrides (only numbers supported)
+#OnValue=240
+#OffValue=12
+
+# Channel specific overrides are supported too, although
+# in the case of single channel binary led there is no
+# practical use for it ...
+#LedOnValue=230
+#LedOffValue=13
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/plugin-api.c
^
|
@@ -116,6 +116,8 @@
void mce_hybris_quit (void);
+#ifdef ENABLE_HYBRIS_SUPPORT
+
/* ========================================================================= *
* FRAME_BUFFER_POWER_STATE
* ========================================================================= */
@@ -218,6 +220,8 @@
return hybris_device_keypad_set_brightness(level);
}
+#endif //ENABLE_HYBRIS_SUPPORT
+
/* ========================================================================= *
* INDICATOR_LED_PATTERN
* ========================================================================= */
@@ -258,9 +262,15 @@
if( sysfs_led_init() ) {
mce_hybris_indicator_uses_sysfs = true;
}
+#ifdef ENABLE_HYBRIS_SUPPORT
else if( !hybris_device_indicator_init() ) {
goto cleanup;
}
+#else
+ else {
+ goto cleanup;
+ }
+#endif
ack = true;
@@ -280,10 +290,12 @@
/* Release sysfs controls */
sysfs_led_quit();
}
+#ifdef ENABLE_HYBRIS_SUPPORT
else {
/* Release libhybris controls */
hybris_device_indicator_quit();
}
+#endif
}
/** Set indicator led pattern via libhybris
@@ -329,9 +341,11 @@
if( mce_hybris_indicator_uses_sysfs ) {
ack = sysfs_led_set_pattern(r, g, b, ms_on, ms_off);
}
+#ifdef ENABLE_HYBRIS_SUPPORT
else {
ack = hybris_device_indicator_set_pattern(r, g, b, ms_on, ms_off);
}
+#endif
mce_log(LL_DEBUG, "pattern(%d,%d,%d,%d,%d) -> %s",
r,g,b, ms_on, ms_off , ack ? "success" : "failure");
@@ -409,6 +423,7 @@
return true;
}
+#ifdef ENABLE_HYBRIS_SUPPORT
/* ========================================================================= *
* PROXIMITY_SENSOR
* ========================================================================= */
@@ -496,6 +511,7 @@
{
hybris_device_als_set_hook(cb);
}
+#endif //ENABLE_HYBRIS_SUPPORT
/* ========================================================================= *
* GENERIC
@@ -506,7 +522,9 @@
void
mce_hybris_quit(void)
{
+#ifdef ENABLE_HYBRIS_SUPPORT
hybris_plugin_fb_unload();
hybris_plugin_lights_unload();
hybris_plugin_sensors_unload();
+#endif
}
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/plugin-config.c
^
|
@@ -75,7 +75,7 @@
void
objconf_init(const objconf_t *cfg, void *obj)
{
- for( size_t i = 0; cfg[i].key; ++i ) {
+ for( size_t i = 0; cfg[i].type != CONFTYPE_NONE; ++i ) {
char **memb = lea(obj, cfg[i].off);
*memb = 0;
}
@@ -89,7 +89,7 @@
void
objconf_quit(const objconf_t *cfg, void *obj)
{
- for( size_t i = 0; cfg[i].key; ++i ) {
+ for( size_t i = 0; cfg[i].type != CONFTYPE_NONE; ++i ) {
char **memb = lea(obj, cfg[i].off);
free(*memb), *memb = 0;
}
@@ -121,39 +121,84 @@
snprintf(tmp, sizeof tmp, "%sDirectory", chn);
dir = plugin_config_get_string(MCE_CONF_LED_CONFIG_HYBRIS_GROUP, tmp, 0);
- for( size_t i = 0; cfg[i].key; ++i ) {
- char **memb = lea(obj, cfg[i].off);
+ for( size_t i = 0; cfg[i].type != CONFTYPE_NONE; ++i ) {
+ const char *ini_key = cfg[i].key;
+ gchar *ini_value = 0;
+ char **cfg_member = lea(obj, cfg[i].off);
+ char *cfg_value = 0;
+
+ switch( cfg[i].type ) {
+ case CONFTYPE_FILE:
+ /* Fetch absolute control file path in form of
+ *
+ * <CHANNEL><MEMBER>File=sys/class/leds/red/brightness
+ *
+ * Where MEMBER is "Brightness", "MaxBrightness", etc
+ */
+ snprintf(tmp, sizeof tmp, "%s%sFile", chn, ini_key);
+ ini_value = plugin_config_get_string(MCE_CONF_LED_CONFIG_HYBRIS_GROUP,
+ tmp, 0);
+ if( !ini_value && dir ) {
+ /* Fetch control file path relative to directory
+ *
+ * <MEMBER>File=brightness
+ */
+ snprintf(tmp, sizeof tmp, "%sFile", ini_key);
+ ini_value = plugin_config_get_string(MCE_CONF_LED_CONFIG_HYBRIS_GROUP,
+ tmp, 0);
+ }
- /* Fetch absolute control file path in form of
- * <CHANNEL><MEMBER>File=sys/class/leds/red/brightness
- *
- * Where MEMBER is "Brightness", "MaxBrightness", etc
- */
- snprintf(tmp, sizeof tmp, "%s%sFile", chn, cfg[i].key);
- gchar *val = plugin_config_get_string(MCE_CONF_LED_CONFIG_HYBRIS_GROUP,
- tmp, 0);
- if( val ) {
- snprintf(tmp, sizeof tmp, "%s/%s", dir, val);
- free(*memb), *memb = strdup(tmp);
- g_free(val);
- }
- else if( dir ) {
- /* Fetch control file path relative to directory
+ if( !ini_value && cfg[i].def ) {
+ /* Use defined fallback value */
+ ini_value = g_strdup(cfg[i].def);
+ }
+
+ if( ini_value ) {
+ snprintf(tmp, sizeof tmp, "%s/%s", dir, ini_value);
+ cfg_value = strdup(tmp);
+ }
+ break;
+
+ case CONFTYPE_STRING:
+ /* Fetch string value in form of
+ * 1. <CHANNEL><MEMBER>=<string>
+ * 2. <MEMBER>=<string>
+ * 3. defined fallback value
*
- * <MEMBER>File=brightness
+ * Where CHANNEL is "Red", "Green", "Blue", etc
+ * Where MEMBER is "OnValue", "OffValue", etc
*/
- snprintf(tmp, sizeof tmp, "%sFile", cfg[i].key);
- val = plugin_config_get_string(MCE_CONF_LED_CONFIG_HYBRIS_GROUP,
- tmp, cfg[i].def);
- if( val ) {
- snprintf(tmp, sizeof tmp, "%s/%s", dir, val);
- free(*memb), *memb = strdup(tmp);
- g_free(val);
+ snprintf(tmp, sizeof tmp, "%s%s", chn, ini_key);
+ ini_value = plugin_config_get_string(MCE_CONF_LED_CONFIG_HYBRIS_GROUP,
+ tmp, 0);
+
+ if( !ini_value ) {
+ snprintf(tmp, sizeof tmp, "%s", ini_key);
+ ini_value = plugin_config_get_string(MCE_CONF_LED_CONFIG_HYBRIS_GROUP,
+ tmp, cfg[i].def);
}
+
+ if( ini_value )
+ cfg_value = strdup(ini_value);
+ break;
+
+ default:
+ break;
}
- set += (*memb != 0);
+ g_free(ini_value);
- mce_log(LOG_DEBUG, "%s:%s = %s", chn, cfg[i].key, *memb ?: "NA");
+ if( cfg_value ) {
+ /* Note: The cfg_member is likely to point to a structure member
+ * that has been defined to have 'const char *' type, and
+ * we ignore it here on purpose.
+ *
+ * ... because the same structures are used also for legacy
+ * lookup table based approach - which basically requires
+ * using const strings for things to make sense.
+ */
+ ++set, free(*cfg_member), *cfg_member = cfg_value;
+ mce_log(LOG_DEBUG, "%s:%s = %s", chn, ini_key, *cfg_member ?: "NA");
+ }
}
g_free(dir);
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/plugin-config.h
^
|
@@ -45,9 +45,24 @@
gchar * plugin_config_get_string(const gchar *group, const gchar *key, const gchar *defaultval);
+typedef enum
+{
+ /** Item is not valid / is a sentinel */
+ CONFTYPE_NONE,
+
+ /** Item is a file path */
+ CONFTYPE_FILE,
+
+ /** Item is a standalone string value */
+ CONFTYPE_STRING,
+} conftype_t;
+
/** Inifile to object member mapping info */
typedef struct
{
+ /** Type of configuration value */
+ conftype_t type;
+
/** Ini-file key */
const char *key;
@@ -61,7 +76,17 @@
/** Object configuration entry sentinel */
#define OBJCONF_STOP \
{\
- .key = 0,\
+ .type = CONFTYPE_NONE,\
+ }
+
+/** Object configuration entry for standalone string value
+ */
+#define OBJCONF_STRING(obj_,memb_,key_,def_)\
+ {\
+ .type = CONFTYPE_STRING,\
+ .key = #key_,\
+ .def = def_,\
+ .off = offsetof(obj_,memb_),\
}
/** Object configuration entry for file path
@@ -70,6 +95,7 @@
*/
#define OBJCONF_FILE(obj_,memb_,key_)\
{\
+ .type = CONFTYPE_FILE,\
.key = #key_,\
.def = #memb_,\
.off = offsetof(obj_,memb_),\
@@ -81,6 +107,7 @@
*/
#define OBJCONF_FILE_EX(obj_,memb_,key_,def_)\
{\
+ .type = CONFTYPE_FILE,\
.key = #key_,\
.def = def_,\
.off = offsetof(obj_,memb_),\
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.5.tar.bz2/sysfs-led-binary.c
^
|
@@ -51,12 +51,16 @@
{
const char *brightness;
const char *max_brightness;
+ const char *on_string;
+ const char *off_string;
} led_paths_binary_t;
typedef struct
{
sysfsval_t *cached_max_brightness;
sysfsval_t *cached_brightness;
+ int on_value;
+ int off_value;
} led_channel_binary_t;
/* ------------------------------------------------------------------------- *
@@ -132,8 +136,7 @@
static void
led_channel_binary_set_value(led_channel_binary_t *self, int value)
{
- value = led_util_scale_value(value,
- sysfsval_get(self->cached_max_brightness));
+ value = value ? self->on_value : self->off_value;
sysfsval_set(self->cached_brightness, value);
}
@@ -187,8 +190,12 @@
bool ack = false;
for( size_t i = 0; i < G_N_ELEMENTS(paths); ++i ) {
- if( (ack = led_channel_binary_probe(channel+0, &paths[i][0])) )
- break;
+ if( !(ack = led_channel_binary_probe(&channel[0], &paths[i][0])) )
+ continue;
+
+ channel[i].off_value = 0;
+ channel[i].on_value = sysfsval_get(channel[0].cached_max_brightness);
+ break;
}
return ack;
@@ -201,6 +208,10 @@
{
OBJCONF_FILE(led_paths_binary_t, brightness, Brightness),
OBJCONF_FILE(led_paths_binary_t, max_brightness, MaxBrightness),
+
+ OBJCONF_STRING(led_paths_binary_t, on_string, OnValue, 0),
+ OBJCONF_STRING(led_paths_binary_t, off_string, OffValue, 0),
+
OBJCONF_STOP
};
@@ -223,6 +234,21 @@
if( !led_channel_binary_probe(channel+i, &paths[i]) )
goto cleanup;
+
+ if( paths[i].off_string )
+ channel[i].off_value = strtol(paths[i].off_string, 0, 0);
+ else
+ channel[i].off_value = 0;
+
+ if( paths[i].on_string )
+ channel[i].on_value = strtol(paths[i].on_string, 0, 0);
+ else
+ channel[i].on_value = sysfsval_get(channel[i].cached_max_brightness);
+
+ mce_log(LL_DEBUG,"[%s] on_value=%d off_value=%d",
+ pfix[i],
+ channel[i].on_value,
+ channel[i].off_value);
}
ack = true;
|