KSPROPERTY_TYPE_BASICSUPPORT and ksproxy.

Discussion in 'Windows Vista Drivers' started by Tom Udale, Dec 15, 2003.

  1. Tom Udale

    Tom Udale Guest

    I am trying to use KSPROPERTY_TYPE_BASICSUPPORT in a ksproxy plugin to
    retrieve the full KSPROPERTY_MEMBERSLIST information I set in the
    driver. The driver sets two member list items, each with one member.
    The first is a KSPROPERTY_STEPPING_LONG with the range for the
    parameter, the second is a default value.

    In the plugin, I call IKsControl->KsProperty twice. The first time to
    get the full KSPROPERTY_DESCRIPTION size, the second time to get the
    full KSPROPERTY_DESCRIPTION. The
    KSPROPERTY_DESCRIPTION.MembersListCount value is coming back as two, but
    I am running out of data before I get to the second
    KSPROPERTY_MEMBERSHEADER. I get the first KSPROPERTY_MEMBERSHEADER, and
    the following KSPROPERTY_STEPPING_LONG but that is it.

    I could understand if they are going to filter out the default values
    since I think there is a second method of getting those, but should they
    not set KSPROPERTY_DESCRIPTION.MembersListCount value to 1 in that case?

    Perhaps there is some trouble in the code (which would not surprise me
    since I can find only the most cursory documentation for
    KSPROPERTY_TYPE_BASICSUPPORT).

    I included the code below.

    Regards,
    Tom Udale


    KSPROPERTY cmd;
    KSPROPERTY_DESCRIPTION desc;
    ULONG sz;

    cmd.Set = PROPSETID_VI80U_CTRL;
    cmd.Id = prpID;
    cmd.Flags = KSPROPERTY_TYPE_BASICSUPPORT;

    if(m_psInterface->KsProperty(&cmd,sizeof(cmd),&desc,sizeof(desc),&sz)==S
    _OK)
    {
    size_t buffSz=desc.DescriptionSize;
    unsigned char* buff=(unsigned char*)malloc(buffSz);

    if(buff)
    {
    memset(buff,'?',buffSz);
    if(m_psInterface->KsProperty(&cmd,sizeof(cmd),buff,buffSz,&sz)==S_OK)
    {
    ...etc
    }
    }
     
    Tom Udale, Dec 15, 2003
    #1
    1. Advertisements

  2. Tom Udale

    Max Paklin Guest

    Tom,

    I am too lazy to check all details of your message and code. They appear to
    be fine, but there could be a little problem somewhere that I missed.

    Below I put the code that I used some time ago. I remember it was working
    fine. It might be of some help to you.

    KSIDENTIFIER ksIdentifier;
    ksIdentifier.Set = gGet;
    ksIdentifier.Id = dwPropId;
    ksIdentifier.Flags = KSPROPERTY_TYPE_BASICSUPPORT;

    BYTE btOutBuffer[512];
    DWORD dwReturned;
    hResult = KsSynchronousDeviceControl(
    hKsObject,
    IOCTL_KS_PROPERTY,
    &ksIdentifier,
    sizeof( ksIdentifier ),
    btOutBuffer,
    sizeof( btOutBuffer ),
    &dwReturned );

    if( SUCCEEDED( hResult ) )
    {
    PBYTE pPointer;

    // Output buffer will contain data of KSPROPERTY_DESCRIPTION
    format
    PKSPROPERTY_DESCRIPTION pPropDesc;
    pPropDesc = reinterpret_cast< PKSPROPERTY_DESCRIPTION >(
    btOutBuffer );

    // KSPROPERTY_DESCRIPTION is followed by
    KSPROPERTY_MEMBERSHEADER
    // structure(s) and each of this KSPROPERTY_MEMBERSHEADER may in
    turn
    // be followed by a number of values structure(s). If the
    MembersFlags
    // of KSPROPERTY_MEMBERSHEADER is
    KSPROPERTY_MEMBER_STEPPEDRANGES
    // then it's our guy of a type KSPROPERTY_STEPPING_LONG
    pPointer = &btOutBuffer[sizeof( KSPROPERTY_DESCRIPTION )];
    PKSPROPERTY_MEMBERSHEADER pHeader;
    pHeader = reinterpret_cast< PKSPROPERTY_MEMBERSHEADER >(
    pPointer );

    for( UINT i = 0; i < pPropDesc->MembersListCount; i++ )
    {
    BOOL bFound = FALSE;

    for( UINT j = 0; j < pHeader->MembersCount; j++ )
    {
    if( pHeader->MembersFlags !=
    KSPROPERTY_MEMBER_STEPPEDRANGES )
    continue;

    pPointer = reinterpret_cast< PBYTE >( pHeader+1 ) +
    j*pHeader->MembersSize;
    PKSPROPERTY_STEPPING_LONG pBounds;
    pBounds = reinterpret_cast< PKSPROPERTY_STEPPING_LONG
    *pMin = pBounds->Bounds.SignedMinimum;
    *pMax = pBounds->Bounds.SignedMaximum;

    bFound = TRUE;
    break;
    }

    if( bFound )
    break;

    // Take the size of structures of values
    int nSize = pHeader->MembersCount*pHeader->MembersSize;
    // Skip current header
    ++pHeader;

    // Skip all the value structures after header
    pPointer = reinterpret_cast< PBYTE >( pHeader ) + nSize;
    pHeader = reinterpret_cast< PKSPROPERTY_MEMBERSHEADER >(
    pPointer );
    }
    }

    -- Max.
     
    Max Paklin, Dec 15, 2003
    #2
    1. Advertisements

  3. Tom Udale

    Tom Udale Guest

    Max,

    Thanks alot for the code. You did the same thing as me. Ironically,
    your code would run without complaint in my situation.

    You are not checking if the values in pHeader make any sense if
    pHeader->MembersFlags !=KSPROPERTY_MEMBER_STEPPEDRANGES, which makes
    sense in this application . Since your 512 buffer is pretty huge, you
    would never notice (due to a GP fault, for example) if you were chewing
    through more than dwReturned worth of data.

    Since yours works one of two things must be happening

    a) your KSPROPERTY_MEMBER_STEPPEDRANGES as the first member list item in
    the driver (which I get the sense is common). Thus your search it
    always found it on the first time through the i loop or

    b) whoever is implementing KSPROPERTY_TYPE_BASICSUPPORT is doing a
    better job than in my case and is actually returning
    pPropDesc->MembersListCount worth of data after the
    KSPROPERTY_DESCRIPTION.
    Was this a stream or avstream driver?

    So, unfortunately, I still cannot tell if the problem I am having is due
    to my driver or the stream class code. I looked over the
    KSPROPERTY_VALUES for these properties and they look fine.

    I will keep looking (try multiple ranges KSPROPERTY_MEMBER_STEPPEDRANGES
    and what-not).

    Regards,

    Tom


    (BTW it looks like there is something odd going on in your j loop. The
    conditional is a loop invarient....)



     
    Tom Udale, Dec 16, 2003
    #3
  4. Tom Udale

    Max Paklin Guest

    Tom, see my comments inline.

    That's why my quick look at your code did not reveal anything obvious.

    Sure, it never intended to be as production quality stuff. Actually even
    more, this code has never been shipped. I just used it in one of internal
    test applications. It worked fine with our driver, therefore I never
    bothered to check if the code was good enough in general.

    Yep. It was always the first one.

    That was for Stream Class based minidriver.
    However these services should be provided by KS, not Stream Class, so it
    should make no difference if AVStream were to be used.

    If you haven't check yet, see TestCap sample in the DDK. I think it uses
    XXX_STEPPEDRANGES. Also check ATI samples for All-in-Wonder.

    -- Max.

     
    Max Paklin, Dec 16, 2003
    #4
  5. Tom Udale

    Tom Udale Guest

    Max,
    I see. I will putter around with it tomorrow and see how things behave
    with multiple ranges or perhaps I will try some values. It is either a
    bug in my code (likely) or some oddity in KS with either multiple member
    range items (hard to believe) or when one of the member range items is a
    default value.

    BTW, it took me a million years to figure this out and it still confuses
    the hell out of me: avstream is often described as a layer on top of ks
    (like stream class to which it is often compared and contrasted), but it
    seems that all the delclarations are in ks.h and it is served up from
    ks.sys. If it is a new layer, why in the world did they not make it
    have its own header (avstrmini.h??) like the stream class got? It
    baffles me when I try to decide what is part of ks, what is part of
    avstream, etc. It is even worse since the functions are not even
    differentiated (eg KsInitializeDriver sounds like ks to me). It is
    almost like some marketing guys got a hold of things and decided to call
    it AVStream instead of KS2 or KS mini-driver extensions or something
    like that. Or am I still completely confused?
    Will do.

    Thanks again,
    Tom
     
    Tom Udale, Dec 16, 2003
    #5
  6. Tom Udale

    Max Paklin Guest

    BTW, it took me a million years to figure this out and it still confuses
    AVStream is KS 2.0.
    I remember it was KS 2.0 and then somebody came up with that name. I guess
    it was some sort of a marketing trick.
     
    Max Paklin, Dec 16, 2003
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.