Skip to contentSkip to conversation

Add support for DMA2D of STMicroelectronics STM32 Soc series

PATCH Superseded [email protected] 3 participants 19 messages Oct 18, 2021 – Oct 25, 2021

Subsystems (5)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add support for DMA2D of STMicroelectronics STM32 Soc series

From: Dillon Min <[email protected]>

This patchset introduces a basic support for DMA2D Interface of STMicroelectronics STM32 SoC series.

This first basic support implements R2M, M2M, M2M_PFC M2M_BLEND support will be added later on.

This has been tested on STM32469-DISCO board.

history
v5:
- rebase to media_tree https://git.linuxtv.org/media_tree.git/
- remove unused log from dma2d driver to avoid spam kernel log.
- fix 0xFFFFFF to 0xffffff, 2^24 to 2^24 -1, etc.
- introduce patch "media: v4l2-ctrls: Add V4L2_CID_COLORFX_CBCR max setting" to add V4L2_CID_COLORFX_CBCR entry.
- thanks to Hans's patch, open nullptr check in v4l2-compliance, update new test result. thanks.
https://lore.kernel.org/linux-media/[email protected]/

v4 link:
https://lore.kernel.org/lkml/[email protected]/

v4:
- replace V4L2_COLORFX_SET_ARGB, V4L2_CID_COLORFX_ARGB to V4L2_COLORFX_SET_RGB, V4L2_CID_COLORFX_RGB since Alpha paramter not used in current. thanks Hans.
v3 link:
https://lore.kernel.org/lkml/[email protected]/

v3:
- use V4L2_COLORFX_SET_ARGB, V4L2_CID_COLORFX_ARGB to pass argb paramter to the dma2d driver, instead of add stm32 private ioctl.
- some v2's patch are removed in this version.
- "[PATCH v2 7/9] media: docs: add doc for the stm32 dma2d driver"
- "[PATCH v2 8/9] media: v4l: uapi: Add user control base for stm32 dma2d controls"
- dma2d's driver changes based on Hans's review result. detail can be found at "media: stm32-dma2d: STM32 DMA2D driver"
- add stm32 clk drivers bugfix, ltdc clock disabled after kenerl boot up. v3 based on kernel and v4l-utils git:

kernel:
commit 9e1ff307c779ce1f0f810c7ecce3d95bbae40896

Author: Linus Torvalds <[email protected]>
Date:   Sun Oct 3 14:08:47 2021 -0700
    Linux 5.15-rc4

v4l-utils:
commit 700f5ded9c6de2c6dfe5d1b453d85566f95b4f0c

Author: Hans Verkuil <[email protected]>
Date:   Sat Oct 2 11:01:05 2021 +0200

test-media: show version info earlier and show cmd args

Log the version info earlier and also log the command line arguments.

v2 link:
https://lore.kernel.org/lkml/[email protected]/

v2:
- update v4l2-compliance to SHA: a4f2e3a6f306 2021-07-13 08:04:15 the test results at below [1].
- introduce Documentation/userspace-api/media/drivers/stm32-uapi.rst to explain the detail of dma2d's ioctl.
- reserved 16 ioctls from v4l2-controls.h for stm32, introduce stm32-media.h.
- collect Reviewed-by tag from Rob Herring.
- update dma2d driver from Hans's review. the details can be found at related patches.
v1 link:
https://lore.kernel.org/lkml/[email protected]/

v1:
The commit based on kernel(master): c3d0e3fd41b7f0f5d5d5b6022ab7e813f04ea727

Note for v4l2-compliance tool on nu-mmu platform:
I add two change based on v4l-utils since commit:
f0c7e3d71eaf4182bae7eb3ee0e43b4eeb047ea9

- change fork() to vfork() in v4l2-test-controls.cpp since no-mmu platform don't include fork().

with v4l2-compliance test log (with above modification):
since the stm32f469-disco ram limitation, there are 25 failed on dma_alloc_coherent()

Really appreciate if someone can help to test this patch on the STM32429I-EVAL evaluation board (https://www.st.com/en/evaluation-tools/stm32429i-eval.html)
8M x 32-bit SDRAM, 1M x 16-bit SRAM and 8M x 16-bit NOR Flash

~ # v4l2-compliance -f -d /dev/video0 > /dev/ttyprintk

[ 1798.550690] [U] v4l2-compliance 1.21.0-4855, 32 bits, 32-bit time_t
[ 1799.527504] [U] v4l2-compliance SHA: 700f5ded9c6d 2021-10-02 09:01:05
[ 1800.534558] [U] Compliance test for stm-dma2d device /dev/video0:
[ 1801.514999] [U] Driver Info:
[ 1801.998840] [U]      Driver name      : stm-dma2d
[ 1802.482151] [U]      Card type        : stm-dma2d
[ 1802.959808] [U]      Bus info         : platform:stm-dma2d
[ 1803.435715] [U]      Driver version   : 5.15.0
[ 1803.904938] [U]      Capabilities     : 0x84208000
[ 1804.371290] [U]              Video Memory-to-Memory
[ 1804.830870] [U]              Streaming
[ 1805.281465] [U]              Extended Pix Format
[ 1805.733249] [U]              Device Capabilities
[ 1806.181369] [U]      Device Caps      : 0x04208000
[ 1806.622899] [U]              Video Memory-to-Memory
[ 1807.057208] [U]              Streaming
[ 1807.483866] [U]              Extended Pix Format
[ 1807.907678] [U] Required ioctls:
[ 1808.325287] [U]      test VIDIOC_QUERYCAP: OK
[ 1808.785260] [U]      test invalid ioctls: OK
[ 1809.199015] [U] Allow for multiple opens:
[ 1809.613894] [U]      test second /dev/video0 open: OK
[ 1810.416746] [U]      test VIDIOC_QUERYCAP: OK
[ 1810.827974] [U]      test VIDIOC_G/S_PRIORITY: OK
[ 1811.466506] [U]      test for unlimited opens: OK
[ 1811.868388] [U] Debug ioctls:
[ 1812.257689] [U]      test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
[ 1813.034108] [U]      test VIDIOC_LOG_STATUS: OK (Not Supported)
[ 1813.807583] [U] Input ioctls:
[ 1814.192271] [U]      test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
[ 1814.958053] [U]      test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
[ 1815.721424] [U]      test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
[ 1816.486425] [U]      test VIDIOC_ENUMAUDIO: OK (Not Supported)
[ 1817.253873] [U]      test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
[ 1818.021773] [U]      test VIDIOC_G/S_AUDIO: OK (Not Supported)
[ 1818.783542] [U]      Inputs: 0 Audio Inputs: 0 Tuners: 0
[ 1819.170414] [U] Output ioctls:
[ 1819.549601] [U]      test VIDIOC_G/S_MODULATOR: OK (Not Supported)
[ 1820.306132] [U]      test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
[ 1821.085495] [U]      test VIDIOC_ENUMAUDOUT: OK (Not Supported)
[ 1821.883894] [U]      test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
[ 1822.698269] [U]      test VIDIOC_G/S_AUDOUT: OK (Not Supported)
[ 1823.541345] [U]      Outputs: 0 Audio Outputs: 0 Modulators: 0
[ 1824.391635] [U] Input/Output configuration ioctls:
[ 1824.830293] [U]      test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
[ 1825.708848] [U]      test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
[ 1826.608994] [U]      test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
[ 1827.520616] [U]      test VIDIOC_G/S_EDID: OK (Not Supported)
[ 1828.438211] [U] Control ioctls:
[ 1828.926449] [U]      test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
[ 1829.856497] [U]      test VIDIOC_QUERYCTRL: OK
[ 1830.335647] [U]      test VIDIOC_G/S_CTRL: OK
[ 1830.816513] [U]      test VIDIOC_G/S/TRY_EXT_CTRLS: OK
[ 1831.740067] [U]      test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
[ 1832.666736] [U]      test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
[ 1833.597005] [U]      Standard Controls: 3 Private Controls: 0
[ 1834.070452] [U] Format ioctls:
[ 1834.540460] [U]      test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
[ 1835.473065] [U]      test VIDIOC_G/S_PARM: OK (Not Supported)
[ 1836.395238] [U]      test VIDIOC_G_FBUF: OK (Not Supported)
[ 1837.322128] [U]      test VIDIOC_G_FMT: OK
[ 1837.798880] [U]      test VIDIOC_TRY_FMT: OK
[ 1838.267574] [U]      test VIDIOC_S_FMT: OK
[ 1838.724264] [U]      test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
[ 1839.627408] [U]      test Cropping: OK (Not Supported)
[ 1840.526875] [U]      test Composing: OK (Not Supported)
[ 1841.428562] [U]      test Scaling: OK
[ 1841.882087] [U] Codec ioctls:
[ 1842.331672] [U]      test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
[ 1843.221419] [U]      test VIDIOC_G_ENC_INDEX: OK (Not Supported)
[ 1844.105854] [U]      test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
[ 1844.993986] [U] Buffer ioctls:
[ 1845.558827] [U]      test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
[ 1846.486226] [U]      test VIDIOC_EXPBUF: OK
[ 1846.936148] [U]      test Requests: OK (Not Supported)
[ 1847.805687] [U]      test TIME32/64: OK
[ 1848.255712] [U] Test input 0:
[ 1848.685591] [U] Stream using all formats:
[ 1853.598085] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1858.085109] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1861.799188] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1864.859534] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1867.974755] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1868.466365] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1868.971398] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1869.487572] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 1870.017197] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1870.562272] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1871.147644] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1871.780530] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1872.431797] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1873.112100] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1873.805156] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1874.492353] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1875.221576] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1876.000283] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1876.808963] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1877.634785] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1883.283141] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1888.533587] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1892.729322] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1896.013783] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1899.195802] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1902.318853] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1905.399663] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1908.515463] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1911.589775] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1914.682147] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1915.169478] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1915.671278] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1916.184281] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 1916.709840] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1917.252352] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1917.834611] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1918.463784] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1919.114290] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1919.789982] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1920.479624] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1921.165202] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1921.893374] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1922.668057] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1923.469342] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1924.297500] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1929.890593] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1935.098497] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1939.250033] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1942.503854] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1945.659254] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1948.763903] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1951.832407] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1954.927592] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1957.991536] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1961.086603] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1961.575893] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1962.079572] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1962.594354] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 1963.121249] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1963.665788] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1964.249129] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1964.880104] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1965.530670] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1966.210598] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1966.902316] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1967.590215] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1968.319871] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1969.097012] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1969.900036] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1970.729920] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1976.318963] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1981.494224] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1985.599406] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1988.829141] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1991.998991] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1995.084529] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1998.191853] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 2001.307217] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 2004.413725] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 2007.527437] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 2008.016277] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2008.523318] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2009.038828] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 2009.567269] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2010.112209] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2010.697226] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 2011.329552] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2011.979307] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2012.658449] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 2013.350104] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2014.035612] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2014.762649] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 2015.538183] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2016.338784] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2017.166692] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 2022.744387] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 2027.927575] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 2032.066337] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 2035.295351] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 2038.476408] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 2041.591223] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 2044.678274] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 2047.774851] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 2050.849788] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 2053.955560] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 2054.446212] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2054.951517] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2055.467584] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 2055.997127] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2056.543193] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2057.128457] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 2057.761407] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2058.413191] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2059.093749] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 2059.786201] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2060.472393] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2061.200709] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 2061.977728] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2062.780816] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2063.610351] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 2069.207680] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 2074.392036] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 2078.538621] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 2081.749134] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 2084.922145] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 2085.416538] [U] Total for stm-dma2d device /dev/video0: 121, Succeeded: 96, Failed: 25, Warnings: 0

*** BLURB HERE ***

Dillon Min (10):
media: admin-guide: add stm32-dma2d description
media: dt-bindings: media: add document for STM32 DMA2d bindings
ARM: dts: stm32: Add DMA2D support for STM32F429 series soc
ARM: dts: stm32: Enable DMA2D on STM32F469-DISCO board
media: v4l2-mem2mem: add v4l2_m2m_get_unmapped_area for no-mmu
platform
media: videobuf2: Fix the size printk format
media: v4l2-ctrls: Add V4L2_CID_COLORFX_CBCR max setting
media: v4l2-ctrls: Add RGB color effects control
clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after
system enter shell
media: stm32-dma2d: STM32 DMA2D driver

 .../admin-guide/media/platform-cardlist.rst        |   1 +
 .../devicetree/bindings/media/st,stm32-dma2d.yaml  |  71 ++
 Documentation/userspace-api/media/v4l/control.rst  |   9 +
 arch/arm/boot/dts/stm32f429.dtsi                   |  10 +
 arch/arm/boot/dts/stm32f469-disco.dts              |   4 +
 drivers/clk/clk-stm32f4.c                          |   4 -
 .../media/common/videobuf2/videobuf2-dma-contig.c  |   4 +-
 drivers/media/platform/Kconfig                     |  11 +
 drivers/media/platform/Makefile                    |   1 +
 drivers/media/platform/stm32/Makefile              |   2 +
 drivers/media/platform/stm32/dma2d/dma2d-hw.c      | 143 ++++
 drivers/media/platform/stm32/dma2d/dma2d-regs.h    | 113 ++++
 drivers/media/platform/stm32/dma2d/dma2d.c         | 739 +++++++++++++++++++++
 drivers/media/platform/stm32/dma2d/dma2d.h         | 135 ++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c          |  12 +-
 drivers/media/v4l2-core/v4l2-mem2mem.c             |  21 +
 include/media/v4l2-mem2mem.h                       |   5 +
 include/uapi/linux/v4l2-controls.h                 |   4 +-
 18 files changed, 1280 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/st,stm32-dma2d.yaml
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-hw.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-regs.h
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v5 1/10 media: admin-guide: add stm32-dma2d description

From: Dillon Min <[email protected]>

add stm32-dma2d description for dma2d driver

---
v5: no change.

 Documentation/admin-guide/media/platform-cardlist.rst | 1 +
 1 file changed, 1 insertion(+)
Documentation/admin-guide/media/platform-cardlist.rst +1 -0
index 261e7772eb3e..ac73c4166d1e 100644
@@ -60,6 +60,7 @@ s5p-mfc            Samsung S5P MFC Video Codec
 sh_veu             SuperH VEU mem2mem video processing
 sh_vou             SuperH VOU video output
 stm32-dcmi         STM32 Digital Camera Memory Interface (DCMI)
+stm32-dma2d        STM32 Chrom-Art Accelerator Unit
 sun4i-csi          Allwinner A10 CMOS Sensor Interface Support
 sun6i-csi          Allwinner V3s Camera Sensor Interface
 sun8i-di           Allwinner Deinterlace
Signature · 1 line
2.7.4
#2 lore raw

PATCH v5 2/10 media: dt-bindings: media: add document for STM32 DMA2d bindings

In reply to [email protected]

From: Dillon Min <[email protected]>

This adds documentation of device tree bindings for the STM32 DMA2D

---
v5: no change.

 .../devicetree/bindings/media/st,stm32-dma2d.yaml  | 71 ++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/st,stm32-dma2d.yaml
Documentation/devicetree/bindings/media/st,stm32-dma2d.yaml new file +71 -0
new file mode 100644
index 000000000000..f97b4a246605
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/st,stm32-dma2d.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STMicroelectronics STM32 Chrom-Art Accelerator DMA2D binding
+
+description:
+  Chrom-ART Accelerator(DMA2D), graphical hardware accelerator
+  enabling enhanced graphical user interface with minimum CPU load
+
+  It can perform the following operations.
+
+  - Filling a part or the whole of a destination image with a specific color.
+  - Copying a part or the whole of a source image into a part or the whole of
+    a destination image.
+  - Copying a part or the whole of a source image into a part or the whole of
+    a destination image with a pixel format conversion.
+  - Blending a part and/or two complete source images with different pixel
+    format and copy the result into a part or the whole of a destination image
+    with a different color format. (TODO)
+
+
+maintainers:
+  - Dillon Min <[email protected]>
+
+properties:
+  compatible:
+    const: st,stm32-dma2d
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: dma2d
+
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/stm32fx-clock.h>
+    #include <dt-bindings/mfd/stm32f4-rcc.h>
+    dma2d: dma2d@4002b000 {
+        compatible = "st,stm32-dma2d";
+        reg = <0x4002b000 0xc00>;
+        interrupts = <90>;
+        resets = <&rcc STM32F4_AHB1_RESET(DMA2D)>;
+        clocks = <&rcc 0 STM32F4_AHB1_CLOCK(DMA2D)>;
+        clock-names = "dma2d";
+    };
+
+...
Signature · 1 line
2.7.4
#3 lore raw

