4 #include "ExynosDisplay.h"
5 #include "MppFactory.h"
6 #include <utils/Mutex.h>
7 #include <utils/Thread.h>
8 #include <utils/Condition.h>
9 #include <utils/List.h>
11 #define FIRST_PRESCALER_THRESHOLD 4
12 #define SECOND_PRESCALER_THRESHOLD 8
14 class BufferFreeThread
;
16 eMPPUnsupportedDownScale
= 0x00000001,
17 eMPPUnsupportedHW
= 0x00000002,
18 eMPPUnsupportedRotation
= 0x00000004,
19 eMPPUnsupportedCoordinate
= 0x00000008,
20 eMPPUnsupportedDRMContents
= 0x00000010,
21 eMPPUnsupportedS3DContents
= 0x00000020,
22 eMPPUnsupportedBlending
= 0x00000040,
23 eMPPUnsupportedFormat
= 0x00000080,
24 eMPPNotAlignedDstSize
= 0x00000100,
25 eMPPNotAlignedSrcCropPosition
= 0x00000200,
26 eMPPNotAlignedHStride
= 0x00000400,
27 eMPPNotAlignedVStride
= 0x00000800,
28 eMPPExceedHStrideMaximum
= 0x00001000,
29 eMPPExceedVStrideMaximum
= 0x00002000,
30 eMPPExeedMaxDownScale
= 0x00004000,
31 eMPPExeedMaxDstWidth
= 0x00008000,
32 eMPPExeedMaxDstHeight
= 0x00010000,
33 eMPPExeedMinSrcWidth
= 0x00020000,
34 eMPPExeedMinSrcHeight
= 0x00040000,
35 eMPPExeedMaxUpScale
= 0x00080000,
36 eMPPExeedSrcWCropMax
= 0x00100000,
37 eMPPExeedSrcHCropMax
= 0x00200000,
38 eMPPExeedSrcWCropMin
= 0x00400000,
39 eMPPExeedSrcHCropMin
= 0x00800000,
40 eMPPExeedMinDstHeight
= 0x01000000,
49 ExynosMPP(ExynosDisplay
*display
, int gscIndex
);
52 static bool isSrcConfigChanged(exynos_mpp_img
&c1
, exynos_mpp_img
&c2
);
53 virtual bool isFormatSupportedByGsc(int format
);
54 bool formatRequiresGsc(int format
);
55 static bool isFormatSupportedByGscOtf(int format
);
57 virtual bool rotationSupported(bool rotation
);
58 virtual bool paritySupported(int w
, int h
);
60 virtual bool isProcessingRequired(hwc_layer_1_t
&layer
, int format
);
61 virtual int getDownscaleRatio(int *numerator
, int *denominator
);
62 virtual int isProcessingSupported(hwc_layer_1_t
&layer
, int format
, bool otf
, int downNumerator
= 1, int downDenominator
= 16);
63 #ifdef USES_VIRTUAL_DISPLAY
64 virtual int processM2M(hwc_layer_1_t
&layer
, int dstFormat
, hwc_frect_t
*sourceCrop
, bool isNeedBufferAlloc
= true);
66 virtual int processM2M(hwc_layer_1_t
&layer
, int dstFormat
, hwc_frect_t
*sourceCrop
);
68 virtual int processOTF(hwc_layer_1_t
&layer
);
69 virtual void cleanupM2M();
70 virtual void cleanupM2M(bool noFenceWait
);
71 virtual void cleanupOTF();
73 virtual int getAdjustedCrop(int rawSrcSize
, int dstSize
, int format
, bool isVertical
, bool isRotated
);
77 virtual bool isUsingMSC();
78 void setMode(int mode
);
80 bool bufferChanged(hwc_layer_1_t
&layer
);
91 ExynosDisplay
*mDisplay
;
92 exynos_mpp_img mSrcConfig
;
93 exynos_mpp_img mMidConfig
;
94 exynos_mpp_img mDstConfig
;
95 buffer_handle_t mDstBuffers
[NUM_GSC_DST_BUFS
];
96 buffer_handle_t mMidBuffers
[NUM_GSC_DST_BUFS
];
97 int mDstBufFence
[NUM_GSC_DST_BUFS
];
98 int mMidBufFence
[NUM_GSC_DST_BUFS
];
101 ptrdiff_t mLastGSCLayerHandle
;
103 bool mDoubleOperation
;
104 android::List
<buffer_handle_t
> mFreedBuffers
;
105 BufferFreeThread
*mBufferFreeThread
;
106 android::Mutex mMutex
;
107 size_t mNumAvailableDstBuffers
;
111 static bool isDstConfigChanged(exynos_mpp_img
&c1
, exynos_mpp_img
&c2
);
112 static bool isReallocationRequired(int w
, int h
, exynos_mpp_img
&c1
, exynos_mpp_img
&c2
);
113 static int minWidth(hwc_layer_1_t
&layer
);
114 static int minHeight(hwc_layer_1_t
&layer
);
115 int maxWidth(hwc_layer_1_t
&layer
);
116 int maxHeight(hwc_layer_1_t
&layer
);
117 static int srcXOffsetAlign(hwc_layer_1_t
&layer
);
118 static int srcYOffsetAlign(hwc_layer_1_t
&layer
);
120 virtual void setupSource(exynos_mpp_img
&src_img
, hwc_layer_1_t
&layer
);
121 void setupOtfDestination(exynos_mpp_img
&src_img
, exynos_mpp_img
&dst_img
, hwc_layer_1_t
&layer
);
122 int reconfigureOtf(exynos_mpp_img
*src_img
, exynos_mpp_img
*dst_img
);
124 virtual void setupM2MDestination(exynos_mpp_img
&src_img
, exynos_mpp_img
&dst_img
, int dst_format
, hwc_layer_1_t
&layer
, hwc_frect_t
*sourceCrop
);
125 bool setupDoubleOperation(exynos_mpp_img
&src_img
, exynos_mpp_img
&mid_img
, hwc_layer_1_t
&layer
);
126 int reallocateBuffers(private_handle_t
*src_handle
, exynos_mpp_img
&dst_img
, exynos_mpp_img
&mid_img
, bool need_gsc_op_twice
);
129 * Override these virtual functions in chip directory to handle per-chip differences
130 * as well as GSC/FIMC differences
132 virtual uint32_t halFormatToMPPFormat(int format
);
134 virtual int sourceWidthAlign(int format
);
135 virtual int sourceHeightAlign(int format
);
136 virtual int destinationAlign(int format
);
137 virtual bool isSourceCropChanged(exynos_mpp_img
&c1
, exynos_mpp_img
&c2
);
138 virtual bool isPerFrameSrcChanged(exynos_mpp_img
&c1
, exynos_mpp_img
&c2
);
139 virtual bool isPerFrameDstChanged(exynos_mpp_img
&c1
, exynos_mpp_img
&c2
);
141 virtual void *createMPP(int id
, int mode
, int outputMode
, int drm
);
142 virtual int configMPP(void *handle
, exynos_mpp_img
*src
, exynos_mpp_img
*dst
);
143 virtual int runMPP(void *handle
, exynos_mpp_img
*src
, exynos_mpp_img
*dst
);
144 virtual int stopMPP(void *handle
);
145 virtual void destroyMPP(void *handle
);
146 virtual int setCSCProperty(void *handle
, unsigned int eqAuto
, unsigned int fullRange
, unsigned int colorspace
);
147 virtual int freeMPP(void *handle
);
148 virtual int setInputCrop(void *handle
, exynos_mpp_img
*src
, exynos_mpp_img
*dst
);
149 virtual bool isSrcCropAligned(hwc_layer_1_t
&layer
, bool rotation
);
152 size_t visibleWidth(ExynosMPP
*processor
, hwc_layer_1_t
&layer
, int format
,
155 class BufferFreeThread
: public android::Thread
{
157 BufferFreeThread(ExynosMPP
*exynosMPP
): mRunning(false) {mExynosMPP
= exynosMPP
;};
158 virtual bool threadLoop();
160 android::Condition mCondition
;
162 ExynosMPP
*mExynosMPP
;