1 /**
2  * MIT License
3  *
4  * -----------------------------------------------------------------------------
5  * Copyright (c) 2008-24 Think Silicon Single Member PC
6  * -----------------------------------------------------------------------------
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights to
11  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12  * the Software, and to permit persons to whom the Software is furnished to do so,
13  * subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the next paragraph)
16  * shall be included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  */
26 
27 /**
28  * @file lv_draw_nema_gfx.h
29  *
30  */
31 
32 #ifndef LV_DRAW_NEMA_GFX_UTILS_H
33 #define LV_DRAW_NEMA_GFX_UTILS_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*********************
40  *      INCLUDES
41  *********************/
42 #include "../../lv_conf_internal.h"
43 
44 #if LV_USE_NEMA_GFX
45 #include "../sw/lv_draw_sw.h"
46 
47 #include "nema_core.h"
48 #include "nema_utils.h"
49 #include "nema_error.h"
50 #include "nema_provisional.h"
51 #include "nema_vg.h"
52 
53 /*********************
54  *      DEFINES
55  *********************/
56 
57 #ifndef NEMA_VIRT2PHYS
58 #define NEMA_VIRT2PHYS
59 #else
60 uintptr_t NEMA_VIRT2PHYS(void * addr);
61 #endif
62 
63 /*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
64 #if LV_COLOR_DEPTH == 8
65 #define LV_NEMA_GFX_COLOR_FORMAT NEMA_L8
66 #define LV_NEMA_GFX_FORMAT_MULTIPLIER 1
67 #elif LV_COLOR_DEPTH == 16
68 #define LV_NEMA_GFX_COLOR_FORMAT NEMA_RGB565
69 #define LV_NEMA_GFX_FORMAT_MULTIPLIER 2
70 #elif LV_COLOR_DEPTH == 24
71 #define LV_NEMA_GFX_COLOR_FORMAT NEMA_BGR24
72 #define LV_NEMA_GFX_FORMAT_MULTIPLIER 3
73 #elif LV_COLOR_DEPTH == 32
74 #define LV_NEMA_GFX_COLOR_FORMAT NEMA_BGRA8888
75 #define LV_NEMA_GFX_FORMAT_MULTIPLIER 4
76 #else
77 /*Can't use GPU with other formats*/
78 #error Selected Color Depth Not Supported
79 #endif
80 
81 /**********************
82  * GLOBAL PROTOTYPES
83  **********************/
84 
85 /**
86  * Check if  `lv_color_format_t` is supported.
87  * @param     cf  The LVGL color format
88  * @return        True/false
89  */
90 bool lv_nemagfx_is_cf_supported(lv_color_format_t cf);
91 
92 /**
93  * Convert a `lv_color_format_t` to a Nema color format.
94  * @param     cf  The LVGL color format
95  * @return        The Nema color format
96  */
97 uint32_t lv_nemagfx_cf_to_nema(lv_color_format_t cf);
98 
99 /**
100  * Get NemaGFX blending mode
101  *
102  * @param[in] lv_blend_mode The LVGL blend mode
103  *
104  * @return NemaGFX blending mode
105  *
106  */
107 uint32_t lv_nemagfx_blending_mode(lv_blend_mode_t lv_blend_mode);
108 
109 
110 /**
111  * Get NemaGFX blending mode
112  *
113  * @param[in] gradient NemaGFX Gradient Buffer
114  *
115  * @param[in] lv_grad Gradient descriptor
116  *
117  * @param[in] opa Descriptor's opacity
118  *
119 */
120 void lv_nemagfx_grad_set(NEMA_VG_GRAD_HANDLE gradient, lv_grad_dsc_t lv_grad, lv_opa_t opa);
121 
122 /**********************
123  *      MACROS
124  **********************/
125 
126 #endif  /*LV_USE_NEMA_GFX*/
127 
128 #ifdef __cplusplus
129 } /*extern "C"*/
130 #endif
131 
132 #endif /*LV_DRAW_NEMA_GFX_UTILS_H*/
133