PATCH v5 3/10 ARM: dts: stm32: Add DMA2D support for STM32F429 series soc

In reply to [email protected]

From: Dillon Min <[email protected]>

Add DMA2D for STM32F429 series soc.

---
v5: no change.

 arch/arm/boot/dts/stm32f429.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/stm32f429.dtsi +10 -0
index 8748d5850298..1d8be5e7c8b8 100644
@@ -743,6 +743,16 @@
 			st,mem2mem;
 		};
 
+		dma2d: dma2d@4002b000 {
+			compatible = "st,stm32-dma2d";
+			reg = <0x4002b000 0xc00>;
+			interrupts = <90>;
+			resets = <&rcc STM32F4_AHB1_RESET(DMA2D)>;
+			clocks = <&rcc 0 STM32F4_AHB1_CLOCK(DMA2D)>;
+			clock-names = "dma2d";
+			status = "disabled";
+		};
+
 		mac: ethernet@40028000 {
 			compatible = "st,stm32-dwmac", "snps,dwmac-3.50a";
 			reg = <0x40028000 0x8000>;
Signature · 1 line
2.7.4
#4 lore raw

PATCH v5 4/10 ARM: dts: stm32: Enable DMA2D on STM32F469-DISCO board

In reply to [email protected]

From: Dillon Min <[email protected]>

Enable DMA2D on STM32F469-DISCO board.

---
v5: no change.

 arch/arm/boot/dts/stm32f469-disco.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/stm32f469-disco.dts +4 -0
index 30905ce672a0..ba26a3375b0d 100644
@@ -132,6 +132,10 @@
 	clock-frequency = <8000000>;
 };
 
+&dma2d {
+	status = "okay";
+};
+
 &dsi {
 	#address-cells = <1>;
 	#size-cells = <0>;
Signature · 1 line
2.7.4
#5 lore raw

PATCH v5 5/10 media: v4l2-mem2mem: add v4l2_m2m_get_unmapped_area for no-mmu platform

In reply to [email protected]

From: Dillon Min <[email protected]>

For platforms without MMU the m2m provides a helper method v4l2_m2m_get_unmapped_area(), The mmap() routines will call this to get a proposed address for the mapping.

More detailed information about get_unmapped_area can be found in Documentation/nommu-mmap.txt

---
v5: no change.

 drivers/media/v4l2-core/v4l2-mem2mem.c | 21 +++++++++++++++++++++
 include/media/v4l2-mem2mem.h           |  5 +++++
 2 files changed, 26 insertions(+)
drivers/media/v4l2-core/v4l2-mem2mem.c +21 -0
index e7f4bf5bc8dd..e2654b422334 100644
@@ -966,6 +966,27 @@ int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
 }
 EXPORT_SYMBOL(v4l2_m2m_mmap);
 
+#ifndef CONFIG_MMU
+unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr,
+					 unsigned long len, unsigned long pgoff,
+					 unsigned long flags)
+{
+	struct v4l2_fh *fh = file->private_data;
+	unsigned long offset = pgoff << PAGE_SHIFT;
+	struct vb2_queue *vq;
+
+	if (offset < DST_QUEUE_OFF_BASE) {
+		vq = v4l2_m2m_get_src_vq(fh->m2m_ctx);
+	} else {
+		vq = v4l2_m2m_get_dst_vq(fh->m2m_ctx);
+		pgoff -= (DST_QUEUE_OFF_BASE >> PAGE_SHIFT);
+	}
+
+	return vb2_get_unmapped_area(vq, addr, len, pgoff, flags);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_get_unmapped_area);
+#endif
+
 #if defined(CONFIG_MEDIA_CONTROLLER)
 void v4l2_m2m_unregister_media_controller(struct v4l2_m2m_dev *m2m_dev)
 {
include/media/v4l2-mem2mem.h +5 -0
index 5a91b548ecc0..fdbd5257e020 100644
@@ -495,6 +495,11 @@ __poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
 int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
 		  struct vm_area_struct *vma);
 
+#ifndef CONFIG_MMU
+unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr,
+					 unsigned long len, unsigned long pgoff,
+					 unsigned long flags);
+#endif
 /**
  * v4l2_m2m_init() - initialize per-driver m2m data
  *
Signature · 1 line
2.7.4
#6 lore raw

PATCH v5 6/10 media: videobuf2: Fix the size printk format

In reply to [email protected]

From: Dillon Min <[email protected]>

Since the type of parameter size is unsigned long, it should printk by %lu, instead of %ld, fix it.

Fixes 7952be9b6ece ("media: drivers/media/common/videobuf2: rename from videobuf")
---
 drivers/media/common/videobuf2/videobuf2-dma-contig.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/common/videobuf2/videobuf2-dma-contig.c +2 -2
index b052a4e36961..28b917e03929 100644
@@ -257,7 +257,7 @@ static void *vb2_dc_alloc(struct vb2_buffer *vb,
 		ret = vb2_dc_alloc_coherent(buf);
 
 	if (ret) {
-		dev_err(dev, "dma alloc of size %ld failed\n", size);
+		dev_err(dev, "dma alloc of size %lu failed\n", size);
 		kfree(buf);
 		return ERR_PTR(-ENOMEM);
 	}
@@ -298,7 +298,7 @@ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
 
 	vma->vm_ops->open(vma);
 
-	pr_debug("%s: mapped dma addr 0x%08lx at 0x%08lx, size %ld\n",
+	pr_debug("%s: mapped dma addr 0x%08lx at 0x%08lx, size %lu\n",
 		 __func__, (unsigned long)buf->dma_addr, vma->vm_start,
 		 buf->size);
 
Signature · 1 line
2.7.4
#7 lore raw

PATCH v5 7/10 media: v4l2-ctrls: Add V4L2_CID_COLORFX_CBCR max setting

In reply to [email protected]

From: Dillon Min <[email protected]>

The max of V4L2_CID_COLORFX_CBCR is 0xffff, so add it to v4l2_ctrl_fill() to sure not beyond that.

---
 drivers/media/v4l2-core/v4l2-ctrls-defs.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls-defs.c +6 -0
index ebe82b6ba6e6..0cb6c0f18b39 100644
@@ -1400,6 +1400,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 		/* Max is calculated as RGB888 that is 2^24 */
 		*max = 0xFFFFFF;
 		break;
+	case V4L2_CID_COLORFX_CBCR:
+		*type = V4L2_CTRL_TYPE_INTEGER;
+		*step = 1;
+		*min = 0;
+		*max = 0xffff;
+		break;
 	case V4L2_CID_FLASH_FAULT:
 	case V4L2_CID_JPEG_ACTIVE_MARKER:
 	case V4L2_CID_3A_LOCK:
Signature · 1 line
2.7.4
#8 lore raw

PATCH v5 8/10 media: v4l2-ctrls: Add RGB color effects control

In reply to [email protected]

From: Dillon Min <[email protected]>

Add V4L2_COLORFX_SET_RGB color effects control, V4L2_CID_COLORFX_RGB for RGB color setting.

with two mirror changes:
- change 0xFFFFFF to 0xffffff
- fix comments 2^24 to 2^24 - 1

---
v5:
- change 0xFFFFFF to 0xffffff.
- change 2^24 to 2^24 -1.

 Documentation/userspace-api/media/v4l/control.rst | 9 +++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c         | 6 ++++--
 include/uapi/linux/v4l2-controls.h                | 4 +++-
 3 files changed, 16 insertions(+), 3 deletions(-)
Documentation/userspace-api/media/v4l/control.rst +9 -0
index f8d0b923da20..3eec65174260 100644
@@ -242,8 +242,17 @@ Control IDs
     * - ``V4L2_COLORFX_SET_CBCR``
       - The Cb and Cr chroma components are replaced by fixed coefficients
 	determined by ``V4L2_CID_COLORFX_CBCR`` control.
+    * - ``V4L2_COLORFX_SET_RGB``
+      - The RGB components are replaced by the fixed RGB components determined
+        by ``V4L2_CID_COLORFX_RGB`` control.
 
 
+``V4L2_CID_COLORFX_RGB`` ``(integer)``
+    Determines the Red, Green, and Blue coefficients for
+    ``V4L2_COLORFX_SET_RGB`` color effect.
+    Bits [7:0] of the supplied 32 bit value are interpreted as Blue component,
+    bits [15:8] as Green component, bits [23:16] as Red component, and
+    bits [31:24] must be zero.
 
 ``V4L2_CID_COLORFX_CBCR`` ``(integer)``
     Determines the Cb and Cr coefficients for ``V4L2_COLORFX_SET_CBCR``
drivers/media/v4l2-core/v4l2-ctrls-defs.c +4 -2
index 0cb6c0f18b39..6f00f8e4b4a6 100644
@@ -785,6 +785,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:	return "Min Number of Output Buffers";
 	case V4L2_CID_ALPHA_COMPONENT:		return "Alpha Component";
 	case V4L2_CID_COLORFX_CBCR:		return "Color Effects, CbCr";
+	case V4L2_CID_COLORFX_RGB:              return "Color Effects, RGB";
 
 	/*
 	 * Codec controls
@@ -1394,11 +1395,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 		*min = *max = *step = *def = 0;
 		break;
 	case V4L2_CID_BG_COLOR:
+	case V4L2_CID_COLORFX_RGB:
 		*type = V4L2_CTRL_TYPE_INTEGER;
 		*step = 1;
 		*min = 0;
-		/* Max is calculated as RGB888 that is 2^24 */
-		*max = 0xFFFFFF;
+		/* Max is calculated as RGB888 that is 2^24 -1 */
+		*max = 0xffffff;
 		break;
 	case V4L2_CID_COLORFX_CBCR:
 		*type = V4L2_CTRL_TYPE_INTEGER;
include/uapi/linux/v4l2-controls.h +3 -1
index 133e20444939..00bb181b56cc 100644
@@ -128,6 +128,7 @@ enum v4l2_colorfx {
 	V4L2_COLORFX_SOLARIZATION		= 13,
 	V4L2_COLORFX_ANTIQUE			= 14,
 	V4L2_COLORFX_SET_CBCR			= 15,
+	V4L2_COLORFX_SET_RGB			= 16,
 };
 #define V4L2_CID_AUTOBRIGHTNESS			(V4L2_CID_BASE+32)
 #define V4L2_CID_BAND_STOP_FILTER		(V4L2_CID_BASE+33)
