[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.changes
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -1,8 +1,8 @@
<services>
<service name="tar_git">
- <param name="url">https://github.com/mer-hybris/mce-plugin-libhybris.git</param>
+ <param name="url">https://github.com/Sailfish-On-Vince/mce-plugin-libhybris.git</param>
<param name="branch">master</param>
- <param name="revision">8242dbe4fe72c54b6f8ef0ef4528a8d682bef063</param>
+ <param name="revision">b5c846da056212da43dabfa55953d87c64c08f9f</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.12.3.tar.bz2/.depend
^
|
@@ -182,6 +182,24 @@
sysfs-led-util.h\
sysfs-val.h\
+sysfs-led-vince.o:\
+ sysfs-led-vince.c\
+ plugin-config.h\
+ plugin-logging.h\
+ sysfs-led-vince.h\
+ sysfs-led-main.h\
+ sysfs-led-util.h\
+ sysfs-val.h\
+
+sysfs-led-vince.pic.o:\
+ sysfs-led-vince.c\
+ plugin-config.h\
+ plugin-logging.h\
+ sysfs-led-vince.h\
+ sysfs-led-main.h\
+ sysfs-led-util.h\
+ sysfs-val.h\
+
sysfs-led-main.o:\
sysfs-led-main.c\
plugin-config.h\
@@ -192,6 +210,7 @@
sysfs-led-f5121.h\
sysfs-led-hammerhead.h\
sysfs-led-htcvision.h\
+ sysfs-led-vince.h\
sysfs-led-main.h\
sysfs-led-redgreen.h\
sysfs-led-util.h\
@@ -208,6 +227,7 @@
sysfs-led-f5121.h\
sysfs-led-hammerhead.h\
sysfs-led-htcvision.h\
+ sysfs-led-vince.h\
sysfs-led-main.h\
sysfs-led-redgreen.h\
sysfs-led-util.h\
@@ -287,4 +307,3 @@
sysfs-val.c\
plugin-logging.h\
sysfs-val.h\
-
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.12.3.tar.bz2/Makefile
^
|
@@ -132,6 +132,7 @@
hybris_OBJS += sysfs-led-util.pic.o
hybris_OBJS += sysfs-led-vanilla.pic.o
hybris_OBJS += sysfs-led-white.pic.o
+hybris_OBJS += sysfs-led-vince.pic.o
hybris_OBJS += sysfs-val.pic.o
hybris.so : LDLIBS += -lhardware -lm
|
[-]
[+]
|
Added |
_service:tar_git:mce-plugin-libhybris-1.12.3.tar.bz2/inifiles/60-vince.ini
^
|
@@ -0,0 +1,9 @@
+[LEDConfigHybris]
+
+# Choose vince backend
+BackEnd=vince
+
+
+RedDirectory=/sys/class/leds/green
+GreenDirectory=/sys/class/leds/green
+BlueDirectory=/sys/class/leds/green
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.12.3.tar.bz2/sysfs-led-main.c
^
|
@@ -32,6 +32,7 @@
#include "sysfs-led-binary.h"
#include "sysfs-led-redgreen.h"
#include "sysfs-led-white.h"
+#include "sysfs-led-vince.h"
#include "plugin-logging.h"
#include "plugin-config.h"
@@ -300,6 +301,10 @@
/* The binary backend needs just one directory
* that has 'brightness' control file. */
{ "binary", led_control_binary_probe },
+
+ /* The vince requires 'brightness', 'max_brightness' and 'blink'
+ * control files to be present for red, green and blue channels. */
+ { "vince", led_control_vince_probe },
};
bool ack = false;
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.12.3.tar.bz2/sysfs-led-redgreen.c
^
|
@@ -277,7 +277,7 @@
/* We can use sw breathing logic to simulate hw blinking */
self->can_breathe = true;
- self->breath_type = LED_RAMP_HARD_STEP;
+ // self->breath_type = LED_RAMP_HARD_STEP;
if( self->use_config )
res = led_control_redgreen_dynamic_probe(channel);
|
[-]
[+]
|
Added |
_service:tar_git:mce-plugin-libhybris-1.12.3.tar.bz2/sysfs-led-vince.c
^
|
@@ -0,0 +1,372 @@
+/** @file sysfs-led-vince.c
+ *
+ * mce-plugin-libhybris - Libhybris plugin for Mode Control Entity
+ * <p>
+ * Copyright (C) 2017 Jolla Ltd.
+ * <p>
+ * @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
+ * @author BirdZhang <0312birdzhang@gmail.com>
+ *
+ * mce-plugin-libhybris is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License.
+ *
+ * mce-plugin-libhybris 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with mce-plugin-libhybris; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* ========================================================================= *
+ * RGB led control: vince backend
+ *
+ * Three channels, all of which:
+ * - must have 'brightness' control file
+ * - must have 'max_brightness' control file
+ * - must have 'blink' control file
+ *
+ * Assumptions built into code:
+ * - writing to 'blink' affects 'brightness' control too and vice versa
+ * ========================================================================= */
+
+#include "sysfs-led-vince.h"
+#include "sysfs-led-util.h"
+#include "sysfs-val.h"
+#include "plugin-config.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <glib.h>
+
+/* ========================================================================= *
+ * PROTOTYPES
+ * ========================================================================= */
+
+typedef struct
+{
+ const char *max_brightness;
+ const char *brightness;
+ const char *blink;
+} led_paths_vince_t;
+
+typedef struct
+{
+ sysfsval_t *cached_max_brightness;
+ sysfsval_t *cached_brightness;
+ sysfsval_t *cached_blink;
+
+ int control_value;
+ bool control_blink;
+
+} led_channel_vince_t;
+
+/* ------------------------------------------------------------------------- *
+ * ONE_CHANNEL
+ * ------------------------------------------------------------------------- */
+
+static void led_channel_vince_init (led_channel_vince_t *self);
+static void led_channel_vince_close (led_channel_vince_t *self);
+static bool led_channel_vince_probe (led_channel_vince_t *self, const led_paths_vince_t *path);
+static void led_channel_vince_set_value (led_channel_vince_t *self, int value);
+static void led_channel_vince_set_blink (led_channel_vince_t *self, int on_ms, int off_ms);
+
+/* ------------------------------------------------------------------------- *
+ * ALL_CHANNELS
+ * ------------------------------------------------------------------------- */
+
+static void led_control_vince_blink_cb (void *data, int on_ms, int off_ms);
+static void led_control_vince_value_cb (void *data, int r, int g, int b);
+static void led_control_vince_close_cb (void *data);
+
+bool led_control_vince_probe (led_control_t *self);
+
+/* ========================================================================= *
+ * ONE_CHANNEL
+ * ========================================================================= */
+
+static void
+led_channel_vince_init(led_channel_vince_t *self)
+{
+ self->cached_max_brightness = sysfsval_create();
+ self->cached_brightness = sysfsval_create();
+ self->cached_blink = sysfsval_create();
+
+ self->control_blink = false;
+ self->control_value = 0;
+}
+
+static void
+led_channel_vince_close(led_channel_vince_t *self)
+{
+ sysfsval_delete(self->cached_max_brightness),
+ self->cached_max_brightness = 0;
+
+ sysfsval_delete(self->cached_brightness),
+ self->cached_brightness = 0;
+
+ sysfsval_delete(self->cached_blink),
+ self->cached_blink = 0;
+}
+
+static bool
+led_channel_vince_probe(led_channel_vince_t *self,
+ const led_paths_vince_t *path)
+{
+ bool ack = false;
+
+ /* Probe control files in reverse existance likelihood order.
+ * Practically all led control directories have 'brightness'
+ * file, most have 'max_brightness' while only some have 'blink'.
+ */
+ if( !sysfsval_open_rw(self->cached_blink, path->blink) )
+ goto cleanup;
+
+ if( !sysfsval_open_ro(self->cached_max_brightness, path->max_brightness) )
+ goto cleanup;
+
+ /* The 'max_brightness' seems to be dynamic. Make an attempt
+ * to set it to an artificially high value and assume that kernel
+ * side will cap the value to the true maximum... */
+#if 1 // TODO: make a QUIRK out of this
+ sysfsval_set(self->cached_max_brightness, 255);
+#endif
+ sysfsval_refresh(self->cached_max_brightness);
+
+ if( sysfsval_get(self->cached_max_brightness) <= 0 )
+ goto cleanup;
+
+ if( !sysfsval_open_rw(self->cached_brightness, path->brightness) )
+ goto cleanup;
+
+ ack = true;
+
+cleanup:
+
+ /* Always close the max_brightness file */
+ sysfsval_close(self->cached_max_brightness);
+
+ /* On failure close the other files too */
+ if( !ack ) {
+ sysfsval_close(self->cached_brightness);
+ sysfsval_close(self->cached_blink);
+ }
+
+ return ack;
+}
+
+static void
+led_channel_vince_set_value(led_channel_vince_t *self,
+ int value)
+{
+ /*
+ * Since Xiaomi implemented 4095 level brightness in panel dtsi
+ * while caf only have 255 level, we multiply 16 to brightness by default.
+ */
+
+ value *= 16;
+ value = (value < 0) ? 0 : (value < 255) ? value : 255;
+ // value = led_util_scale_value(value,
+ // sysfsval_get(self->cached_max_brightness));
+
+ /* Ignore blinking requests while brightness is zero. */
+ if( value <= 0 )
+ self->control_blink = false;
+
+ /* Logically it probably should be that:
+ * - writing blink=1 implies brightness=255
+ * - writing blink=0 implies brightness=0
+ * - writing brightness=n implies blink=0
+ *
+ * However it seems swithing between blinking and non-blinking
+ * modes can cause hiccups that vary from one device to another
+ * (stale sysfs values left behind, led stays off when it should
+ * be lit, ...)
+ *
+ * So the logic is arranged that before switching from static
+ * color to blinking, a brightness=0 is done before writing
+ * blink=0, and when swithing from blinking to static color, a
+ * blink=0 is done before writing brightness=0.
+ *
+ * Note that upper level state machine logic + caching of the
+ * assumed sysfs values means that these transitions are done in
+ * 3 steps (cancel previous mode, reset to black, switch to new
+ * mode) with pproximately SYSFS_LED_KERNEL_DELAY ms in between
|
[-]
[+]
|
Added |
_service:tar_git:mce-plugin-libhybris-1.12.3.tar.bz2/sysfs-led-vince.h
^
|
@@ -0,0 +1,31 @@
+/** @file sysfs-led-vince.h
+ *
+ * mce-plugin-libhybris - Libhybris plugin for Mode Control Entity
+ * <p>
+ * Copyright (C) 2017 Jolla Ltd.
+ * <p>
+ * @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
+ *
+ * mce-plugin-libhybris is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License.
+ *
+ * mce-plugin-libhybris 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with mce-plugin-libhybris; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef SYSFS_LED_VINCE_H_
+# define SYSFS_LED_VINCE_H_
+
+# include "sysfs-led-main.h"
+
+bool led_control_vince_probe(led_control_t *self);
+
+#endif /* SYSFS_LED_VINCE_H_ */
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.12.3.tar.bz2/sysfs-led-white.c
^
|
@@ -178,8 +178,8 @@
// "Motorola Moto G (2nd gen)"
{
{
- .max_brightness = "/sys/class/leds/white/max_brightness",
- .brightness = "/sys/class/leds/white/brightness",
+ .max_brightness = "/sys/class/leds/green/max_brightness",
+ .brightness = "/sys/class/leds/green/brightness",
},
},
};
@@ -253,7 +253,8 @@
/* We can use sw breathing logic */
self->can_breathe = true;
-
+ self->breath_type = LED_RAMP_HARD_STEP;
+
if( self->use_config )
res = led_control_white_dynamic_probe(channel);
|