summaryrefslogtreecommitdiff
path: root/audio/sysvad/common.h
blob: 17e8ebca54798d4053ed2ad163e2d550479379a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
/*++

Copyright (c) Microsoft Corporation All Rights Reserved

Module Name:

    Common.h

Abstract:
    
    CAdapterCommon class declaration.

--*/

#ifndef _SYSVAD_COMMON_H_
#define _SYSVAD_COMMON_H_

#define HNSTIME_PER_MILLISECOND 10000

//=============================================================================
// Macros
//=============================================================================

#define UNREFERENCED_VAR(status) \
    status = status 

//-------------------------------------------------------------------------
// Description:
//
// jump to the given label.
//
// Parameters:
//
//      label - [in] label to jump if condition is met
//
#define JUMP(label)                                             \
        goto label;  

//-------------------------------------------------------------------------
// Description:
//
// If the condition evaluates to TRUE, jump to the given label.
//
// Parameters:
//
//      condition - [in] Code that fits in if statement
//      label - [in] label to jump if condition is met
//
#define IF_TRUE_JUMP(condition, label)                          \
    if (condition)                                               \
    {                                                           \
        goto label;                                             \
    }

//-------------------------------------------------------------------------
// Description:
//
// If the condition evaluates to TRUE, perform the given statement
// then jump to the given label.
//
// Parameters:
//
//      condition - [in] Code that fits in if statement
//      action - [in] action to perform in body of if statement
//      label - [in] label to jump if condition is met
//
#define IF_TRUE_ACTION_JUMP(condition, action, label)           \
    if (condition)                                               \
    {                                                           \
        action;                                                 \
        goto label;                                             \
    }
    
//-------------------------------------------------------------------------
// Description:
//
// If the ntStatus is not NT_SUCCESS, perform the given statement then jump to
// the given label.
//
// Parameters:
//
//      ntStatus - [in] Value to check
//      action - [in] action to perform in body of if statement
//      label - [in] label to jump if condition is met
//
#define IF_FAILED_ACTION_JUMP(ntStatus, action, label)          \
        if (!NT_SUCCESS(ntStatus))                              \
        {                                                       \
            action;                                             \
            goto label;                                         \
        }
    
//-------------------------------------------------------------------------
// Description:
//
// If the ntStatus passed is not NT_SUCCESS, jump to the given label.
//
// Parameters:
//
//      ntStatus - [in] Value to check
//      label - [in] label to jump if condition is met
//
#define IF_FAILED_JUMP(ntStatus, label)                         \
    if (!NT_SUCCESS(ntStatus))                                   \
    {                                                           \
        goto label;                                             \
    }

#define SAFE_RELEASE(p) {if (p) { (p)->Release(); (p) = nullptr; } }
#define SAFE_DELETE_PTR_WITH_TAG(ptr, tag) if(ptr) { ExFreePoolWithTag((ptr), tag); (ptr) = NULL; }

// JACKDESC_RGB(r, g, b) 
#define JACKDESC_RGB(r, g, b) \
    ((COLORREF)((r << 16) | (g << 8) | (b)))

// Min/Max defines.
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MINWAVERT_POOLTAG           'RWNM'
#define MINTOPORT_POOLTAG           'RTNM'
#define MINADAPTER_POOLTAG          'uAyS'
#define USBSIDEBANDTEST_POOLTAG01   '1AyS'
#define USBSIDEBANDTEST_POOLTAG02   '2AyS'
#define USBSIDEBANDTEST_POOLTAG03   '3AyS'
#define USBSIDEBANDTEST_POOLTAG04   '4AyS'
#define USBSIDEBANDTEST_POOLTAG05   '5AyS'
#define USBSIDEBANDTEST_POOLTAG06   '6AyS'
#define USBSIDEBANDTEST_POOLTAG07   '7AyS'
#define USBSIDEBANDTEST_POOLTAG08   '8AyS'
#define USBSIDEBANDTEST_POOLTAG09   '9AyS'
#define USBSIDEBANDTEST_POOLTAG010  'aAyS'
#define USBSIDEBANDTEST_POOLTAG011  'bAyS'
#define USBSIDEBANDTEST_POOLTAG012  'cAyS'
#define USBSIDEBANDTEST_POOLTAG013  'dAyS'
#define USBSIDEBANDTEST_POOLTAG014  'eAyS'
#define USBSIDEBANDTEST_POOLTAG015  'fAyS'
#define USBSIDEBANDTEST_POOLTAG016  'gAyS'
#define A2DPSIDEBANDTEST_POOLTAG01  'hAyS'
#define A2DPSIDEBANDTEST_POOLTAG02  'iAyS'
#define A2DPSIDEBANDTEST_POOLTAG03  'jAyS'
#define A2DPSIDEBANDTEST_POOLTAG04  'kAyS'
#define A2DPSIDEBANDTEST_POOLTAG05  'lAyS'
#define A2DPSIDEBANDTEST_POOLTAG06  'mAyS'
#define A2DPSIDEBANDTEST_POOLTAG07  'nAyS'

