diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2021-10-12 03:12:17 +0300 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2021-10-18 16:28:16 +0300 |
commit | 4a0d5d5c7b0ce18d44f259db8c5ecf27919e85c7 (patch) | |
tree | 186b1b2d00f1995e9c2c1a650e26eb4c2c6f6655 /tests/i915/kms_frontbuffer_tracking.c | |
parent | 9db2886c2111eae9591fbff62ac12e13cbaf9941 (diff) |
lib/kms: Have igt_std_1024_mode_get() return a copy of the mode
We want to provide override modes with different refresh rates.
Start by making igt_std_1024_mode_get() return a copy rather
than a pointer to the static const mode directly. And sprinkle
the necessary free() calls, and some igt_memdups() into parallel
codepaths, so we are consistnetly allocating and freeing everything.
Reviewed-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'tests/i915/kms_frontbuffer_tracking.c')
-rw-r--r-- | tests/i915/kms_frontbuffer_tracking.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/tests/i915/kms_frontbuffer_tracking.c b/tests/i915/kms_frontbuffer_tracking.c index d8f08c14..007bbdeb 100644 --- a/tests/i915/kms_frontbuffer_tracking.c +++ b/tests/i915/kms_frontbuffer_tracking.c @@ -306,51 +306,49 @@ struct { .stop = true, }; -static const drmModeModeInfo *get_connector_smallest_mode(igt_output_t *output) +static drmModeModeInfo *get_connector_smallest_mode(igt_output_t *output) { drmModeConnector *c = output->config.connector; const drmModeModeInfo *smallest = NULL; int i; - for (i = 0; i < c->count_modes; i++) { - drmModeModeInfo *mode = &c->modes[i]; + if (c->connector_type == DRM_MODE_CONNECTOR_eDP) + return igt_std_1024_mode_get(); - if (!smallest) - smallest = mode; + for (i = 0; i < c->count_modes; i++) { + const drmModeModeInfo *mode = &c->modes[i]; - if (mode->hdisplay * mode->vdisplay < + if (!smallest || + mode->hdisplay * mode->vdisplay < smallest->hdisplay * smallest->vdisplay) smallest = mode; } - if (c->connector_type == DRM_MODE_CONNECTOR_eDP) - smallest = igt_std_1024_mode_get(); - - return smallest; + if (smallest) + return igt_memdup(smallest, sizeof(*smallest)); + else + return igt_std_1024_mode_get(); } -static const drmModeModeInfo *connector_get_mode(igt_output_t *output) +static drmModeModeInfo *connector_get_mode(igt_output_t *output) { - const drmModeModeInfo *mode = NULL; - - if (opt.small_modes) - mode = get_connector_smallest_mode(output); - else - mode = &output->config.default_mode; - - /* On HSW the CRC WA is so awful that it makes you think everything is + /* On HSW the CRC WA is so awful that it makes you think everything is * bugged. */ if (IS_HASWELL(intel_get_drm_devid(drm.fd)) && output->config.connector->connector_type == DRM_MODE_CONNECTOR_eDP) - mode = igt_std_1024_mode_get(); + return igt_std_1024_mode_get(); - return mode; + if (opt.small_modes) + return get_connector_smallest_mode(output); + else + return igt_memdup(&output->config.default_mode, + sizeof(output->config.default_mode)); } static void init_mode_params(struct modeset_params *params, igt_output_t *output, enum pipe pipe) { - const drmModeModeInfo *mode; + drmModeModeInfo *mode; igt_output_override_mode(output, NULL); mode = connector_get_mode(output); @@ -380,6 +378,8 @@ static void init_mode_params(struct modeset_params *params, params->sprite.y = 0; params->sprite.w = 64; params->sprite.h = 64; + + free(mode); } static bool find_connector(bool edp_only, bool pipe_a, |