aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson2015-03-04 04:07:19 -0600
committerChris Wilson2015-04-14 09:58:26 -0500
commit5ed5fa10600f0140b317ec07be6f24739c11bd18 (patch)
treed535444f960512bf8eb809f0359b8abcaa7a4080 /xf86drmMode.c
parent6f90b77ea903756c87ae614c093e3d816ebb26fc (diff)
downloadexternal-libdrm-5ed5fa10600f0140b317ec07be6f24739c11bd18.tar.gz
external-libdrm-5ed5fa10600f0140b317ec07be6f24739c11bd18.tar.xz
external-libdrm-5ed5fa10600f0140b317ec07be6f24739c11bd18.zip
mode: Retrieve only the current information for a Connector
Add a new API that allows the caller to skip any forced probing, which may require slow i2c to a remote display, and only report the currently active mode and encoder for a Connector. This is often the information of interest and is much, much faster than re-retrieving the link status and EDIDs, e.g. if the caller only wishes to count the number of active outputs. v2: Fix error path to avoid double free after a failed GETCONNECTOR ioctl. v3: Daniel strongly disapproved of my disjoint in behaviour between GetConnector and GetConnectorCurrent, and considering how best to make a drop in replacement for drmmode_output_init() convinced me keeping the API as consistent as possible was the right approach. v4: Avoid probing on the second calls to GETCONNECTOR for unconnected outputs. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Daniel Vetter <daniel.vetter@ffwll.com> Cc: Damien Lespiau <damien.lespiau@intel.com> Cc: David Herrmann <dh.herrmann@googlemail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 61d5e012..1333da48 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -476,19 +476,23 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id)
476/* 476/*
477 * Connector manipulation 477 * Connector manipulation
478 */ 478 */
479 479static drmModeConnectorPtr
480drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id) 480_drmModeGetConnector(int fd, uint32_t connector_id, int probe)
481{ 481{
482 struct drm_mode_get_connector conn, counts; 482 struct drm_mode_get_connector conn, counts;
483 drmModeConnectorPtr r = NULL; 483 drmModeConnectorPtr r = NULL;
484 484
485retry:
486 memclear(conn); 485 memclear(conn);
487 conn.connector_id = connector_id; 486 conn.connector_id = connector_id;
487 if (!probe) {
488 conn.count_modes = 1;
489 conn.modes_ptr = VOID2U64(drmMalloc(sizeof(struct drm_mode_modeinfo)));
490 }
488 491
489 if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn)) 492 if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
490 return 0; 493 return 0;
491 494
495retry:
492 counts = conn; 496 counts = conn;
493 497
494 if (conn.count_props) { 498 if (conn.count_props) {
@@ -504,6 +508,9 @@ retry:
504 conn.modes_ptr = VOID2U64(drmMalloc(conn.count_modes*sizeof(struct drm_mode_modeinfo))); 508 conn.modes_ptr = VOID2U64(drmMalloc(conn.count_modes*sizeof(struct drm_mode_modeinfo)));
505 if (!conn.modes_ptr) 509 if (!conn.modes_ptr)
506 goto err_allocs; 510 goto err_allocs;
511 } else {
512 conn.count_modes = 1;
513 conn.modes_ptr = VOID2U64(drmMalloc(sizeof(struct drm_mode_modeinfo)));
507 } 514 }
508 515
509 if (conn.count_encoders) { 516 if (conn.count_encoders) {
@@ -572,6 +579,16 @@ err_allocs:
572 return r; 579 return r;
573} 580}
574 581
582drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
583{
584 return _drmModeGetConnector(fd, connector_id, 1);
585}
586
587drmModeConnectorPtr drmModeGetConnectorCurrent(int fd, uint32_t connector_id)
588{
589 return _drmModeGetConnector(fd, connector_id, 0);
590}
591
575int drmModeAttachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_info) 592int drmModeAttachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_info)
576{ 593{
577 struct drm_mode_mode_cmd res; 594 struct drm_mode_mode_cmd res;