Adding HID class support to existing USB function driver

Hello

I have developed a USB function driver for a customer?s digital TV tuner. It registers 2 interfaces at the moment, one of KSCATEGORY_BDA_NETWORK_TUNER and one of GUID_DEVINTERFACE_IRPORT (for CIRClass.sys). All of this is working fine.

We would like to support additional IR remote controls not supported by MS?s CIRClass.sys and are looking at doing internal IR decoding in our driver and forwarding keycode information through an HID interface. We were hoping to use an HID minidriver approach to achieve this and to this end I have tried installing an UpperFilter driver on top of our USB function driver, with the Upper Filter containing the HidRegisterMinidriver() function in it?s DriverEntry routine. This seems to work, in the sense that the filter driver starts to receive IOCTL requests from HIDClass.sys.

However, the system is no longer opening handles to the function driver to operate the BDA and IR functions of the device. (Although the IoRegisterDeviceInterface() and IoSetDeviceInterfaceState() API return with success). Am I just missing some processing at start up or in my PnP routines? Does anyone know if this filter driver is a valid approach for the HID minidriver? In fact, can I use the HID minidriver approach at all, or should I be just exposing a new HID interface in my function driver using IoRegisterDeviceInterface() etc.

Any ideas welcome.

Nick Clarke
Red Software Systems
Software Engineering Consultancy
www.redsoftsys.com

Nick,

If you install an upper filter HID driver for your device, you convert the whole beast into the HIDCLASS minidriver. HIDCLASS does not pass certain requests to its minidrivers including IRP_MJ_CREATEs. The right approach in your case is the child HID device.

Hope that helps,

Ilya Faenson
Rockville, MD USA

-----Original Message-----
From: Nick Clarke
Sent: Friday, February 05, 2010 08:07 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Adding HID class support to existing USB function driver

Hello

I have developed a USB function driver for a customer?s digital TV tuner. It
registers 2 interfaces at the moment, one of KSCATEGORY_BDA_NETWORK_TUNER and
one of GUID_DEVINTERFACE_IRPORT (for CIRClass.sys). All of this is working
fine.

We would like to support additional IR remote controls not supported by MS?s
CIRClass.sys and are looking at doing internal IR decoding in our driver and
forwarding keycode information through an HID interface. We were hoping to use
an HID minidriver approach to achieve this and to this end I have tried
installing an UpperFilter driver on top of our USB function driver, with the
Upper Filter containing the HidRegisterMinidriver() function in it?s DriverEntry
routine. This seems to work, in the sense that the filter driver starts to
receive IOCTL requests from HIDClass.sys.

However, the system is no longer opening handles to the function driver to
operate the BDA and IR functions of the device. (Although the
IoRegisterDeviceInterface() and IoSetDeviceInterfaceState() API return with
success). Am I just missing some processing at start up or in my PnP routines?
Does anyone know if this filter driver is a valid approach for the HID
minidriver? In fact, can I use the HID minidriver approach at all, or should I
be just exposing a new HID interface in my function driver using
IoRegisterDeviceInterface() etc.

Any ideas welcome.

Nick Clarke
Red Software Systems
Software Engineering Consultancy
www.redsoftsys.com

Thanks Ilya

How do I create a child HID device? Are there any WDK examples of how to do this (and .infs too)? With this architecture, would my function driver sprocess it’s BDA and CIRClass I/O in the normal way?

Thanks again for your help
Nick

> How do I create a child HID device? Are there any WDK examples of how to do this (and .infs too)?

KMDF bus driver samples (toaster or such).


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Are you currently linking against any other port drivers? For the bda interface, are you using ks or avstream or streamcls? For circlass, isn’t there a port driver, circlass.sys, that you shoud link against as well? Or are you registering these interfaces on your own in a wdm driver and doing all of the work that the port drivers should be doing for you?

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@redsoftsys.com
Sent: Friday, February 05, 2010 6:01 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Adding HID class support to existing USB function driver

Thanks Ilya

How do I create a child HID device? Are there any WDK examples of how to do this (and .infs too)? With this architecture, would my function driver sprocess it’s BDA and CIRClass I/O in the normal way?

Thanks again for your help
Nick


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I’m linking against CIRClass.lib and using the CIRClass.sys port
driver.

I’m not using any bda port drivers.

On 5 Feb 2010, at 15:29, Doron Holan wrote:

> Are you currently linking against any other port drivers? For the
> bda interface, are you using ks or avstream or streamcls? For
> circlass, isn’t there a port driver, circlass.sys, that you shoud
> link against as well? Or are you registering these interfaces on
> your own in a wdm driver and doing all of the work that the port
> drivers should be doing for you?
>
> d
>
> tiny phone keyboard + fat thumbs = you do the muth
>
>
>
> -----Original Message-----
> From: xxxxx@redsoftsys.com
> Sent: Friday, February 05, 2010 6:01 AM
> To: Windows System Software Devs Interest List
> Subject: RE:[ntdev] Adding HID class support to existing USB
> function driver
>
>
> Thanks Ilya
>
> How do I create a child HID device? Are there any WDK examples of
> how to do this (and .infs too)? With this architecture, would my
> function driver sprocess it’s BDA and CIRClass I/O in the normal way?
>
> Thanks again for your help
> Nick
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
> ______________________________________________
> This email has been scanned by Netintelligence
> http://www.netintelligence.com/email
>

