Implementing Jack Sensing for Windows XP

Hello everyone,
I have been trying to implement the Vista’s Jack Sensing API (GetState) for Windows XP. I read about the HD Audio’s DDI and realized I could just send an IRP to the HD Audio Bus Driver to do the work for me. However, I can’t seem to be able to get the device object in order to send the IRP to it.

I want to add the jack sensing ability to the current audio driver, not implement a whole adapter driver of my own.

I have been looking around the web for a solution, and I am not sure what I should do:

  1. Write a filter driver that attaches the audio stack so I can pass the IRP down the stack. The problem is that I need to filter other irrelevant requests, which is something I am not willing to do. Further than that, I will have to get some device from the stack to attach to it.
  2. Write a virtual audio driver. I came accross this option while Googling, but I am surely not convinced it’s a good one. As I’ve already mentioned, I am not trying to replace the existent driver, neither do I want to intercept requests to the driver or handle anything I don’t need to. However, if I do register as a virtual audio driver, meaning my driver will function as an adapter driver, I will have the option to send the IRP down the stack.
  3. Somehow get the device object for the HD Audio Bus Driver’s device, so I can send it the wanted IRP. This is obviously the better option, but I don’t know how to accomplish it.

Thanks very much in advance,
Moshe.

Hello again,
I’ve searched a lot and found that I should probably use IoGetDeviceInterfaces in order to get the symbolic link of the HDAudio device interface, and then use IoGetDeviceObjectPointer in order to later send IRPs to it.

The problem is I don’t know what GUID to use for the IoGetDeviceInterfaces command, so I can get the HD Audio bus interface. Does any of you know how I can find the right one?

Thanks again!

xxxxx@yahoo.com wrote:

I’ve searched a lot and found that I should probably use IoGetDeviceInterfaces in order to get the symbolic link of the HDAudio device interface, and then use IoGetDeviceObjectPointer in order to later send IRPs to it.

Hmm. Where did you read that? The HDAudio driver does offer services
to its own child drivers. Such a driver sends an IRP_MN_QUERY_INTERFACE
plug-and-play request to its parent driver to fetch the
HDAUDIO_BUS_INTERFACE or HDAUDIO_BUS_INTERFACE_V2 interfaces. In this
case, you’d use GUID_HDAUDIO_BUS_INTERFACE as the InterfaceType.

This is described in
http://www.microsoft.com/whdc/device/audio/hdaudioddi.mspx.

However, that mechanism is COMPLETELY DIFFERENT from the device
interface mechanism accessed by IoGetDeviceInterfaces. To call
IRP_MN_QUERY_INTERFACE, you need a PDO, and that is handed to a child
driver when it loads.

The problem is I don’t know what GUID to use for the IoGetDeviceInterfaces command, so I can get the HD Audio bus interface. Does any of you know how I can find the right one?

What IRPs do you want to send? Is this from an HDAudio child driver, or
from some other driver?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for your reply Tim,
How is a driver considered an HD Audio child driver?

What I want to do is indeed send an IRP_MN_QUERY_INTERFACE to the HD Audio bus driver as you have described, I apologize for not explaining myself correctly.
What I wished for using the IoGetDeviceInterfaces is a way to communicate with the HD Audio bus driver, as I don’t have one right now, perhaps since my driver is not an HD Audio child driver (and I don’t know how to achieve that).

My aim is to send an IRP_MN_QUERY_INTERFACE to the bus driver, in order to later use it’s transferCodecVerbs routine and send commands to the codecs. I am looking for the easiest way to do this, preferrably without having to act as a filter driver or write my own virtual audio driver.

Thanks again.

xxxxx@yahoo.com wrote:

Thanks for your reply Tim,
How is a driver considered an HD Audio child driver?

When an HDAudio device is detected, it will be enumerated as a child of
the HDAudio bus driver. Such a driver has the right to use the services
of the HDAudio bus driver.

What I want to do is indeed send an IRP_MN_QUERY_INTERFACE to the HD Audio bus driver as you have described, I apologize for not explaining myself correctly.
What I wished for using the IoGetDeviceInterfaces is a way to communicate with the HD Audio bus driver, as I don’t have one right now, perhaps since my driver is not an HD Audio child driver (and I don’t know how to achieve that).

IoGetDeviceInterfaces and IRP_MN_QUERY_INTERFACE are two completely
different concepts.

My aim is to send an IRP_MN_QUERY_INTERFACE to the bus driver, in order to later use it’s transferCodecVerbs routine and send commands to the codecs. I am looking for the easiest way to do this, preferrably without having to act as a filter driver or write my own virtual audio driver.

If you are not an HDAudio device, then why do you believe the HDAudio
bus driver has any services of value to you?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hello and thanks again,
You said that:

When an HDAudio device is detected, it will be enumerated as a child of
the HDAudio bus driver. Such a driver has the right to use the services
of the HDAudio bus driver.

Well, how is a device detected as an HD Audio device?

Again, my aim is to use the HD Audio bus driver in order to run a command on one of the devices that are connected to it. I would like to use the HD Audio’s Pin Sense capability on my sound card, while running on Windows XP, in order to figure out whether anything is plugged into a certain jack.
How would you suggest to do it otherwise?

xxxxx@yahoo.com wrote:

Hello and thanks again,
You said that:
> When an HDAudio device is detected, it will be enumerated as a child of
> the HDAudio bus driver. Such a driver has the right to use the services
> of the HDAudio bus driver.
Well, how is a device detected as an HD Audio device?

The HD Audio spec defines what the HD Audio bus is. Only devices that
meet the Intel HD Audio spec and live on an HDAudio Link are HD Audio
devices, and those are the only devices can use the HDAudio bus driver
services. The bus driver understands how to talk to those devices, but
not others.

ftp://download.intel.com/standards/hdaudio/pdf/hdaudio_03.pdf
http://www.microsoft.com/whdc/device/audio/hdaudioddi.mspx

Again, my aim is to use the HD Audio bus driver in order to run a command on one of the devices that are connected to it. I would like to use the HD Audio’s Pin Sense capability on my sound card, while running on Windows XP, in order to figure out whether anything is plugged into a certain jack.
How would you suggest to do it otherwise?

If your device is an HDAudio device living on an HDAudio bus, then all
of this should come for free. If you are not an HDAudio device, then
the HDAudio driver has absolutely no idea how to query your hardware to
find out whether something is plugged in. That’s something YOU have to
provide. I don’t know offhand which properties you have to support in
order to expose jack sense capabilities, but it must be defined somewhere…


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.