1 /**
2  * @file lv_gpu_nxp_vglite.h
3  *
4  */
5 
6 /**
7  * MIT License
8  *
9  * Copyright (c) 2020 NXP
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a copy
12  * of this software and associated documentation files (the "Software"), to deal
13  * in the Software without restriction, including without limitation the rights to
14  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15  * the Software, and to permit persons to whom the Software is furnished to do so,
16  * subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice (including the next paragraph)
19  * shall be included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
22  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
26  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  *
28  */
29 
30 #ifndef LV_SRC_LV_GPU_LV_GPU_NXP_VGLITE_H_
31 #define LV_SRC_LV_GPU_LV_GPU_NXP_VGLITE_H_
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*********************
38  *      INCLUDES
39  *********************/
40 #include "../../lv_conf_internal.h"
41 
42 #if LV_USE_GPU_NXP_VG_LITE
43 
44 /*********************
45  *      DEFINES
46  *********************/
47 
48 /** Use this symbol as limit to disable feature (value has to be larger than supported resolution) */
49 #define LV_GPU_NXP_VG_LITE_FEATURE_DISABLED (1920*1080+1)
50 
51 /** Stride in px required by VG-Lite HW. Don't change this. */
52 #define LV_GPU_NXP_VG_LITE_STRIDE_ALIGN_PX 16U
53 
54 #ifndef LV_GPU_NXP_VG_LITE_FILL_SIZE_LIMIT
55 /** Minimum area (in pixels) to be filled by VG-Lite with 100% opacity*/
56 #define LV_GPU_NXP_VG_LITE_FILL_SIZE_LIMIT 32
57 #endif
58 
59 #ifndef LV_GPU_NXP_VG_LITE_FILL_OPA_SIZE_LIMIT
60 /** Minimum area (in pixels) to be filled by VG-Lite with transparency*/
61 #define LV_GPU_NXP_VG_LITE_FILL_OPA_SIZE_LIMIT 32
62 #endif
63 
64 #ifndef LV_GPU_NXP_VG_LITE_BLIT_SIZE_LIMIT
65 /** Minimum area (in pixels) for image copy with 100% opacity to be handled by VG-Lite*/
66 #define LV_GPU_NXP_VG_LITE_BLIT_SIZE_LIMIT 32
67 #endif
68 
69 #ifndef LV_GPU_NXP_VG_LITE_BUFF_SYNC_BLIT_SIZE_LIMIT
70 /** Minimum invalidated area (in pixels) to be synchronized by VG-Lite during buffer sync */
71 #define LV_GPU_NXP_VG_LITE_BUFF_SYNC_BLIT_SIZE_LIMIT 32
72 #endif
73 
74 #ifndef LV_GPU_NXP_VG_LITE_BLIT_OPA_SIZE_LIMIT
75 /** Minimum area (in pixels) for image copy with transparency to be handled by VG-Lite*/
76 #define LV_GPU_NXP_VG_LITE_BLIT_OPA_SIZE_LIMIT 32
77 #endif
78 
79 #ifndef LV_GPU_NXP_VG_LITE_LOG_ERRORS
80 /** Enable logging of VG-Lite errors (\see LV_LOG_ERROR)*/
81 #define LV_GPU_NXP_VG_LITE_LOG_ERRORS 1
82 #endif
83 
84 /**********************
85  *      TYPEDEFS
86  **********************/
87 
88 /**
89  * BLock Image Transfer descriptor structure
90  */
91 typedef struct {
92 
93     const lv_color_t * src;  /**< Source buffer pointer (must be aligned on 32 bytes)*/
94     lv_area_t src_area;      /**< Area to be copied from source*/
95     lv_coord_t src_width;    /**< Source buffer width*/
96     lv_coord_t src_height;   /**< Source buffer height*/
97     uint32_t src_stride;     /**< Source buffer stride in bytes (must be aligned on 16 px)*/
98 
99     const lv_color_t * dst;  /**< Destination buffer pointer (must be aligned on 32 bytes)*/
100     lv_area_t dst_area;      /**< Target area in destination buffer (must be the same as src_area)*/
101     lv_coord_t dst_width;    /**< Destination buffer width*/
102     lv_coord_t dst_height;   /**< Destination buffer height*/
103     uint32_t dst_stride;     /**< Destination buffer stride in bytes (must be aligned on 16 px)*/
104 
105     lv_opa_t opa;            /**< Opacity - alpha mix (0 = source not copied, 255 = 100% opaque)*/
106 
107 } lv_gpu_nxp_vglite_blit_info_t;
108 
109 /**********************
110  *      MACROS
111  **********************/
112 
113 /**********************
114  *   GLOBAL FUNCTIONS
115  **********************/
116 
117 /***
118  * Fills rectangular area in buffer.
119  * @param[in] dest_buf Destination buffer pointer (must be aligned on 32 bytes)
120  * @param[in] dest_width Destination buffer width in pixels ((must be aligned on 16 px)
121  * @param[in] dest_height Destination buffer height in pixels
122  * @param[in] fill_area Area to be filled
123  * @param[in] color Fill color
124  * @param[in] opa Opacity (255 = full, 128 = 50% background/50% color, 0 = no fill)
125  * @retval LV_RES_OK Fill completed
126  * @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
127  */
128 lv_res_t lv_gpu_nxp_vglite_fill(lv_color_t * dest_buf, lv_coord_t dest_width, lv_coord_t dest_height,
129                                 const lv_area_t * fill_area, lv_color_t color, lv_opa_t opa);
130 
131 /***
132  * BLock Image Transfer.
133  * @param[in] blit Description of the transfer
134  * @retval LV_RES_OK Transfer complete
135  * @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
136  */
137 lv_res_t lv_gpu_nxp_vglite_blit(lv_gpu_nxp_vglite_blit_info_t * blit);
138 
139 #endif /*LV_USE_GPU_NXP_VG_LITE*/
140 
141 #ifdef __cplusplus
142 } /*extern "C"*/
143 #endif
144 
145 #endif /*LV_SRC_LV_GPU_LV_GPU_NXP_VGLITE_H_*/
146