[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.spec
^
|
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.13.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.13.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.13.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.13.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.13.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;
|