diff -Nru powerdebug-0.6.2-2013.02/.gitignore powerdebug-0.7.0-2013.08/.gitignore --- powerdebug-0.6.2-2013.02/.gitignore 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -# -# NOTE! Don't add files that are generated in specific -# subdirectories here. Add them in the ".gitignore" file -# in that subdirectory instead. -# -# NOTE! Please use 'git ls-files -i --exclude-standard' -# command after changing this file, to see if there are -# any tracked files which get ignored after the change. -# -# Normal rules -# -.* -*.o -*.o.* -*.a -*.s -*.patch - -# -# Top-level generic files -# -/tags -/TAGS - -# -# git files that we don't want to ignore even it they are dot-files -# -!.gitignore - -# quilt's files -patches -series - -# cscope files -cscope.* -ncscope.* - -# gnu global files -GPATH -GRTAGS -GSYMS -GTAGS - -*.orig -*~ -\#*# diff -Nru powerdebug-0.6.2-2013.02/Android.mk powerdebug-0.7.0-2013.08/Android.mk --- powerdebug-0.6.2-2013.02/Android.mk 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/Android.mk 2013-08-14 10:06:08.000000000 +0000 @@ -29,6 +29,6 @@ LOCAL_SRC_FILES += \ powerdebug.c sensor.c clocks.c regulator.c \ - display.c tree.c utils.c mainloop.c + display.c tree.c utils.c mainloop.c gpio.c include $(BUILD_EXECUTABLE) diff -Nru powerdebug-0.6.2-2013.02/README powerdebug-0.7.0-2013.08/README --- powerdebug-0.6.2-2013.02/README 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/README 2013-08-14 10:06:08.000000000 +0000 @@ -7,4 +7,10 @@ Current version only displays regulator information and clock tree from debugfs. Support will be added for sensors later. - -- Amit Arora Fri, 08 Sep 2010 + -- Amit Arora Fri, 08 Sep 2010 + +Now we add gpio-change function for power consumption need. +When gpio is not in interrupt mode. use 'D' key to change gpio direction. +And when gpio direction is "out", use 'V' key to change gpio value. + + -- Shaojie Sun Mon, 29 Jul 2013 diff -Nru powerdebug-0.6.2-2013.02/debian/changelog powerdebug-0.7.0-2013.08/debian/changelog --- powerdebug-0.6.2-2013.02/debian/changelog 2013-02-18 08:35:11.000000000 +0000 +++ powerdebug-0.7.0-2013.08/debian/changelog 2013-09-04 10:38:21.000000000 +0000 @@ -1,7 +1,14 @@ +powerdebug (0.7.0-2013.08-1) unstable; urgency=low + + * New upstream release. + * Remove Marcin from Uploaders. + + -- Fathi Boudra Wed, 04 Sep 2013 13:37:18 +0300 + powerdebug (0.6.2-2013.02-1) unstable; urgency=low * New upstream release. - * Add ùyself to Uploaders. + * Add myself to Uploaders. -- Fathi Boudra Mon, 18 Feb 2013 09:27:36 +0200 diff -Nru powerdebug-0.6.2-2013.02/debian/control powerdebug-0.7.0-2013.08/debian/control --- powerdebug-0.6.2-2013.02/debian/control 2013-02-18 08:34:55.000000000 +0000 +++ powerdebug-0.7.0-2013.08/debian/control 2013-09-04 10:42:05.000000000 +0000 @@ -2,10 +2,10 @@ Section: utils Priority: optional Maintainer: Linaro Packagers -Uploaders: Marcin Juszkiewicz , Fathi Boudra +Uploaders: Fathi Boudra Build-Depends: debhelper (>= 8), libncurses5-dev Vcs-Git: git://git.linaro.org/tools/powerdebug.git -Standards-Version: 3.9.3 +Standards-Version: 3.9.4 Package: powerdebug Architecture: any diff -Nru powerdebug-0.6.2-2013.02/display.c powerdebug-0.7.0-2013.08/display.c --- powerdebug-0.6.2-2013.02/display.c 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/display.c 2013-08-14 10:06:08.000000000 +0000 @@ -137,6 +137,11 @@ 0, 2, 0, maxy - 2, maxx); } +void sigwinch_handler(int signo) +{ + display_refresh(current_win, true); +} + static int display_show_unselection(int win, int line, bool bold) { if (mvwchgat(windata[win].pad, line, 0, -1, @@ -159,6 +164,17 @@ return 0; } +static int display_change(int keyvalue) +{ + if (!(windata[current_win].nrdata)) + return 0; + + if (windata[current_win].ops && windata[current_win].ops->change) + return windata[current_win].ops->change(keyvalue); + + return 0; +} + static int display_next_panel(void) { size_t array_size = sizeof(windata) / sizeof(windata[0]); @@ -396,10 +412,18 @@ display_prev_line(); break; + case '\n': case '\r': display_select(); break; + case 'v': + case 'V': + case 'd': + case 'D': + display_change(toupper(keystroke)); + break; + case EOF: case 'q': case 'Q': @@ -469,6 +493,7 @@ break; + case '\n': case '\r': if (!windata[current_win].ops || !windata[current_win].ops->selectf) return 0; @@ -593,8 +618,10 @@ { size_t array_size = sizeof(windata) / sizeof(windata[0]); - if (win < 0 || win >= array_size) + if (win < 0 || win >= array_size) { + printf("error: invalid window"); return -1; + } windata[win].ops = ops; diff -Nru powerdebug-0.6.2-2013.02/display.h powerdebug-0.7.0-2013.08/display.h --- powerdebug-0.6.2-2013.02/display.h 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/display.h 2013-08-14 10:06:08.000000000 +0000 @@ -20,6 +20,7 @@ int (*select)(void); int (*find)(const char *); int (*selectf)(void); + int (*change)(int keyvalue); }; extern int display_print_line(int window, int line, char *str, diff -Nru powerdebug-0.6.2-2013.02/gpio.c powerdebug-0.7.0-2013.08/gpio.c --- powerdebug-0.6.2-2013.02/gpio.c 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/gpio.c 2013-08-14 10:06:08.000000000 +0000 @@ -33,12 +33,14 @@ #define SYSFS_GPIO "/sys/class/gpio" +#define MAX_VALUE_BYTE 10 + struct gpio_info { bool expanded; int active_low; int value; - int direction; - int edge; + char direction[MAX_VALUE_BYTE]; + char edge[MAX_VALUE_BYTE]; char *prefix; } *gpios_info; @@ -51,6 +53,8 @@ gi = malloc(sizeof(*gi)); if (gi) { memset(gi, -1, sizeof(*gi)); + memset(gi->direction, 0, MAX_VALUE_BYTE); + memset(gi->edge, 0, MAX_VALUE_BYTE); gi->prefix = NULL; } @@ -89,8 +93,8 @@ file_read_value(t->path, "active_low", "%d", &gpio->active_low); file_read_value(t->path, "value", "%d", &gpio->value); - file_read_value(t->path, "edge", "%d", &gpio->edge); - file_read_value(t->path, "direction", "%d", &gpio->direction); + file_read_value(t->path, "edge", "%8s", &gpio->edge); + file_read_value(t->path, "direction", "%4s", &gpio->direction); return 0; } @@ -150,11 +154,11 @@ if (gpio->value != -1) printf(", value:%d", gpio->value); - if (gpio->edge != -1) - printf(", edge:%d", gpio->edge); + if (gpio->edge[0] != 0) + printf(", edge:%s", gpio->edge); - if (gpio->direction != -1) - printf(", direction:%d", gpio->direction); + if (gpio->direction[0] != 0) + printf(", direction:%s", gpio->direction); printf(" )\n"); @@ -183,7 +187,7 @@ struct gpio_info *gpio = t->private; char *gpioline; - if (asprintf(&gpioline, "%-20s %-10d %-10d %-10d %-10d", t-> name, + if (asprintf(&gpioline, "%-20s %-10d %-10d %-10s %-10s", t->name, gpio->value, gpio->active_low, gpio->edge, gpio->direction) < 0) return NULL; @@ -260,8 +264,53 @@ return gpio_print_info(gpio_tree); } +static int gpio_change(int keyvalue) +{ + struct tree *t = display_get_row_data(GPIO); + struct gpio_info *gpio = t->private; + + if (!t || !gpio) + return -1; + + switch (keyvalue) { + case 'D': + /* Only change direction when gpio interrupt not set.*/ + if (!strstr(gpio->edge, "none")) + return 0; + + if (strstr(gpio->direction, "in")) + strcpy(gpio->direction, "out"); + else if (strstr(gpio->direction, "out")) + strcpy(gpio->direction, "in"); + file_write_value(t->path, "direction", "%s", &gpio->direction); + file_read_value(t->path, "direction", "%s", &gpio->direction); + + break; + + case 'V': + /* Only change value when gpio direction is out. */ + if (!strstr(gpio->edge, "none") + || !strstr(gpio->direction, "out")) + return 0; + + if (gpio->value) + file_write_value(t->path, "direction", "%s", &"low"); + else + file_write_value(t->path, "direction", "%s", &"high"); + file_read_value(t->path, "value", "%d", &gpio->value); + + break; + + default: + return -1; + } + + return 0; +} + static struct display_ops gpio_ops = { .display = gpio_display, + .change = gpio_change, }; /* diff -Nru powerdebug-0.6.2-2013.02/powerdebug.c powerdebug-0.7.0-2013.08/powerdebug.c --- powerdebug-0.6.2-2013.02/powerdebug.c 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/powerdebug.c 2013-08-14 10:06:08.000000000 +0000 @@ -20,6 +20,7 @@ #include #include #include +#include #include "regulator.h" #include "display.h" #include "clocks.h" @@ -28,6 +29,8 @@ #include "mainloop.h" #include "powerdebug.h" +extern void sigwinch_handler(int); + void usage(void) { printf("Usage: powerdebug [OPTIONS]\n"); @@ -207,6 +210,7 @@ return NULL; memset(options, 0, sizeof(*options)); + signal(SIGWINCH, sigwinch_handler); return options; } @@ -216,6 +220,16 @@ struct powerdebug_options *options; int ret; +#ifdef __ANDROID__ + if (setenv("TERM", "xterm", 1) < 0) { + fprintf(stderr, "setenv failure"); + return 1; + } + if (setenv("TERMINFO", "/system/etc/terminfo", 1) < 0) { + fprintf(stderr, "setenv failure"); + return 1; + } +#endif options = powerdebug_init(); if (!options) { fprintf(stderr, "not enough memory to allocate options\n"); @@ -233,7 +247,7 @@ } if (regulator_init()) { - printf("not enough memory to allocate regulators info\n"); + printf("failed to initialize regulator\n"); options->regulators = false; } diff -Nru powerdebug-0.6.2-2013.02/powerdebug.h powerdebug-0.7.0-2013.08/powerdebug.h --- powerdebug-0.6.2-2013.02/powerdebug.h 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/powerdebug.h 2013-08-14 10:43:05.000000000 +0000 @@ -13,4 +13,4 @@ * - initial API and implementation *******************************************************************************/ -#define VERSION "0.6.2" +#define VERSION "0.7.0" diff -Nru powerdebug-0.6.2-2013.02/regulator.c powerdebug-0.7.0-2013.08/regulator.c --- powerdebug-0.6.2-2013.02/regulator.c 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/regulator.c 2013-08-14 10:06:08.000000000 +0000 @@ -90,13 +90,17 @@ printf("\n%s:\n", tree->name); for (i = 0; i < nregdata; i++) { + int val; if (file_read_value(tree->path, regdata[i].name, regdata[i].ifmt, buffer)) continue; - printf(regdata[i].ofmt, regdata[i].derefme ? - *((int *)buffer) : buffer); + if (regdata[i].derefme) { + val = atoi(buffer); + printf(regdata[i].ofmt, val); + } else + printf(regdata[i].ofmt, buffer); } return 0; @@ -214,8 +218,10 @@ struct regulator_info *reg; reg = regulator_alloc(); - if (!reg) + if (!reg) { + printf("error: unable to allocate memory for regulator\n"); return -1; + } t->private = reg; /* we skip the root node but we set it expanded for its children */ diff -Nru powerdebug-0.6.2-2013.02/tree.c powerdebug-0.7.0-2013.08/tree.c --- powerdebug-0.6.2-2013.02/tree.c 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/tree.c 2013-08-14 10:06:08.000000000 +0000 @@ -121,8 +121,10 @@ int ret = 0; dir = opendir(tree->path); - if (!dir) + if (!dir) { + printf("error: unable to open directory %s\n", tree->path); return -1; + } while (!readdir_r(dir, &dirent, &direntp)) { diff -Nru powerdebug-0.6.2-2013.02/utils.c powerdebug-0.7.0-2013.08/utils.c --- powerdebug-0.6.2-2013.02/utils.c 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/utils.c 2013-08-14 10:06:08.000000000 +0000 @@ -53,3 +53,39 @@ free(rpath); return ret; } + +/* + * This functions is a helper to write a specific file content and store + * the content inside a variable pointer passed as parameter, the format + * parameter gives the variable type to be write to the file. + * + * @path : directory path containing the file + * @name : name of the file to be read + * @format : the format of the format + * @value : a pointer to a variable to store the content of the file + * Returns 0 on success, -1 otherwise + */ +int file_write_value(const char *path, const char *name, + const char *format, void *value) +{ + FILE *file; + char *rpath; + int ret; + + ret = asprintf(&rpath, "%s/%s", path, name); + if (ret < 0) + return ret; + + file = fopen(rpath, "w"); + if (!file) { + ret = -1; + goto out_free; + } + + ret = fprintf(file, format, value) < 0 ? -1 : 0; + + fclose(file); +out_free: + free(rpath); + return ret; +} diff -Nru powerdebug-0.6.2-2013.02/utils.h powerdebug-0.7.0-2013.08/utils.h --- powerdebug-0.6.2-2013.02/utils.h 2013-02-15 06:23:10.000000000 +0000 +++ powerdebug-0.7.0-2013.08/utils.h 2013-08-14 10:06:08.000000000 +0000 @@ -17,6 +17,8 @@ extern int file_read_value(const char *path, const char *name, const char *format, void *value); +extern int file_write_value(const char *path, const char *name, + const char *format, void *value); #endif