Beispiel #1
0
static int sensor_report_value(struct i2c_client *client)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	//char msb = 0, lsb = 0;
	char data[2] = {0};
	unsigned short value = 0;
	int index = 0;
	
	//sensor->client->addr = CM3232_ADDR_DATA;
	data[0] = CM3232_ADDR_DATA;
	sensor_rx_data(sensor->client, data, 2);
	value = (data[1] << 8) | data[0] ;

	DBG("%s:result=%d\n",__func__,value);
	//printk("%s:result=%d\n",__func__,value);
	index = light_report_value(sensor->input_dev, value);	
	DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, value,index);

	if((sensor->pdata->irq_enable)&& (sensor->ops->int_status_reg >= 0))	//read sensor intterupt status register
	{
		
		result= sensor_read_reg(client, sensor->ops->int_status_reg);
		if(result)
		{
			printk("%s:fail to clear sensor int status,ret=0x%x\n",__func__,result);
		}
	}
	
	return result;
}
Beispiel #2
0
static int sensor_report_value(struct i2c_client *client)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	char msb = 0, lsb = 0;
	
	sensor->client->addr = CM3217_ADDR_DATA_LSB;
	sensor_rx_data_normal(sensor->client, &lsb, 1);
	sensor->client->addr = CM3217_ADDR_DATA_MSB;
	sensor_rx_data_normal(sensor->client, &msb, 1);
	result = ((msb << 8) | lsb) & 0xffff;
	
	DBG("%s:result=%d\n",__func__,result);
	light_report_value(sensor->input_dev, result);

	if((sensor->pdata->irq_enable)&& (sensor->ops->int_status_reg >= 0))	//read sensor intterupt status register
	{
		
		result= sensor_read_reg(client, sensor->ops->int_status_reg);
		if(result)
		{
			printk("%s:fail to clear sensor int status,ret=0x%x\n",__func__,result);
		}
	}
	
	return result;
}
static int sensor_report_value(struct i2c_client *client)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	int value = 0;
	char buffer[2] = {0};	
	char index = 0;
	
	if(sensor->ops->read_len < 2)	//sensor->ops->read_len = 2
	{
		printk("%s:lenth is error,len=%d\n",__func__,sensor->ops->read_len);
		return -1;
	}
	
	memset(buffer, 0, 2);

	buffer[0] = sensor->ops->read_reg;
	result = sensor_rx_data(client, buffer, sensor->ops->read_len);	
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}

	value = (buffer[0] << 8) | buffer[1];

	
	index = light_report_value(sensor->input_dev, value);

	DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, value,index);
	
	if(sensor->pdata->irq_enable)
	{
		if(sensor->ops->int_status_reg)
		{	
			value = sensor_read_reg(client, sensor->ops->int_status_reg);
		}
		
		if(value & STA_ALS_INT)
		{
			value &= ~STA_ALS_INT;
			result = sensor_write_reg(client, sensor->ops->int_status_reg,value);	//clear int
			if(result)
			{
				printk("%s:line=%d,error\n",__func__,__LINE__);
				return result;
			}
		}
	}
	
			
	return result;
}
Beispiel #4
0
static int sensor_report_value(struct i2c_client *client)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	int index = 0;

	cm3218_read_lux(client,&result);
	
	index = light_report_value(sensor->input_dev, result);
	DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, result,index);
	
	if((sensor->pdata->irq_enable)&& (sensor->ops->int_status_reg >= 0))	//read sensor intterupt status register
	{
		
		result= sensor_read_reg(client, sensor->ops->int_status_reg);
		if(result)
		{
			printk("%s:fail to clear sensor int status,ret=0x%x\n",__func__,result);
		}
	}
	
	return result;
}
Beispiel #5
0
static int sensor_report_value(struct i2c_client *client)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	char value = 0;
	char index = 0;
	
	if(sensor->pdata->irq_enable)
	{
		if(sensor->ops->int_status_reg)
		{
			value = sensor_read_reg(client, sensor->ops->int_status_reg);
		}
		
	}

	value = sensor_read_reg(client, sensor->ops->read_reg);
	index = light_report_value(sensor->input_dev, value&0x3f); // bit0-5  is ls data;
	
	DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, value,index);
	
	return result;
}