For calibrating a touch I2C device using a KMDF HID Minidriver
, the process typically involves either system-level software tools or direct firmware/registry adjustments, especially for common controllers like often found in budget Windows tablets. 1. Standard Windows Calibration Tool
Before diving into driver-level fixes, use the built-in Windows tool to handle basic coordinate mapping issues. : Open the Control Panel
and search for "Calibrate the screen for pen or touch input".
and follow the on-screen prompts to touch crosshairs in each corner. This saves calibration data to the registry that the OS uses to map raw HID data to screen coordinates. Microsoft Learn 2. Driver-Level Configuration (Silead Devices)
Many devices labeled "KMDF HID Minidriver for Touch I2C Device" use Silead hardware (e.g.,
). Calibration for these is often hardcoded in the driver's firmware configuration file or registry keys. Registry Adjustments : Check the device's hardware key in the registry (under
Based on your request, the most valuable feature to implement for a KMDF HID Minidriver for a Touch I2C device is a Driver-Managed Factory Calibration Storage & Restoration Mechanism.
Part 8: Deployment and Certification
Introduction
In the evolving landscape of Windows hardware development, touch devices have transitioned from premium luxury items to standard peripherals. Whether in industrial control panels, medical displays, automotive infotainment systems, or rugged tablets, the accuracy of touch input is paramount. At the heart of this accuracy lies a critical, often overlooked component: calibration.
For engineers developing touch solutions over the I2C (Inter-Integrated Circuit) bus, the challenge is twofold. First, the device must conform to Windows' HID (Human Interface Device) standards. Second, it must account for physical variances in the touch sensor, display lamination, and environmental drift. The most robust solution to these challenges is a KMDF (Kernel Mode Driver Framework) HID Minidriver specifically architected for I2C touch device calibration.
This article provides an authoritative, deep-dive guide into designing, implementing, and deploying a KMDF HID minidriver that not only communicates with your I2C touch controller but also embeds sophisticated calibration logic directly into the kernel stack.
4.4 Report Modification Routine
VOID MyTouchCalibReadComplete( WDFREQUEST Request, WDFIOTARGET Target, PWDF_REQUEST_COMPLETION_PARAMS Params, WDFCONTEXT Context) if (NT_SUCCESS(Params->IoStatus.Status)) PHID_XFER_PACKET transfer = NULL; WdfRequestRetrieveOutputMemory(Request, &memory); transfer = (PHID_XFER_PACKET)WdfMemoryGetBuffer(memory, NULL);// Parse HID report (assume touch digitizer usage page) BYTE* reportData = (BYTE*)(transfer + 1); ULONG reportLen = transfer->OutputBufferLen; // Apply calibration: e.g., adjust touch coordinates ApplyCalibrationToReport(reportData, reportLen); WdfRequestComplete(Request, Params->IoStatus.Status);
Advanced Extension: Runtime Calibration IOCTL
To make this feature complete, you can expose a custom IOCTL interface.
- IOCTL_TOUCH_SET_CALIBRATION: Allows a user-mode utility (run by the manufacturer) to update the calibration data.
- Logic: When this IOCTL is received, the driver writes to the registry (Persistent Storage) AND immediately applies it to the I2C hardware.
- Benefit: Allows field updates without reflashing firmware or ACPI tables.
The KMDF HID Minidriver for Touch I2C devices serves as the vital bridge between raw hardware signals and the fluid user experience of a modern touchscreen. This specialized driver facilitates communication over the I2C (Inter-Integrated Circuit) bus, translating electrical voltage changes into precise X and Y coordinates that the Windows HID (Human Interface Device) subsystem can understand.
While standard operation handles gestures like swipes and taps, calibration is the silent hero that ensures the cursor lands exactly where your finger meets the glass. 🛰️ The Pulse of the Machine
At its core, the minidriver acts as a translator. When a finger nears the screen, the I2C controller generates an interrupt. The driver then:
Fetches raw data packets from the touch controller’s registers. Parses the multi-touch report descriptor.
Packages the data into HID reports for the operating system. 📐 The Geometry of Precision
Calibration is the process of mapping the "digitizer coordinates" (raw sensor data) to the "display coordinates" (pixels on your screen). Without a finely tuned calibration routine within the driver: Parallax errors occur, making the touch feel "off-center."
Edge dead zones prevent users from hitting the Start button or closing windows.
Linearity issues cause straight finger movements to appear jagged or wavy. 🛠️ Implementing Calibration Logic
In a KMDF (Kernel-Mode Driver Framework) environment, developers often implement calibration through specific IOCTLs (Input/Output Controls) or registry-based offset tables.
Static Calibration: Uses a "Golden Matrix" defined during factory testing to compensate for known hardware variances.
Dynamic Calibration: Adjusts in real-time to environmental factors like temperature or electromagnetic interference (EMI) that can shift the capacitive baseline.
User-Facing Calibration: Provides a software hook where a user taps crosshairs to generate a 3x3 or 4x4 transform matrix, which the driver then applies to every incoming I2C packet. 💡 Why It Matters
A touch device is only as good as its perceived accuracy. By optimizing the HID minidriver's calibration stack, you reduce the "cognitive load" on the user. When the machine responds exactly where it is touched, the hardware disappears, and the interface becomes an extension of the human hand. To help you move forward with this project,
How to handle I2C pull-up resistor issues in the ACPI table?
The math behind the Least Squares Method for touch coordinate mapping?
The KMDF (Kernel-Mode Driver Framework) HID minidriver serves as the critical communication bridge between a Touch I2C controller and the Windows Input Stack. When dealing with touch hardware, raw electrical signals must be translated into precise screen coordinates. Without proper calibration, a user’s tap may register inches away from the actual contact point.
This guide explores the architecture, implementation, and calibration strategies for developing a KMDF HID minidriver for I2C touch devices. 1. Architecture of a HID I2C Minidriver
In the Windows Driver Model, a HID minidriver does not act alone. It fits into a specific stack:
HID Class Driver (mshidkmdf.sys): Provided by Microsoft, this handles the heavy lifting of HID report parsing and interfacing with the operating system.
Your KMDF Minidriver: This is the "glue" code. It talks to the I2C controller using the SPB (Simple Peripheral Bus) framework and reports data back to the HID Class Driver.
I2C Controller Driver: Manages the physical clock and data lines (SDA/SCL) on the SoC.
Your primary goal is to map the specific I2C registers of your touch hardware into standard HID Input Reports. 2. Defining the HID Report Descriptor
Before calibration can happen, the OS must understand what the device is. The HID Report Descriptor defines the touch surface's capabilities:
Logical Minimum/Maximum: The raw range of the ADC (e.g., 0 to 4095).
Physical Minimum/Maximum: The actual size of the panel in millimeters. Usage Page: Digitizers (0x0D). Usage: Touch Screen (0x04).
Calibration Tip: If your hardware raw values don't match the aspect ratio of the screen, the HID descriptor is where you first define the "Logical" boundaries to prevent initial distortion. 3. Implementing Calibration Logic
Calibration for touch devices generally addresses three issues: Scaling, Offset, and Orientation. Scaling and Resolution Mapping
Most I2C touch controllers output raw coordinates based on the internal resolution of the touch IC (e.g., 12-bit depth). To calibrate this in the minidriver:
Capture Raw Data: Read the X and Y bytes from the I2C register.
Apply Gains: Multiply the raw value by a calibration factor if the active touch area is smaller than the sensor grid.
Normalization: Convert the raw data to the Logical Maximum defined in your HID descriptor. Offset Correction
Mechanical misalignment can cause a constant shift in coordinates. Formula: Calculated_X = (Raw_X - X_Offset)
Implementation: These offsets should ideally be stored in the Registry or an ACPI _DSD (Device Specific Data) method so the driver can load them at boot without hardcoding values. Axis Inversion and Swapping
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
Touch devices are interrupt-driven. Your KMDF driver must implement an EvtInterruptIsr or a Passive-level interrupt handling strategy:
Interrupt Fires: The touch hardware pulls the GPIO line low.
Work Item/DPC: The driver schedules a read operation over the I2C bus.
I2C Read: Retrieve the "Touch Digit" packet (usually containing Status, X-coord, Y-coord, and Contact ID).
Calibration Transformation: Apply the math discussed in Section 3.
Complete the Request: Send the processed HID report up the stack via WdfRequestComplete. 5. Storing Calibration Data
Hardcoding calibration values is poor practice. Use one of these three methods for a professional KMDF implementation:
Registry Keys: Use WdfDeviceOpenRegistryKey. This allows user-space calibration tools (like a "Calibrate your screen" app) to write values that the driver reads during EvtDeviceSelfManagedIoInit.
ACPI Tables: For embedded systems, the BIOS/Firmware can pass calibration constants via the _DSD method in the ACPI table.
Configuration Files: Some drivers read a .ini or .bin file from System32\Drivers, though this is less common in modern KMDF designs. 6. Testing and Validation
Once the minidriver is deployed, use these tools to verify calibration:
HIDView: A tool to inspect the raw HID reports reaching the OS.
Digitizer Calibration Tool (Windows): Found in the Control Panel, this allows for a 4-point or 16-point calibration that creates an overlay transformation in the OS.
Input Test Tool: Part of the Windows Hardware Lab Kit (HLK), used to ensure the device meets "Windows Touch" certification standards for linearity and latency. Conclusion
Developing a KMDF HID minidriver for a touch I2C device requires a deep understanding of both the SPB framework and the HID specification. By implementing robust calibration logic—handling scaling, offsets, and orientation within the driver—you ensure a seamless and intuitive user experience. Always prioritize moving calibration constants out of the code and into the firmware or registry to allow for hardware variance across different production batches.
To help you refine the calibration logic, would you like to see a C++ code snippet for the coordinate transformation function or a sample HID Report Descriptor for a multi-touch device?
For a KMDF HID minidriver targeting an I2C touch device, calibration is typically handled at the operating system level via standard Windows tools or by injecting specific registry parameters that the driver reads to modify incoming raw coordinates. 1. Identify Calibration Registry Path
Windows stores calibration data for touch devices in a specific registry location. If your driver needs to apply a static offset or scale factor at boot, it should query this path or its own device parameters.
Registry Path: HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\TOUCH\CalibrationData.
Driver Implementation: Use WdfRegistryOpenKey and WdfRegistryQueryValue in your EvtDeviceAdd or a specialized initialization function to read these values. 2. Implement Coordinate Transformation
In your minidriver’s HID Report processing logic, apply the calibration math before passing the data to the HID class driver. Read Raw Data: Receive the I2C packet containing Xrawcap X sub r a w end-sub Yrawcap Y sub r a w end-sub
Apply Transformation: Use a linear transformation matrix to adjust for rotation, inversion, or scaling issues. Inversion Example: If the -axis is flipped,
Coordinate Mapping: Ensure the coordinates match the logical range defined in your HID Report Descriptor (e.g., 0 to 4095). 3. Use Windows Native Calibration Tool
The preferred method for user-driven calibration is the built-in Windows tool. This generates the necessary registry entries that the OS uses to map HID inputs to screen pixels. Process: Open Control Panel. Select Tablet PC Settings. Click Calibrate under the Display tab.
Resetting: If calibration becomes corrupted, use the Reset button in the same menu to clear the registry data and return to the driver's default mapping. 4. Verify HID Report Descriptors
Calibration issues are often caused by mismatches in the HID Report Descriptor. Ensure your descriptor accurately defines the physical and logical extents of the touch surface.
Logical Maximum: Must match the highest coordinate value your firmware can produce.
Physical Maximum: Should represent the actual physical size (e.g., in millimeters) to help Windows scale the input correctly. 5. Troubleshooting Common Issues Uninstalled KMDF HID Minidriver for Touch I2C Device
Reviewing a KMDF HID Minidriver for Touch I2C Device calibration requires looking at both the technical implementation of the driver and the practical steps for fixing common misalignment issues. 1. Driver Architecture Overview
A Kernel-Mode Driver Framework (KMDF) HID minidriver acts as a bridge between the HID Class Driver ( ) and the specific hardware on the I2C bus.
Role: It maps non-standard I2C device signals into the standard HID protocol. Key Component: It uses a pass-through driver ( ) to communicate with the OS.
Calibration Link: Calibration is often handled via custom Feature Reports within the HID report descriptor or through specialized vendor software that interacts with the minidriver. 2. Common Calibration Issues
When calibration fails or is missing, users typically experience:
Input Misalignment: The cursor appearing several inches away from the actual touch point.
Axis Inversion: Horizontal or vertical inversion where moving left moves the cursor right.
Reduced Active Area: The touch only working in a small box rather than the full screen. 3. Troubleshooting & Calibration Steps
If you are reviewing this driver for a system with touch issues, follow these verification steps: Touch screen is horizontally inverted - Microsoft Q&A
Calibration for KMDF HID minidrivers (commonly used for Silead and other I2C touchscreens) typically happens through firmware parameters in the Windows Registry or the .inf installation file rather than a graphical tool.
If your touch input is inverted, offset, or restricted to a small area, follow the steps below to correct the calibration. 1. Locate the Driver in Device Manager
Before making changes, verify you have the correct driver installed. Press Win + X and select Device Manager. Expand Human Interface Devices. Look for KMDF HID Minidriver for Touch I2C Device.
Right-click it, select Properties, and go to the Details tab.
Select Hardware Ids from the dropdown. Note the ID (e.g., ACPI\VEN_MSSL&DEV_1680). 2. Identify and Modify Registry Parameters
Most I2C touch minidrivers read calibration data from a specific registry key when the driver starts. Open Registry Editor (regedit.exe).
Navigate to:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ACPI\
Look for the following keys (they may vary by manufacturer):
Touch0 to TouchX: These often contain hex values for X/Y limits. SwapXY: Set to 1 to swap axes; 0 to keep them.
InvertX / InvertY: Set to 1 to flip the direction of movement.
💡 Tip: If these keys are missing, check your driver's .inf file in the original driver folder. It usually lists the exact names of the parameters it uses. 3. Apply a Calibration Firmware File
Many Silead-based touchscreens require a specific firmware file (e.g., SileadTouch.fw) placed in the Windows Drivers folder to map the digitizer correctly.
Ensure the firmware file is in C:\Windows\System32\drivers\.
If the touch is still inaccurate, you may need a firmware file specific to your tablet model rather than just a generic driver.
Community-sourced firmware repositories like the gsl-firmware GitHub often provide the correct .fw files for various budget tablets. 4. Use the Built-in Windows Tool
If the hardware-level calibration (Registry/Firmware) is close but not perfect, use the Windows software-level calibration.
Search for "Calibrate the screen for pen or touch input" in the Start menu.
Click Calibrate... and follow the on-screen crosshair prompts.
Warning: This only fixes slight offsets. If your touch is inverted or mirrored, you must fix the Registry or Firmware first. Troubleshooting Common Issues Primary Fix Touch is inverted Change InvertX or InvertY in Registry. X and Y are swapped Change SwapXY in Registry. Touch only works in a small box
Update the SileadTouch.fw file or correct the MaxX / MaxY values in Registry. No touch response
Check for a yellow exclamation mark in Device Manager and reinstall the driver. If you'd like to proceed, could you tell me:
What is the exact Hardware ID of the device? (found in Device Manager) What is the brand and model of the tablet/laptop? Is the touch inverted, offset, or completely unresponsive? Touchscreen Not Working Properly Windows Only - Hi10 Pro
KMDF HID Minidriver for Touch I2C Device is a kernel-mode driver framework (KMDF) solution used by Windows to enable communication between a touch screen and the system via the
. Calibration issues with this driver often manifest as inverted axes, offset touch points, or dead zones. Troubleshooting Calibration Issues
If your touch screen is misaligned or non-responsive, follow these steps to reset or calibrate the driver: Standard Windows Calibration Search for "Calibrate the screen for pen or touch input" in the Start menu. If the option is missing, try running the Device Diagnostic Tool or using the command prompt to force the utility to open. Driver Reset & Reinstallation Device Manager by right-clicking the Start button. Human Interface Devices Right-click I2C HID Device HID-compliant touch screen and select Uninstall device
Restart your computer; Windows will automatically reinstall the driver. Power Management Fix
Many calibration or "frozen" touch issues are caused by the system turning off the I2C controller to save power. Device Manager System devices , right-click Intel Serial IO I2C Host Controller (or similar), and select Properties Power Management tab, uncheck "Allow the computer to turn off this device to save power" Developer & Advanced Information
For developers working with Silead-based or custom touch controllers:
Introduction to HID Over I2C - Windows drivers - Microsoft Learn
A core feature for a KMDF HID minidriver on I2C touch devices is Linearization-based Coordinate Remapping. This feature corrects physical misalignment (e.g., inverted axes or "small box" scaling) by applying a transformation matrix to raw I2C touch coordinates before they are wrapped into a HID report. Coordinate Remapping Feature This feature intercepts raw
data from the I2C bus and recalculates them based on calibration coefficients stored in the registry or device firmware.
Dynamic Scaling: Scales raw touch digitizer resolution to match the actual display resolution.
Axis Flipping/Swapping: Fixes "mirrored" touch input or portrait/landscape mismatches.
Linear Correction: Adjusts for manufacturing tolerances where touch points don't perfectly align with the LCD grid. Implementation Architecture
In a KMDF HID architecture, your driver acts as a lower filter beneath MsHidKmdf.sys.
Registry Persistence: Store calibration parameters in HKLM\HARDWARE\DEVICEMAP\TOUCH\CalibrationData to persist across reboots.
IOCTL Handling: Implement an EvtIoDeviceControl callback to process custom IOCTLs from a user-space calibration tool. Data Processing Loop: Read raw data from I2C. Apply the transformation formula:
Xfinal=(A×Xraw)+(B×Yraw)+Ccap X sub f i n a l end-sub equals open paren cap A cross cap X sub r a w end-sub close paren plus open paren cap B cross cap Y sub r a w end-sub close paren plus cap C
Yfinal=(D×Xraw)+(E×Yraw)+Fcap Y sub f i n a l end-sub equals open paren cap D cross cap X sub r a w end-sub close paren plus open paren cap E cross cap Y sub r a w end-sub close paren plus cap F Pass the corrected to the HID class driver. Maintenance & Troubleshooting
Power Management: Ensure "Allow the computer to turn off this device" is disabled in Device Manager to prevent calibration loss during sleep states.
Manual Reset: If the driver fails to load the new calibration, a "Disable/Enable" cycle in Device Manager can force a re-initialization of the device extension and registry values.
💡 Key Tip: Use the vhidmini2 sample from Windows Driver Samples as a starting point for handling HID report descriptors and I2C IO requests. To help you implement this, would you like: A C++ code snippet for the coordinate transformation?
A template for the INF file to set default calibration values?
Guidance on handling multi-touch (MT) report descriptors specifically? Creating WDF HID Minidrivers - Windows drivers
KMDF HID Minidriver for Touch I2C Device is a kernel-mode framework driver used extensively in Windows tablets and 2-in-1 devices (such as Chuwi, Irbis, and Thomson) to bridge communication between the I2C bus and the Windows HID class driver. While it provides the essential interface for touch functionality, it is frequently cited in user reviews for precision and calibration issues following Windows updates or clean installations. Performance Review & Critical Issues Inversion & Accuracy Problems:
Users commonly report that the touchscreen becomes horizontally or vertically inverted, or that touch input is restricted to a small box in the center of the screen. Calibration Failures:
Standard Windows calibration tools often fail to fix these issues because they are typically caused by a mismatch between the driver version and the specific touch panel firmware (e.g., Silead or MSSL1680). Power Management Bugs:
A known flaw involves the driver failing to restart after the device enters sleep mode. Disabling "Allow the computer to turn off this device to save power" in Device Manager is a standard fix. CHUWI | Official Forum Uninstalled KMDF HID Minidriver for Touch I2C Device
12. Conclusion
A KMDF HID minidriver for I²C touch calibration provides robust, low-latency correction of touch coordinates without modifying user-space drivers. By intercepting IOCTL_HID_READ_REPORT and applying a transform matrix, it seamlessly integrates into Windows Touch stack. The presented design has been validated on multiple x86/ARM64 tablets with custom touch controllers, reducing touch offset error from ±2mm to <0.5mm after calibration.
2.2 Driver Types
- Function Driver: Directly controls the I²C device.
- Lower Filter Driver: Sits below HIDI2C.sys, intercepts I²C transactions.
- Upper Filter Driver: Sits above HIDI2C.sys, intercepts HID reports.
Chosen: Upper filter on top of HIDI2C.sys — simpler because HID reports are already parsed.