In some cases, we just need one valid output to perform a test. This macro can help in these situations by avoiding iterating over all the outputs. Suggested-by: Matt Roper <matthew.d.roper@xxxxxxxxx> CC: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> CC: Matt Roper <matthew.d.roper@xxxxxxxxx> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@xxxxxxxxx> --- lib/igt_kms.h | 5 +++++ tests/kms_rotation_crc.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 09c08aa..6847beb 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -278,6 +278,11 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe); for (int i__ = 0; (plane) = &(display)->pipes[(pipe)].planes[i__], \ i__ < (display)->pipes[(pipe)].n_planes; i__++) +#define get_first_connected_output(display, output) \ + for (int i__ = 0; i__ < (display)->n_outputs; i__++) \ + if ((output = &(display)->outputs[i__]), output->valid) \ + break + /* * Can be used with igt_output_set_pipe() to mean we don't care about the pipe * that should drive this output diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c index 31cece2..3f0a3ef 100644 --- a/tests/kms_rotation_crc.c +++ b/tests/kms_rotation_crc.c @@ -272,14 +272,15 @@ static void test_plane_rotation_ytiled_obj(data_t *data, enum igt_plane plane_ty int bpp = igt_drm_format_to_bpp(format); enum igt_commit_style commit = COMMIT_LEGACY; int fd = data->gfx_fd; - igt_output_t *output = &display->outputs[0]; + igt_output_t *output = NULL; igt_plane_t *plane; drmModeModeInfo *mode; unsigned int stride, size, w, h; uint32_t gem_handle; int ret; - igt_require(output != NULL && output->valid == true); + get_first_connected_output(display, output); + igt_require(output != NULL); plane = igt_output_get_plane(output, plane_type); igt_require(igt_plane_supports_rotation(plane)); -- 2.4.3 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx