[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.spec
^
|
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.0.tar.bz2/Makefile
^
|
@@ -149,6 +149,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.0.tar.bz2/hybris-fb.c
^
|
@@ -32,6 +32,36 @@
#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
* ========================================================================= */
@@ -123,14 +153,10 @@
* ========================================================================= */
/** Pointer to libhybris frame buffer device object */
-static framebuffer_device_t *hybris_device_fb_handle = 0;
+static hw_device_t *hybris_device_fb_handle = 0;
/** Pointer to libhybris frame buffer device object */
-#ifdef HWC_DEVICE_API_VERSION_1_0
-static hwc_composer_device_1_t *hybris_device_hwc_handle = 0;
-#else
-static hwc_composer_device_t *hybris_device_hwc_handle = 0;
-#endif
+static hw_device_t *hybris_device_hwc_handle = 0;
/** Initialize libhybris frame buffer device object
*
@@ -152,26 +178,6 @@
goto cleanup;
}
- /* Open frame buffer device */
- if( hybris_plugin_fb_handle ) {
- hybris_plugin_fb_handle->methods->open(hybris_plugin_fb_handle,
- GRALLOC_HARDWARE_FB0,
- (hw_device_t**)&hybris_device_fb_handle);
- if( !hybris_device_fb_handle ) {
- mce_log(LL_WARN, "failed to open frame buffer device");
- }
- }
-
- /* Open hw composer device */
- if( hybris_plugin_hwc_handle ) {
- hybris_plugin_hwc_handle->methods->open(hybris_plugin_hwc_handle,
- HWC_HARDWARE_COMPOSER,
- (hw_device_t**)&hybris_device_hwc_handle);
- if( !hybris_device_hwc_handle ) {
- mce_log(LL_WARN, "failed to open hw composer device");
- }
- }
-
/* What we'd like to use is:
*
* 1. hwc_dev->setPowerMode()
@@ -181,29 +187,87 @@
* While all are optional, having none available is unexpected.
*/
-#ifdef HWC_DEVICE_API_VERSION_1_0
- if( hybris_device_hwc_handle ) {
-# ifdef HWC_DEVICE_API_VERSION_1_4
- if( hybris_device_hwc_handle->common.version >= HWC_DEVICE_API_VERSION_1_4 &&
- hybris_device_hwc_handle->setPowerMode ) {
- mce_log(LL_DEBUG, "using hw composer setPowerMode() method");
- ack = true;
- goto cleanup;
+ /* Probe hw composer device */
+ if( hybris_plugin_hwc_handle ) {
+ hybris_plugin_hwc_handle->methods->open(hybris_plugin_hwc_handle,
+ HWC_HARDWARE_COMPOSER,
+ &hybris_device_hwc_handle);
+ if( !hybris_device_hwc_handle ) {
+ mce_log(LL_WARN, "failed to open hw composer device");
}
-# endif
- if( hybris_device_hwc_handle->blank ) {
- mce_log(LL_DEBUG, "using hw composer blank() method");
- ack = true;
- goto cleanup;
+ else {
+ uint32_t vers = hybris_device_hwc_handle->version >> 16;
+ mce_log(LL_DEBUG, "hwc version: %u.%u", (vers >> 8), (vers & 255));
+ if( vers >= 0x0300 ) {
+ mce_log(LL_WARN, "hwc api level 3+ - not supported");
+ }
+ else if( vers >= 0x0200 ) {
+ hwc2_device_t *hwcdev = (hwc2_device_t *)hybris_device_hwc_handle;
+ if( hwcdev->getFunction ) {
+ if( hwcdev->getFunction(hwcdev, HWC2_FUNCTION_SET_POWER_MODE) ) {
+ mce_log(LL_DEBUG, "using hw composer 2.0 setPowerMode() method");
+ ack = true;
+ goto cleanup;
+ }
+ }
+ mce_log(LL_WARN, "hwc api level 2.0 - setPowerMode() not available");
+ }
+ else if( vers >= 0x0104 ) {
+#ifdef HWC_DEVICE_API_VERSION_1_4
+ hwc_composer_device_1_t *hwcdev = (hwc_composer_device_1_t *)hybris_device_hwc_handle;
+ if( hwcdev->setPowerMode ) {
+ mce_log(LL_DEBUG, "using hw composer 1.4 setPowerMode() method");
+ ack = true;
+ goto cleanup;
+ }
+#endif
+ mce_log(LL_WARN, "hwc api level 1.4 - setPowerMode() not available");
+ }
+ else if( vers >= 0x0100 ) {
+#ifdef HWC_DEVICE_API_VERSION_1_0
+ hwc_composer_device_1_t *hwcdev = (hwc_composer_device_1_t *)hybris_device_hwc_handle;
+ if( hwcdev->blank ) {
+ mce_log(LL_DEBUG, "using hw composer 1.0 blank() method");
+ ack = true;
+ goto cleanup;
+ }
+#endif
+ mce_log(LL_WARN, "hwc api level 1.0 - blank() not available");
+ }
+ else {
+ mce_log(LL_WARN, "hwc api level 0 - not supported");
+ }
+
+ /* Nothing usable available -> close device */
+ hybris_device_hwc_handle->close(hybris_device_hwc_handle),
+ hybris_device_hwc_handle = 0;
}
}
-#endif
- if( hybris_device_fb_handle ) {
- if( hybris_device_fb_handle->enableScreen ) {
- mce_log(LL_DEBUG, "using framebuffer enableScreen() method");
- ack = true;
- goto cleanup;
+ /* Probe frame buffer device */
+ if( hybris_plugin_fb_handle ) {
+ hybris_plugin_fb_handle->methods->open(hybris_plugin_fb_handle,
+ GRALLOC_HARDWARE_FB0,
+ &hybris_device_fb_handle);
+ if( !hybris_device_fb_handle ) {
+ mce_log(LL_WARN, "failed to open frame buffer device");
+ }
+ else {
+ uint32_t vers = hybris_device_fb_handle->version >> 16;
+ mce_log(LL_DEBUG, "fb_device version: %u.%u", (vers >> 8), (vers & 255));
+
+ framebuffer_device_t *fbdev = (framebuffer_device_t *)hybris_device_fb_handle;
+
+ if( fbdev->enableScreen ) {
+ mce_log(LL_DEBUG, "using framebuffer enableScreen() method");
+ ack = true;
+ goto cleanup;
+ }
+ mce_log(LL_WARN, "fb api - enableScreen() not available");
+
+ /* Nothing usable available -> close device */
+ hybris_device_fb_handle->close(hybris_device_fb_handle),
+ hybris_device_fb_handle = 0;
}
}
@@ -220,12 +284,12 @@
hybris_device_fb_quit(void)
{
if( hybris_device_hwc_handle ) {
- hybris_device_hwc_handle->common.close(&hybris_device_hwc_handle->common);
+ hybris_device_hwc_handle->close(hybris_device_hwc_handle),
hybris_device_hwc_handle = 0;
}
if( hybris_device_fb_handle ) {
- hybris_device_fb_handle->common.close(&hybris_device_fb_handle->common);
+ hybris_device_fb_handle->close(hybris_device_fb_handle),
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.14.0.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.0.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.0.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.0.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;
|