I have implemented a bda driver for our usb device. Now, we should
support MCE, which requests the driver to support two devices on one
hub.

After refer to ddk sample, generictuner, I implemented GetMedium method
in the tuner filter, like following:
---8<--------------------------------------------->8---
CFilter::GetMedium(IN PIRP p_irp,
IN PKSMETHOD p_ks_property,
OUT KSPIN_MEDIUM* p_ks_medium)
{
NTSTATUS status = STATUS_SUCCESS;

if (p_ks_medium == NULL)
{
p_irp->IoStatus.Information = sizeof(KSPIN_MEDIUM);
return STATUS_MORE_ENTRIES;
}

PKSFILTER p_ks_filter = KsGetFilterFromIrp(p_irp);
if (p_ks_filter == NULL || p_ks_filter->Context == NULL)
{
status = STATUS_INVALID_PARAMETER;
return status;
}

CFilter* p_filter = (CFilter*)p_ks_filter->Context;
if (p_filter->m_p_device == NULL)
{
status = STATUS_INVALID_PARAMETER;
return status;
}
p_filter->m_p_device->GetInstanceID(p_ks_medium->Id);

// So, we only support two instances now.
if (p_ks_medium->Id == 0)
{
p_ks_medium->Set = GUID_FIRST_INSTANCE;
}
else if (p_ks_medium->Id = 1)
{
p_ks_medium->Set = GUID_SECOND_INSTANCE;
}
else
{
p_ks_medium->Set = KSMEDIUMSETID_Standard;
}

p_ks_medium->Flags = 0;

return status;
}
---8<--------------------------------------------->8---
But after I enabled this method, the two filters, tuner and capture,
could not be conneted successfully.

Did I missed something? Or may I misunder the medium? Did the Medium
use to differentiate the instances from one driver?

Any comments are welcome!
Advance thanks!
William

Re: One driver for two device? by Max

Max
Fri Aug 04 02:35:10 CDT 2006

Medium is a way of limiting what a pin can connect to. Logically it is
similar to pin type and subtype except it is usually tied to device instance
in one way or another.
This being said if you changed (or added) medium on the output pin of the
tuner filter it will not connect to your capture filter unless you modify
medium on the input pin of that filter as well.

So what you usually do is you set the same medium on the output of the tuner
and on the input of the capture for filters that belong to the same instance
of hardware. When you do that you guarantee that tuner1 doesn't connect to
anything but capture1 and tuner2 will connect only to capture2.

-- Max.



"fantast_xue" <william.xue@gmail.com> wrote in message
news:1154506084.183090.295070@75g2000cwc.googlegroups.com...
>I have implemented a bda driver for our usb device. Now, we should
> support MCE, which requests the driver to support two devices on one
> hub.
>
> After refer to ddk sample, generictuner, I implemented GetMedium method
> in the tuner filter, like following:
> ---8<--------------------------------------------->8---
> CFilter::GetMedium(IN PIRP p_irp,
> IN PKSMETHOD p_ks_property,
> OUT KSPIN_MEDIUM* p_ks_medium)
> {
> NTSTATUS status = STATUS_SUCCESS;
>
> if (p_ks_medium == NULL)
> {
> p_irp->IoStatus.Information = sizeof(KSPIN_MEDIUM);
> return STATUS_MORE_ENTRIES;
> }
>
> PKSFILTER p_ks_filter = KsGetFilterFromIrp(p_irp);
> if (p_ks_filter == NULL || p_ks_filter->Context == NULL)
> {
> status = STATUS_INVALID_PARAMETER;
> return status;
> }
>
> CFilter* p_filter = (CFilter*)p_ks_filter->Context;
> if (p_filter->m_p_device == NULL)
> {
> status = STATUS_INVALID_PARAMETER;
> return status;
> }
> p_filter->m_p_device->GetInstanceID(p_ks_medium->Id);
>
> // So, we only support two instances now.
> if (p_ks_medium->Id == 0)
> {
> p_ks_medium->Set = GUID_FIRST_INSTANCE;
> }
> else if (p_ks_medium->Id = 1)
> {
> p_ks_medium->Set = GUID_SECOND_INSTANCE;
> }
> else
> {
> p_ks_medium->Set = KSMEDIUMSETID_Standard;
> }
>
> p_ks_medium->Flags = 0;
>
> return status;
> }
> ---8<--------------------------------------------->8---
> But after I enabled this method, the two filters, tuner and capture,
> could not be conneted successfully.
>
> Did I missed something? Or may I misunder the medium? Did the Medium
> use to differentiate the instances from one driver?
>
> Any comments are welcome!
> Advance thanks!
> William
>



