aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Arora <amit.arora@linaro.org>2010-12-01 13:51:42 +0530
committerAmit Arora <amit.arora@linaro.org>2010-12-01 13:51:42 +0530
commit3bd7916532336cb9d2c8b1fa0cff6fb650936141 (patch)
tree0740fc3f716586fa0d226e5ca4851dba88d3ee09
parentf4fb810d919be557220c48b3dfa7a1f5a0e7a8b4 (diff)
downloadpowerdebug-3bd7916532336cb9d2c8b1fa0cff6fb650936141.tar.gz
Show parents for a given clock in ncurses mode too
-rw-r--r--clocks.c51
-rw-r--r--powerdebug.c58
-rw-r--r--powerdebug.h1
3 files changed, 90 insertions, 20 deletions
diff --git a/clocks.c b/clocks.c
index 5cdc8d5..81da6c3 100644
--- a/clocks.c
+++ b/clocks.c
@@ -81,8 +81,27 @@ int get_int_from(char *file)
return atoi(result);
}
+void find_parents_for_clock(char *clkname, int complete)
+{
+ char name[256];
+
+ name[0] = '\0';
+ if (!complete) {
+ char str[256];
+
+ strcat(name, clkname);
+ sprintf(str, "Enter Clock Name : %s\n", name);
+ print_one_clock(2, str, 1, 0);
+ return;
+ }
+ sprintf(name, "Parents for \"%s\" Clock : \n", clkname);
+ print_one_clock(0, name, 1, 1);
+ dump_all_parents(clkname);
+}
+
int read_and_print_clock_info(int verbose, int hrow, int selected)
{
+ print_one_clock(0, "Reading Clock Tree ...", 1, 1);
if (!old_clock_line_no)
read_clock_info(clk_dir_path);
@@ -234,8 +253,7 @@ void destroy_clocks_info_recur(struct clock_info *clock)
void read_and_dump_clock_info_one(char *clk)
{
- printf("Clock Tree : (clock name = %s)\n", clk);
- printf("**********\n");
+ printf("\nParents for \"%s\" Clock :\n\n", clk);
read_clock_info(clk_dir_path);
dump_all_parents(clk);
}
@@ -365,14 +383,19 @@ void insert_children(struct clock_info **parent, struct clock_info *clk)
(*parent)->num_children++;
}
-void dump_parent(struct clock_info *clk)
+void dump_parent(struct clock_info *clk, int line)
{
char *unit = "Hz";
double drate;
- static char spaces[256];
+ static char spaces[64];
+ char str[256];
+ static int maxline;
+
+ if (maxline < line)
+ maxline = line;
if (clk && clk->parent)
- dump_parent(clk->parent);
+ dump_parent(clk->parent, ++line);
drate = (double)clk->rate;
if (drate > 1000 && drate < 1000000) {
@@ -384,15 +407,23 @@ void dump_parent(struct clock_info *clk)
drate /= 1000000;
}
if (clk == clocks_info) {
+ line++;
strcpy(spaces, "");
- printf("%s%s (flags:%d,usecount:%d,rate:%5.2f %s)\n", spaces,
- clk->name, clk->flags, clk->usecount, drate, unit);
+ sprintf(str, "%s%s (flags:%d,usecount:%d,rate:%5.2f %s)\n",
+ spaces, clk->name, clk->flags, clk->usecount, drate,
+ unit);
} else {
if (!(clk->parent == clocks_info))
strcat(spaces, " ");
- printf("%s`- %s (flags:%d,usecount:%d,rate:%5.2f %s)\n", spaces,
- clk->name, clk->flags, clk->usecount, drate, unit);
+ sprintf(str, "%s`- %s (flags:%d,usecount:%d,rate:%5.2f %s)\n",
+ spaces, clk->name, clk->flags, clk->usecount, drate,
+ unit);
}
+ if (dump)
+ //printf("line=%d:m%d:l%d %s", maxline - line + 2, maxline, line, str);
+ printf("%s", str);
+ else
+ print_one_clock(maxline - line + 2, str, 1, 0);
}
void dump_all_parents(char *clkarg)
@@ -414,7 +445,7 @@ void dump_all_parents(char *clkarg)
// printf("%s <-- ", spaces);
// }
// printf(" /\n");
- dump_parent(clk);
+ dump_parent(clk, 1);
}
}
diff --git a/powerdebug.c b/powerdebug.c
index 439f8f2..14748c5 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -216,9 +216,9 @@ int main(int argc, char **argv)
{
int c, i;
int firsttime[TOTAL_FEATURE_WINS];
- int enter_hit = 0, verbose = 0;
+ int enter_hit = 0, verbose = 0, findparent_ncurses = 0;
int regulators = 0, sensors = 0, clocks = 0, findparent = 0;
- char clkarg[64];
+ char clkarg[64], clkname_str[64];
for (i = 0; i < TOTAL_FEATURE_WINS; i++)
firsttime[i] = 1;
@@ -343,16 +343,22 @@ int main(int argc, char **argv)
ret = init_clock_details();
if (!ret)
firsttime[CLOCK] = 0;
+ strcpy(clkname_str, "");
}
if (!ret && !dump) {
int hrow;
create_selectedwindow();
- hrow = read_and_print_clock_info(verbose,
+ if (!findparent_ncurses) {
+ hrow = read_and_print_clock_info(
+ verbose,
highlighted_row,
enter_hit);
- highlighted_row = hrow;
- enter_hit = 0;
+ highlighted_row = hrow;
+ enter_hit = 0;
+ } else
+ find_parents_for_clock(clkname_str,
+ enter_hit);
}
if (!ret && dump) {
if (findparent)
@@ -383,6 +389,7 @@ int main(int argc, char **argv)
if (key) {
char keychar;
int keystroke = getch();
+ int oldselectedwin = selectedwindow;
if (keystroke == EOF)
exit(0);
@@ -404,18 +411,49 @@ int main(int argc, char **argv)
highlighted_row++;
if (keystroke == KEY_UP && highlighted_row > 0)
highlighted_row--;
+ if (keystroke == 47)
+ findparent_ncurses = 1;
+
+ if ((keystroke == 27 || oldselectedwin !=
+ selectedwindow) && findparent_ncurses) {
+ findparent_ncurses = 0;
+ clkname_str[0] = '\0';
+ }
+
+ if (findparent_ncurses && keystroke != 13) {
+ int len = strlen(clkname_str);
+ char str[2];
+
+ if (keystroke == 263) {
+ if (len > 0)
+ len--;
+
+ clkname_str[len] = '\0';
+ } else {
+ if (strlen(clkname_str) ||
+ keystroke != '/') {
+ str[0] = keystroke;
+ str[1] = '\0';
+ if (len < 63)
+ strcat(clkname_str,
+ str);
+ }
+ }
+ }
}
keychar = toupper(keystroke);
-
- //killall_windows(1); fini_curses();
- //printf("key entered %d:%c\n", keystroke, keychar);
- //exit(1);
+//#define DEBUG
+#ifdef DEBUG
+ killall_windows(1); fini_curses();
+ printf("key entered %d:%c\n", keystroke, keychar);
+ exit(1);
+#endif
if (keystroke == 13)
enter_hit = 1;
- if (keychar == 'Q')
+ if (keychar == 'Q' && !findparent_ncurses)
exit(0);
if (keychar == 'R')
ticktime = 3;
diff --git a/powerdebug.h b/powerdebug.h
index d07849d..4799118 100644
--- a/powerdebug.h
+++ b/powerdebug.h
@@ -62,6 +62,7 @@ extern struct clock_info *read_clock_info_recur(char *clkpath, int level,
struct clock_info *parent);
extern void dump_clock_info(struct clock_info *clk, int level, int bmp);
extern void insert_children(struct clock_info **parent, struct clock_info *clk);
+extern void find_parents_for_clock(char *clkname, int complete);
extern int read_and_print_clock_info(int verbose, int hrow, int selected);
extern void print_clock_info(int verbose, int hrow, int selected);
extern void get_sensor_info(char *path, char *name, char *sensor, int verbose);