diff mbox

[i-g-t,2/5] lib/igt_kms: Neaten up pipe->planes[] assignment

Message ID 1487354070-14487-2-git-send-email-brian.starkey@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Brian Starkey Feb. 17, 2017, 5:54 p.m. UTC
Remove a bunch of branches, functionally equivalent.

Signed-off-by: Brian Starkey <brian.starkey@arm.com>
---
 lib/igt_kms.c |   34 ++++++++++------------------------
 1 file changed, 10 insertions(+), 24 deletions(-)

Comments

Robert Foss Feb. 19, 2017, 8:41 p.m. UTC | #1
On 2017-02-17 12:54 PM, Brian Starkey wrote:
> Remove a bunch of branches, functionally equivalent.
>
> Signed-off-by: Brian Starkey <brian.starkey@arm.com>
> ---
>  lib/igt_kms.c |   34 ++++++++++------------------------
>  1 file changed, 10 insertions(+), 24 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 4ca9145726e2..783c891aebf1 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -1785,32 +1785,18 @@ void igt_display_init(igt_display_t *display, int drm_fd)
>
>  			type = get_drm_plane_type(display->drm_fd,
>  						  plane_resources->planes[j]);
> -			switch (type) {
> -			case DRM_PLANE_TYPE_PRIMARY:
> -				if (pipe->plane_primary == -1) {
> -					plane = &pipe->planes[0];
> -					plane->index = 0;
> -					pipe->plane_primary = 0;
> -				} else {
> -					plane = &pipe->planes[p];
> -					plane->index = p++;
> -				}
> -				break;
> -			case DRM_PLANE_TYPE_CURSOR:
> -				if (pipe->plane_cursor == -1) {
> -					plane = &pipe->planes[last_plane];
> -					plane->index = last_plane;
> -					pipe->plane_cursor = last_plane;
> -				} else {
> -					plane = &pipe->planes[p];
> -					plane->index = p++;
> -				}
> -				display->has_cursor_plane = true;

The display->has_cursor_plane assignment does not seem to appear in the 
refactored code.

With that fixed this patch is:
Reviewed-by: Robert Foss <robert.foss@collabora.com>


Rob.

> -				break;
> -			default:
> +
> +			if (type == DRM_PLANE_TYPE_PRIMARY && pipe->plane_primary == -1) {
> +				plane = &pipe->planes[0];
> +				plane->index = 0;
> +				pipe->plane_primary = 0;
> +			} else if (type == DRM_PLANE_TYPE_CURSOR && pipe->plane_cursor == -1) {
> +				plane = &pipe->planes[last_plane];
> +				plane->index = last_plane;
> +				pipe->plane_cursor = last_plane;
> +			} else {
>  				plane = &pipe->planes[p];
>  				plane->index = p++;
> -				break;
>  			}
>
>  			igt_assert_f(plane->index < n_planes, "n_planes < plane->index failed\n");
>
Brian Starkey Feb. 20, 2017, 10:17 a.m. UTC | #2
On Sun, Feb 19, 2017 at 03:41:45PM -0500, Robert Foss wrote:
>
>
>On 2017-02-17 12:54 PM, Brian Starkey wrote:
>>Remove a bunch of branches, functionally equivalent.
>>
>>Signed-off-by: Brian Starkey <brian.starkey@arm.com>
>>---
>> lib/igt_kms.c |   34 ++++++++++------------------------
>> 1 file changed, 10 insertions(+), 24 deletions(-)
>>
>>diff --git a/lib/igt_kms.c b/lib/igt_kms.c
>>index 4ca9145726e2..783c891aebf1 100644
>>--- a/lib/igt_kms.c
>>+++ b/lib/igt_kms.c
>>@@ -1785,32 +1785,18 @@ void igt_display_init(igt_display_t *display, int drm_fd)
>>
>> 			type = get_drm_plane_type(display->drm_fd,
>> 						  plane_resources->planes[j]);
>>-			switch (type) {
>>-			case DRM_PLANE_TYPE_PRIMARY:
>>-				if (pipe->plane_primary == -1) {
>>-					plane = &pipe->planes[0];
>>-					plane->index = 0;
>>-					pipe->plane_primary = 0;
>>-				} else {
>>-					plane = &pipe->planes[p];
>>-					plane->index = p++;
>>-				}
>>-				break;
>>-			case DRM_PLANE_TYPE_CURSOR:
>>-				if (pipe->plane_cursor == -1) {
>>-					plane = &pipe->planes[last_plane];
>>-					plane->index = last_plane;
>>-					pipe->plane_cursor = last_plane;
>>-				} else {
>>-					plane = &pipe->planes[p];
>>-					plane->index = p++;
>>-				}
>>-				display->has_cursor_plane = true;
>
>The display->has_cursor_plane assignment does not seem to appear in 
>the refactored code.
>

doh! Thanks for spotting that. I'll fix in v2.

-Brian

>With that fixed this patch is:
>Reviewed-by: Robert Foss <robert.foss@collabora.com>
>
>
>Rob.
>
>>-				break;
>>-			default:
>>+
>>+			if (type == DRM_PLANE_TYPE_PRIMARY && pipe->plane_primary == -1) {
>>+				plane = &pipe->planes[0];
>>+				plane->index = 0;
>>+				pipe->plane_primary = 0;
>>+			} else if (type == DRM_PLANE_TYPE_CURSOR && pipe->plane_cursor == -1) {
>>+				plane = &pipe->planes[last_plane];
>>+				plane->index = last_plane;
>>+				pipe->plane_cursor = last_plane;
>>+			} else {
>> 				plane = &pipe->planes[p];
>> 				plane->index = p++;
>>-				break;
>> 			}
>>
>> 			igt_assert_f(plane->index < n_planes, "n_planes < plane->index failed\n");
>>
diff mbox

Patch

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4ca9145726e2..783c891aebf1 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1785,32 +1785,18 @@  void igt_display_init(igt_display_t *display, int drm_fd)
 
 			type = get_drm_plane_type(display->drm_fd,
 						  plane_resources->planes[j]);
-			switch (type) {
-			case DRM_PLANE_TYPE_PRIMARY:
-				if (pipe->plane_primary == -1) {
-					plane = &pipe->planes[0];
-					plane->index = 0;
-					pipe->plane_primary = 0;
-				} else {
-					plane = &pipe->planes[p];
-					plane->index = p++;
-				}
-				break;
-			case DRM_PLANE_TYPE_CURSOR:
-				if (pipe->plane_cursor == -1) {
-					plane = &pipe->planes[last_plane];
-					plane->index = last_plane;
-					pipe->plane_cursor = last_plane;
-				} else {
-					plane = &pipe->planes[p];
-					plane->index = p++;
-				}
-				display->has_cursor_plane = true;
-				break;
-			default:
+
+			if (type == DRM_PLANE_TYPE_PRIMARY && pipe->plane_primary == -1) {
+				plane = &pipe->planes[0];
+				plane->index = 0;
+				pipe->plane_primary = 0;
+			} else if (type == DRM_PLANE_TYPE_CURSOR && pipe->plane_cursor == -1) {
+				plane = &pipe->planes[last_plane];
+				plane->index = last_plane;
+				pipe->plane_cursor = last_plane;
+			} else {
 				plane = &pipe->planes[p];
 				plane->index = p++;
-				break;
 			}
 
 			igt_assert_f(plane->index < n_planes, "n_planes < plane->index failed\n");