summaryrefslogtreecommitdiff
path: root/audio/sysvad/EndpointsCommon/mintopo.h
blob: f0bae44d3274915a762c380852fd51ba4353d059 (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

/*++

Copyright (c) Microsoft Corporation All Rights Reserved

Module Name:

    minitopo.h

Abstract:

    Declaration of topology miniport.

--*/

#ifndef _SYSVAD_MINTOPO_H_
#define _SYSVAD_MINTOPO_H_

#include "basetopo.h"

//=============================================================================
// Classes
//=============================================================================

///////////////////////////////////////////////////////////////////////////////
// CMiniportTopology 
//   

#pragma code_seg()
class CMiniportTopology : 
    public CMiniportTopologySYSVAD,
    public IMiniportTopology,
    public CUnknown
{
  private:
    eDeviceType             m_DeviceType;

    typedef struct
    {
        AUDIOPOSTURE_ORIENTATION    Orientation;
    }SYSVAD_AUDIOPOSTURE;

    // Assuming that Each filter will have only one endpoint supporting posture
    SYSVAD_AUDIOPOSTURE m_PostureCache;

    AUDIORESOURCEMANAGEMENT_RESOURCEGROUP   m_ResourceGroup {0};

    union {
        PVOID               m_DeviceContext;
#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND)
        PSIDEBANDDEVICECOMMON m_pSidebandDevice;
#endif // defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND)
    };

public:
    DECLARE_STD_UNKNOWN();
    CMiniportTopology
    (
        _In_opt_    PUNKNOWN                UnknownOuter,
        _In_        PCFILTER_DESCRIPTOR    *FilterDesc,
        _In_        USHORT                  DeviceMaxChannels,
        _In_        eDeviceType             DeviceType, 
        _In_opt_    PVOID                   DeviceContext
    )
    : CUnknown(UnknownOuter),
      CMiniportTopologySYSVAD(FilterDesc, DeviceMaxChannels),
      m_DeviceType(DeviceType),
      m_DeviceContext(DeviceContext)
    {
        m_PostureCache.Orientation = AUDIOPOSTURE_ORIENTATION_NOTROTATED;  

#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND)
        if (IsSidebandDevice())
        {
            if (m_pSidebandDevice != NULL)
            {
                // This ref is released on dtor.
                m_pSidebandDevice->AddRef(); // strong ref.
            }
        }
#endif // defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND)
    }

    ~CMiniportTopology();

    IMP_IMiniportTopology;

    NTSTATUS PropertyHandlerJackDescription
    (
        _In_        PPCPROPERTY_REQUEST                         PropertyRequest,
        _In_        ULONG                                       cJackDescriptions,
        _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION       *JackDescriptions
    );

    NTSTATUS PropertyHandlerJackDescription2
    ( 
        _In_        PPCPROPERTY_REQUEST                         PropertyRequest,
        _In_        ULONG                                       cJackDescriptions,
        _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION       *JackDescriptions,
        _In_        DWORD                                       JackCapabilities
    );

    NTSTATUS PropertyHandlerJackDescription3
    ( 
        _In_        PPCPROPERTY_REQUEST                         PropertyRequest,
        _In_        ULONG                                       cJackDescriptions,
        _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION       *JackDescriptions,
        _In_        ULONG                                       ConfigId
    );

    NTSTATUS PropertyHandlerAudioResourceGroup
    (
        _In_        PPCPROPERTY_REQUEST         PropertyRequest
    );

    NTSTATUS PropertyHandler_SetAudioResourceGroup
    (
        _In_        PPCPROPERTY_REQUEST         PropertyRequest
    );

    NTSTATUS PropertyHandlerAudioPostureOrientation
    ( 
        _In_        PPCPROPERTY_REQUEST                                         PropertyRequest,
        _In_        ULONG                                                       cAudioPostureInfos,
        _In_reads_(cAudioPostureInfos) PSYSVAD_AUDIOPOSTURE_INFO                *AudioPostureInfos
    );

    NTSTATUS PropertyHandler_AudioPostureOrientationBasicSupport
    (
        _In_ PPCPROPERTY_REQUEST    PropertyRequest
    );

    NTSTATUS PropertyHandler_SetAudioPostureOrientation
    (
        _In_ PPCPROPERTY_REQUEST                    PropertyRequest
    );
    
#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND)
    BOOL IsSidebandDevice()
    {
        return (m_DeviceType == eBthHfpMicDevice ||
                m_DeviceType == eBthHfpSpeakerDevice ||
                m_DeviceType == eUsbHsMicDevice ||
                m_DeviceType == eUsbHsSpeakerDevice ||
                m_DeviceType == eA2dpHpSpeakerDevice) ? TRUE : FALSE;
    }

    // Returns a weak ref to the Bluetooth HFP device.
    PSIDEBANDDEVICECOMMON GetSidebandDevice() 
    {
        PSIDEBANDDEVICECOMMON sidebandDevice = NULL;
        
        if (IsSidebandDevice())
        {
            if (m_pSidebandDevice != NULL)
            {
                sidebandDevice = m_pSidebandDevice;
            }
        }

        return sidebandDevice;
    }

    static
    VOID
    EvtSpeakerVolumeHandler
    (
        _In_opt_    PVOID   Context
    );

    static
    VOID
    EvtSpeakerConnectionStatusHandler
    (
        _In_opt_    PVOID   Context
    );
    
    static
    VOID
    EvtMicVolumeHandler
    (
        _In_opt_    PVOID   Context
    );

    static
    VOID
    EvtMicConnectionStatusHandler
    (
        _In_opt_    PVOID   Context
    );
#endif // defined(SYSVAD_BTH_BYPASS) defined(SYSVAD_USB_SIDEBAND)

    PVOID GetDeviceContext() { return m_DeviceContext;  }

    friend NTSTATUS PropertyHandler_BthHfpVolumeLevel_BasicSupport(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
    friend NTSTATUS PropertyHandler_BthHfpJackContainerId(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest,
        _In_ ULONG                    cJackDescriptions,
        _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION * JackDescriptions);
    friend NTSTATUS PropertyHandler_BthHfpMicVolumeLevel(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
    friend NTSTATUS PropertyHandler_BthHfpSpeakerVolumeLevel(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
    friend NTSTATUS PropertyHandler_UsbHsJackContainerId(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest,
        _In_ ULONG                    cJackDescriptions,
        _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION * JackDescriptions);
    friend NTSTATUS PropertyHandler_UsbHsVolumeLevel_BasicSupport(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
    friend NTSTATUS PropertyHandler_UsbHsMicVolumeLevel(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
    friend NTSTATUS PropertyHandler_UsbHsMute_BasicSupport(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
    friend NTSTATUS PropertyHandler_UsbHsMicMute(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
    friend NTSTATUS PropertyHandler_A2dpHpJackContainerId(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest,
        _In_ ULONG                    cJackDescriptions,
        _In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION * JackDescriptions);
    friend NTSTATUS PropertyHandler_A2dpHpVolumeLevel_BasicSupport(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
    friend NTSTATUS PropertyHandler_A2dpHpMute_BasicSupport(
        _In_ PPCPROPERTY_REQUEST      PropertyRequest);
};

typedef CMiniportTopology *PCMiniportTopology;

NTSTATUS CMiniportTopology_EventHandler_JackState
(
    _In_  PPCEVENT_REQUEST EventRequest
);

#endif // _SYSVAD_MINTOPO_H_