Ejemplo n.º 1
0
void eQEP::defaultSettings() {
  // Set all options off
  setDecoderControl(0);
  // Enable the eQEP unit
  setControl(EQEP_QEPCTL_PHEN);
  // Set all options off
  setCaptureControl(0);
  // Set all options off
  setPositionCompareControl(0);
  // Default to no interrupts enabled.
  setInterruptEnable(0);
  // Clear all of the interrupts.
  setInterruptClear(EQEP_INT_ENABLE_ALL);
  // Clear all of the sticky bits.
  setStatus(EQEP_QEPSTS_COEF | EQEP_QEPSTS_CDEF | EQEP_QEPSTS_FIMF);
  // Set the Max Position to the maximum possible.
  setMaxPos(-1);
}
Ejemplo n.º 2
0
/**
 * Disable Position Counter Error Interrupt
**/
void eQEP::disablePositionCounterErrorInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_PCE);
}
Ejemplo n.º 3
0
/**
 * Disable Unit Timeout Interrupt
**/
void eQEP::disableQuadraturePhaseErrorInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_PHE);
}
Ejemplo n.º 4
0
/**
 * Disable Quadrature Direction Change Interrupt
**/
void eQEP::disableQuadratureDirectionChangeInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_QDC);
}
Ejemplo n.º 5
0
/**
 * Disable Watchdog Time Out Interrupt
**/
void eQEP::disableWatchdogTimeOutInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_WTO);
}
Ejemplo n.º 6
0
/**
 * Disable Position Counter Underflow Interrupt
**/
void eQEP::disablePositionCounterUnderflowInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_PCU);
}
Ejemplo n.º 7
0
/* Main
 */
