Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed293f77 authored by Daniel Vetter's avatar Daniel Vetter
Browse files

drm/sysfs: Send out uevent when connector->force changes



To avoid even more code duplication punt this all to the probe worker,
which needs some slight adjustment to also generate a uevent when the
status has changed to due connector->force.

v2: Instead of running the output_poll_work (which is kinda the wrong
thing and a layering violation since it's an internal of the probe
helpers), or calling ->detect (which is again a layering violation
since it's used only by probe helpers) just call the official
->fill_modes function, like a GET_CONNECTOR ioctl call.

v3: Restore the accidentally removed forced-probe for echo "detect" >
force.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reported-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1447951610-12622-22-git-send-email-daniel.vetter@ffwll.ch


Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 9744bf41
Loading
Loading
Loading
Loading
+23 −23
Original line number Original line Diff line number Diff line
@@ -147,6 +147,8 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
	list_for_each_entry(mode, &connector->modes, head)
	list_for_each_entry(mode, &connector->modes, head)
		mode->status = MODE_UNVERIFIED;
		mode->status = MODE_UNVERIFIED;


	old_status = connector->status;

	if (connector->force) {
	if (connector->force) {
		if (connector->force == DRM_FORCE_ON ||
		if (connector->force == DRM_FORCE_ON ||
		    connector->force == DRM_FORCE_ON_DIGITAL)
		    connector->force == DRM_FORCE_ON_DIGITAL)
@@ -156,9 +158,8 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
		if (connector->funcs->force)
		if (connector->funcs->force)
			connector->funcs->force(connector);
			connector->funcs->force(connector);
	} else {
	} else {
		old_status = connector->status;

		connector->status = connector->funcs->detect(connector, true);
		connector->status = connector->funcs->detect(connector, true);
	}


	/*
	/*
	 * Normally either the driver's hpd code or the poll loop should
	 * Normally either the driver's hpd code or the poll loop should
@@ -183,7 +184,6 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
			schedule_delayed_work(&dev->mode_config.output_poll_work,
			schedule_delayed_work(&dev->mode_config.output_poll_work,
					      0);
					      0);
	}
	}
	}


	/* Re-enable polling in case the global poll config changed. */
	/* Re-enable polling in case the global poll config changed. */
	if (drm_kms_helper_poll != dev->mode_config.poll_running)
	if (drm_kms_helper_poll != dev->mode_config.poll_running)
+13 −25
Original line number Original line Diff line number Diff line
@@ -167,47 +167,35 @@ static ssize_t status_store(struct device *device,
{
{
	struct drm_connector *connector = to_drm_connector(device);
	struct drm_connector *connector = to_drm_connector(device);
	struct drm_device *dev = connector->dev;
	struct drm_device *dev = connector->dev;
	enum drm_connector_status old_status;
	enum drm_connector_force old_force;
	int ret;
	int ret;


	ret = mutex_lock_interruptible(&dev->mode_config.mutex);
	ret = mutex_lock_interruptible(&dev->mode_config.mutex);
	if (ret)
	if (ret)
		return ret;
		return ret;


	old_status = connector->status;
	old_force = connector->force;


	if (sysfs_streq(buf, "detect")) {
	if (sysfs_streq(buf, "detect"))
		connector->force = 0;
		connector->force = 0;
		connector->status = connector->funcs->detect(connector, true);
	else if (sysfs_streq(buf, "on"))
	} else if (sysfs_streq(buf, "on")) {
		connector->force = DRM_FORCE_ON;
		connector->force = DRM_FORCE_ON;
	} else if (sysfs_streq(buf, "on-digital")) {
	else if (sysfs_streq(buf, "on-digital"))
		connector->force = DRM_FORCE_ON_DIGITAL;
		connector->force = DRM_FORCE_ON_DIGITAL;
	} else if (sysfs_streq(buf, "off")) {
	else if (sysfs_streq(buf, "off"))
		connector->force = DRM_FORCE_OFF;
		connector->force = DRM_FORCE_OFF;
	} else
		ret = -EINVAL;

	if (ret == 0 && connector->force) {
		if (connector->force == DRM_FORCE_ON ||
		    connector->force == DRM_FORCE_ON_DIGITAL)
			connector->status = connector_status_connected;
	else
	else
			connector->status = connector_status_disconnected;
		ret = -EINVAL;
		if (connector->funcs->force)
			connector->funcs->force(connector);
	}


	if (old_status != connector->status) {
	if (old_force != connector->force || !connector->force) {
		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %d to %d\n",
		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force updated from %d to %d or reprobing\n",
			      connector->base.id,
			      connector->base.id,
			      connector->name,
			      connector->name,
			      old_status, connector->status);
			      old_force, connector->force);


		dev->mode_config.delayed_event = true;
		connector->funcs->fill_modes(connector,
		if (dev->mode_config.poll_enabled)
					     dev->mode_config.max_width,
			schedule_delayed_work(&dev->mode_config.output_poll_work,
					     dev->mode_config.max_height);
					      0);
	}
	}


	mutex_unlock(&dev->mode_config.mutex);
	mutex_unlock(&dev->mode_config.mutex);