@@ -145,9 +146,10 @@ enum v4l2_colorfx {
 
 #define V4L2_CID_ALPHA_COMPONENT		(V4L2_CID_BASE+41)
 #define V4L2_CID_COLORFX_CBCR			(V4L2_CID_BASE+42)
+#define V4L2_CID_COLORFX_RGB			(V4L2_CID_BASE+43)
 
 /* last CID + 1 */
-#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+43)
+#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+44)
 
 /* USER-class private control IDs */
 
Signature · 1 line
2.7.4
#9 lore raw

PATCH v5 9/10 clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after system enter shell

In reply to [email protected]

From: Dillon Min <[email protected]>

stm32's clk driver register two ltdc gate clk to clk core by clk_hw_register_gate() and clk_hw_register_composite()

first: 'stm32f429_gates[]', clk name is 'ltdc', which no user to use.
second: 'stm32f429_aux_clk[]', clk name is 'lcd-tft', used by ltdc driver

both of them point to the same offset of stm32's RCC register. after kernel enter console, clk core turn off ltdc's clk as 'stm32f429_gates[]' is no one to use. but, actually 'stm32f429_aux_clk[]' is in use.

stm32f469/746/769 have the same issue, fix it.

---
v5: no change.

 drivers/clk/clk-stm32f4.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/clk/clk-stm32f4.c +0 -4
index af46176ad053..473dfe632cc5 100644
@@ -129,7 +129,6 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = {
 	{ STM32F4_RCC_APB2ENR, 20,	"spi5",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 21,	"spi6",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 22,	"sai1",		"apb2_div" },
-	{ STM32F4_RCC_APB2ENR, 26,	"ltdc",		"apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f469_gates[] __initconst = {
@@ -211,7 +210,6 @@ static const struct stm32f4_gate_data stm32f469_gates[] __initconst = {
 	{ STM32F4_RCC_APB2ENR, 20,	"spi5",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 21,	"spi6",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 22,	"sai1",		"apb2_div" },
-	{ STM32F4_RCC_APB2ENR, 26,	"ltdc",		"apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f746_gates[] __initconst = {
@@ -286,7 +284,6 @@ static const struct stm32f4_gate_data stm32f746_gates[] __initconst = {
 	{ STM32F4_RCC_APB2ENR, 21,	"spi6",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 22,	"sai1",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 23,	"sai2",		"apb2_div" },
-	{ STM32F4_RCC_APB2ENR, 26,	"ltdc",		"apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f769_gates[] __initconst = {
@@ -364,7 +361,6 @@ static const struct stm32f4_gate_data stm32f769_gates[] __initconst = {
 	{ STM32F4_RCC_APB2ENR, 21,	"spi6",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 22,	"sai1",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 23,	"sai2",		"apb2_div" },
-	{ STM32F4_RCC_APB2ENR, 26,	"ltdc",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 30,	"mdio",		"apb2_div" },
 };
 
Signature · 1 line
2.7.4
#10 lore raw

Re: [PATCH v5 09/10] clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after system enter shell

Hi Dillon,

Quoted 8 lines · On 18/10/2021 07:04, [email protected] wrote:

From: Dillon Min <[email protected]>

stm32's clk driver register two ltdc gate clk to clk core by clk_hw_register_gate() and clk_hw_register_composite()

first: 'stm32f429_gates[]', clk name is 'ltdc', which no user to use.
second: 'stm32f429_aux_clk[]', clk name is 'lcd-tft', used by ltdc driver

Quoted 8 lines

both of them point to the same offset of stm32's RCC register. after kernel enter console, clk core turn off ltdc's clk as 'stm32f429_gates[]' is no one to use. but, actually 'stm32f429_aux_clk[]' is in use.

stm32f469/746/769 have the same issue, fix it.

Fixes daf2d117cbca ("clk: stm32f4: Add lcd-tft clock")

Just to double check (I asked as well when v1 was posted, but that's a long time ago):
I can ignore this patch, right? If so, then make sure you follow up on this in the clk subsystem since it is not yet merged in mainline.

If you DO want me to pick it up, then I see that the clk maintainer has already Acked it, so I take it as well.

Regards,

Hans

Quoted 46 lines

---
v5: no change.

 drivers/clk/clk-stm32f4.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/clk/clk-stm32f4.c +0 -4
index af46176ad053..473dfe632cc5 100644
@@ -129,7 +129,6 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = {
 	{ STM32F4_RCC_APB2ENR, 20,	"spi5",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 21,	"spi6",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 22,	"sai1",		"apb2_div" },
-	{ STM32F4_RCC_APB2ENR, 26,	"ltdc",		"apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f469_gates[] __initconst = {
@@ -211,7 +210,6 @@ static const struct stm32f4_gate_data stm32f469_gates[] __initconst = {
 	{ STM32F4_RCC_APB2ENR, 20,	"spi5",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 21,	"spi6",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 22,	"sai1",		"apb2_div" },
-	{ STM32F4_RCC_APB2ENR, 26,	"ltdc",		"apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f746_gates[] __initconst = {
@@ -286,7 +284,6 @@ static const struct stm32f4_gate_data stm32f746_gates[] __initconst = {
 	{ STM32F4_RCC_APB2ENR, 21,	"spi6",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 22,	"sai1",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 23,	"sai2",		"apb2_div" },
-	{ STM32F4_RCC_APB2ENR, 26,	"ltdc",		"apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f769_gates[] __initconst = {
@@ -364,7 +361,6 @@ static const struct stm32f4_gate_data stm32f769_gates[] __initconst = {
 	{ STM32F4_RCC_APB2ENR, 21,	"spi6",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 22,	"sai1",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 23,	"sai2",		"apb2_div" },
-	{ STM32F4_RCC_APB2ENR, 26,	"ltdc",		"apb2_div" },
 	{ STM32F4_RCC_APB2ENR, 30,	"mdio",		"apb2_div" },
 };
 
author
#11 lore raw

Re: [PATCH v5 09/10] clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after system enter shell

Hi Hans

Quoted 21 lines · Hans Verkuil

Hi Dillon,

Quoted 8 lines · On 18/10/2021 07:04, [email protected] wrote:

From: Dillon Min <[email protected]>

stm32's clk driver register two ltdc gate clk to clk core by clk_hw_register_gate() and clk_hw_register_composite()

first: 'stm32f429_gates[]', clk name is 'ltdc', which no user to use.
second: 'stm32f429_aux_clk[]', clk name is 'lcd-tft', used by ltdc driver

Quoted 8 lines

both of them point to the same offset of stm32's RCC register. after kernel enter console, clk core turn off ltdc's clk as 'stm32f429_gates[]' is no one to use. but, actually 'stm32f429_aux_clk[]' is in use.

stm32f469/746/769 have the same issue, fix it.

Fixes daf2d117cbca ("clk: stm32f4: Add lcd-tft clock")
Quoted 6 lines

Just to double check (I asked as well when v1 was posted, but that's a long time ago):
I can ignore this patch, right? If so, then make sure you follow up on this in the clk subsystem since it is not yet merged in mainline.

If you DO want me to pick it up, then I see that the clk maintainer has already Acked it, so I take it as well.

Appreciate, please help to pick it up.

Thanks & Regards
Dillon

Quoted 52 lines

Regards,

Hans

Quoted 46 lines

---
v5: no change.

 drivers/clk/clk-stm32f4.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/clk/clk-stm32f4.c +0 -4
index af46176ad053..473dfe632cc5 100644
@@ -129,7 +129,6 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = {
      { STM32F4_RCC_APB2ENR, 20,      "spi5",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 21,      "spi6",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 22,      "sai1",         "apb2_div" },
-     { STM32F4_RCC_APB2ENR, 26,      "ltdc",         "apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f469_gates[] __initconst = {
@@ -211,7 +210,6 @@ static const struct stm32f4_gate_data stm32f469_gates[] __initconst = {
      { STM32F4_RCC_APB2ENR, 20,      "spi5",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 21,      "spi6",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 22,      "sai1",         "apb2_div" },
-     { STM32F4_RCC_APB2ENR, 26,      "ltdc",         "apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f746_gates[] __initconst = {
@@ -286,7 +284,6 @@ static const struct stm32f4_gate_data stm32f746_gates[] __initconst = {
      { STM32F4_RCC_APB2ENR, 21,      "spi6",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 22,      "sai1",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 23,      "sai2",         "apb2_div" },
-     { STM32F4_RCC_APB2ENR, 26,      "ltdc",         "apb2_div" },
 };
 
 static const struct stm32f4_gate_data stm32f769_gates[] __initconst = {
@@ -364,7 +361,6 @@ static const struct stm32f4_gate_data stm32f769_gates[] __initconst = {
      { STM32F4_RCC_APB2ENR, 21,      "spi6",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 22,      "sai1",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 23,      "sai2",         "apb2_div" },
-     { STM32F4_RCC_APB2ENR, 26,      "ltdc",         "apb2_div" },
      { STM32F4_RCC_APB2ENR, 30,      "mdio",         "apb2_div" },
 };
 
#12 lore raw

PATCH v5 10/10 media: stm32-dma2d: STM32 DMA2D driver

In reply to [email protected]

From: Dillon Min <[email protected]>

This V4L2 subdev m2m driver enables Chrom-Art Accelerator unit of STMicroelectronics STM32 SoC series.

Currently support r2m, m2m, m2m_pfc functions.
- r2m, Filling a part or the whole of a destination image with a specific color.
- m2m, Copying a part or the whole of a source image into a part or the whole of a destination.
- m2m_pfc, Copying a part or the whole of a source image into a part or the whole of a destination image with a pixel format conversion.

---
v5:
- remove useless log from dma2d driver.
- update config VIDEO_STM32_DMA2D description.

 drivers/media/platform/Kconfig                  |  11 +
 drivers/media/platform/Makefile                 |   1 +
 drivers/media/platform/stm32/Makefile           |   2 +
 drivers/media/platform/stm32/dma2d/dma2d-hw.c   | 143 +++++
 drivers/media/platform/stm32/dma2d/dma2d-regs.h | 113 ++++
 drivers/media/platform/stm32/dma2d/dma2d.c      | 739 ++++++++++++++++++++++++
 drivers/media/platform/stm32/dma2d/dma2d.h      | 135 +++++
 7 files changed, 1144 insertions(+)
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-hw.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-regs.h
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.h
drivers/media/platform/Kconfig +11 -0
index d9f90084c2f6..0b3bdf56b44e 100644
@@ -476,6 +476,17 @@ config VIDEO_STI_DELTA_DRIVER
 
 endif # VIDEO_STI_DELTA
 
+config VIDEO_STM32_DMA2D
+	tristate "STM32 Chrom-Art Accelerator (DMA2D)"
+	depends on (VIDEO_DEV && VIDEO_V4L2 && ARCH_STM32) || COMPILE_TEST
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_MEM2MEM_DEV
+	help
+	  Enables DMA2D hwarware support on stm32.
+
+	  The STM32 DMA2D is a memory-to-memory engine for pixel conversion
+	  and specialized DMA dedicated to image manipulation.
+
 config VIDEO_RENESAS_FDP1
 	tristate "Renesas Fine Display Processor"
 	depends on VIDEO_DEV && VIDEO_V4L2
drivers/media/platform/Makefile +1 -0
index 73ce083c2fc6..46f1c05bc576 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_VIDEO_ATMEL_ISI)		+= atmel/
 obj-$(CONFIG_VIDEO_ATMEL_XISC)		+= atmel/
 
 obj-$(CONFIG_VIDEO_STM32_DCMI)		+= stm32/
+obj-$(CONFIG_VIDEO_STM32_DMA2D)		+= stm32/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)	+= mtk-vpu/
 
drivers/media/platform/stm32/Makefile +2 -0
index 48b36db2c2e2..896ef98a73ab 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_VIDEO_STM32_DCMI) += stm32-dcmi.o
+stm32-dma2d-objs := dma2d/dma2d.o dma2d/dma2d-hw.o
+obj-$(CONFIG_VIDEO_STM32_DMA2D) += stm32-dma2d.o
drivers/media/platform/stm32/dma2d/dma2d-hw.c new file +143 -0

143 lines not on this page · raw message

drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +113 -0

113 lines not on this page · raw message

drivers/media/platform/stm32/dma2d/dma2d.c new file +739 -0

739 lines not on this page · raw message

drivers/media/platform/stm32/dma2d/dma2d.h new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
2.7.4
#13 lore raw

Re: [PATCH v5 10/10] media: stm32-dma2d: STM32 DMA2D driver

Quoted 324 lines · On 18/10/2021 07:04, [email protected] wrote:

From: Dillon Min <[email protected]>

This V4L2 subdev m2m driver enables Chrom-Art Accelerator unit of STMicroelectronics STM32 SoC series.

Currently support r2m, m2m, m2m_pfc functions.
- r2m, Filling a part or the whole of a destination image with a specific color.
- m2m, Copying a part or the whole of a source image into a part or the whole of a destination.
- m2m_pfc, Copying a part or the whole of a source image into a part or the whole of a destination image with a pixel format conversion.

---
v5:
- remove useless log from dma2d driver.
- update config VIDEO_STM32_DMA2D description.

 drivers/media/platform/Kconfig                  |  11 +
 drivers/media/platform/Makefile                 |   1 +
 drivers/media/platform/stm32/Makefile           |   2 +
 drivers/media/platform/stm32/dma2d/dma2d-hw.c   | 143 +++++
 drivers/media/platform/stm32/dma2d/dma2d-regs.h | 113 ++++
 drivers/media/platform/stm32/dma2d/dma2d.c      | 739 ++++++++++++++++++++++++
 drivers/media/platform/stm32/dma2d/dma2d.h      | 135 +++++
 7 files changed, 1144 insertions(+)
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-hw.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-regs.h
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.h
drivers/media/platform/Kconfig +11 -0
index d9f90084c2f6..0b3bdf56b44e 100644
@@ -476,6 +476,17 @@ config VIDEO_STI_DELTA_DRIVER
 
 endif # VIDEO_STI_DELTA
 
+config VIDEO_STM32_DMA2D
+	tristate "STM32 Chrom-Art Accelerator (DMA2D)"
+	depends on (VIDEO_DEV && VIDEO_V4L2 && ARCH_STM32) || COMPILE_TEST
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_MEM2MEM_DEV
+	help
+	  Enables DMA2D hwarware support on stm32.
+
+	  The STM32 DMA2D is a memory-to-memory engine for pixel conversion
+	  and specialized DMA dedicated to image manipulation.
+
 config VIDEO_RENESAS_FDP1
 	tristate "Renesas Fine Display Processor"
 	depends on VIDEO_DEV && VIDEO_V4L2
drivers/media/platform/Makefile +1 -0
index 73ce083c2fc6..46f1c05bc576 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_VIDEO_ATMEL_ISI)		+= atmel/
 obj-$(CONFIG_VIDEO_ATMEL_XISC)		+= atmel/
 
 obj-$(CONFIG_VIDEO_STM32_DCMI)		+= stm32/
+obj-$(CONFIG_VIDEO_STM32_DMA2D)		+= stm32/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)	+= mtk-vpu/
 
drivers/media/platform/stm32/Makefile +2 -0
index 48b36db2c2e2..896ef98a73ab 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_VIDEO_STM32_DCMI) += stm32-dcmi.o
+stm32-dma2d-objs := dma2d/dma2d.o dma2d/dma2d-hw.o
+obj-$(CONFIG_VIDEO_STM32_DMA2D) += stm32-dma2d.o
drivers/media/platform/stm32/dma2d/dma2d-hw.c new file +143 -0
new file mode 100644
index 000000000000..8c1c664ab13b
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * ST stm32 Chrom-Art - 2D Graphics Accelerator Driver
+ *
+ * Copyright (c) 2021 Dillon Min
+ * Dillon Min, <[email protected]>
+ *
+ * based on s5p-g2d
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * Kamil Debski, <[email protected]>
+ */
+
+#include <linux/io.h>
+
+#include "dma2d.h"
+#include "dma2d-regs.h"
+
+static inline u32 reg_read(void __iomem *base, u32 reg)
+{
+	return readl_relaxed(base + reg);
+}
+
+static inline void reg_write(void __iomem *base, u32 reg, u32 val)
+{
+	writel_relaxed(val, base + reg);
+}
+
+static inline void reg_set(void __iomem *base, u32 reg, u32 mask)
+{
+	reg_write(base, reg, reg_read(base, reg) | mask);
+}
+
+static inline void reg_clear(void __iomem *base, u32 reg, u32 mask)
+{
+	reg_write(base, reg, reg_read(base, reg) & ~mask);
+}
+
+static inline void reg_update_bits(void __iomem *base, u32 reg, u32 mask,
+				   u32 val)
+{
+	reg_write(base, reg, (reg_read(base, reg) & ~mask) | val);
+}
+
+void dma2d_start(struct dma2d_dev *d)
+{
+	reg_update_bits(d->regs, DMA2D_CR_REG, CR_START, CR_START);
+}
+
+u32 dma2d_get_int(struct dma2d_dev *d)
+{
+	return reg_read(d->regs, DMA2D_ISR_REG);
+}
+
+void dma2d_clear_int(struct dma2d_dev *d)
+{
+	u32 isr_val = reg_read(d->regs, DMA2D_ISR_REG);
+
+	reg_write(d->regs, DMA2D_IFCR_REG, isr_val & 0x003f);
+}
+
+void dma2d_config_common(struct dma2d_dev *d, enum dma2d_op_mode op_mode,
+			 u16 width, u16 height)
+{
+	reg_update_bits(d->regs, DMA2D_CR_REG, CR_MODE_MASK,
+			op_mode << CR_MODE_SHIFT);
+
+	reg_write(d->regs, DMA2D_NLR_REG, (width << 16) | height);
+}
+
+void dma2d_config_out(struct dma2d_dev *d, struct dma2d_frame *frm,
+		      dma_addr_t o_addr)
+{
+	reg_update_bits(d->regs, DMA2D_CR_REG, CR_CEIE, CR_CEIE);
+	reg_update_bits(d->regs, DMA2D_CR_REG, CR_CTCIE, CR_CTCIE);
+	reg_update_bits(d->regs, DMA2D_CR_REG, CR_CAEIE, CR_CAEIE);
+	reg_update_bits(d->regs, DMA2D_CR_REG, CR_TCIE, CR_TCIE);
+	reg_update_bits(d->regs, DMA2D_CR_REG, CR_TEIE, CR_TEIE);
+
+	if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+	    frm->fmt->cmode <= CM_MODE_ARGB4444)
+		reg_update_bits(d->regs, DMA2D_OPFCCR_REG, OPFCCR_CM_MASK,
+				frm->fmt->cmode);
+
+	reg_write(d->regs, DMA2D_OMAR_REG, o_addr);
+
+	reg_write(d->regs, DMA2D_OCOLR_REG,
+		  (frm->a_rgb[3] << 24) |
+		  (frm->a_rgb[2] << 16) |
+		  (frm->a_rgb[1] << 8) |
+		  frm->a_rgb[0]);
+
+	reg_update_bits(d->regs, DMA2D_OOR_REG, OOR_LO_MASK,
+			frm->line_offset & 0x3fff);
+}
+
+void dma2d_config_fg(struct dma2d_dev *d, struct dma2d_frame *frm,
+		     dma_addr_t f_addr)
+{
+	reg_write(d->regs, DMA2D_FGMAR_REG, f_addr);
+	reg_update_bits(d->regs, DMA2D_FGOR_REG, FGOR_LO_MASK,
+			frm->line_offset);
+
+	if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+	    frm->fmt->cmode <= CM_MODE_A4)
+		reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_CM_MASK,
+				frm->fmt->cmode);
+
+	reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_AM_MASK,
+			(frm->a_mode << 16) & 0x03);
+
+	reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_ALPHA_MASK,
+			frm->a_rgb[3] << 24);
+
+	reg_write(d->regs, DMA2D_FGCOLR_REG,
+		  (frm->a_rgb[2] << 16) |
+		  (frm->a_rgb[1] << 8) |
+		  frm->a_rgb[0]);
+}
+
+void dma2d_config_bg(struct dma2d_dev *d, struct dma2d_frame *frm,
+		     dma_addr_t b_addr)
+{
+	reg_write(d->regs, DMA2D_BGMAR_REG, b_addr);
+	reg_update_bits(d->regs, DMA2D_BGOR_REG, BGOR_LO_MASK,
+			frm->line_offset);
+
+	if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+	    frm->fmt->cmode <= CM_MODE_A4)
+		reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_CM_MASK,
+				frm->fmt->cmode);
+
+	reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_AM_MASK,
+			(frm->a_mode << 16) & 0x03);
+
+	reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_ALPHA_MASK,
+			frm->a_rgb[3] << 24);
+
+	reg_write(d->regs, DMA2D_BGCOLR_REG,
+		  (frm->a_rgb[2] << 16) |
+		  (frm->a_rgb[1] << 8) |
+		  frm->a_rgb[0]);
+}
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +94 -0
new file mode 100644
index 000000000000..2128364406c8
@@ -0,0 +1,113 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * ST stm32 Chrom-Art - 2D Graphics Accelerator Driver
+ *
+ * Copyright (c) 2021 Dillon Min
+ * Dillon Min, <[email protected]>
+ *
+ * based on s5p-g2d
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * Kamil Debski, <[email protected]>
+ */
+
+#ifndef __DMA2D_REGS_H__
+#define __DMA2D_REGS_H__
+
+#define DMA2D_CR_REG		0x0000
+#define CR_MODE_MASK		GENMASK(17, 16)
+#define CR_MODE_SHIFT		16
+#define CR_M2M			0x0000
+#define CR_M2M_PFC		BIT(16)
+#define CR_M2M_BLEND		BIT(17)
+#define CR_R2M			(BIT(17) | BIT(16))
+#define CR_CEIE			BIT(13)
+#define CR_CTCIE		BIT(12)
+#define CR_CAEIE		BIT(11)
+#define CR_TWIE			BIT(10)
+#define CR_TCIE			BIT(9)
+#define CR_TEIE			BIT(8)
+#define CR_ABORT		BIT(2)
+#define CR_SUSP			BIT(1)
+#define CR_START		BIT(0)
+
+#define DMA2D_ISR_REG		0x0004
+#define ISR_CEIF		BIT(5)
+#define ISR_CTCIF		BIT(4)
+#define ISR_CAEIF		BIT(3)
+#define ISR_TWIF		BIT(2)
+#define ISR_TCIF		BIT(1)
+#define ISR_TEIF		BIT(0)
+
+#define DMA2D_IFCR_REG		0x0008
+#define IFCR_CCEIF		BIT(5)
+#define IFCR_CCTCIF		BIT(4)
+#define IFCR_CAECIF		BIT(3)
+#define IFCR_CTWIF		BIT(2)
+#define IFCR_CTCIF		BIT(1)
+#define IFCR_CTEIF		BIT(0)
+
+#define DMA2D_FGMAR_REG		0x000c
+#define DMA2D_FGOR_REG		0x0010
+#define FGOR_LO_MASK		GENMASK(13, 0)
+
+#define DMA2D_BGMAR_REG		0x0014
+#define DMA2D_BGOR_REG		0x0018
+#define BGOR_LO_MASK		GENMASK(13, 0)
+
+#define DMA2D_FGPFCCR_REG	0x001c
+#define FGPFCCR_ALPHA_MASK	GENMASK(31, 24)
+#define FGPFCCR_AM_MASK		GENMASK(17, 16)
+#define FGPFCCR_CS_MASK		GENMASK(15, 8)
+#define FGPFCCR_START		BIT(5)
+#define FGPFCCR_CCM_RGB888	BIT(4)
+#define FGPFCCR_CM_MASK		GENMASK(3, 0)
+
+#define DMA2D_FGCOLR_REG	0x0020
+#define FGCOLR_REG_MASK		GENMASK(23, 16)
+#define FGCOLR_GREEN_MASK	GENMASK(15, 8)
+#define FGCOLR_BLUE_MASK	GENMASK(7, 0)
+
+#define DMA2D_BGPFCCR_REG	0x0024
+#define BGPFCCR_ALPHA_MASK	GENMASK(31, 24)
+#define BGPFCCR_AM_MASK		GENMASK(17, 16)
+#define BGPFCCR_CS_MASK		GENMASK(15, 8)
+#define BGPFCCR_START		BIT(5)
+#define BGPFCCR_CCM_RGB888	BIT(4)
+#define BGPFCCR_CM_MASK		GENMASK(3, 0)
+
+#define DMA2D_BGCOLR_REG	0x0028
+#define BGCOLR_REG_MASK		GENMASK(23, 16)
+#define BGCOLR_GREEN_MASK	GENMASK(15, 8)
+#define BGCOLR_BLUE_MASK	GENMASK(7, 0)
+
+#define DMA2D_OPFCCR_REG	0x0034
+#define OPFCCR_CM_MASK		GENMASK(2, 0)
+
+#define DMA2D_OCOLR_REG		0x0038
+#define OCOLR_ALPHA_MASK	GENMASK(31, 24)
+#define OCOLR_RED_MASK		GENMASK(23, 16)
+#define OCOLR_GREEN_MASK	GENMASK(15, 8)
+#define OCOLR_BLUE_MASK		GENMASK(7, 0)
+
+#define DMA2D_OMAR_REG		0x003c
+

drivers/media/platform/stm32/dma2d/dma2d-regs.h line 104

Quoted 10 lines
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +10 -0
+#define DMA2D_OOR_REG		0x0040
+#define OOR_LO_MASK		GENMASK(13, 0)
+
+#define DMA2D_NLR_REG		0x0044
+#define NLR_PL_MASK		GENMASK(29, 16)
+#define NLR_NL_MASK		GENMASK(15, 0)
+
+/* Hardware limits */
+#define MAX_WIDTH		0x3fff
+#define MAX_HEIGHT		0xffff

I think these max width/height values are unrealistic. Even though the hardware theoretically supports this, it is causing the memory alloc failures.

I see that the camera driver has 2592x2592 as the max width/height, so perhaps that should be used? Or alternatively the max resolution of the video output driver, whatever that is?

Regards,

Hans

Quoted 9 lines
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +9 -0
+
+#define DEFAULT_WIDTH		240
+#define DEFAULT_HEIGHT		320
+#define DEFAULT_SIZE		307200
+
+#define CM_MODE_ARGB8888	0x00
+#define CM_MODE_ARGB4444	0x04
+#define CM_MODE_A4		0x0a
+#endif /* __DMA2D_REGS_H__ */
author
#14 lore raw

Re: [PATCH v5 10/10] media: stm32-dma2d: STM32 DMA2D driver

Hi Hans

Quoted 331 lines · Hans Verkuil
Quoted 329 lines · On 18/10/2021 07:04, [email protected] wrote:

From: Dillon Min <[email protected]>

This V4L2 subdev m2m driver enables Chrom-Art Accelerator unit of STMicroelectronics STM32 SoC series.

Currently support r2m, m2m, m2m_pfc functions.
- r2m, Filling a part or the whole of a destination image with a specific color.
- m2m, Copying a part or the whole of a source image into a part or the whole of a destination.
- m2m_pfc, Copying a part or the whole of a source image into a part or the whole of a destination image with a pixel format conversion.

---
v5:
- remove useless log from dma2d driver.
- update config VIDEO_STM32_DMA2D description.

 drivers/media/platform/Kconfig                  |  11 +
 drivers/media/platform/Makefile                 |   1 +
 drivers/media/platform/stm32/Makefile           |   2 +
 drivers/media/platform/stm32/dma2d/dma2d-hw.c   | 143 +++++
 drivers/media/platform/stm32/dma2d/dma2d-regs.h | 113 ++++
 drivers/media/platform/stm32/dma2d/dma2d.c      | 739 ++++++++++++++++++++++++
 drivers/media/platform/stm32/dma2d/dma2d.h      | 135 +++++
 7 files changed, 1144 insertions(+)
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-hw.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-regs.h
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.h
drivers/media/platform/Kconfig +11 -0
index d9f90084c2f6..0b3bdf56b44e 100644
@@ -476,6 +476,17 @@ config VIDEO_STI_DELTA_DRIVER
 
 endif # VIDEO_STI_DELTA
 
+config VIDEO_STM32_DMA2D
+     tristate "STM32 Chrom-Art Accelerator (DMA2D)"
+     depends on (VIDEO_DEV && VIDEO_V4L2 && ARCH_STM32) || COMPILE_TEST
+     select VIDEOBUF2_DMA_CONTIG
+     select V4L2_MEM2MEM_DEV
+     help
+       Enables DMA2D hwarware support on stm32.
+
+       The STM32 DMA2D is a memory-to-memory engine for pixel conversion
+       and specialized DMA dedicated to image manipulation.
+
 config VIDEO_RENESAS_FDP1
      tristate "Renesas Fine Display Processor"
      depends on VIDEO_DEV && VIDEO_V4L2
drivers/media/platform/Makefile +1 -0
index 73ce083c2fc6..46f1c05bc576 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_VIDEO_ATMEL_ISI)               += atmel/
 obj-$(CONFIG_VIDEO_ATMEL_XISC)               += atmel/
 
 obj-$(CONFIG_VIDEO_STM32_DCMI)               += stm32/
+obj-$(CONFIG_VIDEO_STM32_DMA2D)              += stm32/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)     += mtk-vpu/
 
drivers/media/platform/stm32/Makefile +2 -0
index 48b36db2c2e2..896ef98a73ab 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_VIDEO_STM32_DCMI) += stm32-dcmi.o
+stm32-dma2d-objs := dma2d/dma2d.o dma2d/dma2d-hw.o
+obj-$(CONFIG_VIDEO_STM32_DMA2D) += stm32-dma2d.o
drivers/media/platform/stm32/dma2d/dma2d-hw.c new file +143 -0
new file mode 100644
index 000000000000..8c1c664ab13b
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * ST stm32 Chrom-Art - 2D Graphics Accelerator Driver
+ *
+ * Copyright (c) 2021 Dillon Min
+ * Dillon Min, <[email protected]>
+ *
+ * based on s5p-g2d
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * Kamil Debski, <[email protected]>
+ */
+
+#include <linux/io.h>
+
+#include "dma2d.h"
+#include "dma2d-regs.h"
+
+static inline u32 reg_read(void __iomem *base, u32 reg)
+{
+     return readl_relaxed(base + reg);
+}
+
+static inline void reg_write(void __iomem *base, u32 reg, u32 val)
+{
+     writel_relaxed(val, base + reg);
+}
+
+static inline void reg_set(void __iomem *base, u32 reg, u32 mask)
+{
+     reg_write(base, reg, reg_read(base, reg) | mask);
+}
+
+static inline void reg_clear(void __iomem *base, u32 reg, u32 mask)
+{
+     reg_write(base, reg, reg_read(base, reg) & ~mask);
+}
+
+static inline void reg_update_bits(void __iomem *base, u32 reg, u32 mask,
+                                u32 val)
+{
+     reg_write(base, reg, (reg_read(base, reg) & ~mask) | val);
+}
+
+void dma2d_start(struct dma2d_dev *d)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_START, CR_START);
+}
+
+u32 dma2d_get_int(struct dma2d_dev *d)
+{
+     return reg_read(d->regs, DMA2D_ISR_REG);
+}
+
+void dma2d_clear_int(struct dma2d_dev *d)
+{
+     u32 isr_val = reg_read(d->regs, DMA2D_ISR_REG);
+
+     reg_write(d->regs, DMA2D_IFCR_REG, isr_val & 0x003f);
+}
+
+void dma2d_config_common(struct dma2d_dev *d, enum dma2d_op_mode op_mode,
+                      u16 width, u16 height)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_MODE_MASK,
+                     op_mode << CR_MODE_SHIFT);
+
+     reg_write(d->regs, DMA2D_NLR_REG, (width << 16) | height);
+}
+
+void dma2d_config_out(struct dma2d_dev *d, struct dma2d_frame *frm,
+                   dma_addr_t o_addr)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CEIE, CR_CEIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CTCIE, CR_CTCIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CAEIE, CR_CAEIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_TCIE, CR_TCIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_TEIE, CR_TEIE);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_ARGB4444)
+             reg_update_bits(d->regs, DMA2D_OPFCCR_REG, OPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_write(d->regs, DMA2D_OMAR_REG, o_addr);
+
+     reg_write(d->regs, DMA2D_OCOLR_REG,
+               (frm->a_rgb[3] << 24) |
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+
+     reg_update_bits(d->regs, DMA2D_OOR_REG, OOR_LO_MASK,
+                     frm->line_offset & 0x3fff);
+}
+
+void dma2d_config_fg(struct dma2d_dev *d, struct dma2d_frame *frm,
+                  dma_addr_t f_addr)
+{
+     reg_write(d->regs, DMA2D_FGMAR_REG, f_addr);
+     reg_update_bits(d->regs, DMA2D_FGOR_REG, FGOR_LO_MASK,
+                     frm->line_offset);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_A4)
+             reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_AM_MASK,
+                     (frm->a_mode << 16) & 0x03);
+
+     reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_ALPHA_MASK,
+                     frm->a_rgb[3] << 24);
+
+     reg_write(d->regs, DMA2D_FGCOLR_REG,
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+}
+
+void dma2d_config_bg(struct dma2d_dev *d, struct dma2d_frame *frm,
+                  dma_addr_t b_addr)
+{
+     reg_write(d->regs, DMA2D_BGMAR_REG, b_addr);
+     reg_update_bits(d->regs, DMA2D_BGOR_REG, BGOR_LO_MASK,
+                     frm->line_offset);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_A4)
+             reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_AM_MASK,
+                     (frm->a_mode << 16) & 0x03);
+
+     reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_ALPHA_MASK,
+                     frm->a_rgb[3] << 24);
+
+     reg_write(d->regs, DMA2D_BGCOLR_REG,
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+}
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +99 -0
new file mode 100644
index 000000000000..2128364406c8
@@ -0,0 +1,113 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * ST stm32 Chrom-Art - 2D Graphics Accelerator Driver
+ *
+ * Copyright (c) 2021 Dillon Min
+ * Dillon Min, <[email protected]>
+ *
+ * based on s5p-g2d
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * Kamil Debski, <[email protected]>
+ */
+
+#ifndef __DMA2D_REGS_H__
+#define __DMA2D_REGS_H__
+
+#define DMA2D_CR_REG         0x0000
+#define CR_MODE_MASK         GENMASK(17, 16)
+#define CR_MODE_SHIFT                16
+#define CR_M2M                       0x0000
+#define CR_M2M_PFC           BIT(16)
+#define CR_M2M_BLEND         BIT(17)
+#define CR_R2M                       (BIT(17) | BIT(16))
+#define CR_CEIE                      BIT(13)
+#define CR_CTCIE             BIT(12)
+#define CR_CAEIE             BIT(11)
+#define CR_TWIE                      BIT(10)
+#define CR_TCIE                      BIT(9)
+#define CR_TEIE                      BIT(8)
+#define CR_ABORT             BIT(2)
+#define CR_SUSP                      BIT(1)
+#define CR_START             BIT(0)
+
+#define DMA2D_ISR_REG                0x0004
+#define ISR_CEIF             BIT(5)
+#define ISR_CTCIF            BIT(4)
+#define ISR_CAEIF            BIT(3)
+#define ISR_TWIF             BIT(2)
+#define ISR_TCIF             BIT(1)
+#define ISR_TEIF             BIT(0)
+
+#define DMA2D_IFCR_REG               0x0008
+#define IFCR_CCEIF           BIT(5)
+#define IFCR_CCTCIF          BIT(4)
+#define IFCR_CAECIF          BIT(3)
+#define IFCR_CTWIF           BIT(2)
+#define IFCR_CTCIF           BIT(1)
+#define IFCR_CTEIF           BIT(0)
+
+#define DMA2D_FGMAR_REG              0x000c
+#define DMA2D_FGOR_REG               0x0010
+#define FGOR_LO_MASK         GENMASK(13, 0)
+
+#define DMA2D_BGMAR_REG              0x0014
+#define DMA2D_BGOR_REG               0x0018
+#define BGOR_LO_MASK         GENMASK(13, 0)
+
+#define DMA2D_FGPFCCR_REG    0x001c
+#define FGPFCCR_ALPHA_MASK   GENMASK(31, 24)
+#define FGPFCCR_AM_MASK              GENMASK(17, 16)
+#define FGPFCCR_CS_MASK              GENMASK(15, 8)
+#define FGPFCCR_START                BIT(5)
+#define FGPFCCR_CCM_RGB888   BIT(4)
+#define FGPFCCR_CM_MASK              GENMASK(3, 0)
+
+#define DMA2D_FGCOLR_REG     0x0020
+#define FGCOLR_REG_MASK              GENMASK(23, 16)
+#define FGCOLR_GREEN_MASK    GENMASK(15, 8)
+#define FGCOLR_BLUE_MASK     GENMASK(7, 0)
+
+#define DMA2D_BGPFCCR_REG    0x0024
+#define BGPFCCR_ALPHA_MASK   GENMASK(31, 24)
+#define BGPFCCR_AM_MASK              GENMASK(17, 16)
+#define BGPFCCR_CS_MASK              GENMASK(15, 8)
+#define BGPFCCR_START                BIT(5)
+#define BGPFCCR_CCM_RGB888   BIT(4)
+#define BGPFCCR_CM_MASK              GENMASK(3, 0)
+
+#define DMA2D_BGCOLR_REG     0x0028
+#define BGCOLR_REG_MASK              GENMASK(23, 16)
+#define BGCOLR_GREEN_MASK    GENMASK(15, 8)
+#define BGCOLR_BLUE_MASK     GENMASK(7, 0)
+
+#define DMA2D_OPFCCR_REG     0x0034
+#define OPFCCR_CM_MASK               GENMASK(2, 0)
+
+#define DMA2D_OCOLR_REG              0x0038
+#define OCOLR_ALPHA_MASK     GENMASK(31, 24)
+#define OCOLR_RED_MASK               GENMASK(23, 16)
+#define OCOLR_GREEN_MASK     GENMASK(15, 8)
+#define OCOLR_BLUE_MASK              GENMASK(7, 0)
+
+#define DMA2D_OMAR_REG               0x003c
+
+#define DMA2D_OOR_REG                0x0040
+#define OOR_LO_MASK          GENMASK(13, 0)
+
+#define DMA2D_NLR_REG                0x0044
+#define NLR_PL_MASK          GENMASK(29, 16)
Quoted 8 lines

