Exemple #1
0
/** Handle lux value changed event
 *
 * @param lux ambient light value
 */
static void als_lux_changed(unsigned lux)
{
	als_lux_latest = (int)lux;

	mce_log(LL_DEBUG, "lux=%d", als_lux_latest);
	run_datapipes();
}
Exemple #2
0
/** Get filtered ALS state and feed it to datapipes
 *
 * @param lux  sensor reading, or -1 for no-data
 */
static void inputflt_sampling_output(int lux)
{
	lux = inputflt_filter(lux);

	if( als_lux_latest == lux )
		goto EXIT;

	mce_log(LL_DEBUG, "output: %d -> %d", als_lux_latest, lux);

	als_lux_latest = lux;

	run_datapipes();

	execute_datapipe(&ambient_light_sensor_pipe,
			 GINT_TO_POINTER(als_lux_latest),
			 USE_INDATA, CACHE_INDATA);
EXIT:
	return;
}
Exemple #3
0
/** Check if ALS sensor should be enabled or disabled
 */
static void rethink_als_status(void)
{
	static gboolean enable_old = FALSE;

	gboolean enable_new = FALSE;
	gboolean want_data  = FALSE;

	if( !have_als )
		goto EXIT;

	if( use_als_flag ) {
		switch( display_state_next ) {
		case MCE_DISPLAY_ON:
		case MCE_DISPLAY_DIM:
		case MCE_DISPLAY_POWER_UP:
		case MCE_DISPLAY_LPM_OFF:
		case MCE_DISPLAY_LPM_ON:
			want_data = TRUE;
			break;

		default:
		case MCE_DISPLAY_POWER_DOWN:
		case MCE_DISPLAY_OFF:
		case MCE_DISPLAY_UNDEF:
			want_data = FALSE;
			break;
		}
	}

	if( want_data )
		enable_new = TRUE;

	mce_log(LL_DEBUG, "use=%d, want=%d -> enable=%d",
		use_als_flag, want_data, enable_new);

	if( want_data ) {
		/* The sensor has been off for some time, so the
		 * history needs to be forgotten when we get fresh
		 * data */
		inputflt_flush_on_change();

		/* Enable change notifications */
		mce_sensorfw_als_set_notify(als_lux_changed);
	}
	else {
		/* Disable change notifications */
		mce_sensorfw_als_set_notify(0);

		/* Force cached value re-evaluation */
		als_lux_changed(-1);

		/* Stop sampling timer */
		inputflt_sampling_stop();
	}

	if( enable_old == enable_new )
		goto EXIT;

	enable_old = enable_new;

	if( enable_new ) {
		mce_sensorfw_als_enable();
	}
	else {
		mce_sensorfw_als_disable();

		/* Clear thresholds so that the next reading from
		 * als will not be affected by previous state */
		als_filter_clear_threshold(&lut_display);
		als_filter_clear_threshold(&lut_led);
		als_filter_clear_threshold(&lut_key);
		als_filter_clear_threshold(&lut_lpm);
	}

	run_datapipes();
EXIT:
	return;
}
Exemple #4
0
/** Check if ALS sensor should be enabled or disabled
 */
static void rethink_als_status(void)
{
	static gboolean enable_old = FALSE;

	gboolean enable_new = FALSE;
	gboolean want_data  = FALSE;

	if( !have_als )
		goto EXIT;

	if( use_als_flag ) {
		switch( display_state ) {
		case MCE_DISPLAY_ON:
		case MCE_DISPLAY_DIM:
			want_data = TRUE;
			break;

		default:
		case MCE_DISPLAY_OFF:
		case MCE_DISPLAY_LPM_OFF:
		case MCE_DISPLAY_LPM_ON:
		case MCE_DISPLAY_UNDEF:
			want_data = FALSE;
			break;
		}
	}

	if( want_data || ext_als_enablers  )
		enable_new = TRUE;

	mce_log(LL_DEBUG, "use=%d, want=%d ext=%d -> enable=%d",
		use_als_flag, want_data, ext_als_enablers ? 1 : 0,
		enable_new);

	if( want_data )
		mce_sensorfw_als_set_notify(als_lux_changed);
	else
		mce_sensorfw_als_set_notify(0);

	if( enable_old == enable_new )
		goto EXIT;

	enable_old = enable_new;

	if( enable_new ) {
		mce_sensorfw_als_enable();
	}
	else {
		mce_sensorfw_als_disable();

		/* Clear thresholds so that the next reading from
		 * als will not be affected by previous state */
		als_filter_clear_threshold(&lut_display);
		als_filter_clear_threshold(&lut_led);
		als_filter_clear_threshold(&lut_key);
	}

	run_datapipes();
EXIT:
	return;
}