Tohkbd::Tohkbd(QObject *parent) :
       QObject(parent)
{
    dbusRegistered = false;
    interruptsEnabled = false;
    vddEnabled = false;
    capsLockSeq = 0;
    vkbLayoutIsTohkbd = false;
    currentActiveLayout = QString();
    currentOrientationLock = QString();
    keypadIsPresent = false;
    gpio_fd = -1;
    displayIsOn = false;
    keyIsPressed = false;
    keyRepeat = false;
    slideEventEmitted = false;
    taskSwitcherVisible = false;
    ssNotifyReplacesId = 0;
    ssFilename = QString();

    tohkbd2user = new QDBusInterface("com.kimmoli.tohkbd2user", "/", "com.kimmoli.tohkbd2user", QDBusConnection::sessionBus(), this);
    tohkbd2user->setTimeout(2000);

    thread = new QThread();
    worker = new Worker();

    worker->moveToThread(thread);
    connect(worker, SIGNAL(gpioInterruptCaptured()), this, SLOT(handleGpioInterrupt()));
    connect(worker, SIGNAL(workRequested()), thread, SLOT(start()));
    connect(thread, SIGNAL(started()), worker, SLOT(doWork()));
    connect(worker, SIGNAL(finished()), thread, SLOT(quit()), Qt::DirectConnection);

    backlightTimer = new QTimer(this);
    backlightTimer->setSingleShot(true);
    connect(backlightTimer, SIGNAL(timeout()), this, SLOT(backlightTimerTimeout()));

    presenceTimer = new QTimer(this);
    presenceTimer->setInterval(2000);
    presenceTimer->setSingleShot(true);
    connect(presenceTimer, SIGNAL(timeout()), this, SLOT(presenceTimerTimeout()));

    repeatTimer = new QTimer(this);
    repeatTimer->setSingleShot(true);
    connect(repeatTimer, SIGNAL(timeout()), this, SLOT(repeatTimerTimeout()));

    /* do this automatically at startup */
    setVddState(true);
    setInterruptEnable(true);

    uinputif = new UinputIf();
    uinputif->openUinputDevice();

    tca8424 = new tca8424driver(0x3b);
    keymap = new keymapping();

    FKEYS.clear();
    FKEYS.append(KEY_F1);
    FKEYS.append(KEY_F2);
    FKEYS.append(KEY_F3);
    FKEYS.append(KEY_F4);
    FKEYS.append(KEY_F5);
    FKEYS.append(KEY_F6);
    FKEYS.append(KEY_F7);
    FKEYS.append(KEY_F8);
    FKEYS.append(KEY_F9);
    FKEYS.append(KEY_F10);
    FKEYS.append(KEY_F11);
    FKEYS.append(KEY_F12);

    reloadSettings();

    if (currentActiveLayout.isEmpty())
        changeActiveLayout(true);

    if (currentOrientationLock.isEmpty())
    {
        changeOrientationLock(true);
        saveOrientation();
    }

    checkKeypadPresence();

    connect(keymap, SIGNAL(shiftChanged()), this, SLOT(handleShiftChanged()));
    connect(keymap, SIGNAL(ctrlChanged()), this, SLOT(handleCtrlChanged()));
    connect(keymap, SIGNAL(altChanged()), this, SLOT(handleAltChanged()));
    connect(keymap, SIGNAL(symChanged()), this, SLOT(handleSymChanged()));
    connect(keymap, SIGNAL(keyPressed(QList< QPair<int, int> >)), this, SLOT(handleKeyPressed(QList< QPair<int, int> >)));
    connect(keymap, SIGNAL(keyReleased()), this, SLOT(handleKeyReleased()));

}
Ejemplo n.º 8
0
os_status osHwiMultiplexedDelete(os_hwi_handle     hwi_num,
                      os_hwi_function   handler,
                      os_hwi_arg        argument)
{

    os_status status = OS_SUCCESS;
    multiplexed_hwi_t *this_int = NULL, *iterator, *head;
 
#ifdef HWI_ERROR_CHECKING
 
    // Can't remove during active hwi - risk of corrupting active list
    if (g_os_flags & OS_FLG_HWI_ACTIVE)
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        RETURN_ERROR(OS_FAIL);
    }
    if (hwi_num > OS_INT_LAST)
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        RETURN_ERROR(OS_ERR_HWI_INVALID);
    }
 
    if (interrupt_pointer[hwi_num] != osHwiMultiplexedHandler)
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        RETURN_ERROR(OS_ERR_HWI_COMMAND_INVALID);
    }
#endif // HWI_ERROR_CHECKING
 
    osHwiSwiftDisable();
    head = (multiplexed_hwi_t *)interrupt_argument[hwi_num];
 
    for (iterator = head ; iterator != NULL ; iterator = iterator->next)
    {
        if ((iterator->argument == argument) && (iterator->handler == handler))
        {
#ifdef HWI_ERROR_CHECKING
            if (iterator->valid != TRUE)
            {
#ifdef HWI_ERROR_ASSERT
                OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
                status = OS_ERR_ALREADY_FREE;
                REPORT_ERROR(status);
                goto exit_func;
            }
#endif // HWI_ERROR_CHECKING
            this_int = iterator;
            this_int->valid = FALSE;
 
            /* Put this_int at the end of the list. Ensures requirement
             * in osHwiMultiplexedHandler() */
 
            // If first in list
            if (this_int == head)
            {
                // If not single entry in list
                if (this_int->next != NULL)
                {
                    interrupt_argument[hwi_num] = (os_hwi_arg)(this_int->next);
                    move_to_end(iterator, this_int);
                }
                else
                {
                    setInterruptEnable(hwi_num, FALSE);
                }
            }
            // If not already last in list
            if (this_int->next != NULL)
            {
                iterator = head;
                while (iterator->next != this_int)
                {
                    iterator = iterator->next;
                }
                iterator->next = this_int->next;
                move_to_end(iterator, this_int);
            }
            break;
 
        }
    }
 
 
