1 /*
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 #ifndef _EXYNOSDEVICEINTERFACE_H
18 #define _EXYNOSDEVICEINTERFACE_H
19 
20 #include "ExynosHWCHelper.h"
21 #include "ExynosDisplayInterface.h"
22 
23 struct hwc_dpp_size_range {
24   uint32_t min;
25   uint32_t max;
26   uint32_t align;
27 };
28 
29 struct hwc_dpp_restriction {
30   struct hwc_dpp_size_range src_f_w;
31   struct hwc_dpp_size_range src_f_h;
32   struct hwc_dpp_size_range src_w;
33   struct hwc_dpp_size_range src_h;
34   uint32_t src_x_align;
35   uint32_t src_y_align;
36   struct hwc_dpp_size_range dst_f_w;
37   struct hwc_dpp_size_range dst_f_h;
38   struct hwc_dpp_size_range dst_w;
39   struct hwc_dpp_size_range dst_h;
40   uint32_t dst_x_align;
41   uint32_t dst_y_align;
42   struct hwc_dpp_size_range blk_w;
43   struct hwc_dpp_size_range blk_h;
44   uint32_t blk_x_align;
45   uint32_t blk_y_align;
46   uint32_t src_h_rot_max;
47   std::vector<uint32_t> formats;
48   uint32_t scale_down;
49   uint32_t scale_up;
50 };
51 
52 struct hwc_dpp_ch_restriction {
53   int id;
54   unsigned long attr;
55   struct hwc_dpp_restriction restriction;
56 };
57 
58 struct hwc_dpp_restrictions_info {
59   uint32_t ver;
60   std::vector<hwc_dpp_ch_restriction> dpp_chs;
61   uint32_t ppc = 0;
62   uint32_t max_disp_freq = 0;
63 };
64 
65 /* for restriction query */
66 typedef struct dpu_dpp_info {
67     struct hwc_dpp_restrictions_info dpuInfo;
68     bool overlap[16] = {false, };
69 } dpu_dpp_info_t;
70 
71 class ExynosDevice;
72 class ExynosDeviceInterface {
73     protected:
74         ExynosDevice *mExynosDevice = NULL;
75         bool mUseQuery = false;
76         // Gathered DPU resctrictions
77         dpu_dpp_info_t mDPUInfo;
78     public:
~ExynosDeviceInterface()79         virtual ~ExynosDeviceInterface(){};
80         virtual void init(ExynosDevice *exynosDevice) = 0;
initDisplayInterface(std::unique_ptr<ExynosDisplayInterface> & dispInterface)81         virtual int32_t initDisplayInterface(
82                 std::unique_ptr<ExynosDisplayInterface> &dispInterface)
83         { return 0;};
84         /* Fill mDPUInfo according to interface type */
85         virtual void updateRestrictions() = 0;
getUseQuery()86         virtual bool getUseQuery() { return mUseQuery; };
getExynosDevice()87         ExynosDevice* getExynosDevice() {return mExynosDevice;};
88     protected:
89         /* Make dpu restrictions using mDPUInfo */
90         int32_t makeDPURestrictions();
91         /* Update feature table using mDPUInfo */
92         int32_t updateFeatureTable();
93         /* Print restriction */
94         void printDppRestriction(struct hwc_dpp_ch_restriction res);
95     public:
96         uint32_t mType = INTERFACE_TYPE_NONE;
97 };
98 #endif //_EXYNOSDEVICEINTERFACE_H
99