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

Commit e08229cc authored by Lloyd Atkinson's avatar Lloyd Atkinson
Browse files

drm/msm/sde: reset custom props to default on last close



Reset custom property values to their default values for any
planes, CRTCs, or connectors in use by a DRM client when the
last client closes its FD.

Change-Id: I272700b2756510a2cdd5bffa81cb62c84247e8d1
Signed-off-by: default avatarLloyd Atkinson <latkinso@codeaurora.org>
parent 9c9a0530
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -937,9 +937,9 @@ static void msm_lastclose(struct drm_device *dev)
	} else {
		drm_modeset_lock_all(dev);
		msm_disable_all_modes(dev);
		drm_modeset_unlock_all(dev);
		if (kms && kms->funcs && kms->funcs->lastclose)
			kms->funcs->lastclose(kms);
		drm_modeset_unlock_all(dev);
	}
}

+2 −2
Original line number Diff line number Diff line
@@ -83,8 +83,6 @@ struct msm_file_private {

enum msm_mdp_plane_property {
	/* blob properties, always put these first */
	PLANE_PROP_SCALER_V1,
	PLANE_PROP_SCALER_V2,
	PLANE_PROP_CSC_V1,
	PLANE_PROP_INFO,
	PLANE_PROP_SCALER_LUT_ED,
@@ -116,6 +114,8 @@ enum msm_mdp_plane_property {
	PLANE_PROP_ROT_DST_H,
	PLANE_PROP_PREFILL_SIZE,
	PLANE_PROP_PREFILL_TIME,
	PLANE_PROP_SCALER_V1,
	PLANE_PROP_SCALER_V2,

	/* enum/bitmask properties */
	PLANE_PROP_ROTATION,
+10 −5
Original line number Diff line number Diff line
@@ -393,20 +393,25 @@ int msm_property_atomic_set(struct msm_property_info *info,
	struct drm_property_blob *blob;
	int property_idx, rc = -EINVAL;

	if (!info || !property_state) {
		DRM_ERROR("invalid argument(s)\n");
		return -EINVAL;
	}

	property_idx = msm_property_index(info, property);
	if (!info || !property_state ||
			(property_idx == -EINVAL) || !property_state->values) {
		DRM_DEBUG("invalid argument(s)\n");
	if ((property_idx == -EINVAL) || !property_state->values) {
		DRM_ERROR("invalid argument(s)\n");
	} else {
		/* extra handling for incoming properties */
		mutex_lock(&info->property_lock);
		if ((property->flags & DRM_MODE_PROP_BLOB) &&
		if (val && (property->flags & DRM_MODE_PROP_BLOB) &&
			(property_idx < info->blob_count)) {
			/* DRM lookup also takes a reference */
			blob = drm_property_lookup_blob(info->dev,
				(uint32_t)val);
			if (!blob) {
				DRM_ERROR("blob not found\n");
				DRM_ERROR("prop %d blob id 0x%llx not found\n",
						property_idx, val);
				val = 0;
			} else {
				DBG("Blob %u saved", blob->base.id);
+52 −0
Original line number Diff line number Diff line
@@ -1088,6 +1088,58 @@ int sde_connector_set_property_for_commit(struct drm_connector *connector,
			connector, state, property, value);
}

int sde_connector_helper_reset_custom_properties(
		struct drm_connector *connector,
		struct drm_connector_state *connector_state)
{
	struct sde_connector *c_conn;
	struct sde_connector_state *c_state;
	struct drm_property *drm_prop;
	enum msm_mdp_conn_property prop_idx;

	if (!connector || !connector_state) {
		SDE_ERROR("invalid params\n");
		return -EINVAL;
	}

	c_conn = to_sde_connector(connector);
	c_state = to_sde_connector_state(connector_state);

	for (prop_idx = 0; prop_idx < CONNECTOR_PROP_COUNT; prop_idx++) {
		uint64_t val = c_state->property_values[prop_idx].value;
		uint64_t def;
		int ret;

		drm_prop = msm_property_index_to_drm_property(
				&c_conn->property_info, prop_idx);
		if (!drm_prop) {
			/* not all props will be installed, based on caps */
			SDE_DEBUG_CONN(c_conn, "invalid property index %d\n",
					prop_idx);
			continue;
		}

		def = msm_property_get_default(&c_conn->property_info,
				prop_idx);
		if (val == def)
			continue;

		SDE_DEBUG_CONN(c_conn, "set prop %s idx %d from %llu to %llu\n",
				drm_prop->name, prop_idx, val, def);

		ret = drm_atomic_connector_set_property(connector,
				connector_state, drm_prop, def);
		if (ret) {
			SDE_ERROR_CONN(c_conn,
					"set property failed, idx %d ret %d\n",
					prop_idx, ret);
			continue;
		}
	}

	return 0;
}

#ifdef CONFIG_DEBUG_FS
/**
 * sde_connector_init_debugfs - initialize connector debugfs
+11 −0
Original line number Diff line number Diff line
@@ -598,4 +598,15 @@ int sde_connector_get_dither_cfg(struct drm_connector *conn,
 */
void sde_connector_schedule_status_work(struct drm_connector *conn, bool en);

/**
 * sde_connector_helper_reset_properties - reset properties to default values in
 *	the given DRM connector state object
 * @connector: Pointer to DRM connector object
 * @connector_state: Pointer to DRM connector state object
 * Returns: 0 on success, negative errno on failure
 */
int sde_connector_helper_reset_custom_properties(
		struct drm_connector *connector,
		struct drm_connector_state *connector_state);

#endif /* _SDE_CONNECTOR_H_ */
Loading