diff mbox

[v2,i-g-t] demos/intel_sprite_on: Fix connector iteration bug

Message ID 1466012912-1582-1-git-send-email-jim.bride@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

jim.bride@linux.intel.com June 15, 2016, 5:48 p.m. UTC
Instead of looping until the first disconnected port is found,
now go through all possible connectors, drawing the sprite on
any connected display.

v2: Print a message if we don't find any valid connectors.

Signed-off-by: Jim Bride <jim.bride@linux.intel.com>
---
 demos/intel_sprite_on.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Marius Vlad July 4, 2016, 2:34 p.m. UTC | #1
Applied.
On Wed, Jun 15, 2016 at 10:48:32AM -0700, Jim Bride wrote:
> Instead of looping until the first disconnected port is found,
> now go through all possible connectors, drawing the sprite on
> any connected display.
> 
> v2: Print a message if we don't find any valid connectors.
> 
> Signed-off-by: Jim Bride <jim.bride@linux.intel.com>
> ---
>  demos/intel_sprite_on.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/demos/intel_sprite_on.c b/demos/intel_sprite_on.c
> index 6dddded..d3bd420 100644
> --- a/demos/intel_sprite_on.c
> +++ b/demos/intel_sprite_on.c
> @@ -518,6 +518,8 @@ static void ricochet(int tiled, int sprite_w, int sprite_h,
>  	char                                key;
>  	int				    sprite_plane_count = 0;
>  	int 				    i;
> +	int 				    found_count = 0;
> +
>  	// Open up I915 graphics device
>  	gfx_fd = drmOpen("i915", NULL);
>  	if (gfx_fd < 0) {
> @@ -564,10 +566,15 @@ static void ricochet(int tiled, int sprite_w, int sprite_h,
>  		// Find the native (preferred) display mode
>  		connector_find_preferred_mode(gfx_fd, gfx_resources, &curr_connector);
>  		if (curr_connector.mode_valid == 0) {
> -			printf("No valid preferred mode detected\n");
> -			goto out;
> +
> +			if (((c_index + 1) == gfx_resources->count_connectors) &&
> +			    (found_count == 0))
> +				printf("Failed to find any valid connections.");
> +			continue;
>  		}
>  
> +		found_count++;
> +
>  		// Determine if sprite hardware is available on pipe
>  		// associated with this connector.
>  		sprite_plane_count = connector_find_plane(gfx_fd, &curr_connector,
> -- 
> 2.7.4
>
diff mbox

Patch

diff --git a/demos/intel_sprite_on.c b/demos/intel_sprite_on.c
index 6dddded..d3bd420 100644
--- a/demos/intel_sprite_on.c
+++ b/demos/intel_sprite_on.c
@@ -518,6 +518,8 @@  static void ricochet(int tiled, int sprite_w, int sprite_h,
 	char                                key;
 	int				    sprite_plane_count = 0;
 	int 				    i;
+	int 				    found_count = 0;
+
 	// Open up I915 graphics device
 	gfx_fd = drmOpen("i915", NULL);
 	if (gfx_fd < 0) {
@@ -564,10 +566,15 @@  static void ricochet(int tiled, int sprite_w, int sprite_h,
 		// Find the native (preferred) display mode
 		connector_find_preferred_mode(gfx_fd, gfx_resources, &curr_connector);
 		if (curr_connector.mode_valid == 0) {
-			printf("No valid preferred mode detected\n");
-			goto out;
+
+			if (((c_index + 1) == gfx_resources->count_connectors) &&
+			    (found_count == 0))
+				printf("Failed to find any valid connections.");
+			continue;
 		}
 
+		found_count++;
+
 		// Determine if sprite hardware is available on pipe
 		// associated with this connector.
 		sprite_plane_count = connector_find_plane(gfx_fd, &curr_connector,