blob: 1e07eddbfe377f0a8699da8d5240c758d8c3c6d9 [file] [log] [blame]
Amy126ee922019-08-09 16:25:12 -07001/*
2 * Copyright (C) 2019 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_TAG "android.hardware.tv.tuner@1.0-Frontend"
18
19#include "Frontend.h"
20#include <android/hardware/tv/tuner/1.0/IFrontendCallback.h>
21#include <utils/Log.h>
22
23namespace android {
24namespace hardware {
25namespace tv {
26namespace tuner {
27namespace V1_0 {
28namespace implementation {
29
Amy5094ae12019-10-04 18:43:21 -070030Frontend::Frontend(FrontendType type, FrontendId id, sp<Tuner> tuner) {
Amy126ee922019-08-09 16:25:12 -070031 mType = type;
32 mId = id;
Amy5094ae12019-10-04 18:43:21 -070033 mTunerService = tuner;
Amy126ee922019-08-09 16:25:12 -070034 // Init callback to nullptr
35 mCallback = nullptr;
36}
37
38Frontend::~Frontend() {}
39
40Return<Result> Frontend::close() {
41 ALOGV("%s", __FUNCTION__);
42 // Reset callback
43 mCallback = nullptr;
44
45 return Result::SUCCESS;
46}
47
48Return<Result> Frontend::setCallback(const sp<IFrontendCallback>& callback) {
49 ALOGV("%s", __FUNCTION__);
50 if (callback == nullptr) {
51 ALOGW("[ WARN ] Set Frontend callback with nullptr");
52 return Result::INVALID_ARGUMENT;
53 }
54
55 mCallback = callback;
56 return Result::SUCCESS;
57}
58
59Return<Result> Frontend::tune(const FrontendSettings& /* settings */) {
60 ALOGV("%s", __FUNCTION__);
61 if (mCallback == nullptr) {
62 ALOGW("[ WARN ] Frontend callback is not set when tune");
63 return Result::INVALID_STATE;
64 }
65
Amy5094ae12019-10-04 18:43:21 -070066 // TODO dynamically allocate file to the source file
67 mSourceStreamFile = FRONTEND_STREAM_FILE;
68
69 mCallback->onEvent(FrontendEventType::LOCKED);
Amy126ee922019-08-09 16:25:12 -070070 return Result::SUCCESS;
71}
72
73Return<Result> Frontend::stopTune() {
74 ALOGV("%s", __FUNCTION__);
75
Amy5094ae12019-10-04 18:43:21 -070076 mTunerService->frontendStopTune(mId);
77
Amy126ee922019-08-09 16:25:12 -070078 return Result::SUCCESS;
79}
80
Amy016b7312019-09-16 15:51:28 -070081Return<Result> Frontend::scan(const FrontendSettings& /* settings */, FrontendScanType /* type */) {
82 ALOGV("%s", __FUNCTION__);
83
84 return Result::SUCCESS;
85}
86
87Return<Result> Frontend::stopScan() {
88 ALOGV("%s", __FUNCTION__);
89
90 return Result::SUCCESS;
91}
92
93Return<void> Frontend::getStatus(const hidl_vec<FrontendStatusType>& /* statusTypes */,
94 getStatus_cb _hidl_cb) {
95 ALOGV("%s", __FUNCTION__);
96
97 vector<FrontendStatus> statuses;
98 _hidl_cb(Result::SUCCESS, statuses);
99
100 return Void();
101}
102
103Return<Result> Frontend::setLna(bool /* bEnable */) {
104 ALOGV("%s", __FUNCTION__);
105
106 return Result::SUCCESS;
107}
108
Amy42a5b4b2019-10-03 16:49:48 -0700109Return<Result> Frontend::setLnb(uint32_t /* lnb */) {
Amy016b7312019-09-16 15:51:28 -0700110 ALOGV("%s", __FUNCTION__);
111
112 return Result::SUCCESS;
113}
114
Amy126ee922019-08-09 16:25:12 -0700115FrontendType Frontend::getFrontendType() {
116 return mType;
117}
118
119FrontendId Frontend::getFrontendId() {
120 return mId;
121}
122
Amy5094ae12019-10-04 18:43:21 -0700123string Frontend::getSourceFile() {
124 return mSourceStreamFile;
125}
126
Amy126ee922019-08-09 16:25:12 -0700127} // namespace implementation
128} // namespace V1_0
129} // namespace tuner
130} // namespace tv
131} // namespace hardware
132} // namespace android