| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#ifndef LV_DRAW_PPA_PRIVATE_H |
| 7 |
#define LV_DRAW_PPA_PRIVATE_H |
| 8 |
|
| 9 |
#ifdef __cplusplus |
| 10 |
extern "C" { |
| 11 |
#endif |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "../../../lv_conf_internal.h" |
| 17 |
|
| 18 |
#if LV_USE_PPA |
| 19 |
#if LV_PPA_NONBLOCKING_OPS |
| 20 |
#error "PPA draw in nonblocking is experimental and not supported yet, please make it to 0!" |
| 21 |
#endif |
| 22 |
|
| 23 |
#ifndef LV_PPA_NONBLOCKING_OPS |
| 24 |
#define LV_PPA_NONBLOCKING_OPS 0 |
| 25 |
#endif |
| 26 |
|
| 27 |
#include LV_STDDEF_INCLUDE |
| 28 |
#include LV_STDBOOL_INCLUDE |
| 29 |
#include LV_STDINT_INCLUDE |
| 30 |
|
| 31 |
#include "../../../misc/lv_color.h" |
| 32 |
#include "../../../misc/lv_log.h" |
| 33 |
#include "../../lv_draw_private.h" |
| 34 |
#include "../../../display/lv_display_private.h" |
| 35 |
#include "../../../misc/lv_area_private.h" |
| 36 |
|
| 37 |
|
| 38 |
#include "sdkconfig.h" |
| 39 |
|
| 40 |
#if (CONFIG_LV_DRAW_BUF_ALIGN != CONFIG_CACHE_L2_CACHE_LINE_SIZE) |
| 41 |
#error "CONFIG_LV_DRAW_BUF_ALIGN must be equal to CONFIG_CACHE_L2_CACHE_LINE_SIZE!" |
| 42 |
#endif |
| 43 |
|
| 44 |
|
| 45 |
#ifndef CONFIG_SOC_PPA_SUPPORTED |
| 46 |
#error "This SoC does not support PPA" |
| 47 |
#endif |
| 48 |
|
| 49 |
#include "driver/ppa.h" |
| 50 |
#include "esp_heap_caps.h" |
| 51 |
#include "esp_err.h" |
| 52 |
#include "hal/color_hal.h" |
| 53 |
#include "esp_cache.h" |
| 54 |
#include "esp_log.h" |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
typedef struct lv_draw_ppa_unit { |
| 63 |
lv_draw_unit_t base_unit; |
| 64 |
lv_draw_task_t * task_act; |
| 65 |
ppa_client_handle_t srm_client; |
| 66 |
ppa_client_handle_t fill_client; |
| 67 |
ppa_client_handle_t blend_client; |
| 68 |
uint8_t * buf; |
| 69 |
} lv_draw_ppa_unit_t; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
static inline bool ppa_src_cf_supported(lv_color_format_t cf) |
| 88 |
{ |
| 89 |
bool is_cf_supported = false; |
| 90 |
|
| 91 |
switch(cf) { |
| 92 |
case LV_COLOR_FORMAT_RGB565: |
| 93 |
case LV_COLOR_FORMAT_ARGB8888: |
| 94 |
case LV_COLOR_FORMAT_XRGB8888: |
| 95 |
is_cf_supported = true; |
| 96 |
break; |
| 97 |
default: |
| 98 |
break; |
| 99 |
} |
| 100 |
|
| 101 |
return is_cf_supported; |
| 102 |
} |
| 103 |
|
| 104 |
static inline bool ppa_dest_cf_supported(lv_color_format_t cf) |
| 105 |
{ |
| 106 |
bool is_cf_supported = false; |
| 107 |
|
| 108 |
switch(cf) { |
| 109 |
case LV_COLOR_FORMAT_RGB565: |
| 110 |
case LV_COLOR_FORMAT_RGB888: |
| 111 |
case LV_COLOR_FORMAT_ARGB8888: |
| 112 |
is_cf_supported = true; |
| 113 |
break; |
| 114 |
default: |
| 115 |
break; |
| 116 |
} |
| 117 |
|
| 118 |
return is_cf_supported; |
| 119 |
} |
| 120 |
|
| 121 |
static inline ppa_fill_color_mode_t lv_color_format_to_ppa_fill(lv_color_format_t lv_fmt) |
| 122 |
{ |
| 123 |
switch(lv_fmt) { |
| 124 |
case LV_COLOR_FORMAT_RGB565: |
| 125 |
return PPA_FILL_COLOR_MODE_RGB565; |
| 126 |
case LV_COLOR_FORMAT_RGB888: |
| 127 |
return PPA_FILL_COLOR_MODE_RGB888; |
| 128 |
case LV_COLOR_FORMAT_ARGB8888: |
| 129 |
return PPA_FILL_COLOR_MODE_ARGB8888; |
| 130 |
default: |
| 131 |
return PPA_FILL_COLOR_MODE_RGB565; |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
static inline ppa_blend_color_mode_t lv_color_format_to_ppa_blend(lv_color_format_t lv_fmt) |
| 136 |
{ |
| 137 |
switch(lv_fmt) { |
| 138 |
case LV_COLOR_FORMAT_RGB565: |
| 139 |
return PPA_BLEND_COLOR_MODE_RGB565; |
| 140 |
case LV_COLOR_FORMAT_RGB888: |
| 141 |
return PPA_BLEND_COLOR_MODE_RGB888; |
| 142 |
case LV_COLOR_FORMAT_ARGB8888: |
| 143 |
return PPA_BLEND_COLOR_MODE_ARGB8888; |
| 144 |
default: |
| 145 |
return PPA_BLEND_COLOR_MODE_RGB565; |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
static inline ppa_srm_color_mode_t lv_color_format_to_ppa_srm(lv_color_format_t lv_fmt) |
| 150 |
{ |
| 151 |
switch(lv_fmt) { |
| 152 |
case LV_COLOR_FORMAT_RGB565: |
| 153 |
return PPA_SRM_COLOR_MODE_RGB565; |
| 154 |
case LV_COLOR_FORMAT_RGB888: |
| 155 |
return PPA_SRM_COLOR_MODE_RGB888; |
| 156 |
case LV_COLOR_FORMAT_XRGB8888: |
| 157 |
return PPA_SRM_COLOR_MODE_ARGB8888; |
| 158 |
default: |
| 159 |
return PPA_SRM_COLOR_MODE_RGB565; |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
#define PPA_ALIGN_UP(x, align) ((((x) + (align) - 1) / (align)) * (align)) |
| 164 |
#define PPA_PTR_ALIGN_UP(p, align) \ |
| 165 |
((void*)(((uintptr_t)(p) + (uintptr_t)((align) - 1)) & ~(uintptr_t)((align) - 1))) |
| 166 |
|
| 167 |
#define PPA_ALIGN_DOWN(x, align) ((((x) - (align) - 1) / (align)) * (align)) |
| 168 |
#define PPA_PTR_ALIGN_DOWN(p, align) \ |
| 169 |
((void*)(((uintptr_t)(p) - (uintptr_t)((align) - 1)) & ~(uintptr_t)((align) - 1))) |
| 170 |
|
| 171 |
#endif |
| 172 |
|
| 173 |
#ifdef __cplusplus |
| 174 |
} |
| 175 |
#endif |
| 176 |
|
| 177 |
#endif |