typedef enum
{
    eSpeakerDevice = 0,
    eSpeakerHpDevice,
    eHdmiRenderDevice,
    eMicInDevice,
    eMicArrayDevice1,
    eMicArrayDevice2,
    eMicArrayDevice3,
    eBthHfpSpeakerDevice,
    eBthHfpMicDevice,
    eCellularDevice,
    eHandsetSpeakerDevice,
    eHandsetMicDevice,
    eSpeakerHsDevice,
    eMicHsDevice,
    eFmRxDevice,
    eSpdifRenderDevice,
    eUsbHsSpeakerDevice,
    eUsbHsMicDevice,
    eA2dpHpSpeakerDevice,
    eMaxDeviceType
    
} eDeviceType;

//
// Signal processing modes and default formats structs.
//
typedef struct _MODE_AND_DEFAULT_FORMAT {
    GUID            Mode;
    KSDATAFORMAT*   DefaultFormat;
} MODE_AND_DEFAULT_FORMAT, *PMODE_AND_DEFAULT_FORMAT;

//
// Enumeration of the various types of pins implemented in this driver.
//
typedef enum
{
    NoPin,
    BridgePin,
    SystemRenderPin,
    OffloadRenderPin,
    RenderLoopbackPin,
    SystemCapturePin,
    KeywordCapturePin,
    TelephonyBidiPin,
} PINTYPE;

//
// PIN_DEVICE_FORMATS_AND_MODES
//
//  Used to specify a pin's type (e.g. system, offload, etc.), formats, and
//  modes. Conceptually serves similar purpose as the PCPIN_DESCRIPTOR to
//  define a pin, but is more specific to driver implementation.
//
//  Arrays of these structures follow the same order as the filter's
//  pin descriptor array so that KS pin IDs can serve as an index.
//
typedef struct _PIN_DEVICE_FORMATS_AND_MODES
{
    PINTYPE                             PinType;

    KSDATAFORMAT_WAVEFORMATEXTENSIBLE * WaveFormats;
    ULONG                               WaveFormatsCount;
    
    MODE_AND_DEFAULT_FORMAT *           ModeAndDefaultFormat;
    ULONG                               ModeAndDefaultFormatCount;

} PIN_DEVICE_FORMATS_AND_MODES, *PPIN_DEVICE_FORMATS_AND_MODES;

typedef struct _SYSVAD_AUDIOPOSTURE_INFO
{
    BOOL OrientationSupported;
} SYSVAD_AUDIOPOSTURE_INFO, *PSYSVAD_AUDIOPOSTURE_INFO;

//
// Parameter module handler function prototypes.
//
static const GUID NULL_GUID = 
{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};

static const GUID MODULETYPE_HWEFFECT =
{0x2608993c,0x361e,0x488c,{0xa0,0xbc,0x8f,0x3d,0xe7,0xba,0x12,0xb4}};

//
// Forward declaration.
//
struct AUDIOMODULE_DESCRIPTOR;
typedef AUDIOMODULE_DESCRIPTOR *PAUDIOMODULE_DESCRIPTOR;

typedef struct _AUDIOMODULE_PARAMETER_INFO
{
    USHORT      AccessFlags;        // get/set/basic-support attributes.
    USHORT      Flags;        
    ULONG       Size;
    DWORD       VtType;
    PVOID       ValidSet;
    ULONG       ValidSetCount;
} AUDIOMODULE_PARAMETER_INFO, *PAUDIOMODULE_PARAMETER_INFO;

#define AUDIOMODULE_PARAMETER_FLAG_CHANGE_NOTIFICATION  0x00000001

