Ejemplo n.º 1
0
static void bh1721fvc_work_func_light(struct work_struct *work)
{
	int err;
	u16 lux;
	static int cnt = 0;
	unsigned int result = 0;
	
	struct bh1721fvc_data *bh1721fvc = container_of(work,
					struct bh1721fvc_data, work_light);

	err = bh1721fvc_get_luxvalue(bh1721fvc, &lux);
	if (err ==0)
	{
		result = (lux * 10) / 12;
		result = result * 139 / 13;
		if(result > 65000) result = 65000;
			
		bh1721fvc_dbmsg("lux 0x%0X (%d)\n", result, result);
		input_report_abs(bh1721fvc->input_dev, ABS_MISC, result);
		input_sync(bh1721fvc->input_dev);
	} else {
		pr_err("%s: read word failed! (errno=%d)\n", __func__, err);
	}

#if defined(CONFIG_MACH_SAMSUNG_P5)
	if(result == 0) cnt++;
	else cnt =0;
	
	if(cnt > 25)
	{
		cnt = 0;
		printk("Lux Value : 0 during 5 sec...\n");
		bh1721fvc_reset(bh1721fvc);
	}
#endif

}
Ejemplo n.º 2
0
static void bh1721fvc_work_func_light(struct work_struct *work)
{
    int i;
    int err;
    u16 lux;
    unsigned int result = 0;
    struct bh1721fvc_data *bh1721fvc =
        container_of(work, struct bh1721fvc_data, work_light);

    err = bh1721fvc_get_luxvalue(bh1721fvc, &lux);

    /*
     *	result = (lux * 10) / 12;
     *	result = result * 139 / 13;
     */
    result = (lux * 89) / 10;
    if (result <= 8)
        result = 0;

#if defined(CONFIG_MACH_SAMSUNG_P5)
    if (result > 69000)
        result = 69000;
#else
    if (result > 60000)
        result = 60000;
#endif

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

    if (bh1721fvc->light_buffer == i) {
        if (bh1721fvc->light_count++ >= bh1721fvc->light_buffer_cnt) {
            bh1721fvc_dbmsg("lux 0x%0X (%d)\n", result, result);
            input_report_rel(bh1721fvc->input_dev,
                             REL_MISC, result+1);
            input_sync(bh1721fvc->input_dev);
            bh1721fvc->light_level_state = i;
            bh1721fvc->light_count = 0;
        }
    } else {
        bh1721fvc->light_buffer = i;
        bh1721fvc->light_count = 0;

        if (bh1721fvc->light_level_state >= i)
            bh1721fvc->light_buffer_cnt = LIGHT_DOWNWORD_BUFFER;
        else
            bh1721fvc->light_buffer_cnt = LIGHT_UPWORD_BUFFER;
    }
#else
    input_report_rel(bh1721fvc->input_dev, REL_MISC, result+1);
    input_sync(bh1721fvc->input_dev);
#endif

#if defined(CONFIG_MACH_SAMSUNG_P5)
    if (result == 0) {
        if (bh1721fvc->zero_cnt++ > 25) {
            bh1721fvc->zero_cnt = 0;
            if (bh1721fvc->reset_cnt++ <= LIMIT_RESET_COUNT)
                bh1721fvc_reset(bh1721fvc);
            else
                bh1721fvc->reset_cnt == LIMIT_RESET_COUNT + 1;
        }
    } else {
        bh1721fvc->reset_cnt = 0;
        bh1721fvc->zero_cnt = 0;
    }
#endif
}