5#if !defined(ESP_PLATFORM) || !(CONFIG_IDF_TARGET_ESP32S3)
6#warning Compilation target must be ESP32_S3 for this device.
23class Rgb565Dma :
public Rgb565 {};
26struct ColorFormatTraits<Rgb565Dma> {
33template <roo_io::ByteOrder
byte_order>
36 inline void operator()(roo::byte *dst, Color src,
37 const internal::Rgb565Dma &mode)
const {
38 ColorIo<internal::Rgb565Dma, byte_order> io;
45template <BlendingMode blending_mode>
46class Rgb565DmaBlendingWriterOperator {
48 Rgb565DmaBlendingWriterOperator(Rgb565Dma color_mode,
const Color *
color)
49 : color_mode_(color_mode), color_(
color) {}
51 void operator()(roo::byte *p, uint32_t offset) {
52 constexpr uint32_t kBytesPerPixel = ColorTraits<Rgb565Dma>::bytes_per_pixel;
53 roo::byte *cursor = p + offset * kBytesPerPixel;
54 RawFullByteBlender<Rgb565Dma, blending_mode, roo_io::kLittleEndian> blender;
55 blender(cursor, *color_++, color_mode_);
56 Cache_WriteBack_Addr((uint32_t)(p) + offset * kBytesPerPixel,
60 void operator()(roo::byte *p, uint32_t offset, uint32_t count) {
61 constexpr uint32_t kBytesPerPixel = ColorTraits<Rgb565Dma>::bytes_per_pixel;
62 roo::byte *cursor = p + offset * kBytesPerPixel;
63 RawFullByteBlender<Rgb565Dma, blending_mode, roo_io::kLittleEndian> blender;
64 uint32_t orig_count = count;
66 blender(cursor, *color_++, color_mode_);
67 cursor += kBytesPerPixel;
69 Cache_WriteBack_Addr((uint32_t)(p) + offset * kBytesPerPixel,
70 orig_count * kBytesPerPixel);
74 Rgb565Dma color_mode_;
80 roo_io::kLittleEndian> {
81 template <BlendingMode blending_mode>
82 using Operator = Rgb565DmaBlendingWriterOperator<blending_mode>;
87 roo_io::kLittleEndian, 1, uint16_t> {
93 void operator()(roo::byte *p, uint32_t offset) {
94 constexpr uint32_t kBytesPerPixel = ColorTraits<Rgb565Dma>::bytes_per_pixel;
95 roo::byte *cursor = p + offset * kBytesPerPixel;
96 ApplyRawFullByteBlending<Rgb565Dma, roo_io::kLittleEndian>(
97 blending_mode_, cursor, *color_++, Rgb565Dma());
98 Cache_WriteBack_Addr((uint32_t)(p) + offset * kBytesPerPixel,
102 void operator()(roo::byte *p, uint32_t offset, uint32_t count) {
103 constexpr uint32_t kBytesPerPixel = ColorTraits<Rgb565Dma>::bytes_per_pixel;
104 roo::byte *cursor = p + offset * kBytesPerPixel;
105 uint32_t orig_count = count;
106 while (count-- > 0) {
107 ApplyRawFullByteBlending<Rgb565Dma, roo_io::kLittleEndian>(
108 blending_mode_, cursor, *color_++, Rgb565Dma());
109 cursor += kBytesPerPixel;
111 Cache_WriteBack_Addr((uint32_t)(p) + offset * kBytesPerPixel,
112 orig_count * kBytesPerPixel);
120template <BlendingMode blending_mode>
121class Rgb565DmaBlendingFillerOperator {
123 Rgb565DmaBlendingFillerOperator(Rgb565Dma color_mode, Color
color)
126 void operator()(roo::byte *p, uint32_t offset)
const {
127 constexpr uint32_t kBytesPerPixel = ColorTraits<Rgb565Dma>::bytes_per_pixel;
128 roo::byte *cursor = p + offset * kBytesPerPixel;
129 RawFullByteBlender<Rgb565Dma, blending_mode, roo_io::kLittleEndian> blender;
130 blender(cursor, color_, Rgb565Dma());
131 Cache_WriteBack_Addr((uint32_t)(p) + offset * kBytesPerPixel,
135 void operator()(roo::byte *p, uint32_t offset, uint32_t count)
const {
136 constexpr uint32_t kBytesPerPixel = ColorTraits<Rgb565Dma>::bytes_per_pixel;
137 roo::byte *cursor = p + offset * kBytesPerPixel;
138 RawFullByteBlender<Rgb565Dma, blending_mode, roo_io::kLittleEndian> blender;
139 uint32_t orig_count = count;
140 while (count-- > 0) {
141 blender(cursor, color_, Rgb565Dma());
142 cursor += kBytesPerPixel;
144 Cache_WriteBack_Addr((uint32_t)(p) + offset * kBytesPerPixel,
145 orig_count * kBytesPerPixel);
155 roo_io::kLittleEndian> {
156 template <BlendingMode blending_mode>
157 using Operator = Rgb565DmaBlendingFillerOperator<blending_mode>;
162 roo_io::kLittleEndian, 1, uint16_t> {
168 void operator()(roo::byte *p, uint32_t offset)
const {
169 constexpr uint32_t kBytesPerPixel = ColorTraits<Rgb565Dma>::bytes_per_pixel;
170 roo::byte *cursor = p + offset * kBytesPerPixel;
171 ApplyRawFullByteBlending<Rgb565Dma, roo_io::kLittleEndian>(
172 blending_mode_, cursor, color_, Rgb565Dma());
173 Cache_WriteBack_Addr((uint32_t)(p) + offset * kBytesPerPixel,
177 void operator()(roo::byte *p, uint32_t offset, uint32_t count)
const {
178 constexpr uint32_t kBytesPerPixel = ColorTraits<Rgb565Dma>::bytes_per_pixel;
179 roo::byte *cursor = p + offset * kBytesPerPixel;
180 uint32_t orig_count = count;
181 while (count-- > 0) {
182 ApplyRawFullByteBlending<Rgb565Dma, roo_io::kLittleEndian>(
183 blending_mode_, cursor, color_, Rgb565Dma());
184 cursor += kBytesPerPixel;
186 Cache_WriteBack_Addr((uint32_t)(p) + offset * kBytesPerPixel,
187 orig_count * kBytesPerPixel);
201namespace esp32s3_dma {
205 FLUSH_MODE_AGGRESSIVE = 0,
209 FLUSH_MODE_BUFFERED = 1,
222 using ColorMode = Rgb565;
226struct Traits<FLUSH_MODE_AGGRESSIVE> {
227 using ColorMode = ::roo_display::internal::Rgb565Dma;
239 uint16_t hsync_pulse_width;
240 uint16_t hsync_back_porch;
241 uint16_t hsync_front_porch;
242 uint16_t hsync_polarity;
243 uint16_t vsync_pulse_width;
244 uint16_t vsync_back_porch;
245 uint16_t vsync_front_porch;
246 uint16_t vsync_polarity;
247 uint16_t pclk_active_neg;
248 int32_t prefer_speed;
269roo::byte *AllocateBuffer(
const Config &config);
271template <FlushMode flush_mode>
272class ParallelRgb565 :
public DisplayDevice {
274 using ColorMode = Rgb565;
275 static constexpr ColorPixelOrder pixel_order = ColorPixelOrder::kMsbFirst;
276 static constexpr ByteOrder byte_order = roo_io::kLittleEndian;
278 ParallelRgb565(Config cfg)
279 : DisplayDevice(cfg.width, cfg.height), cfg_(std::move(cfg)) {}
281 void init()
override;
283 void begin()
override {}
287 void setAddress(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
288 BlendingMode mode)
override {
289 buffer_->setAddress(x0, y0, x1, y1, mode);
292 void write(Color *
color, uint32_t pixel_count)
override;
294 void fill(Color
color, uint32_t pixel_count)
override;
296 void writePixels(BlendingMode mode, Color *
color, int16_t *x, int16_t *y,
297 uint16_t pixel_count)
override;
299 void fillPixels(BlendingMode mode, Color
color, int16_t *x, int16_t *y,
300 uint16_t pixel_count)
override;
302 void writeRects(BlendingMode mode, Color *
color, int16_t *x0, int16_t *y0,
303 int16_t *x1, int16_t *y1, uint16_t count)
override;
305 void fillRects(BlendingMode mode, Color
color, int16_t *x0, int16_t *y0,
306 int16_t *x1, int16_t *y1, uint16_t count)
override;
308 void drawDirectRect(
const roo::byte *data,
size_t row_width_bytes,
309 int16_t src_x0, int16_t src_y0, int16_t src_x1,
310 int16_t src_y1, int16_t dst_x0, int16_t dst_y0)
override;
312 void drawDirectRectAsync(
const roo::byte *data,
size_t row_width_bytes,
313 int16_t src_x0, int16_t src_y0, int16_t src_x1,
314 int16_t src_y1, int16_t dst_x0,
315 int16_t dst_y0)
override;
317 const ColorFormat &getColorFormat()
const override {
318 static const ::roo_display::internal::ColorFormatImpl<
319 Rgb565, roo_io::kLittleEndian, ColorPixelOrder::kMsbFirst>
320 format(color_mode());
324 const Rgb565 &color_mode()
const {
325 static const Rgb565 mode;
329 void orientationUpdated()
override {
330 if (buffer_ !=
nullptr) {
331 buffer_->setOrientation(orientation());
335 void flush()
override {
336 if (buffer_ !=
nullptr) {
343 inline void flushCache() {
344 uint32_t begin = (uint32_t)buffer_->buffer();
345 uint32_t size = cfg_.width * cfg_.height * 2;
346 Cache_WriteBack_Addr(begin, size);
350 OffscreenDevice<typename internal::Traits<flush_mode>::ColorMode,
351 ColorPixelOrder::kMsbFirst, roo_io::kLittleEndian>;
354 std::unique_ptr<Dev> buffer_;
357using ParallelRgb565Buffered = ParallelRgb565<FLUSH_MODE_BUFFERED>;
void operator()(roo::byte *p, uint32_t offset)
GenericFiller(ColorMode &color_mode, BlendingMode blending_mode, Color color)
void operator()(roo::byte *p, uint32_t offset)
GenericWriter(ColorMode &color_mode, BlendingMode blending_mode, Color *color)
Defines 140 opaque HTML named colors.
BlendingMode
Porter-Duff style blending modes.
@ kSourceOver
Source is placed (alpha-blended) over the destination. This is the default blending mode.
Color AlphaBlendOverOpaque(Color bgc, Color fgc)
roo_io::ByteOrder ByteOrder
BlendingMode blending_mode
void operator()(roo::byte *dst, Color src, const ColorMode &mode) const
BlendingFillerOperator< ColorMode, pixel_order, byte_order, blending_mode > Operator
BlendingWriterOperator< ColorMode, pixel_order, byte_order, blending_mode > Operator