//
// Module callbacks.
//
typedef
NTSTATUS
(*FN_AUDIOMODULE_INIT_CLASS)
(
    _In_  const AUDIOMODULE_DESCRIPTOR * Module,
    _Inout_opt_ PVOID           Context,
    _In_        size_t          Size,
    _In_        KSAUDIOMODULE_NOTIFICATION * NotificationHeader,
    _In_opt_    PPORTCLSNOTIFICATIONS PortNotifications
);

typedef
NTSTATUS
(*FN_AUDIOMODULE_INIT_INSTANCE)
(
    _In_  const AUDIOMODULE_DESCRIPTOR * Module,
    _In_opt_    PVOID           TemplateContext,
    _Inout_opt_ PVOID           Context,
    _In_        size_t          Size,
    _In_        ULONG           InstanceId
);

typedef
VOID
(*FN_AUDIOMODULE_CLEANUP)
(
    _In_        PVOID           Context
);

typedef
NTSTATUS
(*FN_AUDIOMODULE_HANDLER)
(
    _Inout_opt_                          PVOID   Context,
    _In_reads_bytes_(InBufferCb)         PVOID   InBuffer,
    _In_                                 ULONG   InBufferCb,
    _Out_writes_bytes_opt_(*OutBufferCb) PVOID   OutBuffer,
    _Inout_                              ULONG * OutBufferCb 
);

//
// Module description.
//
struct AUDIOMODULE_DESCRIPTOR
{
    const GUID *                    ClassId; 
    const GUID *                    ProcessingMode;
    WCHAR                           Name[AUDIOMODULE_MAX_NAME_CCH_SIZE];
    ULONG                           InstanceId;
    ULONG                           VersionMajor;
    ULONG                           VersionMinor;
    ULONG                           Flags;
    size_t                          ContextSize;
    FN_AUDIOMODULE_INIT_CLASS       InitClass;
    FN_AUDIOMODULE_INIT_INSTANCE    InitInstance;
    FN_AUDIOMODULE_CLEANUP          Cleanup;
    FN_AUDIOMODULE_HANDLER          Handler;
};

#define AUDIOMODULE_DESCRIPTOR_FLAG_NONE        0x00000000

//
// Audio module instance defintion.
// This sample driver generates an instance id by combinding the
// configuration set # for a class module id with the instance of that 
// configuration. Real driver should use a more robust scheme, such as
// an indirect mapping from/to an instance id to/from a configuration set
// + location in the pipeline + any other info the driver needs.
//
#define AUDIOMODULE_CLASS_CFG_ID_MASK           0xFF
#define AUDIOMODULE_CLASS_CFG_INSTANCE_ID_MASK  0xFFFFFF

#define AUDIOMODULE_INSTANCE_ID(ClassCfgId, ClassCfgInstanceId) \
    ((ULONG(ClassCfgId & AUDIOMODULE_CLASS_CFG_ID_MASK) << 24) | \
     (ULONG(ClassCfgInstanceId & AUDIOMODULE_CLASS_CFG_INSTANCE_ID_MASK)))

#define AUDIOMODULE_GET_CLASSCFGID(InstanceId) \
    (ULONG(InstanceId) >> 24 & AUDIOMODULE_CLASS_CFG_ID_MASK)

//
// Used to track run-time audio module changes.
//
struct AUDIOMODULE
{
    const AUDIOMODULE_DESCRIPTOR *  Descriptor;
    PVOID                           Context;
    ULONG                           InstanceId;
    ULONG                           NextCfgInstanceId;  // used by filter modules
    BOOL                            Enabled;
};

// forward declaration.
typedef struct _ENDPOINT_MINIPAIR *PENDPOINT_MINIPAIR;

// both wave & topology miniport create function prototypes have this form:
typedef HRESULT (*PFNCREATEMINIPORT)(
    _Out_           PUNKNOWN                              * Unknown,
    _In_            REFCLSID,
    _In_opt_        PUNKNOWN                                UnknownOuter,
    _In_            POOL_FLAGS                              PoolFlags, 
    _In_            PUNKNOWN                                UnknownAdapter,
    _In_opt_        PVOID                                   DeviceContext,
    _In_            PENDPOINT_MINIPAIR                      MiniportPair
);

//=============================================================================
//
//=============================================================================
typedef struct _SYSVAD_DEVPROPERTY {
    const DEVPROPKEY   *PropertyKey;
    DEVPROPTYPE Type;
    ULONG BufferSize;
    __field_bcount_opt(BufferSize) PVOID Buffer;
} SYSVAD_DEVPROPERTY, PSYSVAD_DEVPROPERTY;