Re: One driver for two device? by WilliamX

WilliamX
Fri Aug 04 06:45:50 CDT 2006

Thank you very much, Max! I fixed the two instances connection issue =

according to your another post. I dynamically created the =

KSFILTER_DESCRIPTOR with different Id. And the descriptor must be used i=
n =

BdaInitFilter.
But I still don't know about the usage of GetMedium which introduced in =
=

the ddk sample, generictuner. Though, it is commented out.
And could you have a look at the topic: Can't get stream point when =

attached two devices into a usb hub?

On Fri, 04 Aug 2006 15:35:10 +0800, you wrote in =

microsoft.public.development.device.drivers:

> Medium is a way of limiting what a pin can connect to. Logically it is=

> similar to pin type and subtype except it is usually tied to device =

> instance
> in one way or another.
> This being said if you changed (or added) medium on the output pin of =
the
> tuner filter it will not connect to your capture filter unless you mod=
ify
> medium on the input pin of that filter as well.
>
> So what you usually do is you set the same medium on the output of the=
=

> tuner
> and on the input of the capture for filters that belong to the same =

> instance
> of hardware. When you do that you guarantee that tuner1 doesn't connec=
t =

> to
> anything but capture1 and tuner2 will connect only to capture2.
>
> -- Max.
>
>
>
> "fantast_xue" <william.xue@gmail.com> wrote in message
> news:1154506084.183090.295070@75g2000cwc.googlegroups.com...
>> I have implemented a bda driver for our usb device. Now, we should
>> support MCE, which requests the driver to support two devices on one
>> hub.
>>
>> After refer to ddk sample, generictuner, I implemented GetMedium meth=
od
>> in the tuner filter, like following:
>> ---8<--------------------------------------------->8---
>> CFilter::GetMedium(IN PIRP p_irp,
>> IN PKSMETHOD p_ks_property,
>> OUT KSPIN_MEDIUM* p_ks_medium)
>> {
>> NTSTATUS status =3D STATUS_SUCCESS;
>>
>> if (p_ks_medium =3D=3D NULL)
>> {
>> p_irp->IoStatus.Information =3D sizeof(KSPIN_MEDIUM);
>> return STATUS_MORE_ENTRIES;
>> }
>>
>> PKSFILTER p_ks_filter =3D KsGetFilterFromIrp(p_irp);
>> if (p_ks_filter =3D=3D NULL || p_ks_filter->Context =3D=3D NUL=
L)
>> {
>> status =3D STATUS_INVALID_PARAMETER;
>> return status;
>> }
>>
>> CFilter* p_filter =3D (CFilter*)p_ks_filter->Context;
>> if (p_filter->m_p_device =3D=3D NULL)
>> {
>> status =3D STATUS_INVALID_PARAMETER;
>> return status;
>> }
>> p_filter->m_p_device->GetInstanceID(p_ks_medium->Id);
>>
>> // So, we only support two instances now.
>> if (p_ks_medium->Id =3D=3D 0)
>> {
>> p_ks_medium->Set =3D GUID_FIRST_INSTANCE;
>> }
>> else if (p_ks_medium->Id =3D 1)
>> {
>> p_ks_medium->Set =3D GUID_SECOND_INSTANCE;
>> }
>> else
>> {
>> p_ks_medium->Set =3D KSMEDIUMSETID_Standard;
>> }
>>
>> p_ks_medium->Flags =3D 0;
>>
>> return status;
>> }
>> ---8<--------------------------------------------->8---
>> But after I enabled this method, the two filters, tuner and capture,
>> could not be conneted successfully.
>>
>> Did I missed something? Or may I misunder the medium? Did the Medium
>> use to differentiate the instances from one driver?
>>
>> Any comments are welcome!
>> Advance thanks!
>> William
>>
>
>

Re: One driver for two device? by Max

