blob: 57ed1ba4f909df289c30236259dd70be29520f0f [file] [log] [blame]
Hongguang4092f2f2021-07-08 18:49:12 -07001/*
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//#define LOG_NDEBUG 0
18#define LOG_TAG "android.hardware.tv.tuner-service.example-Frontend"
19
Hongguange423acd2021-07-27 16:56:47 -070020#include <aidl/android/hardware/tv/tuner/Result.h>
Hongguang4092f2f2021-07-08 18:49:12 -070021#include <utils/Log.h>
22
Hongguange423acd2021-07-27 16:56:47 -070023#include "Frontend.h"
24
Hongguang4092f2f2021-07-08 18:49:12 -070025namespace aidl {
26namespace android {
27namespace hardware {
28namespace tv {
29namespace tuner {
30
Hongguang4a8ac292022-08-09 14:02:03 -070031Frontend::Frontend(FrontendType type, int32_t id) {
Hongguang4092f2f2021-07-08 18:49:12 -070032 mType = type;
33 mId = id;
Hongguang4a8ac292022-08-09 14:02:03 -070034 mTuner = nullptr;
Hongguang4092f2f2021-07-08 18:49:12 -070035 // Init callback to nullptr
36 mCallback = nullptr;
sadiqsada59a40422023-11-10 14:30:33 -080037 mIptvPluginInterface = nullptr;
38 mIptvPluginStreamer = nullptr;
Hongguang881190f2022-01-14 13:23:37 -080039
40 switch (mType) {
41 case FrontendType::ISDBS: {
42 mFrontendCaps.set<FrontendCapabilities::Tag::isdbsCaps>(FrontendIsdbsCapabilities());
43 mFrontendStatusCaps = {
44 FrontendStatusType::DEMOD_LOCK,
45 FrontendStatusType::SNR,
46 FrontendStatusType::FEC,
47 FrontendStatusType::MODULATION,
48 FrontendStatusType::MODULATIONS,
49 FrontendStatusType::ROLL_OFF,
50 FrontendStatusType::STREAM_ID_LIST,
51 };
52 break;
53 }
54 case FrontendType::ATSC3: {
55 mFrontendCaps.set<FrontendCapabilities::Tag::atsc3Caps>(FrontendAtsc3Capabilities());
56 mFrontendStatusCaps = {
57 FrontendStatusType::BER,
58 FrontendStatusType::PER,
59 FrontendStatusType::ATSC3_PLP_INFO,
60 FrontendStatusType::MODULATIONS,
61 FrontendStatusType::BERS,
62 FrontendStatusType::INTERLEAVINGS,
63 FrontendStatusType::BANDWIDTH,
64 FrontendStatusType::ATSC3_ALL_PLP_INFO,
65 };
66 break;
67 }
68 case FrontendType::DVBC: {
69 mFrontendCaps.set<FrontendCapabilities::Tag::dvbcCaps>(FrontendDvbcCapabilities());
70 mFrontendStatusCaps = {
71 FrontendStatusType::PRE_BER, FrontendStatusType::SIGNAL_QUALITY,
72 FrontendStatusType::MODULATION, FrontendStatusType::SPECTRAL,
73 FrontendStatusType::MODULATIONS, FrontendStatusType::CODERATES,
74 FrontendStatusType::INTERLEAVINGS, FrontendStatusType::BANDWIDTH,
75 };
76 break;
77 }
78 case FrontendType::DVBS: {
79 mFrontendCaps.set<FrontendCapabilities::Tag::dvbsCaps>(FrontendDvbsCapabilities());
80 mFrontendStatusCaps = {
81 FrontendStatusType::SIGNAL_STRENGTH, FrontendStatusType::SYMBOL_RATE,
82 FrontendStatusType::MODULATION, FrontendStatusType::MODULATIONS,
83 FrontendStatusType::ROLL_OFF, FrontendStatusType::IS_MISO,
84 };
85 break;
86 }
87 case FrontendType::DVBT: {
88 mFrontendCaps.set<FrontendCapabilities::Tag::dvbtCaps>(FrontendDvbtCapabilities());
89 mFrontendStatusCaps = {
90 FrontendStatusType::EWBS,
91 FrontendStatusType::PLP_ID,
92 FrontendStatusType::HIERARCHY,
93 FrontendStatusType::MODULATIONS,
94 FrontendStatusType::BANDWIDTH,
95 FrontendStatusType::GUARD_INTERVAL,
96 FrontendStatusType::TRANSMISSION_MODE,
97 FrontendStatusType::T2_SYSTEM_ID,
98 FrontendStatusType::DVBT_CELL_IDS,
99 };
100 break;
101 }
102 case FrontendType::ISDBT: {
103 FrontendIsdbtCapabilities isdbtCaps{
104 .modeCap = (int)FrontendIsdbtMode::MODE_1 | (int)FrontendIsdbtMode::MODE_2,
105 .bandwidthCap = (int)FrontendIsdbtBandwidth::BANDWIDTH_6MHZ,
106 .modulationCap = (int)FrontendIsdbtModulation::MOD_16QAM,
107 .coderateCap = (int)FrontendIsdbtCoderate::CODERATE_4_5 |
108 (int)FrontendIsdbtCoderate::CODERATE_6_7,
109 .guardIntervalCap = (int)FrontendIsdbtGuardInterval::INTERVAL_1_128,
110 .timeInterleaveCap = (int)FrontendIsdbtTimeInterleaveMode::AUTO |
111 (int)FrontendIsdbtTimeInterleaveMode::INTERLEAVE_1_0,
112 .isSegmentAuto = true,
113 .isFullSegment = true,
114 };
115 mFrontendCaps.set<FrontendCapabilities::Tag::isdbtCaps>(isdbtCaps);
116 mFrontendStatusCaps = {
117 FrontendStatusType::AGC,
118 FrontendStatusType::LNA,
119 FrontendStatusType::MODULATION,
120 FrontendStatusType::MODULATIONS,
121 FrontendStatusType::BANDWIDTH,
122 FrontendStatusType::GUARD_INTERVAL,
123 FrontendStatusType::TRANSMISSION_MODE,
124 FrontendStatusType::ISDBT_SEGMENTS,
125 FrontendStatusType::ISDBT_MODE,
126 FrontendStatusType::ISDBT_PARTIAL_RECEPTION_FLAG,
127 FrontendStatusType::INTERLEAVINGS,
128 };
129 break;
130 }
131 case FrontendType::ANALOG: {
132 mFrontendCaps.set<FrontendCapabilities::Tag::analogCaps>(FrontendAnalogCapabilities());
133 mFrontendStatusCaps = {
134 FrontendStatusType::LAYER_ERROR,
135 FrontendStatusType::MER,
136 FrontendStatusType::UEC,
137 FrontendStatusType::TS_DATA_RATES,
138 };
139 break;
140 }
141 case FrontendType::ATSC: {
142 mFrontendCaps.set<FrontendCapabilities::Tag::atscCaps>(FrontendAtscCapabilities());
143 mFrontendStatusCaps = {
144 FrontendStatusType::FREQ_OFFSET,
145 FrontendStatusType::RF_LOCK,
146 FrontendStatusType::MODULATIONS,
147 FrontendStatusType::IS_LINEAR,
148 };
149 break;
150 }
151 case FrontendType::ISDBS3: {
152 mFrontendCaps.set<FrontendCapabilities::Tag::isdbs3Caps>(FrontendIsdbs3Capabilities());
153 mFrontendStatusCaps = {
154 FrontendStatusType::DEMOD_LOCK, FrontendStatusType::MODULATION,
155 FrontendStatusType::MODULATIONS, FrontendStatusType::ROLL_OFF,
156 FrontendStatusType::IS_SHORT_FRAMES, FrontendStatusType::STREAM_ID_LIST,
157 };
158 break;
159 }
160 case FrontendType::DTMB: {
161 mFrontendCaps.set<FrontendCapabilities::Tag::dtmbCaps>(FrontendDtmbCapabilities());
162 mFrontendStatusCaps = {
163 FrontendStatusType::MODULATIONS, FrontendStatusType::INTERLEAVINGS,
164 FrontendStatusType::BANDWIDTH, FrontendStatusType::GUARD_INTERVAL,
165 FrontendStatusType::TRANSMISSION_MODE,
166 };
167 break;
168 }
sadiqsada1448ad42023-01-31 16:14:04 -0800169 case FrontendType::IPTV: {
170 mFrontendCaps.set<FrontendCapabilities::Tag::iptvCaps>(FrontendIptvCapabilities());
171 mFrontendStatusCaps = {
172 FrontendStatusType::IPTV_CONTENT_URL,
173 FrontendStatusType::IPTV_PACKETS_LOST,
174 FrontendStatusType::IPTV_PACKETS_RECEIVED,
175 FrontendStatusType::IPTV_AVERAGE_JITTER_MS,
176 FrontendStatusType::IPTV_WORST_JITTER_MS,
177 };
178 break;
179 }
Hongguang881190f2022-01-14 13:23:37 -0800180 default: {
181 break;
182 }
183 }
Hongguang4092f2f2021-07-08 18:49:12 -0700184}
185
Hongguang4a8ac292022-08-09 14:02:03 -0700186Frontend::~Frontend() {
187 ALOGV("%s", __FUNCTION__);
188 mCallback = nullptr;
189 mIsLocked = false;
190 mTuner = nullptr;
191}
Hongguang4092f2f2021-07-08 18:49:12 -0700192
193::ndk::ScopedAStatus Frontend::close() {
194 ALOGV("%s", __FUNCTION__);
195 // Reset callback
196 mCallback = nullptr;
197 mIsLocked = false;
Ray Chin8a9f53e2022-12-29 18:15:22 +0800198 if (mTuner != nullptr) {
199 mTuner->removeFrontend(mId);
200 }
Hongguang4a8ac292022-08-09 14:02:03 -0700201 mTuner = nullptr;
Hongguang4092f2f2021-07-08 18:49:12 -0700202
203 return ::ndk::ScopedAStatus::ok();
204}
205
206::ndk::ScopedAStatus Frontend::setCallback(const std::shared_ptr<IFrontendCallback>& in_callback) {
207 ALOGV("%s", __FUNCTION__);
208 if (in_callback == nullptr) {
209 ALOGW("[ WARN ] Set Frontend callback with nullptr");
Hongguange423acd2021-07-27 16:56:47 -0700210 return ::ndk::ScopedAStatus::fromServiceSpecificError(
211 static_cast<int32_t>(Result::INVALID_ARGUMENT));
Hongguang4092f2f2021-07-08 18:49:12 -0700212 }
213
214 mCallback = in_callback;
215 return ::ndk::ScopedAStatus::ok();
216}
217
sadiqsada56c98292023-11-02 16:45:31 -0700218void Frontend::readTuneByte(dtv_streamer* streamer, void* buf, size_t buf_size, int timeout_ms) {
219 ssize_t bytes_read = mIptvPluginInterface->read_stream(streamer, buf, buf_size, timeout_ms);
sadiqsada94eddcf2023-11-07 16:02:41 -0800220 if (bytes_read <= 0) {
sadiqsada56c98292023-11-02 16:45:31 -0700221 ALOGI("[ ERROR ] Tune byte couldn't be read.");
222 return;
223 }
224 mCallback->onEvent(FrontendEventType::LOCKED);
225 mIsLocked = true;
226}
227
228::ndk::ScopedAStatus Frontend::tune(const FrontendSettings& in_settings) {
Hongguang4092f2f2021-07-08 18:49:12 -0700229 if (mCallback == nullptr) {
sadiqsada56c98292023-11-02 16:45:31 -0700230 ALOGW("[ WARN ] Frontend callback is not set for tunin0g");
Hongguange423acd2021-07-27 16:56:47 -0700231 return ::ndk::ScopedAStatus::fromServiceSpecificError(
232 static_cast<int32_t>(Result::INVALID_STATE));
Hongguang4092f2f2021-07-08 18:49:12 -0700233 }
234
sadiqsada1448ad42023-01-31 16:14:04 -0800235 if (mType != FrontendType::IPTV) {
236 mTuner->frontendStartTune(mId);
sadiqsada56c98292023-11-02 16:45:31 -0700237 mCallback->onEvent(FrontendEventType::LOCKED);
238 mIsLocked = true;
239 } else {
240 // This is a reference implementation for IPTV. It uses an additional socket buffer.
241 // Vendors can use hardware memory directly to make the implementation more performant.
242 ALOGI("[ INFO ] Frontend type is set to IPTV, tag = %d id=%d", in_settings.getTag(),
243 mId);
Hongguang4092f2f2021-07-08 18:49:12 -0700244
sadiqsada56c98292023-11-02 16:45:31 -0700245 // load udp plugin for reading TS data
246 const char* path = "/vendor/lib/iptv_udp_plugin.so";
247 DtvPlugin* plugin = new DtvPlugin(path);
248 if (!plugin) {
249 ALOGE("Failed to create DtvPlugin, plugin_path is invalid");
250 return ::ndk::ScopedAStatus::fromServiceSpecificError(
251 static_cast<int32_t>(Result::INVALID_ARGUMENT));
252 }
253 bool plugin_loaded = plugin->load();
254 if (!plugin_loaded) {
255 ALOGE("Failed to load plugin");
256 return ::ndk::ScopedAStatus::fromServiceSpecificError(
257 static_cast<int32_t>(Result::INVALID_ARGUMENT));
258 }
259 mIptvPluginInterface = plugin->interface();
260
261 // validate content_url format
262 std::string content_url = in_settings.get<FrontendSettings::Tag::iptv>()->contentUrl;
263 std::string transport_desc = "{ \"uri\": \"" + content_url + "\"}";
264 ALOGI("[ INFO ] transport_desc: %s", transport_desc.c_str());
265 bool is_transport_desc_valid = plugin->validate(transport_desc.c_str());
266 if (!is_transport_desc_valid) { // not of format protocol://ip:port
267 ALOGE("[ INFO ] transport_desc is not valid");
268 return ::ndk::ScopedAStatus::fromServiceSpecificError(
269 static_cast<int32_t>(Result::INVALID_ARGUMENT));
270 }
271 mIptvTransportDescription = transport_desc;
272
273 // create a streamer and open it for reading data
274 dtv_streamer* streamer = mIptvPluginInterface->create_streamer();
275 mIptvPluginStreamer = streamer;
276 int open_fd = mIptvPluginInterface->open_stream(streamer, transport_desc.c_str());
277 if (open_fd < 0) {
278 ALOGE("[ INFO ] could not open stream");
279 return ::ndk::ScopedAStatus::fromServiceSpecificError(
280 static_cast<int32_t>(Result::INVALID_ARGUMENT));
281 }
282 ALOGI("[ INFO ] open_stream successful, open_fd=%d", open_fd);
283
284 size_t buf_size = 1;
285 int timeout_ms = 2000;
286 void* buf = malloc(sizeof(char) * buf_size);
287 if (buf == nullptr) ALOGI("malloc buf failed [TUNE]");
288 ALOGI("[ INFO ] [Tune] Allocated buffer of size %zu", buf_size);
289 mIptvFrontendTuneThread =
290 std::thread(&Frontend::readTuneByte, this, streamer, buf, buf_size, timeout_ms);
291 if (mIptvFrontendTuneThread.joinable()) mIptvFrontendTuneThread.join();
292 free(buf);
293 }
Sadiq Sada6c46c892023-11-02 23:03:43 +0000294
Hongguang4092f2f2021-07-08 18:49:12 -0700295 return ::ndk::ScopedAStatus::ok();
296}
297
298::ndk::ScopedAStatus Frontend::stopTune() {
299 ALOGV("%s", __FUNCTION__);
300
Hongguange423acd2021-07-27 16:56:47 -0700301 mTuner->frontendStopTune(mId);
Hongguang4092f2f2021-07-08 18:49:12 -0700302 mIsLocked = false;
303
304 return ::ndk::ScopedAStatus::ok();
305}
306
307::ndk::ScopedAStatus Frontend::scan(const FrontendSettings& in_settings, FrontendScanType in_type) {
308 ALOGV("%s", __FUNCTION__);
Hongguang4092f2f2021-07-08 18:49:12 -0700309
Hongguang6c09bff2021-12-23 10:50:03 -0800310 // If it's in middle of scanning, stop it first.
311 if (mScanThread.joinable()) {
312 mScanThread.join();
313 }
314
315 mFrontendSettings = in_settings;
316 mFrontendScanType = in_type;
317 mScanThread = std::thread(&Frontend::scanThreadLoop, this);
318
319 return ::ndk::ScopedAStatus::ok();
320}
321
Hongguang4a8ac292022-08-09 14:02:03 -0700322void Frontend::setTunerService(std::shared_ptr<Tuner> tuner) {
323 mTuner = tuner;
324}
325
Hongguang6c09bff2021-12-23 10:50:03 -0800326void Frontend::scanThreadLoop() {
Hongguang4092f2f2021-07-08 18:49:12 -0700327 if (mIsLocked) {
Hongguange423acd2021-07-27 16:56:47 -0700328 FrontendScanMessage msg;
Hongguang4092f2f2021-07-08 18:49:12 -0700329 msg.set<FrontendScanMessage::Tag::isEnd>(true);
330 mCallback->onScanMessage(FrontendScanMessageType::END, msg);
Hongguang6c09bff2021-12-23 10:50:03 -0800331 return;
Hongguang4092f2f2021-07-08 18:49:12 -0700332 }
333
Hongguang11da2cb2021-08-05 19:05:12 -0700334 int64_t frequency = 0;
Hongguang6c09bff2021-12-23 10:50:03 -0800335 switch (mFrontendSettings.getTag()) {
Hongguang4092f2f2021-07-08 18:49:12 -0700336 case FrontendSettings::Tag::analog:
Hongguang6c09bff2021-12-23 10:50:03 -0800337 frequency = mFrontendSettings.get<FrontendSettings::Tag::analog>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700338 break;
339 case FrontendSettings::Tag::atsc:
Hongguang6c09bff2021-12-23 10:50:03 -0800340 frequency = mFrontendSettings.get<FrontendSettings::Tag::atsc>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700341 break;
342 case FrontendSettings::Tag::atsc3:
Hongguang6c09bff2021-12-23 10:50:03 -0800343 frequency = mFrontendSettings.get<FrontendSettings::Tag::atsc3>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700344 break;
345 case FrontendSettings::Tag::dvbs:
Hongguang6c09bff2021-12-23 10:50:03 -0800346 frequency = mFrontendSettings.get<FrontendSettings::Tag::dvbs>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700347 break;
348 case FrontendSettings::Tag::dvbc:
Hongguang6c09bff2021-12-23 10:50:03 -0800349 frequency = mFrontendSettings.get<FrontendSettings::Tag::dvbc>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700350 break;
351 case FrontendSettings::Tag::dvbt:
Hongguang6c09bff2021-12-23 10:50:03 -0800352 frequency = mFrontendSettings.get<FrontendSettings::Tag::dvbt>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700353 break;
354 case FrontendSettings::Tag::isdbs:
Hongguang6c09bff2021-12-23 10:50:03 -0800355 frequency = mFrontendSettings.get<FrontendSettings::Tag::isdbs>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700356 break;
357 case FrontendSettings::Tag::isdbs3:
Hongguang6c09bff2021-12-23 10:50:03 -0800358 frequency = mFrontendSettings.get<FrontendSettings::Tag::isdbs3>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700359 break;
360 case FrontendSettings::Tag::isdbt:
Hongguang6c09bff2021-12-23 10:50:03 -0800361 frequency = mFrontendSettings.get<FrontendSettings::Tag::isdbt>().frequency;
Hongguang4092f2f2021-07-08 18:49:12 -0700362 break;
363 default:
364 break;
365 }
366
Hongguang6c09bff2021-12-23 10:50:03 -0800367 if (mFrontendScanType == FrontendScanType::SCAN_BLIND) {
Gareth Fenn282fb372021-09-27 15:14:11 +0100368 frequency += 100 * 1000;
Hongguang4092f2f2021-07-08 18:49:12 -0700369 }
370
371 {
372 FrontendScanMessage msg;
Hongguang11da2cb2021-08-05 19:05:12 -0700373 vector<int64_t> frequencies = {frequency};
Hongguang4092f2f2021-07-08 18:49:12 -0700374 msg.set<FrontendScanMessage::Tag::frequencies>(frequencies);
375 mCallback->onScanMessage(FrontendScanMessageType::FREQUENCY, msg);
376 }
377
378 {
379 FrontendScanMessage msg;
380 msg.set<FrontendScanMessage::Tag::progressPercent>(20);
381 mCallback->onScanMessage(FrontendScanMessageType::PROGRESS_PERCENT, msg);
382 }
383
384 {
385 FrontendScanMessage msg;
386 vector<int32_t> symbolRates = {30};
387 msg.set<FrontendScanMessage::Tag::symbolRates>(symbolRates);
388 mCallback->onScanMessage(FrontendScanMessageType::SYMBOL_RATE, msg);
389 }
390
391 if (mType == FrontendType::DVBT) {
392 FrontendScanMessage msg;
393 msg.set<FrontendScanMessage::Tag::hierarchy>(FrontendDvbtHierarchy::HIERARCHY_NON_NATIVE);
394 mCallback->onScanMessage(FrontendScanMessageType::HIERARCHY, msg);
395 }
396
397 if (mType == FrontendType::ANALOG) {
398 FrontendScanMessage msg;
399 msg.set<FrontendScanMessage::Tag::analogType>(FrontendAnalogType::PAL);
400 mCallback->onScanMessage(FrontendScanMessageType::ANALOG_TYPE, msg);
401 }
402
403 {
404 FrontendScanMessage msg;
Hongguang11da2cb2021-08-05 19:05:12 -0700405 vector<int32_t> plpIds = {2};
Hongguang4092f2f2021-07-08 18:49:12 -0700406 msg.set<FrontendScanMessage::Tag::plpIds>(plpIds);
407 mCallback->onScanMessage(FrontendScanMessageType::PLP_IDS, msg);
408 }
409
410 {
411 FrontendScanMessage msg;
Hongguang11da2cb2021-08-05 19:05:12 -0700412 vector<int32_t> groupIds = {3};
Hongguang4092f2f2021-07-08 18:49:12 -0700413 msg.set<FrontendScanMessage::Tag::groupIds>(groupIds);
414 mCallback->onScanMessage(FrontendScanMessageType::GROUP_IDS, msg);
415 }
416
417 {
418 FrontendScanMessage msg;
Hongguang11da2cb2021-08-05 19:05:12 -0700419 vector<int32_t> inputStreamIds = {1};
Hongguang4092f2f2021-07-08 18:49:12 -0700420 msg.set<FrontendScanMessage::Tag::inputStreamIds>(inputStreamIds);
421 mCallback->onScanMessage(FrontendScanMessageType::INPUT_STREAM_IDS, msg);
422 }
423
424 switch (mType) {
425 case FrontendType::DVBT: {
426 FrontendScanMessage msg;
427 FrontendScanMessageStandard std;
428 std.set<FrontendScanMessageStandard::Tag::tStd>(FrontendDvbtStandard::AUTO);
429 msg.set<FrontendScanMessage::Tag::std>(std);
430 mCallback->onScanMessage(FrontendScanMessageType::STANDARD, msg);
431 break;
432 }
433 case FrontendType::DVBS: {
434 FrontendScanMessage msg;
435 FrontendScanMessageStandard std;
436 std.set<FrontendScanMessageStandard::Tag::sStd>(FrontendDvbsStandard::AUTO);
437 msg.set<FrontendScanMessage::Tag::std>(std);
438 mCallback->onScanMessage(FrontendScanMessageType::STANDARD, msg);
439 break;
440 }
441 case FrontendType::ANALOG: {
442 FrontendScanMessage msg;
443 FrontendScanMessageStandard std;
444 std.set<FrontendScanMessageStandard::Tag::sifStd>(FrontendAnalogSifStandard::AUTO);
445 msg.set<FrontendScanMessage::Tag::std>(std);
446 mCallback->onScanMessage(FrontendScanMessageType::STANDARD, msg);
447 break;
448 }
449 default:
450 break;
451 }
452
453 {
454 FrontendScanMessage msg;
455 FrontendScanAtsc3PlpInfo info;
456 info.plpId = 1;
457 info.bLlsFlag = false;
458 vector<FrontendScanAtsc3PlpInfo> atsc3PlpInfos = {info};
459 msg.set<FrontendScanMessage::Tag::atsc3PlpInfos>(atsc3PlpInfos);
460 mCallback->onScanMessage(FrontendScanMessageType::ATSC3_PLP_INFO, msg);
461 }
462
463 {
464 FrontendScanMessage msg;
465 FrontendModulation modulation;
466 modulation.set<FrontendModulation::Tag::dvbc>(FrontendDvbcModulation::MOD_16QAM);
467 msg.set<FrontendScanMessage::Tag::modulation>(modulation);
468 mCallback->onScanMessage(FrontendScanMessageType::MODULATION, msg);
469 }
470
471 {
472 FrontendScanMessage msg;
473 msg.set<FrontendScanMessage::Tag::isHighPriority>(true);
474 mCallback->onScanMessage(FrontendScanMessageType::HIGH_PRIORITY, msg);
475 }
476
Hongguang7eda7822021-12-20 14:48:14 -0800477 if (mType == FrontendType::DVBT) {
478 FrontendScanMessage msg;
479 vector<int32_t> dvbtCellIds = {0, 1};
480 msg.set<FrontendScanMessage::Tag::dvbtCellIds>(dvbtCellIds);
481 mCallback->onScanMessage(FrontendScanMessageType::DVBT_CELL_IDS, msg);
482 }
483
Hongguang4092f2f2021-07-08 18:49:12 -0700484 {
485 FrontendScanMessage msg;
Hongguangc8438c02022-01-28 19:05:34 -0800486 msg.set<FrontendScanMessage::Tag::isLocked>(false);
487 mCallback->onScanMessage(FrontendScanMessageType::LOCKED, msg);
488 mIsLocked = false;
489 }
490
491 {
492 FrontendScanMessage msg;
Hongguang4092f2f2021-07-08 18:49:12 -0700493 msg.set<FrontendScanMessage::Tag::isLocked>(true);
494 mCallback->onScanMessage(FrontendScanMessageType::LOCKED, msg);
495 mIsLocked = true;
496 }
Hongguang4092f2f2021-07-08 18:49:12 -0700497}
498
499::ndk::ScopedAStatus Frontend::stopScan() {
500 ALOGV("%s", __FUNCTION__);
501
Hongguang6c09bff2021-12-23 10:50:03 -0800502 if (mScanThread.joinable()) {
503 mScanThread.join();
504 }
505
Hongguang4092f2f2021-07-08 18:49:12 -0700506 mIsLocked = false;
507 return ::ndk::ScopedAStatus::ok();
508}
509
510::ndk::ScopedAStatus Frontend::getStatus(const std::vector<FrontendStatusType>& in_statusTypes,
511 std::vector<FrontendStatus>* _aidl_return) {
512 ALOGV("%s", __FUNCTION__);
513
514 for (int i = 0; i < in_statusTypes.size(); i++) {
515 FrontendStatusType type = in_statusTypes[i];
516 FrontendStatus status;
517 // assign randomly selected values for testing.
518 switch (type) {
519 case FrontendStatusType::DEMOD_LOCK: {
520 status.set<FrontendStatus::isDemodLocked>(true);
521 break;
522 }
523 case FrontendStatusType::SNR: {
524 status.set<FrontendStatus::snr>(221);
525 break;
526 }
527 case FrontendStatusType::BER: {
528 status.set<FrontendStatus::ber>(1);
529 break;
530 }
531 case FrontendStatusType::PER: {
532 status.set<FrontendStatus::per>(2);
533 break;
534 }
535 case FrontendStatusType::PRE_BER: {
536 status.set<FrontendStatus::preBer>(3);
537 break;
538 }
539 case FrontendStatusType::SIGNAL_QUALITY: {
540 status.set<FrontendStatus::signalQuality>(4);
541 break;
542 }
543 case FrontendStatusType::SIGNAL_STRENGTH: {
544 status.set<FrontendStatus::signalStrength>(5);
545 break;
546 }
547 case FrontendStatusType::SYMBOL_RATE: {
548 status.set<FrontendStatus::symbolRate>(6);
549 break;
550 }
551 case FrontendStatusType::FEC: {
552 status.set<FrontendStatus::innerFec>(FrontendInnerFec::FEC_2_9); // value = 1 << 7
553 break;
554 }
555 case FrontendStatusType::MODULATION: {
556 switch (mType) {
557 case FrontendType::ISDBS: {
558 FrontendModulationStatus modulationStatus;
559 modulationStatus.set<FrontendModulationStatus::Tag::isdbs>(
560 FrontendIsdbsModulation::MOD_BPSK); // value = 1 << 1
561 status.set<FrontendStatus::modulationStatus>(modulationStatus);
562 break;
563 }
564 case FrontendType::DVBC: {
565 FrontendModulationStatus modulationStatus;
566 modulationStatus.set<FrontendModulationStatus::Tag::dvbc>(
567 FrontendDvbcModulation::MOD_16QAM); // value = 1 << 1
568 status.set<FrontendStatus::modulationStatus>(modulationStatus);
569 break;
570 }
571 case FrontendType::DVBS: {
572 FrontendModulationStatus modulationStatus;
573 modulationStatus.set<FrontendModulationStatus::Tag::dvbs>(
574 FrontendDvbsModulation::MOD_QPSK); // value = 1 << 1
575 status.set<FrontendStatus::modulationStatus>(modulationStatus);
576 break;
577 }
578 case FrontendType::ISDBS3: {
579 FrontendModulationStatus modulationStatus;
580 modulationStatus.set<FrontendModulationStatus::Tag::isdbs3>(
581 FrontendIsdbs3Modulation::MOD_BPSK); // value = 1 << 1
582 status.set<FrontendStatus::modulationStatus>(modulationStatus);
583 break;
584 }
585 case FrontendType::ISDBT: {
586 FrontendModulationStatus modulationStatus;
587 modulationStatus.set<FrontendModulationStatus::Tag::isdbt>(
588 FrontendIsdbtModulation::MOD_DQPSK); // value = 1 << 1
589 status.set<FrontendStatus::modulationStatus>(modulationStatus);
590 break;
591 }
592 default:
593 break;
594 }
595 break;
596 }
597 case FrontendStatusType::SPECTRAL: {
598 status.set<FrontendStatus::inversion>(FrontendSpectralInversion::NORMAL);
599 break;
600 }
601 case FrontendStatusType::LNB_VOLTAGE: {
602 status.set<FrontendStatus::lnbVoltage>(LnbVoltage::VOLTAGE_5V);
603 break;
604 }
605 case FrontendStatusType::PLP_ID: {
Hongguang11da2cb2021-08-05 19:05:12 -0700606 status.set<FrontendStatus::plpId>(101);
Hongguang4092f2f2021-07-08 18:49:12 -0700607 break;
608 }
609 case FrontendStatusType::EWBS: {
610 status.set<FrontendStatus::isEWBS>(false);
611 break;
612 }
613 case FrontendStatusType::AGC: {
614 status.set<FrontendStatus::agc>(7);
615 break;
616 }
617 case FrontendStatusType::LNA: {
618 status.set<FrontendStatus::isLnaOn>(false);
619 break;
620 }
621 case FrontendStatusType::LAYER_ERROR: {
622 vector<bool> v = {false, true, true};
623 status.set<FrontendStatus::isLayerError>(v);
624 break;
625 }
626 case FrontendStatusType::MER: {
627 status.set<FrontendStatus::mer>(8);
628 break;
629 }
630 case FrontendStatusType::FREQ_OFFSET: {
631 status.set<FrontendStatus::freqOffset>(9);
632 break;
633 }
634 case FrontendStatusType::HIERARCHY: {
635 status.set<FrontendStatus::hierarchy>(FrontendDvbtHierarchy::HIERARCHY_1_NATIVE);
636 break;
637 }
638 case FrontendStatusType::RF_LOCK: {
639 status.set<FrontendStatus::isRfLocked>(false);
640 break;
641 }
642 case FrontendStatusType::ATSC3_PLP_INFO: {
643 FrontendStatusAtsc3PlpInfo info1;
644 info1.plpId = 3;
645 info1.isLocked = false;
646 info1.uec = 313;
647 FrontendStatusAtsc3PlpInfo info2;
648 info2.plpId = 5;
649 info2.isLocked = true;
650 info2.uec = 515;
651 vector<FrontendStatusAtsc3PlpInfo> infos = {info1, info2};
652 status.set<FrontendStatus::plpInfo>(infos);
653 break;
654 }
655 case FrontendStatusType::MODULATIONS: {
656 FrontendModulation modulation;
657 vector<FrontendModulation> modulations;
658 switch (mType) {
659 case FrontendType::ISDBS: {
660 modulation.set<FrontendModulation::Tag::isdbs>(
661 FrontendIsdbsModulation::MOD_BPSK); // value = 1 << 1
662 modulations.push_back(modulation);
663 status.set<FrontendStatus::modulations>(modulations);
664 break;
665 }
666 case FrontendType::DVBC: {
667 modulation.set<FrontendModulation::Tag::dvbc>(
668 FrontendDvbcModulation::MOD_16QAM); // value = 1 << 1
669 modulations.push_back(modulation);
670 status.set<FrontendStatus::modulations>(modulations);
671 break;
672 }
673 case FrontendType::DVBS: {
674 modulation.set<FrontendModulation::Tag::dvbs>(
675 FrontendDvbsModulation::MOD_QPSK); // value = 1 << 1
676 modulations.push_back(modulation);
677 status.set<FrontendStatus::modulations>(modulations);
678 break;
679 }
680 case FrontendType::DVBT: {
681 modulation.set<FrontendModulation::Tag::dvbt>(
682 FrontendDvbtConstellation::CONSTELLATION_16QAM_R); // value = 1 <<
683 // 16
684 modulations.push_back(modulation);
685 status.set<FrontendStatus::modulations>(modulations);
686 break;
687 }
688 case FrontendType::ISDBS3: {
689 modulation.set<FrontendModulation::Tag::isdbs3>(
690 FrontendIsdbs3Modulation::MOD_BPSK); // value = 1 << 1
691 modulations.push_back(modulation);
692 status.set<FrontendStatus::modulations>(modulations);
693 break;
694 }
695 case FrontendType::ISDBT: {
696 modulation.set<FrontendModulation::Tag::isdbt>(
697 FrontendIsdbtModulation::MOD_DQPSK); // value = 1 << 1
698 modulations.push_back(modulation);
699 status.set<FrontendStatus::modulations>(modulations);
700 break;
701 }
702 case FrontendType::ATSC: {
703 modulation.set<FrontendModulation::Tag::atsc>(
704 FrontendAtscModulation::MOD_8VSB); // value = 1 << 2
705 modulations.push_back(modulation);
706 status.set<FrontendStatus::modulations>(modulations);
707 break;
708 }
709 case FrontendType::ATSC3: {
710 modulation.set<FrontendModulation::Tag::atsc3>(
711 FrontendAtsc3Modulation::MOD_QPSK); // value = 1 << 1
712 modulations.push_back(modulation);
713 status.set<FrontendStatus::modulations>(modulations);
714 break;
715 }
716 case FrontendType::DTMB: {
717 modulation.set<FrontendModulation::Tag::dtmb>(
718 FrontendDtmbModulation::CONSTELLATION_4QAM); // value = 1 << 1
719 modulations.push_back(modulation);
720 status.set<FrontendStatus::modulations>(modulations);
721 break;
722 }
723 default:
724 break;
725 }
726 break;
727 }
728 case FrontendStatusType::BERS: {
729 vector<int32_t> bers = {1};
730 status.set<FrontendStatus::bers>(bers);
731 break;
732 }
733 case FrontendStatusType::CODERATES: {
734 vector<FrontendInnerFec> rates;
735 rates.push_back(FrontendInnerFec::FEC_6_15); // value = 1 << 39
736 status.set<FrontendStatus::codeRates>(rates);
737 break;
738 }
739 case FrontendStatusType::BANDWIDTH: {
740 FrontendBandwidth bandwidth;
741 switch (mType) {
742 case FrontendType::DVBC: {
743 bandwidth.set<FrontendBandwidth::Tag::dvbc>(
744 FrontendDvbcBandwidth::BANDWIDTH_6MHZ); // value = 1 << 1
745 status.set<FrontendStatus::bandwidth>(bandwidth);
746 break;
747 }
748 case FrontendType::DVBT: {
749 bandwidth.set<FrontendBandwidth::Tag::dvbt>(
750 FrontendDvbtBandwidth::BANDWIDTH_8MHZ); // value = 1 << 1
751 status.set<FrontendStatus::bandwidth>(bandwidth);
752 break;
753 }
754 case FrontendType::ISDBT: {
755 bandwidth.set<FrontendBandwidth::Tag::isdbt>(
756 FrontendIsdbtBandwidth::BANDWIDTH_8MHZ); // value = 1 << 1
757 status.set<FrontendStatus::bandwidth>(bandwidth);
758 break;
759 }
760 case FrontendType::ATSC3: {
761 bandwidth.set<FrontendBandwidth::Tag::atsc3>(
762 FrontendAtsc3Bandwidth::BANDWIDTH_6MHZ); // value = 1 << 1
763 status.set<FrontendStatus::bandwidth>(bandwidth);
764 break;
765 }
766 case FrontendType::DTMB: {
767 bandwidth.set<FrontendBandwidth::Tag::dtmb>(
768 FrontendDtmbBandwidth::BANDWIDTH_8MHZ); // value = 1 << 1
769 status.set<FrontendStatus::bandwidth>(bandwidth);
770 break;
771 }
772 default:
773 break;
774 }
775 break;
776 }
777 case FrontendStatusType::GUARD_INTERVAL: {
778 FrontendGuardInterval interval;
779 switch (mType) {
780 case FrontendType::DVBT: {
781 interval.set<FrontendGuardInterval::Tag::dvbt>(
782 FrontendDvbtGuardInterval::INTERVAL_1_32); // value = 1 << 1
783 status.set<FrontendStatus::interval>(interval);
784 break;
785 }
786 case FrontendType::ISDBT: {
787 interval.set<FrontendGuardInterval::Tag::isdbt>(
Hongguange69a3b22021-08-03 14:23:42 -0700788 FrontendIsdbtGuardInterval::INTERVAL_1_32); // value = 1 << 1
Hongguang4092f2f2021-07-08 18:49:12 -0700789 status.set<FrontendStatus::interval>(interval);
790 break;
791 }
792 case FrontendType::DTMB: {
793 interval.set<FrontendGuardInterval::Tag::dtmb>(
794 FrontendDtmbGuardInterval::PN_420_VARIOUS); // value = 1 << 1
795 status.set<FrontendStatus::interval>(interval);
796 break;
797 }
798 default:
799 break;
800 }
801 break;
802 }
803 case FrontendStatusType::TRANSMISSION_MODE: {
804 FrontendTransmissionMode transMode;
805 switch (mType) {
806 case FrontendType::DVBT: {
807 transMode.set<FrontendTransmissionMode::Tag::dvbt>(
808 FrontendDvbtTransmissionMode::MODE_16K_E); // value = 1 << 8
809 status.set<FrontendStatus::transmissionMode>(transMode);
810 break;
811 }
812 case FrontendType::ISDBT: {
813 transMode.set<FrontendTransmissionMode::Tag::isdbt>(
814 FrontendIsdbtMode::MODE_1); // value = 1 << 1
815 status.set<FrontendStatus::transmissionMode>(transMode);
816 break;
817 }
818 case FrontendType::DTMB: {
819 transMode.set<FrontendTransmissionMode::Tag::dtmb>(
820 FrontendDtmbTransmissionMode::C1); // value = 1 << 1
821 status.set<FrontendStatus::transmissionMode>(transMode);
822 break;
823 }
824 default:
825 break;
826 }
827 break;
828 }
829 case FrontendStatusType::UEC: {
830 status.set<FrontendStatus::uec>(4);
831 break;
832 }
833 case FrontendStatusType::T2_SYSTEM_ID: {
834 status.set<FrontendStatus::systemId>(5);
835 break;
836 }
837 case FrontendStatusType::INTERLEAVINGS: {
838 FrontendInterleaveMode interleave;
839 vector<FrontendInterleaveMode> interleaves;
840 switch (mType) {
841 case FrontendType::DVBC: {
842 // value = 1 << 1
843 interleave.set<FrontendInterleaveMode::Tag::dvbc>(
844 FrontendCableTimeInterleaveMode::INTERLEAVING_128_1_0);
845 interleaves.push_back(interleave);
846 status.set<FrontendStatus::interleaving>(interleaves);
847 break;
848 }
849 case FrontendType::ATSC3: {
850 interleave.set<FrontendInterleaveMode::Tag::atsc3>(
851 FrontendAtsc3TimeInterleaveMode::CTI); // value = 1 << 1
852 interleaves.push_back(interleave);
853 status.set<FrontendStatus::interleaving>(interleaves);
854 break;
855 }
856 case FrontendType::DTMB: {
857 interleave.set<FrontendInterleaveMode::Tag::dtmb>(
858 FrontendDtmbTimeInterleaveMode::TIMER_INT_240); // value = 1 << 1
859 interleaves.push_back(interleave);
860 status.set<FrontendStatus::interleaving>(interleaves);
861 break;
862 }
Hongguang788284f2021-10-28 15:03:29 -0700863 case FrontendType::ISDBT: {
864 interleave.set<FrontendInterleaveMode::Tag::isdbt>(
865 FrontendIsdbtTimeInterleaveMode::INTERLEAVE_1_0); // value = 1 << 1
866 interleaves.push_back(interleave);
867 status.set<FrontendStatus::interleaving>(interleaves);
868 break;
869 }
Hongguang4092f2f2021-07-08 18:49:12 -0700870 default:
871 break;
872 }
873 break;
874 }
875 case FrontendStatusType::ISDBT_SEGMENTS: {
Hongguang11da2cb2021-08-05 19:05:12 -0700876 vector<int32_t> segments = {2, 3};
Hongguang4092f2f2021-07-08 18:49:12 -0700877 status.set<FrontendStatus::isdbtSegment>(segments);
878 break;
879 }
880 case FrontendStatusType::TS_DATA_RATES: {
881 vector<int32_t> dataRates = {4, 5};
882 status.set<FrontendStatus::tsDataRate>(dataRates);
883 break;
884 }
885 case FrontendStatusType::ROLL_OFF: {
886 FrontendRollOff rollOff;
887 switch (mType) {
888 case FrontendType::DVBS: {
889 rollOff.set<FrontendRollOff::Tag::dvbs>(
890 FrontendDvbsRolloff::ROLLOFF_0_35); // value = 1
891 status.set<FrontendStatus::rollOff>(rollOff);
892 break;
893 }
894 case FrontendType::ISDBS: {
895 rollOff.set<FrontendRollOff::Tag::isdbs>(
896 FrontendIsdbsRolloff::ROLLOFF_0_35); // value = 1
897 status.set<FrontendStatus::rollOff>(rollOff);
898 break;
899 }
900 case FrontendType::ISDBS3: {
901 rollOff.set<FrontendRollOff::Tag::isdbs3>(
902 FrontendIsdbs3Rolloff::ROLLOFF_0_03); // value = 1
903 status.set<FrontendStatus::rollOff>(rollOff);
904 break;
905 }
906 default:
907 break;
908 }
909 break;
910 }
911 case FrontendStatusType::IS_MISO: {
912 status.set<FrontendStatus::isMiso>(true);
913 break;
914 }
915 case FrontendStatusType::IS_LINEAR: {
916 status.set<FrontendStatus::isLinear>(true);
917 break;
918 }
919 case FrontendStatusType::IS_SHORT_FRAMES: {
920 status.set<FrontendStatus::isShortFrames>(true);
921 break;
922 }
Hongguang788284f2021-10-28 15:03:29 -0700923 case FrontendStatusType::ISDBT_MODE: {
924 status.set<FrontendStatus::isdbtMode>(FrontendIsdbtMode::AUTO);
925 break;
926 }
927 case FrontendStatusType::ISDBT_PARTIAL_RECEPTION_FLAG: {
928 status.set<FrontendStatus::partialReceptionFlag>(
929 FrontendIsdbtPartialReceptionFlag::AUTO);
930 break;
931 }
Hongguang2ecfc392021-11-23 10:29:15 -0800932 case FrontendStatusType::STREAM_ID_LIST: {
933 vector<int32_t> streamIds = {0, 1};
934 status.set<FrontendStatus::streamIdList>(streamIds);
935 break;
936 }
Hongguang7eda7822021-12-20 14:48:14 -0800937 case FrontendStatusType::DVBT_CELL_IDS: {
938 vector<int32_t> dvbtCellIds = {0, 1};
939 status.set<FrontendStatus::dvbtCellIds>(dvbtCellIds);
940 break;
941 }
Hongguangd99c82d2022-01-13 12:42:52 -0800942 case FrontendStatusType::ATSC3_ALL_PLP_INFO: {
943 FrontendScanAtsc3PlpInfo info1;
944 info1.plpId = 1;
945 info1.bLlsFlag = false;
946 FrontendScanAtsc3PlpInfo info2;
947 info2.plpId = 2;
948 info2.bLlsFlag = true;
949 FrontendScanAtsc3PlpInfo info3;
950 info3.plpId = 3;
951 info3.bLlsFlag = false;
952 vector<FrontendScanAtsc3PlpInfo> infos = {info1, info2, info3};
953 status.set<FrontendStatus::allPlpInfo>(infos);
954 break;
955 }
sadiqsadaaff01d72023-01-12 11:02:34 -0800956 case FrontendStatusType::IPTV_CONTENT_URL: {
957 status.set<FrontendStatus::iptvContentUrl>("");
958 break;
959 }
960 case FrontendStatusType::IPTV_PACKETS_LOST: {
961 status.set<FrontendStatus::iptvPacketsLost>(5);
962 break;
963 }
964 case FrontendStatusType::IPTV_PACKETS_RECEIVED: {
965 status.set<FrontendStatus::iptvPacketsReceived>(5);
966 break;
967 }
968 case FrontendStatusType::IPTV_WORST_JITTER_MS: {
969 status.set<FrontendStatus::iptvWorstJitterMs>(5);
970 break;
971 }
972 case FrontendStatusType::IPTV_AVERAGE_JITTER_MS: {
973 status.set<FrontendStatus::iptvAverageJitterMs>(5);
974 break;
975 }
Hongguang4092f2f2021-07-08 18:49:12 -0700976 default: {
977 continue;
978 }
979 }
980 _aidl_return->push_back(status);
981 }
982
983 return ::ndk::ScopedAStatus::ok();
984}
985
Hongguang4092f2f2021-07-08 18:49:12 -0700986::ndk::ScopedAStatus Frontend::setLnb(int32_t /* in_lnbId */) {
987 ALOGV("%s", __FUNCTION__);
988 if (!supportsSatellite()) {
Hongguange423acd2021-07-27 16:56:47 -0700989 return ::ndk::ScopedAStatus::fromServiceSpecificError(
990 static_cast<int32_t>(Result::INVALID_STATE));
Hongguang4092f2f2021-07-08 18:49:12 -0700991 }
992 return ::ndk::ScopedAStatus::ok();
993}
994
995::ndk::ScopedAStatus Frontend::linkCiCam(int32_t in_ciCamId, int32_t* _aidl_return) {
996 ALOGV("%s", __FUNCTION__);
997
998 mCiCamId = in_ciCamId;
999 *_aidl_return = 0;
1000
1001 return ::ndk::ScopedAStatus::ok();
1002}
1003
1004::ndk::ScopedAStatus Frontend::unlinkCiCam(int32_t /* in_ciCamId */) {
1005 ALOGV("%s", __FUNCTION__);
1006
1007 mCiCamId = -1;
1008
1009 return ::ndk::ScopedAStatus::ok();
1010}
1011
Hongguang2ecfc392021-11-23 10:29:15 -08001012binder_status_t Frontend::dump(int fd, const char** /* args */, uint32_t /* numArgs */) {
1013 dprintf(fd, " Frontend %d\n", mId);
1014 dprintf(fd, " mType: %d\n", mType);
1015 dprintf(fd, " mIsLocked: %d\n", mIsLocked);
1016 dprintf(fd, " mCiCamId: %d\n", mCiCamId);
Hongguang881190f2022-01-14 13:23:37 -08001017 dprintf(fd, " mFrontendStatusCaps:");
1018 for (int i = 0; i < mFrontendStatusCaps.size(); i++) {
1019 dprintf(fd, " %d\n", mFrontendStatusCaps[i]);
1020 }
Hongguang2ecfc392021-11-23 10:29:15 -08001021 return STATUS_OK;
1022}
1023
Hongguangfcedda02021-12-13 17:08:02 -08001024::ndk::ScopedAStatus Frontend::getHardwareInfo(std::string* _aidl_return) {
1025 ALOGV("%s", __FUNCTION__);
1026
1027 *_aidl_return = "Sample Frontend";
1028 return ::ndk::ScopedAStatus::ok();
1029}
1030
Hongguange106f472022-01-11 12:09:22 -08001031::ndk::ScopedAStatus Frontend::removeOutputPid(int32_t /* in_pid */) {
1032 ALOGV("%s", __FUNCTION__);
1033
1034 return ::ndk::ScopedAStatus::fromServiceSpecificError(
1035 static_cast<int32_t>(Result::UNAVAILABLE));
1036}
1037
Hongguang881190f2022-01-14 13:23:37 -08001038::ndk::ScopedAStatus Frontend::getFrontendStatusReadiness(
1039 const std::vector<FrontendStatusType>& in_statusTypes,
1040 std::vector<FrontendStatusReadiness>* _aidl_return) {
1041 ALOGV("%s", __FUNCTION__);
1042
1043 _aidl_return->resize(in_statusTypes.size());
1044 for (int i = 0; i < in_statusTypes.size(); i++) {
1045 int j = 0;
1046 while (j < mFrontendStatusCaps.size()) {
1047 if (in_statusTypes[i] == mFrontendStatusCaps[j]) {
1048 (*_aidl_return)[i] = FrontendStatusReadiness::STABLE;
1049 break;
1050 }
1051 j++;
1052 }
1053 if (j >= mFrontendStatusCaps.size()) {
1054 (*_aidl_return)[i] = FrontendStatusReadiness::UNSUPPORTED;
1055 }
1056 }
1057
1058 return ::ndk::ScopedAStatus::ok();
1059}
1060
Hongguang4092f2f2021-07-08 18:49:12 -07001061FrontendType Frontend::getFrontendType() {
1062 return mType;
1063}
1064
1065int32_t Frontend::getFrontendId() {
1066 return mId;
1067}
1068
sadiqsada56c98292023-11-02 16:45:31 -07001069dtv_plugin* Frontend::getIptvPluginInterface() {
1070 return mIptvPluginInterface;
1071}
1072
1073string Frontend::getIptvTransportDescription() {
1074 return mIptvTransportDescription;
1075}
1076
1077dtv_streamer* Frontend::getIptvPluginStreamer() {
1078 return mIptvPluginStreamer;
1079}
1080
Hongguang4092f2f2021-07-08 18:49:12 -07001081bool Frontend::supportsSatellite() {
1082 return mType == FrontendType::DVBS || mType == FrontendType::ISDBS ||
1083 mType == FrontendType::ISDBS3;
1084}
1085
1086bool Frontend::isLocked() {
1087 return mIsLocked;
1088}
1089
Hongguang881190f2022-01-14 13:23:37 -08001090void Frontend::getFrontendInfo(FrontendInfo* _aidl_return) {
1091 // assign randomly selected values for testing.
1092 *_aidl_return = {
1093 .type = mType,
1094 .minFrequency = 139000000,
1095 .maxFrequency = 1139000000,
1096 .minSymbolRate = 45,
1097 .maxSymbolRate = 1145,
1098 .acquireRange = 30,
1099 .exclusiveGroupId = 57,
1100 .statusCaps = mFrontendStatusCaps,
1101 .frontendCaps = mFrontendCaps,
1102 };
1103}
1104
Hongguang4092f2f2021-07-08 18:49:12 -07001105} // namespace tuner
1106} // namespace tv
1107} // namespace hardware
1108} // namespace android
1109} // namespace aidl