exit_func:
    osHwiSwiftEnable();
    return status;
 
}
Ejemplo n.º 9
0
/**
 * Disable Position Compare Match Interrupt
**/
void eQEP::disablePositionCompareMatchInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_PCM);
}
Ejemplo n.º 10
0
/**
 * Disable Strobe Event Latch Interrupt
**/
void eQEP::disableStrobeEventLatchInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_SEL);
}
Ejemplo n.º 11
0
/**
 * Disable Index Event Latch Interrupt
**/
void eQEP::disableIndexEventLatchInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_IEL);
}
Ejemplo n.º 12
0
/**
 * Disable Unit Timeout Interrupt
**/
void eQEP::disableUnitTimeoutInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_UTO);
}
Ejemplo n.º 13
0
/**
 * Enable Unit Timeout Interrupt
**/
void eQEP::enableUnitTimeoutInterrupt() {
  setInterruptEnable(getInterruptEnable() | EQEP_INT_UTO);
}
Ejemplo n.º 14
0
os_status osHwiCreate(os_hwi_handle     hwi_num,
                      os_hwi_priority   priority,
                      os_hwi_mode       mode,
                      os_hwi_function   handler,
                      os_hwi_arg        argument)
{
    uint16_t        index;
    uint32_t        mode_bit;
    uint32_t        *trigger_reg_ptr;
    uint32_t        trigger_reg;

    /* handle the mode register ELRx */
    index = (uint16_t)((hwi_num - 18) >> 5);          
    trigger_reg_ptr = (uint32_t *)((g_dsp_plat_map->epic).p_elr);
    trigger_reg_ptr += index;

    mode_bit = (uint32_t)(0x00000001 << ((hwi_num - 18) & 0x001F));
    if (mode == LEVEL_MODE)
    {
        READ_UINT32(trigger_reg, *trigger_reg_ptr);
        trigger_reg &= ~mode_bit;
        WRITE_UINT32(*trigger_reg_ptr, trigger_reg);
    }
    else if(mode == EDGE_MODE)
    {
        READ_UINT32(trigger_reg, *trigger_reg_ptr);
        trigger_reg |= mode_bit;
        WRITE_UINT32(*trigger_reg_ptr, trigger_reg);
    }

    /* create hwi task using phoenix API */
    (void)os_create_task(PHOENIX_TSK_INTTASK,
					   (PHOENIX_TSKFUNC)handler,
					   0,
					   hwi_num,
					   0,
					   priority,
					   (PHOENIX_INTVECTOR)(hwi_num - 18));

    /* Store handler into table */
    interrupt_pointer[hwi_num] = handler;
    if (hwi_num == OS_INT_ORED_GENERAL)
        interrupt_argument[hwi_num] = (os_hwi_arg)general_ored_interrupt;
    else if (hwi_num == OS_INT_ORED_DEBUG)
        interrupt_argument[hwi_num] = (os_hwi_arg)debug_ored_interrupt;
    else if (hwi_num == OS_INT_ORED_MAPLE)
        interrupt_argument[hwi_num] = (os_hwi_arg)maple_ored_interrupt;
    else
        interrupt_argument[hwi_num] = argument;

    return OS_SUCCESS; 
   
#if 0
    os_status       status = OS_SUCCESS;
    os_hwi_status   int_status;
    uint16_t        index;
    uint32_t        pending_bit, mode_bit;
    uint32_t        *pending_reg_ptr, *trigger_reg_ptr;
    uint32_t        trigger_reg;
    os_hwi_handle   epic_hwi_num = 0;
 
#ifdef HWI_ERROR_CHECKING
    if ( (priority > OS_HWI_LAST_PRIORITY) && (priority != OS_HWI_PRIORITY_NMI) )
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        RETURN_ERROR(OS_ERR_HWI_PRIORITY_INVALID);
    }
    if (handler == NULL)
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        RETURN_ERROR(OS_ERR_HWI_FUNCTION_INVALID);
    }
    if (HWI_INVALID_MODE(mode))
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        if(priority != 0) //meaning disable only
        {
            RETURN_ERROR(OS_ERR_HWI_MODE_INVALID);
        }
    }
