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

Commit 388a60ed authored by Ajay Singh Parmar's avatar Ajay Singh Parmar Committed by Abhijith Desai
Browse files

drm/msm/dp: add write support in simulation mode



Currently simulation only supports reading data from script
which impersonates a sink device. Further enhancement of script
needs source device to support writing data to it. Add writing
data in simulation so that script can be enhanced for more
simulation support.

Change-Id: I161a3ee30f98d694e80459786edae9dcc4dc91da
CRs-Fixed: 2322388
Signed-off-by: default avatarAjay Singh Parmar <aparmar@codeaurora.org>
Signed-off-by: default avatarAbhijith Desai <desaia@codeaurora.org>
parent 0b01878e
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -492,30 +492,42 @@ static ssize_t dp_aux_transfer_debug(struct drm_dp_aux *drm_aux,
		goto end;
	}

	if ((msg->address + msg->size) > SZ_16K) {
	if ((msg->address + msg->size) > SZ_4K) {
		pr_err("invalid dpcd access: addr=0x%x, size=0x%x\n",
				msg->address + msg->size);
		goto address_error;
	}

	if (aux->native) {
		if (aux->read) {
		aux->dp_aux.reg = msg->address;
		aux->dp_aux.read = aux->read;
		aux->dp_aux.size = msg->size;

		reinit_completion(&aux->comp);

		if (aux->read) {
			timeout = wait_for_completion_timeout(&aux->comp, HZ);
			if (!timeout)
			if (!timeout) {
				pr_err("aux timeout for 0x%x\n", msg->address);

			aux->dp_aux.reg = 0xFFFF;
				ret = -ETIMEDOUT;
				goto end;
			}

			memcpy(msg->buffer, aux->dpcd + msg->address,
				msg->size);
			aux->aux_error_num = DP_AUX_ERR_NONE;
		} else {
			memcpy(aux->dpcd + msg->address, msg->buffer,
				msg->size);

			timeout = wait_for_completion_timeout(&aux->comp, HZ);
			if (!timeout) {
				pr_err("aux timeout for 0x%x\n", msg->address);
				ret = -ETIMEDOUT;
				goto end;
			}
		}

		aux->aux_error_num = DP_AUX_ERR_NONE;
	} else {
		if (aux->read && msg->address == 0x50) {
			memcpy(msg->buffer,
@@ -545,6 +557,10 @@ static ssize_t dp_aux_transfer_debug(struct drm_dp_aux *drm_aux,
	memset(msg->buffer, 0, msg->size);
	ret = msg->size;
end:
	aux->dp_aux.reg = 0xFFFF;
	aux->dp_aux.read = true;
	aux->dp_aux.size = 0;

	mutex_unlock(&aux->mutex);
	return ret;
}
+3 −0
Original line number Diff line number Diff line
@@ -43,8 +43,11 @@ enum dp_aux_error {

struct dp_aux {
	u32 reg;
	u32 size;
	u32 state;

	bool read;

	struct drm_dp_aux *drm_aux;
	int (*drm_aux_register)(struct dp_aux *aux);
	void (*drm_aux_deregister)(struct dp_aux *aux);
+28 −8
Original line number Diff line number Diff line
@@ -71,13 +71,13 @@ static int dp_debug_get_dpcd_buf(struct dp_debug_private *debug)
	int rc = 0;

	if (!debug->dpcd) {
		debug->dpcd = devm_kzalloc(debug->dev, SZ_16K, GFP_KERNEL);
		debug->dpcd = devm_kzalloc(debug->dev, SZ_4K, GFP_KERNEL);
		if (!debug->dpcd) {
			rc = -ENOMEM;
			goto end;
		}

		debug->dpcd_size = SZ_16K;
		debug->dpcd_size = SZ_4K;
	}
end:
	return rc;
@@ -251,21 +251,41 @@ static ssize_t dp_debug_read_dpcd(struct file *file,
		char __user *user_buff, size_t count, loff_t *ppos)
{
	struct dp_debug_private *debug = file->private_data;
	char buf[SZ_8];
	char *buf;
	int const buf_size = SZ_4K;
	u32 offset = 0;
	u32 len = 0;

	if (!debug)
	if (!debug || !debug->aux || !debug->dpcd)
		return -ENODEV;

	if (*ppos)
		return 0;

	len += snprintf(buf, SZ_8, "0x%x\n", debug->aux->reg);
	buf = kzalloc(buf_size, GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

	len += snprintf(buf, buf_size, "0x%x", debug->aux->reg);

	if (copy_to_user(user_buff, buf, len))
		return -EFAULT;
	if (!debug->aux->read) {
		while (1) {
			if (debug->aux->reg + offset >= buf_size ||
			    offset >= debug->aux->size)
				break;

			len += snprintf(buf + len, buf_size - len, "0x%x",
				debug->dpcd[debug->aux->reg + offset++]);
		}

		if (debug->dp_debug.sim_mode && debug->aux->dpcd_updated)
			debug->aux->dpcd_updated(debug->aux);
	}

	if (!copy_to_user(user_buff, buf, len))
		*ppos += len;

	kfree(buf);
	return len;
}