[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,7 +6,7 @@
<service name="tar_git">
<param name="url">https://github.com/nemomobile/mce-plugin-libhybris.git</param>
<param name="branch">master</param>
- <param name="revision">b9d5782021aa410f3146228fe01ebb6a84d01237</param>
+ <param name="revision">a8dd6d9bdc9cb63417369e926b322fd3201bfed3</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.9.0.tar.bz2/Makefile
^
|
@@ -125,6 +125,7 @@
hybris_OBJS += sysfs-led-hammerhead.pic.o
hybris_OBJS += sysfs-led-htcvision.pic.o
hybris_OBJS += sysfs-led-main.pic.o
+hybris_OBJS += sysfs-led-redgreen.pic.o
hybris_OBJS += sysfs-led-util.pic.o
hybris_OBJS += sysfs-led-vanilla.pic.o
|
[-]
[+]
|
Changed |
_service:tar_git:mce-plugin-libhybris-1.9.0.tar.bz2/sysfs-led-main.c
^
|
@@ -29,6 +29,7 @@
#include "sysfs-led-bacon.h"
#include "sysfs-led-htcvision.h"
#include "sysfs-led-binary.h"
+#include "sysfs-led-redgreen.h"
#include "plugin-logging.h"
@@ -271,6 +272,11 @@
* to be present for red, green and blue channels. */
led_control_vanilla_probe,
+ /* The redgreen uses subset of "standard" rgb led
+ * control paths, so to avoid false positive matches
+ * it must be probed after rgb led controls. */
+ led_control_redgreen_probe,
+
/* The binary backend needs just one directory
* that has 'brightness' control file. */
led_control_binary_probe,
|
[-]
[+]
|
Added |
_service:tar_git:mce-plugin-libhybris-1.9.0.tar.bz2/sysfs-led-redgreen.c
^
|
@@ -0,0 +1,228 @@
+/** @file sysfs-led-redgreen.c
+ *
+ * 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
+ */
+
+/* ========================================================================= *
+ * Red + green led control
+ *
+ * Two channels (red and green), both of which:
+ * - must have 'brightness' control file
+ * - must have 'max_brightness' control file
+ *
+ * Notes:
+ * - despite having wide max_brightness range, the brightness control
+ * is binary: zero for off and any non-zero value for on.
+ * ========================================================================= */
+
+#include "sysfs-led-redgreen.h"
+
+#include "sysfs-led-util.h"
+
+#include <stdio.h>
+
+#include <glib.h>
+
+/* ========================================================================= *
+ * PROTOTYPES
+ * ========================================================================= */
+
+typedef struct
+{
+ const char *max; // R
+ const char *val; // W
+} led_paths_redgreen_t;
+
+typedef struct
+{
+ int maxval;
+ int fd_val;
+} led_channel_redgreen_t;
+
+/* ------------------------------------------------------------------------- *
+ * ONE_CHANNEL
+ * ------------------------------------------------------------------------- */
+
+static void led_channel_redgreen_init (led_channel_redgreen_t *self);
+static void led_channel_redgreen_close (led_channel_redgreen_t *self);
+static bool led_channel_redgreen_probe (led_channel_redgreen_t *self, const led_paths_redgreen_t *path);
+static void led_channel_redgreen_set_value (const led_channel_redgreen_t *self, int value);
+
+/* ------------------------------------------------------------------------- *
+ * ALL_CHANNELS
+ * ------------------------------------------------------------------------- */
+
+static void led_control_redgreen_map_color (int r, int g, int b, int *red, int *green);
+static void led_control_redgreen_value_cb (void *data, int r, int g, int b);
+static void led_control_redgreen_close_cb (void *data);
+
+bool led_control_redgreen_probe (led_control_t *self);
+
+/* ========================================================================= *
+ * ONE_CHANNEL
+ * ========================================================================= */
+
+static void
+led_channel_redgreen_init(led_channel_redgreen_t *self)
+{
+ self->maxval = -1;
+ self->fd_val = -1;
+}
+
+static void
+led_channel_redgreen_close(led_channel_redgreen_t *self)
+{
+ led_util_close_file(&self->fd_val);
+}
+
+static bool
+led_channel_redgreen_probe(led_channel_redgreen_t *self,
+ const led_paths_redgreen_t *path)
+{
+ bool res = false;
+
+ led_channel_redgreen_close(self);
+
+ if( (self->maxval = led_util_read_number(path->max)) <= 0 )
+ {
+ goto cleanup;
+ }
+
+ if( !led_util_open_file(&self->fd_val, path->val) )
+ {
+ goto cleanup;
+ }
+
+ res = true;
+
+cleanup:
+
+ if( !res ) led_channel_redgreen_close(self);
+
+ return res;
+}
+
+static void
+led_channel_redgreen_set_value(const led_channel_redgreen_t *self,
+ int value)
+{
+ if( self->fd_val != -1 )
+ {
+ dprintf(self->fd_val, "%d", led_util_scale_value(value, self->maxval));
+ }
+}
+
+/* ========================================================================= *
+ * ALL_CHANNELS
+ * ========================================================================= */
+
+static void
+led_control_redgreen_map_color(int r, int g, int b, int *red, int *green)
+{
+ /* If the pattern defines red and/or green intensities, those should
+ * be used. Otherwise make sure that requesting for blue only colour
+ * does not result in the led being turned off. */
+ if( r || g )
+ {
+ *red = r;
+ *green = g;
+ }
+ else
+ {
+ *red = b;
+ *green = b;
+ }
+}
+
+static void
+led_control_redgreen_value_cb(void *data, int r, int g, int b)
+{
+ const led_channel_redgreen_t *channel = data;
+
+ int red = 0;
+ int green = 0;
+ led_control_redgreen_map_color(r, g, b, &red, &green);
+
+ led_channel_redgreen_set_value(channel + 0, red);
+ led_channel_redgreen_set_value(channel + 1, green);
+}
+
+static void
+led_control_redgreen_close_cb(void *data)
+{
+ led_channel_redgreen_t *channel = data;
+ led_channel_redgreen_close(channel + 0);
+ led_channel_redgreen_close(channel + 1);
+}
+
+bool
+led_control_redgreen_probe(led_control_t *self)
+{
+ /** Sysfs control paths for Red + Green leds */
+ static const led_paths_redgreen_t paths[][2] =
+ {
+ // "standard" paths
+ {
+ {
+ .max = "/sys/class/leds/red/max_brightness",
+ .val = "/sys/class/leds/red/brightness",
+ },
+ {
+ .max = "/sys/class/leds/green/max_brightness",
+ .val = "/sys/class/leds/green/brightness",
+ },
+ },
+ };
+
+ static led_channel_redgreen_t channel[2];
+
+ bool res = false;
+
+ led_channel_redgreen_init(channel + 0);
|
[-]
[+]
|
Added |
_service:tar_git:mce-plugin-libhybris-1.9.0.tar.bz2/sysfs-led-redgreen.h
^
|
@@ -0,0 +1,31 @@
+/** @file sysfs-led-redgreen.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_REDGREEN_H_
+# define SYSFS_LED_REDGREEN_H_
+
+# include "sysfs-led-main.h"
+
+bool led_control_redgreen_probe(led_control_t *self);
+
+#endif /* SYSFS_LED_REDGREEN_H_ */
|