1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS BDA Proxy
4 * FILE: dll/directx/bdaplgin/lnbinfo.cpp
5 * PURPOSE: IBDA_LNBInfo interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8 */
9
10 #include "precomp.h"
11
12 #ifndef _MSC_VER
13 const GUID IID_IBDA_LNBInfo = {0x992cf102, 0x49f9, 0x4719, {0xa6, 0x64, 0xc4, 0xf2, 0x3e, 0x24, 0x08, 0xf4}};
14 const GUID KSPROPSETID_BdaLNBInfo = {0x992cf102, 0x49f9, 0x4719, {0xa6, 0x64, 0xc4, 0xf2, 0x3e, 0x24, 0x8, 0xf4}};
15 #endif
16
17 class CBDALNBInfo : public IBDA_LNBInfo
18 {
19 public:
20 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
21
AddRef()22 STDMETHODIMP_(ULONG) AddRef()
23 {
24 InterlockedIncrement(&m_Ref);
25 return m_Ref;
26 }
Release()27 STDMETHODIMP_(ULONG) Release()
28 {
29 InterlockedDecrement(&m_Ref);
30 if (!m_Ref)
31 {
32 delete this;
33 return 0;
34 }
35 return m_Ref;
36 }
37
38 //IBDA_LNBInfo methods
39 HRESULT STDMETHODCALLTYPE put_LocalOscillatorFrequencyLowBand(ULONG ulLOFLow);
40 HRESULT STDMETHODCALLTYPE get_LocalOscillatorFrequencyLowBand(ULONG *pulLOFLow);
41 HRESULT STDMETHODCALLTYPE put_LocalOscillatorFrequencyHighBand(ULONG ulLOFHigh);
42 HRESULT STDMETHODCALLTYPE get_LocalOscillatorFrequencyHighBand(ULONG *pulLOFHigh);
43 HRESULT STDMETHODCALLTYPE put_HighLowSwitchFrequency(ULONG ulSwitchFrequency);
44 HRESULT STDMETHODCALLTYPE get_HighLowSwitchFrequency(ULONG *pulSwitchFrequency);
45
CBDALNBInfo(IKsPropertySet * pProperty,ULONG NodeId)46 CBDALNBInfo(IKsPropertySet *pProperty, ULONG NodeId) : m_Ref(0), m_pProperty(pProperty), m_NodeId(NodeId){};
~CBDALNBInfo()47 ~CBDALNBInfo(){};
48
49 protected:
50 LONG m_Ref;
51 IKsPropertySet * m_pProperty;
52 ULONG m_NodeId;
53 };
54
55 HRESULT
56 STDMETHODCALLTYPE
QueryInterface(IN REFIID refiid,OUT PVOID * Output)57 CBDALNBInfo::QueryInterface(
58 IN REFIID refiid,
59 OUT PVOID* Output)
60 {
61 *Output = NULL;
62
63 if (IsEqualGUID(refiid, IID_IUnknown))
64 {
65 *Output = PVOID(this);
66 reinterpret_cast<IUnknown*>(*Output)->AddRef();
67 return NOERROR;
68 }
69
70 if (IsEqualGUID(refiid, IID_IBDA_LNBInfo))
71 {
72 *Output = (IBDA_LNBInfo*)(this);
73 reinterpret_cast<IBDA_LNBInfo*>(*Output)->AddRef();
74 return NOERROR;
75 }
76
77 #ifdef BDAPLGIN_TRACE
78 WCHAR Buffer[100];
79 LPOLESTR lpstr;
80 StringFromCLSID(refiid, &lpstr);
81 swprintf(Buffer, L"CBDALNBInfo::QueryInterface: NoInterface for %s", lpstr);
82 OutputDebugStringW(Buffer);
83 CoTaskMemFree(lpstr);
84 #endif
85
86 return E_NOINTERFACE;
87 }
88
89 HRESULT
90 STDMETHODCALLTYPE
put_LocalOscillatorFrequencyLowBand(ULONG ulLOFLow)91 CBDALNBInfo::put_LocalOscillatorFrequencyLowBand(ULONG ulLOFLow)
92 {
93 KSP_NODE Node;
94 HRESULT hr;
95
96 // setup request
97 Node.NodeId = m_NodeId;
98 Node.Reserved = 0;
99
100 // perform request
101 hr = m_pProperty->Set(KSPROPSETID_BdaLNBInfo, KSPROPERTY_BDA_LNB_LOF_LOW_BAND, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulLOFLow, sizeof(LONG));
102
103 #ifdef BDAPLGIN_TRACE
104 WCHAR Buffer[100];
105 swprintf(Buffer, L"CBDALNBInfo::put_LocalOscillatorFrequencyLowBand: m_NodeId %lu ulLOFLow %lu hr %lx\n", m_NodeId, ulLOFLow, hr);
106 OutputDebugStringW(Buffer);
107 #endif
108
109 return hr;
110 }
111
112 HRESULT
113 STDMETHODCALLTYPE
get_LocalOscillatorFrequencyLowBand(ULONG * pulLOFLow)114 CBDALNBInfo::get_LocalOscillatorFrequencyLowBand(ULONG *pulLOFLow)
115 {
116 return E_NOINTERFACE;
117 }
118
119 HRESULT
120 STDMETHODCALLTYPE
put_LocalOscillatorFrequencyHighBand(ULONG ulLOFHigh)121 CBDALNBInfo::put_LocalOscillatorFrequencyHighBand(ULONG ulLOFHigh)
122 {
123 KSP_NODE Node;
124 HRESULT hr;
125
126 // setup request
127 Node.NodeId = m_NodeId;
128 Node.Reserved = 0;
129
130 // perform request
131 hr = m_pProperty->Set(KSPROPSETID_BdaLNBInfo, KSPROPERTY_BDA_LNB_LOF_HIGH_BAND, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulLOFHigh, sizeof(ULONG));
132
133 #ifdef BDAPLGIN_TRACE
134 WCHAR Buffer[100];
135 swprintf(Buffer, L"CBDALNBInfo::put_LocalOscillatorFrequencyHighBand: m_NodeId %lu ulLOFHigh %lu hr %lx\n", m_NodeId, ulLOFHigh, hr);
136 OutputDebugStringW(Buffer);
137 #endif
138
139 return hr;
140 }
141
142 HRESULT
143 STDMETHODCALLTYPE
get_LocalOscillatorFrequencyHighBand(ULONG * pulLOFHigh)144 CBDALNBInfo::get_LocalOscillatorFrequencyHighBand(ULONG *pulLOFHigh)
145 {
146 return E_NOINTERFACE;
147 }
148
149 HRESULT
150 STDMETHODCALLTYPE
put_HighLowSwitchFrequency(ULONG ulSwitchFrequency)151 CBDALNBInfo::put_HighLowSwitchFrequency(ULONG ulSwitchFrequency)
152 {
153 KSP_NODE Node;
154 HRESULT hr;
155
156 // setup request
157 Node.NodeId = m_NodeId;
158 Node.Reserved = 0;
159
160 // perform request
161 hr = m_pProperty->Set(KSPROPSETID_BdaLNBInfo, KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulSwitchFrequency, sizeof(ULONG));
162
163 #ifdef BDAPLGIN_TRACE
164 WCHAR Buffer[100];
165 swprintf(Buffer, L"CBDALNBInfo::put_HighLowSwitchFrequency: m_NodeId %lu ulSwitchFrequency %lu hr %lx\n", m_NodeId, ulSwitchFrequency, hr);
166 OutputDebugStringW(Buffer);
167 #endif
168
169 return hr;
170 }
171
172 HRESULT
173 STDMETHODCALLTYPE
get_HighLowSwitchFrequency(ULONG * pulSwitchFrequency)174 CBDALNBInfo::get_HighLowSwitchFrequency(ULONG *pulSwitchFrequency)
175 {
176 return E_NOINTERFACE;
177 }
178
179 HRESULT
180 WINAPI
CBDALNBInfo_fnConstructor(IKsPropertySet * pProperty,ULONG NodeId,REFIID riid,LPVOID * ppv)181 CBDALNBInfo_fnConstructor(
182 IKsPropertySet *pProperty,
183 ULONG NodeId,
184 REFIID riid,
185 LPVOID * ppv)
186 {
187 // construct device control
188 CBDALNBInfo * handler = new CBDALNBInfo(pProperty, NodeId);
189
190 #ifdef BDAPLGIN_TRACE
191 OutputDebugStringW(L"CBDALNBInfo_fnConstructor\n");
192 #endif
193
194 if (!handler)
195 return E_OUTOFMEMORY;
196
197 if (FAILED(handler->QueryInterface(riid, ppv)))
198 {
199 /* not supported */
200 delete handler;
201 return E_NOINTERFACE;
202 }
203
204 return NOERROR;
205 }
206