Looking at circlass, it is not a traditional port/miniport model. Rather circlass is just some driver listening for the arrival of GUID_DEVINTERFACE_IRPORT. Anyways, the truly correct way to do this in a usb device is to have multiple functions and let usbccgp split apart the device into children stacks, one for each function (circlass, dba, hid). I am assuming you can’t change the hw and that you started with the smscir sample which is KMDF. Just enumerate a child device using static enumeration (see toaster bus\staticbus). To implement the custom hid miniport, you can look at the hidusbfx2 sample and just move the functionality in hidusbfx2 into the PDO that you enumerate (basically you do not need an FDO hid port driver with hidshim+hidclass as an upper filter, you can just use hidshim+hidclass as the FDO and handle all of the HID I/O processing logic in the pdo)

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Nick Clarke
Sent: Friday, February 05, 2010 8:21 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Adding HID class support to existing USB function driver

I’m linking against CIRClass.lib and using the CIRClass.sys port
driver.

I’m not using any bda port drivers.

On 5 Feb 2010, at 15:29, Doron Holan wrote:

> Are you currently linking against any other port drivers? For the
> bda interface, are you using ks or avstream or streamcls? For
> circlass, isn’t there a port driver, circlass.sys, that you shoud
> link against as well? Or are you registering these interfaces on
> your own in a wdm driver and doing all of the work that the port
> drivers should be doing for you?
>
> d
>
> tiny phone keyboard + fat thumbs = you do the muth
>
>
>
> -----Original Message-----
> From: xxxxx@redsoftsys.com
> Sent: Friday, February 05, 2010 6:01 AM
> To: Windows System Software Devs Interest List
> Subject: RE:[ntdev] Adding HID class support to existing USB
> function driver
>
>
> Thanks Ilya
>
> How do I create a child HID device? Are there any WDK examples of
> how to do this (and .infs too)? With this architecture, would my
> function driver sprocess it’s BDA and CIRClass I/O in the normal way?
>
> Thanks again for your help
> Nick
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
> ______________________________________________
> This email has been scanned by Netintelligence
> http://www.netintelligence.com/email
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi Doron

Thanks for your help on this. Just one last thing, my function drive is not KMDF, it was inherited by be and is just a plain old WDM driver. Should I look at the toaster\wdm\bus sample driver on how to enumearte my child device? Also, any other things to watch out for?

Thanks again
Nick

Well, a wdm bus driver is a total pia. I would recommend rewriting to kmdf just so you can use its bus enumeration capabilities. It might cost you in the short run, but you will benefit in the long run by moving to kmdf

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@redsoftsys.com
Sent: Monday, February 08, 2010 3:04 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Adding HID class support to existing USB function driver

Hi Doron

Thanks for your help on this. Just one last thing, my function drive is not KMDF, it was inherited by be and is just a plain old WDM driver. Should I look at the toaster\wdm\bus sample driver on how to enumearte my child device? Also, any other things to watch out for?

Thanks again
Nick


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Not an option I’m afraid, I need HID support added to this device by the end
of Feb or we probably won’t bother.

What I need is a simple and quick way of enumerating a child device from my
existing WDM function driver. Then I guess we’d install the
HIDClass.sys-based driver on top of our function driver. If this is not
possible, I’m guessing the management will decide that it’s not worth the
effort to support the customers who need this HID functionality.

I’ve taken a look at the WDM bus driver toaster sample and it looks to me
like I need to first create a new PDO using IoCreateDeviceSecure(), then
handle a bunch of PnP IRPs. It looks like the driver installation is
achieved by the use of a GUID_DEVCLASS_TOASTER in the sample (returned in
the IRP_MN_QUERY_BUS_INFORMATION). Should I replace this with my own GUID
and .inf to load my HIDClass.sys-based driver on top of my function driver?
I’m coding using this assumption now! Any pointers to help would be much
appreciated.

Thanks

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: 08 February 2010 15:28
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Adding HID class support to existing USB function
driver

Well, a wdm bus driver is a total pia. I would recommend rewriting to kmdf
just so you can use its bus enumeration capabilities. It might cost you in
the short run, but you will benefit in the long run by moving to kmdf

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@redsoftsys.com
Sent: Monday, February 08, 2010 3:04 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Adding HID class support to existing USB function driver

Hi Doron

Thanks for your help on this. Just one last thing, my function drive is not
KMDF, it was inherited by be and is just a plain old WDM driver. Should I
look at the toaster\wdm\bus sample driver on how to enumearte my child
device? Also, any other things to watch out for?

Thanks again
Nick


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

______________________________________________
This email has been scanned by Netintelligence
http://www.netintelligence.com/email

>and is just a plain old WDM driver. Should I look at the toaster\wdm\bus sample driver on how to

enumearte my child device?

Yes.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

> handle a bunch of PnP IRPs. It looks like the driver installation is

achieved by the use of a GUID_DEVCLASS_TOASTER in the sample (returned in
the IRP_MN_QUERY_BUS_INFORMATION).

No, it is achieved by the responses to MN_QUERY_ID. The devclass GUID should be changed too :slight_smile:


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com