#endif /* HWI_ERROR_CHECKING */

    if (hwi_num > OS_INT_LAST)
    {
        if(hwi_num > OS_INT_GEN_LAST)
        {
#ifdef HWI_ERROR_ASSERT
            OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
            RETURN_ERROR(OS_ERR_HWI_INVALID);
        }
        else
        {
            return osHwiCreateGeneral(hwi_num,handler,argument);
        }
    }

    if ( (priority > 0) && (priority != OS_HWI_PRIORITY_NMI) )
        priority = (os_hwi_priority)((OS_HWI_LAST_PRIORITY + 1) - priority);

    int_status = osHwiDisable();

#ifdef HWI_LOGGING
    if (priority != OS_HWI_PRIORITY_NMI)
        osLog(LOG_HWI_CREATE, (uint32_t)(((OS_HWI_LAST_PRIORITY - priority)<<16) | (hwi_num)));
    else
        osLog(LOG_HWI_CREATE, (uint32_t)(((0xFFFF)<<16) | (hwi_num))); /* for NMI interrupts */
#endif

    /* Store handler into table */
    interrupt_pointer[hwi_num] = handler;
    if (hwi_num == OS_INT_ORED_GENERAL)
        interrupt_argument[hwi_num] = (os_hwi_arg)general_ored_interrupt;
    else if (hwi_num == OS_INT_ORED_DEBUG)
        interrupt_argument[hwi_num] = (os_hwi_arg)debug_ored_interrupt;
    else if (hwi_num == OS_INT_ORED_MAPLE)
        interrupt_argument[hwi_num] = (os_hwi_arg)maple_ored_interrupt;
    else
        interrupt_argument[hwi_num] = argument;
 
    /* Non-EPIC interrupts don't require any more handling */
    if (hwi_num < EPIC_INTERRUPTS_OFFSET)
    {
        osHwiEnable(int_status);
        return status;
    }
    else /* get the EPIC interrupt zero-based index */
        epic_hwi_num = (os_hwi_handle)(hwi_num - EPIC_INTERRUPTS_OFFSET);

    prioritySet(epic_hwi_num, priority);

    /* handle the mode register ELRx */
    index = (uint16_t)(epic_hwi_num >> 5);           /* /32 */
    trigger_reg_ptr = (uint32_t *)((g_dsp_plat_map->epic).p_elr);
    trigger_reg_ptr += index;

    mode_bit = (uint32_t)(0x00000001 << (epic_hwi_num & 0x001F));
    if (mode == LEVEL_MODE)
    {
        READ_UINT32(trigger_reg, *trigger_reg_ptr);
        trigger_reg &= ~mode_bit;
        WRITE_UINT32(*trigger_reg_ptr, trigger_reg);
    }
    else // mode == EDGE_MODE
    {
        READ_UINT32(trigger_reg, *trigger_reg_ptr);
        trigger_reg |= mode_bit;
        WRITE_UINT32(*trigger_reg_ptr, trigger_reg);
    }
 
    /* handle the pending interrupt register */
    index = (uint16_t)(epic_hwi_num >> 5);               /* /32 */
    pending_reg_ptr = (uint32_t *)((g_dsp_plat_map->epic).p_ipr);
    pending_reg_ptr += index;

    /* Figure out what the pending mask looks like */
    pending_bit = (uint32_t)(0x00000001 << (epic_hwi_num & 0x001F));

    /* Clear any pending interrupts */
    WRITE_UINT32(*pending_reg_ptr,pending_bit);

    /* enable the interrupt in the ENDIS register */
    setInterruptEnable(hwi_num, TRUE);
 
    osHwiEnable(int_status);

    return status;

