This patch adds a "get current" info function for apps to use, probably mostly at startup time when they just want to see what outputs are available vs. detecting current status & mode lists. Can help speed up startup quite a bit in some configurations.
Signed-off-by: Jesse Barnes <jbar...@virtuousgeek.org> -- Jesse Barnes, Intel Open Source Technology Center diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 94a7688..5d4732d 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1209,24 +1209,31 @@ out: } /** - * drm_mode_getconnector - get connector configuration - * @inode: inode from the ioctl - * @filp: file * from the ioctl - * @cmd: cmd from ioctl - * @arg: arg from ioctl + * do_mode_getconnector - get connector configuration + * @dev: DRM device + * @data: drm_mode_get_connector request + * @file_priv: file private + * @probe: probe for data? * * LOCKING: - * Caller? (FIXME) + * Takes struct mutex. * * Construct a connector configuration structure to return to the user. * * Called by the user via ioctl. * + * This will generally be called twice; once to get the count for the + * various structures and do probing, and then again to return the actual + * data. + * + * The @probe flag controls whether we should actually go probe all the + * outputs or just return the current data (e.g. from the last call). + * * RETURNS: * Zero on success, errno on failure. */ -int drm_mode_getconnector(struct drm_device *dev, void *data, - struct drm_file *file_priv) +static int do_mode_getconnector(struct drm_device *dev, void *data, + struct drm_file *file_priv, int probe) { struct drm_mode_get_connector *out_resp = data; struct drm_mode_object *obj; @@ -1270,7 +1277,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, } } - if (out_resp->count_modes == 0) { + if (out_resp->count_modes == 0 && probe) { connector->funcs->fill_modes(connector, dev->mode_config.max_width, dev->mode_config.max_height); @@ -1355,6 +1362,46 @@ out: return ret; } +/** + * drm_mode_getconnector - get connector configuration + * @dev: drm device + * @data: getconnector request structure + * @file_priv: file private + * + * LOCKING: + * None. + * + * Get connector information, by probing outputs. + * + * RETURNS: + * Zero on success, errno on failure. + */ +int drm_mode_getconnector(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return do_mode_getconnector(dev, data, file_priv, true); +} + +/** + * drm_mode_getconnector_current - get current connector configuration + * @dev: DRM device + * @data: getconnector request structure + * @file_priv: file private + * + * LOCKING: + * None. + * + * Return connector data from the last probe. + * + * RETURNS: + * Zero on success, errno on failure. + */ +int drm_mode_getconnector_current(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return do_mode_getconnector(dev, data, file_priv, false); +} + int drm_mode_getencoder(struct drm_device *dev, void *data, struct drm_file *file_priv) { diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index c4ada8b..64bf784 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -137,6 +137,7 @@ static struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETGAMMA, drm_mode_gamma_set_ioctl, DRM_MASTER), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETENCODER, drm_mode_getencoder, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCONNECTOR, drm_mode_getconnector, DRM_MASTER|DRM_CONTROL_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCONNECTOR_CURRENT, drm_mode_getconnector_current, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_mode_attachmode_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_mode_detachmode_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPERTY, drm_mode_getproperty_ioctl, DRM_MASTER | DRM_CONTROL_ALLOW), diff --git a/include/drm/drm.h b/include/drm/drm.h index 7cb50bd..75ba0b4 100644 --- a/include/drm/drm.h +++ b/include/drm/drm.h @@ -686,6 +686,7 @@ struct drm_gem_open { #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd) #define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd) #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int) +#define DRM_IOCTL_MODE_GETCONNECTOR_CURRENT DRM_IOWR(0xB0, struct drm_mode_get_connector) /** * Device specific ioctls should only be in their respective headers diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 3c1924c..bae1552 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -697,6 +697,8 @@ extern int drm_mode_getcrtc(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_getconnector(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int drm_mode_getconnector_current(struct drm_device *dev, + void *data, struct drm_file *file_priv); extern int drm_mode_setcrtc(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_cursor_ioctl(struct drm_device *dev, ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf -- _______________________________________________ Dri-devel mailing list Dri-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dri-devel