Re: [igt-dev] [PATCH i-g-t 1/3] tests/kms_getfb: Split property-ID get into helper

2018-03-23 Thread Daniel Stone
On 23 March 2018 at 14:53, Ville Syrjälä  wrote:
> On Fri, Mar 23, 2018 at 01:46:14PM +, Daniel Stone wrote:
>> +/**
>> + * Find and return an arbitrary valid property ID.
>> + */
>> +static uint32_t get_prop_id(int fd)
>
> get_any_prop_id() or something like that maybe?

Yeah, a good choice of colour. :)

Cheers,
Daniel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH i-g-t 1/3] tests/kms_getfb: Split property-ID get into helper

2018-03-23 Thread Ville Syrjälä
On Fri, Mar 23, 2018 at 01:46:14PM +, Daniel Stone wrote:
> We'll want to reuse this, so split it out into a (smaller!) helper.
> 
> Signed-off-by: Daniel Stone 
> ---
>  tests/kms_getfb.c | 36 +++-
>  1 file changed, 19 insertions(+), 17 deletions(-)
> 
> diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
> index c5968e75..a9852626 100644
> --- a/tests/kms_getfb.c
> +++ b/tests/kms_getfb.c
> @@ -72,6 +72,23 @@ static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 
> *ret)
>   gem_close(fd, add.handles[0]);
>  }
>  
> +/**
> + * Find and return an arbitrary valid property ID.
> + */
> +static uint32_t get_prop_id(int fd)

get_any_prop_id() or something like that maybe?

Either way
Reviewed-by: Ville Syrjälä 

> +{
> + igt_display_t display;
> +
> + igt_display_init(, fd);
> + for (int i = 0; i < display.n_outputs; i++) {
> + igt_output_t *output = [i];
> + if (output->props[IGT_CONNECTOR_DPMS] != 0)
> + return output->props[IGT_CONNECTOR_DPMS];
> + }
> +
> + return 0;
> +}
> +
>  static void test_handle_input(int fd)
>  {
>   struct drm_mode_fb_cmd2 add = {};
> @@ -111,23 +128,8 @@ static void test_handle_input(int fd)
>   }
>  
>   igt_subtest("getfb-handle-not-fb") {
> - struct drm_mode_fb_cmd get = { };
> - uint32_t prop_id = 0;
> - igt_display_t display;
> -
> - /* Find a valid property ID to use. */
> - igt_display_init(, fd);
> - for (int i = 0; i < display.n_outputs; i++) {
> - igt_output_t *output = [i];
> -
> - if (output->props[IGT_CONNECTOR_DPMS] != 0) {
> - prop_id = output->props[IGT_CONNECTOR_DPMS];
> - break;
> - }
> - }
> - igt_require(prop_id > 0);
> -
> - get.fb_id = prop_id;
> + struct drm_mode_fb_cmd get = { .fb_id = get_prop_id(fd) };
> + igt_require(get.fb_id > 0);
>   do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB, , ENOENT);
>   }
>  }
> -- 
> 2.16.2
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH i-g-t 1/3] tests/kms_getfb: Split property-ID get into helper

2018-03-23 Thread Daniel Stone
We'll want to reuse this, so split it out into a (smaller!) helper.

Signed-off-by: Daniel Stone 
---
 tests/kms_getfb.c | 36 +++-
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
index c5968e75..a9852626 100644
--- a/tests/kms_getfb.c
+++ b/tests/kms_getfb.c
@@ -72,6 +72,23 @@ static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret)
gem_close(fd, add.handles[0]);
 }
 
+/**
+ * Find and return an arbitrary valid property ID.
+ */
+static uint32_t get_prop_id(int fd)
+{
+   igt_display_t display;
+
+   igt_display_init(, fd);
+   for (int i = 0; i < display.n_outputs; i++) {
+   igt_output_t *output = [i];
+   if (output->props[IGT_CONNECTOR_DPMS] != 0)
+   return output->props[IGT_CONNECTOR_DPMS];
+   }
+
+   return 0;
+}
+
 static void test_handle_input(int fd)
 {
struct drm_mode_fb_cmd2 add = {};
@@ -111,23 +128,8 @@ static void test_handle_input(int fd)
}
 
igt_subtest("getfb-handle-not-fb") {
-   struct drm_mode_fb_cmd get = { };
-   uint32_t prop_id = 0;
-   igt_display_t display;
-
-   /* Find a valid property ID to use. */
-   igt_display_init(, fd);
-   for (int i = 0; i < display.n_outputs; i++) {
-   igt_output_t *output = [i];
-
-   if (output->props[IGT_CONNECTOR_DPMS] != 0) {
-   prop_id = output->props[IGT_CONNECTOR_DPMS];
-   break;
-   }
-   }
-   igt_require(prop_id > 0);
-
-   get.fb_id = prop_id;
+   struct drm_mode_fb_cmd get = { .fb_id = get_prop_id(fd) };
+   igt_require(get.fb_id > 0);
do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB, , ENOENT);
}
 }
-- 
2.16.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel