[wdmaudiodev] Re: Read Write PCI Configuration Space

This code might help. If you are writing to command and status reg - offset
should be 4 and length should be 4.

WritePCIConfigSpace
(
        IN      PDEVICE_OBJECT pLowerDevObj,   
        IN OUT  PVOID       pBuffer,    
        IN      ULONG       Offset,     
        IN      ULONG       Length      
)
{
        NTSTATUS        ntStatus = STATUS_SUCCESS;
        KEVENT          WaitEvent;

        // Allocate an irp
        PIRP irp = IoAllocateIrp( pLowerDevObj->StackSize,
                                                          FALSE );
        if(NULL != irp)
        {
                // get top stack location
                PIO_STACK_LOCATION irpStack = IoGetNextIrpStackLocation( irp
);

                // setup the stack location
                irpStack->MajorFunction = IRP_MJ_PNP;
                irpStack->MinorFunction = IRP_MN_WRITE_CONFIG;
                irpStack->DeviceObject =  pLowerDevObj;

                // init the config space parameters
                irpStack->Parameters.ReadWriteConfig.WhichSpace = 0;    //
must be 0
                irpStack->Parameters.ReadWriteConfig.Buffer = pBuffer;
                irpStack->Parameters.ReadWriteConfig.Offset = Offset;
                irpStack->Parameters.ReadWriteConfig.Length = Length;

                // set the thread
                irp->Tail.Overlay.Thread = PsGetCurrentThread();

                // init the status block
                irp->IoStatus.Status = STATUS_NOT_SUPPORTED;

                // initialize the event
                KeInitializeEvent( &WaitEvent,
                                                   SynchronizationEvent,
                                                   FALSE );

                // set the completion routine
                IoSetCompletionRoutine( irp,
        
CompletionRoutine,
                                                                &WaitEvent,
                                                                TRUE,
                                                                TRUE,
                                                                TRUE );

                // pass the irp to the device object
                ntStatus = IoCallDriver( pLowerDevObj,
                                                                 irp );

                // wait if the irp is pending
                if(ntStatus == STATUS_PENDING)
                {
                        // wait for completion
                        ntStatus = KeWaitForSingleObject( &WaitEvent,
        
Executive,
        
KernelMode,
        
FALSE,
        
NULL );
                }

        } else
        {
                ntStatus = STATUS_INSUFFICIENT_RESOURCES;
        }

        return ntStatus;

}

CompletionRoutine
(
        IN      PDEVICE_OBJECT  DeviceObject,
        IN      PIRP            Irp,
        IN      PKEVENT           Context
)
{
        // set the event
        KeSetEvent( Context, IO_NO_INCREMENT, FALSE);
        return STATUS_MORE_PROCESSING_REQUIRED;
}

-----Original Message-----
From: Nitin Porwal, Noida [mailto:nitinp@xxxxxxxxxxxxxxxxx]
Sent: Friday, March 05, 2004 12:57 AM
To: 'wdmaudiodev@xxxxxxxxxxxxx '
Subject: [wdmaudiodev] Read Write PCI Configuration Space


Hi,
  Does anybody have some stuff about how to read/write the PCI Configuration
space. my objective is to set some bits in the Command and Status register
of PCI Config space. If anybody can provide me sample code then it would be
of great help


Thanks
Nitin

-----Original Message-----
From: wdmaudiodev-bounce@xxxxxxxxxxxxx
To: wdmaudiodev@xxxxxxxxxxxxx
Sent: 3/4/04 1:37 PM
Subject: [wdmaudiodev] Re: Modified kernel streaming example

Well, actually not. I had this problem with one specific device only
and only for large buffers (2048 samples and more).

I have not followed this problem too much even though the technical 
support of the device
gave me a contact address for the driver I used. I did not contact the 
person however
because it seemed that with the latest version of the driver which is 
available in the meantime
the problem disappeared (no intensive testing!).

I modified my own software also to achieve better performance in another

context.
Also this may be the reason why it seems to work now:

I am using the KS-example for capture and playback (duplex), not only 
for playback.
In the latest version of my software I have one thread for incoming and 
one for outgoing buffers.
Before I had one thread for both, waiting for all events in one 
Wait-function.

Mmmh, the problem I described was only for playback... Maybe it is 
helpful anyway.

But there was no change in the context of KS-Interfacing actually...

Best Regards,
Hauke

Jerry Evans wrote:

>I have run into exactly the same problem with the AC97 drivers in WinXP
SP1.
>Did you find a solution ?
>
>Does anyone know what to do when this occurs ?
>
>TIA
>
>Jerry
>
>----- Original Message ----- 
>From: "User for realtime audio" <audiodev@xxxxxxxxxxxxxxxxxx>
>To: <wdmaudiodev@xxxxxxxxxxxxx>
>Sent: Wednesday, December 17, 2003 11:20 AM
>Subject: [wdmaudiodev] Re: Modified kernel streaming example
>
>
>>Well, still suffering the same problem I have found out something new:
>>
>>It seems that my problem is correlated to the order of the buffers
being
>>processed
>>by the driver:
>>If using 8 Buffers to flush the order to write the buffers should be
>>0..7 according to the
>>first write-accesses to the driver. And that should be the order of
the
>>signalled events.
>>
>>Whenever using buffers with critical sizes the order in which the
>>buffer-writes have been
>>completed are kind of arbitrary, e.g. 0 5 3 7 0 2 5 6.
>>
>>In case of those buffersizes that function propperly, the order is as
>>expected 0..7.
>>Thus it seems that the driver somehow writes the buffers to the
hardware
>>in a wrong order, thus my question:
>>
>
>
>******************
>
>WDMAUDIODEV addresses:
>Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
>Subscribe:
mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
>Unsubscribe:
mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
>Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx
>
>URL to WDMAUDIODEV page:
>http://www.wdmaudiodev.de/
>
>
>
>


******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:
mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.de/
******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.de/
******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.de/

Other related posts: