2 Copyright (c) 2006-2008 dogbert <dogber1@gmail.com>
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #define PC_IMPLEMENTATION // for the implementation of IDMAChannel
36 class CMiniportWaveStreamCMI;
38 class CMiniportWaveCMI:
40 public IMiniportWaveRT,
42 public IMiniportWaveCyclic,
44 public IMiniportWaveCMI,
48 PCMIADAPTER CMIAdapter; // Adapter common object.
53 PDMACHANNEL DMAChannel[3];
54 UInt32 notificationInterval;
57 UInt32 requestedChannelCount;
58 UInt32 requestedChannelMask;
61 CMiniportWaveStreamCMI *stream[3];
62 bool isStreamRunning[3];
65 NTSTATUS processResources(PRESOURCELIST resourceList);
67 NTSTATUS isFormatAllowed(UInt32 sampleRate, BOOLEAN multiChan, BOOLEAN AC3);
68 NTSTATUS validateFormat(PKSDATAFORMAT format, ULONG PinID, BOOLEAN capture);
70 NTSTATUS newDMAChannel(PDMACHANNEL *dmaChannel, UInt32 bufferLength);
72 NTSTATUS loadChannelConfigFromRegistry();
73 NTSTATUS storeChannelConfigToRegistry();
75 DECLARE_STD_UNKNOWN();
76 DEFINE_STD_CONSTRUCTOR(CMiniportWaveCMI);
81 IMP_IMiniportWaveCyclic;
84 STDMETHODIMP_(void) ServiceWaveISR(UInt32 streamIndex);
85 STDMETHODIMP_(void) powerUp();
86 STDMETHODIMP_(void) powerDown();
88 friend NTSTATUS NTAPI PropertyHandler_ChannelConfig(PPCPROPERTY_REQUEST PropertyRequest);
89 friend class CMiniportWaveStreamCMI;
93 class CMiniportWaveStreamCMI:
95 public IMiniportWaveRTStream,
97 public IMiniportWaveCyclicStream,
99 public IDrmAudioStream,
103 CMiniportWaveCMI *Miniport;
105 PPORTWAVERTSTREAM Port;
108 UInt32 dmaMemorySize;
110 PDMACHANNEL DMAChannel;
111 PSERVICEGROUP ServiceGroup; // For notification.
114 bool isCaptureStream;// Capture or render.
116 UInt32 channelNumber; // hardware channel number: 0/A or 1/B
117 KSSTATE state; // Stop, pause, run.
118 UInt32 periodSize; // process n frames until the interrupt is fired in frames, NOT in bytes
119 UInt32 dmaSize; // size of the DMA buffer in frames, NOT in bytes
120 UInt32 currentChannelCount, currentSampleRate, currentResolution;
121 bool enableAC3Passthru, enableSPDIF;
123 NTSTATUS prepareStream();
124 NTSTATUS setDACChannels();
125 NTSTATUS setupSPDIFPlayback(bool enableSPDIF);
126 NTSTATUS setupAC3Passthru();
129 DECLARE_STD_UNKNOWN();
130 DEFINE_STD_CONSTRUCTOR(CMiniportWaveStreamCMI);
131 ~CMiniportWaveStreamCMI();
133 IMP_IMiniportWaveRTStream;
135 IMP_IMiniportWaveCyclicStream;
141 NTSTATUS Init(CMiniportWaveCMI* Miniport_, UInt32 streamIndex_, bool isCaptureStream_, PKSDATAFORMAT DataFormat, PPORTWAVERTSTREAM PortStream_);
143 NTSTATUS Init(CMiniportWaveCMI* Miniport_, UInt32 streamIndex_, bool isCaptureStream_, PKSDATAFORMAT DataFormat, PDMACHANNEL DMAChannel_, PSERVICEGROUP* OutServiceGroup);
145 friend class CMiniportWaveCMI;
148 NTSTATUS CreateMiniportWaveStreamCMI(CMiniportWaveStreamCMI **MiniportWaveStreamCMI, PUNKNOWN pUnknownOuter, POOL_TYPE PoolType);
150 #endif //_MINWAVE_HPP_