Exemplo n.º 1
0
static ssize_t codec_debug_write(struct file *filp,
	const char __user *ubuf, size_t cnt, loff_t *ppos)
{
	char *access_str = filp->private_data;
	char lbuf[32];
	unsigned char reg_idx[2] = {0x00, 0x00};
	int rc;
	long int param[5];

	if (cnt > sizeof(lbuf) - 1)
		return -EINVAL;

	rc = copy_from_user(lbuf, ubuf, cnt);
	if (rc)
		return -EFAULT;

	lbuf[cnt] = '\0';

	if (!strcmp(access_str, "poke")) {
		
		rc = get_parameters(lbuf, param, 2);
		if ((param[0] <= 0xFF) && (param[1] <= 0xFF) &&
			(rc == 0)) {
			reg_idx[0] = param[0];
			reg_idx[1] = param[1];
			tfa9887_i2c_write(reg_idx, 2);
		} else
			rc = -EINVAL;
	} else if (!strcmp(access_str, "peek")) {
		
		rc = get_parameters(lbuf, param, 1);
		if ((param[0] <= 0xFF) && (rc == 0)) {
			reg_idx[0] = param[0];
			tfa9887_i2c_read(&read_data, 1);
		} else
			rc = -EINVAL;
	}

	if (rc == 0)
		rc = cnt;
	else
		pr_err("%s: rc = %d\n", __func__, rc);

	return rc;
}
Exemplo n.º 2
0
void set_tfa9887_config()
{
    tfa9887_i2c_write(config_seq1[0], 1);
    tfa9887_i2c_write(config_seq2[0], 1);
    tfa9887_i2c_write(config_seq3[0], 1);
    tfa9887_i2c_write(config_seq4[0], 3);
    tfa9887_i2c_write(config_seq5[0], 3);
    tfa9887_i2c_write(config_seq6[0], 8);
    tfa9887_i2c_write(config_seq7[0], 253);
    tfa9887_i2c_write(config_seq8[0], 172);
    tfa9887_i2c_write(config_seq9[0], 3);
    tfa9887_i2c_write(config_seq10[0], 1);
    tfa9887_i2c_write(config_seq11[0], 5);
    tfa9887_i2c_write(config_seq12[0], 1);
    tfa9887_i2c_write(config_seq13[0], 1);
    tfa9887_i2c_write(config_seq14[0], 1);
    tfa9887_i2c_write(config_seq15[0], 3);
    tfa9887_i2c_write(config_seq16[0], 3);
}