xref: /openbmc/linux/tools/perf/ui/setup.c (revision 9d749629)
1 #include <pthread.h>
2 
3 #include "../util/cache.h"
4 #include "../util/debug.h"
5 #include "../util/hist.h"
6 
7 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
8 
9 void setup_browser(bool fallback_to_pager)
10 {
11 	if (use_browser < 2 && (!isatty(1) || dump_trace))
12 		use_browser = 0;
13 
14 	/* default to TUI */
15 	if (use_browser < 0)
16 		use_browser = 1;
17 
18 	switch (use_browser) {
19 	case 2:
20 		if (perf_gtk__init() == 0)
21 			break;
22 		/* fall through */
23 	case 1:
24 		use_browser = 1;
25 		if (ui__init() == 0)
26 			break;
27 		/* fall through */
28 	default:
29 		use_browser = 0;
30 		if (fallback_to_pager)
31 			setup_pager();
32 
33 		perf_hpp__column_enable(PERF_HPP__OVERHEAD);
34 		perf_hpp__init();
35 		break;
36 	}
37 }
38 
39 void exit_browser(bool wait_for_ok)
40 {
41 	switch (use_browser) {
42 	case 2:
43 		perf_gtk__exit(wait_for_ok);
44 		break;
45 
46 	case 1:
47 		ui__exit(wait_for_ok);
48 		break;
49 
50 	default:
51 		break;
52 	}
53 }
54