modetest: custom mode support

It is useful to be able to specify mode parameters manually. Add support
for setting user-supplied modes. This patch is based on the original
idea by Rohit and Jessica, but implemented from scratch.

Suggested-by: Rohith Iyer <quic_rohiiyer@quicinc.com>
Suggested-by: Jessica Zhang <quic_jesszhan@quicinc.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
main
Dmitry Baryshkov 2023-07-30 18:33:28 +03:00 committed by Dmitry Baryshkov
parent 4d3635fada
commit 45f3d9bab6
2 changed files with 22 additions and 1 deletions

View File

@ -25,5 +25,6 @@ modetest = executable(
include_directories : [inc_root, inc_tests, inc_drm], include_directories : [inc_root, inc_tests, inc_drm],
dependencies : [dep_threads, dep_cairo], dependencies : [dep_threads, dep_cairo],
link_with : [libdrm, libutil], link_with : [libdrm, libutil],
link_args: '-lm',
install : with_install_tests, install : with_install_tests,
) )

View File

@ -70,6 +70,7 @@
static enum util_fill_pattern primary_fill = UTIL_PATTERN_SMPTE; static enum util_fill_pattern primary_fill = UTIL_PATTERN_SMPTE;
static enum util_fill_pattern secondary_fill = UTIL_PATTERN_TILES; static enum util_fill_pattern secondary_fill = UTIL_PATTERN_TILES;
static drmModeModeInfo user_mode;
struct crtc { struct crtc {
drmModeCrtc *crtc; drmModeCrtc *crtc;
@ -853,7 +854,25 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str,
int i; int i;
connector = get_connector_by_id(dev, con_id); connector = get_connector_by_id(dev, con_id);
if (!connector || !connector->count_modes) if (!connector)
return NULL;
if (strchr(mode_str, ',')) {
i = sscanf(mode_str, "%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu",
&user_mode.hdisplay, &user_mode.hsync_start,
&user_mode.hsync_end, &user_mode.htotal,
&user_mode.vdisplay, &user_mode.vsync_start,
&user_mode.vsync_end, &user_mode.vtotal);
if (i == 8) {
user_mode.clock = roundf(user_mode.htotal * user_mode.vtotal * vrefresh / 1000);
user_mode.vrefresh = roundf(vrefresh);
snprintf(user_mode.name, sizeof(user_mode.name), "custom%dx%d", user_mode.hdisplay, user_mode.vdisplay);
return &user_mode;
}
}
if (!connector->count_modes)
return NULL; return NULL;
/* Pick by Index */ /* Pick by Index */
@ -2103,6 +2122,7 @@ static void usage(char *name)
fprintf(stderr, "\n Test options:\n\n"); fprintf(stderr, "\n Test options:\n\n");
fprintf(stderr, "\t-P <plane_id>@<crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n"); fprintf(stderr, "\t-P <plane_id>@<crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n");
fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:[#<mode index>]<mode>[-<vrefresh>][@<format>]\tset a mode\n"); fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:[#<mode index>]<mode>[-<vrefresh>][@<format>]\tset a mode\n");
fprintf(stderr, "\t\tcustom mode can be specified as <hdisplay>,<hsyncstart>,<hsyncend>,<htotal>,<vdisplay>,<vsyncstart>,<vsyncend>,<vtotal>\n");
fprintf(stderr, "\t-C\ttest hw cursor\n"); fprintf(stderr, "\t-C\ttest hw cursor\n");
fprintf(stderr, "\t-v\ttest vsynced page flipping\n"); fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
fprintf(stderr, "\t-r\tset the preferred mode for all connectors\n"); fprintf(stderr, "\t-r\tset the preferred mode for all connectors\n");