blob: d0a73d99552ab3f442e9fb22a11c20fe7ecc8577 [file] [log] [blame]
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -08001/*
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 */
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080016#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
17#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080018
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070019#include "Tuner.h"
20
Tomasz Wasilczyk803301a2017-03-13 14:30:15 -070021#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080022#include <android/hardware/broadcastradio/1.1/types.h>
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080023
24namespace android {
25namespace hardware {
26namespace broadcastradio {
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080027namespace V1_1 {
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080028namespace implementation {
29
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070030struct AmFmBandConfig {
31 V1_0::Band type;
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080032 uint32_t lowerLimit; // kHz
33 uint32_t upperLimit; // kHz
Tomasz Wasilczyk701a5bd2017-08-10 12:32:45 -070034 std::vector<uint32_t> spacings; // kHz
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070035};
36
37struct ModuleConfig {
38 std::string productName;
39 std::vector<AmFmBandConfig> amFmBands;
40};
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080041
Tomasz Wasilczyk803301a2017-03-13 14:30:15 -070042struct BroadcastRadio : public V1_1::IBroadcastRadio {
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070043 /**
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 Wasilczyk213170b2017-02-07 17:38:21 -080052
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070053 /**
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 Wasilczyk213170b2017-02-07 17:38:21 -080059
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070060 // V1_1::IBroadcastRadio methods
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080061 Return<void> getProperties(getProperties_cb _hidl_cb) override;
Tomasz Wasilczyk803301a2017-03-13 14:30:15 -070062 Return<void> getProperties_1_1(getProperties_1_1_cb _hidl_cb) override;
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070063 Return<void> openTuner(const V1_0::BandConfig& config, bool audio,
64 const sp<V1_0::ITunerCallback>& callback,
65 openTuner_cb _hidl_cb) override;
Tomasz Wasilczykba3e2542017-07-17 13:59:21 -070066 Return<void> getImage(int32_t id, getImage_cb _hidl_cb);
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080067
Tomasz Wasilczykc863a952018-03-07 14:28:55 -080068 std::vector<V1_0::BandConfig> getAmFmBands() const;
69
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070070 private:
71 std::mutex mMut;
72 V1_0::Class mClassId;
73 ModuleConfig mConfig;
74 wp<Tuner> mTuner;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080075};
76
77} // namespace implementation
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080078} // namespace V1_1
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080079} // namespace broadcastradio
80} // namespace hardware
81} // namespace android
82
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080083#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H