Exemple #1
0
static void cm3663_work_func_light(struct work_struct *work)
{
	int i;
	int als;
	struct cm3663_data *cm3663 = container_of(work, struct cm3663_data,
					      work_light);

	als = lightsensor_get_alsvalue(cm3663);

	for (i = 0; ARRAY_SIZE(adc_table); i++)
		if (als <= adc_table[i])
			break;

	if (cm3663->light_buffer == i) {
		if (cm3663->light_count++ == LIGHT_BUFFER_NUM) {
			input_report_abs(cm3663->light_input_dev,
							ABS_MISC, als + 1);
			input_sync(cm3663->light_input_dev);
			cm3663->light_count = 0;
		}
	} else {
		cm3663->light_buffer = i;
		cm3663->light_count = 0;
	}
}
/*
 * sysfs interface
 * return the lux value calculated using adc/lux table.
 */
static ssize_t cm3663_light_sensor_lux_show(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	struct cm3663_data *cm3663 = dev_get_drvdata(dev);
	return sprintf(buf, "%d\n",
		lightsensor_get_alsvalue(cm3663));
}
/*
 * work function for light sensor
 * it get the current adc value from the sensor and
 * get lux value using adc/lux table.
 * if there was a change of boundary, it will notify the event.
 */
static void cm3663_work_func_light(struct work_struct *work)
{
	int als;
	struct cm3663_data *cm3663 =
		container_of(work, struct cm3663_data, work_light);
	int i = 0;

	als = lightsensor_get_alsvalue(cm3663);

	input_report_abs(cm3663->light_input_dev,
			ABS_MISC, als+1);
	input_sync(cm3663->light_input_dev);
}
Exemple #4
0
static void cm3663_work_func_light(struct work_struct *work)
{
	int als;
	struct cm3663_data *cm3663 = container_of(work, struct cm3663_data,
					      work_light);

	als = lightsensor_get_alsvalue(cm3663);
        input_report_rel(cm3663->light_input_dev, REL_MISC, als+1);
	input_sync(cm3663->light_input_dev);

	if (lightval_logcount++ > 500) {
        	printk(KERN_INFO "[CM3663] light value = %d \n", als+1);
		lightval_logcount = 0;
	}          
}
Exemple #5
0
static ssize_t lightsensor_file_state_show(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	struct cm3663_data *cm3663 = dev_get_drvdata(dev);
	int adc = 0;

	if (!(cm3663->power_state & LIGHT_ENABLED))
		cm3663_light_enable(cm3663);

	adc = lightsensor_get_alsvalue(cm3663);

	if (!(cm3663->power_state & LIGHT_ENABLED))
		cm3663_light_disable(cm3663);

	return sprintf(buf, "%d\n", adc);
}
static void cm3663_work_func_light(struct work_struct *work)
{
	int als;
	struct cm3663_data *cm3663 = container_of(work, struct cm3663_data,
					      work_light);

	als = lightsensor_get_alsvalue(cm3663);
#if defined(CONFIG_MACH_S2PLUS)
	input_report_rel(cm3663->light_input_dev,
					REL_MISC, als + 1);
#else
	input_report_abs(cm3663->light_input_dev,
					ABS_MISC, als + 1);
#endif
	input_sync(cm3663->light_input_dev);
}