aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/thermal/tmon/tui.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/thermal/tmon/tui.c b/tools/thermal/tmon/tui.c
index 2779573a53cb..36e1f86c8452 100644
--- a/tools/thermal/tmon/tui.c
+++ b/tools/thermal/tmon/tui.c
@@ -110,6 +110,18 @@ void write_status_bar(int x, char *line)
110 wrefresh(status_bar_window); 110 wrefresh(status_bar_window);
111} 111}
112 112
113/* wrap at 5 */
114#define DIAG_DEV_ROWS 5
115/*
116 * list cooling devices + "set temp" entry; wraps after 5 rows, if they fit
117 */
118static int diag_dev_rows(void)
119{
120 int entries = ptdata.nr_cooling_dev + 1;
121 int rows = max(DIAG_DEV_ROWS, (entries + 1) / 2);
122 return min(rows, entries);
123}
124
113void setup_windows(void) 125void setup_windows(void)
114{ 126{
115 int y_begin = 1; 127 int y_begin = 1;
@@ -134,7 +146,7 @@ void setup_windows(void)
134 * dialogue window is a pop-up, when needed it lays on top of cdev win 146 * dialogue window is a pop-up, when needed it lays on top of cdev win
135 */ 147 */
136 148
137 dialogue_window = subwin(stdscr, ptdata.nr_cooling_dev+5, maxx-50, 149 dialogue_window = subwin(stdscr, diag_dev_rows() + 5, maxx-50,
138 DIAG_Y, DIAG_X); 150 DIAG_Y, DIAG_X);
139 151
140 thermal_data_window = subwin(stdscr, ptdata.nr_tz_sensor * 152 thermal_data_window = subwin(stdscr, ptdata.nr_tz_sensor *
@@ -270,7 +282,6 @@ void show_cooling_device(void)
270} 282}
271 283
272const char DIAG_TITLE[] = "[ TUNABLES ]"; 284const char DIAG_TITLE[] = "[ TUNABLES ]";
273#define DIAG_DEV_ROWS 5
274void show_dialogue(void) 285void show_dialogue(void)
275{ 286{
276 int j, x = 0, y = 0; 287 int j, x = 0, y = 0;
@@ -287,7 +298,7 @@ void show_dialogue(void)
287 mvwprintw(w, 0, maxx/4, DIAG_TITLE); 298 mvwprintw(w, 0, maxx/4, DIAG_TITLE);
288 /* list all the available tunables */ 299 /* list all the available tunables */
289 for (j = 0; j <= ptdata.nr_cooling_dev; j++) { 300 for (j = 0; j <= ptdata.nr_cooling_dev; j++) {
290 y = j % DIAG_DEV_ROWS; 301 y = j % diag_dev_rows();
291 if (y == 0 && j != 0) 302 if (y == 0 && j != 0)
292 x += 20; 303 x += 20;
293 if (j == ptdata.nr_cooling_dev) 304 if (j == ptdata.nr_cooling_dev)
@@ -298,7 +309,7 @@ void show_dialogue(void)
298 ptdata.cdi[j].type, ptdata.cdi[j].instance); 309 ptdata.cdi[j].type, ptdata.cdi[j].instance);
299 } 310 }
300 wattron(w, A_BOLD); 311 wattron(w, A_BOLD);
301 mvwprintw(w, DIAG_DEV_ROWS+1, 1, "Enter Choice [A-Z]?"); 312 mvwprintw(w, diag_dev_rows()+1, 1, "Enter Choice [A-Z]?");
302 wattroff(w, A_BOLD); 313 wattroff(w, A_BOLD);
303 /* print legend at the bottom line */ 314 /* print legend at the bottom line */
304 mvwprintw(w, rows - 2, 1, 315 mvwprintw(w, rows - 2, 1,
@@ -450,7 +461,7 @@ static void handle_input_choice(int ch)
450 snprintf(buf, sizeof(buf), "New Value for %.10s-%2d: ", 461 snprintf(buf, sizeof(buf), "New Value for %.10s-%2d: ",
451 ptdata.cdi[cdev_id].type, 462 ptdata.cdi[cdev_id].type,
452 ptdata.cdi[cdev_id].instance); 463 ptdata.cdi[cdev_id].instance);
453 write_dialogue_win(buf, DIAG_DEV_ROWS+2, 2); 464 write_dialogue_win(buf, diag_dev_rows() + 2, 2);
454 handle_input_val(cdev_id); 465 handle_input_val(cdev_id);
455 } else { 466 } else {
456 snprintf(buf, sizeof(buf), "Invalid selection %d", ch); 467 snprintf(buf, sizeof(buf), "Invalid selection %d", ch);