diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-03-04 10:07:19 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-04-14 15:58:26 +0100 |
commit | 5ed5fa10600f0140b317ec07be6f24739c11bd18 (patch) | |
tree | d535444f960512bf8eb809f0359b8abcaa7a4080 /xf86drmMode.c | |
parent | 6f90b77ea903756c87ae614c093e3d816ebb26fc (diff) |
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.c | 23 |
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) /* * Connector manipulation */ - -drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id) +static drmModeConnectorPtr +_drmModeGetConnector(int fd, uint32_t connector_id, int probe) { struct drm_mode_get_connector conn, counts; drmModeConnectorPtr r = NULL; -retry: memclear(conn); conn.connector_id = connector_id; + if (!probe) { + conn.count_modes = 1; + conn.modes_ptr = VOID2U64(drmMalloc(sizeof(struct drm_mode_modeinfo))); + } if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn)) return 0; +retry: counts = conn; if (conn.count_props) { @@ -504,6 +508,9 @@ retry: conn.modes_ptr = VOID2U64(drmMalloc(conn.count_modes*sizeof(struct drm_mode_modeinfo))); if (!conn.modes_ptr) goto err_allocs; + } else { + conn.count_modes = 1; + conn.modes_ptr = VOID2U64(drmMalloc(sizeof(struct drm_mode_modeinfo))); } if (conn.count_encoders) { @@ -572,6 +579,16 @@ err_allocs: return r; } +drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id) +{ + return _drmModeGetConnector(fd, connector_id, 1); +} + +drmModeConnectorPtr drmModeGetConnectorCurrent(int fd, uint32_t connector_id) +{ + return _drmModeGetConnector(fd, connector_id, 0); +} + int drmModeAttachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_info) { struct drm_mode_mode_cmd res; |