├── Source ├── Main │ ├── csaudioacp3x.inx │ ├── csaudioacp3x.rc │ ├── minwavertstream.h │ ├── Main.vcxproj.Filters │ ├── NewDelete.cpp │ ├── minwavert.h │ └── minwavertstream.cpp ├── Filters │ ├── speakertopo.h │ ├── headphonetopo.h │ ├── micjacktopo.h │ ├── Filters.vcxproj.Filters │ ├── micarraytopo.h │ ├── micjacktopo.cpp │ ├── speakertopo.cpp │ ├── headphonetopo.cpp │ ├── speakertoptable.h │ ├── headphonetoptable.h │ ├── micjacktoptable.h │ ├── micarray1toptable.h │ ├── speakerwavtable.h │ ├── micarraywavtable.h │ └── minipairs.h ├── Inc │ ├── Inc.vcxproj.Filters │ ├── mintopo.h │ ├── NewDelete.h │ ├── basetopo.h │ ├── endpoints.h │ ├── kshelper.h │ ├── definitions.h │ ├── Inc.vcxproj │ └── common.h └── Utilities │ ├── Utilities.vcxproj.Filters │ ├── acp3x.h │ ├── csaudioapi.cpp │ ├── hw.h │ └── Utilities.vcxproj ├── README.md ├── Package ├── package.VcxProj.Filters └── package.VcxProj ├── .gitignore └── csaudioacp3x.sln /Source/Main/csaudioacp3x.inx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrultrabook/csaudioacp3x/main/Source/Main/csaudioacp3x.inx -------------------------------------------------------------------------------- /Source/Filters/speakertopo.h: -------------------------------------------------------------------------------- 1 | 2 | /*++ 3 | 4 | Copyright (c) Microsoft Corporation All Rights Reserved 5 | 6 | Module Name: 7 | 8 | speakertopo.h 9 | 10 | Abstract: 11 | 12 | Declaration of topology miniport for the speaker (internal). 13 | --*/ 14 | 15 | #ifndef _CSAUDIOACP3X_SPEAKERTOPO_H_ 16 | #define _CSAUDIOACP3X_SPEAKERTOPO_H_ 17 | 18 | NTSTATUS PropertyHandler_SpeakerTopoFilter(_In_ PPCPROPERTY_REQUEST PropertyRequest); 19 | 20 | NTSTATUS PropertyHandler_SpeakerTopology(_In_ PPCPROPERTY_REQUEST PropertyRequest); 21 | 22 | #endif // _CSAUDIOACP3X_SPEAKERTOPO_H_ 23 | -------------------------------------------------------------------------------- /Source/Filters/headphonetopo.h: -------------------------------------------------------------------------------- 1 | 2 | /*++ 3 | 4 | Copyright (c) Microsoft Corporation All Rights Reserved 5 | 6 | Module Name: 7 | 8 | headphonetopo.h 9 | 10 | Abstract: 11 | 12 | Declaration of topology miniport for the headphone (jack). 13 | --*/ 14 | 15 | #ifndef _CSAUDIOACP3X_HEADPHONETOPO_H_ 16 | #define _CSAUDIOACP3X_HEADPHONETOPO_H_ 17 | 18 | NTSTATUS PropertyHandler_HeadphoneTopoFilter(_In_ PPCPROPERTY_REQUEST PropertyRequest); 19 | 20 | NTSTATUS PropertyHandler_HeadphoneTopology(_In_ PPCPROPERTY_REQUEST PropertyRequest); 21 | 22 | #endif // _CSAUDIOACP3X_HEADPHONETOPO_H_ 23 | -------------------------------------------------------------------------------- /Source/Filters/micjacktopo.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | micjack.h 8 | 9 | Abstract: 10 | 11 | Declaration of topology miniport for the mic (external: headphone). 12 | 13 | --*/ 14 | 15 | #ifndef _CSAUDIOACP3X_MICJACKTOPO_H_ 16 | #define _CSAUDIOACP3X_MICJACKTOPO_H_ 17 | 18 | // Function declarations. 19 | NTSTATUS 20 | PropertyHandler_MicJackTopoFilter(_In_ PPCPROPERTY_REQUEST PropertyRequest); 21 | 22 | NTSTATUS PropertyHandler_MicJackTopology(_In_ PPCPROPERTY_REQUEST PropertyRequest); 23 | 24 | #endif // _CSAUDIOACP3X_MICJACKTOPO_H_ 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoolStar Audio for AMD ACP 3.0 2 | 3 | Open Source alternative for the AMD ACP 3.0 driver (may also work on newer AMD chipsets using ACP) 4 | 5 | Currently Implemented: 6 | 7 | * 16-bit 48 Khz Audio Streams 8 | * BT and I2S TDM streams (Speaker/DMIC is on BT, 3.5mm jack on I2S) 9 | * Runtime Power Management 10 | * Play / Pause / Stop support for streams 11 | * WDM Position Counter 12 | 13 | Not Yet Implemented: 14 | * Notifications using IRQ with watermark register 15 | 16 | Tested on HP Chromebook 14b (Ryzen 3 3250C) 17 | 18 | Based off SimpleAudioSample (commit 9e1a643093cac60cd333b6d69abc1e4118a12d63) and TabletAudioSample from Microsoft's WDK 10 samples 19 | 20 | Based off Linux commit 6f6f28bf5d8e070c1e4a10d62d2a1af264683042 (relevant to sound/soc/amd/raven folder) 21 | -------------------------------------------------------------------------------- /Package/package.VcxProj.Filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* 6 | {0924612D-FBA7-477E-BBB9-B3B6EA7C6B03} 7 | 8 | 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | {97311738-0AD8-4F7E-AC88-9C9BEAF53AEE} 11 | 12 | 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml 14 | {8DC1C4F0-C285-400E-A983-77A339891354} 15 | 16 | 17 | inf;inv;inx;mof;mc; 18 | {9F086F34-79D2-4FAA-87FD-C2DBEFCED0BA} 19 | 20 | 21 | -------------------------------------------------------------------------------- /Source/Inc/Inc.vcxproj.Filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* 6 | {54BE0AAC-642F-4D50-80D1-CA3C4BB4BB4C} 7 | 8 | 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | {6A00B9EC-DB03-4D51-B351-60DE9C0C51A1} 11 | 12 | 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml 14 | {887357BD-50C0-40E6-85E8-87E0F45862DB} 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Source/Main/csaudioacp3x.rc: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | CsAudioAcp3x.rc 8 | 9 | Abstract: 10 | 11 | --*/ 12 | 13 | #include 14 | 15 | #define VER_FILETYPE VFT_DRV 16 | #define VER_FILESUBTYPE VFT2_DRV_SOUND 17 | #define VER_FILEDESCRIPTION_STR "CoolStar ACP Audio (Ryzen 2000/3000)" 18 | #define VER_INTERNALNAME_STR "CsAudioAcp3x.sys" 19 | #define VER_ORIGINALFILENAME_STR "CsAudioAcp3x.sys" 20 | 21 | #define VER_LEGALCOPYRIGHT_YEARS "2023" 22 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) " VER_LEGALCOPYRIGHT_YEARS " CoolStar." 23 | 24 | #define VER_FILEVERSION 1,0,3,0 25 | #define VER_PRODUCTVERSION_STR "1.0.3.0" 26 | #define VER_PRODUCTVERSION 1,0,3,0 27 | #define LVER_PRODUCTVERSION_STR L"1.0.3.0" 28 | 29 | #define VER_FILEFLAGSMASK (VS_FF_DEBUG | VS_FF_PRERELEASE) 30 | #ifdef DEBUG 31 | #define VER_FILEFLAGS (VS_FF_DEBUG) 32 | #else 33 | #define VER_FILEFLAGS (0) 34 | #endif 35 | 36 | #define VER_FILEOS VOS_NT_WINDOWS32 37 | 38 | #define VER_COMPANYNAME_STR "CoolStar" 39 | #define VER_PRODUCTNAME_STR "CoolStar ACP 3.x Audio" 40 | 41 | #include "common.ver" 42 | 43 | 44 | -------------------------------------------------------------------------------- /Source/Utilities/Utilities.vcxproj.Filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* 6 | {CDBBEDA3-98E9-4C7A-BDB1-25EC47D0B087} 7 | 8 | 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | {FA3DF57E-BA19-4783-831B-CF9D4D594F70} 11 | 12 | 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml 14 | {CB830E4F-01DA-4D35-9789-E7DB0D02A79C} 15 | 16 | 17 | inf;inv;inx;mof;mc; 18 | {49F92783-3B39-4D0C-A153-8C346F754749} 19 | 20 | 21 | 22 | 23 | Source Files 24 | 25 | 26 | Source Files 27 | 28 | 29 | Source Files 30 | 31 | 32 | Source Files 33 | 34 | 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | Header Files 53 | 54 | 55 | Header Files 56 | 57 | 58 | -------------------------------------------------------------------------------- /Source/Inc/mintopo.h: -------------------------------------------------------------------------------- 1 | 2 | /*++ 3 | 4 | Copyright (c) Microsoft Corporation All Rights Reserved 5 | 6 | Module Name: 7 | 8 | minitopo.h 9 | 10 | Abstract: 11 | 12 | Declaration of topology miniport. 13 | --*/ 14 | 15 | #ifndef _CSAUDIOACP3X_MINTOPO_H_ 16 | #define _CSAUDIOACP3X_MINTOPO_H_ 17 | 18 | #include "basetopo.h" 19 | 20 | //============================================================================= 21 | // Classes 22 | //============================================================================= 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | // CMiniportTopology 26 | // 27 | 28 | class CMiniportTopology : 29 | public CMiniportTopologyCsAudioAcp3x, 30 | public IMiniportTopology, 31 | public CUnknown 32 | { 33 | private: 34 | eDeviceType m_DeviceType; 35 | 36 | union { 37 | PVOID m_DeviceContext; 38 | }; 39 | 40 | public: 41 | DECLARE_STD_UNKNOWN(); 42 | CMiniportTopology 43 | ( 44 | _In_opt_ PUNKNOWN UnknownOuter, 45 | _In_ PCFILTER_DESCRIPTOR *FilterDesc, 46 | _In_ USHORT DeviceMaxChannels, 47 | _In_ eDeviceType DeviceType, 48 | _In_opt_ PVOID DeviceContext 49 | ) 50 | : CUnknown(UnknownOuter), 51 | CMiniportTopologyCsAudioAcp3x(FilterDesc, DeviceMaxChannels), 52 | m_DeviceType(DeviceType), 53 | m_DeviceContext(DeviceContext) 54 | { 55 | } 56 | 57 | ~CMiniportTopology(); 58 | 59 | IMP_IMiniportTopology; 60 | 61 | NTSTATUS PropertyHandlerJackDescription 62 | ( 63 | _In_ PPCPROPERTY_REQUEST PropertyRequest, 64 | _In_ ULONG cJackDescriptions, 65 | _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION *JackDescriptions 66 | ); 67 | 68 | NTSTATUS PropertyHandlerJackDescription2 69 | ( 70 | _In_ PPCPROPERTY_REQUEST PropertyRequest, 71 | _In_ ULONG cJackDescriptions, 72 | _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION *JackDescriptions, 73 | _In_ DWORD JackCapabilities 74 | ); 75 | 76 | PVOID GetDeviceContext() { return m_DeviceContext; } 77 | }; 78 | 79 | typedef CMiniportTopology *PCMiniportTopology; 80 | 81 | #endif // _CSAUDIOACP3X_MINTOPO_H_ 82 | -------------------------------------------------------------------------------- /Source/Utilities/acp3x.h: -------------------------------------------------------------------------------- 1 | #ifndef __ACP_3X_H__ 2 | #define __ACP_3X_H__ 3 | 4 | #define I2S_SP_INSTANCE 0x01 5 | #define I2S_BT_INSTANCE 0x02 6 | 7 | #define TDM_ENABLE 1 8 | #define TDM_DISABLE 0 9 | 10 | #define ACP3x_DEVS 4 11 | #define ACP3x_PHY_BASE_ADDRESS 0x1240000 12 | #define ACP3x_I2S_MODE 0 13 | #define ACP3x_REG_START 0x1240000 14 | #define ACP3x_REG_END 0x1250200 15 | #define ACP3x_I2STDM_REG_START 0x1242400 16 | #define ACP3x_I2STDM_REG_END 0x1242410 17 | #define ACP3x_BT_TDM_REG_START 0x1242800 18 | #define ACP3x_BT_TDM_REG_END 0x1242810 19 | #define I2S_MODE 0x04 20 | #define I2S_RX_THRESHOLD 27 21 | #define I2S_TX_THRESHOLD 28 22 | #define BT_TX_THRESHOLD 26 23 | #define BT_RX_THRESHOLD 25 24 | #define ACP_ERR_INTR_MASK 29 25 | #define ACP3x_POWER_ON 0x00 26 | #define ACP3x_POWER_ON_IN_PROGRESS 0x01 27 | #define ACP3x_POWER_OFF 0x02 28 | #define ACP3x_POWER_OFF_IN_PROGRESS 0x03 29 | #define ACP3x_SOFT_RESET__SoftResetAudDone_MASK 0x00010001 30 | 31 | #define ACP_SRAM_PTE_OFFSET 0x02050000 32 | #define ACP_SRAM_SP_PB_PTE_OFFSET 0x0 33 | #define ACP_SRAM_SP_CP_PTE_OFFSET 0x100 34 | #define ACP_SRAM_BT_PB_PTE_OFFSET 0x200 35 | #define ACP_SRAM_BT_CP_PTE_OFFSET 0x300 36 | #define PAGE_SIZE_4K_ENABLE 0x2 37 | #define I2S_SP_TX_MEM_WINDOW_START 0x4000000 38 | #define I2S_SP_RX_MEM_WINDOW_START 0x4020000 39 | #define I2S_BT_TX_MEM_WINDOW_START 0x4040000 40 | #define I2S_BT_RX_MEM_WINDOW_START 0x4060000 41 | 42 | #define SP_PB_FIFO_ADDR_OFFSET 0x500 43 | #define SP_CAPT_FIFO_ADDR_OFFSET 0x700 44 | #define BT_PB_FIFO_ADDR_OFFSET 0x900 45 | #define BT_CAPT_FIFO_ADDR_OFFSET 0xB00 46 | #define PLAYBACK_MIN_NUM_PERIODS 2 47 | #define PLAYBACK_MAX_NUM_PERIODS 8 48 | #define PLAYBACK_MAX_PERIOD_SIZE 8192 49 | #define PLAYBACK_MIN_PERIOD_SIZE 1024 50 | #define CAPTURE_MIN_NUM_PERIODS 2 51 | #define CAPTURE_MAX_NUM_PERIODS 8 52 | #define CAPTURE_MAX_PERIOD_SIZE 8192 53 | #define CAPTURE_MIN_PERIOD_SIZE 1024 54 | 55 | #define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS) 56 | #define MIN_BUFFER MAX_BUFFER 57 | #define FIFO_SIZE 0x100 58 | #define DMA_SIZE 0x40 59 | #define FRM_LEN 0x100 60 | 61 | #define SLOT_WIDTH_8 0x08 62 | #define SLOT_WIDTH_16 0x10 63 | #define SLOT_WIDTH_24 0x18 64 | #define SLOT_WIDTH_32 0x20 65 | #define ACP_PGFSM_CNTL_POWER_ON_MASK 0x01 66 | #define ACP_PGFSM_CNTL_POWER_OFF_MASK 0x00 67 | #define ACP_PGFSM_STATUS_MASK 0x03 68 | #define ACP_POWERED_ON 0x00 69 | #define ACP_POWER_ON_IN_PROGRESS 0x01 70 | #define ACP_POWERED_OFF 0x02 71 | #define ACP_POWER_OFF_IN_PROGRESS 0x03 72 | 73 | #define ACP3x_ITER_IRER_SAMP_LEN_MASK 0x38 74 | #define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF 75 | 76 | #endif -------------------------------------------------------------------------------- /Source/Filters/Filters.vcxproj.Filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* 6 | {75C3E63D-04EA-4EB3-B9F1-505497C51F71} 7 | 8 | 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | {5E8F8D4C-2886-4109-9E78-CE5EA6DB4AC4} 11 | 12 | 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml 14 | {75D3016A-4ED8-4FAF-9817-394BE1112534} 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | -------------------------------------------------------------------------------- /Source/Main/minwavertstream.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | minwavertstream.h 8 | 9 | Abstract: 10 | 11 | Definition of wavert miniport class. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_MINWAVERTSTREAM_H_ 15 | #define _CSAUDIOACP3X_MINWAVERTSTREAM_H_ 16 | 17 | // 18 | // Structure to store notifications events in a protected list 19 | // 20 | typedef struct _NotificationListEntry 21 | { 22 | LIST_ENTRY ListEntry; 23 | PKEVENT NotificationEvent; 24 | } NotificationListEntry; 25 | 26 | EXT_CALLBACK TimerNotifyRT; 27 | 28 | //============================================================================= 29 | // Referenced Forward 30 | //============================================================================= 31 | class CMiniportWaveRT; 32 | typedef CMiniportWaveRT *PCMiniportWaveRT; 33 | 34 | //============================================================================= 35 | // Classes 36 | //============================================================================= 37 | /////////////////////////////////////////////////////////////////////////////// 38 | // CMiniportWaveRTStream 39 | // 40 | class CMiniportWaveRTStream : 41 | public IMiniportWaveRTStream, 42 | public IDrmAudioStream, 43 | public CUnknown 44 | { 45 | public: 46 | PPORTWAVERTSTREAM m_pPortStream; 47 | PMDL m_pMDL; 48 | 49 | DECLARE_STD_UNKNOWN(); 50 | DEFINE_STD_CONSTRUCTOR(CMiniportWaveRTStream); 51 | ~CMiniportWaveRTStream(); 52 | 53 | IMP_IMiniportWaveRTStream; 54 | IMP_IMiniportWaveRT; 55 | IMP_IDrmAudioStream; 56 | 57 | NTSTATUS Init 58 | ( 59 | _In_ PCMiniportWaveRT Miniport, 60 | _In_ PPORTWAVERTSTREAM Stream, 61 | _In_ ULONG Channel, 62 | _In_ BOOLEAN Capture, 63 | _In_ PKSDATAFORMAT DataFormat, 64 | _In_ GUID SignalProcessingMode 65 | ); 66 | 67 | // Friends 68 | friend class CMiniportWaveRT; 69 | protected: 70 | CMiniportWaveRT* m_pMiniport; 71 | ULONG m_ulPin; 72 | BOOLEAN m_bCapture; 73 | BOOLEAN m_bUnregisterStream; 74 | ULONG m_ulDmaBufferSize; 75 | KSSTATE m_KsState; 76 | ULONG m_ulDmaMovementRate; 77 | PWAVEFORMATEXTENSIBLE m_pWfExt; 78 | ULONG m_ulContentId; 79 | KSPIN_LOCK m_PositionSpinLock; 80 | UINT32 m_lastLinkPos; 81 | UINT64 m_lastLinearPos; 82 | 83 | }; 84 | typedef CMiniportWaveRTStream *PCMiniportWaveRTStream; 85 | #endif // _CSAUDIOACP3X_MINWAVERTSTREAM_H_ 86 | 87 | -------------------------------------------------------------------------------- /Source/Inc/NewDelete.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | NewDelete.h 8 | 9 | Abstract: 10 | 11 | Declaration of placement new and delete operators. 12 | --*/ 13 | #pragma once 14 | 15 | #ifdef _NEW_DELETE_OPERATORS_ 16 | 17 | /***************************************************************************** 18 | * Functions 19 | */ 20 | 21 | /***************************************************************************** 22 | * ::new() 23 | ***************************************************************************** 24 | * New function for creating objects with a specified allocation tag and 25 | * pool type 26 | */ 27 | PVOID operator new 28 | ( 29 | size_t iSize, 30 | POOL_TYPE poolType, 31 | ULONG tag 32 | ); 33 | 34 | 35 | /***************************************************************************** 36 | * ::new() 37 | ***************************************************************************** 38 | * New function for creating objects with a specified pool type. 39 | */ 40 | PVOID operator new 41 | ( 42 | size_t iSize, 43 | POOL_TYPE poolType 44 | ); 45 | 46 | 47 | /***************************************************************************** 48 | * ::delete() 49 | ***************************************************************************** 50 | * Delete with tag function. 51 | */ 52 | void __cdecl operator delete 53 | ( 54 | PVOID pVoid, 55 | ULONG tag 56 | ); 57 | 58 | 59 | /***************************************************************************** 60 | * ::delete() 61 | ***************************************************************************** 62 | * Sized Delete function. 63 | */ 64 | void __cdecl operator delete 65 | ( 66 | _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid, 67 | _In_ size_t cbSize 68 | ); 69 | 70 | 71 | /***************************************************************************** 72 | * ::delete() 73 | ***************************************************************************** 74 | * Basic Delete function. 75 | */ 76 | void __cdecl operator delete 77 | ( 78 | PVOID pVoid 79 | ); 80 | 81 | 82 | /***************************************************************************** 83 | * ::delete() 84 | ***************************************************************************** 85 | * Sized Array Delete function. 86 | */ 87 | void __cdecl operator delete[] 88 | ( 89 | _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid, 90 | _In_ size_t cbSize 91 | ); 92 | 93 | 94 | /***************************************************************************** 95 | * ::delete() 96 | ***************************************************************************** 97 | * Array Delete function. 98 | */ 99 | void __cdecl operator delete[] 100 | ( 101 | _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid 102 | ); 103 | 104 | #endif//_NEW_DELETE_OPERATORS_ 105 | -------------------------------------------------------------------------------- /Source/Filters/micarraytopo.h: -------------------------------------------------------------------------------- 1 | 2 | /*++ 3 | 4 | Copyright (c) Microsoft Corporation All Rights Reserved 5 | 6 | Module Name: 7 | 8 | micarraytopo.h 9 | 10 | Abstract: 11 | 12 | Declaration of mic array topology miniport. 13 | 14 | --*/ 15 | 16 | #ifndef _CSAUDIOACP3X_MICARRAYTOPO_H_ 17 | #define _CSAUDIOACP3X_MICARRAYTOPO_H_ 18 | 19 | #include "basetopo.h" 20 | 21 | //============================================================================= 22 | // Classes 23 | //============================================================================= 24 | 25 | /////////////////////////////////////////////////////////////////////////////// 26 | // CMicArrayMiniportTopology 27 | // 28 | 29 | #pragma code_seg() 30 | class CMicArrayMiniportTopology : 31 | public CMiniportTopologyCsAudioAcp3x, 32 | public IMiniportTopology, 33 | public CUnknown 34 | { 35 | public: 36 | DECLARE_STD_UNKNOWN(); 37 | CMicArrayMiniportTopology 38 | ( 39 | _In_opt_ PUNKNOWN UnknownOuter, 40 | _In_ PCFILTER_DESCRIPTOR* FilterDesc, 41 | _In_ USHORT DeviceMaxChannels, 42 | _In_ eDeviceType DeviceType 43 | ) 44 | : CUnknown(UnknownOuter), 45 | CMiniportTopologyCsAudioAcp3x(FilterDesc, DeviceMaxChannels), 46 | m_DeviceType(DeviceType) 47 | { 48 | ASSERT(m_DeviceType == eMicArrayDevice1 || m_DeviceType == eMicJackDevice); 49 | } 50 | 51 | ~CMicArrayMiniportTopology(); 52 | 53 | IMP_IMiniportTopology; 54 | 55 | NTSTATUS PropertyHandlerMicArrayGeometry 56 | ( 57 | _In_ PPCPROPERTY_REQUEST PropertyRequest 58 | ); 59 | 60 | NTSTATUS PropertyHandlerMicProperties 61 | ( 62 | _In_ PPCPROPERTY_REQUEST PropertyRequest 63 | ); 64 | 65 | NTSTATUS PropertyHandlerJackDescription 66 | ( 67 | _In_ PPCPROPERTY_REQUEST PropertyRequest 68 | ); 69 | 70 | NTSTATUS PropertyHandlerJackDescription2 71 | ( 72 | _In_ PPCPROPERTY_REQUEST PropertyRequest 73 | ); 74 | 75 | protected: 76 | eDeviceType m_DeviceType; 77 | 78 | }; 79 | 80 | typedef CMicArrayMiniportTopology* PCMicArrayMiniportTopology; 81 | 82 | 83 | NTSTATUS 84 | CreateMicArrayMiniportTopology( 85 | _Out_ PUNKNOWN* Unknown, 86 | _In_ REFCLSID, 87 | _In_opt_ PUNKNOWN UnknownOuter, 88 | _In_ POOL_TYPE PoolType, 89 | _In_ PUNKNOWN UnknownAdapter, 90 | _In_opt_ PVOID DeviceContext, 91 | _In_ PENDPOINT_MINIPAIR MiniportPair 92 | ); 93 | 94 | NTSTATUS PropertyHandler_MicArrayTopoFilter(_In_ PPCPROPERTY_REQUEST PropertyRequest); 95 | NTSTATUS PropertyHandler_MicArrayTopology(_In_ PPCPROPERTY_REQUEST PropertyRequest); 96 | 97 | #endif // _CSAUDIOACP3X_MICARRAYTOPO_H_ 98 | -------------------------------------------------------------------------------- /Source/Inc/basetopo.h: -------------------------------------------------------------------------------- 1 | 2 | /*++ 3 | 4 | Copyright (c) Microsoft Corporation All Rights Reserved 5 | 6 | Module Name: 7 | 8 | basetopo.h 9 | 10 | Abstract: 11 | 12 | Declaration of topology miniport. 13 | --*/ 14 | 15 | #ifndef _CSAUDIOACP3X_BASETOPO_H_ 16 | #define _CSAUDIOACP3X_BASETOPO_H_ 17 | 18 | //============================================================================= 19 | // Classes 20 | //============================================================================= 21 | 22 | /////////////////////////////////////////////////////////////////////////////// 23 | // CMiniportTopologyCsAudioAcp3x 24 | // 25 | 26 | class CMiniportTopologyCsAudioAcp3x 27 | { 28 | protected: 29 | PADAPTERCOMMON m_AdapterCommon; // Adapter common object. 30 | PPCFILTER_DESCRIPTOR m_FilterDescriptor; // Filter descriptor. 31 | PPORTEVENTS m_PortEvents; // Event interface. 32 | USHORT m_DeviceMaxChannels; // Max device channels. 33 | 34 | public: 35 | CMiniportTopologyCsAudioAcp3x( 36 | _In_ PCFILTER_DESCRIPTOR *FilterDesc, 37 | _In_ USHORT DeviceMaxChannels 38 | ); 39 | 40 | ~CMiniportTopologyCsAudioAcp3x(); 41 | 42 | NTSTATUS GetDescription 43 | ( 44 | _Out_ PPCFILTER_DESCRIPTOR * Description 45 | ); 46 | 47 | NTSTATUS DataRangeIntersection 48 | ( 49 | _In_ ULONG PinId, 50 | _In_ PKSDATARANGE ClientDataRange, 51 | _In_ PKSDATARANGE MyDataRange, 52 | _In_ ULONG OutputBufferLength, 53 | _Out_writes_bytes_to_opt_(OutputBufferLength, *ResultantFormatLength) 54 | PVOID ResultantFormat OPTIONAL, 55 | _Out_ PULONG ResultantFormatLength 56 | ); 57 | 58 | NTSTATUS Init 59 | ( 60 | _In_ PUNKNOWN UnknownAdapter, 61 | _In_ PPORTTOPOLOGY Port_ 62 | ); 63 | 64 | // PropertyHandlers. 65 | NTSTATUS PropertyHandlerGeneric 66 | ( 67 | _In_ PPCPROPERTY_REQUEST PropertyRequest 68 | ); 69 | 70 | NTSTATUS PropertyHandlerMuxSource 71 | ( 72 | _In_ PPCPROPERTY_REQUEST PropertyRequest 73 | ); 74 | 75 | NTSTATUS PropertyHandlerDevSpecific 76 | ( 77 | _In_ PPCPROPERTY_REQUEST PropertyRequest 78 | ); 79 | 80 | VOID AddEventToEventList 81 | ( 82 | _In_ PKSEVENT_ENTRY EventEntry 83 | ); 84 | 85 | VOID GenerateEventList 86 | ( 87 | _In_opt_ GUID *Set, 88 | _In_ ULONG EventId, 89 | _In_ BOOL PinEvent, 90 | _In_ ULONG PinId, 91 | _In_ BOOL NodeEvent, 92 | _In_ ULONG NodeId 93 | ); 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Source/Main/Main.vcxproj.Filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* 6 | {7FE326AE-6214-4FE0-A27B-F229A098BDBC} 7 | 8 | 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | {64C16D2B-849C-4264-A615-18A8E8AC9505} 11 | 12 | 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml 14 | {46FAF4E8-F18C-4797-9CFA-2F3473BCB316} 15 | 16 | 17 | inf;inv;inx;mof;mc; 18 | {EE8F0A00-C1F0-4CB4-80E3-5FCC378E0BF4} 19 | 20 | 21 | 22 | 23 | Source Files 24 | 25 | 26 | Source Files 27 | 28 | 29 | Source Files 30 | 31 | 32 | Source Files 33 | 34 | 35 | Source Files 36 | 37 | 38 | Source Files 39 | 40 | 41 | Source Files 42 | 43 | 44 | Source Files 45 | 46 | 47 | Source Files 48 | 49 | 50 | Source Files 51 | 52 | 53 | Source Files 54 | 55 | 56 | Source Files 57 | 58 | 59 | Source Files 60 | 61 | 62 | Source Files 63 | 64 | 65 | 66 | 67 | Resource Files 68 | 69 | 70 | 71 | 72 | Header Files 73 | 74 | 75 | 76 | 77 | Driver Files 78 | 79 | 80 | -------------------------------------------------------------------------------- /Source/Filters/micjacktopo.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | usbhsmictopo.cpp 8 | 9 | Abstract: 10 | 11 | Implementation of topology miniport for the mic (external: headphone). 12 | 13 | --*/ 14 | #pragma warning (disable : 4127) 15 | 16 | #include "definitions.h" 17 | #include "endpoints.h" 18 | #include "mintopo.h" 19 | #include "micjacktopo.h" 20 | #include "micjacktoptable.h" 21 | 22 | //============================================================================= 23 | #pragma code_seg("PAGE") 24 | NTSTATUS 25 | PropertyHandler_MicJackTopoFilter 26 | ( 27 | _In_ PPCPROPERTY_REQUEST PropertyRequest 28 | ) 29 | /*++ 30 | 31 | Routine Description: 32 | 33 | Redirects property request to miniport object 34 | 35 | Arguments: 36 | 37 | PropertyRequest - 38 | 39 | Return Value: 40 | 41 | NT status code. 42 | 43 | --*/ 44 | { 45 | PAGED_CODE(); 46 | 47 | ASSERT(PropertyRequest); 48 | 49 | DPF_ENTER(("[PropertyHandler_MicJackTopoFilter]")); 50 | 51 | // PropertryRequest structure is filled by portcls. 52 | // MajorTarget is a pointer to miniport object for miniports. 53 | // 54 | NTSTATUS ntStatus = STATUS_INVALID_DEVICE_REQUEST; 55 | PCMiniportTopology pMiniport = (PCMiniportTopology)PropertyRequest->MajorTarget; 56 | 57 | if (IsEqualGUIDAligned(*PropertyRequest->PropertyItem->Set, KSPROPSETID_Jack)) 58 | { 59 | switch (PropertyRequest->PropertyItem->Id) 60 | { 61 | case KSPROPERTY_JACK_DESCRIPTION: 62 | ntStatus = pMiniport->PropertyHandlerJackDescription( 63 | PropertyRequest, 64 | ARRAYSIZE(MicJackDescriptions), 65 | MicJackDescriptions); 66 | break; 67 | 68 | case KSPROPERTY_JACK_DESCRIPTION2: 69 | ntStatus = pMiniport->PropertyHandlerJackDescription2( 70 | PropertyRequest, 71 | ARRAYSIZE(MicJackDescriptions), 72 | MicJackDescriptions, 73 | 0 // jack capabilities 74 | ); 75 | break; 76 | } 77 | } 78 | 79 | return ntStatus; 80 | } // PropertyHandler_MicJackTopoFilter 81 | 82 | //============================================================================= 83 | NTSTATUS 84 | PropertyHandler_MicJackTopology 85 | ( 86 | _In_ PPCPROPERTY_REQUEST PropertyRequest 87 | ) 88 | /*++ 89 | 90 | Routine Description: 91 | 92 | Redirects property request to miniport object 93 | 94 | Arguments: 95 | 96 | PropertyRequest - 97 | 98 | Return Value: 99 | 100 | NT status code. 101 | 102 | --*/ 103 | { 104 | PAGED_CODE(); 105 | 106 | ASSERT(PropertyRequest); 107 | 108 | DPF_ENTER(("[PropertyHandler_MicJackTopology]")); 109 | 110 | // PropertryRequest structure is filled by portcls. 111 | // MajorTarget is a pointer to miniport object for miniports. 112 | // 113 | PCMiniportTopology pMiniport = (PCMiniportTopology)PropertyRequest->MajorTarget; 114 | 115 | return pMiniport->PropertyHandlerGeneric(PropertyRequest); 116 | } // PropertyHandler_HeadphoneTopology 117 | 118 | #pragma code_seg() 119 | -------------------------------------------------------------------------------- /Source/Inc/endpoints.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | endpoints.h 8 | 9 | Abstract: 10 | 11 | Node and Pin numbers and other common definitions for simple audio sample. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_ENDPOINTS_H_ 15 | #define _CSAUDIOACP3X_ENDPOINTS_H_ 16 | 17 | // Name Guid 18 | // {0104947F-82AE-4291-A6F3-5E2DE1AD7DC2} 19 | #define STATIC_NAME_SIMPLE_AUDIO_SAMPLE\ 20 | 0x104947f, 0x82ae, 0x4291, 0xa6, 0xf3, 0x5e, 0x2d, 0xe1, 0xad, 0x7d, 0xc2 21 | DEFINE_GUIDSTRUCT("0104947F-82AE-4291-A6F3-5E2DE1AD7DC2", NAME_SIMPLE_AUDIO_SAMPLE); 22 | #define NAME_SIMPLE_AUDIO_SAMPLE DEFINE_GUIDNAMED(NAME_SIMPLE_AUDIO_SAMPLE) 23 | 24 | //---------------------------------------------------- 25 | // New defines for the render endpoints. 26 | //---------------------------------------------------- 27 | 28 | // Default pin instances. 29 | #define MAX_INPUT_SYSTEM_STREAMS 1 30 | 31 | // Wave pins - no mix, no offload 32 | enum 33 | { 34 | KSPIN_WAVE_RENDER3_SINK_SYSTEM = 0, 35 | KSPIN_WAVE_RENDER3_SOURCE 36 | }; 37 | 38 | // Wave pins - offloading is NOT supported. 39 | enum 40 | { 41 | KSPIN_WAVE_RENDER2_SINK_SYSTEM = 0, 42 | KSPIN_WAVE_RENDER2_SINK_LOOPBACK, 43 | KSPIN_WAVE_RENDER2_SOURCE 44 | }; 45 | 46 | // Wave Topology nodes - offloading is NOT supported. 47 | enum 48 | { 49 | KSNODE_WAVE_SUM = 0, 50 | KSNODE_WAVE_VOLUME, 51 | KSNODE_WAVE_MUTE, 52 | KSNODE_WAVE_PEAKMETER 53 | }; 54 | 55 | // Topology pins. 56 | enum 57 | { 58 | KSPIN_TOPO_WAVEOUT_SOURCE = 0, 59 | KSPIN_TOPO_LINEOUT_DEST, 60 | }; 61 | 62 | // Topology nodes. 63 | enum 64 | { 65 | KSNODE_TOPO_WAVEOUT_VOLUME = 0, 66 | KSNODE_TOPO_WAVEOUT_MUTE, 67 | KSNODE_TOPO_WAVEOUT_PEAKMETER 68 | }; 69 | 70 | //---------------------------------------------------- 71 | // New defines for the capture endpoints. 72 | //---------------------------------------------------- 73 | 74 | // Default pin instances. 75 | #define MAX_INPUT_STREAMS 1 // Number of capture streams. 76 | 77 | // Wave pins 78 | enum 79 | { 80 | KSPIN_WAVE_BRIDGE = 0, 81 | KSPIN_WAVEIN_HOST, 82 | }; 83 | 84 | // Wave Topology nodes. 85 | enum 86 | { 87 | KSNODE_WAVE_ADC = 0 88 | }; 89 | 90 | // Wave Topology nodes. 91 | enum 92 | { 93 | KSNODE_WAVE_DAC = 0 94 | }; 95 | 96 | // topology pins. 97 | enum 98 | { 99 | KSPIN_TOPO_MIC_ELEMENTS, 100 | KSPIN_TOPO_BRIDGE 101 | }; 102 | 103 | // topology nodes. 104 | enum 105 | { 106 | KSNODE_TOPO_VOLUME, 107 | KSNODE_TOPO_MUTE, 108 | KSNODE_TOPO_PEAKMETER 109 | }; 110 | 111 | // data format attribute range definitions. 112 | static 113 | KSATTRIBUTE PinDataRangeSignalProcessingModeAttribute = 114 | { 115 | sizeof(KSATTRIBUTE), 116 | 0, 117 | STATICGUIDOF(KSATTRIBUTEID_AUDIOSIGNALPROCESSING_MODE), 118 | }; 119 | 120 | static 121 | PKSATTRIBUTE PinDataRangeAttributes[] = 122 | { 123 | &PinDataRangeSignalProcessingModeAttribute, 124 | }; 125 | 126 | static 127 | KSATTRIBUTE_LIST PinDataRangeAttributeList = 128 | { 129 | ARRAYSIZE(PinDataRangeAttributes), 130 | PinDataRangeAttributes, 131 | }; 132 | 133 | #endif // _CSAUDIOACP3X_ENDPOINTS_H_ 134 | -------------------------------------------------------------------------------- /Source/Filters/speakertopo.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | speakertopo.cpp 8 | 9 | Abstract: 10 | 11 | Implementation of topology miniport for the speaker (internal). 12 | --*/ 13 | 14 | #pragma warning (disable : 4127) 15 | 16 | #include "definitions.h" 17 | #include "endpoints.h" 18 | #include "mintopo.h" 19 | #include "speakertopo.h" 20 | #include "speakertoptable.h" 21 | 22 | 23 | #pragma code_seg("PAGE") 24 | //============================================================================= 25 | NTSTATUS 26 | PropertyHandler_SpeakerTopoFilter 27 | ( 28 | _In_ PPCPROPERTY_REQUEST PropertyRequest 29 | ) 30 | /*++ 31 | 32 | Routine Description: 33 | 34 | Redirects property request to miniport object 35 | 36 | Arguments: 37 | 38 | PropertyRequest - 39 | 40 | Return Value: 41 | 42 | NT status code. 43 | 44 | --*/ 45 | { 46 | PAGED_CODE(); 47 | 48 | ASSERT(PropertyRequest); 49 | 50 | DPF_ENTER(("[PropertyHandler_SpeakerTopoFilter]")); 51 | 52 | // PropertryRequest structure is filled by portcls. 53 | // MajorTarget is a pointer to miniport object for miniports. 54 | // 55 | NTSTATUS ntStatus = STATUS_INVALID_DEVICE_REQUEST; 56 | PCMiniportTopology pMiniport = (PCMiniportTopology)PropertyRequest->MajorTarget; 57 | 58 | if (IsEqualGUIDAligned(*PropertyRequest->PropertyItem->Set, KSPROPSETID_Jack)) 59 | { 60 | if (PropertyRequest->PropertyItem->Id == KSPROPERTY_JACK_DESCRIPTION) 61 | { 62 | ntStatus = pMiniport->PropertyHandlerJackDescription( 63 | PropertyRequest, 64 | ARRAYSIZE(SpeakerJackDescriptions), 65 | SpeakerJackDescriptions 66 | ); 67 | } 68 | else if (PropertyRequest->PropertyItem->Id == KSPROPERTY_JACK_DESCRIPTION2) 69 | { 70 | ntStatus = pMiniport->PropertyHandlerJackDescription2( 71 | PropertyRequest, 72 | ARRAYSIZE(SpeakerJackDescriptions), 73 | SpeakerJackDescriptions, 74 | 0 // jack capabilities 75 | ); 76 | } 77 | } 78 | 79 | return ntStatus; 80 | } // PropertyHandler_SpeakerTopoFilter 81 | 82 | //============================================================================= 83 | NTSTATUS 84 | PropertyHandler_SpeakerTopology 85 | ( 86 | _In_ PPCPROPERTY_REQUEST PropertyRequest 87 | ) 88 | /*++ 89 | 90 | Routine Description: 91 | 92 | Redirects property request to miniport object 93 | 94 | Arguments: 95 | 96 | PropertyRequest - 97 | 98 | Return Value: 99 | 100 | NT status code. 101 | 102 | --*/ 103 | { 104 | PAGED_CODE(); 105 | 106 | ASSERT(PropertyRequest); 107 | 108 | DPF_ENTER(("[PropertyHandler_SpeakerTopology]")); 109 | 110 | // PropertryRequest structure is filled by portcls. 111 | // MajorTarget is a pointer to miniport object for miniports. 112 | // 113 | PCMiniportTopology pMiniport = (PCMiniportTopology)PropertyRequest->MajorTarget; 114 | 115 | return pMiniport->PropertyHandlerGeneric(PropertyRequest); 116 | } // PropertyHandler_SpeakerTopology 117 | 118 | #pragma code_seg() 119 | -------------------------------------------------------------------------------- /Source/Filters/headphonetopo.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | headphonetopo.cpp 8 | 9 | Abstract: 10 | 11 | Implementation of topology miniport for the headphone (jack). 12 | --*/ 13 | 14 | #pragma warning (disable : 4127) 15 | 16 | #include "definitions.h" 17 | #include "endpoints.h" 18 | #include "mintopo.h" 19 | #include "headphonetopo.h" 20 | #include "headphonetoptable.h" 21 | 22 | 23 | #pragma code_seg("PAGE") 24 | //============================================================================= 25 | NTSTATUS 26 | PropertyHandler_HeadphoneTopoFilter 27 | ( 28 | _In_ PPCPROPERTY_REQUEST PropertyRequest 29 | ) 30 | /*++ 31 | 32 | Routine Description: 33 | 34 | Redirects property request to miniport object 35 | 36 | Arguments: 37 | 38 | PropertyRequest - 39 | 40 | Return Value: 41 | 42 | NT status code. 43 | 44 | --*/ 45 | { 46 | PAGED_CODE(); 47 | 48 | ASSERT(PropertyRequest); 49 | 50 | DPF_ENTER(("[PropertyHandler_HeadphoneTopoFilter]")); 51 | 52 | // PropertryRequest structure is filled by portcls. 53 | // MajorTarget is a pointer to miniport object for miniports. 54 | // 55 | NTSTATUS ntStatus = STATUS_INVALID_DEVICE_REQUEST; 56 | PCMiniportTopology pMiniport = (PCMiniportTopology)PropertyRequest->MajorTarget; 57 | 58 | if (IsEqualGUIDAligned(*PropertyRequest->PropertyItem->Set, KSPROPSETID_Jack)) 59 | { 60 | if (PropertyRequest->PropertyItem->Id == KSPROPERTY_JACK_DESCRIPTION) 61 | { 62 | ntStatus = pMiniport->PropertyHandlerJackDescription( 63 | PropertyRequest, 64 | ARRAYSIZE(HeadphoneJackDescriptions), 65 | HeadphoneJackDescriptions 66 | ); 67 | } 68 | else if (PropertyRequest->PropertyItem->Id == KSPROPERTY_JACK_DESCRIPTION2) 69 | { 70 | ntStatus = pMiniport->PropertyHandlerJackDescription2( 71 | PropertyRequest, 72 | ARRAYSIZE(HeadphoneJackDescriptions), 73 | HeadphoneJackDescriptions, 74 | 0 // jack capabilities 75 | ); 76 | } 77 | } 78 | 79 | return ntStatus; 80 | } // PropertyHandler_HeadphoneTopoFilter 81 | 82 | //============================================================================= 83 | NTSTATUS 84 | PropertyHandler_HeadphoneTopology 85 | ( 86 | _In_ PPCPROPERTY_REQUEST PropertyRequest 87 | ) 88 | /*++ 89 | 90 | Routine Description: 91 | 92 | Redirects property request to miniport object 93 | 94 | Arguments: 95 | 96 | PropertyRequest - 97 | 98 | Return Value: 99 | 100 | NT status code. 101 | 102 | --*/ 103 | { 104 | PAGED_CODE(); 105 | 106 | ASSERT(PropertyRequest); 107 | 108 | DPF_ENTER(("[PropertyHandler_HeadphoneTopology]")); 109 | 110 | // PropertryRequest structure is filled by portcls. 111 | // MajorTarget is a pointer to miniport object for miniports. 112 | // 113 | PCMiniportTopology pMiniport = (PCMiniportTopology)PropertyRequest->MajorTarget; 114 | 115 | return pMiniport->PropertyHandlerGeneric(PropertyRequest); 116 | } // PropertyHandler_HeadphoneTopology 117 | 118 | #pragma code_seg() 119 | -------------------------------------------------------------------------------- /Source/Utilities/csaudioapi.cpp: -------------------------------------------------------------------------------- 1 | #include "definitions.h" 2 | #include "hw.h" 3 | 4 | VOID CsAudioCallbackFunction( 5 | CCsAudioAcp3xHW* hw, 6 | CsAudioArg* arg, 7 | PVOID Argument2 8 | ) { 9 | if (!hw) { 10 | return; 11 | } 12 | 13 | if (Argument2 == &hw->CsAudioArg2) { 14 | return; 15 | } 16 | 17 | CsAudioArg localArg; 18 | RtlZeroMemory(&localArg, sizeof(CsAudioArg)); 19 | RtlCopyMemory(&localArg, arg, min(arg->argSz, sizeof(CsAudioArg))); 20 | 21 | hw->CSAudioAPICalled(localArg); 22 | } 23 | 24 | NTSTATUS CCsAudioAcp3xHW::CSAudioAPIInit() { 25 | NTSTATUS status; 26 | 27 | UNICODE_STRING CSAudioCallbackAPI; 28 | RtlInitUnicodeString(&CSAudioCallbackAPI, L"\\CallBack\\CsAudioCallbackAPI"); 29 | 30 | 31 | OBJECT_ATTRIBUTES attributes; 32 | InitializeObjectAttributes(&attributes, 33 | &CSAudioCallbackAPI, 34 | OBJ_KERNEL_HANDLE | OBJ_OPENIF | OBJ_CASE_INSENSITIVE | OBJ_PERMANENT, 35 | NULL, 36 | NULL 37 | ); 38 | status = ExCreateCallback(&this->CSAudioAPICallback, &attributes, TRUE, TRUE); 39 | if (!NT_SUCCESS(status)) { 40 | return status; 41 | } 42 | 43 | this->CSAudioAPICallbackObj = ExRegisterCallback(this->CSAudioAPICallback, 44 | (PCALLBACK_FUNCTION)CsAudioCallbackFunction, 45 | this 46 | ); 47 | if (!this->CSAudioAPICallbackObj) { 48 | 49 | return STATUS_NO_CALLBACK_ACTIVE; 50 | } 51 | 52 | CsAudioArg arg; 53 | RtlZeroMemory(&arg, sizeof(CsAudioArg)); 54 | arg.argSz = sizeof(CsAudioArg); 55 | arg.endpointType = CSAudioEndpointTypeDSP; 56 | arg.endpointRequest = CSAudioEndpointRegister; 57 | ExNotifyCallback(this->CSAudioAPICallback, &arg, &CsAudioArg2); 58 | 59 | return status; 60 | } 61 | 62 | NTSTATUS CCsAudioAcp3xHW::CSAudioAPIDeinit() { 63 | if (this->CSAudioAPICallbackObj) { 64 | ExUnregisterCallback(this->CSAudioAPICallbackObj); 65 | this->CSAudioAPICallbackObj = NULL; 66 | } 67 | 68 | if (this->CSAudioAPICallback) { 69 | ObfDereferenceObject(this->CSAudioAPICallback); 70 | this->CSAudioAPICallback = NULL; 71 | } 72 | return STATUS_SUCCESS; 73 | } 74 | 75 | void CCsAudioAcp3xHW::CSAudioAPICalled(CsAudioArg arg) { 76 | if (arg.endpointRequest == CSAudioEndpointRegister) { 77 | CsAudioArg newArg; 78 | RtlZeroMemory(&newArg, sizeof(CsAudioArg)); 79 | newArg.argSz = sizeof(CsAudioArg); 80 | newArg.endpointType = arg.endpointType; 81 | newArg.endpointRequest = CSAudioEndpointStop; 82 | ExNotifyCallback(this->CSAudioAPICallback, &newArg, &CsAudioArg2); 83 | } 84 | } 85 | 86 | CSAudioEndpointType CCsAudioAcp3xHW::GetCSAudioEndpoint(eDeviceType deviceType) { 87 | switch (deviceType) { 88 | case eSpeakerDevice: 89 | return CSAudioEndpointTypeSpeaker; 90 | case eHeadphoneDevice: 91 | return CSAudioEndpointTypeHeadphone; 92 | case eMicArrayDevice1: 93 | return CSAudioEndpointTypeMicArray; 94 | case eMicJackDevice: 95 | return CSAudioEndpointTypeMicJack; 96 | } 97 | return CSAudioEndpointTypeDSP; 98 | } 99 | 100 | eDeviceType CCsAudioAcp3xHW::GetDeviceType(CSAudioEndpointType endpointType) { 101 | switch (endpointType) { 102 | case CSAudioEndpointTypeSpeaker: 103 | return eSpeakerDevice; 104 | case CSAudioEndpointTypeHeadphone: 105 | return eHeadphoneDevice; 106 | case CSAudioEndpointTypeMicArray: 107 | return eMicArrayDevice1; 108 | case CSAudioEndpointTypeMicJack: 109 | return eMicJackDevice; 110 | } 111 | return eSpeakerDevice; 112 | } -------------------------------------------------------------------------------- /Source/Main/NewDelete.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * NewDelete.cpp - CPP placement new and delete operators implementation 3 | ***************************************************************************** 4 | * Copyright (c) Microsoft Corporation All Rights Reserved 5 | * 6 | * Module Name: 7 | * 8 | * NewDelete.cpp 9 | * 10 | * Abstract: 11 | * 12 | * Definition of placement new and delete operators. 13 | * 14 | */ 15 | 16 | #ifdef _NEW_DELETE_OPERATORS_ 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #include 20 | } 21 | #else 22 | #include 23 | #endif 24 | 25 | #include "newDelete.h" 26 | #include "definitions.h" 27 | 28 | #pragma code_seg() 29 | /***************************************************************************** 30 | * Functions 31 | */ 32 | 33 | /***************************************************************************** 34 | * ::new() 35 | ***************************************************************************** 36 | * New function for creating objects with a specified allocation tag. 37 | */ 38 | PVOID operator new 39 | ( 40 | size_t iSize, 41 | POOL_TYPE poolType, 42 | ULONG tag 43 | ) 44 | { 45 | PVOID result = ExAllocatePoolZero(poolType, iSize, tag); 46 | 47 | return result; 48 | } 49 | 50 | 51 | /***************************************************************************** 52 | * ::new() 53 | ***************************************************************************** 54 | * New function for creating objects with a specified allocation tag. 55 | */ 56 | PVOID operator new 57 | ( 58 | size_t iSize, 59 | POOL_TYPE poolType 60 | ) 61 | { 62 | PVOID result = ExAllocatePoolZero(poolType, iSize, CSAUDIOACP3X_POOLTAG); 63 | 64 | return result; 65 | } 66 | 67 | 68 | /***************************************************************************** 69 | * ::delete() 70 | ***************************************************************************** 71 | * Delete with tag function. 72 | */ 73 | void __cdecl operator delete 74 | ( 75 | PVOID pVoid, 76 | ULONG tag 77 | ) 78 | { 79 | if (pVoid) 80 | { 81 | ExFreePoolWithTag(pVoid, tag); 82 | } 83 | } 84 | 85 | 86 | /***************************************************************************** 87 | * ::delete() 88 | ***************************************************************************** 89 | * Sized Delete function. 90 | */ 91 | void __cdecl operator delete 92 | ( 93 | _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid, 94 | _In_ size_t cbSize 95 | ) 96 | { 97 | UNREFERENCED_PARAMETER(cbSize); 98 | 99 | if (pVoid) 100 | { 101 | ExFreePoolWithTag(pVoid, CSAUDIOACP3X_POOLTAG); 102 | } 103 | } 104 | 105 | 106 | /***************************************************************************** 107 | * ::delete() 108 | ***************************************************************************** 109 | * Sized Array Delete function. 110 | */ 111 | void __cdecl operator delete[] 112 | ( 113 | _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid, 114 | _In_ size_t cbSize 115 | ) 116 | { 117 | UNREFERENCED_PARAMETER(cbSize); 118 | 119 | if (pVoid) 120 | { 121 | ExFreePoolWithTag(pVoid, CSAUDIOACP3X_POOLTAG); 122 | } 123 | } 124 | 125 | 126 | /***************************************************************************** 127 | * ::delete() 128 | ***************************************************************************** 129 | * Array Delete function. 130 | */ 131 | void __cdecl operator delete[] 132 | ( 133 | _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid 134 | ) 135 | { 136 | if (pVoid) 137 | { 138 | ExFreePoolWithTag(pVoid, CSAUDIOACP3X_POOLTAG); 139 | } 140 | } 141 | #endif//_NEW_DELETE_OPERATORS_ 142 | -------------------------------------------------------------------------------- /Source/Utilities/hw.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | hw.h 8 | 9 | Abstract: 10 | 11 | Declaration of Simple Audio Sample HW class. 12 | Simple Audio Sample HW has an array for storing mixer and volume settings 13 | for the topology. 14 | --*/ 15 | 16 | #ifndef _CSAUDIOACP3X_HW_H_ 17 | #define _CSAUDIOACP3X_HW_H_ 18 | 19 | typedef enum { 20 | CSAudioEndpointTypeDSP, 21 | CSAudioEndpointTypeSpeaker, 22 | CSAudioEndpointTypeHeadphone, 23 | CSAudioEndpointTypeMicArray, 24 | CSAudioEndpointTypeMicJack 25 | } CSAudioEndpointType; 26 | 27 | typedef enum { 28 | CSAudioEndpointRegister, 29 | CSAudioEndpointStart, 30 | CSAudioEndpointStop, 31 | CSAudioEndpointOverrideFormat 32 | } CSAudioEndpointRequest; 33 | 34 | typedef struct CSAUDIOFORMATOVERRIDE { 35 | UINT16 channels; 36 | UINT16 frequency; 37 | UINT16 bitsPerSample; 38 | UINT16 validBitsPerSample; 39 | BOOL force32BitOutputContainer; 40 | } CsAudioFormatOverride; 41 | 42 | typedef struct CSAUDIOARG { 43 | UINT32 argSz; 44 | CSAudioEndpointType endpointType; 45 | CSAudioEndpointRequest endpointRequest; 46 | union { 47 | CsAudioFormatOverride formatOverride; 48 | }; 49 | } CsAudioArg, * PCsAudioArg; 50 | 51 | #define USEACPHW 1 52 | 53 | #if USEACPHW 54 | #include "acp_chip_offset_byte.h" 55 | #include "acp3x.h" 56 | #define BIT(nr) (1UL << (nr)) 57 | 58 | union baseaddr { 59 | PVOID Base; 60 | UINT8* baseptr; 61 | }; 62 | 63 | typedef struct _PCI_BAR { 64 | union baseaddr Base; 65 | ULONG Len; 66 | } PCI_BAR, * PPCI_BAR; 67 | #endif 68 | 69 | //============================================================================= 70 | // Defines 71 | //============================================================================= 72 | // BUGBUG we should dynamically allocate this... 73 | #define MAX_TOPOLOGY_NODES 20 74 | 75 | //============================================================================= 76 | // Classes 77 | //============================================================================= 78 | /////////////////////////////////////////////////////////////////////////////// 79 | // CCsAudioAcp3xHW 80 | // This class represents virtual Simple Audio Sample HW. An array representing volume 81 | // registers and mute registers. 82 | 83 | class CCsAudioAcp3xHW 84 | { 85 | public: 86 | int CsAudioArg2; 87 | void CSAudioAPICalled(CsAudioArg arg); 88 | 89 | private: 90 | PCALLBACK_OBJECT CSAudioAPICallback; 91 | PVOID CSAudioAPICallbackObj; 92 | 93 | NTSTATUS CSAudioAPIInit(); 94 | NTSTATUS CSAudioAPIDeinit(); 95 | CSAudioEndpointType GetCSAudioEndpoint(eDeviceType deviceType); 96 | eDeviceType GetDeviceType(CSAudioEndpointType endpointType); 97 | 98 | protected: 99 | LONG m_PeakMeterControls[MAX_TOPOLOGY_NODES]; 100 | ULONG m_ulMux; // Mux selection 101 | BOOL m_bDevSpecific; 102 | INT m_iDevSpecific; 103 | UINT m_uiDevSpecific; 104 | #if USEACPHW 105 | PCI_BAR m_BAR0; 106 | UINT32 m_pme_en; 107 | 108 | SHORT bt_running_streams; 109 | SHORT sp_running_streams; 110 | 111 | UINT32 rv_read32(UINT32 reg); 112 | void rv_write32(UINT32 reg, UINT32 val); 113 | #endif 114 | 115 | private: 116 | #if USEACPHW 117 | NTSTATUS acp3x_power_on(); 118 | NTSTATUS acp3x_power_off(); 119 | NTSTATUS acp3x_reset(); 120 | #endif 121 | public: 122 | CCsAudioAcp3xHW(_In_ PRESOURCELIST ResourceList); 123 | ~CCsAudioAcp3xHW(); 124 | 125 | bool ResourcesValidated(); 126 | 127 | NTSTATUS acp3x_init(); 128 | NTSTATUS acp3x_deinit(); 129 | 130 | NTSTATUS acp3x_hw_params(eDeviceType deviceType); 131 | NTSTATUS acp3x_program_dma(eDeviceType deviceType, PMDL mdl, IPortWaveRTStream* stream); 132 | NTSTATUS acp3x_play(eDeviceType deviceType, UINT32 byteCount); 133 | NTSTATUS acp3x_stop(eDeviceType deviceType); 134 | NTSTATUS acp3x_current_position(eDeviceType deviceType, UINT32* linkPos, UINT64* linearPos); 135 | NTSTATUS acp3x_set_position(eDeviceType deviceType, UINT32 linkPos, UINT64 linearPos); 136 | 137 | void MixerReset(); 138 | BOOL bGetDevSpecific(); 139 | void bSetDevSpecific 140 | ( 141 | _In_ BOOL bDevSpecific 142 | ); 143 | INT iGetDevSpecific(); 144 | void iSetDevSpecific 145 | ( 146 | _In_ INT iDevSpecific 147 | ); 148 | UINT uiGetDevSpecific(); 149 | void uiSetDevSpecific 150 | ( 151 | _In_ UINT uiDevSpecific 152 | ); 153 | ULONG GetMixerMux(); 154 | void SetMixerMux 155 | ( 156 | _In_ ULONG ulNode 157 | ); 158 | 159 | LONG GetMixerPeakMeter 160 | ( 161 | _In_ ULONG ulNode, 162 | _In_ ULONG ulChannel 163 | ); 164 | 165 | protected: 166 | private: 167 | }; 168 | typedef CCsAudioAcp3xHW *PCCsAudioAcp3xHW; 169 | 170 | #endif // _CSAUDIOACP3X_HW_H_ 171 | -------------------------------------------------------------------------------- /Source/Inc/kshelper.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | kshelper.h 8 | 9 | Abstract: 10 | 11 | Helper functions for simple audio sample 12 | --*/ 13 | #ifndef _CSAUDIOACP3X_KSHELPER_H_ 14 | #define _CSAUDIOACP3X_KSHELPER_H_ 15 | 16 | #include 17 | #include 18 | 19 | PWAVEFORMATEX 20 | GetWaveFormatEx 21 | ( 22 | _In_ PKSDATAFORMAT pDataFormat 23 | ); 24 | 25 | NTSTATUS 26 | ValidatePropertyParams 27 | ( 28 | _In_ PPCPROPERTY_REQUEST PropertyRequest, 29 | _In_ ULONG cbValueSize, 30 | _In_ ULONG cbInstanceSize = 0 31 | ); 32 | 33 | NTSTATUS 34 | PropertyHandler_BasicSupport 35 | ( 36 | _In_ PPCPROPERTY_REQUEST PropertyRequest, 37 | _In_ ULONG Flags, 38 | _In_ DWORD PropTypeSetId 39 | ); 40 | 41 | NTSTATUS 42 | PropertyHandler_BasicSupportPeakMeter2 43 | ( 44 | _In_ PPCPROPERTY_REQUEST PropertyRequest, 45 | _In_ ULONG MaxChannels 46 | ); 47 | 48 | NTSTATUS 49 | PropertyHandler_CpuResources 50 | ( 51 | _In_ PPCPROPERTY_REQUEST PropertyRequest 52 | ); 53 | 54 | NTSTATUS 55 | PropertyHandler_PeakMeter2 56 | ( 57 | _In_ PADAPTERCOMMON AdapterCommon, 58 | _In_ PPCPROPERTY_REQUEST PropertyRequest, 59 | _In_ ULONG MaxChannels 60 | ); 61 | 62 | //============================================================================= 63 | // Property helpers 64 | //============================================================================= 65 | 66 | NTSTATUS 67 | CsAudioAcp3xPropertyDispatch 68 | ( 69 | _In_ PPCPROPERTY_REQUEST PropertyRequest 70 | ); 71 | 72 | // Use this structure to define property items with extra data allowing easier 73 | // definition of separate get, set, and support handlers dispatched through 74 | // CsAudioAcp3xPropertyDispatch. 75 | typedef struct 76 | { 77 | PCPROPERTY_ITEM PropertyItem; // Standard PCPROPERTY_ITEM 78 | ULONG MinProperty; // Minimum size of the property instance data 79 | ULONG MinData; // Minimum size of the property value 80 | PCPFNPROPERTY_HANDLER GetHandler; // Property get handler (NULL if GET not supported) 81 | PCPFNPROPERTY_HANDLER SetHandler; // Property set handler (NULL if SET not supported) 82 | PCPFNPROPERTY_HANDLER SupportHandler; // Property support handler (NULL for common handler) 83 | VOID *ContextData; // Optional context information for the handler, NULL for unused 84 | ULONG ContextDataSize; // Size of the data held at ContextData, 0 for unused 85 | } CSAUDIOACP3X_PROPERTY_ITEM; 86 | 87 | // The following macros facilitate adding property handlers to a class, allowing 88 | // easier declaration and definition of a "thunk" routine that directly handles 89 | // the property request and calls into a class instance method. Note that as 90 | // written, the thunk routine assumes PAGED_CODE. 91 | #define DECLARE_CLASSPROPERTYHANDLER(theClass, theMethod) \ 92 | NTSTATUS theClass##_##theMethod \ 93 | ( \ 94 | _In_ PPCPROPERTY_REQUEST PropertyRequest \ 95 | ); 96 | 97 | #define DECLARE_PROPERTYHANDLER(theMethod) \ 98 | NTSTATUS theMethod \ 99 | ( \ 100 | _In_ PPCPROPERTY_REQUEST PropertyRequest \ 101 | ); 102 | 103 | #define DEFINE_CLASSPROPERTYHANDLER(theClass, theMethod) \ 104 | NTSTATUS theClass##_##theMethod \ 105 | ( \ 106 | _In_ PPCPROPERTY_REQUEST PropertyRequest \ 107 | ) \ 108 | { \ 109 | NTSTATUS status; \ 110 | \ 111 | PAGED_CODE(); \ 112 | \ 113 | theClass* p = reinterpret_cast(PropertyRequest->MajorTarget); \ 114 | \ 115 | p->AddRef(); \ 116 | status = p->theMethod(PropertyRequest); \ 117 | p->Release(); \ 118 | \ 119 | return status; \ 120 | } \ 121 | NTSTATUS theClass::theMethod \ 122 | ( \ 123 | _In_ PPCPROPERTY_REQUEST PropertyRequest \ 124 | ) 125 | 126 | 127 | 128 | 129 | #endif // _CSAUDIOACP3X_KSHELPER_H_ 130 | -------------------------------------------------------------------------------- /Source/Filters/speakertoptable.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | speakertoptable.h 8 | 9 | Abstract: 10 | 11 | Declaration of topology tables. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_SPEAKERTOPTABLE_H_ 15 | #define _CSAUDIOACP3X_SPEAKERTOPTABLE_H_ 16 | 17 | //============================================================================= 18 | static 19 | KSDATARANGE SpeakerTopoPinDataRangesBridge[] = 20 | { 21 | { 22 | sizeof(KSDATARANGE), 23 | 0, 24 | 0, 25 | 0, 26 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 27 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_ANALOG), 28 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_NONE) 29 | } 30 | }; 31 | 32 | //============================================================================= 33 | static 34 | PKSDATARANGE SpeakerTopoPinDataRangePointersBridge[] = 35 | { 36 | &SpeakerTopoPinDataRangesBridge[0] 37 | }; 38 | 39 | //============================================================================= 40 | static 41 | PCPIN_DESCRIPTOR SpeakerTopoMiniportPins[] = 42 | { 43 | // KSPIN_TOPO_WAVEOUT_SOURCE 44 | { 45 | 0, 46 | 0, 47 | 0, // InstanceCount 48 | NULL, // AutomationTable 49 | { // KsPinDescriptor 50 | 0, // InterfacesCount 51 | NULL, // Interfaces 52 | 0, // MediumsCount 53 | NULL, // Mediums 54 | SIZEOF_ARRAY(SpeakerTopoPinDataRangePointersBridge),// DataRangesCount 55 | SpeakerTopoPinDataRangePointersBridge, // DataRanges 56 | KSPIN_DATAFLOW_IN, // DataFlow 57 | KSPIN_COMMUNICATION_NONE, // Communication 58 | &KSCATEGORY_AUDIO, // Category 59 | NULL, // Name 60 | 0 // Reserved 61 | } 62 | }, 63 | // KSPIN_TOPO_LINEOUT_DEST 64 | { 65 | 0, 66 | 0, 67 | 0, // InstanceCount 68 | NULL, // AutomationTable 69 | { // KsPinDescriptor 70 | 0, // InterfacesCount 71 | NULL, // Interfaces 72 | 0, // MediumsCount 73 | NULL, // Mediums 74 | SIZEOF_ARRAY(SpeakerTopoPinDataRangePointersBridge),// DataRangesCount 75 | SpeakerTopoPinDataRangePointersBridge, // DataRanges 76 | KSPIN_DATAFLOW_OUT, // DataFlow 77 | KSPIN_COMMUNICATION_NONE, // Communication 78 | &KSNODETYPE_SPEAKER, // Category 79 | NULL, // Name 80 | 0 // Reserved 81 | } 82 | } 83 | }; 84 | 85 | //============================================================================= 86 | static 87 | KSJACK_DESCRIPTION SpeakerJackDescBridge = 88 | { 89 | KSAUDIO_SPEAKER_STEREO, 90 | 0xB3C98C, // Color spec for green 91 | eConnTypeAtapiInternal, 92 | eGeoLocFront, 93 | eGenLocInternal, 94 | ePortConnIntegratedDevice, 95 | TRUE 96 | }; 97 | 98 | // Only return a KSJACK_DESCRIPTION for the physical bridge pin. 99 | static 100 | PKSJACK_DESCRIPTION SpeakerJackDescriptions[] = 101 | { 102 | NULL, 103 | &SpeakerJackDescBridge 104 | }; 105 | 106 | static 107 | PCCONNECTION_DESCRIPTOR SpeakerTopoMiniportConnections[] = 108 | { 109 | {PCFILTER_NODE, KSPIN_TOPO_WAVEOUT_SOURCE, PCFILTER_NODE, KSPIN_TOPO_LINEOUT_DEST} //no volume controls 110 | }; 111 | 112 | //============================================================================= 113 | static 114 | PCPROPERTY_ITEM PropertiesSpeakerTopoFilter[] = 115 | { 116 | { 117 | &KSPROPSETID_Jack, 118 | KSPROPERTY_JACK_DESCRIPTION, 119 | KSPROPERTY_TYPE_GET | 120 | KSPROPERTY_TYPE_BASICSUPPORT, 121 | PropertyHandler_SpeakerTopoFilter 122 | }, 123 | { 124 | &KSPROPSETID_Jack, 125 | KSPROPERTY_JACK_DESCRIPTION2, 126 | KSPROPERTY_TYPE_GET | 127 | KSPROPERTY_TYPE_BASICSUPPORT, 128 | PropertyHandler_SpeakerTopoFilter 129 | } 130 | }; 131 | 132 | DEFINE_PCAUTOMATION_TABLE_PROP(AutomationSpeakerTopoFilter, PropertiesSpeakerTopoFilter); 133 | 134 | //============================================================================= 135 | static 136 | PCFILTER_DESCRIPTOR SpeakerTopoMiniportFilterDescriptor = 137 | { 138 | 0, // Version 139 | &AutomationSpeakerTopoFilter, // AutomationTable 140 | sizeof(PCPIN_DESCRIPTOR), // PinSize 141 | SIZEOF_ARRAY(SpeakerTopoMiniportPins), // PinCount 142 | SpeakerTopoMiniportPins, // Pins 143 | sizeof(PCNODE_DESCRIPTOR), // NodeSize 144 | 0, // NodeCount 145 | NULL, // Nodes 146 | SIZEOF_ARRAY(SpeakerTopoMiniportConnections), // ConnectionCount 147 | SpeakerTopoMiniportConnections, // Connections 148 | 0, // CategoryCount 149 | NULL // Categories 150 | }; 151 | 152 | #endif // _CSAUDIOACP3X_SPEAKERTOPTABLE_H_ 153 | -------------------------------------------------------------------------------- /Source/Filters/headphonetoptable.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | speakertoptable.h 8 | 9 | Abstract: 10 | 11 | Declaration of topology tables. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_HEADPHONETOPTABLE_H_ 15 | #define _CSAUDIOACP3X_HEADPHONETOPTABLE_H_ 16 | 17 | //============================================================================= 18 | static 19 | KSDATARANGE HeadphoneTopoPinDataRangesBridge[] = 20 | { 21 | { 22 | sizeof(KSDATARANGE), 23 | 0, 24 | 0, 25 | 0, 26 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 27 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_ANALOG), 28 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_NONE) 29 | } 30 | }; 31 | 32 | //============================================================================= 33 | static 34 | PKSDATARANGE HeadphoneTopoPinDataRangePointersBridge[] = 35 | { 36 | &HeadphoneTopoPinDataRangesBridge[0] 37 | }; 38 | 39 | //============================================================================= 40 | static 41 | PCPIN_DESCRIPTOR HeadphoneTopoMiniportPins[] = 42 | { 43 | // KSPIN_TOPO_WAVEOUT_SOURCE 44 | { 45 | 0, 46 | 0, 47 | 0, // InstanceCount 48 | NULL, // AutomationTable 49 | { // KsPinDescriptor 50 | 0, // InterfacesCount 51 | NULL, // Interfaces 52 | 0, // MediumsCount 53 | NULL, // Mediums 54 | SIZEOF_ARRAY(HeadphoneTopoPinDataRangePointersBridge),// DataRangesCount 55 | HeadphoneTopoPinDataRangePointersBridge, // DataRanges 56 | KSPIN_DATAFLOW_IN, // DataFlow 57 | KSPIN_COMMUNICATION_NONE, // Communication 58 | &KSCATEGORY_AUDIO, // Category 59 | NULL, // Name 60 | 0 // Reserved 61 | } 62 | }, 63 | // KSPIN_TOPO_LINEOUT_DEST 64 | { 65 | 0, 66 | 0, 67 | 0, // InstanceCount 68 | NULL, // AutomationTable 69 | { // KsPinDescriptor 70 | 0, // InterfacesCount 71 | NULL, // Interfaces 72 | 0, // MediumsCount 73 | NULL, // Mediums 74 | SIZEOF_ARRAY(HeadphoneTopoPinDataRangePointersBridge),// DataRangesCount 75 | HeadphoneTopoPinDataRangePointersBridge, // DataRanges 76 | KSPIN_DATAFLOW_OUT, // DataFlow 77 | KSPIN_COMMUNICATION_NONE, // Communication 78 | &KSNODETYPE_HEADPHONES, // Category 79 | NULL, // Name 80 | 0 // Reserved 81 | } 82 | } 83 | }; 84 | 85 | //============================================================================= 86 | static 87 | KSJACK_DESCRIPTION HeadphoneJackDescBridge = 88 | { 89 | KSAUDIO_SPEAKER_STEREO, 90 | 0xB3C98C, // Color spec for green 91 | eConnType3Point5mm, 92 | eGeoLocRight, 93 | eGenLocPrimaryBox, 94 | ePortConnJack, 95 | TRUE 96 | }; 97 | 98 | // Only return a KSJACK_DESCRIPTION for the physical bridge pin. 99 | static 100 | PKSJACK_DESCRIPTION HeadphoneJackDescriptions[] = 101 | { 102 | NULL, 103 | &HeadphoneJackDescBridge 104 | }; 105 | 106 | static 107 | PCCONNECTION_DESCRIPTOR HeadphoneTopoMiniportConnections[] = 108 | { 109 | {PCFILTER_NODE, KSPIN_TOPO_WAVEOUT_SOURCE, PCFILTER_NODE, KSPIN_TOPO_LINEOUT_DEST} //no volume controls 110 | }; 111 | 112 | //============================================================================= 113 | static 114 | PCPROPERTY_ITEM PropertiesHeadphoneTopoFilter[] = 115 | { 116 | { 117 | &KSPROPSETID_Jack, 118 | KSPROPERTY_JACK_DESCRIPTION, 119 | KSPROPERTY_TYPE_GET | 120 | KSPROPERTY_TYPE_BASICSUPPORT, 121 | PropertyHandler_HeadphoneTopoFilter 122 | }, 123 | { 124 | &KSPROPSETID_Jack, 125 | KSPROPERTY_JACK_DESCRIPTION2, 126 | KSPROPERTY_TYPE_GET | 127 | KSPROPERTY_TYPE_BASICSUPPORT, 128 | PropertyHandler_HeadphoneTopoFilter 129 | } 130 | }; 131 | 132 | DEFINE_PCAUTOMATION_TABLE_PROP(AutomationHeadphoneTopoFilter, PropertiesHeadphoneTopoFilter); 133 | 134 | //============================================================================= 135 | static 136 | PCFILTER_DESCRIPTOR HeadphoneTopoMiniportFilterDescriptor = 137 | { 138 | 0, // Version 139 | &AutomationHeadphoneTopoFilter, // AutomationTable 140 | sizeof(PCPIN_DESCRIPTOR), // PinSize 141 | SIZEOF_ARRAY(HeadphoneTopoMiniportPins), // PinCount 142 | HeadphoneTopoMiniportPins, // Pins 143 | sizeof(PCNODE_DESCRIPTOR), // NodeSize 144 | 0, // NodeCount 145 | NULL, // Nodes 146 | SIZEOF_ARRAY(HeadphoneTopoMiniportConnections), // ConnectionCount 147 | HeadphoneTopoMiniportConnections, // Connections 148 | 0, // CategoryCount 149 | NULL // Categories 150 | }; 151 | 152 | #endif // _CSAUDIOACP3X_HEADPHONETOPTABLE_H_ 153 | -------------------------------------------------------------------------------- /Package/package.VcxProj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | ARM64 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | Release 14 | ARM64 15 | 16 | 17 | Release 18 | Win32 19 | 20 | 21 | Debug 22 | x64 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | 30 | 31 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF} 32 | 33 | 34 | 35 | WindowsKernelModeDriver10.0 36 | Utility 37 | Package 38 | true 39 | Debug 40 | 41 | 42 | 43 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A} 44 | {E9D167E6-E633-4284-8F02-FF86DF3B6D7F} 45 | $(MSBuildProjectName) 46 | 47 | 48 | Windows10 49 | true 50 | 51 | 52 | Windows10 53 | false 54 | 55 | 56 | Windows10 57 | true 58 | 59 | 60 | Windows10 61 | true 62 | 63 | 64 | Windows10 65 | false 66 | 67 | 68 | Windows10 69 | false 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | DbgengKernelDebugger 81 | False 82 | None 83 | 84 | 85 | 86 | 87 | 88 | %PathToInf% 89 | False 90 | False 91 | True 92 | 93 | 133563 94 | 95 | 96 | 97 | sha256 98 | 99 | 100 | 101 | 102 | sha256 103 | 104 | 105 | 106 | 107 | sha256 108 | 109 | 110 | 111 | 112 | sha256 113 | 114 | 115 | 116 | 117 | sha256 118 | 119 | 120 | 121 | 122 | sha256 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /Source/Filters/micjacktoptable.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | usbhsmictopotable.h 8 | 9 | Abstract: 10 | 11 | Declaration of topology table for the USB Headset mic (external) 12 | 13 | --*/ 14 | 15 | #ifndef _CSAUDIOACP3X_MICJACKTOPTABLE_H_ 16 | #define _CSAUDIOACP3X_MICJACKTOPTABLE_H_ 17 | 18 | //============================================================================= 19 | static 20 | KSDATARANGE MicJackTopoPinDataRangesBridge[] = 21 | { 22 | { 23 | sizeof(KSDATARANGE), 24 | 0, 25 | 0, 26 | 0, 27 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 28 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_ANALOG), 29 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_NONE) 30 | } 31 | }; 32 | 33 | //============================================================================= 34 | static 35 | PKSDATARANGE MicJackTopoPinDataRangePointersBridge[] = 36 | { 37 | &MicJackTopoPinDataRangesBridge[0] 38 | }; 39 | 40 | //============================================================================= 41 | static 42 | PCPIN_DESCRIPTOR MicJackTopoMiniportPins[] = 43 | { 44 | // KSPIN_TOPO_MIC_ELEMENTS 45 | { 46 | 0, 47 | 0, 48 | 0, // InstanceCount 49 | NULL, // AutomationTable 50 | { // KsPinDescriptor 51 | 0, // InterfacesCount 52 | NULL, // Interfaces 53 | 0, // MediumsCount 54 | NULL, // Mediums 55 | SIZEOF_ARRAY(MicJackTopoPinDataRangePointersBridge),// DataRangesCount 56 | MicJackTopoPinDataRangePointersBridge, // DataRanges 57 | KSPIN_DATAFLOW_IN, // DataFlow 58 | KSPIN_COMMUNICATION_NONE, // Communication 59 | &KSNODETYPE_MICROPHONE, // Category 60 | NULL, // Name 61 | 0 // Reserved 62 | } 63 | }, 64 | 65 | // KSPIN_TOPO_BRIDGE 66 | { 67 | 0, 68 | 0, 69 | 0, // InstanceCount 70 | NULL, // AutomationTable 71 | { // KsPinDescriptor 72 | 0, // InterfacesCount 73 | NULL, // Interfaces 74 | 0, // MediumsCount 75 | NULL, // Mediums 76 | SIZEOF_ARRAY(MicJackTopoPinDataRangePointersBridge),// DataRangesCount 77 | MicJackTopoPinDataRangePointersBridge, // DataRanges 78 | KSPIN_DATAFLOW_OUT, // DataFlow 79 | KSPIN_COMMUNICATION_NONE, // Communication 80 | &KSCATEGORY_AUDIO, // Category 81 | NULL, // Name 82 | 0 // Reserved 83 | } 84 | } 85 | }; 86 | 87 | //============================================================================= 88 | static 89 | KSJACK_DESCRIPTION MicJackDesc = 90 | { 91 | KSAUDIO_SPEAKER_MONO, 92 | JACKDESC_RGB(0, 0, 0), 93 | eConnType3Point5mm, 94 | eGeoLocRight, 95 | eGenLocPrimaryBox, 96 | ePortConnJack, 97 | TRUE // NOTE: For convenience, wired headset jacks will be "unplugged" at boot. 98 | }; 99 | 100 | //============================================================================= 101 | // Only return a KSJACK_DESCRIPTION for the physical bridge pin. 102 | static 103 | PKSJACK_DESCRIPTION MicJackDescriptions[] = 104 | { 105 | &MicJackDesc, 106 | NULL 107 | }; 108 | 109 | //============================================================================= 110 | static 111 | PCCONNECTION_DESCRIPTOR MicJackMiniportConnections[] = 112 | { 113 | // FromNode, FromPin, ToNode, ToPin 114 | { PCFILTER_NODE, KSPIN_TOPO_MIC_ELEMENTS, PCFILTER_NODE, KSPIN_TOPO_BRIDGE } 115 | }; 116 | 117 | 118 | //============================================================================= 119 | static 120 | PCPROPERTY_ITEM MicJackPropertiesTopoFilter[] = 121 | { 122 | { 123 | &KSPROPSETID_Jack, 124 | KSPROPERTY_JACK_DESCRIPTION, 125 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 126 | PropertyHandler_MicJackTopoFilter 127 | }, 128 | { 129 | &KSPROPSETID_Jack, 130 | KSPROPERTY_JACK_DESCRIPTION2, 131 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 132 | PropertyHandler_MicJackTopoFilter 133 | } 134 | }; 135 | 136 | 137 | DEFINE_PCAUTOMATION_TABLE_PROP(AutomationMicJackTopoFilter, 138 | MicJackPropertiesTopoFilter); 139 | 140 | 141 | //============================================================================= 142 | static 143 | PCFILTER_DESCRIPTOR MicJackTopoMiniportFilterDescriptor = 144 | { 145 | 0, // Version 146 | &AutomationMicJackTopoFilter, // AutomationTable 147 | sizeof(PCPIN_DESCRIPTOR), // PinSize 148 | SIZEOF_ARRAY(MicJackTopoMiniportPins), // PinCount 149 | MicJackTopoMiniportPins, // Pins 150 | sizeof(PCNODE_DESCRIPTOR), // NodeSize 151 | 0, // NodeCount 152 | NULL, // Nodes 153 | SIZEOF_ARRAY(MicJackMiniportConnections),// ConnectionCount 154 | MicJackMiniportConnections, // Connections 155 | 0, // CategoryCount 156 | NULL // Categories 157 | }; 158 | 159 | #endif // _CSAUDIOACP3X_MICJACKTOPTABLE_H_ 160 | -------------------------------------------------------------------------------- /Source/Filters/micarray1toptable.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | micarray1toptable.h 8 | 9 | Abstract: 10 | 11 | Declaration of topology tables for the mic array. 12 | 13 | --*/ 14 | 15 | #ifndef _CSAUDIOACP3X_MICARRAY1TOPTABLE_H_ 16 | #define _CSAUDIOACP3X_MICARRAY1TOPTABLE_H_ 17 | 18 | // 19 | // {6ae81ff4-203e-4fe1-88aa-f2d57775cd4a} 20 | DEFINE_GUID(MICARRAY1_CUSTOM_NAME, 21 | 0x6ae81ff4, 0x203e, 0x4fe1, 0x88, 0xaa, 0xf2, 0xd5, 0x77, 0x75, 0xcd, 0x4a); 22 | 23 | //============================================================================= 24 | static 25 | KSDATARANGE MicArray1TopoPinDataRangesBridge[] = 26 | { 27 | { 28 | sizeof(KSDATARANGE), 29 | 0, 30 | 0, 31 | 0, 32 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 33 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_ANALOG), 34 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_NONE) 35 | } 36 | }; 37 | 38 | //============================================================================= 39 | static 40 | PKSDATARANGE MicArray1TopoPinDataRangePointersBridge[] = 41 | { 42 | &MicArray1TopoPinDataRangesBridge[0] 43 | }; 44 | 45 | //============================================================================= 46 | static 47 | PCPIN_DESCRIPTOR MicArray1TopoMiniportPins[] = 48 | { 49 | // KSPIN_TOPO_MIC_ELEMENTS 50 | { 51 | 0, 52 | 0, 53 | 0, // InstanceCount 54 | NULL, // AutomationTable 55 | { // KsPinDescriptor 56 | 0, // InterfacesCount 57 | NULL, // Interfaces 58 | 0, // MediumsCount 59 | NULL, // Mediums 60 | SIZEOF_ARRAY(MicArray1TopoPinDataRangePointersBridge), // DataRangesCount 61 | MicArray1TopoPinDataRangePointersBridge, // DataRanges 62 | KSPIN_DATAFLOW_IN, // DataFlow 63 | KSPIN_COMMUNICATION_NONE, // Communication 64 | &KSNODETYPE_MICROPHONE_ARRAY, // Category 65 | &MICARRAY1_CUSTOM_NAME, // Name 66 | 0 // Reserved 67 | } 68 | }, 69 | 70 | // KSPIN_TOPO_BRIDGE 71 | { 72 | 0, 73 | 0, 74 | 0, // InstanceCount 75 | NULL, // AutomationTable 76 | { // KsPinDescriptor 77 | 0, // InterfacesCount 78 | NULL, // Interfaces 79 | 0, // MediumsCount 80 | NULL, // Mediums 81 | SIZEOF_ARRAY(MicArray1TopoPinDataRangePointersBridge), // DataRangesCount 82 | MicArray1TopoPinDataRangePointersBridge, // DataRanges 83 | KSPIN_DATAFLOW_OUT, // DataFlow 84 | KSPIN_COMMUNICATION_NONE, // Communication 85 | &KSCATEGORY_AUDIO, // Category 86 | NULL, // Name 87 | 0 // Reserved 88 | } 89 | } 90 | }; 91 | 92 | static 93 | PCCONNECTION_DESCRIPTOR MicArray1TopoMiniportConnections[] = 94 | { 95 | // FromNode, FromPin, ToNode, ToPin 96 | { PCFILTER_NODE, KSPIN_TOPO_MIC_ELEMENTS, PCFILTER_NODE, KSPIN_TOPO_BRIDGE } 97 | }; 98 | 99 | 100 | 101 | //============================================================================= 102 | static 103 | PCPROPERTY_ITEM MicArray1PropertiesTopoFilter[] = 104 | { 105 | { 106 | &KSPROPSETID_Jack, 107 | KSPROPERTY_JACK_DESCRIPTION, 108 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 109 | PropertyHandler_MicArrayTopoFilter 110 | }, 111 | { 112 | &KSPROPSETID_Jack, 113 | KSPROPERTY_JACK_DESCRIPTION2, 114 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 115 | PropertyHandler_MicArrayTopoFilter 116 | }, 117 | { 118 | &KSPROPSETID_Audio, 119 | KSPROPERTY_AUDIO_MIC_ARRAY_GEOMETRY, 120 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 121 | PropertyHandler_MicArrayTopoFilter 122 | }, 123 | { 124 | &KSPROPSETID_Audio, 125 | KSPROPERTY_AUDIO_MIC_SNR, 126 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 127 | PropertyHandler_MicArrayTopoFilter 128 | }, 129 | { 130 | &KSPROPSETID_Audio, 131 | KSPROPERTY_AUDIO_MIC_SENSITIVITY2, 132 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 133 | PropertyHandler_MicArrayTopoFilter 134 | } 135 | }; 136 | 137 | DEFINE_PCAUTOMATION_TABLE_PROP(AutomationMicArray1TopoFilter, MicArray1PropertiesTopoFilter); 138 | 139 | //============================================================================= 140 | static 141 | PCFILTER_DESCRIPTOR MicArray1TopoMiniportFilterDescriptor = 142 | { 143 | 0, // Version 144 | &AutomationMicArray1TopoFilter, // AutomationTable 145 | sizeof(PCPIN_DESCRIPTOR), // PinSize 146 | SIZEOF_ARRAY(MicArray1TopoMiniportPins), // PinCount 147 | MicArray1TopoMiniportPins, // Pins 148 | sizeof(PCNODE_DESCRIPTOR), // NodeSize 149 | 0, // NodeCount 150 | NULL, // Nodes 151 | SIZEOF_ARRAY(MicArray1TopoMiniportConnections),// ConnectionCount 152 | MicArray1TopoMiniportConnections, // Connections 153 | 0, // CategoryCount 154 | NULL // Categories 155 | }; 156 | 157 | #endif // _CSAUDIOACP3X_MICARRAY1TOPTABLE_H_ 158 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | 28 | # Visual Studio 2015/2017 cache/options directory 29 | .vs/ 30 | # Uncomment if you have tasks that create the project's static files in wwwroot 31 | #wwwroot/ 32 | 33 | # Visual Studio 2017 auto generated files 34 | Generated\ Files/ 35 | 36 | # MSTest test Results 37 | [Tt]est[Rr]esult*/ 38 | [Bb]uild[Ll]og.* 39 | 40 | # NUNIT 41 | *.VisualState.xml 42 | TestResult.xml 43 | 44 | # Build Results of an ATL Project 45 | [Dd]ebugPS/ 46 | [Rr]eleasePS/ 47 | dlldata.c 48 | 49 | # Benchmark Results 50 | BenchmarkDotNet.Artifacts/ 51 | 52 | # .NET Core 53 | project.lock.json 54 | project.fragment.lock.json 55 | artifacts/ 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_h.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *_wpftmp.csproj 81 | *.log 82 | *.vspscc 83 | *.vssscc 84 | .builds 85 | *.pidb 86 | *.svclog 87 | *.scc 88 | 89 | # Chutzpah Test files 90 | _Chutzpah* 91 | 92 | # Visual C++ cache files 93 | ipch/ 94 | *.aps 95 | *.ncb 96 | *.opendb 97 | *.opensdf 98 | *.sdf 99 | *.cachefile 100 | *.VC.db 101 | *.VC.VC.opendb 102 | 103 | # Visual Studio profiler 104 | *.psess 105 | *.vsp 106 | *.vspx 107 | *.sap 108 | 109 | # Visual Studio Trace Files 110 | *.e2e 111 | 112 | # TFS 2012 Local Workspace 113 | $tf/ 114 | 115 | # Guidance Automation Toolkit 116 | *.gpState 117 | 118 | # ReSharper is a .NET coding add-in 119 | _ReSharper*/ 120 | *.[Rr]e[Ss]harper 121 | *.DotSettings.user 122 | 123 | # JustCode is a .NET coding add-in 124 | .JustCode 125 | 126 | # TeamCity is a build add-in 127 | _TeamCity* 128 | 129 | # DotCover is a Code Coverage Tool 130 | *.dotCover 131 | 132 | # AxoCover is a Code Coverage Tool 133 | .axoCover/* 134 | !.axoCover/settings.json 135 | 136 | # Visual Studio code coverage results 137 | *.coverage 138 | *.coveragexml 139 | 140 | # NCrunch 141 | _NCrunch_* 142 | .*crunch*.local.xml 143 | nCrunchTemp_* 144 | 145 | # MightyMoose 146 | *.mm.* 147 | AutoTest.Net/ 148 | 149 | # Web workbench (sass) 150 | .sass-cache/ 151 | 152 | # Installshield output folder 153 | [Ee]xpress/ 154 | 155 | # DocProject is a documentation generator add-in 156 | DocProject/buildhelp/ 157 | DocProject/Help/*.HxT 158 | DocProject/Help/*.HxC 159 | DocProject/Help/*.hhc 160 | DocProject/Help/*.hhk 161 | DocProject/Help/*.hhp 162 | DocProject/Help/Html2 163 | DocProject/Help/html 164 | 165 | # Click-Once directory 166 | publish/ 167 | 168 | # Publish Web Output 169 | *.[Pp]ublish.xml 170 | *.azurePubxml 171 | # Note: Comment the next line if you want to checkin your web deploy settings, 172 | # but database connection strings (with potential passwords) will be unencrypted 173 | *.pubxml 174 | *.publishproj 175 | 176 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 177 | # checkin your Azure Web App publish settings, but sensitive information contained 178 | # in these scripts will be unencrypted 179 | PublishScripts/ 180 | 181 | # NuGet Packages 182 | *.nupkg 183 | # The packages folder can be ignored because of Package Restore 184 | **/[Pp]ackages/* 185 | # except build/, which is used as an MSBuild target. 186 | !**/[Pp]ackages/build/ 187 | # Uncomment if necessary however generally it will be regenerated when needed 188 | #!**/[Pp]ackages/repositories.config 189 | # NuGet v3's project.json files produces more ignorable files 190 | *.nuget.props 191 | *.nuget.targets 192 | 193 | # Microsoft Azure Build Output 194 | csx/ 195 | *.build.csdef 196 | 197 | # Microsoft Azure Emulator 198 | ecf/ 199 | rcf/ 200 | 201 | # Windows Store app package directories and files 202 | AppPackages/ 203 | BundleArtifacts/ 204 | Package.StoreAssociation.xml 205 | _pkginfo.txt 206 | *.appx 207 | 208 | # Visual Studio cache files 209 | # files ending in .cache can be ignored 210 | *.[Cc]ache 211 | # but keep track of directories ending in .cache 212 | !*.[Cc]ache/ 213 | 214 | # Others 215 | ClientBin/ 216 | ~$* 217 | *~ 218 | *.dbmdl 219 | *.dbproj.schemaview 220 | *.jfm 221 | *.pfx 222 | *.publishsettings 223 | orleans.codegen.cs 224 | 225 | # Including strong name files can present a security risk 226 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 227 | #*.snk 228 | 229 | # Since there are multiple workflows, uncomment next line to ignore bower_components 230 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 231 | #bower_components/ 232 | 233 | # RIA/Silverlight projects 234 | Generated_Code/ 235 | 236 | # Backup & report files from converting an old project file 237 | # to a newer Visual Studio version. Backup files are not needed, 238 | # because we have git ;-) 239 | _UpgradeReport_Files/ 240 | Backup*/ 241 | UpgradeLog*.XML 242 | UpgradeLog*.htm 243 | ServiceFabricBackup/ 244 | *.rptproj.bak 245 | 246 | # SQL Server files 247 | *.mdf 248 | *.ldf 249 | *.ndf 250 | 251 | # Business Intelligence projects 252 | *.rdl.data 253 | *.bim.layout 254 | *.bim_*.settings 255 | *.rptproj.rsuser 256 | 257 | # Microsoft Fakes 258 | FakesAssemblies/ 259 | 260 | # GhostDoc plugin setting file 261 | *.GhostDoc.xml 262 | 263 | # Node.js Tools for Visual Studio 264 | .ntvs_analysis.dat 265 | node_modules/ 266 | 267 | # Visual Studio 6 build log 268 | *.plg 269 | 270 | # Visual Studio 6 workspace options file 271 | *.opt 272 | 273 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 274 | *.vbw 275 | 276 | # Visual Studio LightSwitch build output 277 | **/*.HTMLClient/GeneratedArtifacts 278 | **/*.DesktopClient/GeneratedArtifacts 279 | **/*.DesktopClient/ModelManifest.xml 280 | **/*.Server/GeneratedArtifacts 281 | **/*.Server/ModelManifest.xml 282 | _Pvt_Extensions 283 | 284 | # Paket dependency manager 285 | .paket/paket.exe 286 | paket-files/ 287 | 288 | # FAKE - F# Make 289 | .fake/ 290 | 291 | # JetBrains Rider 292 | .idea/ 293 | *.sln.iml 294 | 295 | # CodeRush personal settings 296 | .cr/personal 297 | 298 | # Python Tools for Visual Studio (PTVS) 299 | __pycache__/ 300 | *.pyc 301 | 302 | # Cake - Uncomment if you are using it 303 | # tools/** 304 | # !tools/packages.config 305 | 306 | # Tabs Studio 307 | *.tss 308 | 309 | # Telerik's JustMock configuration file 310 | *.jmconfig 311 | 312 | # BizTalk build output 313 | *.btp.cs 314 | *.btm.cs 315 | *.odx.cs 316 | *.xsd.cs 317 | 318 | # OpenCover UI analysis results 319 | OpenCover/ 320 | 321 | # Azure Stream Analytics local run output 322 | ASALocalRun/ 323 | 324 | # MSBuild Binary and Structured Log 325 | *.binlog 326 | 327 | # NVidia Nsight GPU debugger configuration file 328 | *.nvuser 329 | 330 | # MFractors (Xamarin productivity tool) working folder 331 | .mfractor/ 332 | 333 | # Local History for Visual Studio 334 | .localhistory/ 335 | -------------------------------------------------------------------------------- /Source/Inc/definitions.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | Definitions.h 8 | 9 | Abstract: 10 | 11 | Header file for common stuff. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_DEFINITIONS_H_ 15 | #define _CSAUDIOACP3X_DEFINITIONS_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "NewDelete.h" 25 | 26 | //============================================================================= 27 | // Defines 28 | //============================================================================= 29 | 30 | // Product Id 31 | // {836BA6D1-3FF7-4411-8BCD-469553452DCE} 32 | #define STATIC_PID_CSAUDIOACP3X\ 33 | 0x836ba6d1, 0x3ff7, 0x4411, 0x8b, 0xcd, 0x46, 0x95, 0x53, 0x45, 0x2d, 0xce 34 | DEFINE_GUIDSTRUCT("836BA6D1-3FF7-4411-8BCD-469553452DCE", PID_CSAUDIOACP3X); 35 | #define PID_CSAUDIOACP3X DEFINE_GUIDNAMED(PID_CSAUDIOACP3X) 36 | 37 | // Pool tag used for CSAUDIOACP3X allocations 38 | #define CSAUDIOACP3X_POOLTAG 'SASM' 39 | 40 | // Debug module name 41 | #define STR_MODULENAME "CSAUDIOACP3X: " 42 | 43 | // Debug utility macros 44 | #define D_FUNC 4 45 | #define D_BLAB DEBUGLVL_BLAB 46 | #define D_VERBOSE DEBUGLVL_VERBOSE 47 | #define D_TERSE DEBUGLVL_TERSE 48 | #define D_ERROR DEBUGLVL_ERROR 49 | #define DPF _DbgPrintF 50 | #define DPF_ENTER(x) DPF(D_FUNC, x) 51 | 52 | // Channel orientation 53 | #define CHAN_LEFT 0 54 | #define CHAN_RIGHT 1 55 | #define CHAN_MASTER (-1) 56 | 57 | // Dma Settings. 58 | #define DMA_BUFFER_SIZE 0x16000 59 | 60 | #define KSPROPERTY_TYPE_ALL KSPROPERTY_TYPE_BASICSUPPORT | \ 61 | KSPROPERTY_TYPE_GET | \ 62 | KSPROPERTY_TYPE_SET 63 | 64 | // Specific node numbers 65 | #define DEV_SPECIFIC_VT_BOOL 9 66 | #define DEV_SPECIFIC_VT_I4 10 67 | #define DEV_SPECIFIC_VT_UI4 11 68 | 69 | #define _100NS_PER_MILLISECOND 10000 // number of 100ns units per millisecond 70 | 71 | // Default volume settings. 72 | #define VOLUME_STEPPING_DELTA 0x8000 73 | #define VOLUME_SIGNED_MAXIMUM 0x00000000 74 | #define VOLUME_SIGNED_MINIMUM (-96 * 0x10000) 75 | 76 | // Default peak meter settings 77 | #define PEAKMETER_STEPPING_DELTA 0x1000 78 | #define PEAKMETER_SIGNED_MAXIMUM LONG_MAX 79 | #define PEAKMETER_SIGNED_MINIMUM LONG_MIN 80 | 81 | #define VALUE_NORMALIZE_P(v, step) \ 82 | ((((v) + (step)/2) / (step)) * (step)) 83 | 84 | #define VALUE_NORMALIZE(v, step) \ 85 | ((v) > 0 ? VALUE_NORMALIZE_P((v), (step)) : -(VALUE_NORMALIZE_P(-(v), (step)))) 86 | 87 | #define VALUE_NORMALIZE_IN_RANGE_EX(v, min, max, step) \ 88 | ((v) > (max) ? (max) : \ 89 | (v) < (min) ? (min) : \ 90 | VALUE_NORMALIZE((v), (step))) 91 | 92 | // to normalize volume values. 93 | #define VOLUME_NORMALIZE_IN_RANGE(v) \ 94 | VALUE_NORMALIZE_IN_RANGE_EX((v), VOLUME_SIGNED_MINIMUM, VOLUME_SIGNED_MAXIMUM, VOLUME_STEPPING_DELTA) 95 | 96 | // to normalize sample peak meter. 97 | #define PEAKMETER_NORMALIZE_IN_RANGE(v) \ 98 | VALUE_NORMALIZE_IN_RANGE_EX((v), PEAKMETER_SIGNED_MINIMUM, PEAKMETER_SIGNED_MAXIMUM, PEAKMETER_STEPPING_DELTA) 99 | 100 | #define ALL_CHANNELS_ID UINT32_MAX 101 | 102 | // Macros to assist with pin instance counting 103 | #define VERIFY_PIN_INSTANCE_RESOURCES_AVAILABLE(status, allocated, max) \ 104 | status = (allocated < max) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES 105 | 106 | #define ALLOCATE_PIN_INSTANCE_RESOURCES(allocated) \ 107 | allocated++ 108 | 109 | #define FREE_PIN_INSTANCE_RESOURCES(allocated) \ 110 | allocated-- 111 | 112 | // Define the value data type for supported sound detector patterns. Only 113 | // one pattern type is supported in this sample. 114 | typedef struct { 115 | KSMULTIPLE_ITEM MultipleItem; 116 | GUID PatternType[1]; 117 | } CONTOSO_SUPPORTEDPATTERNSVALUE; 118 | 119 | //============================================================================= 120 | // Typedefs 121 | //============================================================================= 122 | 123 | // Flags to identify stream processing mode 124 | typedef enum { 125 | CONNECTIONTYPE_TOPOLOGY_OUTPUT = 0, 126 | CONNECTIONTYPE_WAVE_OUTPUT = 1 127 | } CONNECTIONTYPE; 128 | 129 | // Connection table for registering topology/wave bridge connection 130 | typedef struct _PHYSICALCONNECTIONTABLE 131 | { 132 | ULONG ulTopology; 133 | ULONG ulWave; 134 | CONNECTIONTYPE eType; 135 | } PHYSICALCONNECTIONTABLE, *PPHYSICALCONNECTIONTABLE; 136 | 137 | // 138 | // This is the structure of the portclass FDO device extension Nt has created 139 | // for us. We keep the adapter common object here. 140 | // 141 | struct IAdapterCommon; 142 | typedef struct _PortClassDeviceContext // 32 64 Byte offsets for 32 and 64 bit architectures 143 | { 144 | ULONG_PTR m_pulReserved1[2]; // 0-7 0-15 First two pointers are reserved. 145 | PDEVICE_OBJECT m_DoNotUsePhysicalDeviceObject; // 8-11 16-23 Reserved pointer to our Physical Device Object (PDO). 146 | PVOID m_pvReserved2; // 12-15 24-31 Reserved pointer to our Start Device function. 147 | PVOID m_pvReserved3; // 16-19 32-39 "Out Memory" according to DDK. 148 | IAdapterCommon* m_pCommon; // 20-23 40-47 Pointer to our adapter common object. 149 | PVOID m_pvUnused1; // 24-27 48-55 Unused space. 150 | PVOID m_pvUnused2; // 28-31 56-63 Unused space. 151 | 152 | // Anything after above line should not be used. 153 | // This actually goes on for (64*sizeof(ULONG_PTR)) but it is all opaque. 154 | } PortClassDeviceContext; 155 | 156 | // 157 | // Major/MinorTarget to object casting. 158 | // 159 | #define MajorTarget_to_Obj(ptr) \ 160 | reinterpret_cast(ptr) 161 | 162 | #define MinorTarget_to_Obj(ptr) \ 163 | static_cast(reinterpret_cast(ptr)) 164 | 165 | // 166 | // Global settings. 167 | // 168 | extern DWORD g_DoNotCreateDataFiles; 169 | extern DWORD g_DisableBthScoBypass; 170 | extern UNICODE_STRING g_RegistryPath; 171 | 172 | //============================================================================= 173 | // Function prototypes 174 | //============================================================================= 175 | 176 | // Generic topology handler 177 | NTSTATUS PropertyHandler_Topology 178 | ( 179 | _In_ PPCPROPERTY_REQUEST PropertyRequest 180 | ); 181 | 182 | // Default WaveFilter automation table. 183 | // Handles the GeneralComponentId request. 184 | NTSTATUS PropertyHandler_WaveFilter 185 | ( 186 | _In_ PPCPROPERTY_REQUEST PropertyRequest 187 | ); 188 | 189 | NTSTATUS PropertyHandler_GenericPin 190 | ( 191 | _In_ PPCPROPERTY_REQUEST PropertyRequest 192 | ); 193 | 194 | // common.h uses some of the above definitions. 195 | #include "common.h" 196 | #include "kshelper.h" 197 | 198 | #endif // _CSAUDIOACP3X_DEFINITIONS_H_ 199 | -------------------------------------------------------------------------------- /csaudioacp3x.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.30503.244 4 | MinimumVisualStudioVersion = 12.0 5 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{FA56D96B-290B-4C73-A5E1-02C1861D3224}" 6 | EndProject 7 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Filters", "Filters", "{952A7CB1-E516-44AA-AC38-4AEED9874C41}" 8 | EndProject 9 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{0B4B8E51-20A8-43A4-A8DA-42FF90D628AC}" 10 | EndProject 11 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Inc", "Inc", "{C65091AE-E5B7-4359-8984-55852792406E}" 12 | EndProject 13 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{C06F6070-75EE-4F57-8D35-4AC2AB08D029}" 14 | EndProject 15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package", "Package\package.VcxProj", "{830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}" 16 | EndProject 17 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Filters", "Source\Filters\Filters.vcxproj", "{771312CF-E5A2-4676-8142-86CEBDF99E2B}" 18 | EndProject 19 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utilities", "Source\Utilities\Utilities.vcxproj", "{33E61864-6F2C-4F9F-BE70-8F8985A4F283}" 20 | EndProject 21 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Inc", "Source\Inc\Inc.vcxproj", "{4B664BA5-057A-41B8-B365-2C99065C4DFA}" 22 | EndProject 23 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main", "Source\Main\Main.vcxproj", "{E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}" 24 | ProjectSection(ProjectDependencies) = postProject 25 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283} = {33E61864-6F2C-4F9F-BE70-8F8985A4F283} 26 | {771312CF-E5A2-4676-8142-86CEBDF99E2B} = {771312CF-E5A2-4676-8142-86CEBDF99E2B} 27 | EndProjectSection 28 | EndProject 29 | Global 30 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 31 | Debug|ARM64 = Debug|ARM64 32 | Debug|Win32 = Debug|Win32 33 | Debug|x64 = Debug|x64 34 | Release|ARM64 = Release|ARM64 35 | Release|Win32 = Release|Win32 36 | Release|x64 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 39 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Debug|ARM64.ActiveCfg = Debug|ARM64 40 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Debug|ARM64.Build.0 = Debug|ARM64 41 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Debug|Win32.ActiveCfg = Debug|Win32 42 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Debug|Win32.Build.0 = Debug|Win32 43 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Debug|x64.ActiveCfg = Debug|x64 44 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Debug|x64.Build.0 = Debug|x64 45 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Release|ARM64.ActiveCfg = Release|ARM64 46 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Release|ARM64.Build.0 = Release|ARM64 47 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Release|Win32.ActiveCfg = Release|Win32 48 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Release|Win32.Build.0 = Release|Win32 49 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Release|x64.ActiveCfg = Release|x64 50 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A}.Release|x64.Build.0 = Release|x64 51 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Debug|ARM64.ActiveCfg = Debug|ARM64 52 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Debug|ARM64.Build.0 = Debug|ARM64 53 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Debug|Win32.ActiveCfg = Debug|Win32 54 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Debug|Win32.Build.0 = Debug|Win32 55 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Debug|x64.ActiveCfg = Debug|x64 56 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Debug|x64.Build.0 = Debug|x64 57 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Release|ARM64.ActiveCfg = Release|ARM64 58 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Release|ARM64.Build.0 = Release|ARM64 59 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Release|Win32.ActiveCfg = Release|Win32 60 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Release|Win32.Build.0 = Release|Win32 61 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Release|x64.ActiveCfg = Release|x64 62 | {771312CF-E5A2-4676-8142-86CEBDF99E2B}.Release|x64.Build.0 = Release|x64 63 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Debug|ARM64.ActiveCfg = Debug|ARM64 64 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Debug|ARM64.Build.0 = Debug|ARM64 65 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Debug|Win32.ActiveCfg = Debug|Win32 66 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Debug|Win32.Build.0 = Debug|Win32 67 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Debug|x64.ActiveCfg = Debug|x64 68 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Debug|x64.Build.0 = Debug|x64 69 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Release|ARM64.ActiveCfg = Release|ARM64 70 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Release|ARM64.Build.0 = Release|ARM64 71 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Release|Win32.ActiveCfg = Release|Win32 72 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Release|Win32.Build.0 = Release|Win32 73 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Release|x64.ActiveCfg = Release|x64 74 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283}.Release|x64.Build.0 = Release|x64 75 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Debug|ARM64.ActiveCfg = Debug|ARM64 76 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Debug|ARM64.Build.0 = Debug|ARM64 77 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Debug|Win32.ActiveCfg = Debug|Win32 78 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Debug|Win32.Build.0 = Debug|Win32 79 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Debug|x64.ActiveCfg = Debug|x64 80 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Debug|x64.Build.0 = Debug|x64 81 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Release|ARM64.ActiveCfg = Release|ARM64 82 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Release|ARM64.Build.0 = Release|ARM64 83 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Release|Win32.ActiveCfg = Release|Win32 84 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Release|Win32.Build.0 = Release|Win32 85 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Release|x64.ActiveCfg = Release|x64 86 | {4B664BA5-057A-41B8-B365-2C99065C4DFA}.Release|x64.Build.0 = Release|x64 87 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Debug|ARM64.ActiveCfg = Debug|ARM64 88 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Debug|ARM64.Build.0 = Debug|ARM64 89 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Debug|Win32.ActiveCfg = Debug|Win32 90 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Debug|Win32.Build.0 = Debug|Win32 91 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Debug|x64.ActiveCfg = Debug|x64 92 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Debug|x64.Build.0 = Debug|x64 93 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Release|ARM64.ActiveCfg = Release|ARM64 94 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Release|ARM64.Build.0 = Release|ARM64 95 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Release|Win32.ActiveCfg = Release|Win32 96 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Release|Win32.Build.0 = Release|Win32 97 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Release|x64.ActiveCfg = Release|x64 98 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF}.Release|x64.Build.0 = Release|x64 99 | EndGlobalSection 100 | GlobalSection(SolutionProperties) = preSolution 101 | HideSolutionNode = FALSE 102 | EndGlobalSection 103 | GlobalSection(NestedProjects) = preSolution 104 | {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A} = {FA56D96B-290B-4C73-A5E1-02C1861D3224} 105 | {771312CF-E5A2-4676-8142-86CEBDF99E2B} = {952A7CB1-E516-44AA-AC38-4AEED9874C41} 106 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283} = {0B4B8E51-20A8-43A4-A8DA-42FF90D628AC} 107 | {4B664BA5-057A-41B8-B365-2C99065C4DFA} = {C65091AE-E5B7-4359-8984-55852792406E} 108 | {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF} = {C06F6070-75EE-4F57-8D35-4AC2AB08D029} 109 | EndGlobalSection 110 | GlobalSection(ExtensibilityGlobals) = postSolution 111 | SolutionGuid = {6DB4FE19-4FE0-4DC4-B898-C46E01E6BDF4} 112 | EndGlobalSection 113 | EndGlobal 114 | -------------------------------------------------------------------------------- /Source/Filters/speakerwavtable.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | speakerwavtable.h 8 | 9 | Abstract: 10 | 11 | Declaration of wave miniport tables for the render endpoints. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_SPEAKERWAVTABLE_H_ 15 | #define _CSAUDIOACP3X_SPEAKERWAVTABLE_H_ 16 | 17 | // To keep the code simple assume device supports only 48KHz, 16-bit, stereo (PCM and NON-PCM) 18 | 19 | #define SPEAKER_DEVICE_MAX_CHANNELS 2 // Max Channels. 20 | 21 | #define SPEAKER_HOST_MAX_CHANNELS 2 // Max Channels. 22 | #define SPEAKER_HOST_MIN_BITS_PER_SAMPLE 16 // Min Bits Per Sample 23 | #define SPEAKER_HOST_MAX_BITS_PER_SAMPLE 16 // Max Bits Per Sample 24 | #define SPEAKER_HOST_MIN_SAMPLE_RATE 48000 // Min Sample Rate 25 | #define SPEAKER_HOST_MAX_SAMPLE_RATE 48000 // Max Sample Rate 26 | 27 | // 28 | // Max # of pin instances. 29 | // 30 | #define SPEAKER_MAX_INPUT_SYSTEM_STREAMS 1 31 | 32 | //============================================================================= 33 | 34 | static 35 | KSDATAFORMAT_WAVEFORMATEXTENSIBLE SpeakerHostPinSupportedDeviceFormats[] = 36 | { 37 | { // 0 38 | { 39 | sizeof(KSDATAFORMAT_WAVEFORMATEXTENSIBLE), 40 | 0, 41 | 0, 42 | 0, 43 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 44 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_PCM), 45 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) 46 | }, 47 | { 48 | { 49 | WAVE_FORMAT_EXTENSIBLE, 50 | 2, 51 | 48000, 52 | 192000, 53 | 4, 54 | 16, 55 | sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) 56 | }, 57 | 16, 58 | KSAUDIO_SPEAKER_STEREO, 59 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_PCM) 60 | } 61 | } 62 | }; 63 | 64 | // 65 | // Supported modes (only on streaming pins). 66 | // 67 | static 68 | MODE_AND_DEFAULT_FORMAT SpeakerHostPinSupportedDeviceModes[] = 69 | { 70 | { 71 | STATIC_AUDIO_SIGNALPROCESSINGMODE_DEFAULT, 72 | &SpeakerHostPinSupportedDeviceFormats[0].DataFormat // 48KHz 73 | } 74 | }; 75 | 76 | // 77 | // The entries here must follow the same order as the filter's pin 78 | // descriptor array. 79 | // 80 | static 81 | PIN_DEVICE_FORMATS_AND_MODES SpeakerPinDeviceFormatsAndModes[] = 82 | { 83 | { 84 | SystemRenderPin, 85 | SpeakerHostPinSupportedDeviceFormats, 86 | SIZEOF_ARRAY(SpeakerHostPinSupportedDeviceFormats), 87 | SpeakerHostPinSupportedDeviceModes, 88 | SIZEOF_ARRAY(SpeakerHostPinSupportedDeviceModes) 89 | }, 90 | { 91 | BridgePin, 92 | NULL, 93 | 0, 94 | NULL, 95 | 0 96 | } 97 | }; 98 | 99 | //============================================================================= 100 | static 101 | KSDATARANGE_AUDIO SpeakerPinDataRangesStream[] = 102 | { 103 | { // 0 104 | { 105 | sizeof(KSDATARANGE_AUDIO), 106 | KSDATARANGE_ATTRIBUTES, // An attributes list follows this data range 107 | 0, 108 | 0, 109 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 110 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_PCM), 111 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) 112 | }, 113 | SPEAKER_HOST_MAX_CHANNELS, 114 | SPEAKER_HOST_MIN_BITS_PER_SAMPLE, 115 | SPEAKER_HOST_MAX_BITS_PER_SAMPLE, 116 | SPEAKER_HOST_MIN_SAMPLE_RATE, 117 | SPEAKER_HOST_MAX_SAMPLE_RATE 118 | } 119 | }; 120 | 121 | static 122 | PKSDATARANGE SpeakerPinDataRangePointersStream[] = 123 | { 124 | PKSDATARANGE(&SpeakerPinDataRangesStream[0]), 125 | PKSDATARANGE(&PinDataRangeAttributeList), 126 | }; 127 | 128 | //============================================================================= 129 | static 130 | KSDATARANGE SpeakerPinDataRangesBridge[] = 131 | { 132 | { 133 | sizeof(KSDATARANGE), 134 | 0, 135 | 0, 136 | 0, 137 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 138 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_ANALOG), 139 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_NONE) 140 | } 141 | }; 142 | 143 | static 144 | PKSDATARANGE SpeakerPinDataRangePointersBridge[] = 145 | { 146 | &SpeakerPinDataRangesBridge[0] 147 | }; 148 | 149 | //============================================================================= 150 | static 151 | PCPIN_DESCRIPTOR SpeakerWaveMiniportPins[] = 152 | { 153 | // Wave Out Streaming Pin (Renderer) KSPIN_WAVE_RENDER3_SINK_SYSTEM 154 | { 155 | SPEAKER_MAX_INPUT_SYSTEM_STREAMS, 156 | SPEAKER_MAX_INPUT_SYSTEM_STREAMS, 157 | 0, 158 | NULL, // AutomationTable 159 | { 160 | 0, 161 | NULL, 162 | 0, 163 | NULL, 164 | SIZEOF_ARRAY(SpeakerPinDataRangePointersStream), 165 | SpeakerPinDataRangePointersStream, 166 | KSPIN_DATAFLOW_IN, 167 | KSPIN_COMMUNICATION_SINK, 168 | &KSCATEGORY_AUDIO, 169 | NULL, 170 | 0 171 | } 172 | }, 173 | // Wave Out Bridge Pin (Renderer) KSPIN_WAVE_RENDER3_SOURCE 174 | { 175 | 0, 176 | 0, 177 | 0, 178 | NULL, 179 | { 180 | 0, 181 | NULL, 182 | 0, 183 | NULL, 184 | SIZEOF_ARRAY(SpeakerPinDataRangePointersBridge), 185 | SpeakerPinDataRangePointersBridge, 186 | KSPIN_DATAFLOW_OUT, 187 | KSPIN_COMMUNICATION_NONE, 188 | &KSCATEGORY_AUDIO, 189 | NULL, 190 | 0 191 | } 192 | }, 193 | }; 194 | 195 | //============================================================================= 196 | // 197 | // ---------------------------- 198 | // | | 199 | // Host Pin 0-->| |--> 1 KSPIN_WAVE_RENDER3_SOURCE 200 | // | | 201 | // ---------------------------- 202 | static 203 | PCCONNECTION_DESCRIPTOR SpeakerWaveMiniportConnections[] = 204 | { 205 | { PCFILTER_NODE, KSPIN_WAVE_RENDER3_SINK_SYSTEM, PCFILTER_NODE, KSPIN_WAVE_RENDER3_SOURCE } 206 | }; 207 | 208 | //============================================================================= 209 | static 210 | PCPROPERTY_ITEM PropertiesSpeakerWaveFilter[] = 211 | { 212 | { 213 | &KSPROPSETID_Pin, 214 | KSPROPERTY_PIN_PROPOSEDATAFORMAT, 215 | KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_BASICSUPPORT, 216 | PropertyHandler_WaveFilter 217 | }, 218 | { 219 | &KSPROPSETID_Pin, 220 | KSPROPERTY_PIN_PROPOSEDATAFORMAT2, 221 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 222 | PropertyHandler_WaveFilter 223 | } 224 | }; 225 | 226 | DEFINE_PCAUTOMATION_TABLE_PROP(AutomationSpeakerWaveFilter, PropertiesSpeakerWaveFilter); 227 | 228 | //============================================================================= 229 | static 230 | PCFILTER_DESCRIPTOR SpeakerWaveMiniportFilterDescriptor = 231 | { 232 | 0, // Version 233 | &AutomationSpeakerWaveFilter, // AutomationTable 234 | sizeof(PCPIN_DESCRIPTOR), // PinSize 235 | SIZEOF_ARRAY(SpeakerWaveMiniportPins), // PinCount 236 | SpeakerWaveMiniportPins, // Pins 237 | sizeof(PCNODE_DESCRIPTOR), // NodeSize 238 | 0, // NodeCount 239 | NULL, // Nodes 240 | SIZEOF_ARRAY(SpeakerWaveMiniportConnections), // ConnectionCount 241 | SpeakerWaveMiniportConnections, // Connections 242 | 0, // CategoryCount 243 | NULL // Categories - use defaults (audio, render, capture) 244 | }; 245 | 246 | #endif // _CSAUDIOACP3X_SPEAKERWAVTABLE_H_ 247 | -------------------------------------------------------------------------------- /Source/Filters/micarraywavtable.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | micarraywavtable.h 8 | 9 | Abstract:- 10 | 11 | Declaration of wave miniport tables for the mic array. 12 | 13 | --*/ 14 | 15 | #ifndef _CSAUDIOACP3X_MICARRAYWAVTABLE_H_ 16 | #define _CSAUDIOACP3X_MICARRAYWAVTABLE_H_ 17 | 18 | // 19 | // Mic array range. 20 | // 21 | #define MICARRAY_RAW_CHANNELS 2 // Channels for raw mode 22 | #define MICARRAY_DEVICE_MAX_CHANNELS 2 // Max channels overall 23 | #define MICARRAY_32_BITS_PER_SAMPLE_PCM 32 // 32 Bits Per Sample 24 | #define MICARRAY_RAW_SAMPLE_RATE 48000 // Raw sample rate 25 | 26 | // 27 | // Max # of pin instances. 28 | // 29 | #define MICARRAY_MAX_INPUT_STREAMS 1 30 | 31 | //============================================================================= 32 | static 33 | KSDATAFORMAT_WAVEFORMATEXTENSIBLE MicArrayPinSupportedDeviceFormats[] = 34 | { 35 | // 48 KHz 16-bit 2 channels 36 | { 37 | { 38 | sizeof(KSDATAFORMAT_WAVEFORMATEXTENSIBLE), 39 | 0, 40 | 0, 41 | 0, 42 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 43 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_PCM), 44 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) 45 | }, 46 | { 47 | { 48 | WAVE_FORMAT_EXTENSIBLE, 49 | 2, 50 | 48000, 51 | 192000, 52 | 4, 53 | 16, 54 | sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) 55 | }, 56 | 16, 57 | KSAUDIO_SPEAKER_STEREO, 58 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_PCM) 59 | } 60 | } 61 | }; 62 | 63 | // 64 | // Supported modes (only on streaming pins). 65 | // 66 | static 67 | MODE_AND_DEFAULT_FORMAT MicArrayPinSupportedDeviceModes[] = 68 | { 69 | { 70 | STATIC_AUDIO_SIGNALPROCESSINGMODE_RAW, 71 | &MicArrayPinSupportedDeviceFormats[0].DataFormat 72 | } 73 | }; 74 | 75 | // 76 | // The entries here must follow the same order as the filter's pin 77 | // descriptor array. 78 | // 79 | static 80 | PIN_DEVICE_FORMATS_AND_MODES MicArrayPinDeviceFormatsAndModes[] = 81 | { 82 | { 83 | BridgePin, 84 | NULL, 85 | 0, 86 | NULL, 87 | 0 88 | }, 89 | { 90 | SystemCapturePin, 91 | MicArrayPinSupportedDeviceFormats, 92 | SIZEOF_ARRAY(MicArrayPinSupportedDeviceFormats), 93 | MicArrayPinSupportedDeviceModes, 94 | SIZEOF_ARRAY(MicArrayPinSupportedDeviceModes) 95 | } 96 | }; 97 | 98 | //============================================================================= 99 | // Data ranges 100 | // 101 | // See CMiniportWaveRT::DataRangeIntersection. 102 | // 103 | static 104 | KSDATARANGE_AUDIO MicArrayPinDataRangesRawStream[] = 105 | { 106 | { 107 | { 108 | sizeof(KSDATARANGE_AUDIO), 109 | KSDATARANGE_ATTRIBUTES, // An attributes list follows this data range 110 | 0, 111 | 0, 112 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 113 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_PCM), 114 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) 115 | }, 116 | MICARRAY_RAW_CHANNELS, 117 | MICARRAY_32_BITS_PER_SAMPLE_PCM, 118 | MICARRAY_32_BITS_PER_SAMPLE_PCM, 119 | MICARRAY_RAW_SAMPLE_RATE, 120 | MICARRAY_RAW_SAMPLE_RATE 121 | }, 122 | }; 123 | 124 | static 125 | PKSDATARANGE MicArrayPinDataRangePointersStream[] = 126 | { 127 | // All supported device formats should be listed in the DataRange. 128 | PKSDATARANGE(&MicArrayPinDataRangesRawStream[0]), 129 | PKSDATARANGE(&PinDataRangeAttributeList), 130 | }; 131 | 132 | //============================================================================= 133 | static 134 | KSDATARANGE MicArrayPinDataRangesBridge[] = 135 | { 136 | { 137 | sizeof(KSDATARANGE), 138 | 0, 139 | 0, 140 | 0, 141 | STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), 142 | STATICGUIDOF(KSDATAFORMAT_SUBTYPE_ANALOG), 143 | STATICGUIDOF(KSDATAFORMAT_SPECIFIER_NONE) 144 | } 145 | }; 146 | 147 | static 148 | PKSDATARANGE MicArrayPinDataRangePointersBridge[] = 149 | { 150 | &MicArrayPinDataRangesBridge[0] 151 | }; 152 | 153 | //============================================================================= 154 | static 155 | PCPIN_DESCRIPTOR MicArrayWaveMiniportPins[] = 156 | { 157 | // Wave In Bridge Pin (Capture - From Topology) KSPIN_WAVE_BRIDGE 158 | { 159 | 0, 160 | 0, 161 | 0, 162 | NULL, 163 | { 164 | 0, 165 | NULL, 166 | 0, 167 | NULL, 168 | SIZEOF_ARRAY(MicArrayPinDataRangePointersBridge), 169 | MicArrayPinDataRangePointersBridge, 170 | KSPIN_DATAFLOW_IN, 171 | KSPIN_COMMUNICATION_NONE, 172 | &KSCATEGORY_AUDIO, 173 | NULL, 174 | 0 175 | } 176 | }, 177 | // Wave In Streaming Pin (Capture) KSPIN_WAVE_HOST 178 | { 179 | MICARRAY_MAX_INPUT_STREAMS, 180 | MICARRAY_MAX_INPUT_STREAMS, 181 | 0, 182 | NULL, 183 | { 184 | 0, 185 | NULL, 186 | 0, 187 | NULL, 188 | SIZEOF_ARRAY(MicArrayPinDataRangePointersStream), 189 | MicArrayPinDataRangePointersStream, 190 | KSPIN_DATAFLOW_OUT, 191 | KSPIN_COMMUNICATION_SINK, 192 | &KSCATEGORY_AUDIO, 193 | &KSAUDFNAME_RECORDING_CONTROL, 194 | 0 195 | } 196 | } 197 | }; 198 | 199 | //============================================================================= 200 | static 201 | PCNODE_DESCRIPTOR MicArrayWaveMiniportNodes[] = 202 | { 203 | // KSNODE_WAVE_ADC 204 | { 205 | 0, // Flags 206 | NULL, // AutomationTable 207 | &KSNODETYPE_ADC, // Type 208 | NULL // Name 209 | } 210 | }; 211 | 212 | //============================================================================= 213 | static 214 | PCCONNECTION_DESCRIPTOR MicArrayWaveMiniportConnections[] = 215 | { 216 | { PCFILTER_NODE, KSPIN_WAVE_BRIDGE, KSNODE_WAVE_ADC, 1 }, 217 | { KSNODE_WAVE_ADC, 0, PCFILTER_NODE, KSPIN_WAVEIN_HOST }, 218 | }; 219 | 220 | //============================================================================= 221 | 222 | static 223 | CSAUDIOACP3X_PROPERTY_ITEM PropertiesMicArrayWaveFilter[] = 224 | { 225 | { 226 | { 227 | &KSPROPSETID_General, 228 | KSPROPERTY_GENERAL_COMPONENTID, 229 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 230 | PropertyHandler_WaveFilter, 231 | }, 232 | 0, 233 | 0, 234 | NULL, 235 | NULL, 236 | NULL, 237 | NULL, 238 | 0 239 | }, 240 | { 241 | { 242 | &KSPROPSETID_Pin, 243 | KSPROPERTY_PIN_PROPOSEDATAFORMAT, 244 | KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_BASICSUPPORT, 245 | PropertyHandler_WaveFilter, 246 | }, 247 | 0, 248 | 0, 249 | NULL, 250 | NULL, 251 | NULL, 252 | NULL, 253 | 0 254 | }, 255 | { 256 | { 257 | &KSPROPSETID_Pin, 258 | KSPROPERTY_PIN_PROPOSEDATAFORMAT2, 259 | KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, 260 | PropertyHandler_WaveFilter, 261 | }, 262 | 0, 263 | 0, 264 | NULL, 265 | NULL, 266 | NULL, 267 | NULL, 268 | 0 269 | }, 270 | }; 271 | 272 | DEFINE_PCAUTOMATION_TABLE_PROP(AutomationMicArrayWaveFilter, PropertiesMicArrayWaveFilter); 273 | 274 | //============================================================================= 275 | static 276 | PCFILTER_DESCRIPTOR MicArrayWaveMiniportFilterDescriptor = 277 | { 278 | 0, // Version 279 | &AutomationMicArrayWaveFilter, // AutomationTable 280 | sizeof(PCPIN_DESCRIPTOR), // PinSize 281 | SIZEOF_ARRAY(MicArrayWaveMiniportPins), // PinCount 282 | MicArrayWaveMiniportPins, // Pins 283 | sizeof(PCNODE_DESCRIPTOR), // NodeSize 284 | SIZEOF_ARRAY(MicArrayWaveMiniportNodes), // NodeCount 285 | MicArrayWaveMiniportNodes, // Nodes 286 | SIZEOF_ARRAY(MicArrayWaveMiniportConnections), // ConnectionCount 287 | MicArrayWaveMiniportConnections, // Connections 288 | 0, // CategoryCount 289 | NULL // Categories - use defaults (audio, render, capture) 290 | }; 291 | 292 | #endif // _CSAUDIOACP3X_MICARRAYWAVTABLE_H_ 293 | -------------------------------------------------------------------------------- /Source/Main/minwavert.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | minwavert.h 8 | 9 | Abstract: 10 | 11 | Definition of wavert miniport class. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_MINWAVERT_H_ 15 | #define _CSAUDIOACP3X_MINWAVERT_H_ 16 | 17 | //============================================================================= 18 | // Referenced Forward 19 | //============================================================================= 20 | class CMiniportWaveRTStream; 21 | class CAdapterCommon; 22 | typedef CMiniportWaveRTStream *PCMiniportWaveRTStream; 23 | 24 | //============================================================================= 25 | // Classes 26 | //============================================================================= 27 | /////////////////////////////////////////////////////////////////////////////// 28 | // CMiniportWaveRT 29 | // 30 | class CMiniportWaveRT : 31 | public IMiniportWaveRT, 32 | public IMiniportAudioSignalProcessing, 33 | public CUnknown 34 | { 35 | private: 36 | ULONG m_ulSystemAllocated; 37 | 38 | ULONG m_ulMaxSystemStreams; 39 | ULONG m_ulMaxOffloadStreams; 40 | ULONG m_ulMaxLoopbackStreams; 41 | 42 | // weak ref of running streams. 43 | PCMiniportWaveRTStream * m_SystemStreams; 44 | 45 | PKSDATAFORMAT_WAVEFORMATEXTENSIBLE m_pMixFormat; 46 | PKSDATAFORMAT_WAVEFORMATEXTENSIBLE m_pDeviceFormat; 47 | PCFILTER_DESCRIPTOR m_FilterDesc; 48 | PIN_DEVICE_FORMATS_AND_MODES * m_DeviceFormatsAndModes; 49 | KSPIN_LOCK m_DeviceFormatsAndModesLock; // To serialize access. 50 | KIRQL m_DeviceFormatsAndModesIrql; 51 | ULONG m_DeviceFormatsAndModesCount; 52 | USHORT m_DeviceMaxChannels; 53 | PDRMPORT m_pDrmPort; 54 | DRMRIGHTS m_MixDrmRights; 55 | ULONG m_ulMixDrmContentId; 56 | 57 | union { 58 | PVOID m_DeviceContext; 59 | }; 60 | 61 | protected: 62 | PADAPTERCOMMON m_pAdapterCommon; 63 | ULONG m_DeviceFlags; 64 | eDeviceType m_DeviceType; 65 | PPORTEVENTS m_pPortEvents; 66 | PENDPOINT_MINIPAIR m_pMiniportPair; 67 | 68 | public: 69 | NTSTATUS EventHandler_PinCapsChange 70 | ( 71 | _In_ PPCEVENT_REQUEST EventRequest 72 | ); 73 | 74 | NTSTATUS ValidateStreamCreate 75 | ( 76 | _In_ ULONG _Pin, 77 | _In_ BOOLEAN _Capture 78 | ); 79 | 80 | NTSTATUS StreamCreated 81 | ( 82 | _In_ ULONG _Pin, 83 | _In_ PCMiniportWaveRTStream _Stream 84 | ); 85 | 86 | NTSTATUS StreamClosed 87 | ( 88 | _In_ ULONG _Pin, 89 | _In_ PCMiniportWaveRTStream _Stream 90 | ); 91 | 92 | NTSTATUS AcquireDMA( 93 | _In_ PCMiniportWaveRTStream _Stream 94 | ); 95 | 96 | NTSTATUS StartDMA( 97 | UINT32 byteCount 98 | ); 99 | 100 | NTSTATUS StopDMA(); 101 | 102 | NTSTATUS CurrentPosition(UINT32* linkPos, UINT64* linearPos); 103 | NTSTATUS UpdatePosition(UINT32 linkPos, UINT64 linearPos); 104 | 105 | NTSTATUS IsFormatSupported 106 | ( 107 | _In_ ULONG _ulPin, 108 | _In_ BOOLEAN _bCapture, 109 | _In_ PKSDATAFORMAT _pDataFormat 110 | ); 111 | 112 | static NTSTATUS GetAttributesFromAttributeList 113 | ( 114 | _In_ const KSMULTIPLE_ITEM *_pAttributes, 115 | _In_ size_t _Size, 116 | _Out_ GUID* _pSignalProcessingMode 117 | ); 118 | 119 | protected: 120 | NTSTATUS UpdateDrmRights 121 | ( 122 | void 123 | ); 124 | 125 | public: 126 | DECLARE_STD_UNKNOWN(); 127 | 128 | #pragma code_seg("PAGE") 129 | CMiniportWaveRT( 130 | _In_ PUNKNOWN UnknownAdapter, 131 | _In_ PENDPOINT_MINIPAIR MiniportPair, 132 | _In_opt_ PVOID DeviceContext 133 | ) 134 | :CUnknown(0), 135 | m_ulMaxSystemStreams(0), 136 | m_DeviceType(MiniportPair->DeviceType), 137 | m_DeviceContext(DeviceContext), 138 | m_DeviceMaxChannels(MiniportPair->DeviceMaxChannels), 139 | m_DeviceFormatsAndModes(MiniportPair->PinDeviceFormatsAndModes), 140 | m_DeviceFormatsAndModesCount(MiniportPair->PinDeviceFormatsAndModesCount), 141 | m_DeviceFlags(MiniportPair->DeviceFlags), 142 | m_pMiniportPair(MiniportPair) 143 | { 144 | PAGED_CODE(); 145 | 146 | m_pAdapterCommon = (PADAPTERCOMMON)UnknownAdapter; 147 | if (m_pAdapterCommon) 148 | m_pAdapterCommon->AddRef(); 149 | 150 | if (MiniportPair->WaveDescriptor) 151 | { 152 | RtlCopyMemory(&m_FilterDesc, MiniportPair->WaveDescriptor, sizeof(m_FilterDesc)); 153 | 154 | // 155 | // Get the max # of pin instances. 156 | // 157 | if (IsRenderDevice()) 158 | { 159 | if (m_FilterDesc.PinCount > KSPIN_WAVE_RENDER2_SOURCE) 160 | { 161 | m_ulMaxSystemStreams = m_FilterDesc.Pins[KSPIN_WAVE_RENDER2_SINK_SYSTEM].MaxFilterInstanceCount; 162 | m_ulMaxLoopbackStreams = m_FilterDesc.Pins[KSPIN_WAVE_RENDER2_SINK_LOOPBACK].MaxFilterInstanceCount; 163 | } 164 | else if(m_FilterDesc.PinCount > KSPIN_WAVE_RENDER3_SOURCE) 165 | { 166 | m_ulMaxSystemStreams = m_FilterDesc.Pins[KSPIN_WAVE_RENDER3_SINK_SYSTEM].MaxFilterInstanceCount; 167 | } 168 | } 169 | else 170 | { 171 | // 172 | // capture bridge pin comes first in the enumeration 173 | // 174 | if (m_FilterDesc.PinCount > KSPIN_WAVEIN_HOST) 175 | { 176 | m_ulMaxSystemStreams = m_FilterDesc.Pins[KSPIN_WAVEIN_HOST].MaxFilterInstanceCount; 177 | } 178 | } 179 | } 180 | 181 | KeInitializeSpinLock(&m_DeviceFormatsAndModesLock); 182 | m_DeviceFormatsAndModesIrql = PASSIVE_LEVEL; 183 | } 184 | 185 | #pragma code_seg() 186 | 187 | ~CMiniportWaveRT(); 188 | 189 | IMP_IMiniportWaveRT; 190 | IMP_IMiniportAudioSignalProcessing; 191 | 192 | // Friends 193 | friend class CMiniportWaveRTStream; 194 | friend class CMiniportTopologyCsAudioAcp3x; 195 | 196 | friend NTSTATUS PropertyHandler_WaveFilter 197 | ( 198 | _In_ PPCPROPERTY_REQUEST PropertyRequest 199 | ); 200 | 201 | public: 202 | public: 203 | NTSTATUS PropertyHandlerProposedFormat 204 | ( 205 | _In_ PPCPROPERTY_REQUEST PropertyRequest 206 | ); 207 | 208 | NTSTATUS PropertyHandlerProposedFormat2 209 | 210 | ( 211 | _In_ PPCPROPERTY_REQUEST PropertyRequest 212 | ); 213 | 214 | PADAPTERCOMMON GetAdapterCommObj() 215 | { 216 | return (PADAPTERCOMMON)m_pAdapterCommon; 217 | }; 218 | #pragma code_seg() 219 | 220 | private: 221 | _IRQL_raises_(DISPATCH_LEVEL) 222 | _Acquires_lock_(m_DeviceFormatsAndModesLock) 223 | _Requires_lock_not_held_(m_DeviceFormatsAndModesLock) 224 | _IRQL_saves_global_(SpinLock, m_DeviceFormatsAndModesIrql) 225 | VOID AcquireFormatsAndModesLock(); 226 | 227 | _Releases_lock_(m_DeviceFormatsAndModesLock) 228 | _Requires_lock_held_(m_DeviceFormatsAndModesLock) 229 | _IRQL_restores_global_(SpinLock, m_DeviceFormatsAndModesIrql) 230 | VOID ReleaseFormatsAndModesLock(); 231 | 232 | _Post_satisfies_(return > 0) 233 | ULONG GetPinSupportedDeviceFormats(_In_ ULONG PinId, _Outptr_opt_result_buffer_(return) KSDATAFORMAT_WAVEFORMATEXTENSIBLE **ppFormats); 234 | 235 | _Success_(return != 0) 236 | ULONG GetPinSupportedDeviceModes(_In_ ULONG PinId, _Outptr_opt_result_buffer_(return) _On_failure_(_Deref_post_null_) MODE_AND_DEFAULT_FORMAT **ppModes); 237 | 238 | #pragma code_seg() 239 | 240 | protected: 241 | #pragma code_seg() 242 | BOOL IsRenderDevice() 243 | { 244 | return (m_DeviceType == eSpeakerDevice || m_DeviceType == eHeadphoneDevice) ? TRUE : FALSE; 245 | } 246 | 247 | BOOL IsSystemRenderPin(ULONG nPinId); 248 | 249 | BOOL IsSystemCapturePin(ULONG nPinId); 250 | 251 | BOOL IsBridgePin(ULONG nPinId); 252 | 253 | // These three pins are the pins used by the audio engine for host, loopback, and offload. 254 | ULONG GetSystemPinId() 255 | { 256 | ASSERT(IsRenderDevice()); 257 | return KSPIN_WAVE_RENDER2_SINK_SYSTEM; 258 | } 259 | }; 260 | 261 | typedef CMiniportWaveRT *PCMiniportWaveRT; 262 | 263 | #endif // _CSAUDIOACP3X_MINWAVERT_H_ 264 | -------------------------------------------------------------------------------- /Source/Filters/minipairs.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | minipairs.h 8 | 9 | Abstract: 10 | 11 | Local audio endpoint filter definitions. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_MINIPAIRS_H_ 15 | #define _CSAUDIOACP3X_MINIPAIRS_H_ 16 | 17 | #include "headphonetopo.h" 18 | #include "speakertopo.h" 19 | #include "headphonetoptable.h" 20 | #include "speakertoptable.h" 21 | #include "speakerwavtable.h" 22 | 23 | #include "micjacktopo.h" 24 | #include "micarraytopo.h" 25 | #include "micjacktoptable.h" 26 | #include "micarray1toptable.h" 27 | #include "micarraywavtable.h" 28 | 29 | 30 | NTSTATUS 31 | CreateMiniportWaveRTCsAudioAcp3x 32 | ( 33 | _Out_ PUNKNOWN *, 34 | _In_ REFCLSID, 35 | _In_opt_ PUNKNOWN, 36 | _In_ POOL_TYPE, 37 | _In_ PUNKNOWN, 38 | _In_opt_ PVOID, 39 | _In_ PENDPOINT_MINIPAIR 40 | ); 41 | 42 | NTSTATUS 43 | CreateMiniportTopologyCsAudioAcp3x 44 | ( 45 | _Out_ PUNKNOWN *, 46 | _In_ REFCLSID, 47 | _In_opt_ PUNKNOWN, 48 | _In_ POOL_TYPE, 49 | _In_ PUNKNOWN, 50 | _In_opt_ PVOID, 51 | _In_ PENDPOINT_MINIPAIR 52 | ); 53 | 54 | // 55 | // Render miniports. 56 | // 57 | 58 | /********************************************************************* 59 | * Topology/Wave bridge connection for speaker (internal) * 60 | * * 61 | * +------+ +------+ * 62 | * | Wave | | Topo | * 63 | * | | | | * 64 | * System --->|0 1|--------------->|0 1|---> Line Out * 65 | * | | | | * 66 | * +------+ +------+ * 67 | *********************************************************************/ 68 | static 69 | PHYSICALCONNECTIONTABLE SpeakerTopologyPhysicalConnections[] = 70 | { 71 | { 72 | KSPIN_TOPO_WAVEOUT_SOURCE, // TopologyIn 73 | KSPIN_WAVE_RENDER3_SOURCE, // WaveOut 74 | CONNECTIONTYPE_WAVE_OUTPUT 75 | } 76 | }; 77 | 78 | static 79 | ENDPOINT_MINIPAIR SpeakerMiniports = 80 | { 81 | eSpeakerDevice, 82 | L"TopologySpeaker", // make sure this or the template name matches with KSNAME_TopologySpeaker in the inf's [Strings] section 83 | NULL, // optional template name 84 | CreateMiniportTopologyCsAudioAcp3x, 85 | &SpeakerTopoMiniportFilterDescriptor, 86 | 0, NULL, // Interface properties 87 | L"WaveSpeaker", // make sure this or the template name matches with KSNAME_WaveSpeaker in the inf's [Strings] section 88 | NULL, // optional template name 89 | CreateMiniportWaveRTCsAudioAcp3x, 90 | &SpeakerWaveMiniportFilterDescriptor, 91 | 0, // Interface properties 92 | NULL, 93 | SPEAKER_DEVICE_MAX_CHANNELS, 94 | SpeakerPinDeviceFormatsAndModes, 95 | SIZEOF_ARRAY(SpeakerPinDeviceFormatsAndModes), 96 | SpeakerTopologyPhysicalConnections, 97 | SIZEOF_ARRAY(SpeakerTopologyPhysicalConnections), 98 | ENDPOINT_NO_FLAGS, 99 | }; 100 | 101 | static 102 | ENDPOINT_MINIPAIR HeadphoneMiniports = 103 | { 104 | eHeadphoneDevice, 105 | L"TopologyHeadphones", // make sure this or the template name matches with KSNAME_TopologySpeaker in the inf's [Strings] section 106 | NULL, // optional template name 107 | CreateMiniportTopologyCsAudioAcp3x, 108 | &HeadphoneTopoMiniportFilterDescriptor, 109 | 0, NULL, // Interface properties 110 | L"WaveHeadphones", // make sure this or the template name matches with KSNAME_WaveSpeaker in the inf's [Strings] section 111 | NULL, // optional template name 112 | CreateMiniportWaveRTCsAudioAcp3x, 113 | &SpeakerWaveMiniportFilterDescriptor, 114 | 0, // Interface properties 115 | NULL, 116 | SPEAKER_DEVICE_MAX_CHANNELS, 117 | SpeakerPinDeviceFormatsAndModes, 118 | SIZEOF_ARRAY(SpeakerPinDeviceFormatsAndModes), 119 | SpeakerTopologyPhysicalConnections, 120 | SIZEOF_ARRAY(SpeakerTopologyPhysicalConnections), 121 | ENDPOINT_NO_FLAGS, 122 | }; 123 | 124 | // 125 | // Capture miniports. 126 | // 127 | 128 | /********************************************************************* 129 | * Topology/Wave bridge connection for mic array 1 (front) * 130 | * * 131 | * +------+ +------+ * 132 | * | Topo | | Wave | * 133 | * | | | | * 134 | * Mic in --->|0 1|===>|0 1|---> Capture Host Pin * 135 | * | | | | * 136 | * +------+ +------+ * 137 | *********************************************************************/ 138 | static 139 | PHYSICALCONNECTIONTABLE MicArray1TopologyPhysicalConnections[] = 140 | { 141 | { 142 | KSPIN_TOPO_BRIDGE, // TopologyOut 143 | KSPIN_WAVE_BRIDGE, // WaveIn 144 | CONNECTIONTYPE_TOPOLOGY_OUTPUT 145 | } 146 | }; 147 | 148 | static 149 | ENDPOINT_MINIPAIR MicArray1Miniports = 150 | { 151 | eMicArrayDevice1, 152 | L"TopologyMicArray1", // make sure this or the template name matches with KSNAME_TopologyMicArray1 in the inf's [Strings] section 153 | NULL, // optional template name 154 | CreateMicArrayMiniportTopology, 155 | &MicArray1TopoMiniportFilterDescriptor, 156 | 0, NULL, // Interface properties 157 | L"WaveMicArray1", // make sure this or the tempalte name matches with KSNAME_WaveMicArray1 in the inf's [Strings] section 158 | NULL, // optional template name 159 | CreateMiniportWaveRTCsAudioAcp3x, 160 | &MicArrayWaveMiniportFilterDescriptor, 161 | 0, // Interface properties 162 | NULL, 163 | MICARRAY_DEVICE_MAX_CHANNELS, 164 | MicArrayPinDeviceFormatsAndModes, 165 | SIZEOF_ARRAY(MicArrayPinDeviceFormatsAndModes), 166 | MicArray1TopologyPhysicalConnections, 167 | SIZEOF_ARRAY(MicArray1TopologyPhysicalConnections), 168 | ENDPOINT_NO_FLAGS, 169 | }; 170 | 171 | static 172 | ENDPOINT_MINIPAIR MicJackMiniports = 173 | { 174 | eMicJackDevice, 175 | L"TopologyMicJack", // make sure this or the template name matches with KSNAME_TopologyMicArray1 in the inf's [Strings] section 176 | NULL, // optional template name 177 | CreateMiniportTopologyCsAudioAcp3x, 178 | &MicJackTopoMiniportFilterDescriptor, 179 | 0, NULL, // Interface properties 180 | L"WaveMicJack", // make sure this or the tempalte name matches with KSNAME_WaveMicArray1 in the inf's [Strings] section 181 | NULL, // optional template name 182 | CreateMiniportWaveRTCsAudioAcp3x, 183 | &MicArrayWaveMiniportFilterDescriptor, 184 | 0, // Interface properties 185 | NULL, 186 | MICARRAY_DEVICE_MAX_CHANNELS, 187 | MicArrayPinDeviceFormatsAndModes, 188 | SIZEOF_ARRAY(MicArrayPinDeviceFormatsAndModes), 189 | MicArray1TopologyPhysicalConnections, 190 | SIZEOF_ARRAY(MicArray1TopologyPhysicalConnections), 191 | ENDPOINT_NO_FLAGS, 192 | }; 193 | 194 | 195 | //============================================================================= 196 | // 197 | // Render miniport pairs. NOTE: the split of render and capture is arbitrary and 198 | // unnessary, this array could contain capture endpoints. 199 | // 200 | static 201 | PENDPOINT_MINIPAIR g_RenderEndpoints[] = 202 | { 203 | &SpeakerMiniports, 204 | &HeadphoneMiniports 205 | }; 206 | 207 | #define g_cRenderEndpoints (SIZEOF_ARRAY(g_RenderEndpoints)) 208 | 209 | //============================================================================= 210 | // 211 | // Capture miniport pairs. NOTE: the split of render and capture is arbitrary and 212 | // unnessary, this array could contain render endpoints. 213 | // 214 | static 215 | PENDPOINT_MINIPAIR g_CaptureEndpoints[] = 216 | { 217 | &MicArray1Miniports, 218 | &MicJackMiniports 219 | }; 220 | 221 | #define g_cCaptureEndpoints (SIZEOF_ARRAY(g_CaptureEndpoints)) 222 | 223 | //============================================================================= 224 | // 225 | // Total miniports = # endpoints * 2 (topology + wave). 226 | // 227 | #define g_MaxMiniports ((g_cRenderEndpoints + g_cCaptureEndpoints) * 2) 228 | 229 | #endif // _CSAUDIOACP3X_MINIPAIRS_H_ 230 | -------------------------------------------------------------------------------- /Source/Inc/Inc.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | ARM64 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | Release 14 | ARM64 15 | 16 | 17 | Release 18 | Win32 19 | 20 | 21 | Debug 22 | x64 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | 30 | {4B664BA5-057A-41B8-B365-2C99065C4DFA} 31 | $(MSBuildProjectName) 32 | 1 33 | Debug 34 | Win32 35 | {F51739CE-5253-42B5-9191-57F28B5842C6} 36 | 37 | 38 | 39 | Windows10 40 | False 41 | Universal 42 | KMDF 43 | WindowsKernelModeDriver10.0 44 | StaticLibrary 45 | 46 | 47 | Windows10 48 | False 49 | Universal 50 | KMDF 51 | WindowsKernelModeDriver10.0 52 | StaticLibrary 53 | 54 | 55 | Windows10 56 | True 57 | Universal 58 | KMDF 59 | WindowsKernelModeDriver10.0 60 | StaticLibrary 61 | 62 | 63 | Windows10 64 | True 65 | Universal 66 | KMDF 67 | WindowsKernelModeDriver10.0 68 | StaticLibrary 69 | 70 | 71 | Windows10 72 | False 73 | Universal 74 | KMDF 75 | WindowsKernelModeDriver10.0 76 | StaticLibrary 77 | 78 | 79 | Windows10 80 | True 81 | Universal 82 | KMDF 83 | WindowsKernelModeDriver10.0 84 | StaticLibrary 85 | 86 | 87 | 88 | $(IntDir) 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | Inc 111 | 112 | 113 | Inc 114 | 115 | 116 | Inc 117 | 118 | 119 | Inc 120 | 121 | 122 | Inc 123 | 124 | 125 | Inc 126 | 127 | 128 | 129 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 130 | %(PreprocessorDefinitions);_USE_WAVERT_ 131 | 132 | 133 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 134 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 135 | 136 | 137 | 4595;%(DisableSpecificWarnings) 138 | 139 | 140 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 141 | %(PreprocessorDefinitions);_USE_WAVERT_ 142 | 143 | 144 | sha256 145 | 146 | 147 | 148 | 149 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 150 | %(PreprocessorDefinitions);_USE_WAVERT_ 151 | 152 | 153 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 154 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 155 | 156 | 157 | 4595;%(DisableSpecificWarnings) 158 | 159 | 160 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 161 | %(PreprocessorDefinitions);_USE_WAVERT_ 162 | 163 | 164 | sha256 165 | 166 | 167 | 168 | 169 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 170 | %(PreprocessorDefinitions);_USE_WAVERT_ 171 | 172 | 173 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 174 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 175 | 176 | 177 | 4595;%(DisableSpecificWarnings) 178 | 179 | 180 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 181 | %(PreprocessorDefinitions);_USE_WAVERT_ 182 | 183 | 184 | sha256 185 | 186 | 187 | 188 | 189 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 190 | %(PreprocessorDefinitions);_USE_WAVERT_ 191 | 192 | 193 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 194 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 195 | 196 | 197 | 4595;%(DisableSpecificWarnings) 198 | 199 | 200 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 201 | %(PreprocessorDefinitions);_USE_WAVERT_ 202 | 203 | 204 | sha256 205 | 206 | 207 | 208 | 209 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 210 | %(PreprocessorDefinitions);_USE_WAVERT_ 211 | 212 | 213 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 214 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 215 | 216 | 217 | 4595;%(DisableSpecificWarnings) 218 | 219 | 220 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 221 | %(PreprocessorDefinitions);_USE_WAVERT_ 222 | 223 | 224 | sha256 225 | 226 | 227 | 228 | 229 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 230 | %(PreprocessorDefinitions);_USE_WAVERT_ 231 | 232 | 233 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 234 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 235 | 236 | 237 | 4595;%(DisableSpecificWarnings) 238 | 239 | 240 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 241 | %(PreprocessorDefinitions);_USE_WAVERT_ 242 | 243 | 244 | sha256 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | -------------------------------------------------------------------------------- /Source/Main/minwavertstream.cpp: -------------------------------------------------------------------------------- 1 | #include "definitions.h" 2 | #include 3 | #include 4 | #include "endpoints.h" 5 | #include "minwavert.h" 6 | #include "minwavertstream.h" 7 | #include "acp3x.h" 8 | #define MINWAVERTSTREAM_POOLTAG 'SRWM' 9 | 10 | #pragma warning (disable : 4127) 11 | 12 | //============================================================================= 13 | // CMiniportWaveRTStream 14 | //============================================================================= 15 | 16 | //============================================================================= 17 | #pragma code_seg("PAGE") 18 | CMiniportWaveRTStream::~CMiniportWaveRTStream 19 | ( 20 | void 21 | ) 22 | /*++ 23 | 24 | Routine Description: 25 | 26 | Destructor for wavertstream 27 | 28 | Arguments: 29 | 30 | Return Value: 31 | 32 | NT status code. 33 | 34 | --*/ 35 | { 36 | PAGED_CODE(); 37 | if (NULL != m_pMiniport) 38 | { 39 | 40 | if (m_bUnregisterStream) 41 | { 42 | m_pMiniport->StreamClosed(m_ulPin, this); 43 | m_bUnregisterStream = FALSE; 44 | } 45 | 46 | m_pMiniport->Release(); 47 | m_pMiniport = NULL; 48 | } 49 | 50 | if (m_pWfExt) 51 | { 52 | ExFreePoolWithTag( m_pWfExt, MINWAVERTSTREAM_POOLTAG ); 53 | m_pWfExt = NULL; 54 | } 55 | 56 | // Since we just cancelled the notification timer, wait for all queued 57 | // DPCs to complete before we free the notification DPC. 58 | // 59 | KeFlushQueuedDpcs(); 60 | 61 | DPF_ENTER(("[CMiniportWaveRTStream::~CMiniportWaveRTStream]")); 62 | } // ~CMiniportWaveRTStream 63 | 64 | //============================================================================= 65 | #pragma code_seg("PAGE") 66 | 67 | NTSTATUS 68 | CMiniportWaveRTStream::Init 69 | ( 70 | _In_ PCMiniportWaveRT Miniport_, 71 | _In_ PPORTWAVERTSTREAM PortStream_, 72 | _In_ ULONG Pin_, 73 | _In_ BOOLEAN Capture_, 74 | _In_ PKSDATAFORMAT DataFormat_, 75 | _In_ GUID SignalProcessingMode 76 | ) 77 | /*++ 78 | 79 | Routine Description: 80 | 81 | Initializes the stream object. 82 | 83 | Arguments: 84 | 85 | Miniport_ - 86 | 87 | Pin_ - 88 | 89 | DataFormat - 90 | 91 | SignalProcessingMode - The driver uses the signalProcessingMode to configure 92 | driver and/or hardware specific signal processing to be applied to this new 93 | stream. 94 | 95 | Return Value: 96 | 97 | NT status code. 98 | 99 | --*/ 100 | { 101 | PAGED_CODE(); 102 | UNREFERENCED_PARAMETER(SignalProcessingMode); 103 | 104 | PWAVEFORMATEX pWfEx = NULL; 105 | NTSTATUS ntStatus = STATUS_SUCCESS; 106 | 107 | m_pMiniport = NULL; 108 | m_ulPin = 0; 109 | m_bUnregisterStream = FALSE; 110 | m_bCapture = FALSE; 111 | m_ulDmaBufferSize = 0; 112 | m_KsState = KSSTATE_STOP; 113 | m_ulDmaMovementRate = 0; 114 | m_pWfExt = NULL; 115 | m_ulContentId = 0; 116 | 117 | m_pPortStream = PortStream_; 118 | 119 | // Initialize the spinlock to synchronize position updates 120 | KeInitializeSpinLock(&m_PositionSpinLock); 121 | 122 | pWfEx = GetWaveFormatEx(DataFormat_); 123 | if (NULL == pWfEx) 124 | { 125 | return STATUS_UNSUCCESSFUL; 126 | } 127 | 128 | m_pMiniport = reinterpret_cast(Miniport_); 129 | if (m_pMiniport == NULL) 130 | { 131 | return STATUS_INVALID_PARAMETER; 132 | } 133 | m_pMiniport->AddRef(); 134 | if (!NT_SUCCESS(ntStatus)) 135 | { 136 | return ntStatus; 137 | } 138 | m_ulPin = Pin_; 139 | m_bCapture = Capture_; 140 | m_ulDmaMovementRate = pWfEx->nAvgBytesPerSec; 141 | 142 | m_pWfExt = (PWAVEFORMATEXTENSIBLE)ExAllocatePoolZero(NonPagedPool, sizeof(WAVEFORMATEX) + pWfEx->cbSize, MINWAVERTSTREAM_POOLTAG); 143 | if (m_pWfExt == NULL) 144 | { 145 | return STATUS_INSUFFICIENT_RESOURCES; 146 | } 147 | RtlCopyMemory(m_pWfExt, pWfEx, sizeof(WAVEFORMATEX) + pWfEx->cbSize); 148 | 149 | if (m_bCapture) 150 | { 151 | 152 | //Initialize Capture hardware 153 | } 154 | else 155 | { 156 | //Initialize Render hardware 157 | } 158 | 159 | // 160 | // Register this stream. 161 | // 162 | ntStatus = m_pMiniport->StreamCreated(m_ulPin, this); 163 | if (NT_SUCCESS(ntStatus)) 164 | { 165 | m_bUnregisterStream = TRUE; 166 | } 167 | 168 | return ntStatus; 169 | } // Init 170 | 171 | //============================================================================= 172 | #pragma code_seg("PAGE") 173 | STDMETHODIMP_(NTSTATUS) 174 | CMiniportWaveRTStream::NonDelegatingQueryInterface 175 | ( 176 | _In_ REFIID Interface, 177 | _COM_Outptr_ PVOID * Object 178 | ) 179 | /*++ 180 | 181 | Routine Description: 182 | 183 | QueryInterface 184 | 185 | Arguments: 186 | 187 | Interface - GUID 188 | 189 | Object - interface pointer to be returned 190 | 191 | Return Value: 192 | 193 | NT status code. 194 | 195 | --*/ 196 | { 197 | PAGED_CODE(); 198 | 199 | ASSERT(Object); 200 | 201 | if (IsEqualGUIDAligned(Interface, IID_IUnknown)) 202 | { 203 | *Object = PVOID(PUNKNOWN(PMINIPORTWAVERTSTREAM(this))); 204 | } 205 | else if (IsEqualGUIDAligned(Interface, IID_IMiniportWaveRTStream)) 206 | { 207 | *Object = PVOID(PMINIPORTWAVERTSTREAM(this)); 208 | } 209 | else if (IsEqualGUIDAligned(Interface, IID_IDrmAudioStream)) 210 | { 211 | *Object = (PVOID)(IDrmAudioStream*)this; 212 | } 213 | else 214 | { 215 | *Object = NULL; 216 | } 217 | 218 | if (*Object) 219 | { 220 | PUNKNOWN(*Object)->AddRef(); 221 | return STATUS_SUCCESS; 222 | } 223 | 224 | return STATUS_INVALID_PARAMETER; 225 | } // NonDelegatingQueryInterface 226 | 227 | 228 | //============================================================================= 229 | #pragma code_seg("PAGE") 230 | NTSTATUS CMiniportWaveRTStream::GetClockRegister 231 | ( 232 | _Out_ PKSRTAUDIO_HWREGISTER Register_ 233 | ) 234 | { 235 | UNREFERENCED_PARAMETER(Register_); 236 | 237 | PAGED_CODE(); 238 | 239 | return STATUS_NOT_IMPLEMENTED; 240 | } 241 | 242 | //============================================================================= 243 | #pragma code_seg("PAGE") 244 | NTSTATUS CMiniportWaveRTStream::GetPositionRegister 245 | ( 246 | _Out_ PKSRTAUDIO_HWREGISTER Register_ 247 | ) 248 | { 249 | UNREFERENCED_PARAMETER(Register_); 250 | 251 | PAGED_CODE(); 252 | 253 | return STATUS_NOT_IMPLEMENTED; 254 | } 255 | 256 | //============================================================================= 257 | #pragma code_seg("PAGE") 258 | VOID CMiniportWaveRTStream::GetHWLatency 259 | ( 260 | _Out_ PKSRTAUDIO_HWLATENCY Latency_ 261 | ) 262 | { 263 | PAGED_CODE(); 264 | 265 | ASSERT(Latency_); 266 | 267 | Latency_->ChipsetDelay = 0; 268 | Latency_->CodecDelay = 0; 269 | Latency_->FifoSize = FIFO_SIZE; 270 | } 271 | 272 | //============================================================================= 273 | #pragma code_seg("PAGE") 274 | VOID CMiniportWaveRTStream::FreeAudioBuffer 275 | ( 276 | _In_opt_ PMDL Mdl_, 277 | _In_ ULONG Size_ 278 | ) 279 | { 280 | UNREFERENCED_PARAMETER(Size_); 281 | 282 | PAGED_CODE(); 283 | 284 | if (Mdl_ != NULL) 285 | { 286 | m_pPortStream->FreePagesFromMdl(Mdl_); 287 | } 288 | 289 | m_ulDmaBufferSize = 0; 290 | } 291 | 292 | //============================================================================= 293 | #pragma code_seg("PAGE") 294 | NTSTATUS CMiniportWaveRTStream::AllocateAudioBuffer 295 | ( 296 | _In_ ULONG RequestedSize_, 297 | _Out_ PMDL *AudioBufferMdl_, 298 | _Out_ ULONG *ActualSize_, 299 | _Out_ ULONG *OffsetFromFirstPage_, 300 | _Out_ MEMORY_CACHING_TYPE *CacheType_ 301 | ) 302 | { 303 | PAGED_CODE(); 304 | 305 | if ((0 == RequestedSize_) || (RequestedSize_ < m_pWfExt->Format.nBlockAlign)) 306 | { 307 | return STATUS_UNSUCCESSFUL; 308 | } 309 | 310 | if (RequestedSize_ > MAX_BUFFER) { 311 | RequestedSize_ = MAX_BUFFER; 312 | } 313 | 314 | RequestedSize_ -= RequestedSize_ % (m_pWfExt->Format.nBlockAlign); 315 | 316 | PHYSICAL_ADDRESS highAddress; 317 | highAddress.HighPart = 0; 318 | highAddress.LowPart = MAXULONG; 319 | 320 | PMDL pBufferMdl = m_pPortStream->AllocatePagesForMdl(highAddress, RequestedSize_); 321 | 322 | if (NULL == pBufferMdl) 323 | { 324 | return STATUS_UNSUCCESSFUL; 325 | } 326 | 327 | m_pMDL = pBufferMdl; 328 | 329 | m_ulDmaBufferSize = RequestedSize_; 330 | 331 | *AudioBufferMdl_ = pBufferMdl; 332 | *ActualSize_ = RequestedSize_; 333 | *OffsetFromFirstPage_ = 0; 334 | *CacheType_ = MmNonCached; 335 | 336 | return STATUS_SUCCESS; 337 | } 338 | 339 | //============================================================================= 340 | #pragma code_seg() 341 | NTSTATUS CMiniportWaveRTStream::GetPosition 342 | ( 343 | _Out_ KSAUDIO_POSITION *Position_ 344 | ) 345 | { 346 | NTSTATUS ntStatus; 347 | 348 | KIRQL oldIrql; 349 | KeAcquireSpinLock(&m_PositionSpinLock, &oldIrql); 350 | 351 | UINT64 linearPos; 352 | m_pMiniport->CurrentPosition(NULL, &linearPos); 353 | Position_->PlayOffset = linearPos; 354 | Position_->WriteOffset = linearPos + FIFO_SIZE; 355 | 356 | KeReleaseSpinLock(&m_PositionSpinLock, oldIrql); 357 | 358 | ntStatus = STATUS_SUCCESS; 359 | 360 | return ntStatus; 361 | } 362 | 363 | //============================================================================= 364 | #pragma code_seg() 365 | NTSTATUS CMiniportWaveRTStream::SetState 366 | ( 367 | _In_ KSSTATE State_ 368 | ) 369 | { 370 | NTSTATUS ntStatus = STATUS_SUCCESS; 371 | KIRQL oldIrql; 372 | 373 | // Spew an event for a pin state change request from portcls 374 | //Event type: eMINIPORT_PIN_STATE 375 | switch (State_) 376 | { 377 | case KSSTATE_STOP: 378 | if (m_KsState == KSSTATE_ACQUIRE) 379 | { 380 | // Acquire stream resources 381 | } 382 | KeAcquireSpinLock(&m_PositionSpinLock, &oldIrql); 383 | 384 | m_pMiniport->StopDMA(); 385 | if (!NT_SUCCESS(ntStatus)) { 386 | return ntStatus; 387 | } 388 | 389 | KeReleaseSpinLock(&m_PositionSpinLock, oldIrql); 390 | break; 391 | 392 | case KSSTATE_ACQUIRE: 393 | if (m_KsState == KSSTATE_STOP) 394 | { 395 | // Acquire stream resources 396 | } 397 | break; 398 | 399 | case KSSTATE_PAUSE: 400 | m_pMiniport->CurrentPosition(&m_lastLinkPos, &m_lastLinearPos); 401 | m_pMiniport->StopDMA(); 402 | break; 403 | 404 | case KSSTATE_RUN: 405 | // Start DMA 406 | ntStatus = m_pMiniport->AcquireDMA(this); 407 | if (!NT_SUCCESS(ntStatus)) { 408 | return ntStatus; 409 | } 410 | 411 | m_pMiniport->StartDMA(m_ulDmaBufferSize); 412 | if (!NT_SUCCESS(ntStatus)) { 413 | return ntStatus; 414 | } 415 | 416 | /*if (m_KsState == KSSTATE_PAUSE) { 417 | DbgPrint("Restoring last position\n"); 418 | m_pMiniport->UpdatePosition(m_lastLinkPos, m_lastLinearPos); 419 | }*/ 420 | 421 | break; 422 | } 423 | 424 | m_KsState = State_; 425 | 426 | return ntStatus; 427 | } 428 | 429 | //============================================================================= 430 | #pragma code_seg("PAGE") 431 | NTSTATUS CMiniportWaveRTStream::SetFormat 432 | ( 433 | _In_ KSDATAFORMAT *DataFormat_ 434 | ) 435 | { 436 | UNREFERENCED_PARAMETER(DataFormat_); 437 | 438 | PAGED_CODE(); 439 | 440 | //if (!m_fCapture && !g_DoNotCreateDataFiles) 441 | //{ 442 | // ntStatus = m_SaveData.SetDataFormat(Format); 443 | //} 444 | 445 | return STATUS_NOT_SUPPORTED; 446 | } 447 | 448 | //============================================================================= 449 | #pragma code_seg("PAGE") 450 | STDMETHODIMP_(NTSTATUS) 451 | CMiniportWaveRTStream::SetContentId 452 | ( 453 | _In_ ULONG contentId, 454 | _In_ PCDRMRIGHTS drmRights 455 | ) 456 | /*++ 457 | 458 | Routine Description: 459 | 460 | Sets DRM content Id for this stream. Also updates the Mixed content Id. 461 | 462 | Arguments: 463 | 464 | contentId - new content id 465 | 466 | drmRights - rights for this stream. 467 | 468 | Return Value: 469 | 470 | NT status code. 471 | 472 | --*/ 473 | { 474 | PAGED_CODE(); 475 | UNREFERENCED_PARAMETER(drmRights); 476 | 477 | DPF_ENTER(("[CMiniportWaveRT::SetContentId]")); 478 | 479 | NTSTATUS ntStatus; 480 | ULONG ulOldContentId = contentId; 481 | 482 | m_ulContentId = contentId; 483 | 484 | // 485 | // Miniport should create a mixed DrmRights. 486 | // 487 | ntStatus = m_pMiniport->UpdateDrmRights(); 488 | 489 | // 490 | // Restore the passed-in content Id. 491 | // 492 | if (!NT_SUCCESS(ntStatus)) 493 | { 494 | m_ulContentId = ulOldContentId; 495 | } 496 | 497 | // 498 | // From MSDN: 499 | // 500 | // This sample doesn't forward protected content, but if your driver uses 501 | // lower layer drivers or a different stack to properly work, please see the 502 | // following info from MSDN: 503 | // 504 | // "Before allowing protected content to flow through a data path, the system 505 | // verifies that the data path is secure. To do so, the system authenticates 506 | // each module in the data path beginning at the upstream end of the data path 507 | // and moving downstream. As each module is authenticated, that module gives 508 | // the system information about the next module in the data path so that it 509 | // can also be authenticated. To be successfully authenticated, a module's 510 | // binary file must be signed as DRM-compliant. 511 | // 512 | // Two adjacent modules in the data path can communicate with each other in 513 | // one of several ways. If the upstream module calls the downstream module 514 | // through IoCallDriver, the downstream module is part of a WDM driver. In 515 | // this case, the upstream module calls the DrmForwardContentToDeviceObject 516 | // function to provide the system with the device object representing the 517 | // downstream module. (If the two modules communicate through the downstream 518 | // module's COM interface or content handlers, the upstream module calls 519 | // DrmForwardContentToInterface or DrmAddContentHandlers instead.) 520 | // 521 | // DrmForwardContentToDeviceObject performs the same function as 522 | // PcForwardContentToDeviceObject and IDrmPort2::ForwardContentToDeviceObject." 523 | // 524 | // Other supported DRM DDIs for down-level module validation are: 525 | // DrmForwardContentToInterfaces and DrmAddContentHandlers. 526 | // 527 | // For more information, see MSDN's DRM Functions and Interfaces. 528 | // 529 | 530 | return ntStatus; 531 | } // SetContentId 532 | 533 | -------------------------------------------------------------------------------- /Source/Utilities/Utilities.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | ARM64 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | Release 14 | ARM64 15 | 16 | 17 | Release 18 | Win32 19 | 20 | 21 | Debug 22 | x64 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | 30 | {33E61864-6F2C-4F9F-BE70-8F8985A4F283} 31 | $(MSBuildProjectName) 32 | 1 33 | Debug 34 | Win32 35 | {F51739CE-5253-42B5-9191-57F28B5842C6} 36 | 37 | 38 | 39 | Windows10 40 | False 41 | Universal 42 | KMDF 43 | WindowsKernelModeDriver10.0 44 | StaticLibrary 45 | 46 | 47 | Windows10 48 | False 49 | Universal 50 | KMDF 51 | WindowsKernelModeDriver10.0 52 | StaticLibrary 53 | 54 | 55 | Windows10 56 | True 57 | Universal 58 | KMDF 59 | WindowsKernelModeDriver10.0 60 | StaticLibrary 61 | 62 | 63 | Windows10 64 | True 65 | Universal 66 | KMDF 67 | WindowsKernelModeDriver10.0 68 | StaticLibrary 69 | 70 | 71 | Windows10 72 | False 73 | Universal 74 | KMDF 75 | WindowsKernelModeDriver10.0 76 | StaticLibrary 77 | 78 | 79 | Windows10 80 | True 81 | Universal 82 | KMDF 83 | WindowsKernelModeDriver10.0 84 | StaticLibrary 85 | 86 | 87 | 88 | $(IntDir) 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | Utilities 111 | 112 | 113 | Utilities 114 | 115 | 116 | Utilities 117 | 118 | 119 | Utilities 120 | 121 | 122 | Utilities 123 | 124 | 125 | Utilities 126 | 127 | 128 | 129 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 130 | %(AdditionalIncludeDirectories);..\Inc 131 | %(PreprocessorDefinitions);_USE_WAVERT_ 132 | 133 | 134 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 135 | %(AdditionalIncludeDirectories);..\Inc;. 136 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 137 | 138 | 139 | 4595;%(DisableSpecificWarnings) 140 | 141 | 142 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 143 | %(AdditionalIncludeDirectories);..\Inc 144 | %(PreprocessorDefinitions);_USE_WAVERT_ 145 | 146 | 147 | sha256 148 | 149 | 150 | 151 | 152 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 153 | %(AdditionalIncludeDirectories);..\Inc 154 | %(PreprocessorDefinitions);_USE_WAVERT_ 155 | 156 | 157 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 158 | %(AdditionalIncludeDirectories);..\Inc;. 159 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 160 | 161 | 162 | 4595;%(DisableSpecificWarnings) 163 | 164 | 165 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 166 | %(AdditionalIncludeDirectories);..\Inc 167 | %(PreprocessorDefinitions);_USE_WAVERT_ 168 | 169 | 170 | sha256 171 | 172 | 173 | 174 | 175 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 176 | %(AdditionalIncludeDirectories);..\Inc 177 | %(PreprocessorDefinitions);_USE_WAVERT_ 178 | 179 | 180 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 181 | %(AdditionalIncludeDirectories);..\Inc;. 182 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 183 | 184 | 185 | 4595;%(DisableSpecificWarnings) 186 | 187 | 188 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 189 | %(AdditionalIncludeDirectories);..\Inc 190 | %(PreprocessorDefinitions);_USE_WAVERT_ 191 | 192 | 193 | sha256 194 | 195 | 196 | 197 | 198 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 199 | %(AdditionalIncludeDirectories);..\Inc 200 | %(PreprocessorDefinitions);_USE_WAVERT_ 201 | 202 | 203 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 204 | %(AdditionalIncludeDirectories);..\Inc;. 205 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 206 | 207 | 208 | 4595;%(DisableSpecificWarnings) 209 | 210 | 211 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 212 | %(AdditionalIncludeDirectories);..\Inc 213 | %(PreprocessorDefinitions);_USE_WAVERT_ 214 | 215 | 216 | sha256 217 | 218 | 219 | 220 | 221 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 222 | %(AdditionalIncludeDirectories);..\Inc 223 | %(PreprocessorDefinitions);_USE_WAVERT_ 224 | 225 | 226 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 227 | %(AdditionalIncludeDirectories);..\Inc;. 228 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 229 | 230 | 231 | 4595;%(DisableSpecificWarnings) 232 | 233 | 234 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 235 | %(AdditionalIncludeDirectories);..\Inc 236 | %(PreprocessorDefinitions);_USE_WAVERT_ 237 | 238 | 239 | sha256 240 | 241 | 242 | 243 | 244 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 245 | %(AdditionalIncludeDirectories);..\Inc 246 | %(PreprocessorDefinitions);_USE_WAVERT_ 247 | 248 | 249 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. 250 | %(AdditionalIncludeDirectories);..\Inc;. 251 | %(PreprocessorDefinitions);_USE_WAVERT_;_NEW_DELETE_OPERATORS_ 252 | 253 | 254 | 4595;%(DisableSpecificWarnings) 255 | 256 | 257 | %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. 258 | %(AdditionalIncludeDirectories);..\Inc 259 | %(PreprocessorDefinitions);_USE_WAVERT_ 260 | 261 | 262 | sha256 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | -------------------------------------------------------------------------------- /Source/Inc/common.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation All Rights Reserved 4 | 5 | Module Name: 6 | 7 | Common.h 8 | 9 | Abstract: 10 | 11 | CAdapterCommon class declaration. 12 | --*/ 13 | 14 | #ifndef _CSAUDIOACP3X_COMMON_H_ 15 | #define _CSAUDIOACP3X_COMMON_H_ 16 | 17 | #define HNSTIME_PER_MILLISECOND 10000 18 | 19 | //============================================================================= 20 | // Macros 21 | //============================================================================= 22 | 23 | #define UNREFERENCED_VAR(status) \ 24 | status = status 25 | 26 | //------------------------------------------------------------------------- 27 | // Description: 28 | // 29 | // jump to the given label. 30 | // 31 | // Parameters: 32 | // 33 | // label - [in] label to jump if condition is met 34 | // 35 | #define JUMP(label) \ 36 | goto label; 37 | 38 | //------------------------------------------------------------------------- 39 | // Description: 40 | // 41 | // If the condition evaluates to TRUE, jump to the given label. 42 | // 43 | // Parameters: 44 | // 45 | // condition - [in] Code that fits in if statement 46 | // label - [in] label to jump if condition is met 47 | // 48 | #define IF_TRUE_JUMP(condition, label) \ 49 | if (condition) \ 50 | { \ 51 | goto label; \ 52 | } 53 | 54 | //------------------------------------------------------------------------- 55 | // Description: 56 | // 57 | // If the condition evaluates to TRUE, perform the given statement 58 | // then jump to the given label. 59 | // 60 | // Parameters: 61 | // 62 | // condition - [in] Code that fits in if statement 63 | // action - [in] action to perform in body of if statement 64 | // label - [in] label to jump if condition is met 65 | // 66 | #define IF_TRUE_ACTION_JUMP(condition, action, label) \ 67 | if (condition) \ 68 | { \ 69 | action; \ 70 | goto label; \ 71 | } 72 | 73 | //------------------------------------------------------------------------- 74 | // Description: 75 | // 76 | // If the ntStatus is not NT_SUCCESS, perform the given statement then jump to 77 | // the given label. 78 | // 79 | // Parameters: 80 | // 81 | // ntStatus - [in] Value to check 82 | // action - [in] action to perform in body of if statement 83 | // label - [in] label to jump if condition is met 84 | // 85 | #define IF_FAILED_ACTION_JUMP(ntStatus, action, label) \ 86 | if (!NT_SUCCESS(ntStatus)) \ 87 | { \ 88 | action; \ 89 | goto label; \ 90 | } 91 | 92 | //------------------------------------------------------------------------- 93 | // Description: 94 | // 95 | // If the ntStatus passed is not NT_SUCCESS, jump to the given label. 96 | // 97 | // Parameters: 98 | // 99 | // ntStatus - [in] Value to check 100 | // label - [in] label to jump if condition is met 101 | // 102 | #define IF_FAILED_JUMP(ntStatus, label) \ 103 | if (!NT_SUCCESS(ntStatus)) \ 104 | { \ 105 | goto label; \ 106 | } 107 | 108 | #define SAFE_RELEASE(p) {if (p) { (p)->Release(); (p) = nullptr; } } 109 | #define SAFE_DELETE_PTR_WITH_TAG(ptr, tag) if(ptr) { ExFreePoolWithTag((ptr), tag); (ptr) = NULL; } 110 | 111 | // JACKDESC_RGB(r, g, b) 112 | #define JACKDESC_RGB(r, g, b) \ 113 | ((COLORREF)((r << 16) | (g << 8) | (b))) 114 | 115 | // Min/Max defines. 116 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) 117 | #define MAX(x, y) ((x) > (y) ? (x) : (y)) 118 | 119 | #define MINWAVERT_POOLTAG 'RWNM' 120 | #define MINTOPORT_POOLTAG 'RTNM' 121 | #define MINADAPTER_POOLTAG 'uAyS' 122 | 123 | typedef enum 124 | { 125 | eSpeakerDevice = 0, 126 | eHeadphoneDevice, 127 | eMicArrayDevice1, 128 | eMicJackDevice, 129 | eMaxDeviceType, 130 | } eDeviceType; 131 | 132 | // 133 | // Signal processing modes and default formats structs. 134 | // 135 | typedef struct _MODE_AND_DEFAULT_FORMAT { 136 | GUID Mode; 137 | KSDATAFORMAT* DefaultFormat; 138 | } MODE_AND_DEFAULT_FORMAT, *PMODE_AND_DEFAULT_FORMAT; 139 | 140 | // 141 | // Enumeration of the various types of pins implemented in this driver. 142 | // 143 | typedef enum 144 | { 145 | NoPin, 146 | BridgePin, 147 | SystemRenderPin, 148 | SystemCapturePin, 149 | } PINTYPE; 150 | 151 | // 152 | // PIN_DEVICE_FORMATS_AND_MODES 153 | // 154 | // Used to specify a pin's type (e.g. system, offload, etc.), formats, and 155 | // modes. Conceptually serves similar purpose as the PCPIN_DESCRIPTOR to 156 | // define a pin, but is more specific to driver implementation. 157 | // 158 | // Arrays of these structures follow the same order as the filter's 159 | // pin descriptor array so that KS pin IDs can serve as an index. 160 | // 161 | typedef struct _PIN_DEVICE_FORMATS_AND_MODES 162 | { 163 | PINTYPE PinType; 164 | 165 | KSDATAFORMAT_WAVEFORMATEXTENSIBLE * WaveFormats; 166 | ULONG WaveFormatsCount; 167 | 168 | MODE_AND_DEFAULT_FORMAT * ModeAndDefaultFormat; 169 | ULONG ModeAndDefaultFormatCount; 170 | 171 | } PIN_DEVICE_FORMATS_AND_MODES, *PPIN_DEVICE_FORMATS_AND_MODES; 172 | 173 | // forward declaration. 174 | typedef struct _ENDPOINT_MINIPAIR *PENDPOINT_MINIPAIR; 175 | 176 | // both wave & topology miniport create function prototypes have this form: 177 | typedef HRESULT (*PFNCREATEMINIPORT)( 178 | _Out_ PUNKNOWN * Unknown, 179 | _In_ REFCLSID, 180 | _In_opt_ PUNKNOWN UnknownOuter, 181 | _In_ POOL_TYPE PoolType, 182 | _In_ PUNKNOWN UnknownAdapter, 183 | _In_opt_ PVOID DeviceContext, 184 | _In_ PENDPOINT_MINIPAIR MiniportPair 185 | ); 186 | 187 | //============================================================================= 188 | // 189 | //============================================================================= 190 | typedef struct _CSAUDIOACP3X_DEVPROPERTY { 191 | const DEVPROPKEY *PropertyKey; 192 | DEVPROPTYPE Type; 193 | ULONG BufferSize; 194 | __field_bcount_opt(BufferSize) PVOID Buffer; 195 | } CSAUDIOACP3X_DEVPROPERTY, PCSAUDIOACP3X_DEVPROPERTY; 196 | 197 | #define ENDPOINT_NO_FLAGS 0x00000000 198 | #define ENDPOINT_CELLULAR_PROVIDER1 0x00000008 199 | #define ENDPOINT_CELLULAR_PROVIDER2 0x00000010 200 | 201 | // 202 | // Endpoint miniport pair (wave/topology) descriptor. 203 | // 204 | typedef struct _ENDPOINT_MINIPAIR 205 | { 206 | eDeviceType DeviceType; 207 | 208 | // Topology miniport. 209 | PWSTR TopoName; // make sure this or the template name matches with CSAUDIOACP3X..szPname in the inf's [Strings] section 210 | PWSTR TemplateTopoName; // optional template name 211 | PFNCREATEMINIPORT TopoCreateCallback; 212 | PCFILTER_DESCRIPTOR* TopoDescriptor; 213 | ULONG TopoInterfacePropertyCount; 214 | const CSAUDIOACP3X_DEVPROPERTY* TopoInterfaceProperties; 215 | 216 | // Wave RT miniport. 217 | PWSTR WaveName; // make sure this or the template name matches with CSAUDIOACP3X..szPname in the inf's [Strings] section 218 | PWSTR TemplateWaveName; // optional template name 219 | PFNCREATEMINIPORT WaveCreateCallback; 220 | PCFILTER_DESCRIPTOR* WaveDescriptor; 221 | ULONG WaveInterfacePropertyCount; 222 | const CSAUDIOACP3X_DEVPROPERTY* WaveInterfaceProperties; 223 | 224 | USHORT DeviceMaxChannels; 225 | PIN_DEVICE_FORMATS_AND_MODES* PinDeviceFormatsAndModes; 226 | ULONG PinDeviceFormatsAndModesCount; 227 | 228 | // Miniport physical connections. 229 | PHYSICALCONNECTIONTABLE* PhysicalConnections; 230 | ULONG PhysicalConnectionCount; 231 | 232 | // General endpoint flags (one of more ENDPOINT_, see above) 233 | ULONG DeviceFlags; 234 | } ENDPOINT_MINIPAIR; 235 | 236 | //============================================================================= 237 | // Defines 238 | //============================================================================= 239 | 240 | DEFINE_GUID(IID_IAdapterCommon, 241 | 0x7eda2950, 0xbf9f, 0x11d0, 0x87, 0x1f, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44); 242 | 243 | //============================================================================= 244 | // Interfaces 245 | //============================================================================= 246 | 247 | /////////////////////////////////////////////////////////////////////////////// 248 | // IAdapterCommon 249 | // 250 | DECLARE_INTERFACE_(IAdapterCommon, IUnknown) 251 | { 252 | STDMETHOD_(NTSTATUS, Init) 253 | ( 254 | THIS_ 255 | _In_ PRESOURCELIST ResourceList, 256 | _In_ PDEVICE_OBJECT DeviceObject 257 | ) PURE; 258 | 259 | STDMETHOD_(PDEVICE_OBJECT, GetDeviceObject) 260 | ( 261 | THIS 262 | ) PURE; 263 | 264 | STDMETHOD_(PDEVICE_OBJECT, GetPhysicalDeviceObject) 265 | ( 266 | THIS 267 | ) PURE; 268 | 269 | STDMETHOD_(WDFDEVICE, GetWdfDevice) 270 | ( 271 | THIS 272 | ) PURE; 273 | 274 | STDMETHOD_(VOID, SetWaveServiceGroup) 275 | ( 276 | THIS_ 277 | _In_ PSERVICEGROUP ServiceGroup 278 | ) PURE; 279 | 280 | STDMETHOD_(NTSTATUS, PrepareDMA) 281 | ( 282 | THIS_ 283 | _In_ eDeviceType deviceType, 284 | _In_ PMDL mdl, 285 | _In_ IPortWaveRTStream * stream 286 | ) PURE; 287 | 288 | STDMETHOD_(NTSTATUS, StartDMA) 289 | ( 290 | THIS_ 291 | _In_ eDeviceType deviceType, 292 | _In_ UINT32 byteCount 293 | ) PURE; 294 | STDMETHOD_(NTSTATUS, StopDMA) 295 | ( 296 | THIS_ 297 | _In_ eDeviceType deviceType 298 | ) PURE; 299 | STDMETHOD_(NTSTATUS, CurrentPosition) 300 | ( 301 | THIS_ 302 | _In_ eDeviceType deviceType, 303 | _Out_ UINT32 * linkPos, 304 | _Out_ UINT64 * linearPos 305 | ) PURE; 306 | STDMETHOD_(NTSTATUS, UpdatePosition) 307 | ( 308 | THIS_ 309 | _In_ eDeviceType deviceType, 310 | _In_ UINT32 linkPos, 311 | _In_ UINT64 linearPos 312 | ) PURE; 313 | 314 | STDMETHOD_(BOOL, bDevSpecificRead) 315 | ( 316 | THIS_ 317 | ) PURE; 318 | 319 | STDMETHOD_(VOID, bDevSpecificWrite) 320 | ( 321 | THIS_ 322 | _In_ BOOL bDevSpecific 323 | ); 324 | 325 | STDMETHOD_(INT, iDevSpecificRead) 326 | ( 327 | THIS_ 328 | ) PURE; 329 | 330 | STDMETHOD_(VOID, iDevSpecificWrite) 331 | ( 332 | THIS_ 333 | _In_ INT iDevSpecific 334 | ); 335 | 336 | STDMETHOD_(UINT, uiDevSpecificRead) 337 | ( 338 | THIS_ 339 | ) PURE; 340 | 341 | STDMETHOD_(VOID, uiDevSpecificWrite) 342 | ( 343 | THIS_ 344 | _In_ UINT uiDevSpecific 345 | ); 346 | 347 | STDMETHOD_(ULONG, MixerMuxRead) 348 | ( 349 | THIS 350 | ); 351 | 352 | STDMETHOD_(VOID, MixerMuxWrite) 353 | ( 354 | THIS_ 355 | _In_ ULONG Index 356 | ); 357 | 358 | STDMETHOD_(LONG, MixerPeakMeterRead) 359 | ( 360 | THIS_ 361 | _In_ ULONG Index, 362 | _In_ ULONG Channel 363 | ) PURE; 364 | 365 | STDMETHOD_(VOID, MixerReset) 366 | ( 367 | THIS 368 | ) PURE; 369 | 370 | STDMETHOD_(NTSTATUS, WriteEtwEvent) 371 | ( 372 | THIS_ 373 | _In_ EPcMiniportEngineEvent miniportEventType, 374 | _In_ ULONGLONG ullData1, 375 | _In_ ULONGLONG ullData2, 376 | _In_ ULONGLONG ullData3, 377 | _In_ ULONGLONG ullData4 378 | ) PURE; 379 | 380 | STDMETHOD_(VOID, SetEtwHelper) 381 | ( 382 | THIS_ 383 | PPORTCLSETWHELPER _pPortClsEtwHelper 384 | ) PURE; 385 | 386 | STDMETHOD_(NTSTATUS, InstallSubdevice) 387 | ( 388 | _In_opt_ PIRP Irp, 389 | _In_ PWSTR Name, 390 | _In_opt_ PWSTR TemplateName, 391 | _In_ REFGUID PortClassId, 392 | _In_ REFGUID MiniportClassId, 393 | _In_opt_ PFNCREATEMINIPORT MiniportCreate, 394 | _In_ ULONG cPropertyCount, 395 | _In_reads_opt_(cPropertyCount) const CSAUDIOACP3X_DEVPROPERTY * pProperties, 396 | _In_opt_ PVOID DeviceContext, 397 | _In_ PENDPOINT_MINIPAIR MiniportPair, 398 | _In_opt_ PRESOURCELIST ResourceList, 399 | _In_ REFGUID PortInterfaceId, 400 | _Out_opt_ PUNKNOWN * OutPortInterface, 401 | _Out_opt_ PUNKNOWN * OutPortUnknown, 402 | _Out_opt_ PUNKNOWN * OutMiniportUnknown 403 | ); 404 | 405 | STDMETHOD_(NTSTATUS, UnregisterSubdevice) 406 | ( 407 | THIS_ 408 | _In_opt_ PUNKNOWN UnknownPort 409 | ); 410 | 411 | STDMETHOD_(NTSTATUS, ConnectTopologies) 412 | ( 413 | THIS_ 414 | _In_ PUNKNOWN UnknownTopology, 415 | _In_ PUNKNOWN UnknownWave, 416 | _In_ PHYSICALCONNECTIONTABLE* PhysicalConnections, 417 | _In_ ULONG PhysicalConnectionCount 418 | ); 419 | 420 | STDMETHOD_(NTSTATUS, DisconnectTopologies) 421 | ( 422 | THIS_ 423 | _In_ PUNKNOWN UnknownTopology, 424 | _In_ PUNKNOWN UnknownWave, 425 | _In_ PHYSICALCONNECTIONTABLE* PhysicalConnections, 426 | _In_ ULONG PhysicalConnectionCount 427 | ); 428 | 429 | STDMETHOD_(NTSTATUS, InstallEndpointFilters) 430 | ( 431 | THIS_ 432 | _In_opt_ PIRP Irp, 433 | _In_ PENDPOINT_MINIPAIR MiniportPair, 434 | _In_opt_ PVOID DeviceContext, 435 | _Out_opt_ PUNKNOWN * UnknownTopology, 436 | _Out_opt_ PUNKNOWN * UnknownWave, 437 | _Out_opt_ PUNKNOWN * UnknownMiniportTopology, 438 | _Out_opt_ PUNKNOWN * UnknownMiniportWave 439 | ); 440 | 441 | STDMETHOD_(NTSTATUS, RemoveEndpointFilters) 442 | ( 443 | THIS_ 444 | _In_ PENDPOINT_MINIPAIR MiniportPair, 445 | _In_opt_ PUNKNOWN UnknownTopology, 446 | _In_opt_ PUNKNOWN UnknownWave 447 | ); 448 | 449 | STDMETHOD_(NTSTATUS, GetFilters) 450 | ( 451 | THIS_ 452 | _In_ PENDPOINT_MINIPAIR MiniportPair, 453 | _Out_opt_ PUNKNOWN *UnknownTopologyPort, 454 | _Out_opt_ PUNKNOWN *UnknownTopologyMiniport, 455 | _Out_opt_ PUNKNOWN *UnknownWavePort, 456 | _Out_opt_ PUNKNOWN *UnknownWaveMiniport 457 | ); 458 | 459 | STDMETHOD_(NTSTATUS, SetIdlePowerManagement) 460 | ( 461 | THIS_ 462 | _In_ PENDPOINT_MINIPAIR MiniportPair, 463 | _In_ BOOL bEnable 464 | ); 465 | 466 | STDMETHOD_(VOID, Cleanup)(); 467 | 468 | }; 469 | 470 | typedef IAdapterCommon *PADAPTERCOMMON; 471 | 472 | //============================================================================= 473 | // Function Prototypes 474 | //============================================================================= 475 | NTSTATUS 476 | NewAdapterCommon 477 | ( 478 | _Out_ PUNKNOWN * Unknown, 479 | _In_ REFCLSID, 480 | _In_opt_ PUNKNOWN UnknownOuter, 481 | _In_ POOL_TYPE PoolType 482 | ); 483 | 484 | #endif //_CSAUDIOACP3X_COMMON_H_ 485 | --------------------------------------------------------------------------------