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_TUNERDVRHELPER_H
18 #define ANDROID_MEDIA_TUNERDVRHELPER_H
19 
20 #include <aidl/android/media/tv/tunerresourcemanager/TunerDemuxInfo.h>
21 #include <aidl/android/media/tv/tunerresourcemanager/TunerFrontendInfo.h>
22 #include <utils/String16.h>
23 
24 using ::aidl::android::media::tv::tunerresourcemanager::TunerDemuxInfo;
25 using ::aidl::android::media::tv::tunerresourcemanager::TunerFrontendInfo;
26 using ::android::String16;
27 
28 using namespace std;
29 
30 namespace aidl {
31 namespace android {
32 namespace media {
33 namespace tv {
34 namespace tuner {
35 
36 const static int TUNER_HAL_VERSION_UNKNOWN = 0;
37 const static int TUNER_HAL_VERSION_1_0 = 1 << 16;
38 const static int TUNER_HAL_VERSION_1_1 = (1 << 16) | 1;
39 const static int TUNER_HAL_VERSION_2_0 = 2 << 16;
40 
41 // Keep syncing with ShareFilter.java
42 const static int STATUS_INACCESSIBLE = 1 << 7;
43 
44 const static String16 sSharedFilterPermission("android.permission.ACCESS_TV_SHARED_FILTER");
45 
46 typedef enum {
47     FRONTEND,
48     DEMUX,
49     DESCRAMBLER,
50     LNB
51 } TunerResourceType;
52 
53 class TunerHelper {
54 public:
55     static bool checkTunerFeature();
56 
57     // TODO: update Demux, Descrambler.
58     static void updateTunerResources(const vector<TunerFrontendInfo>& feInfos,
59                                      const vector<int32_t>& lnbHandles);
60 
61     static void updateTunerResources(const vector<TunerFrontendInfo>& feInfos,
62                                      const vector<TunerDemuxInfo>& demuxInfos,
63                                      const vector<int32_t>& lnbHandles);
64     // TODO: create a map between resource id and handles.
65     static int getResourceIdFromHandle(int resourceHandle, int type);
66     static int getResourceHandleFromId(int id, int resourceType);
67 
68 private:
69     static int32_t sResourceRequestCount;
70 };
71 
72 }  // namespace tuner
73 }  // namespace tv
74 }  // namespace media
75 }  // namespace android
76 }  // namespace aidl
77 
78 #endif  // ANDROID_MEDIA_TUNERDVRHELPER_H
79