Пример #1
0
static int find_down_level(LinphoneQoslevel *oldlevel, LinphoneQoslevel *level) {
    const LinphoneQoslevel *cur_level = getcurent_level(oldlevel->fps, oldlevel->size);
    const LinphoneQoslevel *lower_level;

    lower_level = get_next_level(cur_level);
    if (lower_level) {
        *level = *lower_level;
        if (level->max_bit > oldlevel->max_bit)
            level->max_bit = oldlevel->max_bit;
        return 0;
    }

    if (cur_level) {
        if ((oldlevel->fps > cur_level->fps) || (oldlevel->size > cur_level->size) || (oldlevel->max_bit > cur_level->max_bit)) {
            *level = *cur_level;
            if (level->max_bit > oldlevel->max_bit)
                level->max_bit = oldlevel->max_bit;
            return 0;
        }

        if (oldlevel->max_bit > cur_level->min_bit) {
            *level = *oldlevel;
            level->max_bit = cur_level->min_bit;
            return 0;
        }
    }

    return 1;
}
Пример #2
0
/*For Factory Test Mode*/
static ssize_t lightsensor_file_state_show(struct device *dev, struct device_attribute *attr, char *buf)
{	
	struct bh1721_data *bh1721 = dev_get_drvdata(dev);
	unsigned int result;
	/* 
	 * POWER ON command is possible to omit.
	 */
	printk("[%s] lightsensor_file_state_show \n", __func__);	

	bh1721_write_command(bh1721->i2c_client, &POWER_ON);
	bh1721_write_command(bh1721->i2c_client, &H_RESOLUTION_2);

	/* Maximum measurement time */
	msleep(180);
	
	bh1721_read_value(bh1721->i2c_client, bh1721->illuminance_data);
	bh1721_write_command(bh1721->i2c_client, &POWER_DOWN);

	result = bh1721->illuminance_data[0] << 8 | bh1721->illuminance_data[1];
	result = (result*10)/12;
	
	/* apply hysteresis */
	printk("[%s] original lux = %u\n", __func__, result);	
	result = get_next_level(result);	
	printk("[%s] representative lux = %u\n", __func__, result);
	
	return sprintf(buf, "%d\n", result);
}
Пример #3
0
static unsigned int lightsensor_get_adcvalue(struct bh1721_data *bh1721)
{
	unsigned int result;
	bh1721_write_command(bh1721->i2c_client, &H_RESOLUTION_2);

	/* Maximum measurement time */
	msleep(180);
	bh1721_read_value(bh1721->i2c_client, bh1721->illuminance_data);
	
	result = bh1721->illuminance_data[0] << 8 | bh1721->illuminance_data[1];
	result = (result*10)/12;

	result = get_next_level(result);	
	return result;
}