[FEATURE] energy: add support lcd maru
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 17 Oct 2013 18:44:05 +0000 (22:44 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 17 Oct 2013 18:48:54 +0000 (22:48 +0400)
Change-Id: I35c793c841a675eb31c9aa503a76eabf0dd79e46
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
energy/Kbuild
energy/lcd/maru.c [new file with mode: 0644]

index 112ab66..a10d1a9 100644 (file)
@@ -6,7 +6,16 @@ swap_energy-y := energy_module.o \
                  debugfs_energy.o \
                  lcd/lcd_base.o
 
+
+# S6E8AA0:
 ifeq ($(CONFIG_LCD_S6E8AA0), y)
        swap_energy-y += lcd/s6e8aa0.o
        EXTRA_CFLAGS += -DCONFIG_ENEGRGY_LCD
 endif
+
+
+# MARU:
+ifeq ($(CONFIG_MARU_BACKLIGHT), y)
+       swap_energy-y += lcd/maru.o
+       EXTRA_CFLAGS += -DCONFIG_ENEGRGY_LCD
+endif
diff --git a/energy/lcd/maru.c b/energy/lcd/maru.c
new file mode 100644 (file)
index 0000000..03dbe08
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ *  Dynamic Binary Instrumentation Module based on KProbes
+ *  energy/lcd/maru.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2013
+ *
+ * 2013         Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <kprobe/dbi_kprobes.h>
+#include <linux/backlight.h>
+#include "lcd_base.h"
+
+static struct lcd_ops_set *ops_s = NULL;
+
+
+
+
+
+/* ============================================================================
+ * ===                               POWER                                  ===
+ * ============================================================================
+ */
+static int get_power(void)
+{
+       /* in drivers/maru/maru_lcd.c value 'lcd_power' constant and zero */
+       return 0;
+}
+
+
+
+
+
+/* ============================================================================
+ * ===                              BACKLIGHT                               ===
+ * ============================================================================
+ */
+static int get_backlight(void)
+{
+       const char *backlight_path = "/sys/class/backlight/emulator/brightness";
+
+       return read_val(backlight_path);
+}
+
+static int entry_handler_set_backlight(struct kretprobe_instance *ri,
+                                      struct pt_regs *regs)
+{
+       int *brightness = (int *)ri->data;
+       struct backlight_device *bd = (struct backlight_device *)regs->ax;
+       *brightness = bd->props.brightness;
+
+       return 0;
+}
+
+static int ret_handler_set_backlight(struct kretprobe_instance *ri,
+                                    struct pt_regs *regs)
+{
+       int ret = regs_return_value(regs);
+       int *brightness = (int *)ri->data;
+
+       if (!ret && ops_s && ops_s->set_backlight)
+               ops_s->set_backlight(*brightness);
+
+       return 0;
+}
+
+static struct kretprobe set_backlight_krp = {
+       .kp.symbol_name = "marubl_send_intensity",
+       .entry_handler = entry_handler_set_backlight,
+       .handler = ret_handler_set_backlight,
+       .data_size = sizeof(int)
+};
+
+
+
+
+
+/* ============================================================================
+ * ===                              INIT/EXIT                               ===
+ * ============================================================================
+ */
+int lcd_mach_init(struct lcd_ops_set *ops_set, struct lcd_ops_get *ops_get)
+{
+       int ret = 0;
+
+       ret = dbi_register_kretprobe(&set_backlight_krp);
+       if (ret)
+               return ret;
+
+       ops_s = ops_set;
+       ops_get->get_power = get_power;
+       ops_get->get_backlight = get_backlight;
+
+       return ret;
+}
+
+void lcd_mach_exit(void)
+{
+       dbi_unregister_kretprobe(&set_backlight_krp);
+       ops_s = NULL;
+}