drivers/media/platform/stm32/dma2d/dma2d-regs.h line 104

Quoted 5 lines
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +5 -0
+#define NLR_NL_MASK          GENMASK(15, 0)
+
+/* Hardware limits */
+#define MAX_WIDTH            0x3fff
+#define MAX_HEIGHT           0xffff

I think these max width/height values are unrealistic. Even though the hardware theoretically supports this, it is causing the memory alloc failures.

Oh, I suppose the memory alloc failures test case was fixed designed by v4l2-compliance , actually it depends on the driver's ability.

Quoted 4 lines

I see that the camera driver has 2592x2592 as the max width/height, so perhaps that should be used? Or alternatively the max resolution of the video output driver, whatever that is?

I will try 2592x2592, and 2048x2048[display driver]. It fits the camera's output or display input is a good idea.

[display driver] drivers/gpu/drm/stm/drv.c

Thanks & Regards
Dillon

Quoted 14 lines

Regards,

Hans

Quoted 9 lines
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +9 -0
+
+#define DEFAULT_WIDTH                240
+#define DEFAULT_HEIGHT               320
+#define DEFAULT_SIZE         307200
+
+#define CM_MODE_ARGB8888     0x00
+#define CM_MODE_ARGB4444     0x04
+#define CM_MODE_A4           0x0a
+#endif /* __DMA2D_REGS_H__ */
author
#15 lore raw

