forked from faust93/mocha_patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0001-1-2-qcom-fm-radio-return-from-the-dead.patch
334 lines (318 loc) · 12.1 KB
/
0001-1-2-qcom-fm-radio-return-from-the-dead.patch
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
From e9a8e32af6511b8a8480df06273fc8038acf39ee Mon Sep 17 00:00:00 2001
From: faust93 <monumentum@gmail.com>
Date: Thu, 15 Jan 2015 15:41:37 +0300
Subject: [PATCH] [1/2] qcom fm radio return from the dead
Change-Id: I2aca9e43b78f5413844e1eee280ac443ce3f5e76
---
include/media/AudioSystem.h | 4 +-
include/media/IAudioFlinger.h | 4 +-
media/libmedia/AudioSystem.cpp | 9 ++++
media/libmedia/IAudioFlinger.cpp | 22 ++++++++++
services/audioflinger/AudioFlinger.cpp | 23 ++++++++++
services/audioflinger/AudioFlinger.h | 7 +++
services/audioflinger/AudioPolicyService.cpp | 64 ++++++++++++++++++++++++++++
services/audioflinger/AudioPolicyService.h | 16 ++++++-
8 files changed, 146 insertions(+), 3 deletions(-)
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 1c23e7c..a11b0fb 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -118,7 +118,9 @@ public:
audio_channel_mask_t channelMask, size_t* buffSize);
static status_t setVoiceVolume(float volume);
-
+#ifdef QCOM_FM_ENABLED
+ static status_t setFmVolume(float volume);
+#endif
// return the number of audio frames written by AudioFlinger to audio HAL and
// audio dsp to DAC since the output on which the specified stream is playing
// has exited standby.
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index c3519f2..711e04a 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -228,7 +228,9 @@ public:
// that looks on primary device for a stream with fast flag, primary flag, or first one.
virtual uint32_t getPrimaryOutputSamplingRate() = 0;
virtual size_t getPrimaryOutputFrameCount() = 0;
-
+#ifdef QCOM_FM_ENABLED
+ virtual status_t setFmVolume(float volume) = 0;
+#endif
// Intended for AudioService to inform AudioFlinger of device's low RAM attribute,
// and should be called at most once. For a definition of what "low RAM" means, see
// android.app.ActivityManager.isLowRamDevice().
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index b0688e7..4d98f2a 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -423,6 +423,15 @@ void AudioSystem::releaseAudioSessionId(int audioSession) {
}
}
+#ifdef QCOM_FM_ENABLED
+status_t AudioSystem::setFmVolume(float value)
+{
+ const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+ if (af == 0) return PERMISSION_DENIED;
+ return af->setFmVolume(value);
+}
+#endif
+
// ---------------------------------------------------------------------------
void AudioSystem::AudioFlingerClient::binderDied(const wp<IBinder>& who) {
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 92471d6..75e83a5 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -71,6 +71,9 @@ enum {
GET_EFFECT_DESCRIPTOR,
CREATE_EFFECT,
MOVE_EFFECTS,
+#ifdef QCOM_FM_ENABLED
+ SET_FM_VOLUME,
+#endif
LOAD_HW_MODULE,
GET_PRIMARY_OUTPUT_SAMPLING_RATE,
GET_PRIMARY_OUTPUT_FRAME_COUNT,
@@ -751,6 +754,17 @@ public:
return reply.readInt32();
}
+#ifdef QCOM_FM_ENABLED
+ virtual status_t setFmVolume(float volume)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeFloat(volume);
+ remote()->transact(SET_FM_VOLUME, data, &reply);
+ return reply.readInt32();
+ }
+#endif
+
virtual audio_module_handle_t loadHwModule(const char *name)
{
Parcel data, reply;
@@ -1174,6 +1188,14 @@ status_t BnAudioFlinger::onTransact(
reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
return NO_ERROR;
} break;
+#ifdef QCOM_FM_ENABLED
+ case SET_FM_VOLUME: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ float volume = data.readFloat();
+ reply->writeInt32( setFmVolume(volume) );
+ return NO_ERROR;
+ } break;
+#endif
case LOAD_HW_MODULE: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
reply->writeInt32(loadHwModule(data.readCString()));
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index b8d8aab..c880384 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1346,6 +1346,29 @@ status_t AudioFlinger::getRenderPosition(size_t *halFrames, size_t *dspFrames,
return BAD_VALUE;
}
+#ifdef QCOM_FM_ENABLED
+status_t AudioFlinger::setFmVolume(float value)
+{
+ status_t ret = initCheck();
+ if (ret != NO_ERROR) {
+ return ret;
+ }
+
+ // check calling permissions
+ if (!settingsAllowed()) {
+ return PERMISSION_DENIED;
+ }
+
+ AutoMutex lock(mHardwareLock);
+ audio_hw_device_t *dev = mPrimaryHardwareDev->hwDevice();
+ mHardwareStatus = AUDIO_SET_FM_VOLUME;
+ ret = dev->set_fm_volume(dev, value);
+ mHardwareStatus = AUDIO_HW_IDLE;
+
+ return ret;
+}
+#endif
+
void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
{
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index b861e4f..c60c4f9 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -253,6 +253,10 @@ public:
virtual status_t moveEffects(int sessionId, audio_io_handle_t srcOutput,
audio_io_handle_t dstOutput);
+#ifdef QCOM_FM_ENABLED
+ virtual status_t setFmVolume(float volume);
+#endif
+
virtual audio_module_handle_t loadHwModule(const char *name);
virtual uint32_t getPrimaryOutputSamplingRate();
@@ -740,6 +744,9 @@ private:
AUDIO_HW_SET_MIC_MUTE, // set_mic_mute
AUDIO_HW_SET_VOICE_VOLUME, // set_voice_volume
AUDIO_HW_SET_PARAMETER, // set_parameters
+#ifdef QCOM_FM_ENABLED
+ AUDIO_SET_FM_VOLUME,
+#endif
AUDIO_HW_GET_INPUT_BUFFER_SIZE, // get_input_buffer_size
AUDIO_HW_GET_MASTER_VOLUME, // get_master_volume
AUDIO_HW_GET_PARAMETER, // get_parameters
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index a23d031..cd07d8f 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -826,6 +826,18 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
mLock.lock();
delete data;
}break;
+#ifdef QCOM_FM_ENABLED
+ case SET_FM_VOLUME: {
+ FmVolumeData *data = (FmVolumeData *)command->mParam;
+ ALOGV("AudioCommandThread() processing set fm volume volume %f", data->mVolume);
+ command->mStatus = AudioSystem::setFmVolume(data->mVolume);
+ if (command->mWaitStatus) {
+ command->mCond.signal();
+ mWaitWorkCV.wait(mLock);
+ }
+ delete data;
+ }break;
+#endif
default:
ALOGW("AudioCommandThread() unknown command %d", command->mCommand);
}
@@ -977,6 +989,33 @@ status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand(float volume
return status;
}
+#ifdef QCOM_FM_ENABLED
+status_t AudioPolicyService::AudioCommandThread::fmVolumeCommand(float volume, int delayMs)
+{
+ status_t status = NO_ERROR;
+ AudioCommand *command = new AudioCommand();
+ command->mCommand = SET_FM_VOLUME;
+ FmVolumeData *data = new FmVolumeData();
+ data->mVolume = volume;
+ command->mParam = data;
+ if (delayMs == 0) {
+ command->mWaitStatus = true;
+ } else {
+ command->mWaitStatus = false;
+ }
+ Mutex::Autolock _l(mLock);
+ insertCommand_l(command, delayMs);
+ ALOGV("AudioCommandThread() adding set fm volume volume %f", volume);
+ mWaitWorkCV.signal();
+ if (command->mWaitStatus) {
+ command->mCond.wait(mLock);
+ status = command->mStatus;
+ mWaitWorkCV.signal();
+ }
+ return status;
+}
+#endif
+
void AudioPolicyService::AudioCommandThread::stopOutputCommand(audio_io_handle_t output,
audio_stream_type_t stream,
int session)
@@ -1074,6 +1113,12 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *comma
// command status as the command is now delayed
delayMs = 1;
} break;
+#ifdef QCOM_FM_ENABLED
+ case SET_FM_VOLUME: {
+ removedCommands.add(command2);
+ command->mTime = command2->mTime;
+ } break;
+#endif
case START_TONE:
case STOP_TONE:
default:
@@ -1150,6 +1195,13 @@ int AudioPolicyService::setStreamVolume(audio_stream_type_t stream,
output, delayMs);
}
+#ifdef QCOM_FM_ENABLED
+status_t AudioPolicyService::setFmVolume(float volume, int delayMs)
+{
+ return mAudioCommandThread->fmVolumeCommand(volume, delayMs);
+}
+#endif
+
int AudioPolicyService::startTone(audio_policy_tone_t tone,
audio_stream_type_t stream)
{
@@ -1689,6 +1741,15 @@ static int aps_set_voice_volume(void *service, float volume, int delay_ms)
return audioPolicyService->setVoiceVolume(volume, delay_ms);
}
+#ifdef QCOM_FM_ENABLED
+static int aps_set_fm_volume(void *service, float volume, int delay_ms)
+{
+ AudioPolicyService *audioPolicyService = (AudioPolicyService *)service;
+
+ return audioPolicyService->setFmVolume(volume, delay_ms);
+}
+#endif
+
}; // extern "C"
namespace {
@@ -1702,6 +1763,9 @@ namespace {
close_input : aps_close_input,
set_stream_volume : aps_set_stream_volume,
set_stream_output : aps_set_stream_output,
+#ifdef QCOM_FM_ENABLED
+ set_fm_volume : aps_set_fm_volume,
+#endif
set_parameters : aps_set_parameters,
get_parameters : aps_get_parameters,
start_tone : aps_start_tone,
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index f38ca65..71375ae 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -138,6 +138,9 @@ public:
virtual status_t startTone(audio_policy_tone_t tone, audio_stream_type_t stream);
virtual status_t stopTone();
virtual status_t setVoiceVolume(float volume, int delayMs = 0);
+#ifdef QCOM_FM_ENABLED
+ virtual status_t setFmVolume(float volume, int delayMs = 0);
+#endif
virtual bool isOffloadSupported(const audio_offload_info_t &config);
status_t doStopOutput(audio_io_handle_t output,
@@ -168,6 +171,9 @@ private:
SET_VOLUME,
SET_PARAMETERS,
SET_VOICE_VOLUME,
+#ifdef QCOM_FM_ENABLED
+ SET_FM_VOLUME,
+#endif
STOP_OUTPUT,
RELEASE_OUTPUT
};
@@ -190,6 +196,9 @@ private:
status_t parametersCommand(audio_io_handle_t ioHandle,
const char *keyValuePairs, int delayMs = 0);
status_t voiceVolumeCommand(float volume, int delayMs = 0);
+#ifdef QCOM_FM_ENABLED
+ status_t fmVolumeCommand(float volume, int delayMs = 0);
+#endif
void stopOutputCommand(audio_io_handle_t output,
audio_stream_type_t stream,
int session);
@@ -247,7 +256,12 @@ private:
public:
float mVolume;
};
-
+#ifdef QCOM_FM_ENABLED
+ class FmVolumeData : public AudioCommandData {
+ public:
+ float mVolume;
+ };
+#endif
class StopOutputData : public AudioCommandData {
public:
audio_io_handle_t mIO;
--
1.9.3 (Apple Git-50)