#define ENDPOINT_NO_FLAGS                       0x00000000
#define ENDPOINT_OFFLOAD_SUPPORTED              0x00000001
#define ENDPOINT_LOOPBACK_SUPPORTED             0x00000002
#define ENDPOINT_SOUNDDETECTOR_SUPPORTED        0x00000004
#define ENDPOINT_CELLULAR_PROVIDER1             0x00000008
#define ENDPOINT_CELLULAR_PROVIDER2             0x00000010

//
// Endpoint miniport pair (wave/topology) descriptor.
//
typedef struct _ENDPOINT_MINIPAIR 
{
    eDeviceType                     DeviceType;

    // Topology miniport.
    PWSTR                           TopoName;               // make sure this or the template name matches with SYSVAD.<TopoName>.szPname in the inf's [Strings] section
    PWSTR                           TemplateTopoName;       // optional template name
    PFNCREATEMINIPORT               TopoCreateCallback;
    PCFILTER_DESCRIPTOR*            TopoDescriptor;
    ULONG                           TopoInterfacePropertyCount;
    const SYSVAD_DEVPROPERTY*       TopoInterfaceProperties;

    // Wave RT miniport.
    PWSTR                           WaveName;               // make sure this or the template name matches with SYSVAD.<WaveName>.szPname in the inf's [Strings] section
    PWSTR                           TemplateWaveName;       // optional template name
    PFNCREATEMINIPORT               WaveCreateCallback;
    PCFILTER_DESCRIPTOR*            WaveDescriptor;
    ULONG                           WaveInterfacePropertyCount;
    const SYSVAD_DEVPROPERTY*       WaveInterfaceProperties;

    USHORT                          DeviceMaxChannels;
    PIN_DEVICE_FORMATS_AND_MODES*   PinDeviceFormatsAndModes;
    ULONG                           PinDeviceFormatsAndModesCount;

    // Miniport physical connections.
    PHYSICALCONNECTIONTABLE*        PhysicalConnections;
    ULONG                           PhysicalConnectionCount;

    // General endpoint flags (one of more ENDPOINT_<flag-type>, see above)
    ULONG                           DeviceFlags;

    // Static module list description.
    AUDIOMODULE_DESCRIPTOR *        ModuleList;
    ULONG                           ModuleListCount;
    const GUID *                    ModuleNotificationDeviceId;
} ENDPOINT_MINIPAIR;

//=============================================================================
// Defines
//=============================================================================

DEFINE_GUID(IID_IAdapterCommon,
0x7eda2950, 0xbf9f, 0x11d0, 0x87, 0x1f, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);

// {4E1E5697-4D04-4438-A913-B0EEE03732BA}
DEFINE_GUID(IID_IMiniportChange, 
0x4e1e5697, 0x4d04, 0x4438, 0xa9, 0x13, 0xb0, 0xee, 0xe0, 0x37, 0x32, 0xba);

//=============================================================================
// Interfaces
//=============================================================================

///////////////////////////////////////////////////////////////////////////////
// IID_IMiniportChange
//
DECLARE_INTERFACE_(IMiniportChange, IUnknown)
{
    STDMETHOD_(NTSTATUS, NotifyEndpointPair) 
    ( 
        THIS_
        _In_ WCHAR              *RenderEndpointTopoName,
        _In_ ULONG              RenderEndpointNameLen,
        _In_ ULONG              RenderPinId,
        _In_ WCHAR              *CaptureEndpointTopoName,
        _In_ ULONG              CaptureEndpointNameLen,
        _In_ ULONG              CapturePinId
    ) PURE;
};