Re: [PATCH v5 10/10] media: stm32-dma2d: STM32 DMA2D driver

Hi Hans

Quoted 348 lines · Dillon Min

Hi Hans

Quoted 331 lines · Hans Verkuil
Quoted 329 lines · On 18/10/2021 07:04, [email protected] wrote:

From: Dillon Min <[email protected]>

This V4L2 subdev m2m driver enables Chrom-Art Accelerator unit of STMicroelectronics STM32 SoC series.

Currently support r2m, m2m, m2m_pfc functions.
- r2m, Filling a part or the whole of a destination image with a specific color.
- m2m, Copying a part or the whole of a source image into a part or the whole of a destination.
- m2m_pfc, Copying a part or the whole of a source image into a part or the whole of a destination image with a pixel format conversion.

---
v5:
- remove useless log from dma2d driver.
- update config VIDEO_STM32_DMA2D description.

 drivers/media/platform/Kconfig                  |  11 +
 drivers/media/platform/Makefile                 |   1 +
 drivers/media/platform/stm32/Makefile           |   2 +
 drivers/media/platform/stm32/dma2d/dma2d-hw.c   | 143 +++++
 drivers/media/platform/stm32/dma2d/dma2d-regs.h | 113 ++++
 drivers/media/platform/stm32/dma2d/dma2d.c      | 739 ++++++++++++++++++++++++
 drivers/media/platform/stm32/dma2d/dma2d.h      | 135 +++++
 7 files changed, 1144 insertions(+)
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-hw.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-regs.h
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.h
drivers/media/platform/Kconfig +11 -0
index d9f90084c2f6..0b3bdf56b44e 100644
@@ -476,6 +476,17 @@ config VIDEO_STI_DELTA_DRIVER
 
 endif # VIDEO_STI_DELTA
 
+config VIDEO_STM32_DMA2D
+     tristate "STM32 Chrom-Art Accelerator (DMA2D)"
+     depends on (VIDEO_DEV && VIDEO_V4L2 && ARCH_STM32) || COMPILE_TEST
+     select VIDEOBUF2_DMA_CONTIG
+     select V4L2_MEM2MEM_DEV
+     help
+       Enables DMA2D hwarware support on stm32.
+
+       The STM32 DMA2D is a memory-to-memory engine for pixel conversion
+       and specialized DMA dedicated to image manipulation.
+
 config VIDEO_RENESAS_FDP1
      tristate "Renesas Fine Display Processor"
      depends on VIDEO_DEV && VIDEO_V4L2
drivers/media/platform/Makefile +1 -0
index 73ce083c2fc6..46f1c05bc576 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_VIDEO_ATMEL_ISI)               += atmel/
 obj-$(CONFIG_VIDEO_ATMEL_XISC)               += atmel/
 
 obj-$(CONFIG_VIDEO_STM32_DCMI)               += stm32/
+obj-$(CONFIG_VIDEO_STM32_DMA2D)              += stm32/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)     += mtk-vpu/
 
drivers/media/platform/stm32/Makefile +2 -0
index 48b36db2c2e2..896ef98a73ab 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_VIDEO_STM32_DCMI) += stm32-dcmi.o
+stm32-dma2d-objs := dma2d/dma2d.o dma2d/dma2d-hw.o
+obj-$(CONFIG_VIDEO_STM32_DMA2D) += stm32-dma2d.o
drivers/media/platform/stm32/dma2d/dma2d-hw.c new file +143 -0
new file mode 100644
index 000000000000..8c1c664ab13b
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * ST stm32 Chrom-Art - 2D Graphics Accelerator Driver
+ *
+ * Copyright (c) 2021 Dillon Min
+ * Dillon Min, <[email protected]>
+ *
+ * based on s5p-g2d
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * Kamil Debski, <[email protected]>
+ */
+
+#include <linux/io.h>
+
+#include "dma2d.h"
+#include "dma2d-regs.h"
+
+static inline u32 reg_read(void __iomem *base, u32 reg)
+{
+     return readl_relaxed(base + reg);
+}
+
+static inline void reg_write(void __iomem *base, u32 reg, u32 val)
+{
+     writel_relaxed(val, base + reg);
+}
+
+static inline void reg_set(void __iomem *base, u32 reg, u32 mask)
+{
+     reg_write(base, reg, reg_read(base, reg) | mask);
+}
+
+static inline void reg_clear(void __iomem *base, u32 reg, u32 mask)
+{
+     reg_write(base, reg, reg_read(base, reg) & ~mask);
+}
+
+static inline void reg_update_bits(void __iomem *base, u32 reg, u32 mask,
+                                u32 val)
+{
+     reg_write(base, reg, (reg_read(base, reg) & ~mask) | val);
+}
+
+void dma2d_start(struct dma2d_dev *d)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_START, CR_START);
+}
+
+u32 dma2d_get_int(struct dma2d_dev *d)
+{
+     return reg_read(d->regs, DMA2D_ISR_REG);
+}
+
+void dma2d_clear_int(struct dma2d_dev *d)
+{
+     u32 isr_val = reg_read(d->regs, DMA2D_ISR_REG);
+
+     reg_write(d->regs, DMA2D_IFCR_REG, isr_val & 0x003f);
+}
+
+void dma2d_config_common(struct dma2d_dev *d, enum dma2d_op_mode op_mode,
+                      u16 width, u16 height)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_MODE_MASK,
+                     op_mode << CR_MODE_SHIFT);
+
+     reg_write(d->regs, DMA2D_NLR_REG, (width << 16) | height);
+}
+
+void dma2d_config_out(struct dma2d_dev *d, struct dma2d_frame *frm,
+                   dma_addr_t o_addr)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CEIE, CR_CEIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CTCIE, CR_CTCIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CAEIE, CR_CAEIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_TCIE, CR_TCIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_TEIE, CR_TEIE);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_ARGB4444)
+             reg_update_bits(d->regs, DMA2D_OPFCCR_REG, OPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_write(d->regs, DMA2D_OMAR_REG, o_addr);
+
+     reg_write(d->regs, DMA2D_OCOLR_REG,
+               (frm->a_rgb[3] << 24) |
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+
+     reg_update_bits(d->regs, DMA2D_OOR_REG, OOR_LO_MASK,
+                     frm->line_offset & 0x3fff);
+}
+
+void dma2d_config_fg(struct dma2d_dev *d, struct dma2d_frame *frm,
+                  dma_addr_t f_addr)
+{
+     reg_write(d->regs, DMA2D_FGMAR_REG, f_addr);
+     reg_update_bits(d->regs, DMA2D_FGOR_REG, FGOR_LO_MASK,
+                     frm->line_offset);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_A4)
+             reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_AM_MASK,
+                     (frm->a_mode << 16) & 0x03);
+
+     reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_ALPHA_MASK,
+                     frm->a_rgb[3] << 24);
+
+     reg_write(d->regs, DMA2D_FGCOLR_REG,
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+}
+
+void dma2d_config_bg(struct dma2d_dev *d, struct dma2d_frame *frm,
+                  dma_addr_t b_addr)
+{
+     reg_write(d->regs, DMA2D_BGMAR_REG, b_addr);
+     reg_update_bits(d->regs, DMA2D_BGOR_REG, BGOR_LO_MASK,
+                     frm->line_offset);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_A4)
+             reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_AM_MASK,
+                     (frm->a_mode << 16) & 0x03);
+
+     reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_ALPHA_MASK,
+                     frm->a_rgb[3] << 24);
+
+     reg_write(d->regs, DMA2D_BGCOLR_REG,
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+}
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +99 -0
new file mode 100644
index 000000000000..2128364406c8
@@ -0,0 +1,113 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * ST stm32 Chrom-Art - 2D Graphics Accelerator Driver
+ *
+ * Copyright (c) 2021 Dillon Min
+ * Dillon Min, <[email protected]>
+ *
+ * based on s5p-g2d
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * Kamil Debski, <[email protected]>
+ */
+
+#ifndef __DMA2D_REGS_H__
+#define __DMA2D_REGS_H__
+
+#define DMA2D_CR_REG         0x0000
+#define CR_MODE_MASK         GENMASK(17, 16)
+#define CR_MODE_SHIFT                16
+#define CR_M2M                       0x0000
+#define CR_M2M_PFC           BIT(16)
+#define CR_M2M_BLEND         BIT(17)
+#define CR_R2M                       (BIT(17) | BIT(16))
+#define CR_CEIE                      BIT(13)
+#define CR_CTCIE             BIT(12)
+#define CR_CAEIE             BIT(11)
+#define CR_TWIE                      BIT(10)
+#define CR_TCIE                      BIT(9)
+#define CR_TEIE                      BIT(8)
+#define CR_ABORT             BIT(2)
+#define CR_SUSP                      BIT(1)
+#define CR_START             BIT(0)
+
+#define DMA2D_ISR_REG                0x0004
+#define ISR_CEIF             BIT(5)
+#define ISR_CTCIF            BIT(4)
+#define ISR_CAEIF            BIT(3)
+#define ISR_TWIF             BIT(2)
+#define ISR_TCIF             BIT(1)
+#define ISR_TEIF             BIT(0)
+
+#define DMA2D_IFCR_REG               0x0008
+#define IFCR_CCEIF           BIT(5)
+#define IFCR_CCTCIF          BIT(4)
+#define IFCR_CAECIF          BIT(3)
+#define IFCR_CTWIF           BIT(2)
+#define IFCR_CTCIF           BIT(1)
+#define IFCR_CTEIF           BIT(0)
+
+#define DMA2D_FGMAR_REG              0x000c
+#define DMA2D_FGOR_REG               0x0010
+#define FGOR_LO_MASK         GENMASK(13, 0)
+
+#define DMA2D_BGMAR_REG              0x0014
+#define DMA2D_BGOR_REG               0x0018
+#define BGOR_LO_MASK         GENMASK(13, 0)
+
+#define DMA2D_FGPFCCR_REG    0x001c
+#define FGPFCCR_ALPHA_MASK   GENMASK(31, 24)
+#define FGPFCCR_AM_MASK              GENMASK(17, 16)
+#define FGPFCCR_CS_MASK              GENMASK(15, 8)
+#define FGPFCCR_START                BIT(5)
+#define FGPFCCR_CCM_RGB888   BIT(4)
+#define FGPFCCR_CM_MASK              GENMASK(3, 0)
+
+#define DMA2D_FGCOLR_REG     0x0020
+#define FGCOLR_REG_MASK              GENMASK(23, 16)
+#define FGCOLR_GREEN_MASK    GENMASK(15, 8)
+#define FGCOLR_BLUE_MASK     GENMASK(7, 0)
+
+#define DMA2D_BGPFCCR_REG    0x0024
+#define BGPFCCR_ALPHA_MASK   GENMASK(31, 24)
+#define BGPFCCR_AM_MASK              GENMASK(17, 16)
+#define BGPFCCR_CS_MASK              GENMASK(15, 8)
+#define BGPFCCR_START                BIT(5)
+#define BGPFCCR_CCM_RGB888   BIT(4)
+#define BGPFCCR_CM_MASK              GENMASK(3, 0)
+
+#define DMA2D_BGCOLR_REG     0x0028
+#define BGCOLR_REG_MASK              GENMASK(23, 16)
+#define BGCOLR_GREEN_MASK    GENMASK(15, 8)
+#define BGCOLR_BLUE_MASK     GENMASK(7, 0)
+
+#define DMA2D_OPFCCR_REG     0x0034
+#define OPFCCR_CM_MASK               GENMASK(2, 0)
+
+#define DMA2D_OCOLR_REG              0x0038
+#define OCOLR_ALPHA_MASK     GENMASK(31, 24)
+#define OCOLR_RED_MASK               GENMASK(23, 16)
+#define OCOLR_GREEN_MASK     GENMASK(15, 8)
+#define OCOLR_BLUE_MASK              GENMASK(7, 0)
+
+#define DMA2D_OMAR_REG               0x003c
+
+#define DMA2D_OOR_REG                0x0040
+#define OOR_LO_MASK          GENMASK(13, 0)
+
+#define DMA2D_NLR_REG                0x0044
+#define NLR_PL_MASK          GENMASK(29, 16)
Quoted 8 lines

drivers/media/platform/stm32/dma2d/dma2d-regs.h line 104

Quoted 5 lines
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +5 -0
+#define NLR_NL_MASK          GENMASK(15, 0)
+
+/* Hardware limits */
+#define MAX_WIDTH            0x3fff
+#define MAX_HEIGHT           0xffff

I think these max width/height values are unrealistic. Even though the hardware theoretically supports this, it is causing the memory alloc failures.

