Ejemplo n.º 1
0
static ssize_t anx7808_write_reg_store(struct device *dev, struct device_attribute *attr,
		 const char *buf, size_t count)
{
	int ret = 0;
	char op, i;
	char r[3];
	char v[3];
	unchar tmp;
	int id, reg, val = 0 ;

	if (sp_tx_system_state != STATE_PLAY_BACK) {
		pr_err("%s: error!, Not STATE_PLAY_BACK\n", LOG_TAG);
		return -EINVAL;
	}

	if (count != 7 && count != 5) {
		pr_err("%s: cnt:%d, invalid input!\n", LOG_TAG, count-1);
		pr_err("%s: ex) 05df   -> op:0(read)  id:5 reg:0xdf \n", LOG_TAG);
		pr_err("%s: ex) 15df5f -> op:1(wirte) id:5 reg:0xdf val:0x5f\n", LOG_TAG);
		return -EINVAL;
	}

	ret = snprintf(&op, 2, buf);
	ret = snprintf(&i, 2, buf+1);
	ret = snprintf(r, 3, buf+2);

	id = simple_strtoul(&i, NULL, 10);
	reg = simple_strtoul(r, NULL, 16);

	if ((id != 0 && id != 1 && id != 5 && id != 6 && id != 7)) {
		pr_err("%s: invalid addr id! (id:0,1,5,6,7)\n", LOG_TAG);
		return -EINVAL;
	}

	id = anx7808_id_change(id); /* ex) 5 -> 0x72 */

	switch (op) {

	case 0x30: /* "0" -> read */
		sp_read_reg(id, reg, &tmp);
		pr_info("%s: anx7808 read(0x%x,0x%x)= 0x%x \n", LOG_TAG, id, reg, tmp);
		break;

	case 0x31: /* "1" -> write */
		ret = snprintf(v, 3, buf+4);
		val = simple_strtoul(v, NULL, 16);

		sp_write_reg(id, reg, val);
		sp_read_reg(id, reg, &tmp);
		pr_info("%s: anx7808 write(0x%x,0x%x,0x%x)\n", LOG_TAG, id, reg, tmp);
		break;

	default:
		pr_err("%s: invalid operation code! (0:read, 1:write)\n", LOG_TAG);
		return -EINVAL;
	}

	return count;
}
Ejemplo n.º 2
0
static int write_swing_function(const char *val, struct kernel_param *kp)
{
	int ret=0;
	unchar c=0;
	int old_val = write_swing_value;
	//struct anx7808_platform_data *pdata = anx7808_client->dev.platform_data;
	if (ret)
		return ret;

	if (write_swing_value > 0xf)  {
		write_swing_value = old_val;
		return -EINVAL;
	}


	ret = param_set_int(val, kp);
	if (write_swing_value ==1){
		sp_write_reg(TX_P0, 0xa3, write_swing_value);
		printk("TX_P0  0xa3: %x\n",write_swing_value);
	}
	else if (write_swing_value==2)
	{
		g_dump_7808_reg = 1;		
	}
	else if (write_swing_value==3) 
	{
		g_dump_7808_reg = 0;		
	}	
	else if (write_swing_value ==4)
	{
                sp_tx_aux_dpcdread_bytes(0x00, 0x02, 0x06, 1, &c);
                printk("sp_tx_config_hdmi_pad , ADJUST_REQUEST_LANE0_1 = 0x%x\n", c);		
	}	
	else if(write_swing_value==5){
		sp_tx_aux_dpcdread_bytes(0x00, 0x01, 0x03, 1, &c);		
		printk("DPCD , LANE0_SET = 0x%x\n", c);	
	}
	
	return 0;
}