diff mbox

lib/igt_kms: Introduce get_first_connected_output to retrieve a valid output

Message ID 1446084594-2976-1-git-send-email-vivek.kasireddy@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vivek Kasireddy Oct. 29, 2015, 2:09 a.m. UTC
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@intel.com>
CC: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
CC: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
 lib/igt_kms.h            | 5 +++++
 tests/kms_rotation_crc.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Thomas Wood Oct. 29, 2015, 11:05 a.m. UTC | #1
On 29 October 2015 at 02:09, Vivek Kasireddy <vivek.kasireddy@intel.com> wrote:
> 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@intel.com>
> CC: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> CC: Matt Roper <matthew.d.roper@intel.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> ---
>  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__++)
>


Please add some API documentation here.

> +#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@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

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));