• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021, 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 
17 #ifndef ANDROID_MEDIA_TUNERHIDLFRONTEND_H
18 #define ANDROID_MEDIA_TUNERHIDLFRONTEND_H
19 
20 #include <aidl/android/hardware/tv/tuner/IFrontendCallback.h>
21 #include <aidl/android/media/tv/tuner/BnTunerFrontend.h>
22 #include <android/hardware/tv/tuner/1.0/ITuner.h>
23 #include <android/hardware/tv/tuner/1.1/IFrontend.h>
24 #include <android/hardware/tv/tuner/1.1/IFrontendCallback.h>
25 #include <utils/Log.h>
26 
27 using ::aidl::android::hardware::tv::tuner::FrontendAtsc3Settings;
28 using ::aidl::android::hardware::tv::tuner::FrontendDvbsCodeRate;
29 using ::aidl::android::hardware::tv::tuner::FrontendEventType;
30 using ::aidl::android::hardware::tv::tuner::FrontendScanMessage;
31 using ::aidl::android::hardware::tv::tuner::FrontendScanMessageType;
32 using ::aidl::android::hardware::tv::tuner::FrontendScanType;
33 using ::aidl::android::hardware::tv::tuner::FrontendSettings;
34 using ::aidl::android::hardware::tv::tuner::FrontendStatus;
35 using ::aidl::android::hardware::tv::tuner::FrontendStatusReadiness;
36 using ::aidl::android::hardware::tv::tuner::FrontendStatusType;
37 using ::android::sp;
38 using ::android::hardware::hidl_vec;
39 using ::android::hardware::Return;
40 using ::android::hardware::Void;
41 using ::std::shared_ptr;
42 using ::std::vector;
43 
44 using HidlFrontendAtsc3PlpSettings = ::android::hardware::tv::tuner::V1_0::FrontendAtsc3PlpSettings;
45 using HidlFrontendDvbsCodeRate = ::android::hardware::tv::tuner::V1_0::FrontendDvbsCodeRate;
46 using HidlFrontendEventType = ::android::hardware::tv::tuner::V1_0::FrontendEventType;
47 using HidlFrontendId = ::android::hardware::tv::tuner::V1_0::FrontendId;
48 using HidlFrontendScanMessage = ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
49 using HidlFrontendScanMessageType = ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
50 using HidlFrontendSettings = ::android::hardware::tv::tuner::V1_0::FrontendSettings;
51 using HidlFrontendStatus = ::android::hardware::tv::tuner::V1_0::FrontendStatus;
52 using HidlIFrontend = ::android::hardware::tv::tuner::V1_0::IFrontend;
53 using HidlIFrontendCallback = ::android::hardware::tv::tuner::V1_1::IFrontendCallback;
54 using HidlFrontendScanMessageExt1_1 =
55         ::android::hardware::tv::tuner::V1_1::FrontendScanMessageExt1_1;
56 using HidlFrontendScanMessageTypeExt1_1 =
57         ::android::hardware::tv::tuner::V1_1::FrontendScanMessageTypeExt1_1;
58 using HidlFrontendSettingsExt1_1 = ::android::hardware::tv::tuner::V1_1::FrontendSettingsExt1_1;
59 using HidlFrontendStatusExt1_1 = ::android::hardware::tv::tuner::V1_1::FrontendStatusExt1_1;
60 
61 namespace aidl {
62 namespace android {
63 namespace media {
64 namespace tv {
65 namespace tuner {
66 
67 class TunerHidlFrontend : public BnTunerFrontend {
68 public:
69     TunerHidlFrontend(sp<HidlIFrontend> frontend, int id);
70     virtual ~TunerHidlFrontend();
71 
72     ::ndk::ScopedAStatus setCallback(
73             const shared_ptr<ITunerFrontendCallback>& in_tunerFrontendCallback) override;
74     ::ndk::ScopedAStatus tune(const FrontendSettings& in_settings) override;
75     ::ndk::ScopedAStatus stopTune() override;
76     ::ndk::ScopedAStatus scan(const FrontendSettings& in_settings,
77                               FrontendScanType in_frontendScanType) override;
78     ::ndk::ScopedAStatus stopScan() override;
79     ::ndk::ScopedAStatus setLnb(const shared_ptr<ITunerLnb>& in_lnb) override;
80     ::ndk::ScopedAStatus linkCiCamToFrontend(int32_t in_ciCamId, int32_t* _aidl_return) override;
81     ::ndk::ScopedAStatus unlinkCiCamToFrontend(int32_t in_ciCamId) override;
82     ::ndk::ScopedAStatus close() override;
83     ::ndk::ScopedAStatus getStatus(const vector<FrontendStatusType>& in_statusTypes,
84                                    vector<FrontendStatus>* _aidl_return) override;
85     ::ndk::ScopedAStatus getFrontendId(int32_t* _aidl_return) override;
86     ::ndk::ScopedAStatus getHardwareInfo(std::string* _aidl_return) override;
87     ::ndk::ScopedAStatus removeOutputPid(int32_t in_pid) override;
88     ::ndk::ScopedAStatus getFrontendStatusReadiness(
89             const std::vector<FrontendStatusType>& in_statusTypes,
90             std::vector<FrontendStatusReadiness>* _aidl_return) override;
91 
92     void setLna(bool in_bEnable);
93 
94     struct FrontendCallback : public HidlIFrontendCallback {
FrontendCallbackFrontendCallback95         FrontendCallback(const shared_ptr<ITunerFrontendCallback> tunerFrontendCallback)
96               : mTunerFrontendCallback(tunerFrontendCallback){};
97 
98         virtual Return<void> onEvent(HidlFrontendEventType frontendEventType);
99         virtual Return<void> onScanMessage(HidlFrontendScanMessageType type,
100                                            const HidlFrontendScanMessage& message);
101         virtual Return<void> onScanMessageExt1_1(HidlFrontendScanMessageTypeExt1_1 type,
102                                                  const HidlFrontendScanMessageExt1_1& message);
103 
104         shared_ptr<ITunerFrontendCallback> mTunerFrontendCallback;
105     };
106 
107 private:
108     hidl_vec<HidlFrontendAtsc3PlpSettings> getAtsc3PlpSettings(
109             const FrontendAtsc3Settings& settings);
110     HidlFrontendDvbsCodeRate getDvbsCodeRate(const FrontendDvbsCodeRate& codeRate);
111     void getHidlFrontendSettings(const FrontendSettings& aidlSettings,
112                                  HidlFrontendSettings& settings,
113                                  HidlFrontendSettingsExt1_1& settingsExt);
114     void getAidlFrontendStatus(const vector<HidlFrontendStatus>& hidlStatus,
115                                const vector<HidlFrontendStatusExt1_1>& hidlStatusExt,
116                                vector<FrontendStatus>& aidlStatus);
117 
118     int mId;
119     sp<HidlIFrontend> mFrontend;
120     sp<::android::hardware::tv::tuner::V1_1::IFrontend> mFrontend_1_1;
121 };
122 
123 }  // namespace tuner
124 }  // namespace tv
125 }  // namespace media
126 }  // namespace android
127 }  // namespace aidl
128 
129 #endif  // ANDROID_MEDIA_TUNERHIDLFRONTEND_H
130