1 /**
2  * @file lv_gpu_nxp_pxp.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_PXP_H_
31 #define LV_SRC_LV_GPU_LV_GPU_NXP_PXP_H_
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*********************
38  *      INCLUDES
39  *********************/
40 
41 #include "../../lv_conf_internal.h"
42 
43 #if LV_USE_GPU_NXP_PXP
44 
45 #include "../misc/lv_area.h"
46 #include "../misc/lv_color.h"
47 
48 /*********************
49  *      DEFINES
50  *********************/
51 
52 /** PXP module instance to use*/
53 #define LV_GPU_NXP_PXP_ID PXP
54 
55 /** PXP interrupt line I*/
56 #define LV_GPU_NXP_PXP_IRQ_ID PXP_IRQn
57 
58 #ifndef LV_GPU_NXP_PXP_BLIT_SIZE_LIMIT
59 /** Minimum area (in pixels) for image copy with 100% opacity to be handled by PXP*/
60 #define LV_GPU_NXP_PXP_BLIT_SIZE_LIMIT 32
61 #endif
62 
63 #ifndef LV_GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT
64 /** Minimum area (in pixels) for image copy with transparency to be handled by PXP*/
65 #define LV_GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT 16
66 #endif
67 
68 #ifndef LV_GPU_NXP_PXP_BUFF_SYNC_BLIT_SIZE_LIMIT
69 /** Minimum invalidated area (in pixels) to be synchronized by PXP during buffer sync */
70 #define LV_GPU_NXP_PXP_BUFF_SYNC_BLIT_SIZE_LIMIT 32
71 #endif
72 
73 #ifndef LV_GPU_NXP_PXP_FILL_SIZE_LIMIT
74 /** Minimum area (in pixels) to be filled by PXP with 100% opacity*/
75 #define LV_GPU_NXP_PXP_FILL_SIZE_LIMIT 64
76 #endif
77 
78 #ifndef LV_GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT
79 /** Minimum area (in pixels) to be filled by PXP with transparency*/
80 #define LV_GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT 32
81 #endif
82 
83 /**********************
84  *      TYPEDEFS
85  **********************/
86 /**
87  * NXP PXP device configuration - call-backs used for
88  * interrupt init/wait/deinit.
89  */
90 typedef struct {
91     /** Callback for PXP interrupt initialization*/
92     lv_res_t (*pxp_interrupt_init)(void);
93 
94     /** Callback for PXP interrupt de-initialization*/
95     void (*pxp_interrupt_deinit)(void);
96 
97     /** Callback that should start PXP and wait for operation complete*/
98     void (*pxp_run)(void);
99 } lv_nxp_pxp_cfg_t;
100 
101 /**********************
102  *  STATIC VARIABLES
103  **********************/
104 
105 /**********************
106  *      MACROS
107  **********************/
108 
109 /**********************
110  *   GLOBAL FUNCTIONS
111  **********************/
112 
113 /**
114  * Reset and initialize PXP device. This function should be called as a part
115  * of display init sequence.
116  *
117  * @return LV_RES_OK: PXP init ok; LV_RES_INV: init error. See error log for more information.
118  */
119 lv_res_t lv_gpu_nxp_pxp_init(lv_nxp_pxp_cfg_t * cfg);
120 
121 /**
122  * Disable PXP device. Should be called during display deinit sequence.
123  */
124 void lv_gpu_nxp_pxp_deinit(void);
125 
126 /**
127  * Fill area, with optional opacity.
128  *
129  * @param[in/out] dest_buf destination buffer
130  * @param[in] dest_width width (stride) of destination buffer in pixels
131  * @param[in] fill_area area to fill
132  * @param[in] color color
133  * @param[in] opa transparency of the color
134  */
135 void lv_gpu_nxp_pxp_fill(lv_color_t * dest_buf, lv_coord_t dest_width, const lv_area_t * fill_area, lv_color_t color,
136                          lv_opa_t opa);
137 
138 /**
139  * @brief BLock Image Transfer - copy rectangular image from src buffer to dst buffer with effects.
140  *
141  * By default, image is copied directly, with optional opacity configured by \p opa.
142  * Color keying can be enabled by calling lv_gpu_nxp_pxp_enable_color_key() before calling this function.
143  * Recoloring can be enabled by calling lv_gpu_nxp_pxp_enable_recolor() before calling this function.
144  * Note that color keying and recoloring at the same time is not supported and black rectangle is rendered.
145  *
146  * @param[in/out] dest destination buffer
147  * @param[in] dest_width width (stride) of destination buffer in pixels
148  * @param[in] src source buffer
149  * @param[in] src_with width (stride) of source buffer in pixels
150  * @param[in] copy_w width of area to be copied from src to dest
151  * @param[in] copy_h height of area to be copied from src to dest
152  * @param[in] opa opacity of the result
153  */
154 void lv_gpu_nxp_pxp_blit(lv_color_t * dest, lv_coord_t dest_width, const lv_color_t * src, lv_coord_t src_width,
155                          lv_coord_t copy_width, lv_coord_t copy_height, lv_opa_t opa);
156 
157 /**
158  * @brief Enable color keying for subsequent calls to lv_gpu_nxp_pxp_blit()
159  *
160  * Color key is defined by LV_COLOR_TRANSP symbol in lv_conf.h
161  */
162 void lv_gpu_nxp_pxp_enable_color_key(void);
163 
164 /**
165  * @brief Disable color keying for subsequent calls to lv_gpu_nxp_pxp_blit()
166  *
167  */
168 void lv_gpu_nxp_pxp_disable_color_key(void);
169 
170 /**
171  * @brief Enable recolor feature for subsequent calls to lv_gpu_nxp_pxp_blit()
172  *
173  * @param[in] color recolor value
174  * @param[in] opa effect opacity
175  */
176 void lv_gpu_nxp_pxp_enable_recolor(lv_color_t color, lv_opa_t opa);
177 
178 /**
179  * @brief Disable recolor feature for subsequent calls to lv_gpu_nxp_pxp_blit()
180  */
181 void lv_gpu_nxp_pxp_disable_recolor(void);
182 
183 /**********************
184  *   STATIC FUNCTIONS
185  **********************/
186 
187 #endif /*LV_USE_GPU_NXP_PXP*/
188 
189 #ifdef __cplusplus
190 } /*extern "C"*/
191 #endif
192 
193 #endif /*LV_SRC_LV_GPU_LV_GPU_NXP_PXP_H_*/
194