Author: janderwald
Date: Wed Dec 22 13:52:25 2010
New Revision: 50094
URL:
http://svn.reactos.org/svn/reactos?rev=50094&view=rev
Log:
[PSDK]
- Add ks gate functions
Modified:
branches/audio-bringup/include/psdk/ks.h
Modified: branches/audio-bringup/include/psdk/ks.h
URL:
http://svn.reactos.org/svn/reactos/branches/audio-bringup/include/psdk/ks.h…
==============================================================================
--- branches/audio-bringup/include/psdk/ks.h [iso-8859-1] (original)
+++ branches/audio-bringup/include/psdk/ks.h [iso-8859-1] Wed Dec 22 13:52:25 2010
@@ -2928,6 +2928,232 @@
XP / DX8
*/
#if defined(_NTDDK_)
+
+typedef struct _KSGATE KSGATE, *PKSGATE;
+
+struct _KSGATE {
+ LONG Count;
+ PKSGATE NextGate;
+};
+
+#ifndef _NTOS_
+
+static
+void
+__inline
+KsGateTurnInputOn(
+ IN PKSGATE Gate OPTIONAL)
+{
+ while (Gate && (InterlockedIncrement(&Gate->Count) == 1))
+ {
+ Gate = Gate->NextGate;
+ }
+}
+
+static
+void
+__inline
+KsGateTurnInputOff(
+ IN PKSGATE Gate OPTIONAL)
+{
+ while (Gate && (InterlockedDecrement(&Gate->Count) == 0))
+ {
+ Gate = Gate->NextGate;
+ }
+}
+
+static
+BOOLEAN
+__inline
+KsGateGetStateUnsafe(
+ IN PKSGATE Gate)
+{
+ ASSERT(Gate);
+ return((BOOLEAN)(Gate->Count > 0));
+}
+
+static
+BOOLEAN
+__inline
+KsGateCaptureThreshold(
+ IN PKSGATE Gate)
+{
+ BOOLEAN captured;
+
+ ASSERT(Gate);
+
+ captured = (BOOLEAN)(InterlockedCompareExchange(&Gate->Count,0,1) == 1);
+
+ if (captured)
+ {
+ KsGateTurnInputOff(Gate->NextGate);
+ }
+
+ return captured;
+}
+
+static
+void
+__inline
+KsGateInitialize(
+ IN PKSGATE Gate,
+ IN LONG InitialCount,
+ IN PKSGATE NextGate OPTIONAL,
+ IN BOOLEAN StateToPropagate
+ )
+{
+ ASSERT(Gate);
+ Gate->Count = InitialCount;
+ Gate->NextGate = NextGate;
+
+ if (NextGate)
+ {
+ if (InitialCount > 0)
+ {
+ if (StateToPropagate)
+ {
+ KsGateTurnInputOn(NextGate);
+ }
+ }
+ else
+ {
+ if (!StateToPropagate)
+ {
+ KsGateTurnInputOff(NextGate);
+ }
+ }
+ }
+}
+
+static
+void
+__inline
+KsGateInitializeAnd(
+ IN PKSGATE AndGate,
+ IN PKSGATE NextOrGate OPTIONAL)
+{
+ KsGateInitialize(AndGate,1,NextOrGate,TRUE);
+}
+
+static
+void
+__inline
+KsGateInitializeOr(
+ IN PKSGATE OrGate,
+ IN PKSGATE NextAndGate OPTIONAL)
+{
+ KsGateInitialize(OrGate,0,NextAndGate,FALSE);
+}
+
+static
+void
+__inline
+KsGateAddOnInputToAnd(
+ IN PKSGATE AndGate)
+{
+ UNREFERENCED_PARAMETER (AndGate);
+}
+
+static
+void
+__inline
+KsGateAddOffInputToAnd(
+ IN PKSGATE AndGate)
+{
+ KsGateTurnInputOff(AndGate);
+}
+
+static
+void
+__inline
+KsGateRemoveOnInputFromAnd(
+ IN PKSGATE AndGate)
+{
+ UNREFERENCED_PARAMETER (AndGate);
+}
+
+static
+void
+__inline
+KsGateRemoveOffInputFromAnd(
+ IN PKSGATE AndGate)
+{
+ KsGateTurnInputOn(AndGate);
+}
+
+static
+void
+__inline
+KsGateAddOnInputToOr(
+ IN PKSGATE OrGate)
+{
+ KsGateTurnInputOn(OrGate);
+}
+
+static
+void
+__inline
+KsGateAddOffInputToOr(
+ IN PKSGATE OrGate)
+{
+ UNREFERENCED_PARAMETER (OrGate);
+}
+
+static
+void
+__inline
+KsGateRemoveOnInputFromOr(
+ IN PKSGATE OrGate)
+{
+ KsGateTurnInputOff(OrGate);
+}
+
+static
+void
+__inline
+KsGateRemoveOffInputFromOr(
+ IN PKSGATE OrGate)
+{
+ UNREFERENCED_PARAMETER (OrGate);
+}
+
+static
+void
+__inline
+KsGateTerminateAnd(
+ IN PKSGATE AndGate)
+{
+ ASSERT(AndGate);
+ if (KsGateGetStateUnsafe(AndGate))
+ {
+ KsGateRemoveOnInputFromOr(AndGate->NextGate);
+ }
+ else
+ {
+ KsGateRemoveOffInputFromOr(AndGate->NextGate);
+ }
+}
+
+static
+void
+__inline
+KsGateTerminateOr(
+ IN PKSGATE OrGate)
+{
+ ASSERT(OrGate);
+ if (KsGateGetStateUnsafe(OrGate))
+ {
+ KsGateRemoveOnInputFromAnd(OrGate->NextGate);
+ }
+ else
+ {
+ KsGateRemoveOffInputFromAnd(OrGate->NextGate);
+ }
+}
+
+#endif
+
+
struct _KSMAPPING {
PHYSICAL_ADDRESS PhysicalAddress;
ULONG ByteCount;
@@ -2940,13 +3166,7 @@
KSSTREAM_POINTER_STATE_LOCKED
} KSSTREAM_POINTER_STATE;
-typedef struct _KSGATE KSGATE, *PKSGATE;
typedef struct _KSPROCESSPIN_INDEXENTRY KSPROCESSPIN_INDEXENTRY,
*PKSPROCESSPIN_INDEXENTRY;
-
-struct _KSGATE {
- LONG Count;
- PKSGATE NextGate;
-};
struct _KSSTREAM_POINTER_OFFSET
{