drm/meson: add support for Amlogic Video FBC
v8 cover drm/meson: add support for Amlogic Video FBC
Amlogic uses a proprietary lossless image compression protocol and format for their hardware video codec accelerators, either video decoders or video input encoders.
It considerably reduces memory bandwidth while writing and reading frames in memory.
The underlying storage is considered to be 3 components, 8bit or 10-bit per component, YCbCr 420, single plane :
- DRM_FORMAT_YUV420_8BIT
- DRM_FORMAT_YUV420_10BIT
This modifier will be notably added to DMA-BUF frames imported from the V4L2 Amlogic VDEC decoder.
At least two layout are supported :
- Basic: composed of a body and a header
- Scatter: the buffer is filled with a IOMMU scatter table referring to the encoder current memory layout. This mode if more efficient in terms of memory allocation but frames are not dumpable and only valid during until the buffer is freed and back in control of the encoder
At least two options are supported :
- Memory saving: when the pixel bpp is 8b, the size of the superblock can be reduced, thus saving memory.
This serie adds the missing register, updated the FBC decoder registers content to be committed by the crtc code.
The Amlogic FBC has been tested with compressed content from the Amlogic HW VP9 decoder on S905X (GXL), S905D2 (G12A) and S905X3 (SM1) in 8bit (Scatter+Mem Saving on G12A/SM1, Mem Saving on GXL) and 10bit (Scatter on G12A/SM1, default on GXL).
It's expected to work as-is on GXM and G12B SoCs.
Changes since v7 at [7]:
- rebased on drm-misc-next
- removed spurious DEBUG in drivers/gpu/drm/meson/meson_overlay.c
Changes since v6 at [6]:
- rebased on drm-misc-next (after drm-misc-next-2020-05-14)
- updated patch 1 commit log for completion
Changes since v5 at [5]:
- merged all fourcc patches in 1
- fixed fourcc definition to have only a single DRM_MOD_
- fixed 2 checkpatch issues
Changes since v4 at [4]:
- added layout and options mask
- cosmetic changes in fourcc.h
- fixed mod check using the masks
- fixed plane apply using the masks
Changes since v3 at [3]:
- added dropped fourcc patch for scatter
- fixed build of last patch
Changes since v2 at [2]:
- Added "BASIC" layout and moved the SCATTER mode as layout, making BASIC and SCATTER layout exclusives
- Moved the Memory Saving at bit 8 for options fields
- Split fourcc and overlay patch to introduce basic, mem saving and then scatter in separate patches
- Added comment about "transferability" of the buffers
Changes since v1 at [1]:
- s/VD1_AXI_SEL_AFB/VD1_AXI_SEL_AFBC/ into meson_registers.h
[1] https://patchwork.freedesktop.org/series/73722/#rev1
[2] https://patchwork.freedesktop.org/series/73722/#rev2
[3] https://patchwork.freedesktop.org/series/73722/#rev3
[4] https://patchwork.freedesktop.org/series/73722/#rev4
[5] https://patchwork.freedesktop.org/series/73722/#rev5
[6] https://patchwork.freedesktop.org/series/73722/#rev6
[7] https://patchwork.freedesktop.org/series/73722/#rev7
Neil Armstrong (6):
drm/fourcc: Add modifier definitions for describing Amlogic Video
Framebuffer Compression
drm/meson: add Amlogic Video FBC registers
drm/meson: overlay: setup overlay for Amlogic FBC drm/meson: overlay: setup overlay for Amlogic FBC Memory Saving mode drm/meson: overlay: setup overlay for Amlogic FBC Scatter Memory
layout
drm/meson: crtc: handle commit of Amlogic FBC frames
drivers/gpu/drm/meson/meson_crtc.c | 118 +++++++--- drivers/gpu/drm/meson/meson_drv.h | 16 ++ drivers/gpu/drm/meson/meson_overlay.c | 289 +++++++++++++++++++++++- drivers/gpu/drm/meson/meson_registers.h | 22 ++ include/uapi/drm/drm_fourcc.h | 74 ++++++ 5 files changed, 481 insertions(+), 38 deletions(-)
Signature · 1 line
2.22.0
PATCH v8 1/6 drm/fourcc: Add modifier definitions for describing Amlogic Video Framebuffer Compression
Amlogic uses a proprietary lossless image compression protocol and format for their hardware video codec accelerators, either video decoders or video input encoders.
It considerably reduces memory bandwidth while writing and reading frames in memory.
The underlying storage is considered to be 3 components, 8bit or 10-bit per component, YCbCr 420, single plane :
- DRM_FORMAT_YUV420_8BIT
- DRM_FORMAT_YUV420_10BIT
This modifier will be notably added to DMA-BUF frames imported from the V4L2 Amlogic VDEC decoder.
This introduces the basic layout composed of:
- a body content organized in 64x32 superblocks with 4096 bytes per superblock in default mode.
- a 32 bytes per 128x64 header block
This layout is tranferrable between Amlogic SoCs supporting this modifier.
The Memory Saving option exist changing the layout superblock size to save memory when using 8bit components pixels size.
Finally is also adds the Scatter Memory layout, meaning the header contains IOMMU references to the compressed frames content to optimize memory access and layout.
In this mode, only the header memory address is needed, thus the content memory organization is tied to the current producer execution and cannot be saved/dumped neither transferrable between Amlogic SoCs supporting this modifier.
--- include/uapi/drm/drm_fourcc.h | 74 +++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+)
include/uapi/drm/drm_fourcc.h +74 -0
@@ -331,6 +331,7 @@ extern "C" {#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07#define DRM_FORMAT_MOD_VENDOR_ARM 0x08#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 +#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a/* add more to the end as needed */
@@ -950,6 +951,79 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)*/ #define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) +/* +* Amlogic Video Framebuffer Compression modifiers +* +* Amlogic uses a proprietary lossless image compression protocol and format +* for their hardware video codec accelerators, either video decoders or +* video input encoders. +* +* It considerably reduces memory bandwidth while writing and reading +* frames in memory. +* +* The underlying storage is considered to be 3 components, 8bit or 10-bit +* per component YCbCr 420, single plane : +* - DRM_FORMAT_YUV420_8BIT +* - DRM_FORMAT_YUV420_10BIT +* +* The first 8 bits of the mode defines the layout, then the following 8 bits +* defines the options changing the layout. +* +* Not all combinations are valid, and different SoCs may support different +* combinations of layout and options. +*/ +#define __fourcc_mod_amlogic_layout_mask 0xf +#define __fourcc_mod_amlogic_options_shift 8 +#define __fourcc_mod_amlogic_options_mask 0xf + +#define DRM_FORMAT_MOD_AMLOGIC_FBC (__layout, __options) \ + fourcc_mod_code(AMLOGIC, \ + ((__layout) & __fourcc_mod_amlogic_layout_mask) | \ + ((__options) & __fourcc_mod_amlogic_options_mask \ + << __fourcc_mod_amlogic_options_shift)) + +/* Amlogic FBC Layouts */ + +/* +* Amlogic FBC Basic Layout +* +* The basic layout is composed of: +* - a body content organized in 64x32 superblocks with 4096 bytes per +* superblock in default mode. +* - a 32 bytes per 128x64 header block +* +* This layout is transferrable between Amlogic SoCs supporting this modifier. +*/ +#define AMLOGIC_FBC_LAYOUT_BASIC (1ULL) + +/* +* Amlogic FBC Scatter Memory layout +* +* Indicates the header contains IOMMU references to the compressed +* frames content to optimize memory access and layout. +* +* In this mode, only the header memory address is needed, thus the +* content memory organization is tied to the current producer +* execution and cannot be saved/dumped neither transferrable between +* Amlogic SoCs supporting this modifier. +*/ +#define AMLOGIC_FBC_LAYOUT_SCATTER (2ULL) + +/* Amlogic FBC Layout Options Bit Mask */ + +/* +* Amlogic FBC Memory Saving mode +* +* Indicates the storage is packed when pixel size is multiple of word +* boudaries, i.e. 8bit should be stored in this mode to save allocation +* memory. +* +* This mode reduces body layout to 3072 bytes per 64x32 superblock with +* the basic layout and 3200 bytes per 64x32 superblock combined with +* the scatter layout. +*/ +#define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0) +#if defined(__cplusplus) }#endif
Signature · 1 line
2.22.0
Re: [PATCH v8 1/6] drm/fourcc: Add modifier definitions for describing Amlogic Video Framebuffer Compression
Quoted 8 lines · Neil Armstrong
Finally is also adds the Scatter Memory layout, meaning the header contains IOMMU references to the compressed frames content to optimize memory access and layout.
In this mode, only the header memory address is needed, thus the content memory organization is tied to the current producer execution and cannot be saved/dumped neither transferrable between Amlogic SoCs supporting this modifier.
Still not sure how to handle this one, since this breaks fundamental assumptions about modifiers.
Re: [PATCH v8 1/6] drm/fourcc: Add modifier definitions for describing Amlogic Video Framebuffer Compression
Quoted 6 lines · Simon Ser
Quoted 4 lines · Neil Armstrong
Finally is also adds the Scatter Memory layout, meaning the header contains IOMMU references to the compressed frames content to optimize memory access and layout.
Quoted 7 lines
Quoted 4 lines
In this mode, only the header memory address is needed, thus the content memory organization is tied to the current producer execution and cannot be saved/dumped neither transferrable between Amlogic SoCs supporting this modifier.
Still not sure how to handle this one, since this breaks fundamental assumptions about modifiers.
I wonder whether we should require special allocations for these, and then just outright reject mmap on these buffers. mmap on dma-buf isn't a required feature.
That would make sure that userspace cannot look at them.
Also I'm kinda suspecting that there's not unlimited amounts of this magic invisible storage available anyway.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v8 1/6] drm/fourcc: Add modifier definitions for describing Amlogic Video Framebuffer Compression
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Simon Ser
Quoted 8 lines · Neil Armstrong
Finally is also adds the Scatter Memory layout, meaning the header contains IOMMU references to the compressed frames content to optimize memory access and layout.
In this mode, only the header memory address is needed, thus the content memory organization is tied to the current producer execution and cannot be saved/dumped neither transferrable between Amlogic SoCs supporting this modifier.
Quoted 6 lines
Quoted 2 lines
Still not sure how to handle this one, since this breaks fundamental assumptions about modifiers.
I wonder whether we should require special allocations for these, and then just outright reject mmap on these buffers. mmap on dma-buf isn't a required feature.
Yes, it's the plan to reject mmap on these buffers, but it can't be explained in the modifiers description and it's a requirement of the producer, not the consumer.
Quoted 7 lines
That would make sure that userspace cannot look at them.
Also I'm kinda suspecting that there's not unlimited amounts of this magic invisible storage available anyway.
-Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v8 1/6] drm/fourcc: Add modifier definitions for describing Amlogic Video Framebuffer Compression
Quoted 17 lines · Neil Armstrong
Quoted 15 lines · Daniel Vetter
Quoted 13 lines · Simon Ser
Quoted 8 lines · Neil Armstrong
Finally is also adds the Scatter Memory layout, meaning the header contains IOMMU references to the compressed frames content to optimize memory access and layout.
In this mode, only the header memory address is needed, thus the content memory organization is tied to the current producer execution and cannot be saved/dumped neither transferrable between Amlogic SoCs supporting this modifier.
Still not sure how to handle this one, since this breaks fundamental assumptions about modifiers.
Quoted 7 lines
Quoted 3 lines
I wonder whether we should require special allocations for these, and then just outright reject mmap on these buffers. mmap on dma-buf isn't a required feature.
Yes, it's the plan to reject mmap on these buffers, but it can't be explained in the modifiers description and it's a requirement of the producer, not the consumer.
Hm I think worth to add that as a note to the modifier. Just to make sure. And avoids questions like the one from Simon. -Daniel
Quoted 13 lines
Quoted 8 lines
That would make sure that userspace cannot look at them.
Also I'm kinda suspecting that there's not unlimited amounts of this magic invisible storage available anyway.
-Daniel_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v8 1/6] drm/fourcc: Add modifier definitions for describing Amlogic Video Framebuffer Compression
Hi,
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Neil Armstrong
Quoted 18 lines · Daniel Vetter
Quoted 6 lines · Simon Ser
Quoted 4 lines · Neil Armstrong
Finally is also adds the Scatter Memory layout, meaning the header contains IOMMU references to the compressed frames content to optimize memory access and layout.
Quoted 7 lines
Quoted 4 lines
In this mode, only the header memory address is needed, thus the content memory organization is tied to the current producer execution and cannot be saved/dumped neither transferrable between Amlogic SoCs supporting this modifier.
Still not sure how to handle this one, since this breaks fundamental assumptions about modifiers.
I wonder whether we should require special allocations for these, and then just outright reject mmap on these buffers. mmap on dma-buf isn't a required feature.
Quoted 6 lines
Quoted 3 lines
Yes, it's the plan to reject mmap on these buffers, but it can't be explained in the modifiers description and it's a requirement of the producer, not the consumer.
Hm I think worth to add that as a note to the modifier. Just to make sure. And avoids questions like the one from Simon.
Something like:
/*
* Amlogic FBC Scatter Memory layout
*
* Indicates the header contains IOMMU references to the compressed
* frames content to optimize memory access and layout.
*
* In this mode, only the header memory address is needed, thus the
* content memory organization is tied to the current producer
* execution and cannot be saved/dumped neither transferrable between
* Amlogic SoCs supporting this modifier.
+ *
+ * Due to the nature of the layout, these buffers are not expected to
+ * be accessible by the user-space clients but only accessible by the
+ * hardware producers and consumers.
+ *
+ * The user-space clients should expect a failure while trying to mmap
+ * the DMA-BUF handle returned by the producer.
*/
Thanks,
Neil
Quoted 18 lines
-Daniel
Quoted 13 lines
Quoted 8 lines
That would make sure that userspace cannot look at them.
Also I'm kinda suspecting that there's not unlimited amounts of this magic invisible storage available anyway.
-Daniel_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v8 1/6] drm/fourcc: Add modifier definitions for describing Amlogic Video Framebuffer Compression
Quoted 44 lines · Neil Armstrong
Hi,
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Neil Armstrong
Quoted 18 lines · Daniel Vetter
Quoted 6 lines · Simon Ser
Quoted 4 lines · Neil Armstrong
Finally is also adds the Scatter Memory layout, meaning the header contains IOMMU references to the compressed frames content to optimize memory access and layout.
Quoted 7 lines
Quoted 4 lines
In this mode, only the header memory address is needed, thus the content memory organization is tied to the current producer execution and cannot be saved/dumped neither transferrable between Amlogic SoCs supporting this modifier.
Still not sure how to handle this one, since this breaks fundamental assumptions about modifiers.
I wonder whether we should require special allocations for these, and then just outright reject mmap on these buffers. mmap on dma-buf isn't a required feature.
Quoted 6 lines
Quoted 3 lines
Yes, it's the plan to reject mmap on these buffers, but it can't be explained in the modifiers description and it's a requirement of the producer, not the consumer.
Hm I think worth to add that as a note to the modifier. Just to make sure. And avoids questions like the one from Simon.
Something like:
/*
* Amlogic FBC Scatter Memory layout
*
* Indicates the header contains IOMMU references to the compressed
* frames content to optimize memory access and layout.
*
* In this mode, only the header memory address is needed, thus the
* content memory organization is tied to the current producer
* execution and cannot be saved/dumped neither transferrable between
* Amlogic SoCs supporting this modifier.
Quoted 8 lines
+ *
+ * Due to the nature of the layout, these buffers are not expected to
+ * be accessible by the user-space clients but only accessible by the
+ * hardware producers and consumers.
+ *
+ * The user-space clients should expect a failure while trying to mmap
+ * the DMA-BUF handle returned by the producer.
*/
lgtm, Acked-by: Daniel Vetter <[email protected]>
Quoted 23 lines
Thanks,
NeilQuoted 18 lines
-Daniel
Quoted 13 lines
Quoted 8 lines
That would make sure that userspace cannot look at them.
Also I'm kinda suspecting that there's not unlimited amounts of this magic invisible storage available anyway.
-Daniel_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v8 2/6 drm/meson: add Amlogic Video FBC registers
In reply to Neil ArmstrongAdd the registers of the VPU VD1 Amlogic FBC decoder module, and routing register.
--- drivers/gpu/drm/meson/meson_registers.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/meson/meson_registers.h +22 -0
@@ -144,10 +144,15 @@#define VIU_SW_RESET_OSD1 BIT(0)#define VIU_MISC_CTRL0 0x1a06#define VIU_CTRL0_VD1_AFBC_MASK 0x170000 +#define VIU_CTRL0_AFBC_TO_VD1 BIT(20)#define VIU_MISC_CTRL1 0x1a07#define MALI_AFBC_MISC GENMASK(15, 8)#define D2D3_INTF_LENGTH 0x1a08#define D2D3_INTF_CTRL0 0x1a09 +#define VD1_AFBCD0_MISC_CTRL 0x1a0a +#define VD1_AXI_SEL_AFBC (1 << 12) +#define AFBC_VD1_SEL (1 << 10) +#define VD2_AFBCD1_MISC_CTRL 0x1a0b#define VIU_OSD1_CTRL_STAT 0x1a10#define VIU_OSD1_OSD_BLK_ENABLE BIT(0)#define VIU_OSD1_OSD_MEM_MODE_LINEAR BIT(2)
@@ -365,6 +370,23 @@#define VIU_OSD1_OETF_LUT_ADDR_PORT 0x1add#define VIU_OSD1_OETF_LUT_DATA_PORT 0x1ade#define AFBC_ENABLE 0x1ae0 +#define AFBC_MODE 0x1ae1 +#define AFBC_SIZE_IN 0x1ae2 +#define AFBC_DEC_DEF_COLOR 0x1ae3 +#define AFBC_CONV_CTRL 0x1ae4 +#define AFBC_LBUF_DEPTH 0x1ae5 +#define AFBC_HEAD_BADDR 0x1ae6 +#define AFBC_BODY_BADDR 0x1ae7 +#define AFBC_SIZE_OUT 0x1ae8 +#define AFBC_OUT_YSCOPE 0x1ae9 +#define AFBC_STAT 0x1aea +#define AFBC_VD_CFMT_CTRL 0x1aeb +#define AFBC_VD_CFMT_W 0x1aec +#define AFBC_MIF_HOR_SCOPE 0x1aed +#define AFBC_MIF_VER_SCOPE 0x1aee +#define AFBC_PIXEL_HOR_SCOPE 0x1aef +#define AFBC_PIXEL_VER_SCOPE 0x1af0 +#define AFBC_VD_CFMT_H 0x1af1/* vpp */ #define VPP_DUMMY_DATA 0x1d00
Signature · 1 line
2.22.0
PATCH v8 3/6 drm/meson: overlay: setup overlay for Amlogic FBC
In reply to Neil ArmstrongSetup the Amlogic FBC decoder for the VD1 video overlay plane.
The VD1 Amlogic FBC decoder is integrated in the pipeline like the YUV pixel reading/formatter but used a direct memory address instead.
This adds support for the basic layout, and needs to calculate the content body size since the header is allocated after.
--- drivers/gpu/drm/meson/meson_drv.h | 16 ++ drivers/gpu/drm/meson/meson_overlay.c | 251 +++++++++++++++++++++++++- 2 files changed, 259 insertions(+), 8 deletions(-)
drivers/gpu/drm/meson/meson_drv.h +16 -0
@@ -86,6 +86,7 @@ struct meson_drm {bool vd1_enabled;bool vd1_commit; +bool vd1_afbc;unsigned int vd1_planes;uint32_t vd1_if0_gen_reg;uint32_t vd1_if0_luma_x0;
@@ -111,6 +112,21 @@ struct meson_drm {uint32_t vd1_height0;uint32_t vd1_height1;uint32_t vd1_height2; +uint32_t vd1_afbc_mode; +uint32_t vd1_afbc_en; +uint32_t vd1_afbc_head_addr; +uint32_t vd1_afbc_body_addr; +uint32_t vd1_afbc_conv_ctrl; +uint32_t vd1_afbc_dec_def_color; +uint32_t vd1_afbc_vd_cfmt_ctrl; +uint32_t vd1_afbc_vd_cfmt_w; +uint32_t vd1_afbc_vd_cfmt_h; +uint32_t vd1_afbc_mif_hor_scope; +uint32_t vd1_afbc_mif_ver_scope; +uint32_t vd1_afbc_size_out; +uint32_t vd1_afbc_pixel_hor_scope; +uint32_t vd1_afbc_pixel_ver_scope; +uint32_t vd1_afbc_size_in;uint32_t vpp_pic_in_height;uint32_t vpp_postblend_vd1_h_start_end;uint32_t vpp_postblend_vd1_v_start_end;
drivers/gpu/drm/meson/meson_overlay.c +243 -8
335 lines not on this page · raw message
Signature · 6 lines
2.22.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
kernel test robot
build botRe: [PATCH v8 3/6] drm/meson: overlay: setup overlay for Amlogic FBC
I love your patch! Yet something to improve:
Hi Neil,
I love your patch! Yet something to improve:
[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next drm-tip/drm-tip linus/master v5.8-rc3 next-20200702] [cannot apply to drm/drm-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Neil-Armstrong/drm-meson-add-support-for-Amlogic-Video-FBC/20200702-154952 base: git://anongit.freedesktop.org/drm-intel for-linux-next config: arm-allyesconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
In file included from include/linux/build_bug.h:5,
from include/linux/bitfield.h:10,
from drivers/gpu/drm/meson/meson_overlay.c:8:
drivers/gpu/drm/meson/meson_overlay.c: In function 'meson_overlay_setup_scaler_params':
>> include/linux/compiler.h:392:38: error: call to '__compiletime_assert_334' declared with attribute error: FIELD_PREP: value too large for the field
392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
include/linux/compiler.h:373:4: note: in definition of macro '__compiletime_assert'
373 | prefix ## suffix(); \
| ^~~~~~
include/linux/compiler.h:392:2: note: in expansion of macro '_compiletime_assert'
392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/meson/meson_overlay.c:147:37: note: in expansion of macro 'FIELD_PREP'
147 | #define AFBC_DEC_PIXEL_BGN_H(value) FIELD_PREP(GENMASK(28, 16), value)
| ^~~~~~~~~~
>> drivers/gpu/drm/meson/meson_overlay.c:413:4: note: in expansion of macro 'AFBC_DEC_PIXEL_BGN_H'
413 | AFBC_DEC_PIXEL_BGN_H(hd_start_lines - afbc_left) |
| ^~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:392:38: error: call to '__compiletime_assert_394' declared with attribute error: FIELD_PREP: value too large for the field
392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
include/linux/compiler.h:373:4: note: in definition of macro '__compiletime_assert'
373 | prefix ## suffix(); \
| ^~~~~~
include/linux/compiler.h:392:2: note: in expansion of macro '_compiletime_assert'
392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~
drivers/gpu/drm/meson/meson_overlay.c:61:28: note: in expansion of macro 'FIELD_PREP'
61 | #define VD_H_START(value) FIELD_PREP(GENMASK(27, 16), value)
| ^~~~~~~~~~
>> drivers/gpu/drm/meson/meson_overlay.c:434:40: note: in expansion of macro 'VD_H_START'
434 | priv->viu.vpp_blend_vd2_h_start_end = VD_H_START(hd_start_lines) |
| ^~~~~~~~~~vim +/__compiletime_assert_334 +392 include/linux/compiler.h
9a8ab1c39970a4 Daniel Santos 2013-02-21 378 9a8ab1c39970a4 Daniel Santos 2013-02-21 379 #define _compiletime_assert(condition, msg, prefix, suffix) \ 9a8ab1c39970a4 Daniel Santos 2013-02-21 380 __compiletime_assert(condition, msg, prefix, suffix) 9a8ab1c39970a4 Daniel Santos 2013-02-21 381 9a8ab1c39970a4 Daniel Santos 2013-02-21 382 /** 9a8ab1c39970a4 Daniel Santos 2013-02-21 383 * compiletime_assert - break build and emit msg if condition is false 9a8ab1c39970a4 Daniel Santos 2013-02-21 384 * @condition: a compile-time constant condition to check 9a8ab1c39970a4 Daniel Santos 2013-02-21 385 * @msg: a message to emit if condition is false 9a8ab1c39970a4 Daniel Santos 2013-02-21 386 * 9a8ab1c39970a4 Daniel Santos 2013-02-21 387 * In tradition of POSIX assert, this macro will break the build if the 9a8ab1c39970a4 Daniel Santos 2013-02-21 388 * supplied condition is *false*, emitting the supplied error message if the 9a8ab1c39970a4 Daniel Santos 2013-02-21 389 * compiler has support to do so. 9a8ab1c39970a4 Daniel Santos 2013-02-21 390 */ 9a8ab1c39970a4 Daniel Santos 2013-02-21 391 #define compiletime_assert(condition, msg) \
af9c5d2e3b3558 Vegard Nossum 2020-04-06 @392 _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)9a8ab1c39970a4 Daniel Santos 2013-02-21 393
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v8 4/6 drm/meson: overlay: setup overlay for Amlogic FBC Memory Saving mode
In reply to Neil ArmstrongSetup the Amlogic FBC decoder for the VD1 video overlay plane to use a different superblock size for the Memory Saving mode.
--- drivers/gpu/drm/meson/meson_overlay.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/gpu/drm/meson/meson_overlay.c +23 -2
@@ -486,6 +486,10 @@ static void meson_overlay_atomic_update(struct drm_plane *plane,AFBC_HOLD_LINE_NUM (8 ) |AFBC_BURST_LEN (2 ); +if (fb->modifier &DRM_FORMAT_MOD_AMLOGIC_FBC (0 , +AMLOGIC_FBC_OPTION_MEM_SAVING )) + priv->viu.vd1_afbc_mode |=AFBC_BLK_MEM_MODE ; + priv->viu.vd1_afbc_en =0x1600 |AFBC_DEC_ENABLE ; priv->viu.vd1_afbc_conv_ctrl =AFBC_CONV_LBUF_LEN (256 );
@@ -671,12 +675,17 @@ static void meson_overlay_atomic_update(struct drm_plane *plane, }if (priv->viu.vd1_afbc) { +/* Default mode is 4k per superblock */ +unsigned long block_size =4096 ;unsigned long body_size; -/* Default mode is 4k per superblock */ +/* 8bit mem saving mode is 3072bytes per superblock */ +if (priv->viu.vd1_afbc_mode &AFBC_BLK_MEM_MODE ) + block_size =3072 ; + body_size = (ALIGN (priv->viu.vd1_stride0,64 ) /64 ) * (ALIGN (priv->viu.vd1_height0,32 ) /32 ) * -4096 ; + block_size; priv->viu.vd1_afbc_body_addr = priv->viu.vd1_addr0 >>4 ;
@@ -734,6 +743,9 @@ static bool meson_overlay_format_mod_supported(struct drm_plane *plane,unsigned int layout = modifier &DRM_FORMAT_MOD_AMLOGIC_FBC ( __fourcc_mod_amlogic_layout_mask,0 ); +unsigned int options = + (modifier >> __fourcc_mod_amlogic_options_shift) & + __fourcc_mod_amlogic_options_mask;if (format !=DRM_FORMAT_YUV420_8BIT && format !=DRM_FORMAT_YUV420_10BIT ) {
@@ -748,6 +760,13 @@ static bool meson_overlay_format_mod_supported(struct drm_plane *plane,return false; } +if (options && + options !=AMLOGIC_FBC_OPTION_MEM_SAVING ) { +DRM_DEBUG_KMS ("%llx invalid layout %x\n" , + modifier, layout); +return false; + } +return true; }
@@ -781,6 +800,8 @@ static const uint32_t supported_drm_formats[] = { };static const uint64_t format_modifiers[] = { +DRM_FORMAT_MOD_AMLOGIC_FBC (AMLOGIC_FBC_LAYOUT_BASIC , +AMLOGIC_FBC_OPTION_MEM_SAVING ),DRM_FORMAT_MOD_AMLOGIC_FBC (AMLOGIC_FBC_LAYOUT_BASIC ,0 ),DRM_FORMAT_MOD_LINEAR ,DRM_FORMAT_MOD_INVALID ,
Signature · 6 lines
2.22.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v8 5/6 drm/meson: overlay: setup overlay for Amlogic FBC Scatter Memory layout
In reply to Neil ArmstrongSetup the Amlogic FBC decoder for the VD1 video overlay plane to use read the FBC header as Scatter Memory layout reference.
--- drivers/gpu/drm/meson/meson_overlay.c | 53 ++++++++++++++++++--------- 1 file changed, 35 insertions(+), 18 deletions(-)
drivers/gpu/drm/meson/meson_overlay.c +35 -18
@@ -490,6 +490,10 @@ static void meson_overlay_atomic_update(struct drm_plane *plane, AMLOGIC_FBC_OPTION_MEM_SAVING)) priv->viu.vd1_afbc_mode |= AFBC_BLK_MEM_MODE; +if ((fb->modifier & __fourcc_mod_amlogic_layout_mask) == +AMLOGIC_FBC_LAYOUT_SCATTER ) + priv->viu.vd1_afbc_mode |=AFBC_SCATTER_MODE ; + priv->viu.vd1_afbc_en =0x1600 |AFBC_DEC_ENABLE ; priv->viu.vd1_afbc_conv_ctrl =AFBC_CONV_LBUF_LEN (256 );
@@ -675,23 +679,32 @@ static void meson_overlay_atomic_update(struct drm_plane *plane, }if (priv->viu.vd1_afbc) { -/* Default mode is 4k per superblock */ -unsigned long block_size =4096 ; -unsigned long body_size; - -/* 8bit mem saving mode is 3072bytes per superblock */ -if (priv->viu.vd1_afbc_mode &AFBC_BLK_MEM_MODE ) - block_size =3072 ; - - body_size = (ALIGN (priv->viu.vd1_stride0,64 ) /64 ) * - (ALIGN (priv->viu.vd1_height0,32 ) /32 ) * - block_size; - - priv->viu.vd1_afbc_body_addr = priv->viu.vd1_addr0 >>4 ; - -/* Header is after body content */ - priv->viu.vd1_afbc_head_addr = (priv->viu.vd1_addr0 + - body_size) >>4 ; +if (priv->viu.vd1_afbc_mode &AFBC_SCATTER_MODE ) { +/* +* In Scatter mode, the header contains the physical +* body content layout, thus the body content +* size isn't needed. +*/ + priv->viu.vd1_afbc_head_addr = priv->viu.vd1_addr0 >>4 ; + priv->viu.vd1_afbc_body_addr =0 ; + }else { +/* Default mode is 4k per superblock */ +unsigned long block_size =4096 ; +unsigned long body_size; + +/* 8bit mem saving mode is 3072bytes per superblock */ +if (priv->viu.vd1_afbc_mode &AFBC_BLK_MEM_MODE ) + block_size =3072 ; + + body_size = (ALIGN (priv->viu.vd1_stride0,64 ) /64 ) * + (ALIGN (priv->viu.vd1_height0,32 ) /32 ) * + block_size; + + priv->viu.vd1_afbc_body_addr = priv->viu.vd1_addr0 >>4 ; +/* Header is after body content */ + priv->viu.vd1_afbc_head_addr = (priv->viu.vd1_addr0 + + body_size) >>4 ; + } } priv->viu.vd1_enabled = true;
@@ -754,7 +767,8 @@ static bool meson_overlay_format_mod_supported(struct drm_plane *plane,return false; } -if (layout !=AMLOGIC_FBC_LAYOUT_BASIC ) { +if (layout !=AMLOGIC_FBC_LAYOUT_BASIC && + layout !=AMLOGIC_FBC_LAYOUT_SCATTER ) {DRM_DEBUG_KMS ("%llx invalid layout %x\n" , modifier, layout);return false;
@@ -800,8 +814,11 @@ static const uint32_t supported_drm_formats[] = { };static const uint64_t format_modifiers[] = { +DRM_FORMAT_MOD_AMLOGIC_FBC (AMLOGIC_FBC_LAYOUT_SCATTER , +AMLOGIC_FBC_OPTION_MEM_SAVING ),DRM_FORMAT_MOD_AMLOGIC_FBC (AMLOGIC_FBC_LAYOUT_BASIC ,AMLOGIC_FBC_OPTION_MEM_SAVING ), +DRM_FORMAT_MOD_AMLOGIC_FBC (AMLOGIC_FBC_LAYOUT_SCATTER ,0 ),DRM_FORMAT_MOD_AMLOGIC_FBC (AMLOGIC_FBC_LAYOUT_BASIC ,0 ),DRM_FORMAT_MOD_LINEAR ,DRM_FORMAT_MOD_INVALID ,
Signature · 1 line
2.22.0
PATCH v8 6/6 drm/meson: crtc: handle commit of Amlogic FBC frames
In reply to Neil ArmstrongSince the VD1 Amlogic FBC decoder is now configured by the overlay driver, commit the right registers to decode the Amlogic FBC frame.
--- drivers/gpu/drm/meson/meson_crtc.c | 118 +++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 30 deletions(-)
drivers/gpu/drm/meson/meson_crtc.c +88 -30
@@ -291,6 +291,10 @@ static void meson_crtc_enable_vd1(struct meson_drm *priv)VPP_VD1_PREBLEND |VPP_VD1_POSTBLEND |VPP_COLOR_MNG_ENABLE , priv->io_base + _REG(VPP_MISC)); + +writel_bits_relaxed (VIU_CTRL0_AFBC_TO_VD1 , + priv->viu.vd1_afbc ?VIU_CTRL0_AFBC_TO_VD1 :0 , + priv->io_base +_REG (VIU_MISC_CTRL0 )); }static void meson_g12a_crtc_enable_vd1 (struct meson_drm *priv)
@@ -300,6 +304,10 @@ static void meson_g12a_crtc_enable_vd1(struct meson_drm *priv)VD_BLEND_POSTBLD_SRC_VD1 |VD_BLEND_POSTBLD_PREMULT_EN , priv->io_base + _REG(VD1_BLEND_SRC_CTRL)); + +writel_relaxed (priv->viu.vd1_afbc ? + (VD1_AXI_SEL_AFBC |AFBC_VD1_SEL ) :0 , + priv->io_base +_REG (VD1_AFBCD0_MISC_CTRL )); }void meson_crtc_irq (struct meson_drm *priv)
@@ -383,36 +391,86 @@ void meson_crtc_irq(struct meson_drm *priv)/* Update the VD1 registers */ if (priv->viu.vd1_enabled && priv->viu.vd1_commit) { -switch (priv->viu.vd1_planes) { -case 3 : -meson_canvas_config (priv->canvas, - priv->canvas_id_vd1_2, - priv->viu.vd1_addr2, - priv->viu.vd1_stride2, - priv->viu.vd1_height2, -MESON_CANVAS_WRAP_NONE , -MESON_CANVAS_BLKMODE_LINEAR , -MESON_CANVAS_ENDIAN_SWAP64 ); -/* fallthrough */ -case 2 : -meson_canvas_config (priv->canvas, - priv->canvas_id_vd1_1, - priv->viu.vd1_addr1, - priv->viu.vd1_stride1, - priv->viu.vd1_height1, -MESON_CANVAS_WRAP_NONE , -MESON_CANVAS_BLKMODE_LINEAR , -MESON_CANVAS_ENDIAN_SWAP64 ); -/* fallthrough */ -case 1 : -meson_canvas_config (priv->canvas, - priv->canvas_id_vd1_0, - priv->viu.vd1_addr0, - priv->viu.vd1_stride0, - priv->viu.vd1_height0, -MESON_CANVAS_WRAP_NONE , -MESON_CANVAS_BLKMODE_LINEAR , -MESON_CANVAS_ENDIAN_SWAP64 ); +if (priv->viu.vd1_afbc) { +writel_relaxed (priv->viu.vd1_afbc_head_addr, + priv->io_base + +_REG (AFBC_HEAD_BADDR )); +writel_relaxed (priv->viu.vd1_afbc_body_addr, + priv->io_base + +_REG (AFBC_BODY_BADDR )); +writel_relaxed (priv->viu.vd1_afbc_en, + priv->io_base + +_REG (AFBC_ENABLE )); +writel_relaxed (priv->viu.vd1_afbc_mode, + priv->io_base + +_REG (AFBC_MODE )); +writel_relaxed (priv->viu.vd1_afbc_size_in, + priv->io_base + +_REG (AFBC_SIZE_IN )); +writel_relaxed (priv->viu.vd1_afbc_dec_def_color, + priv->io_base + +_REG (AFBC_DEC_DEF_COLOR )); +writel_relaxed (priv->viu.vd1_afbc_conv_ctrl, + priv->io_base + +_REG (AFBC_CONV_CTRL )); +writel_relaxed (priv->viu.vd1_afbc_size_out, + priv->io_base + +_REG (AFBC_SIZE_OUT )); +writel_relaxed (priv->viu.vd1_afbc_vd_cfmt_ctrl, + priv->io_base + +_REG (AFBC_VD_CFMT_CTRL )); +writel_relaxed (priv->viu.vd1_afbc_vd_cfmt_w, + priv->io_base + +_REG (AFBC_VD_CFMT_W )); +writel_relaxed (priv->viu.vd1_afbc_mif_hor_scope, + priv->io_base + +_REG (AFBC_MIF_HOR_SCOPE )); +writel_relaxed (priv->viu.vd1_afbc_mif_ver_scope, + priv->io_base + +_REG (AFBC_MIF_VER_SCOPE )); +writel_relaxed (priv->viu.vd1_afbc_pixel_hor_scope, + priv->io_base+ +_REG (AFBC_PIXEL_HOR_SCOPE )); +writel_relaxed (priv->viu.vd1_afbc_pixel_ver_scope, + priv->io_base + +_REG (AFBC_PIXEL_VER_SCOPE )); +writel_relaxed (priv->viu.vd1_afbc_vd_cfmt_h, + priv->io_base + +_REG (AFBC_VD_CFMT_H )); + }else { +switch (priv->viu.vd1_planes) { +case 3 : +meson_canvas_config (priv->canvas, + priv->canvas_id_vd1_2, + priv->viu.vd1_addr2, + priv->viu.vd1_stride2, + priv->viu.vd1_height2, +MESON_CANVAS_WRAP_NONE , +MESON_CANVAS_BLKMODE_LINEAR , +MESON_CANVAS_ENDIAN_SWAP64 ); + fallthrough; +case 2 : +meson_canvas_config (priv->canvas, + priv->canvas_id_vd1_1, + priv->viu.vd1_addr1, + priv->viu.vd1_stride1, + priv->viu.vd1_height1, +MESON_CANVAS_WRAP_NONE , +MESON_CANVAS_BLKMODE_LINEAR , +MESON_CANVAS_ENDIAN_SWAP64 ); + fallthrough; +case 1 : +meson_canvas_config (priv->canvas, + priv->canvas_id_vd1_0, + priv->viu.vd1_addr0, + priv->viu.vd1_stride0, + priv->viu.vd1_height0, +MESON_CANVAS_WRAP_NONE , +MESON_CANVAS_BLKMODE_LINEAR , +MESON_CANVAS_ENDIAN_SWAP64 ); + } + +writel_relaxed (0 , priv->io_base +_REG (AFBC_ENABLE )); } writel_relaxed(priv->viu.vd1_if0_gen_reg,
Signature · 1 line
2.22.0
Quoted 29 lines · Neil Armstrong
Amlogic uses a proprietary lossless image compression protocol and format for their hardware video codec accelerators, either video decoders or video input encoders.
It considerably reduces memory bandwidth while writing and reading frames in memory.
The underlying storage is considered to be 3 components, 8bit or 10-bit per component, YCbCr 420, single plane :
-DRM_FORMAT_YUV420_8BIT
-DRM_FORMAT_YUV420_10BITThis modifier will be notably added to DMA-BUF frames imported from the V4L2 Amlogic VDEC decoder.
At least two layout are supported :
- Basic: composed of a body and a header
- Scatter: the buffer is filled with a IOMMU scatter table referring to the encoder current memory layout. This mode if more efficient in terms of memory allocation but frames are not dumpable and only valid during until the buffer is freed and back in control of the encoderAt least two options are supported :
- Memory saving: when the pixel bpp is 8b, the size of the superblock can be reduced, thus saving memory.This serie adds the missing register, updated the FBC decoder registers content to be committed by the crtc code.
Quoted 6 lines
The Amlogic FBC has been tested with compressed content from the Amlogic HW VP9 decoder on S905X (GXL), S905D2 (G12A) and S905X3 (SM1) in 8bit (Scatter+Mem Saving on G12A/SM1, Mem Saving on GXL) and 10bit (Scatter on G12A/SM1, default on GXL).
It's expected to work as-is on GXM and G12B SoCs.
Kevin
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel