blob: bb2a4b652798db7f5e51acde3d01caeeb4da41e3 [file] [log] [blame]
Naseer Ahmed58780b92013-07-29 17:41:40 -04001/*
Zohaib Alam1bb65612013-09-28 03:38:20 -04002* Copyright (c) 2013-2014 The Linux Foundation. All rights reserved.
Naseer Ahmed58780b92013-07-29 17:41:40 -04003*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are
6* met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above
10* copyright notice, this list of conditions and the following
11* disclaimer in the documentation and/or other materials provided
12* with the distribution.
13* * Neither the name of The Linux Foundation. nor the names of its
14* contributors may be used to endorse or promote products derived
15* from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30#ifndef HWC_VPU_H
31#define HWC_VPU_H
32
33#include <sys/types.h>
Zohaib Alam1bb65612013-09-28 03:38:20 -040034#include "hwc_utils.h"
35
36#define MAX_PIPES_PER_LAYER 2
Naseer Ahmed58780b92013-07-29 17:41:40 -040037
38//Forward declarations
39struct hwc_display_contents_1;
40typedef struct hwc_display_contents_1 hwc_display_contents_1_t;
Zohaib Alam1bb65612013-09-28 03:38:20 -040041struct hwc_layer_1;
42typedef struct hwc_layer_1 hwc_layer_1_t;
Naseer Ahmed58780b92013-07-29 17:41:40 -040043struct hwc_context_t;
Zohaib Alam1bb65612013-09-28 03:38:20 -040044
Naseer Ahmed58780b92013-07-29 17:41:40 -040045namespace vpu {
46class VPU;
Zohaib Alam1bb65612013-09-28 03:38:20 -040047struct LayerList;
Naseer Ahmed58780b92013-07-29 17:41:40 -040048};
Naseer Ahmed4957c522013-11-12 18:07:15 -050049namespace android {
50class Parcel;
51};
Naseer Ahmed58780b92013-07-29 17:41:40 -040052
53namespace qhwc {
54
55class VPUClient {
56public:
Zohaib Alam1bb65612013-09-28 03:38:20 -040057 VPUClient(hwc_context_t *ctx);
Naseer Ahmed58780b92013-07-29 17:41:40 -040058
59 ~VPUClient();
60
Zohaib Alam1bb65612013-09-28 03:38:20 -040061 int setupVpuSession(hwc_context_t *ctx, int display,
62 hwc_display_contents_1_t* list);
63 int prepare(hwc_context_t *ctx, int display,
64 hwc_display_contents_1_t* list);
65 int predraw(hwc_context_t *ctx, int display,
66 hwc_display_contents_1_t* list);
67 int draw(hwc_context_t *ctx, int display,
68 hwc_display_contents_1_t* list);
Naseer Ahmed4957c522013-11-12 18:07:15 -050069 int processCommand(uint32_t command,
Zohaib Alam1bb65612013-09-28 03:38:20 -040070 const android::Parcel* inParcel, android::Parcel* outParcel);
71 int getLayerFormat(int dpy, hwc_layer_1_t *layer);
72 int getWidth(int dpy, hwc_layer_1_t *layer);
73 int getHeight(int dpy, hwc_layer_1_t *layer);
74 bool supportedVPULayer(int dpy, hwc_layer_1_t *layer);
Naseer Ahmed58780b92013-07-29 17:41:40 -040075
76private:
77 vpu::VPU *mVPU;
78 void* mVPULib;
79
Zohaib Alam1bb65612013-09-28 03:38:20 -040080 /* VpuLayerProp struct:
81 * This struct corresponds to only one layer
82 * pipeCount: number of pipes required for a layer
83 * pipeID[]: pipe ids corresponding to the layer
84 */
85 struct VpuLayerProp {
86 int format;
87 int width;
88 int height;
89 int pipeCount;
90 bool vpuLayer;
91 bool firstBuffer;
92 hwc_frect_t sourceCropf;
93 hwc_layer_1_t *layer;
94 int pipeID[MAX_PIPES_PER_LAYER];
95 int dest[MAX_PIPES_PER_LAYER];
96 };
97 int mNumVpuLayers; /* total num of vpu supported layers */
98 int mGpuFallback; /* all layers are not supported by vpu */
99
100 VpuLayerProp mProp[HWC_NUM_DISPLAY_TYPES][MAX_NUM_APP_LAYERS];
101 int mDebugLogs;
102 private_handle_t *mHnd[HWC_NUM_DISPLAY_TYPES][MAX_NUM_APP_LAYERS];
103 vpu::LayerList *vList[HWC_NUM_DISPLAY_TYPES];
104
105 /* Private debug functions */
106 int32_t isDebug() { return (mDebugLogs >= 1); }
107 int32_t isDebug2() { return (mDebugLogs >= 2); }
108
109 /* Private Get/Set functions */
110 int getLayerIdx(int dpy, hwc_layer_1_t *layer);
111 void getPipeId(VpuLayerProp* prop, int &pipe);
112 void getPipeId(VpuLayerProp* prop, int &lPipe, int &rPipe);
113 int getDest(VpuLayerProp* prop, int pipenum);
114 void setPipeCount(VpuLayerProp* prop, int count);
115 void setPipeId(VpuLayerProp* prop, int lPipeId, int rPipeId);
116 void setPipeId(VpuLayerProp* prop, int pipeId);
117 void setDest(VpuLayerProp* prop, int lDest, int rDest);
118 void setDest(VpuLayerProp* prop, int dest);
119
120 /* Private implementations */
121 bool supportedVPULayer(VpuLayerProp* prop);
122 bool allocResLayerPipes(hwc_context_t* ctx, int dpy,
123 hwc_display_contents_1_t* list);
124 bool allocLayerPipes(hwc_context_t* ctx, int dpy,
125 hwc_display_contents_1_t* list);
126 bool allocResLayerPipesSplit(hwc_context_t* ctx, int dpy,
127 hwc_display_contents_1_t* list);
128 bool allocLayerPipesSplit(hwc_context_t* ctx, int dpy,
129 hwc_display_contents_1_t* list);
130 bool configureLayers(hwc_context_t* ctx, int dpy,
131 hwc_display_contents_1_t* list);
132 bool configureLayersSplit(hwc_context_t* ctx, int dpy,
133 hwc_display_contents_1_t* list);
134 void setMDPCompLayerFlags(hwc_context_t *ctx, int dpy,
135 hwc_display_contents_1_t* list);
136 bool drawDummyLayers(hwc_context_t* ctx, int dpy,
137 hwc_display_contents_1_t* list);
138 bool queueHandle(hwc_context_t* ctx, VpuLayerProp* prop,
139 private_handle_t* hnd);
140 bool queueHandleSplit(hwc_context_t* ctx, VpuLayerProp* prop,
141 private_handle_t* hnd);
Naseer Ahmed58780b92013-07-29 17:41:40 -0400142}; // class VPU
143}; // namespace qhwc
144#endif /* end of include guard: HWC_VPU_H */