Add tuner legacy HIDL HAL support.
The AIDL HAL based solution will be the default implementation. The
tuner service will only create the legacy HIDL HAL based implementation
when the HIDL HAL is available.
Bug: 191825295
Test: atest android.media.tv.tuner.cts on both AIDL and HIDL HAL.
Test: sampletunertvinput
Change-Id: I8436ae80721ad943c60b5814b535f3b87a54ccda
diff --git a/services/tuner/TunerHelper.h b/services/tuner/TunerHelper.h
new file mode 100644
index 0000000..0d8d6a5
--- /dev/null
+++ b/services/tuner/TunerHelper.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIA_TUNERDVRHELPER_H
+#define ANDROID_MEDIA_TUNERDVRHELPER_H
+
+#include <aidl/android/media/tv/tunerresourcemanager/TunerFrontendInfo.h>
+#include <utils/String16.h>
+
+using ::aidl::android::media::tv::tunerresourcemanager::TunerFrontendInfo;
+using ::android::String16;
+
+using namespace std;
+
+namespace aidl {
+namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
+
+const static int TUNER_HAL_VERSION_UNKNOWN = 0;
+const static int TUNER_HAL_VERSION_1_0 = 1 << 16;
+const static int TUNER_HAL_VERSION_1_1 = (1 << 16) | 1;
+const static int TUNER_HAL_VERSION_2_0 = 2 << 16;
+
+typedef enum {
+ FRONTEND,
+ LNB,
+ DEMUX,
+ DESCRAMBLER,
+} TunerResourceType;
+
+class TunerHelper {
+public:
+ static bool checkTunerFeature();
+
+ // TODO: update Demux, Descrambler.
+ static void updateTunerResources(const vector<TunerFrontendInfo>& feInfos,
+ const vector<int32_t>& lnbHandles);
+ // TODO: create a map between resource id and handles.
+ static int getResourceIdFromHandle(int resourceHandle, int type);
+ static int getResourceHandleFromId(int id, int resourceType);
+
+private:
+ static int32_t sResourceRequestCount;
+};
+
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
+
+#endif // ANDROID_MEDIA_TUNERDVRHELPER_H