Skip to contentSkip to conversation

demos/intel_sprite_on: Fix connector iteration bug

PATCH Superseded Jim Bride 2 participants 5 messages Jun 13, 2016 – Jul 4, 2016

lore
Share & tools
lore

Jim Bride

author
#0 lore raw

PATCH 1/1 demos/intel_sprite_on: Fix connector iteration bug

Instead of looping until the first disconnected port is found, now go through all possible connectors, drawing the sprite on any connected display.

---
 demos/intel_sprite_on.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
demos/intel_sprite_on.c +2 -4
index 6dddded..ff40e3c 100644
@@ -563,10 +563,8 @@ 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 (curr_connector.mode_valid == 0)
+			continue;
 
 		// Determine if sprite hardware is available on pipe
 		// associated with this connector.
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 14 lines · Jim Bride

Instead of looping until the first disconnected port is found, now go through all possible connectors, drawing the sprite on any connected display.

---
 demos/intel_sprite_on.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
demos/intel_sprite_on.c +0 -0
index 6dddded..ff40e3c 100644

demos/intel_sprite_on.c static void ricochet(int tiled, int sprite_w, int sprite_h, · line 567

Quoted 9 lines
demos/intel_sprite_on.c +2 -4
@@ -563,10 +563,8 @@ 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 (curr_connector.mode_valid == 0)
+			continue;

Could you also add that info message when all connectors are disconnected?

Like checking the index is equal w/ the number of connectors available?

Quoted 10 lines
demos/intel_sprite_on.c +0 -0
 		// Determine if sprite hardware is available on pipe
 		// associated with this connector.
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#2 lore raw
Quoted 27 lines · Marius Vlad
Quoted 14 lines · Jim Bride

Instead of looping until the first disconnected port is found, now go through all possible connectors, drawing the sprite on any connected display.

---
 demos/intel_sprite_on.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
demos/intel_sprite_on.c +0 -0
index 6dddded..ff40e3c 100644

demos/intel_sprite_on.c static void ricochet(int tiled, int sprite_w, int sprite_h, · line 567

Quoted 9 lines
demos/intel_sprite_on.c +2 -4
@@ -563,10 +563,8 @@ 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 (curr_connector.mode_valid == 0)
+			continue;

Could you also add that info message when all connectors are disconnected?

Quoted 1 line

Like checking the index is equal w/ the number of connectors available?

Sure. New version coming in a little bit.

Jim

Quoted 10 lines
Quoted 10 lines
demos/intel_sprite_on.c +0 -0
 		// Determine if sprite hardware is available on pipe
 		// associated with this connector.
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#3 lore raw

PATCH v2 1/1 demos/intel_sprite_on: Fix connector iteration bug

In reply to Jim Bride

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.

---
 demos/intel_sprite_on.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
demos/intel_sprite_on.c +9 -2
index 6dddded..d3bd420 100644
@@ -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,
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Applied
#4 lore raw

Applied.

Quoted 45 lines · Jim Bride

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.

---
 demos/intel_sprite_on.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
demos/intel_sprite_on.c +9 -2
index 6dddded..d3bd420 100644
@@ -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,
Signature · 1 line
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx