Debian Codegraph @

lvgl/docs/src/integration/chip_vendors/stm32/dma2d_gpu.rst

raw
1 .. _dma2d:
2
3 ===========
4 STM32 DMA2D
5 ===========
6
7 STM32 DMA2D is also called Chrom-ART. It will be referred to as DMA2D
8 on this page.
9
10
11 What is DMA2D
12 *************
13
14 Many STM32s come with a dedicated hardware peripheral for accelerating
15 pixel data manipulation. It works asynchronously with the CPU. If you
16 know what DMA is, it's similar to a memory-to-memory DMA engine and can even
17 be used like one, but allows specifying source and destination stride
18 and converting the data it's moving from one pixel format to another.
19 It can blend foregrounds together with backgrounds controlled by a constant
20 alpha value or from a pixel alpha channel.
21
22 LVGL integrates DMA2D as a :ref:`draw unit <draw units>`. During rendering,
23 the LVGL DMA2D draw unit will take tasks that it can perform. The ones
24 it cannot perform will be done in parallel by the software draw unit.
25 The draw tasks that the LVGL DMA2D draw unit can render are fills
26 and images. In general, the DMA2D draw unit can handle fills and images
27 that use standard color formats, no gradient, no transforms, and no radius.
28
29
30 Usage
31 *****
32
33 To use DMA2D in your project now, set :c:macro:`LV_USE_DRAW_DMA2D`
34 to ``1`` in ``lv_conf.h``. You will need to specify the header for LVGL
35 to include internally for DMA2D definitions. Set :c:macro:`LV_DRAW_DMA2D_HAL_INCLUDE`
36 to the corresponding header. E.g., if your STM32 model is an STM32U5, the
37 header name will likely be ``"stm32u5xx_hal.h"``. If you're using a framework,
38 ensure it will not be in contention with LVGL over the DMA2D peripheral.
39 LVGL uses direct memory register access to manipulate the DMA2D peripheral.
40 It does not use the STM32 HAL.
41
42 Nothing more is required for DMA2D to start working immediately, but
43 you may want to make some other considerations.
44
45 Since DMA2D is implemented in LVGL as a draw unit, it can work in parallel
46 with other draw units (typically only the software draw unit). By default,
47 any time that DMA2D is working on a draw task that LVGL depends on the
48 completion of before continuing, LVGL will spin waiting for
49 DMA2D to complete. If you would like the CPU to sleep or be scheduled to
50 other RTOS tasks while a DMA2D transfer is ongoing, do the following:
51
52 1. An RTOS/OS must be present. Set :c:macro:`LV_USE_OS` to one of the supported values
53 in ``lv_conf_template.h`` corresponding to the RTOS you're using.
54 2. Set :c:macro:`LV_USE_DRAW_DMA2D_INTERRUPT` to ``1`` in ``lv_conf.h``.
55 3. You must call
56 :cpp:expr:`lv_draw_dma2d_transfer_complete_interrupt_handler()`
57 when you receive the global interrupt that signals
58 a DMA2D transfer has completed.
59
60
61 Interop with LTDC and NeoChrom
62 ******************************
63
64 DMA2D usage can be freely mixed with LTDC usage as long as :c:macro:`LV_ST_LTDC_USE_DMA2D_FLUSH`
65 is **not** enabled. LTDC will use the DMA2D peripheral for flushing, if that is enabled.
66
67 NeoChrom and DMA2D may be enabled at the same time. They are both draw units
68 and they will both independently accept draw tasks.
69
70
71 API
72 ***
73
74 .. API startswith: lv_draw_dma2d_
75