Ejemplo n.º 1
0
/**
 * Init function for the modetransition component
 *
 * @return TRUE on success, FALSE on failure
 */
gboolean mce_mode_init(void)
{
	gboolean status = FALSE;

	/* Append triggers/filters to datapipes */
	mce_mode_datapipe_init();

	/* If the bootup file exists, mce has crashed / restarted;
	 * since it exists in /var/run it will be removed when we reboot.
	 *
	 * If the file doesn't exist, create it to ensure that
	 * restarting mce doesn't get mce stuck in the transition submode
	 */
	if (g_access(MCE_BOOTUP_FILENAME, F_OK) == -1) {
		if (errno == ENOENT) {
			mce_log(LL_DEBUG, "Bootup mode enabled");
			mce_add_submode_int32(MCE_SUBMODE_TRANSITION);
			errno = 0;

			mce_write_string_to_file(MCE_BOOTUP_FILENAME,
						 ENABLED_STRING);

			if (g_access(MALF_FILENAME, F_OK) == 0) {
				mce_add_submode_int32(MCE_SUBMODE_MALF);
				mce_log(LL_DEBUG, "Malf mode enabled");
				if (g_access(MCE_MALF_FILENAME, F_OK) == -1) {
					if (errno != ENOENT) {
						mce_log(LL_CRIT,
							"access() failed: %s. Exiting.",
							g_strerror(errno));
						goto EXIT;
					}

					mce_write_string_to_file(MCE_MALF_FILENAME,
								 ENABLED_STRING);
				}
			}
		} else {
			mce_log(LL_CRIT,
				"access() failed: %s. Exiting.",
				g_strerror(errno));
			goto EXIT;
		}
	} else {
		if (g_access(MALF_FILENAME, F_OK) == 0) {
			if (g_access(MCE_MALF_FILENAME, F_OK) == 0) {
				mce_add_submode_int32(MCE_SUBMODE_MALF);
				mce_log(LL_DEBUG, "Malf mode enabled");
			}
		} else if ((errno == ENOENT) &&
			   (g_access(MCE_MALF_FILENAME, F_OK) == 0)) {
			g_remove(MCE_MALF_FILENAME);
		}
	}

	status = TRUE;

EXIT:
	return status;
}
Ejemplo n.º 2
0
/** Allow/deny touch panel to enter sleep mode
 *
 * @param allow true to allow touch to sleep, false to deny
 */
static void dbltap_allow_sleep_mode(bool allow)
{
        /* Initialized not to match any bool value  */
        static int allowed = -1;

        /* Whether or not this function gets called depends on the
         * availability of dbltap_ctrl_path, so we need to check that
         * sleep_mode_ctrl_path and related values are also configured
         * and available */

        if( !sleep_mode_ctrl_path )
                goto EXIT;

        if( !sleep_mode_allow_val || !sleep_mode_deny_val )
                goto EXIT;

        if( allowed == allow )
                goto EXIT;

        allowed = allow;

        mce_log(LL_DEBUG, "touch panel sleep mode %s",
                allowed ? "allowed" : "denied");

        mce_write_string_to_file(sleep_mode_ctrl_path,
                                 allowed ?
                                 sleep_mode_allow_val :
                                 sleep_mode_deny_val);

EXIT:
        return;
}
Ejemplo n.º 3
0
/** Enable/disable doubletap wakeups
 *
 * @param state disable/enable/disable-without-powering-off
 */
static void dbltap_set_state(dt_state_t state)
{
        static dt_state_t prev_state = DT_UNDEF;

        bool allow_sleep_mode = true;

        if( prev_state == state )
                goto EXIT;

        prev_state = state;

        mce_log(LL_DEBUG, "double tap wakeups: %s", dt_state_name[state]);

        const char *val = 0;

        switch( state ) {
        case DT_DISABLED:
                val = dbltap_disable_val;
                break;
        case DT_ENABLED:
                val = dbltap_enable_val;
                break;
        case DT_DISABLED_NOSLEEP:
                val = dbltap_disable_val;
                allow_sleep_mode = false;
                break;
        default:
                break;
        }

        if( val ) {
                dbltap_allow_sleep_mode(allow_sleep_mode);
                mce_write_string_to_file(dbltap_ctrl_path, val);
        }
EXIT:
        return;
}