Oh, I suppose the memory alloc failures test case was fixed, designed by v4l2-compliance , actually it depends on the driver's ability.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

I see that the camera driver has 2592x2592 as the max width/height, so perhaps that should be used? Or alternatively the max resolution of the video output driver, whatever that is?

I will try 2592x2592, and 2048x2048[display driver]. It fits the camera's output or display input is a good idea.

Tried 2592x2592 and 2048x2048, both failed on my setup due to the low memory size. I'd like to send v6 with max 2592x2592 if you prefer?

fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)

        BA24 (32-bit ARGB 8-8-8-8) 2048x2048 -> BA24 (32-bit ARGB

8-8-8-8) 2048x2048: FAIL

fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)

        BA24 (32-bit ARGB 8-8-8-8) 2592x2592 -> BA24 (32-bit ARGB

8-8-8-8) 2592x2592: FAIL

~ # free
total used free shared
buff/cache available
Mem: 15648 4060 8276 0 3312 7648

Thanks & Regards

Dillon

Quoted 20 lines

[display driver] drivers/gpu/drm/stm/drv.c

Thanks & Regards
Dillon

Quoted 14 lines

Regards,

Hans

Quoted 9 lines
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +9 -0
+
+#define DEFAULT_WIDTH                240
+#define DEFAULT_HEIGHT               320
+#define DEFAULT_SIZE         307200
+
+#define CM_MODE_ARGB8888     0x00
+#define CM_MODE_ARGB4444     0x04
+#define CM_MODE_A4           0x0a
+#endif /* __DMA2D_REGS_H__ */
#16 lore raw

Re: [PATCH v5 10/10] media: stm32-dma2d: STM32 DMA2D driver

Quoted 355 lines · Dillon Min

Hi Hans

Quoted 352 lines · Dillon Min

Hi Hans

Quoted 331 lines · Hans Verkuil
Quoted 329 lines · On 18/10/2021 07:04, [email protected] wrote:

From: Dillon Min <[email protected]>

This V4L2 subdev m2m driver enables Chrom-Art Accelerator unit of STMicroelectronics STM32 SoC series.

Currently support r2m, m2m, m2m_pfc functions.
- r2m, Filling a part or the whole of a destination image with a specific color.
- m2m, Copying a part or the whole of a source image into a part or the whole of a destination.
- m2m_pfc, Copying a part or the whole of a source image into a part or the whole of a destination image with a pixel format conversion.

---
v5:
- remove useless log from dma2d driver.
- update config VIDEO_STM32_DMA2D description.

 drivers/media/platform/Kconfig                  |  11 +
 drivers/media/platform/Makefile                 |   1 +
 drivers/media/platform/stm32/Makefile           |   2 +
 drivers/media/platform/stm32/dma2d/dma2d-hw.c   | 143 +++++
 drivers/media/platform/stm32/dma2d/dma2d-regs.h | 113 ++++
 drivers/media/platform/stm32/dma2d/dma2d.c      | 739 ++++++++++++++++++++++++
 drivers/media/platform/stm32/dma2d/dma2d.h      | 135 +++++
 7 files changed, 1144 insertions(+)
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-hw.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-regs.h
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.h
drivers/media/platform/Kconfig +11 -0
index d9f90084c2f6..0b3bdf56b44e 100644
@@ -476,6 +476,17 @@ config VIDEO_STI_DELTA_DRIVER
 
 endif # VIDEO_STI_DELTA
 
+config VIDEO_STM32_DMA2D
+     tristate "STM32 Chrom-Art Accelerator (DMA2D)"
+     depends on (VIDEO_DEV && VIDEO_V4L2 && ARCH_STM32) || COMPILE_TEST
+     select VIDEOBUF2_DMA_CONTIG
+     select V4L2_MEM2MEM_DEV
+     help
+       Enables DMA2D hwarware support on stm32.
+
+       The STM32 DMA2D is a memory-to-memory engine for pixel conversion
+       and specialized DMA dedicated to image manipulation.
+
 config VIDEO_RENESAS_FDP1
      tristate "Renesas Fine Display Processor"
      depends on VIDEO_DEV && VIDEO_V4L2
drivers/media/platform/Makefile +1 -0
index 73ce083c2fc6..46f1c05bc576 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_VIDEO_ATMEL_ISI)               += atmel/
 obj-$(CONFIG_VIDEO_ATMEL_XISC)               += atmel/
 
 obj-$(CONFIG_VIDEO_STM32_DCMI)               += stm32/
+obj-$(CONFIG_VIDEO_STM32_DMA2D)              += stm32/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)     += mtk-vpu/
 
drivers/media/platform/stm32/Makefile +2 -0
index 48b36db2c2e2..896ef98a73ab 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_VIDEO_STM32_DCMI) += stm32-dcmi.o
+stm32-dma2d-objs := dma2d/dma2d.o dma2d/dma2d-hw.o
+obj-$(CONFIG_VIDEO_STM32_DMA2D) += stm32-dma2d.o
drivers/media/platform/stm32/dma2d/dma2d-hw.c new file +143 -0
new file mode 100644
index 000000000000..8c1c664ab13b
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * ST stm32 Chrom-Art - 2D Graphics Accelerator Driver
+ *
+ * Copyright (c) 2021 Dillon Min
+ * Dillon Min, <[email protected]>
+ *
+ * based on s5p-g2d
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * Kamil Debski, <[email protected]>
+ */
+
+#include <linux/io.h>
+
+#include "dma2d.h"
+#include "dma2d-regs.h"
+
+static inline u32 reg_read(void __iomem *base, u32 reg)
+{
+     return readl_relaxed(base + reg);
+}
+
+static inline void reg_write(void __iomem *base, u32 reg, u32 val)
+{
+     writel_relaxed(val, base + reg);
+}
+
+static inline void reg_set(void __iomem *base, u32 reg, u32 mask)
+{
+     reg_write(base, reg, reg_read(base, reg) | mask);
+}
+
+static inline void reg_clear(void __iomem *base, u32 reg, u32 mask)
+{
+     reg_write(base, reg, reg_read(base, reg) & ~mask);
+}
+
+static inline void reg_update_bits(void __iomem *base, u32 reg, u32 mask,
+                                u32 val)
+{
+     reg_write(base, reg, (reg_read(base, reg) & ~mask) | val);
+}
+
+void dma2d_start(struct dma2d_dev *d)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_START, CR_START);
+}
+
+u32 dma2d_get_int(struct dma2d_dev *d)
+{
+     return reg_read(d->regs, DMA2D_ISR_REG);
+}
+
+void dma2d_clear_int(struct dma2d_dev *d)
+{
+     u32 isr_val = reg_read(d->regs, DMA2D_ISR_REG);
+
+     reg_write(d->regs, DMA2D_IFCR_REG, isr_val & 0x003f);
+}
+
+void dma2d_config_common(struct dma2d_dev *d, enum dma2d_op_mode op_mode,
+                      u16 width, u16 height)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_MODE_MASK,
+                     op_mode << CR_MODE_SHIFT);
+
+     reg_write(d->regs, DMA2D_NLR_REG, (width << 16) | height);
+}
+
+void dma2d_config_out(struct dma2d_dev *d, struct dma2d_frame *frm,
+                   dma_addr_t o_addr)
+{
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CEIE, CR_CEIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CTCIE, CR_CTCIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_CAEIE, CR_CAEIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_TCIE, CR_TCIE);
+     reg_update_bits(d->regs, DMA2D_CR_REG, CR_TEIE, CR_TEIE);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_ARGB4444)
+             reg_update_bits(d->regs, DMA2D_OPFCCR_REG, OPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_write(d->regs, DMA2D_OMAR_REG, o_addr);
+
+     reg_write(d->regs, DMA2D_OCOLR_REG,
+               (frm->a_rgb[3] << 24) |
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+
+     reg_update_bits(d->regs, DMA2D_OOR_REG, OOR_LO_MASK,
+                     frm->line_offset & 0x3fff);
+}
+
+void dma2d_config_fg(struct dma2d_dev *d, struct dma2d_frame *frm,
+                  dma_addr_t f_addr)
+{
+     reg_write(d->regs, DMA2D_FGMAR_REG, f_addr);
+     reg_update_bits(d->regs, DMA2D_FGOR_REG, FGOR_LO_MASK,
+                     frm->line_offset);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_A4)
+             reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_AM_MASK,
+                     (frm->a_mode << 16) & 0x03);
+
+     reg_update_bits(d->regs, DMA2D_FGPFCCR_REG, FGPFCCR_ALPHA_MASK,
+                     frm->a_rgb[3] << 24);
+
+     reg_write(d->regs, DMA2D_FGCOLR_REG,
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+}
+
+void dma2d_config_bg(struct dma2d_dev *d, struct dma2d_frame *frm,
+                  dma_addr_t b_addr)
+{
+     reg_write(d->regs, DMA2D_BGMAR_REG, b_addr);
+     reg_update_bits(d->regs, DMA2D_BGOR_REG, BGOR_LO_MASK,
+                     frm->line_offset);
+
+     if (frm->fmt->cmode >= CM_MODE_ARGB8888 &&
+         frm->fmt->cmode <= CM_MODE_A4)
+             reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_CM_MASK,
+                             frm->fmt->cmode);
+
+     reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_AM_MASK,
+                     (frm->a_mode << 16) & 0x03);
+
+     reg_update_bits(d->regs, DMA2D_BGPFCCR_REG, BGPFCCR_ALPHA_MASK,
+                     frm->a_rgb[3] << 24);
+
+     reg_write(d->regs, DMA2D_BGCOLR_REG,
+               (frm->a_rgb[2] << 16) |
+               (frm->a_rgb[1] << 8) |
+               frm->a_rgb[0]);
+}
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +99 -0
new file mode 100644
index 000000000000..2128364406c8
@@ -0,0 +1,113 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * ST stm32 Chrom-Art - 2D Graphics Accelerator Driver
+ *
+ * Copyright (c) 2021 Dillon Min
+ * Dillon Min, <[email protected]>
+ *
+ * based on s5p-g2d
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * Kamil Debski, <[email protected]>
+ */
+
+#ifndef __DMA2D_REGS_H__
+#define __DMA2D_REGS_H__
+
+#define DMA2D_CR_REG         0x0000
+#define CR_MODE_MASK         GENMASK(17, 16)
+#define CR_MODE_SHIFT                16
+#define CR_M2M                       0x0000
+#define CR_M2M_PFC           BIT(16)
+#define CR_M2M_BLEND         BIT(17)
+#define CR_R2M                       (BIT(17) | BIT(16))
+#define CR_CEIE                      BIT(13)
+#define CR_CTCIE             BIT(12)
+#define CR_CAEIE             BIT(11)
+#define CR_TWIE                      BIT(10)
+#define CR_TCIE                      BIT(9)
+#define CR_TEIE                      BIT(8)
+#define CR_ABORT             BIT(2)
+#define CR_SUSP                      BIT(1)
+#define CR_START             BIT(0)
+
+#define DMA2D_ISR_REG                0x0004
+#define ISR_CEIF             BIT(5)
+#define ISR_CTCIF            BIT(4)
+#define ISR_CAEIF            BIT(3)
+#define ISR_TWIF             BIT(2)
+#define ISR_TCIF             BIT(1)
+#define ISR_TEIF             BIT(0)
+
+#define DMA2D_IFCR_REG               0x0008
+#define IFCR_CCEIF           BIT(5)
+#define IFCR_CCTCIF          BIT(4)
+#define IFCR_CAECIF          BIT(3)
+#define IFCR_CTWIF           BIT(2)
+#define IFCR_CTCIF           BIT(1)
+#define IFCR_CTEIF           BIT(0)
+
+#define DMA2D_FGMAR_REG              0x000c
+#define DMA2D_FGOR_REG               0x0010
+#define FGOR_LO_MASK         GENMASK(13, 0)
+
+#define DMA2D_BGMAR_REG              0x0014
+#define DMA2D_BGOR_REG               0x0018
+#define BGOR_LO_MASK         GENMASK(13, 0)
+
+#define DMA2D_FGPFCCR_REG    0x001c
+#define FGPFCCR_ALPHA_MASK   GENMASK(31, 24)
+#define FGPFCCR_AM_MASK              GENMASK(17, 16)
+#define FGPFCCR_CS_MASK              GENMASK(15, 8)
+#define FGPFCCR_START                BIT(5)
+#define FGPFCCR_CCM_RGB888   BIT(4)
+#define FGPFCCR_CM_MASK              GENMASK(3, 0)
+
+#define DMA2D_FGCOLR_REG     0x0020
+#define FGCOLR_REG_MASK              GENMASK(23, 16)
+#define FGCOLR_GREEN_MASK    GENMASK(15, 8)
+#define FGCOLR_BLUE_MASK     GENMASK(7, 0)
+
+#define DMA2D_BGPFCCR_REG    0x0024
+#define BGPFCCR_ALPHA_MASK   GENMASK(31, 24)
+#define BGPFCCR_AM_MASK              GENMASK(17, 16)
+#define BGPFCCR_CS_MASK              GENMASK(15, 8)
+#define BGPFCCR_START                BIT(5)
+#define BGPFCCR_CCM_RGB888   BIT(4)
+#define BGPFCCR_CM_MASK              GENMASK(3, 0)
+
+#define DMA2D_BGCOLR_REG     0x0028
+#define BGCOLR_REG_MASK              GENMASK(23, 16)
+#define BGCOLR_GREEN_MASK    GENMASK(15, 8)
+#define BGCOLR_BLUE_MASK     GENMASK(7, 0)
+
+#define DMA2D_OPFCCR_REG     0x0034
+#define OPFCCR_CM_MASK               GENMASK(2, 0)
+
+#define DMA2D_OCOLR_REG              0x0038
+#define OCOLR_ALPHA_MASK     GENMASK(31, 24)
+#define OCOLR_RED_MASK               GENMASK(23, 16)
+#define OCOLR_GREEN_MASK     GENMASK(15, 8)
+#define OCOLR_BLUE_MASK              GENMASK(7, 0)
+
+#define DMA2D_OMAR_REG               0x003c
+
+#define DMA2D_OOR_REG                0x0040
+#define OOR_LO_MASK          GENMASK(13, 0)
+
+#define DMA2D_NLR_REG                0x0044
+#define NLR_PL_MASK          GENMASK(29, 16)
Quoted 8 lines

drivers/media/platform/stm32/dma2d/dma2d-regs.h line 104

Quoted 5 lines
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +5 -0
+#define NLR_NL_MASK          GENMASK(15, 0)
+
+/* Hardware limits */
+#define MAX_WIDTH            0x3fff
+#define MAX_HEIGHT           0xffff

I think these max width/height values are unrealistic. Even though the hardware theoretically supports this, it is causing the memory alloc failures.

Oh, I suppose the memory alloc failures test case was fixed, designed by v4l2-compliance , actually it depends on the driver's ability.

Quoted 4 lines

I see that the camera driver has 2592x2592 as the max width/height, so perhaps that should be used? Or alternatively the max resolution of the video output driver, whatever that is?

Quoted 5 lines
Quoted 2 lines

I will try 2592x2592, and 2048x2048[display driver]. It fits the camera's output or display input is a good idea.

Tried 2592x2592 and 2048x2048, both failed on my setup due to the low memory size. I'd like to send v6 with max 2592x2592 if you prefer?

Sounds good.

Hans

Quoted 38 lines

fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)

        BA24 (32-bit ARGB 8-8-8-8) 2048x2048 -> BA24 (32-bit ARGB

8-8-8-8) 2048x2048: FAIL

fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)

        BA24 (32-bit ARGB 8-8-8-8) 2592x2592 -> BA24 (32-bit ARGB

8-8-8-8) 2592x2592: FAIL

~ # free
total used free shared
buff/cache available
Mem: 15648 4060 8276 0 3312 7648

Thanks & Regards

Dillon

Quoted 20 lines

[display driver] drivers/gpu/drm/stm/drv.c

