NTSTATUS RetrieveCalibrationFromACPI( _In_ WDFDEVICE Device, _Out_ PVOID CalibrationBuffer, _In_ ULONG BufferSize ) NTSTATUS status; ACPI_EVAL_INPUT_BUFFER_COMPLEX inputBuffer = 0 ; PACPI_EVAL_OUTPUT_BUFFER outputBuffer = NULL; ULONG outputLength = 0; // 1. Initialize ACPI input arguments with the Touch _DSM UUID inputBuffer.Signature = ACPI_EVAL_INPUT_BUFFER_COMPLEX_SIGNATURE; inputBuffer.MethodNameAsUlong = (ULONG)'MSD_'; // _DSM reversed inputBuffer.ArgumentCount = 4; // (Fill out UUID, Revision, Function Index, and Empty Package arguments here...) // 2. Send the IOCTL_ACPI_EVAL_METHOD to the underlying bus status = WdfIoTargetSendIoctlSynchronously( WdfDeviceGetIoTarget(Device), NULL, IOCTL_ACPI_EVAL_METHOD, &inputMemoryDescriptor, &outputMemoryDescriptor, NULL, NULL ); if (NT_STATUS_IS_SUCCESS(status)) // Parse outputBuffer down to coefficients and copy to CalibrationBuffer return status; Use code with caution. 4. Injecting Calibration into the HID Parsing Pipeline
Depending on how the touch panel is mounted (0°, 90°, 180°, 270°), you may need to: Swap X and Y. Invert an axis: Final_X = Logical_Max_X - Calculated_X . 4. Handling Interrupts and Data Retrieval kmdf hid minidriver for touch i2c device calibration
In most cases, hidi2c.sys is sufficient. However, it does NOT support custom calibration. It forwards raw HID reports directly from the I2C device to the HID class driver. To inject calibration, we must replace or layer our own . Writing kernel drivers presents risks
By following the architecture and practices outlined in this article—custom IOCTL interfaces, registry-backed coefficient storage, real-time coordinate transformation, and thorough debugging—you can build a driver that is robust, certifiable, and adaptable to any touch sensor or environmental condition. registry-backed coefficient storage
Writing kernel drivers presents risks, as mistakes can cause system-wide crashes (Blue Screens of Death). Follow these testing procedures: Step 1: Use Driver Verifier
The driver parses the HID report bytes according to the device's HID report descriptor to locate the X and Y coordinate fields.
+-------------------------------------------------------+ | Windows Touch Input Subsystem | +-------------------------------------------------------+ | +-------------------------------------------------------+ | HIDClass.sys | +-------------------------------------------------------+ | +-------------------------------------------------------+ | Your Custom KMDF HID Minidriver (Calibration Layer) | +-------------------------------------------------------+ | +-------------------------------------------------------+ | HIDI2C.sys (Standard I2C Transport) | +-------------------------------------------------------+ | +-------------------------------------------------------+ | SpbCx / I2C Controller | +-------------------------------------------------------+ | +-------------------------------------------------------+ | Touch Controller Hardware | +-------------------------------------------------------+ The Role of the Minidriver