Max
Fri Aug 04 17:33:08 CDT 2006

I saw your question about USB hub related issues.
I have absolutely no clue how hub can cause this problem.

My wild guess is that you have a race in your driver. When you device is
connected through the hub some timing in which you consume USB bits is
different comparing to direct connection. Which causes a bug in your driver
to come out.

The most likely reason for the leading edge stream pointer to be NULL is
that all buffers in the queue are consumed. Maybe you are cloning stream
pointers somewhere and not unlocking them somehow? That causes them to keep
hanging around and eventually the queue allocated for you by AVStream gets
exhausted.
That would be the only thing that I can think of.

-- Max.




"WilliamX" <william.xue@gmail.com.nospam> wrote in message
news:op.tdrb8rn0sed5ky@williamxue...
Thank you very much, Max! I fixed the two instances connection issue
according to your another post. I dynamically created the
KSFILTER_DESCRIPTOR with different Id. And the descriptor must be used in
BdaInitFilter.
But I still don't know about the usage of GetMedium which introduced in
the ddk sample, generictuner. Though, it is commented out.
And could you have a look at the topic: Can't get stream point when
attached two devices into a usb hub?

On Fri, 04 Aug 2006 15:35:10 +0800, you wrote in
microsoft.public.development.device.drivers:

> Medium is a way of limiting what a pin can connect to. Logically it is
> similar to pin type and subtype except it is usually tied to device
> instance
> in one way or another.
> This being said if you changed (or added) medium on the output pin of the
> tuner filter it will not connect to your capture filter unless you modify
> medium on the input pin of that filter as well.
>
> So what you usually do is you set the same medium on the output of the
> tuner
> and on the input of the capture for filters that belong to the same
> instance
> of hardware. When you do that you guarantee that tuner1 doesn't connect
> to
> anything but capture1 and tuner2 will connect only to capture2.
>
> -- Max.
>
>
>
> "fantast_xue" <william.xue@gmail.com> wrote in message
> news:1154506084.183090.295070@75g2000cwc.googlegroups.com...
>> I have implemented a bda driver for our usb device. Now, we should
>> support MCE, which requests the driver to support two devices on one
>> hub.
>>
>> After refer to ddk sample, generictuner, I implemented GetMedium method
>> in the tuner filter, like following:
>> ---8<--------------------------------------------->8---
>> CFilter::GetMedium(IN PIRP p_irp,
>> IN PKSMETHOD p_ks_property,
>> OUT KSPIN_MEDIUM* p_ks_medium)
>> {
>> NTSTATUS status = STATUS_SUCCESS;
>>
>> if (p_ks_medium == NULL)
>> {
>> p_irp->IoStatus.Information = sizeof(KSPIN_MEDIUM);
>> return STATUS_MORE_ENTRIES;
>> }
>>
>> PKSFILTER p_ks_filter = KsGetFilterFromIrp(p_irp);
>> if (p_ks_filter == NULL || p_ks_filter->Context == NULL)
>> {
>> status = STATUS_INVALID_PARAMETER;
>> return status;
>> }
>>
>> CFilter* p_filter = (CFilter*)p_ks_filter->Context;
>> if (p_filter->m_p_device == NULL)
>> {
>> status = STATUS_INVALID_PARAMETER;
>> return status;
>> }
>> p_filter->m_p_device->GetInstanceID(p_ks_medium->Id);
>>
>> // So, we only support two instances now.
>> if (p_ks_medium->Id == 0)
>> {
>> p_ks_medium->Set = GUID_FIRST_INSTANCE;
>> }
>> else if (p_ks_medium->Id = 1)
>> {
>> p_ks_medium->Set = GUID_SECOND_INSTANCE;
>> }
>> else
>> {
>> p_ks_medium->Set = KSMEDIUMSETID_Standard;
>> }
>>
>> p_ks_medium->Flags = 0;
>>
>> return status;
>> }
>> ---8<--------------------------------------------->8---
>> But after I enabled this method, the two filters, tuner and capture,
>> could not be conneted successfully.
>>
>> Did I missed something? Or may I misunder the medium? Did the Medium
>> use to differentiate the instances from one driver?
>>
>> Any comments are welcome!
>> Advance thanks!
>> William
>>
>
>