• 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 TunerHidlService;
68 
69 class TunerHidlFrontend : public BnTunerFrontend {
70 public:
71     TunerHidlFrontend(const sp<HidlIFrontend> frontend, const int id,
72                       const shared_ptr<TunerHidlService> tuner);
73     virtual ~TunerHidlFrontend();
74 
75     ::ndk::ScopedAStatus setCallback(
76             const shared_ptr<ITunerFrontendCallback>& in_tunerFrontendCallback) override;
77     ::ndk::ScopedAStatus tune(const FrontendSettings& in_settings) override;
78     ::ndk::ScopedAStatus stopTune() override;
79     ::ndk::ScopedAStatus scan(const FrontendSettings& in_settings,
80                               FrontendScanType in_frontendScanType) override;
81     ::ndk::ScopedAStatus stopScan() override;
82     ::ndk::ScopedAStatus setLnb(const shared_ptr<ITunerLnb>& in_lnb) override;
83     ::ndk::ScopedAStatus linkCiCamToFrontend(int32_t in_ciCamId, int32_t* _aidl_return) override;
84     ::ndk::ScopedAStatus unlinkCiCamToFrontend(int32_t in_ciCamId) override;
85     ::ndk::ScopedAStatus close() override;
86     ::ndk::ScopedAStatus getStatus(const vector<FrontendStatusType>& in_statusTypes,
87                                    vector<FrontendStatus>* _aidl_return) override;
88     ::ndk::ScopedAStatus getFrontendId(int32_t* _aidl_return) override;
89     ::ndk::ScopedAStatus getHardwareInfo(std::string* _aidl_return) override;
90     ::ndk::ScopedAStatus removeOutputPid(int32_t in_pid) override;
91     ::ndk::ScopedAStatus getFrontendStatusReadiness(
92             const std::vector<FrontendStatusType>& in_statusTypes,
93             std::vector<FrontendStatusReadiness>* _aidl_return) override;
94 
95     void setLna(bool in_bEnable);
96 
97     struct FrontendCallback : public HidlIFrontendCallback {
FrontendCallbackFrontendCallback98         FrontendCallback(const shared_ptr<ITunerFrontendCallback> tunerFrontendCallback)
99               : mTunerFrontendCallback(tunerFrontendCallback){};
100 
101         virtual Return<void> onEvent(HidlFrontendEventType frontendEventType);
102         virtual Return<void> onScanMessage(HidlFrontendScanMessageType type,
103                                            const HidlFrontendScanMessage& message);
104         virtual Return<void> onScanMessageExt1_1(HidlFrontendScanMessageTypeExt1_1 type,
105                                                  const HidlFrontendScanMessageExt1_1& message);
106 
107         shared_ptr<ITunerFrontendCallback> mTunerFrontendCallback;
108     };
109 
110 private:
111     hidl_vec<HidlFrontendAtsc3PlpSettings> getAtsc3PlpSettings(
112             const FrontendAtsc3Settings& settings);
113     HidlFrontendDvbsCodeRate getDvbsCodeRate(const FrontendDvbsCodeRate& codeRate);
114     void getHidlFrontendSettings(const FrontendSettings& aidlSettings,
115                                  HidlFrontendSettings& settings,
116                                  HidlFrontendSettingsExt1_1& settingsExt);
117     void getAidlFrontendStatus(const vector<HidlFrontendStatus>& hidlStatus,
118                                const vector<HidlFrontendStatusExt1_1>& hidlStatusExt,
119                                vector<FrontendStatus>& aidlStatus);
120 
121     int mId;
122     sp<HidlIFrontend> mFrontend;
123     sp<::android::hardware::tv::tuner::V1_1::IFrontend> mFrontend_1_1;
124     shared_ptr<TunerHidlService> mTunerService;
125 };
126 
127 }  // namespace tuner
128 }  // namespace tv
129 }  // namespace media
130 }  // namespace android
131 }  // namespace aidl
132 
133 #endif  // ANDROID_MEDIA_TUNERHIDLFRONTEND_H
134