Esempio n. 1
0
NTSTATUS BOOTTRACKPAD(
	_In_  PDEVICE_CONTEXT  pDevice
	)
{
	NTSTATUS status = 0;

	static char bl_exit[] = {
		0x00, 0xff, 0xa5, 0x00, 0x01,
		0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };

	static char bl_deactivate[] = {
		0x00, 0xff, 0x3b, 0x00, 0x01,
		0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };

	cyapa_boot_regs boot;

	FuncEntry(TRACE_FLAG_WDFLOADING);

	SpbReadDataSynchronously(&pDevice->I2CContext, CMD_BOOT_STATUS, &boot, sizeof(boot));

	if ((boot.stat & CYAPA_STAT_RUNNING) == 0) {
		if (boot.error & CYAPA_ERROR_BOOTLOADER)
			SpbWriteDataSynchronously(&pDevice->I2CContext, CMD_BOOT_STATUS, bl_deactivate, sizeof(bl_deactivate));
		else
			SpbWriteDataSynchronously(&pDevice->I2CContext, CMD_BOOT_STATUS, bl_exit, sizeof(bl_exit));
	}

	WDF_TIMER_CONFIG              timerConfig;
	WDFTIMER                      hTimer;
	WDF_OBJECT_ATTRIBUTES         attributes;

	WDF_TIMER_CONFIG_INIT(&timerConfig, CyapaBootTimer);

	WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
	attributes.ParentObject = pDevice->FxDevice;
	status = WdfTimerCreate(&timerConfig, &attributes, &hTimer);

	WdfTimerStart(hTimer, WDF_REL_TIMEOUT_IN_MS(75));

	FuncExit(TRACE_FLAG_WDFLOADING);
	return status;
}
Esempio n. 2
0
void cyapa_set_power_mode(_In_  PDEVICE_CONTEXT  pDevice, _In_ uint8_t power_mode)
{
	int ret;
	uint8_t power;

	SpbReadDataSynchronously(&pDevice->I2CContext, CMD_POWER_MODE, &ret, 1);
	if (ret < 0)
		return;

	power = (ret & ~0xFC);
	power |= power_mode & 0xFc;

	SpbWriteDataSynchronously(&pDevice->I2CContext, CMD_POWER_MODE, &power, 1);
}
Esempio n. 3
0
NTSTATUS BOOTTRACKPAD(
	_In_  PDEVICE_CONTEXT  pDevice
	)
{
	if (deviceLoaded)
		return 0;

	NTSTATUS status = 0;

	static char bl_exit[] = {
		0x00, 0xff, 0xa5, 0x00, 0x01,
		0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };

	FuncEntry(TRACE_FLAG_WDFLOADING);
	SpbWriteDataSynchronously(&pDevice->I2CContext, 0x00, bl_exit, sizeof(bl_exit));
	FuncExit(TRACE_FLAG_WDFLOADING);

	deviceLoaded = true;
	return status;
}
Esempio n. 4
0
NTSTATUS
RmiChangeSleepState(
   IN RMI4_CONTROLLER_CONTEXT* ControllerContext,
   IN SPB_CONTEXT *SpbContext,
   IN UCHAR SleepState
   )
/*++

Routine Description:

   Changes the SleepMode bits on the controller as specified

Arguments:

   ControllerContext - Touch controller context
   
   SpbContext - A pointer to the current i2c context

   SleepState - Either RMI4_F11_DEVICE_CONTROL_SLEEP_MODE_OPERATING
                or RMI4_F11_DEVICE_CONTROL_SLEEP_MODE_SLEEPING

Return Value:

   NTSTATUS indicating success or failure

--*/
{
    RMI4_F01_CTRL_REGISTERS* controlF01;
    UCHAR deviceControl;
    int index;
    NTSTATUS status;

    controlF01 = (RMI4_F01_CTRL_REGISTERS*) &deviceControl;

    //
    // Find RMI device control function housing sleep settings
    // 
    index = RmiGetFunctionIndex(
        ControllerContext->Descriptors,
        ControllerContext->FunctionCount,
        RMI4_F01_RMI_DEVICE_CONTROL);

    if (index == ControllerContext->FunctionCount)
    {
        Trace(
            TRACE_LEVEL_ERROR,
            TRACE_FLAG_POWER,
            "Power change failure - RMI Function 01 missing");

        status = STATUS_INVALID_DEVICE_STATE;
        goto exit;
    }

    status = RmiChangePage(
        ControllerContext,
        SpbContext,
        ControllerContext->FunctionOnPage[index]);

    if (!NT_SUCCESS(status))
    {
        Trace(
            TRACE_LEVEL_ERROR,
            TRACE_FLAG_POWER,
            "Could not change register page");

        goto exit;
    }

    //
    // Read Device Control register
    //
    status = SpbReadDataSynchronously(
        SpbContext,
        ControllerContext->Descriptors[index].ControlBase,
        &deviceControl,
        sizeof(deviceControl)
        );

    if (!NT_SUCCESS(status))
    {
        Trace(
            TRACE_LEVEL_ERROR,
            TRACE_FLAG_POWER,
            "Could not read sleep register - %!STATUS!",
            status);

        goto exit;
    }

    //
    // Assign new sleep state
    //
    controlF01->DeviceControl.SleepMode = SleepState;

    //
    // Write setting back to the controller
    //
    status = SpbWriteDataSynchronously(
        SpbContext,
        ControllerContext->Descriptors[index].ControlBase,
        &deviceControl,
        sizeof(deviceControl)
        );

    if (!NT_SUCCESS(status))
    {
        Trace(
            TRACE_LEVEL_ERROR,
            TRACE_FLAG_POWER,
            "Could not write sleep register - %X",
            status);

        goto exit;
    }

exit:

    return status;
}