2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_EXYNOS_HWC_H_
18 #define ANDROID_EXYNOS_HWC_H_
27 #include <sys/ioctl.h>
30 #include <sys/resource.h>
34 #include <decon_8890.h>
38 #include "ExynosDisplayResourceManagerModule.h"
45 #define HWC_REMOVE_DEPRECATED_VERSIONS 1
47 #include <cutils/compiler.h>
48 #include <cutils/log.h>
49 #include <cutils/properties.h>
50 #include <hardware/gralloc.h>
51 #include <hardware/hardware.h>
52 #include <hardware/hwcomposer.h>
53 #include <hardware_legacy/uevent.h>
54 #include <utils/String8.h>
55 #include <utils/Vector.h>
56 #include <utils/Timers.h>
58 #include <sync/sync.h>
60 #include "gralloc_priv.h"
62 #include "exynos_gscaler.h"
64 #include "exynos_fimc.h"
66 #include "exynos_format.h"
67 #include "exynos_v4l2.h"
68 #include "s5p_tvout_v4l2.h"
69 #include "ExynosHWCModule.h"
70 #include "ExynosRect.h"
71 #include <linux/videodev2.h>
73 #ifdef USE_FB_PHY_LINEAR
74 const size_t NUM_HW_WIN_FB_PHY
= 5;
75 #undef DUAL_VIDEO_OVERLAY_SUPPORT
76 #define G2D_COMPOSITION
77 #ifdef G2D_COMPOSITION
78 #define USE_FIMG2D_API
82 #if defined(DUAL_VIDEO_OVERLAY_SUPPORT)
83 #define MAX_VIDEO_LAYERS 2
85 #define MAX_VIDEO_LAYERS 1
88 #ifndef FIMD_WORD_SIZE_BYTES
89 #define FIMD_WORD_SIZE_BYTES 8
93 #define FIMD_BURSTLEN 16
96 #ifndef DRM_FIMD_BURSTLEN
97 #define DRM_FIMD_BURSTLEN 8
100 #ifndef FIMD_ADDED_BURSTLEN_BYTES
101 #define FIMD_ADDED_BURSTLEN_BYTES 0
104 #ifndef FIMD_TOTAL_BW_LIMIT
105 #define FIMD_TOTAL_BW_LIMIT (2560 * 1600 * 5)
108 #ifndef WINUPDATE_X_ALIGNMENT
109 #define WINUPDATE_X_ALIGNMENT (8)
112 #ifndef WINUPDATE_W_ALIGNMENT
113 #define WINUPDATE_W_ALIGNMENT (8)
116 #ifndef WINUPDATE_DSC_H_SLICE_NUM
117 #define WINUPDATE_DSC_H_SLICE_NUM (4)
120 #ifndef WINUPDATE_DSC_Y_SLICE_SIZE
121 #define WINUPDATE_DSC_Y_SLICE_SIZE (64)
124 #ifndef WINUPDATE_THRESHOLD
125 #define WINUPDATE_THRESHOLD (75)
128 #ifndef WINUPDATE_MIN_HEIGHT
129 #define WINUPDATE_MIN_HEIGHT (1)
132 #define MEDIA_PROCESSOR_GSC 0
133 #define MEDIA_PROCESSOR_FIMC 1
134 #define MEDIA_PROCESSOR_G2D 2
137 #define DEFAULT_MEDIA_PROCESSOR MEDIA_PROCESSOR_FIMC
139 #define DEFAULT_MEDIA_PROCESSOR MEDIA_PROCESSOR_GSC
142 #ifdef NUM_AVAILABLE_HW_WINDOWS
144 * NUM_AVAILABLE_HW_WINDOWS can be optionally provided by
145 * soc specific header file which is generally present at
146 * $SoC\libhwcmodule\ExynosHWCModule.h. This is useful when
147 * same display controller driver is used by SoCs having
148 * different number of windows.
149 * S3C_FB_MAX_WIN: max number of hardware windows supported
150 * by the display controller driver.
151 * NUM_AVAILABLE_HW_WINDOWS: max windows in the given SoC.
153 const size_t NUM_HW_WINDOWS
= NUM_AVAILABLE_HW_WINDOWS
;
156 const size_t NUM_HW_WINDOWS
= MAX_DECON_WIN
;
158 const size_t NUM_HW_WINDOWS
= S3C_FB_MAX_WIN
;
163 #define HWC_VERSION HWC_DEVICE_API_VERSION_1_3
167 #define IDMA_SECURE IDMA_G2
170 const size_t NO_FB_NEEDED
= NUM_HW_WINDOWS
+ 1;
172 #ifndef FIMD_BW_OVERLAP_CHECK
173 const size_t MAX_NUM_FIMD_DMA_CH
= 2;
174 const int FIMD_DMA_CH_IDX
[S3C_FB_MAX_WIN
] = {0, 1, 1, 1, 0};
177 #define MAX_DEV_NAME 128
178 #ifndef VSYNC_DEV_PREFIX
179 #define VSYNC_DEV_PREFIX ""
181 #ifndef VSYNC_DEV_MIDDLE
182 #define VSYNC_DEV_MIDDLE ""
185 #ifdef TRY_SECOND_VSYNC_DEV
186 #ifndef VSYNC_DEV_NAME2
187 #define VSYNC_DEV_NAME2 ""
189 #ifndef VSYNC_DEV_MIDDLE2
190 #define VSYNC_DEV_MIDDLE2 ""
197 const uint32_t VPP_ASSIGN_ORDER
[] = {MPP_VG
, MPP_VGR
};
199 const uint32_t VPP_ASSIGN_ORDER
[] = {MPP_VPP_G
, MPP_VG
, MPP_VGR
};
203 const size_t NUM_GSC_UNITS
= sizeof(AVAILABLE_GSC_UNITS
) /
204 sizeof(AVAILABLE_GSC_UNITS
[0]);
206 const size_t BURSTLEN_BYTES
= FIMD_BURSTLEN
* FIMD_WORD_SIZE_BYTES
+ FIMD_ADDED_BURSTLEN_BYTES
;
207 const size_t DRM_BURSTLEN_BYTES
= DRM_FIMD_BURSTLEN
* FIMD_WORD_SIZE_BYTES
+ FIMD_ADDED_BURSTLEN_BYTES
;
208 #if defined(NOT_USE_TRIPLE_BUFFER)
209 const size_t NUM_HDMI_BUFFERS
= 4;
211 const size_t NUM_HDMI_BUFFERS
= 3;
214 #define NUM_VIRT_OVER 5
216 #define NUM_VIRT_OVER_HDMI 5
218 #define HWC_PAGE_MISS_TH 5
221 #ifndef HDMI_INCAPABLE
222 #define HDMI_PRESET_DEFAULT V4L2_DV_1080P60
224 #define HDMI_PRESET_DEFAULT 0
226 #define HDMI_PRESET_ERROR -1
228 #define HWC_FIMD_BW_TH 1 /* valid range 1 to 5 */
229 #define HWC_FPS_TH 5 /* valid range 1 to 60 */
230 #define VSYNC_INTERVAL (1000000000.0 / 60)
231 #define NUM_CONFIG_STABLE 10
233 #define OTF_SWITCH_THRESHOLD 2
241 inline bool hwcPrintDebugMessages()
243 return hwcDebug
& (1 << HLOG_CODE
);
246 #if defined(DISABLE_HWC_DEBUG)
252 if (hwcPrintDebugMessages()) \
255 if (hwcPrintDebugMessages()) \
258 if (hwcPrintDebugMessages()) \
262 typedef enum _COMPOS_MODE_SWITCH
{
266 } HWC_COMPOS_MODE_SWITCH
;
268 struct exynos5_hwc_composer_device_1_t
;
282 } video_layer_config
;
284 struct exynos5_gsc_map_t
{
288 // TODO: GSC_LOCAL_PATH
294 struct exynos5_hwc_post_data_t
{
295 int overlay_map
[NUM_HW_WINDOWS
];
296 exynos5_gsc_map_t gsc_map
[NUM_HW_WINDOWS
];
300 const size_t NUM_GSC_DST_BUFS
= 3;
301 const size_t NUM_DRM_GSC_DST_BUFS
= 2;
302 struct exynos5_gsc_data_t
{
304 exynos_mpp_img src_cfg
;
305 exynos_mpp_img mid_cfg
;
306 exynos_mpp_img dst_cfg
;
307 buffer_handle_t dst_buf
[NUM_GSC_DST_BUFS
];
308 buffer_handle_t mid_buf
[NUM_GSC_DST_BUFS
];
309 int dst_buf_fence
[NUM_GSC_DST_BUFS
];
310 int mid_buf_fence
[NUM_GSC_DST_BUFS
];
313 uint32_t last_gsc_lay_hnd
;
316 struct hdmi_layer_t
{
329 int num_of_video_ovly
;
330 int dynamic_recomp_mode
;
331 int skip_static_layer_mode
;
332 int dma_bw_balance_mode
;
335 #if defined(G2D_COMPOSITION) || defined(USE_GRALLOC_FLAG_FOR_HDMI)
339 #ifdef G2D_COMPOSITION
340 struct exynos5_g2d_data_t
{
341 int ovly_lay_idx
[NUM_HW_WIN_FB_PHY
];
342 int win_used
[NUM_HW_WINDOWS
];
346 class ExynosPrimaryDisplay
;
347 class ExynosExternalDisplay
;
348 class ExynosVirtualDisplay
;
349 #if defined(USES_DUAL_DISPLAY)
350 class ExynosSecondaryDisplayModule
;
353 class ExynosDisplayResourceManagerModule
;
356 struct exynos5_hwc_composer_device_1_t
{
357 hwc_composer_device_1_t base
;
359 ExynosPrimaryDisplay
*primaryDisplay
;
360 #if defined(USES_DUAL_DISPLAY)
361 ExynosSecondaryDisplayModule
*secondaryDisplay
;
363 ExynosExternalDisplay
*externalDisplay
;
364 ExynosVirtualDisplay
*virtualDisplay
;
365 struct v4l2_rect mVirtualDisplayRect
;
367 ExynosDisplayResourceManagerModule
*mDisplayResourceManager
;
375 const hwc_procs_t
*procs
;
376 pthread_t vsync_thread
;
382 int mHdmiCurrentPreset
;
383 bool mHdmiResolutionChanged
;
384 bool mHdmiResolutionHandled
;
387 int video_playback_status
;
389 int VsyncInterruptStatus
;
391 uint64_t LastUpdateTimeStamp
;
392 uint64_t LastModeSwitchTimeStamp
;
396 pthread_t update_stat_thread
;
397 int update_event_cnt
;
398 volatile bool update_stat_thread_flag
;
400 struct hwc_ctrl_t hwc_ctrl
;
406 bool force_mirror_mode
;
407 int ext_fbt_transform
; /* HAL_TRANSFORM_ROT_XXX */
408 bool external_display_pause
;
409 bool local_external_display_pause
;
417 void exynos5_create_update_stat_thread(struct exynos5_hwc_composer_device_1_t
*dev
);
427 S3D_MODE_DISABLED
= 0,