///////////////////////////////////////////////////////////////////////////////
// IAdapterCommon
//
DECLARE_INTERFACE_(IAdapterCommon, IUnknown)
{
    STDMETHOD_(NTSTATUS,        Init) 
    ( 
        THIS_
        _In_  PDEVICE_OBJECT      DeviceObject 
    ) PURE;

    STDMETHOD_(PDEVICE_OBJECT,  GetDeviceObject)
    (
        THIS
    ) PURE;
    
    STDMETHOD_(PDEVICE_OBJECT,  GetPhysicalDeviceObject)
    (
        THIS
    ) PURE;

    STDMETHOD_(WDFDEVICE,       GetWdfDevice)
    (
        THIS
    ) PURE;

    STDMETHOD_(VOID,            SetWaveServiceGroup) 
    ( 
        THIS_
        _In_ PSERVICEGROUP        ServiceGroup 
    ) PURE;

    STDMETHOD_(BOOL,            bDevSpecificRead)
    (
        THIS_
    ) PURE;

    STDMETHOD_(VOID,            bDevSpecificWrite)
    (
        THIS_
        _In_  BOOL                bDevSpecific
    );

    STDMETHOD_(INT,             iDevSpecificRead)
    (
        THIS_
    ) PURE;

    STDMETHOD_(VOID,            iDevSpecificWrite)
    (
        THIS_
        _In_  INT                 iDevSpecific
    );

    STDMETHOD_(UINT,            uiDevSpecificRead)
    (
        THIS_
    ) PURE;

    STDMETHOD_(VOID,            uiDevSpecificWrite)
    (
        THIS_
        _In_  UINT                uiDevSpecific
    );

    STDMETHOD_(BOOL,            MixerMuteRead)
    (
        THIS_
        _In_  ULONG               Index,
        _In_  ULONG               Channel
    ) PURE;

    STDMETHOD_(VOID,            MixerMuteWrite)
    (
        THIS_
        _In_  ULONG               Index,
        _In_  ULONG               Channel,
        _In_  BOOL                Value
    );

    STDMETHOD_(ULONG,           MixerMuxRead)
    (
        THIS
    );

    STDMETHOD_(VOID,            MixerMuxWrite)
    (
        THIS_
        _In_  ULONG               Index
    );

    STDMETHOD_(LONG,            MixerVolumeRead) 
    ( 
        THIS_
        _In_  ULONG               Index,
        _In_  ULONG               Channel
    ) PURE;

    STDMETHOD_(VOID,            MixerVolumeWrite) 
    ( 
        THIS_
        _In_  ULONG               Index,
        _In_  ULONG               Channel,
        _In_  LONG                Value 
    ) PURE;
    
    STDMETHOD_(LONG,            MixerPeakMeterRead) 
    ( 
        THIS_
        _In_  ULONG               Index,
        _In_  ULONG               Channel
    ) PURE;

    STDMETHOD_(VOID,            MixerReset) 
    ( 
        THIS 
    ) PURE;

    STDMETHOD_(NTSTATUS,        WriteEtwEvent) 
    ( 
        THIS_ 
        _In_ EPcMiniportEngineEvent    miniportEventType,
        _In_ ULONGLONG  ullData1,
        _In_ ULONGLONG  ullData2,
        _In_ ULONGLONG  ullData3,
        _In_ ULONGLONG  ullData4
    ) PURE;

    STDMETHOD_(VOID,            SetEtwHelper) 
    ( 
        THIS_
        PPORTCLSETWHELPER _pPortClsEtwHelper
    ) PURE;
    
    STDMETHOD_(NTSTATUS,        InstallSubdevice)
    ( 
        _In_opt_        PIRP                                        Irp,
        _In_            PWSTR                                       Name,
        _In_opt_        PWSTR                                       TemplateName,
        _In_            REFGUID                                     PortClassId,
        _In_            REFGUID                                     MiniportClassId,
        _In_opt_        PFNCREATEMINIPORT                           MiniportCreate,
        _In_            ULONG                                       cPropertyCount,
        _In_reads_opt_(cPropertyCount) const SYSVAD_DEVPROPERTY   * pProperties,
        _In_opt_        PVOID                                       DeviceContext,
        _In_            PENDPOINT_MINIPAIR                          MiniportPair,
        _In_opt_        PRESOURCELIST                               ResourceList,
        _In_            REFGUID                                     PortInterfaceId,
        _Out_opt_       PUNKNOWN                                  * OutPortInterface,
        _Out_opt_       PUNKNOWN                                  * OutPortUnknown,
        _Out_opt_       PUNKNOWN                                  * OutMiniportUnknown
    );    

    STDMETHOD_(NTSTATUS,        UnregisterSubdevice)
    (
        THIS_
        _In_opt_   PUNKNOWN     UnknownPort
    );

    STDMETHOD_(NTSTATUS,        ConnectTopologies)
    (
        THIS_
        _In_ PUNKNOWN                   UnknownTopology,
        _In_ PUNKNOWN                   UnknownWave,
        _In_ PHYSICALCONNECTIONTABLE*   PhysicalConnections,
        _In_ ULONG                      PhysicalConnectionCount
    );

    STDMETHOD_(NTSTATUS,        DisconnectTopologies)
    (
        THIS_
        _In_ PUNKNOWN                   UnknownTopology,
        _In_ PUNKNOWN                   UnknownWave,
        _In_ PHYSICALCONNECTIONTABLE*   PhysicalConnections,
        _In_ ULONG                      PhysicalConnectionCount
    );

    STDMETHOD_(NTSTATUS,        InstallEndpointFilters)
    (
        THIS_
        _In_opt_    PIRP                Irp, 
        _In_        PENDPOINT_MINIPAIR  MiniportPair,
        _In_opt_    PVOID               DeviceContext,
        _Out_opt_   PUNKNOWN *          UnknownTopology,
        _Out_opt_   PUNKNOWN *          UnknownWave,
        _Out_opt_   PUNKNOWN *          UnknownMiniportTopology,
        _Out_opt_   PUNKNOWN *          UnknownMiniportWave
    );

    STDMETHOD_(NTSTATUS,        RemoveEndpointFilters)
    (
        THIS_
        _In_        PENDPOINT_MINIPAIR  MiniportPair,
        _In_opt_    PUNKNOWN            UnknownTopology,
        _In_opt_    PUNKNOWN            UnknownWave
    );

    STDMETHOD_(NTSTATUS,        GetFilters)
    (
        THIS_
        _In_        PENDPOINT_MINIPAIR  MiniportPair,
        _Out_opt_   PUNKNOWN            *UnknownTopologyPort,
        _Out_opt_   PUNKNOWN            *UnknownTopologyMiniport,
        _Out_opt_   PUNKNOWN            *UnknownWavePort,
        _Out_opt_   PUNKNOWN            *UnknownWaveMiniport
    );

    STDMETHOD_(NTSTATUS,        SetIdlePowerManagement)
    (
        THIS_
        _In_        PENDPOINT_MINIPAIR  MiniportPair,
        _In_        BOOL                bEnable
    );

#ifdef SYSVAD_BTH_BYPASS
    STDMETHOD_(NTSTATUS,        InitBthScoBypass)();
       
#endif // SYSVAD_BTH_BYPASS

#ifdef SYSVAD_USB_SIDEBAND
    STDMETHOD_(NTSTATUS,        InitUsbSideband)();

    STDMETHOD_(NTSTATUS,        AddDeviceAsPowerDependency)
    (
        _In_ PDEVICE_OBJECT pdo
    );

    STDMETHOD_(NTSTATUS,        RemoveDeviceAsPowerDependency)
    (
        _In_ PDEVICE_OBJECT pdo
    );

#endif // SYSVAD_USB_SIDEBAND

#ifdef SYSVAD_A2DP_SIDEBAND
    STDMETHOD_(NTSTATUS,        InitA2dpSideband)();

#endif // SYSVAD_A2DP_SIDEBAND

    STDMETHOD_(VOID, Cleanup)();

#ifdef SYSVAD_USB_SIDEBAND
    STDMETHOD_(NTSTATUS, UpdatePowerRelations)(_In_ PIRP Irp);
#endif // SYSVAD_USB_SIDEBAND

    STDMETHOD_(NTSTATUS, NotifyEndpointPair) 
    ( 
        THIS_
        _In_ WCHAR  *RenderEndpointTopoName,
        _In_ ULONG  RenderEndpointNameLen,
        _In_ ULONG  RenderPinId,
        _In_ WCHAR  *CaptureEndpointTopoName,
        _In_ ULONG  CaptureEndpointNameLen,
        _In_ ULONG  CapturePinId
    ) PURE;
};