#endif
}
Ejemplo n.º 15
0
/**
 * Disable Position Compare Ready Interrupt
**/
void eQEP::disablePositionCompareReadyInterrupt() {
  setInterruptEnable(getInterruptEnable() & ~EQEP_INT_PCR);
}
Ejemplo n.º 16
0
os_status osHwiMultiplexedCreate(os_hwi_handle     hwi_num,
                      os_hwi_priority   priority,
                      os_hwi_mode       mode,
                      os_hwi_function   handler,
                      os_hwi_arg        argument)
{

    multiplexed_hwi_t *this_int = NULL, *head = NULL, *fixed_head = NULL;
    os_status          status;
    bool               reusing_non_valid_entry = FALSE;


#ifdef HWI_ERROR_CHECKING
    if ( (priority > OS_HWI_LAST_PRIORITY) && (priority != OS_HWI_PRIORITY_NMI) )
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        RETURN_ERROR(OS_ERR_HWI_PRIORITY_INVALID);
    }
 
    if (handler == NULL)
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        RETURN_ERROR(OS_ERR_HWI_FUNCTION_INVALID);
    }
 
    if (HWI_INVALID_MODE(mode))
    {
#ifdef HWI_ERROR_ASSERT
        OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
        if(priority != 0) //meaning disable only
        {
            RETURN_ERROR(OS_ERR_HWI_MODE_INVALID);
        }
    }
#endif /* HWI_ERROR_CHECKING */
 

    osHwiSwiftDisable();
 
    // If multiplexed interrupt list already registered
    if (interrupt_pointer[hwi_num] == osHwiMultiplexedHandler)
    {
        fixed_head = (multiplexed_hwi_t *)interrupt_argument[hwi_num];
 
        head = fixed_head;
 
        // Error in registration
#ifdef HWI_ERROR_CHECKING
      if (head == NULL)
      {
#ifdef HWI_ERROR_ASSERT
          OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
          status = OS_ERR_HWI_INVALID;
          REPORT_ERROR(status);
          goto exit_func;
      }
 
        // Verify that the mode is consistent with other
        this_int = head;

        do
        {
            if ((this_int->mode != mode) && (this_int->valid == TRUE))
            {
#ifdef HWI_ERROR_ASSERT
                OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
                status = OS_ERR_HWI_MODE_INVALID;
                REPORT_ERROR(status);
                goto exit_func;
            }
            this_int = this_int->next;
        } while (this_int != NULL);
#endif /* HWI_ERROR_CHECKING */
 
        this_int = NULL;
        while (head != NULL)
        {
            if (head->valid == FALSE)
            {
                this_int = head;
                reusing_non_valid_entry = TRUE;
                break;
            }
            head = head->next;
        }
 
    }
 
    if (this_int == NULL)
    {
        this_int = (multiplexed_hwi_t *)osMalloc(sizeof(multiplexed_hwi_t), OS_MEM_LOCAL);
        if (this_int == NULL)
        {
#ifdef HWI_ERROR_ASSERT
                OS_ASSERT;
#endif /* HWI_ERROR_ASSERT */
                status = OS_ERR_NO_MEMORY;
                REPORT_ERROR(status);
                goto exit_func;
        }

        this_int->next = NULL;
    }

    this_int->argument = argument;
    this_int->handler = handler;
    this_int->mode = mode;
    this_int->valid = TRUE;

    // This is the first registration of this multiplexed interrupt
    if (fixed_head == NULL)
        status = osHwiCreate(hwi_num, priority, mode, osHwiMultiplexedHandler, (os_hwi_arg)this_int);
    else
    {
        // If necessary to append this_int to linked list
        if (reusing_non_valid_entry == FALSE)
        {
            head = fixed_head;
            while (head->next != NULL)
                head = head->next;
            head->next = this_int;
        }
        // Set priority to new priority
        status = osHwiPrioritySet(hwi_num, priority);
        // Enable the interrupt
        setInterruptEnable(hwi_num, TRUE);
    }
 
