hifb.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. /******************************************************************************
  2. Copyright (C), 2001-2011, Hisilicon Tech. Co., Ltd.
  3. ******************************************************************************
  4. File Name : hifb.h
  5. Version : Initial Draft
  6. Author : Hisilicon multimedia software group
  7. Created :
  8. Description :
  9. History :
  10. 1.Date : 2009/03/12
  11. Author :
  12. Modification: Created file
  13. ******************************************************************************/
  14. #ifndef __HIFB_H__
  15. #define __HIFB_H__
  16. #ifdef __cplusplus
  17. #if __cplusplus
  18. extern "C"{
  19. #endif
  20. #endif /* __cplusplus */
  21. #include "hi_type.h"
  22. #include "hi_common.h"
  23. #include <linux/fb.h>
  24. /*************************** Structure Definition ****************************/
  25. #define IOC_TYPE_HIFB 'F'
  26. /** To obtain the colorkey of an overlay layer */
  27. #define FBIOGET_COLORKEY_HIFB _IOR(IOC_TYPE_HIFB, 90, HIFB_COLORKEY_S)
  28. /** To set the colorkey of an overlay layer */
  29. #define FBIOPUT_COLORKEY_HIFB _IOW(IOC_TYPE_HIFB, 91, HIFB_COLORKEY_S)
  30. /** To get the alpha of an overlay layer */
  31. #define FBIOGET_ALPHA_HIFB _IOR(IOC_TYPE_HIFB, 92, HIFB_ALPHA_S)
  32. /** To set the alpha of an overlay layer */
  33. #define FBIOPUT_ALPHA_HIFB _IOW(IOC_TYPE_HIFB, 93, HIFB_ALPHA_S)
  34. /** To get the origin of an overlay layer on the screen */
  35. #define FBIOGET_SCREEN_ORIGIN_HIFB _IOR(IOC_TYPE_HIFB, 94, HIFB_POINT_S)
  36. /** To set the origin of an overlay layer on the screen */
  37. #define FBIOPUT_SCREEN_ORIGIN_HIFB _IOW(IOC_TYPE_HIFB, 95, HIFB_POINT_S)
  38. /** To obtain the anti-flicker setting of an overlay layer */
  39. #define FBIOGET_DEFLICKER_HIFB _IOR(IOC_TYPE_HIFB, 98, HIFB_DEFLICKER_S)
  40. /** To set the anti-flicker setting of an overlay layer */
  41. #define FBIOPUT_DEFLICKER_HIFB _IOW(IOC_TYPE_HIFB, 99, HIFB_DEFLICKER_S)
  42. /** To wait for the vertical blanking region of an overlay layer */
  43. #define FBIOGET_VBLANK_HIFB _IO(IOC_TYPE_HIFB, 100)
  44. /** To set the display state of an overlay layer */
  45. #define FBIOPUT_SHOW_HIFB _IOW(IOC_TYPE_HIFB, 101, HI_BOOL)
  46. /** To obtain the display state of an overlay layer */
  47. #define FBIOGET_SHOW_HIFB _IOR(IOC_TYPE_HIFB, 102, HI_BOOL)
  48. /** to obtain the capability of an overlay layer */
  49. #define FBIOGET_CAPABILITY_HIFB _IOR(IOC_TYPE_HIFB, 103, HIFB_CAPABILITY_S)
  50. /** set the screen output size */
  51. #define FBIOPUT_SCREENSIZE _IOW(IOC_TYPE_HIFB, 130, HIFB_SIZE_S)
  52. /** get the screen output size */
  53. #define FBIOGET_SCREENSIZE _IOR(IOC_TYPE_HIFB, 131, HIFB_SIZE_S)
  54. /** To display multiple surfaces in turn and set the alpha and colorkey attributes */
  55. #define FBIOFLIP_SURFACE _IOW(IOC_TYPE_HIFB, 132, HIFB_SURFACEEX_S)
  56. /**To set the compression function status of an overlay layer*/
  57. #define FBIOPUT_COMPRESSION_HIFB _IOW(IOC_TYPE_HIFB, 133, HI_BOOL)
  58. /**To obtain the compression function status of an overlay layer*/
  59. #define FBIOGET_COMPRESSION_HIFB _IOR(IOC_TYPE_HIFB, 134, HI_BOOL)
  60. /**To set the hdr function status of an overlay layer*/
  61. #define FBIOPUT_DYNAMIC_RANGE_HIFB _IOW(IOC_TYPE_HIFB, 139, HIFB_DYNAMIC_RANGE_E)
  62. /**To get the hdr function status of an overlay layer*/
  63. #define FBIOGET_DYNAMIC_RANGE_HIFB _IOR(IOC_TYPE_HIFB, 140, HIFB_DYNAMIC_RANGE_E)
  64. /**To release the layer*/
  65. #define FBIO_RELEASE_HIFB _IO(IOC_TYPE_HIFB, 150)
  66. typedef struct
  67. {
  68. HI_U32 u32Width;
  69. HI_U32 u32Height;
  70. }HIFB_SIZE_S;
  71. static inline HI_U8 hifb_rgb(const struct fb_bitfield* pBit, HI_S32 color)
  72. {
  73. return ((HI_U8)((((HI_U32)color)>>pBit->offset) << (8-pBit->length)) +
  74. ((HI_U8)(((HI_U32)(color)>>pBit->offset) << (8-pBit->length)) >> pBit->length));
  75. }
  76. static inline HI_S32 hifb_color2key(const struct fb_var_screeninfo* pVar, HI_S32 color)
  77. {
  78. if (pVar->bits_per_pixel <= 8)
  79. {
  80. return color;
  81. }
  82. else
  83. {
  84. HI_U8 r, g, b;
  85. r = hifb_rgb(&pVar->red, color);
  86. g = hifb_rgb(&pVar->green, color);
  87. b = hifb_rgb(&pVar->blue, color);
  88. return (r<<16) + (g<<8) + b;
  89. }
  90. }
  91. typedef enum hifbDYNAMIC_RANGE_E
  92. {
  93. HIFB_DYNAMIC_RANGE_SDR8 = 0,
  94. HIFB_DYNAMIC_RANGE_SDR10,
  95. HIFB_DYNAMIC_RANGE_HDR10,
  96. HIFB_DYNAMIC_RANGE_HLG,
  97. HIFB_DYNAMIC_RANGE_SLF,
  98. HIFB_DYNAMIC_RANGE_BUTT
  99. } HIFB_DYNAMIC_RANGE_E;
  100. typedef struct
  101. {
  102. HI_BOOL bKeyEnable; /* colorkey enable flag */
  103. HI_U32 u32Key; /* colorkey value, maybe contains alpha */
  104. }HIFB_COLORKEY_S;
  105. typedef struct
  106. {
  107. HI_S32 x;
  108. HI_S32 y;
  109. HI_S32 w;
  110. HI_S32 h;
  111. } HIFB_RECT;
  112. typedef struct
  113. {
  114. HI_S32 s32XPos; /**< horizontal position */
  115. HI_S32 s32YPos; /**< vertical position */
  116. }HIFB_POINT_S;
  117. typedef struct hiHIFB_DEFLICKER_S
  118. {
  119. HI_U32 u32HDfLevel; /**< horizontal deflicker level */
  120. HI_U32 u32VDfLevel; /**< vertical deflicker level */
  121. HI_U8 ATTRIBUTE *pu8HDfCoef; /**< horizontal deflicker coefficient */
  122. HI_U8 ATTRIBUTE *pu8VDfCoef; /**< vertical deflicker coefficient */
  123. }HIFB_DEFLICKER_S;
  124. /** Alpha info */
  125. typedef struct
  126. {
  127. HI_BOOL bAlphaEnable; /**< alpha enable flag */
  128. HI_BOOL bAlphaChannel; /**< alpha channel enable flag */
  129. HI_U8 u8Alpha0; /**< alpha0 value, used in ARGB1555 */
  130. HI_U8 u8Alpha1; /**< alpha1 value, used in ARGB1555 */
  131. HI_U8 u8GlobalAlpha; /**< global alpha value */
  132. HI_U8 u8Reserved;
  133. }HIFB_ALPHA_S;
  134. typedef enum
  135. {
  136. HIFB_FMT_RGB565 = 0,
  137. HIFB_FMT_RGB888, /**< RGB888 24bpp */
  138. HIFB_FMT_KRGB444, /**< RGB444 16bpp */
  139. HIFB_FMT_KRGB555, /**< RGB555 16bpp */
  140. HIFB_FMT_KRGB888, /**< RGB888 32bpp */
  141. HIFB_FMT_ARGB4444, /**< ARGB4444 */
  142. HIFB_FMT_ARGB1555, /**< ARGB1555 */
  143. HIFB_FMT_ARGB8888, /**< ARGB8888 */
  144. HIFB_FMT_ARGB8565, /**< ARGB8565 */
  145. HIFB_FMT_RGBA4444, /**< ARGB4444 */
  146. HIFB_FMT_RGBA5551, /**< RGBA5551 */
  147. HIFB_FMT_RGBA5658, /**< RGBA5658 */
  148. HIFB_FMT_RGBA8888, /**< RGBA8888 */
  149. HIFB_FMT_BGR565, /**< BGR565 */
  150. HIFB_FMT_BGR888, /**< BGR888 */
  151. HIFB_FMT_ABGR4444, /**< ABGR4444 */
  152. HIFB_FMT_ABGR1555, /**< ABGR1555 */
  153. HIFB_FMT_ABGR8888, /**< ABGR8888 */
  154. HIFB_FMT_ABGR8565, /**< ABGR8565 */
  155. HIFB_FMT_KBGR444, /**< BGR444 16bpp */
  156. HIFB_FMT_KBGR555, /**< BGR555 16bpp */
  157. HIFB_FMT_KBGR888, /**< BGR888 32bpp */
  158. HIFB_FMT_1BPP, /**< clut1 */
  159. HIFB_FMT_2BPP, /**< clut2 */
  160. HIFB_FMT_4BPP, /**< clut4 */
  161. HIFB_FMT_8BPP, /**< clut8 */
  162. HIFB_FMT_ACLUT44, /**< AClUT44*/
  163. HIFB_FMT_ACLUT88, /**< ACLUT88 */
  164. HIFB_FMT_PUYVY, /**< UYVY */
  165. HIFB_FMT_PYUYV, /**< YUYV */
  166. HIFB_FMT_PYVYU, /**< YVYU */
  167. HIFB_FMT_YUV888, /**< YUV888 */
  168. HIFB_FMT_AYUV8888, /**< AYUV8888 */
  169. HIFB_FMT_YUVA8888, /**< YUVA8888 */
  170. HIFB_FMT_BUTT
  171. }HIFB_COLOR_FMT_E;
  172. typedef struct
  173. {
  174. HI_BOOL bKeyRgb;
  175. HI_BOOL bKeyAlpha; /**< whether support colorkey alpha */
  176. HI_BOOL bGlobalAlpha; /**< whether support global alpha */
  177. HI_BOOL bCmap; /**< whether support color map */
  178. HI_BOOL bHasCmapReg; /**< whether has color map register*/
  179. HI_BOOL bColFmt[HIFB_FMT_BUTT]; /**< support which color format */
  180. HI_BOOL bVoScale; /**< support vo scale*/
  181. HI_BOOL bLayerSupported; /**< whether support a certain layer, for example:x5 HD support HIFB_SD_0 not support HIFB_SD_1*/
  182. HI_U32 u32MaxWidth; /**< the max pixels per line */
  183. HI_U32 u32MaxHeight; /**< the max lines */
  184. HI_U32 u32MinWidth; /**< the min pixels per line */
  185. HI_U32 u32MinHeight; /**< the min lines */
  186. HI_U32 u32VDefLevel; /**< vertical deflicker level, 0 means vertical deflicker is unsupported */
  187. HI_U32 u32HDefLevel; /**< horizontal deflicker level, 0 means horizontal deflicker is unsupported */
  188. HI_BOOL bDcmp;
  189. HI_BOOL bPreMul;
  190. HI_BOOL bGHDR; /* NEW Feature. Is GHDR supported. */
  191. }HIFB_CAPABILITY_S;
  192. /*refresh mode*/
  193. typedef enum
  194. {
  195. HIFB_LAYER_BUF_DOUBLE = 0x0, /**< 2 display buf in fb */
  196. HIFB_LAYER_BUF_ONE = 0x1, /**< 1 display buf in fb */
  197. HIFB_LAYER_BUF_NONE = 0x2, /**< no display buf in fb,the buf user refreshed will be directly set to VO*/
  198. HIFB_LAYER_BUF_DOUBLE_IMMEDIATE=0x3, /**< 2 display buf in fb, each refresh will be displayed*/
  199. HIFB_LAYER_BUF_BUTT
  200. } HIFB_LAYER_BUF_E;
  201. /* surface info */
  202. typedef struct
  203. {
  204. HI_U64 u64PhyAddr; /**< start physical address */
  205. HI_U64 u64GBPhyAddr; // TODO new
  206. HI_U32 u32Width; /**< width pixels */
  207. HI_U32 u32Height; /**< height pixels */
  208. HI_U32 u32Pitch; /**< line pixels */
  209. HIFB_COLOR_FMT_E enFmt; /**< color format */
  210. HIFB_DYNAMIC_RANGE_E enDynamicRange; /* NEW dynamic range. */
  211. }HIFB_SURFACE_S;
  212. typedef struct
  213. {
  214. HI_U64 u64PhyAddr;
  215. HIFB_ALPHA_S stAlpha;
  216. HIFB_COLORKEY_S stColorkey;
  217. }HIFB_SURFACEEX_S;
  218. /* refresh surface info */
  219. typedef struct
  220. {
  221. HIFB_SURFACE_S stCanvas;
  222. HIFB_RECT UpdateRect; /* refresh region*/
  223. }HIFB_BUFFER_S;
  224. /* cursor info */
  225. typedef struct
  226. {
  227. HIFB_SURFACE_S stCursor;
  228. HIFB_POINT_S stHotPos;
  229. } HIFB_CURSOR_S;
  230. /* DDR detect zone info */
  231. typedef struct
  232. {
  233. HI_U32 u32StartSection;
  234. HI_U32 u32ZoneNums;
  235. } HIFB_DDRZONE_S;
  236. /* crusor handle */
  237. /* Attention:surface in cursor will be released by user*/
  238. #define FBIOPUT_CURSOR_INFO _IOW(IOC_TYPE_HIFB, 104, HIFB_CURSOR_S )
  239. #define FBIOGET_CURSOR_INFO _IOW(IOC_TYPE_HIFB, 105, HIFB_CURSOR_S )
  240. #define FBIOPUT_CURSOR_STATE _IOW(IOC_TYPE_HIFB, 106, HI_BOOL )
  241. #define FBIOGET_CURSOR_STATE _IOW(IOC_TYPE_HIFB, 107, HI_BOOL )
  242. #define FBIOPUT_CURSOR_POS _IOW(IOC_TYPE_HIFB, 108, HIFB_POINT_S )
  243. #define FBIOGET_CURSOR_POS _IOR(IOC_TYPE_HIFB, 109, HIFB_POINT_S )
  244. #define FBIOPUT_CURSOR_COLORKEY _IOR(IOC_TYPE_HIFB, 110, HIFB_COLORKEY_S )
  245. #define FBIOGET_CURSOR_COLORKEY _IOW(IOC_TYPE_HIFB, 111, HIFB_COLORKEY_S )
  246. #define FBIOPUT_CURSOR_ALPHA _IOR(IOC_TYPE_HIFB, 112, HIFB_ALPHA_S )
  247. #define FBIOGET_CURSOR_ALPHA _IOW(IOC_TYPE_HIFB, 113, HIFB_ALPHA_S )
  248. /** cursor will be separated from attached layer automatically if you attach cursor to another layer,that means
  249. cursor can be attached to only one layer at any time*/
  250. #define FBIOPUT_CURSOR_ATTCHCURSOR _IOW(IOC_TYPE_HIFB, 114, HI_U32 )
  251. #define FBIOPUT_CURSOR_DETACHCURSOR _IOW(IOC_TYPE_HIFB, 115, HI_U32 )
  252. /**antiflicker level*/
  253. /**Auto means fb will choose a appropriate antiflicker level automatically according to the color info of map*/
  254. typedef enum
  255. {
  256. HIFB_LAYER_ANTIFLICKER_NONE = 0x0, /**< no antiflicker*/
  257. HIFB_LAYER_ANTIFLICKER_LOW = 0x1, /**< low level*/
  258. HIFB_LAYER_ANTIFLICKER_MIDDLE = 0x2,/**< middle level*/
  259. HIFB_LAYER_ANTIFLICKER_HIGH = 0x3, /**< high level*/
  260. HIFB_LAYER_ANTIFLICKER_AUTO = 0x4, /**< auto*/
  261. HIFB_LAYER_ANTIFLICKER_BUTT
  262. }HIFB_LAYER_ANTIFLICKER_LEVEL_E;
  263. /* MIRROR mode */
  264. typedef enum
  265. {
  266. HIFB_MIRROR_NONE = 0x0,
  267. HIFB_MIRROR_HORIZONTAL = 0x1,
  268. HIFB_MIRROR_VERTICAL = 0x2,
  269. HIFB_MIRROR_BOTH= 0x3,
  270. HIFB_MIRROR_BUTT
  271. }HIFB_MIRROR_MODE_E;
  272. /* ROTATE mode */
  273. typedef enum
  274. {
  275. HIFB_ROTATE_NONE = 0x0,
  276. HIFB_ROTATE_90 = 0x1,
  277. HIFB_ROTATE_180 = 0x2,
  278. HIFB_ROTATE_270= 0x3,
  279. HIFB_ROTATE_BUTT
  280. }HIFB_ROTATE_MODE_E;
  281. /*layer info maskbit*/
  282. typedef enum
  283. {
  284. HIFB_LAYERMASK_BUFMODE = 0x1, /**< BUFMODE bitmask */
  285. HIFB_LAYERMASK_ANTIFLICKER_MODE = 0x2, /**< ANTIFLICKER_MODE bitmask */
  286. HIFB_LAYERMASK_POS = 0x4, /**< the position bitmask */
  287. HIFB_LAYERMASK_CANVASSIZE = 0x8, /**< canvassize bitmask */
  288. HIFB_LAYERMASK_DISPSIZE = 0x10, /**< displaysize bitmask */
  289. HIFB_LAYERMASK_SCREENSIZE = 0x20, /**< screensize bitmask */
  290. HIFB_LAYERMASK_BMUL = 0x40, /**< pre-mult bitmask */
  291. HIFB_LAYERMASK_BUTT
  292. }HIFB_LAYER_INFO_MASKBIT;
  293. /**layer info*/
  294. typedef struct
  295. {
  296. HIFB_LAYER_BUF_E BufMode;
  297. HIFB_LAYER_ANTIFLICKER_LEVEL_E eAntiflickerLevel;
  298. HI_S32 s32XPos; /**< the x pos of origion point in screen */
  299. HI_S32 s32YPos; /**< the y pos of origion point in screen */
  300. HI_U32 u32CanvasWidth; /**< the width of canvas buffer */
  301. HI_U32 u32CanvasHeight; /**< the height of canvas buffer */
  302. HI_U32 u32DisplayWidth; /**< the width of display buf in fb.for 0 buf ,there is no display buf in fb, so it's effectless*/
  303. HI_U32 u32DisplayHeight; /**< the height of display buf in fb. */
  304. HI_U32 u32ScreenWidth; /**< the width of screen */
  305. HI_U32 u32ScreenHeight; /**< the height of screen */
  306. HI_BOOL bPreMul; /**< The data drawed in buf is premul data or not*/
  307. HI_U32 u32Mask; /**< param modify mask bit*/
  308. }HIFB_LAYER_INFO_S;
  309. /** To set the layer information */
  310. #define FBIOPUT_LAYER_INFO _IOW(IOC_TYPE_HIFB, 120, HIFB_LAYER_INFO_S)
  311. /** To get the layer information */
  312. #define FBIOGET_LAYER_INFO _IOR(IOC_TYPE_HIFB, 121, HIFB_LAYER_INFO_S)
  313. /** To get canvas buf */
  314. #define FBIOGET_CANVAS_BUFFER _IOR(IOC_TYPE_HIFB, 123, HIFB_BUFFER_S)
  315. /** To refresh the displayed contents in extended mode */
  316. #define FBIO_REFRESH _IOW(IOC_TYPE_HIFB, 124, HIFB_BUFFER_S)
  317. /**sync refresh*/
  318. #define FBIO_WAITFOR_FREFRESH_DONE _IO(IOC_TYPE_HIFB, 125)
  319. /* To set the mirror mode */
  320. #define FBIOPUT_MIRROR_MODE _IOW(IOC_TYPE_HIFB, 126, HIFB_MIRROR_MODE_E)
  321. /* To get the mirror mode */
  322. #define FBIOGET_MIRROR_MODE _IOW(IOC_TYPE_HIFB, 127, HIFB_MIRROR_MODE_E)
  323. /* To set the rotate mode */
  324. #define FBIOPUT_ROTATE_MODE _IOW(IOC_TYPE_HIFB, 128, HIFB_ROTATE_MODE_E)
  325. /* To get the rotate mode */
  326. #define FBIOGET_ROTATE_MODE _IOW(IOC_TYPE_HIFB, 129, HIFB_ROTATE_MODE_E)
  327. /**To set the DDR detect zone of an overlay layer*/
  328. #define FBIOPUT_MDDRDETECT_HIFB _IOW(IOC_TYPE_HIFB, 135, HIFB_DDRZONE_S)
  329. /**To get the DDR detect zone of an overlay layer*/
  330. #define FBIOGET_MDDRDETECT_HIFB _IOW(IOC_TYPE_HIFB, 136, HIFB_DDRZONE_S)
  331. #ifdef __cplusplus
  332. #if __cplusplus
  333. }
  334. #endif
  335. #endif /* __cplusplus */
  336. #endif /* __HIFB_H__ */