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

/*++

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 
//   

class CMiniportTopology : 
    public CMiniportTopologySYSVAD,
    public IMiniportTopology,
    public CUnknown
{
  private:
    eDeviceType             m_DeviceType;
    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)
    {
#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
    );
    
#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_