testdisplay: Untangle dump_info() from the main testing loop

-i is just supposed to show some information about the DRM resources.
Right now it works in a quite convoluted way. Untangle this to call
dump_info() when -i is given, exit the program and be done with it.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
This commit is contained in:
Damien Lespiau 2013-09-05 16:49:11 +01:00
parent b9db1a6a96
commit 66477a230f

View File

@ -53,6 +53,7 @@
#include <errno.h> #include <errno.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <sys/time.h> #include <sys/time.h>
@ -67,8 +68,8 @@
drmModeRes *resources; drmModeRes *resources;
int drm_fd, modes; int drm_fd, modes;
int dump_info = 0, test_all_modes =0, test_preferred_mode = 0, force_mode = 0, int test_all_modes = 0, test_preferred_mode = 0, force_mode = 0, test_plane,
test_plane, enable_tiling; enable_tiling;
int sleep_between_modes = 5; int sleep_between_modes = 5;
uint32_t depth = 24, stride, bpp; uint32_t depth = 24, stride, bpp;
int qr_code = 0; int qr_code = 0;
@ -181,6 +182,12 @@ static void dump_crtcs_fd(int drmfd)
drmModeFreeResources(mode_resources); drmModeFreeResources(mode_resources);
} }
static void dump_info(void)
{
dump_connectors_fd(drm_fd);
dump_crtcs_fd(drm_fd);
}
static void connector_find_preferred_mode(uint32_t connector_id, static void connector_find_preferred_mode(uint32_t connector_id,
unsigned long crtc_idx_mask, unsigned long crtc_idx_mask,
int mode_num, struct connector *c) int mode_num, struct connector *c)
@ -423,11 +430,6 @@ int update_display(void)
if (!connectors) if (!connectors)
return 0; return 0;
if (dump_info) {
dump_connectors_fd(drm_fd);
dump_crtcs_fd(drm_fd);
}
if (test_preferred_mode || test_all_modes || force_mode || specified_disp_id != -1) { if (test_preferred_mode || test_all_modes || force_mode || specified_disp_id != -1) {
unsigned long crtc_idx_mask = -1UL; unsigned long crtc_idx_mask = -1UL;
@ -523,6 +525,7 @@ int main(int argc, char **argv)
GIOChannel *stdinchannel; GIOChannel *stdinchannel;
GMainLoop *mainloop; GMainLoop *mainloop;
float force_clock; float force_clock;
bool opt_dump_info = false;
igt_skip_on_simulation(); igt_skip_on_simulation();
@ -532,7 +535,7 @@ int main(int argc, char **argv)
while ((c = getopt(argc, argv, optstr)) != -1) { while ((c = getopt(argc, argv, optstr)) != -1) {
switch (c) { switch (c) {
case 'i': case 'i':
dump_info = 1; opt_dump_info = true;
break; break;
case 'a': case 'a':
test_all_modes = 1; test_all_modes = 1;
@ -588,12 +591,17 @@ int main(int argc, char **argv)
else if (depth <= 32) else if (depth <= 32)
bpp = 32; bpp = 32;
if (!test_all_modes && !force_mode && !dump_info && if (!test_all_modes && !force_mode && !test_preferred_mode &&
!test_preferred_mode && specified_mode_num == -1) specified_mode_num == -1)
test_all_modes = 1; test_all_modes = 1;
drm_fd = drm_open_any(); drm_fd = drm_open_any();
if (opt_dump_info) {
dump_info();
goto out_close;
}
do_or_die(igt_set_vt_graphics_mode()); do_or_die(igt_set_vt_graphics_mode());
mainloop = g_main_loop_new(NULL, FALSE); mainloop = g_main_loop_new(NULL, FALSE);
@ -628,7 +636,7 @@ int main(int argc, char **argv)
goto out_stdio; goto out_stdio;
} }
if (dump_info || test_all_modes) if (test_all_modes)
goto out_stdio; goto out_stdio;
g_main_loop_run(mainloop); g_main_loop_run(mainloop);