exit_func:
    osHwiSwiftEnable();
    return status;
}
Ejemplo n.º 17
0
/**
 * Enable Position Counter Overflow Interrupt
**/
void eQEP::enablePositionCounterOverflowInterrupt() {
  setInterruptEnable(getInterruptEnable() | EQEP_INT_PCO);
}
static int arlan_setup_card_by_book(struct net_device *dev)
{
	u_char irqLevel, configuredStatusFlag;
	volatile struct arlan_shmem *arlan = ((struct arlan_private *) dev->priv)->card;

//	ARLAN_DEBUG_ENTRY("arlan_setup_card");

	READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);

	IFDEBUG(10)
	if (configuredStatusFlag != 0)
		IFDEBUG(10) printk("arlan: CARD IS CONFIGURED\n");
	else
		IFDEBUG(10) printk("arlan: card is NOT configured\n");

	if (testMemory || (READSHMB(arlan->diagnosticInfo) != 0xff))
		if (arlan_hw_test_memory(dev))
			return -1;

	DEBUGSHM(4, "arlan configuredStatus = %d \n", arlan->configuredStatusFlag, u_char);
	DEBUGSHM(4, "arlan driver diagnostic: 0x%2x\n", arlan->diagnosticInfo, u_char);

	/* issue nop command - no interrupt */
	arlan_command(dev, ARLAN_COMMAND_NOOP);
	if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
		return -1;

	IFDEBUG(50) printk("1st Noop successfully executed !!\n");

	/* try to turn on the arlan interrupts */
	clearClearInterrupt(dev);
	setClearInterrupt(dev);
	setInterruptEnable(dev);

	/* issue nop command - with interrupt */

	arlan_command(dev, ARLAN_COMMAND_NOOPINT);
	if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
		return -1;


	IFDEBUG(50) printk("2nd Noop successfully executed !!\n");

	READSHM(irqLevel, arlan->irqLevel, u_char)
	
	if (irqLevel != dev->irq)
	{
		IFDEBUG(1) printk(KERN_WARNING "arlan dip switches set irq to %d\n", irqLevel);
		printk(KERN_WARNING "device driver irq set to %d - does not match\n", dev->irq);
		dev->irq = irqLevel;
	}
	else
		IFDEBUG(2) printk("irq level is OK\n");


	IFDEBUG(3) arlan_print_diagnostic_info(dev);

	arlan_command(dev, ARLAN_COMMAND_CONF);

	READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);
	if (configuredStatusFlag == 0)
	{
		printk(KERN_WARNING "arlan configure failed\n");
		return -1;
	}
	arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW);
	arlan_command(dev, ARLAN_COMMAND_RX);
	arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW);
	printk(KERN_NOTICE "%s: arlan driver version %s loaded\n",
	       dev->name, arlan_version);

//	ARLAN_DEBUG_EXIT("arlan_setup_card");

	return 0;		/* no errors */
}
Ejemplo n.º 19
0
/* Main
 */