typedef IAdapterCommon *PADAPTERCOMMON;
typedef IMiniportChange *PMINIPORTCHANGE;

//=============================================================================
// Function Prototypes
//=============================================================================
NTSTATUS
NewAdapterCommon
( 
    _Out_       PUNKNOWN *              Unknown,
    _In_        REFCLSID,
    _In_opt_    PUNKNOWN                UnknownOuter,
    _In_        POOL_FLAGS              PoolFlags
);


#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND)

// Event callback definition.
typedef VOID (*PFNEVENTNOTIFICATION)(
    _In_opt_    PVOID   Context
);

DEFINE_GUID(IID_IBthHfpDeviceCommon,
    0x576b824a, 0x5248, 0x47b1, 0x82, 0xc5, 0xe4, 0x7b, 0xa7, 0xe2, 0xaf, 0x2b);

DEFINE_GUID(IID_IUsbHsDeviceCommon,
    0xb57b5547, 0x63f, 0x4a58, 0xb3, 0x7, 0x90, 0xb2, 0xfc, 0x6c, 0x32, 0xdb);

DEFINE_GUID(IID_IA2dpHpDeviceCommon,
    0xe1a6f128, 0x905, 0x4c18, 0xb4, 0x84, 0xc2, 0xca, 0x45, 0xb1, 0x57, 0x6d);



