Kmdf Hid Minidriver For Touch I2c Device Calibration Online

// Configure I2C connection using resource list PVIDEO_PNP_DEVICE pDev = CreateDeviceContext(); To allow a user-mode calibration tool to interact with your driver, you must provide a private IOCTL. This is how the calibration GUI collects raw points and sends back coefficients.

Pseudo-code:

#define IOCTL_TOUCH_CALIBRATE_SET_COEFFS \ CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_TOUCH_CALIBRATE_GET_RAW CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS) kmdf hid minidriver for touch i2c device calibration

In your KMDF driver, implement a EvtIoDeviceControl callback: FILE_ANY_ACCESS) In your KMDF driver

CalibratedPoint->X = (RawPoint->X * pContext->CoeffA) + (RawPoint->Y * pContext->CoeffB) + pContext->CoeffC; CalibratedPoint->Y = (RawPoint->X * pContext->CoeffD) + (RawPoint->Y * pContext->CoeffE) + pContext->CoeffF; X = (RawPoint-&gt

void EvtIoDeviceControl( WDFQUEUE Queue, WDFREQUEST Request, size_t OutputBufferLength, size_t InputBufferLength, ULONG IoControlCode)

switch(IoControlCode) case IOCTL_TOUCH_CALIBRATE_SET_COEFFS: // Lock mutex, copy coefficients into device context, apply to next touch // Store in registry via WdfRegistry break; case IOCTL_TOUCH_CALIBRATE_GET_RAW: // Temporarily bypass calibration, read raw I2C registers, return break;

1 Comment

  1. hridoy November 13, 2021 at 1:24 pm

    New
    member

    Reply

Leave A Comment

Your email address will not be published. Required fields are marked *