Exemplo n.º 1
0
void
i2c_dp_aux_reset_bus(struct i2c_adapter *adapter)
{
	(void) i2c_algo_dp_aux_address(adapter, 0, false);
	(void) i2c_algo_dp_aux_stop(adapter, false);
					   
}
Exemplo n.º 2
0
static int
i2c_algo_dp_aux_exec(void *cookie, i2c_op_t op, i2c_addr_t addr,
    const void *cmdbuf, size_t cmdlen, void *buffer, size_t len, int flags)
{
	struct i2c_algo_dp_aux_data *algo_data = cookie;
	struct i2c_controller *adapter = algo_data->adapter;
	uint8_t *buf;
	int i, ret;

	buf = (void *)cmdbuf;
	if (cmdlen > 0) {
		ret = i2c_algo_dp_aux_address(adapter, addr, false);
		if (ret < 0)
			goto out;
		for (i = 0; i < cmdlen; i++) {
			ret = i2c_algo_dp_aux_put_byte(adapter, buf[i]);
			if (ret < 0)
				goto out;
		}
	}

	buf = buffer;
	ret = i2c_algo_dp_aux_address(adapter, addr, I2C_OP_READ_P(op));
	if (ret < 0)
		goto out;
	if (I2C_OP_READ_P(op)) {
		for (i = 0; i < len; i++) {
			ret = i2c_algo_dp_aux_get_byte(adapter, &buf[i]);
			if (ret < 0)
				break;
		}
	} else {
		for (i = 0; i < len; i++) {
			ret = i2c_algo_dp_aux_put_byte(adapter, buf[i]);
			if (ret < 0)
				break;
		}
	}

out:
	if (I2C_OP_STOP_P(op))
		i2c_algo_dp_aux_stop(adapter, I2C_OP_READ_P(op));

	if (ret >= 0)
		ret = 0;
	DRM_DEBUG_KMS("dp_aux_exec return %d\n", ret);
	return ret;
}
Exemplo n.º 3
0
int
i2c_algo_dp_aux_xfer(struct i2c_adapter *adapter,
		     struct i2c_msg *msgs,
		     int num)
{
	int ret = 0;
	bool reading = false;
	int m;
	int b;

	for (m = 0; m < num; m++) {
		u16 len = msgs[m].len;
		u8 *buf = msgs[m].buf;
		reading = (msgs[m].flags & I2C_M_RD) != 0;
		ret = i2c_algo_dp_aux_address(adapter, msgs[m].addr, reading);
		if (ret < 0)
			break;
		if (reading) {
			for (b = 0; b < len; b++) {
				ret = i2c_algo_dp_aux_get_byte(adapter, &buf[b]);
				if (ret < 0)
					break;
			}
		} else {
			for (b = 0; b < len; b++) {
				ret = i2c_algo_dp_aux_put_byte(adapter, buf[b]);
				if (ret < 0)
					break;
			}
		}
		if (ret < 0)
			break;
	}
	if (ret >= 0)
		ret = num;
	i2c_algo_dp_aux_stop(adapter, reading);
	fprintf(stderr, "[000000.0] [drm:%s], ", __func__);
	fprintf(stderr, "dp_aux_xfer return %d\n", ret);
	return ret;
}