Thanks & Regards
Dillon

Quoted 14 lines

Regards,

Hans

Quoted 9 lines
drivers/media/platform/stm32/dma2d/dma2d-regs.h new file +9 -0
+
+#define DEFAULT_WIDTH                240
+#define DEFAULT_HEIGHT               320
+#define DEFAULT_SIZE         307200
+
+#define CM_MODE_ARGB8888     0x00
+#define CM_MODE_ARGB4444     0x04
+#define CM_MODE_A4           0x0a
+#endif /* __DMA2D_REGS_H__ */
#17 lore raw
In reply to [email protected]

Le lundi 18 octobre 2021 à 13:04 +0800, [email protected] a écrit :

Quoted 174 lines

From: Dillon Min <[email protected]>

This patchset introduces a basic support for DMA2D Interface of STMicroelectronics STM32 SoC series.

This first basic support implements R2M, M2M, M2M_PFC M2M_BLEND support will be added later on.

This has been tested on STM32469-DISCO board.

history
v5:
- rebase to media_tree https://git.linuxtv.org/media_tree.git/
- remove unused log from dma2d driver to avoid spam kernel log.
- fix 0xFFFFFF to 0xffffff, 2^24 to 2^24 -1, etc.
- introduce patch "media: v4l2-ctrls: Add V4L2_CID_COLORFX_CBCR max setting" to add V4L2_CID_COLORFX_CBCR entry.
- thanks to Hans's patch, open nullptr check in v4l2-compliance, update new test result. thanks.
https://lore.kernel.org/linux-media/[email protected]/

v4 link:
https://lore.kernel.org/lkml/[email protected]/

v4:
- replace V4L2_COLORFX_SET_ARGB, V4L2_CID_COLORFX_ARGB to V4L2_COLORFX_SET_RGB, V4L2_CID_COLORFX_RGB since Alpha paramter not used in current. thanks Hans.
v3 link:
https://lore.kernel.org/lkml/[email protected]/

v3:
- use V4L2_COLORFX_SET_ARGB, V4L2_CID_COLORFX_ARGB to pass argb paramter to the dma2d driver, instead of add stm32 private ioctl.
- some v2's patch are removed in this version.
- "[PATCH v2 7/9] media: docs: add doc for the stm32 dma2d driver"
- "[PATCH v2 8/9] media: v4l: uapi: Add user control base for stm32 dma2d controls"
- dma2d's driver changes based on Hans's review result. detail can be found at "media: stm32-dma2d: STM32 DMA2D driver"
- add stm32 clk drivers bugfix, ltdc clock disabled after kenerl boot up. v3 based on kernel and v4l-utils git:

kernel:
commit 9e1ff307c779ce1f0f810c7ecce3d95bbae40896

Author: Linus Torvalds <[email protected]>
Date:   Sun Oct 3 14:08:47 2021 -0700
    Linux 5.15-rc4

v4l-utils:
commit 700f5ded9c6de2c6dfe5d1b453d85566f95b4f0c

Author: Hans Verkuil <[email protected]>
Date:   Sat Oct 2 11:01:05 2021 +0200

test-media: show version info earlier and show cmd args

Log the version info earlier and also log the command line arguments.

v2 link:
https://lore.kernel.org/lkml/[email protected]/

v2:
- update v4l2-compliance to SHA: a4f2e3a6f306 2021-07-13 08:04:15 the test results at below [1].
- introduce Documentation/userspace-api/media/drivers/stm32-uapi.rst to explain the detail of dma2d's ioctl.
- reserved 16 ioctls from v4l2-controls.h for stm32, introduce stm32-media.h.
- collect Reviewed-by tag from Rob Herring.
- update dma2d driver from Hans's review. the details can be found at related patches.
v1 link:
https://lore.kernel.org/lkml/[email protected]/

v1:
The commit based on kernel(master): c3d0e3fd41b7f0f5d5d5b6022ab7e813f04ea727

Note for v4l2-compliance tool on nu-mmu platform:
I add two change based on v4l-utils since commit:
f0c7e3d71eaf4182bae7eb3ee0e43b4eeb047ea9

- change fork() to vfork() in v4l2-test-controls.cpp since no-mmu platform don't include fork().

with v4l2-compliance test log (with above modification):
since the stm32f469-disco ram limitation, there are 25 failed on dma_alloc_coherent()

Really appreciate if someone can help to test this patch on the STM32429I-EVAL evaluation board (https://www.st.com/en/evaluation-tools/stm32429i-eval.html)
8M x 32-bit SDRAM, 1M x 16-bit SRAM and 8M x 16-bit NOR Flash

~ # v4l2-compliance -f -d /dev/video0 > /dev/ttyprintk

[ 1798.550690] [U] v4l2-compliance 1.21.0-4855, 32 bits, 32-bit time_t
[ 1799.527504] [U] v4l2-compliance SHA: 700f5ded9c6d 2021-10-02 09:01:05
[ 1800.534558] [U] Compliance test for stm-dma2d device /dev/video0:
[ 1801.514999] [U] Driver Info:
[ 1801.998840] [U]      Driver name      : stm-dma2d
[ 1802.482151] [U]      Card type        : stm-dma2d
[ 1802.959808] [U]      Bus info         : platform:stm-dma2d
[ 1803.435715] [U]      Driver version   : 5.15.0
[ 1803.904938] [U]      Capabilities     : 0x84208000
[ 1804.371290] [U]              Video Memory-to-Memory
[ 1804.830870] [U]              Streaming
[ 1805.281465] [U]              Extended Pix Format
[ 1805.733249] [U]              Device Capabilities
[ 1806.181369] [U]      Device Caps      : 0x04208000
[ 1806.622899] [U]              Video Memory-to-Memory
[ 1807.057208] [U]              Streaming
[ 1807.483866] [U]              Extended Pix Format
[ 1807.907678] [U] Required ioctls:
[ 1808.325287] [U]      test VIDIOC_QUERYCAP: OK
[ 1808.785260] [U]      test invalid ioctls: OK
[ 1809.199015] [U] Allow for multiple opens:
[ 1809.613894] [U]      test second /dev/video0 open: OK
[ 1810.416746] [U]      test VIDIOC_QUERYCAP: OK
[ 1810.827974] [U]      test VIDIOC_G/S_PRIORITY: OK
[ 1811.466506] [U]      test for unlimited opens: OK
[ 1811.868388] [U] Debug ioctls:
[ 1812.257689] [U]      test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
[ 1813.034108] [U]      test VIDIOC_LOG_STATUS: OK (Not Supported)
[ 1813.807583] [U] Input ioctls:
[ 1814.192271] [U]      test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
[ 1814.958053] [U]      test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
[ 1815.721424] [U]      test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
[ 1816.486425] [U]      test VIDIOC_ENUMAUDIO: OK (Not Supported)
[ 1817.253873] [U]      test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
[ 1818.021773] [U]      test VIDIOC_G/S_AUDIO: OK (Not Supported)
[ 1818.783542] [U]      Inputs: 0 Audio Inputs: 0 Tuners: 0
[ 1819.170414] [U] Output ioctls:
[ 1819.549601] [U]      test VIDIOC_G/S_MODULATOR: OK (Not Supported)
[ 1820.306132] [U]      test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
[ 1821.085495] [U]      test VIDIOC_ENUMAUDOUT: OK (Not Supported)
[ 1821.883894] [U]      test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
[ 1822.698269] [U]      test VIDIOC_G/S_AUDOUT: OK (Not Supported)
[ 1823.541345] [U]      Outputs: 0 Audio Outputs: 0 Modulators: 0
[ 1824.391635] [U] Input/Output configuration ioctls:
[ 1824.830293] [U]      test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
[ 1825.708848] [U]      test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
[ 1826.608994] [U]      test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
[ 1827.520616] [U]      test VIDIOC_G/S_EDID: OK (Not Supported)
[ 1828.438211] [U] Control ioctls:
[ 1828.926449] [U]      test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
[ 1829.856497] [U]      test VIDIOC_QUERYCTRL: OK
[ 1830.335647] [U]      test VIDIOC_G/S_CTRL: OK
[ 1830.816513] [U]      test VIDIOC_G/S/TRY_EXT_CTRLS: OK
[ 1831.740067] [U]      test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
[ 1832.666736] [U]      test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
[ 1833.597005] [U]      Standard Controls: 3 Private Controls: 0
[ 1834.070452] [U] Format ioctls:
[ 1834.540460] [U]      test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
[ 1835.473065] [U]      test VIDIOC_G/S_PARM: OK (Not Supported)
[ 1836.395238] [U]      test VIDIOC_G_FBUF: OK (Not Supported)
[ 1837.322128] [U]      test VIDIOC_G_FMT: OK
[ 1837.798880] [U]      test VIDIOC_TRY_FMT: OK
[ 1838.267574] [U]      test VIDIOC_S_FMT: OK
[ 1838.724264] [U]      test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
[ 1839.627408] [U]      test Cropping: OK (Not Supported)
[ 1840.526875] [U]      test Composing: OK (Not Supported)
[ 1841.428562] [U]      test Scaling: OK
[ 1841.882087] [U] Codec ioctls:
[ 1842.331672] [U]      test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
[ 1843.221419] [U]      test VIDIOC_G_ENC_INDEX: OK (Not Supported)
[ 1844.105854] [U]      test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
[ 1844.993986] [U] Buffer ioctls:
[ 1845.558827] [U]      test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
[ 1846.486226] [U]      test VIDIOC_EXPBUF: OK
[ 1846.936148] [U]      test Requests: OK (Not Supported)
[ 1847.805687] [U]      test TIME32/64: OK
[ 1848.255712] [U] Test input 0:
[ 1848.685591] [U] Stream using all formats:
Quoted 8 lines
[ 1853.598085] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1858.085109] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1861.799188] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1864.859534] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1867.974755] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1868.466365] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1868.971398] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1869.487572] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL

Have you considered adapting your maximum width/height to something reasonable ? Consider V4L2 drivers will usually be used for streaming, so using 2 OUTPUT and 2 CAPTURE buffer isn't special, so perhaps find something that will be possible to allocate ? I bet you can't even have more then 4G of ram on that device, so even if theoretically you could program the HW for 16383x65535, it is physically impossible to allocate a second buffer of that size (or any size).

Quoted 118 lines
[ 1870.017197] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1870.562272] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1871.147644] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1871.780530] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1872.431797] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1873.112100] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1873.805156] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1874.492353] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1875.221576] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1876.000283] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1876.808963] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1877.634785] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1883.283141] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1888.533587] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1892.729322] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1896.013783] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1899.195802] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1902.318853] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1905.399663] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1908.515463] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1911.589775] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1914.682147] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1915.169478] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1915.671278] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1916.184281] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 1916.709840] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1917.252352] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1917.834611] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1918.463784] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1919.114290] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1919.789982] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1920.479624] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1921.165202] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1921.893374] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1922.668057] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1923.469342] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1924.297500] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1929.890593] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1935.098497] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1939.250033] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1942.503854] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1945.659254] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1948.763903] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1951.832407] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1954.927592] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1957.991536] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1961.086603] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1961.575893] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1962.079572] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1962.594354] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 1963.121249] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1963.665788] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1964.249129] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1964.880104] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1965.530670] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1966.210598] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1966.902316] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1967.590215] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1968.319871] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1969.097012] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1969.900036] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1970.729920] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1976.318963] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1981.494224] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1985.599406] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1988.829141] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1991.998991] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1995.084529] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1998.191853] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 2001.307217] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 2004.413725] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 2007.527437] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 2008.016277] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2008.523318] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2009.038828] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 2009.567269] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2010.112209] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2010.697226] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 2011.329552] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2011.979307] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2012.658449] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 2013.350104] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2014.035612] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2014.762649] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 2015.538183] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2016.338784] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2017.166692] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 2022.744387] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 2027.927575] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 2032.066337] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 2035.295351] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 2038.476408] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 2041.591223] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 2044.678274] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 2047.774851] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 2050.849788] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 2053.955560] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 2054.446212] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2054.951517] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2055.467584] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 2055.997127] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2056.543193] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2057.128457] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 2057.761407] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2058.413191] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2059.093749] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 2059.786201] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2060.472393] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2061.200709] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 2061.977728] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2062.780816] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2063.610351] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 2069.207680] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 2074.392036] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 2078.538621] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 2081.749134] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 2084.922145] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 2085.416538] [U] Total for stm-dma2d device /dev/video0: 121, Succeeded: 96, Failed: 25, Warnings: 0
Quoted 1 line

*** BLURB HERE ***

^ I guess that was meant for you to justify the failures.

Quoted 31 lines

Dillon Min (10):
media: admin-guide: add stm32-dma2d description
media: dt-bindings: media: add document for STM32 DMA2d bindings
ARM: dts: stm32: Add DMA2D support for STM32F429 series soc
ARM: dts: stm32: Enable DMA2D on STM32F469-DISCO board
media: v4l2-mem2mem: add v4l2_m2m_get_unmapped_area for no-mmu
platform
media: videobuf2: Fix the size printk format
media: v4l2-ctrls: Add V4L2_CID_COLORFX_CBCR max setting
media: v4l2-ctrls: Add RGB color effects control
clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after
system enter shell
media: stm32-dma2d: STM32 DMA2D driver

 .../admin-guide/media/platform-cardlist.rst        |   1 +
 .../devicetree/bindings/media/st,stm32-dma2d.yaml  |  71 ++
 Documentation/userspace-api/media/v4l/control.rst  |   9 +
 arch/arm/boot/dts/stm32f429.dtsi                   |  10 +
 arch/arm/boot/dts/stm32f469-disco.dts              |   4 +
 drivers/clk/clk-stm32f4.c                          |   4 -
 .../media/common/videobuf2/videobuf2-dma-contig.c  |   4 +-
 drivers/media/platform/Kconfig                     |  11 +
 drivers/media/platform/Makefile                    |   1 +
 drivers/media/platform/stm32/Makefile              |   2 +
 drivers/media/platform/stm32/dma2d/dma2d-hw.c      | 143 ++++
 drivers/media/platform/stm32/dma2d/dma2d-regs.h    | 113 ++++
 drivers/media/platform/stm32/dma2d/dma2d.c         | 739 +++++++++++++++++++++
 drivers/media/platform/stm32/dma2d/dma2d.h         | 135 ++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c          |  12 +-
 drivers/media/v4l2-core/v4l2-mem2mem.c             |  21 +
Quoted 9 lines
 include/media/v4l2-mem2mem.h                       |   5 +
 include/uapi/linux/v4l2-controls.h                 |   4 +-
 18 files changed, 1280 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/st,stm32-dma2d.yaml
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-hw.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-regs.h
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.h

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#18 lore raw

Hi Nicolas

Quoted 185 lines · Nicolas Dufresne
Quoted 174 lines · Le lundi 18 octobre 2021 à 13:04 +0800, [email protected] a écrit :

From: Dillon Min <[email protected]>

This patchset introduces a basic support for DMA2D Interface of STMicroelectronics STM32 SoC series.

This first basic support implements R2M, M2M, M2M_PFC M2M_BLEND support will be added later on.

This has been tested on STM32469-DISCO board.

history
v5:
- rebase to media_tree https://git.linuxtv.org/media_tree.git/
- remove unused log from dma2d driver to avoid spam kernel log.
- fix 0xFFFFFF to 0xffffff, 2^24 to 2^24 -1, etc.
- introduce patch "media: v4l2-ctrls: Add V4L2_CID_COLORFX_CBCR max setting" to add V4L2_CID_COLORFX_CBCR entry.
- thanks to Hans's patch, open nullptr check in v4l2-compliance, update new test result. thanks.
https://lore.kernel.org/linux-media/[email protected]/

v4 link:
https://lore.kernel.org/lkml/[email protected]/

v4:
- replace V4L2_COLORFX_SET_ARGB, V4L2_CID_COLORFX_ARGB to V4L2_COLORFX_SET_RGB, V4L2_CID_COLORFX_RGB since Alpha paramter not used in current. thanks Hans.
v3 link:
https://lore.kernel.org/lkml/[email protected]/

