All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] lib/igt_kms, tests/testdisplay: allow probing of new connector modes
@ 2016-01-14 22:08 Jesse Barnes
  0 siblings, 0 replies; only message in thread
From: Jesse Barnes @ 2016-01-14 22:08 UTC (permalink / raw)
  To: intel-gfx

Fixup some fallout from the connector probing changes so testdisplay -m
will pick up newly hotplugged displays correctly.

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org.
---
 lib/igt_kms.c               | 53 ++++++++++++++++++++++++++++++++++++++++-----
 lib/igt_kms.h               |  3 +++
 tests/testdisplay.c         | 21 ++++++++++++------
 tests/testdisplay.h         |  2 +-
 tests/testdisplay_hotplug.c |  2 +-
 5 files changed, 67 insertions(+), 14 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 497118a..90c8da7 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -533,18 +533,20 @@ bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 }
 
 /**
- * kmstest_get_connector_config:
+ * _kmstest_connector_config:
  * @drm_fd: DRM fd
  * @connector_id: DRM connector id
  * @crtc_idx_mask: mask of allowed DRM CRTC indices
  * @config: structure filled with the possible configuration
+ * @probe: whether to fully re-probe mode list or not
  *
  * This tries to find a suitable configuration for the given connector and CRTC
  * constraint and fills it into @config.
  */
-bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
-				  unsigned long crtc_idx_mask,
-				  struct kmstest_connector_config *config)
+static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
+				      unsigned long crtc_idx_mask,
+				      struct kmstest_connector_config *config,
+				      bool probe)
 {
 	drmModeRes *resources;
 	drmModeConnector *connector;
@@ -558,7 +560,11 @@ bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
 	}
 
 	/* First, find the connector & mode */
-	connector = drmModeGetConnectorCurrent(drm_fd, connector_id);
+	if (probe)
+		connector = drmModeGetConnector(drm_fd, connector_id);
+	else
+		connector = drmModeGetConnectorCurrent(drm_fd, connector_id);
+
 	if (!connector)
 		goto err2;
 
@@ -634,6 +640,43 @@ err1:
 }
 
 /**
+ * kmstest_get_connector_config:
+ * @drm_fd: DRM fd
+ * @connector_id: DRM connector id
+ * @crtc_idx_mask: mask of allowed DRM CRTC indices
+ * @config: structure filled with the possible configuration
+ *
+ * This tries to find a suitable configuration for the given connector and CRTC
+ * constraint and fills it into @config.
+ */
+bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
+				  unsigned long crtc_idx_mask,
+				  struct kmstest_connector_config *config)
+{
+	return _kmstest_connector_config(drm_fd, connector_id, crtc_idx_mask,
+					 config, 0);
+}
+
+/**
+ * kmstest_probe_connector_config:
+ * @drm_fd: DRM fd
+ * @connector_id: DRM connector id
+ * @crtc_idx_mask: mask of allowed DRM CRTC indices
+ * @config: structure filled with the possible configuration
+ *
+ * This tries to find a suitable configuration for the given connector and CRTC
+ * constraint and fills it into @config, fully probing the connector in the
+ * process.
+ */
+bool kmstest_probe_connector_config(int drm_fd, uint32_t connector_id,
+				    unsigned long crtc_idx_mask,
+				    struct kmstest_connector_config *config)
+{
+	return _kmstest_connector_config(drm_fd, connector_id, crtc_idx_mask,
+					 config, 1);
+}
+
+/**
  * kmstest_free_connector_config:
  * @config: connector configuration structure
  *
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 94f315f..3f7add5 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -140,6 +140,9 @@ bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
 				  unsigned long crtc_idx_mask,
 				  struct kmstest_connector_config *config);
+bool kmstest_probe_connector_config(int drm_fd, uint32_t connector_id,
+				    unsigned long crtc_idx_mask,
+				    struct kmstest_connector_config *config);
 void kmstest_free_connector_config(struct kmstest_connector_config *config);
 
 void kmstest_set_connector_dpms(int fd, drmModeConnector *connector, int mode);
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index ff49e23..00b47bd 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -191,12 +191,19 @@ static void dump_info(void)
 
 static void connector_find_preferred_mode(uint32_t connector_id,
 					  unsigned long crtc_idx_mask,
-					  int mode_num, struct connector *c)
+					  int mode_num, struct connector *c,
+					  bool probe)
 {
 	struct kmstest_connector_config config;
+	bool ret;
 
-	if (!kmstest_get_connector_config(drm_fd, connector_id, crtc_idx_mask,
-					  &config)) {
+	if (probe)
+		ret = kmstest_probe_connector_config(drm_fd, connector_id,
+						     crtc_idx_mask, &config);
+	else
+		ret = kmstest_get_connector_config(drm_fd, connector_id,
+						   crtc_idx_mask, &config);
+	if (!ret) {
 		c->mode_valid = 0;
 		return;
 	}
@@ -456,7 +463,7 @@ set_stereo_mode(struct connector *c)
  * Each connector has a corresponding encoder, except in the SDVO case
  * where an encoder may have multiple connectors.
  */
-int update_display(void)
+int update_display(bool probe)
 {
 	struct connector *connectors;
 	int c;
@@ -488,7 +495,7 @@ int update_display(void)
 			connector_find_preferred_mode(connector->id,
 						      crtc_idx_mask,
 						      specified_mode_num,
-						      connector);
+						      connector, probe);
 			if (!connector->mode_valid)
 				continue;
 
@@ -513,7 +520,7 @@ int update_display(void)
 			connector_find_preferred_mode(connector->id,
 						      -1UL,
 						      specified_mode_num,
-						      connector);
+						      connector, probe);
 			if (!connector->mode_valid)
 				continue;
 
@@ -765,7 +772,7 @@ int main(int argc, char **argv)
 
 	ret = 0;
 
-	if (!update_display()) {
+	if (!update_display(false)) {
 		ret = 1;
 		goto out_stdio;
 	}
diff --git a/tests/testdisplay.h b/tests/testdisplay.h
index 962e621..27f8209 100644
--- a/tests/testdisplay.h
+++ b/tests/testdisplay.h
@@ -32,4 +32,4 @@ gboolean testdisplay_setup_hotplug(void);
 void testdisplay_cleanup_hotplug(void);
 
 /* called by the hotplug code */
-int update_display(void);
+int update_display(bool probe);
diff --git a/tests/testdisplay_hotplug.c b/tests/testdisplay_hotplug.c
index 9d11399..3b900ca 100644
--- a/tests/testdisplay_hotplug.c
+++ b/tests/testdisplay_hotplug.c
@@ -59,7 +59,7 @@ static gboolean hotplug_event(GIOChannel *source, GIOCondition condition,
 
 	if (memcmp(&s.st_rdev, &udev_devnum, sizeof(dev_t)) == 0 &&
 	    hotplug && atoi(hotplug) == 1)
-		update_display();
+		update_display(true);
 
 	udev_device_unref(dev);
 out:
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-14 22:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-14 22:08 [PATCH i-g-t] lib/igt_kms, tests/testdisplay: allow probing of new connector modes Jesse Barnes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.