You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.0 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2016-2019. All rights reserved.
* Description: Define some macros and constants
* Author: Hisilicon
* Created: 2016.08.12
*/
#ifndef HWC_COMMON_H_INCLUDED
#define HWC_COMMON_H_INCLUDED
#include <unordered_map>
#include <hardware/hardware.h>
#include "gralloc_priv.h"
#define SYNC_IOC_WAIT _IOW('>', 0, __s32)
#define ALIGN_UP(a, b) (((a) + (typeof(a))(b) - 1) & (~((typeof(a))(b)-1)))
#define ALIGN_DOWN(a, b) ((a) & (~((typeof(a))(b)-(typeof(a))1)))
#define ALIGN(x, align) (((x) + ((align)-1)) & ~((align)-1))
#define UNUSED(x) ((void)x)
#ifndef HWC_CHK_PRINTF
#define HWC_CHK_PRINTF(val, ...) \
do { \
if (val) { \
__VA_ARGS__; \
} \
} while (0)
#endif
#ifndef HWC_CHK_RETURN
#define HWC_CHK_RETURN(val, ret, ...) \
do { \
if (val) { \
__VA_ARGS__; \
return (ret); \
} \
} while (0)
#endif
#ifndef HWC_CHK_RETURN_NOT_VALUE
#define HWC_CHK_RETURN_NOT_VALUE(val, ...) \
do { \
if (val) { \
__VA_ARGS__; \
return; \
} \
} while (0)
#endif
namespace HwcCommon {
const int HWCDEVICE_VERSION_MAJOR = 2;
const int HWCDEVICE_VERSION_MINOR = 0;
const int HWC_SUCCESS = 0;
const int HWC_FAILURE = -1;
const int HWC_TIMEOUT = 100;
const int HWC_DEFAULT_BYTEPP = 4;
const int HWC_CALCULATED = 0;
const int HWC_NOT_CALCULATED = 1;
const int HDR_TYPE_NUM = 8;
const int HWC_INVALID_PHY_ADDR = 0;
const int HWC_INVALID_FENCE_ID = -1;
const int HWC_FENCE_TIMEOUT = 3000;
const uint32_t CLIENT_TARGET_SLOT_0 = 0;
const int32_t OVERLAY_MODE = 255;
const int HWC_OVERLAY_MAXLAYER_NUM = 4;
const int FENCE_MAP_SIZE = 3;
const int TARGET_MAP_SIZE = 4;
const int FB_PRIMARY_ID = 0;
const int FB_EXTERNAL_CURSOR_ID = 1;
const int FB_EXTERNAL_ID = 3;
const int MAX_HDR_TYPES = 3;
const int HWC_INVALID_VSYNC_TIME = -1;
const int HWC_XCOLLIE_TIME_OUT = 8;
const int HWC_MAX_REFRESH_RATE = 120;
const int HWC_REFRESH_RATIO = 1000;
const int GFX2D_MAX_RESIZE_NUM = 3;
const int GFX2D_COMPOSE_MIN_LAYER_COUNT = 2;
const int SIXTY_HZ_OF_TIME = 16666;
const int TIME_CONVERSION_LEVEL = 1000;
const int HDR_ARRAY_INDEX_0 = 0;
const int HDR_ARRAY_INDEX_1 = 1;
const int HDR_ARRAY_INDEX_2 = 2;
const int GFX2D_SURFACE_STRIDE_INDEX_0 = 0;
const int GFX2D_SURFACE_STRIDE_INDEX_1 = 1;
const int GFX2D_SURFACE_STRIDE_INDEX_2 = 2;
const int CB_INDEX = 1;
const int CR_INDEX = 2;
const int HWC_XR_3D_WIDTH = 3840;
const int HWC_XR_3D_HEIGHT = 1080;
const int HWC_XR_3D_OLD_WIDTH = 2560;
const int HWC_XR_3D_OLD_HEIGHT = 720;
const int HWC_HEX = 16;
const int HWC_PIXEL_CHECK_TIMEOUT = 3;
const int SIDEBAND_PLAY_MAGIC_NUM = 'NXPY';
const int SIDEBAND_PLAY_MAGIC_NUM_BLACK = 'BLAK';
using PrivHandle = const private_handle_t *;
struct HWCBuffer {
buffer_handle_t buffer;
int fenceId;
int releaseFenceFd;
};
struct HdrCap {
unsigned int num;
bool dolby;
bool hdr10;
bool hlg;
float maxLuminance;
float maxAverageLuminance;
float minLuminance;
};
struct DisplayConfigInfo {
uint32_t width;
uint32_t height;
float xDpi;
float yDpi;
float fps;
};
using DisplayConfigs = std::unordered_map<hwc2_config_t, DisplayConfigInfo>;
enum class HWC_COMPOSE {
HWC_GPU_COMPOSE = 1,
HWC_GFX2D_COMPOSE = 2,
HWC_DIRECT_PRESENT = 3,
};
enum class HWC_TYPE_PP {
HWC_BYTE_PP_INVALID = -1,
HWC_BYTE_PP_2 = 2,
HWC_BYTE_PP_3 = 3,
HWC_BYTE_PP_4 = 4,
};
}
#endif // HWC_COMMON_H_INCLUDED