Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H |
| 17 | #define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H |
| 18 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 19 | #include "Tuner.h" |
| 20 | |
Tomasz Wasilczyk | 803301a | 2017-03-13 14:30:15 -0700 | [diff] [blame] | 21 | #include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h> |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 22 | #include <android/hardware/broadcastradio/1.1/types.h> |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace broadcastradio { |
| 27 | namespace V1_1 { |
| 28 | namespace implementation { |
| 29 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 30 | struct AmFmBandConfig { |
| 31 | V1_0::Band type; |
| 32 | uint32_t lowerLimit; // kHz |
| 33 | uint32_t upperLimit; // kHz |
| 34 | uint32_t spacing; // kHz |
| 35 | }; |
| 36 | |
| 37 | struct ModuleConfig { |
| 38 | std::string productName; |
| 39 | std::vector<AmFmBandConfig> amFmBands; |
| 40 | }; |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 41 | |
Tomasz Wasilczyk | 803301a | 2017-03-13 14:30:15 -0700 | [diff] [blame] | 42 | struct BroadcastRadio : public V1_1::IBroadcastRadio { |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 43 | /** |
| 44 | * Constructs new broadcast radio module. |
| 45 | * |
| 46 | * Before calling a constructor with a given classId, it must be checked with isSupported |
| 47 | * method first. Otherwise it results in undefined behaviour. |
| 48 | * |
| 49 | * @param classId type of a radio. |
| 50 | */ |
| 51 | BroadcastRadio(V1_0::Class classId); |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 52 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 53 | /** |
| 54 | * Checks, if a given radio type is supported. |
| 55 | * |
| 56 | * @param classId type of a radio. |
| 57 | */ |
| 58 | static bool isSupported(V1_0::Class classId); |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 59 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 60 | // V1_1::IBroadcastRadio methods |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 61 | Return<void> getProperties(getProperties_cb _hidl_cb) override; |
Tomasz Wasilczyk | 803301a | 2017-03-13 14:30:15 -0700 | [diff] [blame] | 62 | Return<void> getProperties_1_1(getProperties_1_1_cb _hidl_cb) override; |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 63 | Return<void> openTuner(const V1_0::BandConfig& config, bool audio, |
| 64 | const sp<V1_0::ITunerCallback>& callback, |
| 65 | openTuner_cb _hidl_cb) override; |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 66 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 67 | private: |
| 68 | std::mutex mMut; |
| 69 | V1_0::Class mClassId; |
| 70 | ModuleConfig mConfig; |
| 71 | wp<Tuner> mTuner; |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | } // namespace implementation |
| 75 | } // namespace V1_1 |
| 76 | } // namespace broadcastradio |
| 77 | } // namespace hardware |
| 78 | } // namespace android |
| 79 | |
| 80 | #endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H |