Tohkbd::Tohkbd(QObject *parent) :
       QObject(parent)
{
    dbusRegistered = false;
    interruptsEnabled = false;
    vddEnabled = false;
    vkbLayoutIsTohkbd = false;
    currentActiveLayout = QString();
    currentOrientationLock = QString();
    keypadIsPresent = false;
    gpio_fd = -1;
    displayIsOn = false;
    keyIsPressed = false;
    keyRepeat = false;
    slideEventEmitted = false;
    taskSwitcherVisible = false;
    selfieLedOn = false;
    gpioInterruptCounter = 0;
    actualSailfishVersion = QString();

    fix_CapsLock = !checkSailfishVersion("1.1.7.0");
    capsLock = false;

    tohkbd2user = new ComKimmoliTohkbd2userInterface("com.kimmoli.tohkbd2user", "/", QDBusConnection::sessionBus(), this);
    tohkbd2user->setTimeout(2000);

    thread = new QThread();
    worker = new Worker();

    worker->moveToThread(thread);
    connect(worker, SIGNAL(gpioInterruptCaptured()), this, SLOT(handleGpioInterrupt()));
    connect(worker, SIGNAL(workRequested()), thread, SLOT(start()));
    connect(thread, SIGNAL(started()), worker, SLOT(doWork()));
    connect(worker, SIGNAL(finished()), thread, SLOT(quit()), Qt::DirectConnection);

    backlightTimer = new QTimer(this);
    backlightTimer->setSingleShot(true);
    connect(backlightTimer, SIGNAL(timeout()), this, SLOT(backlightTimerTimeout()));

    presenceTimer = new QTimer(this);
    presenceTimer->setInterval(2000);
    presenceTimer->setSingleShot(true);
    connect(presenceTimer, SIGNAL(timeout()), this, SLOT(presenceTimerTimeout()));

    repeatTimer = new QTimer(this);
    repeatTimer->setSingleShot(true);
    connect(repeatTimer, SIGNAL(timeout()), this, SLOT(repeatTimerTimeout()));

    /* do this automatically at startup */
    setVddState(true);
    setInterruptEnable(true);

    uinputif = new UinputIf();
    uinputif->openUinputDevice();

    uinputevpoll = new UinputEvPoll();
    evpollThread = new QThread();

    uinputevpoll->moveToThread(evpollThread);
    connect(uinputevpoll, SIGNAL(capsLockLedChanged(bool)), this, SLOT(capsLockLedState(bool)));
    connect(uinputevpoll, SIGNAL(pollingRequested()), evpollThread, SLOT(start()));
    connect(evpollThread, SIGNAL(started()), uinputevpoll, SLOT(doPoll()));
    connect(uinputevpoll, SIGNAL(finished()), evpollThread, SLOT(quit()), Qt::DirectConnection);

    uinputevpoll->requestPolling(uinputif->getFd());

    printf("uinputevpoll->requestPolling(uinputif->getFd());\n");

    tca8424 = new tca8424driver(0x3b);
    keymap = new keymapping();

    FKEYS.clear();
    FKEYS.append(KEY_F1);
    FKEYS.append(KEY_F2);
    FKEYS.append(KEY_F3);
    FKEYS.append(KEY_F4);
    FKEYS.append(KEY_F5);
    FKEYS.append(KEY_F6);
    FKEYS.append(KEY_F7);
    FKEYS.append(KEY_F8);
    FKEYS.append(KEY_F9);
    FKEYS.append(KEY_F10);
    FKEYS.append(KEY_F11);
    FKEYS.append(KEY_F12);

    reloadSettings();

    keymap->setLayout(masterLayout);

    if (currentActiveLayout.isEmpty())
        changeActiveLayout(true);

    if (currentOrientationLock.isEmpty())
    {
        changeOrientationLock(true);
        saveOrientation();
    }

    checkKeypadPresence();

    connect(keymap, SIGNAL(shiftChanged()), this, SLOT(handleShiftChanged()));
    connect(keymap, SIGNAL(ctrlChanged()), this, SLOT(handleCtrlChanged()));
    connect(keymap, SIGNAL(altChanged()), this, SLOT(handleAltChanged()));
    connect(keymap, SIGNAL(symChanged()), this, SLOT(handleSymChanged()));
    connect(keymap, SIGNAL(toggleCapsLock()), this, SLOT(toggleCapsLock()));
    connect(keymap, SIGNAL(keyPressed(QList< QPair<int, int> >)), this, SLOT(handleKeyPressed(QList< QPair<int, int> >)));
    connect(keymap, SIGNAL(keyReleased()), this, SLOT(handleKeyReleased()));
    connect(keymap, SIGNAL(bogusDetected()), tca8424, SLOT(reset()));
}