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

Commit 99638f95 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drm/msm: enable support for custom power ioctl"

parents 72fd98bd f1676cb6
Loading
Loading
Loading
Loading
+68 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#include "msm_kms.h"
#include "msm_mmu.h"
#include "sde_wb.h"
#include "sde_dbg.h"

/*
 * MSM driver version:
@@ -915,6 +916,7 @@ static int context_init(struct drm_device *dev, struct drm_file *file)
		return -ENOMEM;

	msm_submitqueue_init(dev, ctx);
	mutex_init(&ctx->power_lock);

	file->driver_priv = ctx;

@@ -969,6 +971,14 @@ static void msm_postclose(struct drm_device *dev, struct drm_file *file)
		priv->lastctx = NULL;
	mutex_unlock(&dev->struct_mutex);

	mutex_lock(&ctx->power_lock);
	if (ctx->enable_refcnt) {
		SDE_EVT32(ctx->enable_refcnt);
		sde_power_resource_enable(&priv->phandle,
				priv->pclient, false);
	}
	mutex_unlock(&ctx->power_lock);

	context_close(ctx);
}

@@ -1710,6 +1720,62 @@ static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data,
	return msm_submitqueue_remove(file->driver_priv, id);
}

/**
 * msm_ioctl_power_ctrl - enable/disable power vote on MDSS Hw
 * @dev: drm device for the ioctl
 * @data: data pointer for the ioctl
 * @file_priv: drm file for the ioctl call
 *
 */
int msm_ioctl_power_ctrl(struct drm_device *dev, void *data,
			struct drm_file *file_priv)
{
	struct msm_file_private *ctx = file_priv->driver_priv;
	struct msm_drm_private *priv;
	struct drm_msm_power_ctrl *power_ctrl = data;
	bool vote_req = false;
	int old_cnt;
	int rc = 0;

	if (unlikely(!power_ctrl)) {
		DRM_ERROR("invalid ioctl data\n");
		return -EINVAL;
	}

	priv = dev->dev_private;

	mutex_lock(&ctx->power_lock);

	old_cnt = ctx->enable_refcnt;
	if (power_ctrl->enable) {
		if (!ctx->enable_refcnt)
			vote_req = true;
		ctx->enable_refcnt++;
	} else if (ctx->enable_refcnt) {
		ctx->enable_refcnt--;
		if (!ctx->enable_refcnt)
			vote_req = true;
	} else {
		pr_err("ignoring, unbalanced disable\n");
	}

	if (vote_req) {
		rc = sde_power_resource_enable(&priv->phandle,
				priv->pclient, power_ctrl->enable);

		if (rc)
			ctx->enable_refcnt = old_cnt;
	}

	pr_debug("pid %d enable %d, refcnt %d, vote_req %d\n",
			current->pid, power_ctrl->enable, ctx->enable_refcnt,
			vote_req);
	SDE_EVT32(current->pid, power_ctrl->enable, ctx->enable_refcnt,
			vote_req);
	mutex_unlock(&ctx->power_lock);
	return rc;
}

static const struct drm_ioctl_desc msm_ioctls[] = {
	DRM_IOCTL_DEF_DRV(MSM_GET_PARAM,    msm_ioctl_get_param,    DRM_AUTH|DRM_RENDER_ALLOW),
	DRM_IOCTL_DEF_DRV(MSM_GEM_NEW,      msm_ioctl_gem_new,      DRM_AUTH|DRM_RENDER_ALLOW),
@@ -1727,6 +1793,8 @@ static const struct drm_ioctl_desc msm_ioctls[] = {
	DRM_IOCTL_DEF_DRV(MSM_DEREGISTER_EVENT,  msm_ioctl_deregister_event,
			  DRM_UNLOCKED),
	DRM_IOCTL_DEF_DRV(MSM_RMFB2, msm_ioctl_rmfb2, DRM_UNLOCKED),
	DRM_IOCTL_DEF_DRV(MSM_POWER_CTRL, msm_ioctl_power_ctrl,
			DRM_RENDER_ALLOW),
};

static const struct vm_operations_struct vm_ops = {
+6 −0
Original line number Diff line number Diff line
@@ -78,6 +78,12 @@ struct msm_file_private {
	struct list_head submitqueues;

	int queueid;

	/* update the refcount when user driver calls power_ctrl IOCTL */
	unsigned short enable_refcnt;

	/* protects enable_refcnt */
	struct mutex power_lock;
};

enum msm_mdp_plane_property {
+13 −0
Original line number Diff line number Diff line
@@ -382,6 +382,16 @@ struct drm_msm_submitqueue {
	__u32 id;      /* out, identifier */
};

/**
 * struct drm_msm_power_ctrl: Payload to enable/disable the power vote
 * @enable: enable/disable the power vote
 * @flags:  operation control flags, for future use
 */
struct drm_msm_power_ctrl {
	__u32 enable;
	__u32 flags;
};

#define DRM_MSM_GET_PARAM              0x00
/* placeholder:
#define DRM_MSM_SET_PARAM              0x01
@@ -402,6 +412,7 @@ struct drm_msm_submitqueue {
#define DRM_MSM_REGISTER_EVENT         0x41
#define DRM_MSM_DEREGISTER_EVENT       0x42
#define DRM_MSM_RMFB2                  0x43
#define DRM_MSM_POWER_CTRL             0x44

/* sde custom events */
#define DRM_EVENT_HISTOGRAM 0x80000000
@@ -433,6 +444,8 @@ struct drm_msm_submitqueue {
			DRM_MSM_RMFB2), unsigned int)
#define DRM_IOCTL_MSM_SUBMITQUEUE_NEW    DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_NEW, struct drm_msm_submitqueue)
#define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE  DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32)
#define DRM_IOCTL_MSM_POWER_CTRL DRM_IOW((DRM_COMMAND_BASE + \
			DRM_MSM_POWER_CTRL), struct drm_msm_power_ctrl)

#if defined(__cplusplus)
}