//=============================================================================
// Interfaces
//=============================================================================

///////////////////////////////////////////////////////////////////////////////
// ISidebandDeviceCommon
//
DECLARE_INTERFACE_(ISidebandDeviceCommon, IUnknown)
{
    STDMETHOD_(BOOL,                IsVolumeSupported)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;
    
    STDMETHOD_(PVOID,               GetVolumeSettings)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _Out_       PULONG                  Size 
    ) PURE;

    STDMETHOD_(NTSTATUS,            GetVolume)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _In_        LONG                    Channel,
        _Out_       LONG                    *pVolume
    ) PURE;

    STDMETHOD_(NTSTATUS,            SetVolume)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _In_        LONG                    Channel,
        _In_        LONG                    Volume
    ) PURE;

    STDMETHOD_(BOOL,                IsMuteSupported)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;
    
    STDMETHOD_(PVOID,               GetMuteSettings)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _Out_       PULONG                  Size 
    ) PURE;

    STDMETHOD_(LONG,                GetMute)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _In_        LONG                    Channel
    ) PURE;

    STDMETHOD_(NTSTATUS,            SetMute)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _In_        LONG                    Channel,
        _In_        LONG                    Mute
    ) PURE;

    STDMETHOD_(BOOL,                GetConnectionStatus)
    (
        THIS_
    ) PURE;
    
    STDMETHOD_(NTSTATUS,            Connect)
    (
        THIS_
    ) PURE;

    STDMETHOD_(NTSTATUS,            Disconnect)
    (
        THIS_
    ) PURE;
    
    STDMETHOD_(BOOL,                GetStreamStatus)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;

    STDMETHOD_(NTSTATUS,            StreamOpen)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;

    STDMETHOD_(NTSTATUS,            StreamStart)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;

    STDMETHOD_(NTSTATUS,            StreamSuspend)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;

    STDMETHOD_(NTSTATUS,            StreamClose)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;

    STDMETHOD_(GUID,                GetContainerId)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;

    STDMETHOD_(VOID,                SetVolumeHandler)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _In_opt_    PFNEVENTNOTIFICATION    EventHandler,
        _In_opt_    PVOID                   EventHandlerContext
    ) PURE;

    STDMETHOD_(VOID,                SetMuteHandler)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _In_opt_    PFNEVENTNOTIFICATION    EventHandler,
        _In_opt_    PVOID                   EventHandlerContext
    ) PURE;
    
    STDMETHOD_(VOID,                SetConnectionStatusHandler)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _In_opt_    PFNEVENTNOTIFICATION    EventHandler,
        _In_opt_    PVOID                   EventHandlerContext
    ) PURE;

    STDMETHOD_(VOID,                SetFormatChangeHandler)
    (
        THIS_
        _In_        eDeviceType             deviceType,
        _In_opt_    PFNEVENTNOTIFICATION    EventHandler,
        _In_opt_    PVOID                   EventHandlerContext
    ) PURE;

    STDMETHOD_(PPIN_DEVICE_FORMATS_AND_MODES, GetFormatsAndModes)
    (
        THIS_
        _In_        eDeviceType             deviceType
    ) PURE;

    _IRQL_requires_max_(DISPATCH_LEVEL)
    STDMETHOD_(BOOL,                IsNRECSupported)
    (
        THIS_
    ) PURE;
    
    STDMETHOD_(BOOL,                GetNRECDisableStatus)
    (
        THIS_
    ) PURE;
};
typedef ISidebandDeviceCommon *PSIDEBANDDEVICECOMMON;

#endif // SYSVAD_BTH_BYPASS

#endif  //_SYSVAD_COMMON_H_