v3:
- use V4L2_COLORFX_SET_ARGB, V4L2_CID_COLORFX_ARGB to pass argb paramter to the dma2d driver, instead of add stm32 private ioctl.
- some v2's patch are removed in this version.
- "[PATCH v2 7/9] media: docs: add doc for the stm32 dma2d driver"
- "[PATCH v2 8/9] media: v4l: uapi: Add user control base for stm32 dma2d controls"
- dma2d's driver changes based on Hans's review result. detail can be found at "media: stm32-dma2d: STM32 DMA2D driver"
- add stm32 clk drivers bugfix, ltdc clock disabled after kenerl boot up. v3 based on kernel and v4l-utils git:

kernel:
commit 9e1ff307c779ce1f0f810c7ecce3d95bbae40896

Author: Linus Torvalds <[email protected]>
Date:   Sun Oct 3 14:08:47 2021 -0700
    Linux 5.15-rc4

v4l-utils:
commit 700f5ded9c6de2c6dfe5d1b453d85566f95b4f0c

Author: Hans Verkuil <[email protected]>
Date:   Sat Oct 2 11:01:05 2021 +0200

test-media: show version info earlier and show cmd args

Log the version info earlier and also log the command line arguments.

v2 link:
https://lore.kernel.org/lkml/[email protected]/

v2:
- update v4l2-compliance to SHA: a4f2e3a6f306 2021-07-13 08:04:15 the test results at below [1].
- introduce Documentation/userspace-api/media/drivers/stm32-uapi.rst to explain the detail of dma2d's ioctl.
- reserved 16 ioctls from v4l2-controls.h for stm32, introduce stm32-media.h.
- collect Reviewed-by tag from Rob Herring.
- update dma2d driver from Hans's review. the details can be found at related patches.
v1 link:
https://lore.kernel.org/lkml/[email protected]/

v1:
The commit based on kernel(master): c3d0e3fd41b7f0f5d5d5b6022ab7e813f04ea727

Note for v4l2-compliance tool on nu-mmu platform:
I add two change based on v4l-utils since commit:
f0c7e3d71eaf4182bae7eb3ee0e43b4eeb047ea9

- change fork() to vfork() in v4l2-test-controls.cpp since no-mmu platform don't include fork().

with v4l2-compliance test log (with above modification):
since the stm32f469-disco ram limitation, there are 25 failed on dma_alloc_coherent()

Really appreciate if someone can help to test this patch on the STM32429I-EVAL evaluation board (https://www.st.com/en/evaluation-tools/stm32429i-eval.html)
8M x 32-bit SDRAM, 1M x 16-bit SRAM and 8M x 16-bit NOR Flash

~ # v4l2-compliance -f -d /dev/video0 > /dev/ttyprintk

[ 1798.550690] [U] v4l2-compliance 1.21.0-4855, 32 bits, 32-bit time_t
[ 1799.527504] [U] v4l2-compliance SHA: 700f5ded9c6d 2021-10-02 09:01:05
[ 1800.534558] [U] Compliance test for stm-dma2d device /dev/video0:
[ 1801.514999] [U] Driver Info:
[ 1801.998840] [U]      Driver name      : stm-dma2d
[ 1802.482151] [U]      Card type        : stm-dma2d
[ 1802.959808] [U]      Bus info         : platform:stm-dma2d
[ 1803.435715] [U]      Driver version   : 5.15.0
[ 1803.904938] [U]      Capabilities     : 0x84208000
[ 1804.371290] [U]              Video Memory-to-Memory
[ 1804.830870] [U]              Streaming
[ 1805.281465] [U]              Extended Pix Format
[ 1805.733249] [U]              Device Capabilities
[ 1806.181369] [U]      Device Caps      : 0x04208000
[ 1806.622899] [U]              Video Memory-to-Memory
[ 1807.057208] [U]              Streaming
[ 1807.483866] [U]              Extended Pix Format
[ 1807.907678] [U] Required ioctls:
[ 1808.325287] [U]      test VIDIOC_QUERYCAP: OK
[ 1808.785260] [U]      test invalid ioctls: OK
[ 1809.199015] [U] Allow for multiple opens:
[ 1809.613894] [U]      test second /dev/video0 open: OK
[ 1810.416746] [U]      test VIDIOC_QUERYCAP: OK
[ 1810.827974] [U]      test VIDIOC_G/S_PRIORITY: OK
[ 1811.466506] [U]      test for unlimited opens: OK
[ 1811.868388] [U] Debug ioctls:
[ 1812.257689] [U]      test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
[ 1813.034108] [U]      test VIDIOC_LOG_STATUS: OK (Not Supported)
[ 1813.807583] [U] Input ioctls:
[ 1814.192271] [U]      test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
[ 1814.958053] [U]      test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
[ 1815.721424] [U]      test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
[ 1816.486425] [U]      test VIDIOC_ENUMAUDIO: OK (Not Supported)
[ 1817.253873] [U]      test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
[ 1818.021773] [U]      test VIDIOC_G/S_AUDIO: OK (Not Supported)
[ 1818.783542] [U]      Inputs: 0 Audio Inputs: 0 Tuners: 0
[ 1819.170414] [U] Output ioctls:
[ 1819.549601] [U]      test VIDIOC_G/S_MODULATOR: OK (Not Supported)
[ 1820.306132] [U]      test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
[ 1821.085495] [U]      test VIDIOC_ENUMAUDOUT: OK (Not Supported)
[ 1821.883894] [U]      test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
[ 1822.698269] [U]      test VIDIOC_G/S_AUDOUT: OK (Not Supported)
[ 1823.541345] [U]      Outputs: 0 Audio Outputs: 0 Modulators: 0
[ 1824.391635] [U] Input/Output configuration ioctls:
[ 1824.830293] [U]      test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
[ 1825.708848] [U]      test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
[ 1826.608994] [U]      test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
[ 1827.520616] [U]      test VIDIOC_G/S_EDID: OK (Not Supported)
[ 1828.438211] [U] Control ioctls:
[ 1828.926449] [U]      test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
[ 1829.856497] [U]      test VIDIOC_QUERYCTRL: OK
[ 1830.335647] [U]      test VIDIOC_G/S_CTRL: OK
[ 1830.816513] [U]      test VIDIOC_G/S/TRY_EXT_CTRLS: OK
[ 1831.740067] [U]      test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
[ 1832.666736] [U]      test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
[ 1833.597005] [U]      Standard Controls: 3 Private Controls: 0
[ 1834.070452] [U] Format ioctls:
[ 1834.540460] [U]      test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
[ 1835.473065] [U]      test VIDIOC_G/S_PARM: OK (Not Supported)
[ 1836.395238] [U]      test VIDIOC_G_FBUF: OK (Not Supported)
[ 1837.322128] [U]      test VIDIOC_G_FMT: OK
[ 1837.798880] [U]      test VIDIOC_TRY_FMT: OK
[ 1838.267574] [U]      test VIDIOC_S_FMT: OK
[ 1838.724264] [U]      test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
[ 1839.627408] [U]      test Cropping: OK (Not Supported)
[ 1840.526875] [U]      test Composing: OK (Not Supported)
[ 1841.428562] [U]      test Scaling: OK
[ 1841.882087] [U] Codec ioctls:
[ 1842.331672] [U]      test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
[ 1843.221419] [U]      test VIDIOC_G_ENC_INDEX: OK (Not Supported)
[ 1844.105854] [U]      test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
[ 1844.993986] [U] Buffer ioctls:
[ 1845.558827] [U]      test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
[ 1846.486226] [U]      test VIDIOC_EXPBUF: OK
[ 1846.936148] [U]      test Requests: OK (Not Supported)
[ 1847.805687] [U]      test TIME32/64: OK
[ 1848.255712] [U] Test input 0:
[ 1848.685591] [U] Stream using all formats:
Quoted 8 lines
[ 1853.598085] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1858.085109] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1861.799188] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1864.859534] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1867.974755] [U]      BA24 (32-bit ARGB 8-8-8-8) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1868.466365] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1868.971398] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1869.487572] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
Quoted 6 lines

Have you considered adapting your maximum width/height to something reasonable ? Consider V4L2 drivers will usually be used for streaming, so using 2 OUTPUT and 2 CAPTURE buffer isn't special, so perhaps find something that will be possible to allocate ? I bet you can't even have more then 4G of ram on that device, so even if theoretically you could program the HW for 16383x65535, it is physically impossible to allocate a second buffer of that size (or any size).

Thanks for your reminder. yes it's not a reasonable max resolution. I just use the max value which dma2d controller can accept, but forget the physical memory size. My board only mount 32MiB sdram, Anyway, this issue was fixed in [v6] suggested by Hans.

[v6] https://lore.kernel.org/lkml/[email protected]/

Thanks & Best Regards
Dillon

Quoted 165 lines
Quoted 119 lines
[ 1870.017197] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1870.562272] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1871.147644] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1871.780530] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1872.431797] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1873.112100] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1873.805156] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1874.492353] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1875.221576] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1876.000283] stm-dma2d 4002b000.dma2d: dma alloc of size 4294643712 failed
[ 1876.808963] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1877.634785] [U]      BA24 (32-bit ARGB 8-8-8-8) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1883.283141] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1888.533587] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1892.729322] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1896.013783] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1899.195802] [U]      BA24 (32-bit ARGB 8-8-8-8) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1902.318853] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1905.399663] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1908.515463] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1911.589775] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1914.682147] [U]      RGB3 (24-bit RGB 8-8-8) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1915.169478] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1915.671278] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1916.184281] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 1916.709840] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1917.252352] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1917.834611] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1918.463784] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1919.114290] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1919.789982] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1920.479624] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1921.165202] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1921.893374] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1922.668057] stm-dma2d 4002b000.dma2d: dma alloc of size 3220983808 failed
[ 1923.469342] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1924.297500] [U]      RGB3 (24-bit RGB 8-8-8) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1929.890593] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1935.098497] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1939.250033] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1942.503854] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1945.659254] [U]      RGB3 (24-bit RGB 8-8-8) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1948.763903] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1951.832407] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 1954.927592] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 1957.991536] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 1961.086603] [U]      RGBP (16-bit RGB 5-6-5) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 1961.575893] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1962.079572] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1962.594354] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 1963.121249] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1963.665788] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1964.249129] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 1964.880104] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1965.530670] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1966.210598] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 1966.902316] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1967.590215] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1968.319871] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 1969.097012] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 1969.900036] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 1970.729920] [U]      RGBP (16-bit RGB 5-6-5) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 1976.318963] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 1981.494224] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 1985.599406] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 1988.829141] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 1991.998991] [U]      RGBP (16-bit RGB 5-6-5) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 1995.084529] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 1998.191853] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 2001.307217] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 2004.413725] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 2007.527437] [U]      AR15 (16-bit ARGB 1-5-5-5) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 2008.016277] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2008.523318] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2009.038828] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 2009.567269] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2010.112209] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2010.697226] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 2011.329552] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2011.979307] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2012.658449] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 2013.350104] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2014.035612] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2014.762649] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 2015.538183] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2016.338784] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2017.166692] [U]      AR15 (16-bit ARGB 1-5-5-5) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 2022.744387] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 2027.927575] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 2032.066337] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 2035.295351] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 2038.476408] [U]      AR15 (16-bit ARGB 1-5-5-5) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 2041.591223] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> BA24 (32-bit ARGB 8-8-8-8) 1x1: OK
[ 2044.678274] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> RGB3 (24-bit RGB 8-8-8) 1x1: OK
[ 2047.774851] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> RGBP (16-bit RGB 5-6-5) 1x1: OK
[ 2050.849788] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> AR15 (16-bit ARGB 1-5-5-5) 1x1: OK
[ 2053.955560] [U]      AR12 (16-bit ARGB 4-4-4-4) 1x1 -> AR12 (16-bit ARGB 4-4-4-4) 1x1: OK
[ 2054.446212] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2054.951517] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2055.467584] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> BA24 (32-bit ARGB 8-8-8-8) 16383x65535: FAIL
[ 2055.997127] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2056.543193] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2057.128457] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> RGB3 (24-bit RGB 8-8-8) 16383x65535: FAIL
[ 2057.761407] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2058.413191] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2059.093749] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> RGBP (16-bit RGB 5-6-5) 16383x65535: FAIL
[ 2059.786201] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2060.472393] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2061.200709] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> AR15 (16-bit ARGB 1-5-5-5) 16383x65535: FAIL
[ 2061.977728] stm-dma2d 4002b000.dma2d: dma alloc of size 2147323904 failed
[ 2062.780816] [U]              fail: v4l2-test-buffers.cpp(1349): q.reqbufs(node, 2)
[ 2063.610351] [U]      AR12 (16-bit ARGB 4-4-4-4) 16383x65535 -> AR12 (16-bit ARGB 4-4-4-4) 16383x65535: FAIL
[ 2069.207680] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> BA24 (32-bit ARGB 8-8-8-8) 240x320: OK
[ 2074.392036] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> RGB3 (24-bit RGB 8-8-8) 240x320: OK
[ 2078.538621] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> RGBP (16-bit RGB 5-6-5) 240x320: OK
[ 2081.749134] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> AR15 (16-bit ARGB 1-5-5-5) 240x320: OK
[ 2084.922145] [U]      AR12 (16-bit ARGB 4-4-4-4) 240x320 -> AR12 (16-bit ARGB 4-4-4-4) 240x320: OK
[ 2085.416538] [U] Total for stm-dma2d device /dev/video0: 121, Succeeded: 96, Failed: 25, Warnings: 0
Quoted 1 line

*** BLURB HERE ***

^ I guess that was meant for you to justify the failures.

Quoted 40 lines

Dillon Min (10):
media: admin-guide: add stm32-dma2d description
media: dt-bindings: media: add document for STM32 DMA2d bindings
ARM: dts: stm32: Add DMA2D support for STM32F429 series soc
ARM: dts: stm32: Enable DMA2D on STM32F469-DISCO board
media: v4l2-mem2mem: add v4l2_m2m_get_unmapped_area for no-mmu
platform
media: videobuf2: Fix the size printk format
media: v4l2-ctrls: Add V4L2_CID_COLORFX_CBCR max setting
media: v4l2-ctrls: Add RGB color effects control
clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after
system enter shell
media: stm32-dma2d: STM32 DMA2D driver

 .../admin-guide/media/platform-cardlist.rst        |   1 +
 .../devicetree/bindings/media/st,stm32-dma2d.yaml  |  71 ++
 Documentation/userspace-api/media/v4l/control.rst  |   9 +
 arch/arm/boot/dts/stm32f429.dtsi                   |  10 +
 arch/arm/boot/dts/stm32f469-disco.dts              |   4 +
 drivers/clk/clk-stm32f4.c                          |   4 -
 .../media/common/videobuf2/videobuf2-dma-contig.c  |   4 +-
 drivers/media/platform/Kconfig                     |  11 +
 drivers/media/platform/Makefile                    |   1 +
 drivers/media/platform/stm32/Makefile              |   2 +
 drivers/media/platform/stm32/dma2d/dma2d-hw.c      | 143 ++++
 drivers/media/platform/stm32/dma2d/dma2d-regs.h    | 113 ++++
 drivers/media/platform/stm32/dma2d/dma2d.c         | 739 +++++++++++++++++++++
 drivers/media/platform/stm32/dma2d/dma2d.h         | 135 ++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c          |  12 +-
 drivers/media/v4l2-core/v4l2-mem2mem.c             |  21 +
 include/media/v4l2-mem2mem.h                       |   5 +
 include/uapi/linux/v4l2-controls.h                 |   4 +-
 18 files changed, 1280 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/st,stm32-dma2d.yaml
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-hw.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d-regs.h
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.c
 create mode 100644 drivers/media/platform/stm32/dma2d/dma2d.h