Commit graph

143 commits

Author SHA1 Message Date
Dominik Behr
60aa3a0304 add dma-heap.h to external
and use it instead of system headers

Bug: 411474910
Test: mm ccdec in system/cros-codecs
Change-Id: I7a58acaa610e1678a379a4c28886938075e39037
2025-05-09 14:05:18 -07:00
Dominik Behr
89677c4474 mediatek: advertise support of protected buffers only
if the heap is available

Bug: b/406253026
Test: run android.graphics.cts.BitmapTest#testWrapHardwareBufferWithProtectedUsageFails
Flag: EXEMPT: desktop-only change
Change-Id: Ifbd1d75e63609e5e7c24e0ec6dce7aaba9f14b98
2025-04-14 16:34:23 -07:00
Andres Calderon Jaramillo
0df716da2c mediatek: Resolve DRM_FORMAT_FLEX_YCbCr_420_888 to NV12 outside MT8173
On Android, cros-codecs needs NV12 buffers that can be written to by the
CPU so that it can do MM21->NV12 de-tiling using libyuv. On Android, we
can't specify that we want NV12 buffers specifically using the gralloc
API. Instead, we ask for DRM_FORMAT_FLEX_YCbCr_420_888 and hope for the
best.

Before this CL, minigbm was returning YV12 buffers in this case on
corsola. This CL makes it so that on the mediatek backend,
DRM_FORMAT_FLEX_YCbCr_420_888 is always resolved to NV12 outside of
MT8173.

Bug: 408498122
Bug: 408503818
Test: adb -s $DUT shell codec -vpR /tmp/1080.mp4 on corsola
Test: vts-tradefed run vts --serial $DUT -m VtsHalMediaC2V1_0TargetVideoDecTest on corsola
Change-Id: Idbdba3434fdfdb0bf12aa7c92d1f9523e5870aba
2025-04-07 17:52:34 +00:00
Dominik Behr
a1e715acd8 cros_gralloc: add support for mt8186
Add build changes for mt8186.
Add ARM metadata types: compression, plane fds and data type.
Add mediatek_drm.h which is not available.

Bug: 388092228
Test: boot corsola with minigbm gralloc/mapper

Change-Id: I1f1e8a57f37e26694320c3ddee01fbad453f854b
2025-03-27 19:25:18 -07:00
Jeffrey Kardatzke
ff04d4aa48 minigbm: Fix 10bit protected allocations on MTK
There was another change done after this was tested before which then
was setting the size before the calculation was done to handle the
10-bit case. We now fix that size after doing the 10-bit modification.

BUG=b:367770932
TEST=None

Change-Id: Id5410f802c9140d378217fbf7b33f1d467ebf5ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5967833
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Auto-Submit: Jeffrey Kardatzke <jkardatzke@google.com>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Tested-by: Jeffrey Kardatzke <jkardatzke@google.com>
2024-10-28 07:50:21 +00:00
Grzegorz Jaszczyk
ff0509d723 mediatek: allow DRM_FORMAT_YVU420_ANDROID for camera use
After this change is_supported() succeeds, USB camera starts
working and:

 E [minigbm:CrosGralloc4Allocator.cc(88)]: Unsupported combination -- pixel format: YV12, drm format:DRM_FOURCC_9997, usage: CPU_READ_NEVER | CPU_WRITE_NEVER | CPU_WRITE_RARELY | CPU_WRITE_OFTEN | GPU_TEXTURE | CAMERA_OUTPUT (0x20130)

issue is fixed.

Similar settings were already introduced for other backends e.g. msm:
https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3058396

BUG=b:320202326, b:309244873
Test: Verify that external USB camera is working in Android environment

Change-Id: I7e1e328998ddf62ed127c001f054ed10c6fb6a02
Reviewed-by: Michal Dubiel <dubielm@google.com>
Reviewed-by: Konrad Adamczyk <konrada@google.com>
Tested-by: Konrad Adamczyk <konrada@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5913519
Auto-Submit: Grzegorz Jaszczyk <jaszczyk@google.com>
Tested-by: Grzegorz Jaszczyk <jaszczyk@google.com>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
2024-10-10 14:55:09 +00:00
Jason-jh Lin
661992dfdf mediatek: Allocate secure buffer by DMA_HEAP_IOCTL_ALLOC
1. Allocate secure buffer from DMA_HEAP_IOCTL_ALLOC ,then using FD to
create a GEM handle and close this FD.

2. Since the secure buffer doesn't allocate via DRM_IOCTL_MTK_GEM_CREATE,
the DRM_MTK_GEM_CREATE_FLAG_RESTRICTED flag can be removed.
It should be added in the code that calls drmModeAddFB2().

3. Add mediatek_private_drv_data to store the dma_heap_fd in drv->priv,
and also add mediatek_close() to close dma_heap_fd and free drv->priv
when backend driver is closing.

BUG=b:248609774
TEST=emerge-geralt minigbm

Change-Id: I96df25580efe04f2c9a739b2d68de8837df091df
Signed-off-by: Jason-jh Lin <jason-jh.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5581571
Reviewed-by: Jeffrey Kardatzke <jkardatzke@google.com>
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
2024-07-17 19:41:57 +00:00
Fei Shao
cd5aef63a7 minigbm: mediatek: Pass ALLOC_SINGLE_PAGES for linear scanout buffer
To improve the efficiency of allocating high-resolution video decoder,
pass a flag to notify the kernel DMA framework to allocate linear
scanout buffers with single pages, so the allocation is more likely to
success when the available large chunk memory is constrained.

BUG=b:352229429
TEST=emerge-geralt libdrm minigbm

Cq-Depend: chromium:5689126
Change-Id: I21f2745cb5bdb7eaf7f50482c4c091791d13bbcc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5706152
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-by: Fei Shao <fshao@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
2024-07-15 13:32:51 +00:00
Fei Shao
c06a7dbe71 minigbm: mediatek: Integrate primitive BO use flag definitions
Move the primitive is_* boolean definitions for BO_USE_* flags to the
top of mediatek_bo_create_with_modifiers().

No functional changes.

BUG=b:352229429
TEST=emerge-geralt minigbm

Change-Id: Id1e9007d16bbf43bfb11af6f0376a18e1fc02cf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5706151
Tested-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
2024-07-15 10:38:19 +00:00
Fei Shao
41fb484c28 minigbm: mediatek: Update restricted flag name
Follow CL:5689125 and rename the flag.

BUG=b:352225473
TEST=emerge-geralt minigbm libdrm

Cq-Depend: chromium:5689125
Change-Id: I271d57e255a79af5b8e93ddb91186107dc8ec529
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5690587
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-by: Fei Shao <fshao@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
2024-07-12 15:37:52 +00:00
Jeffrey Kardatzke
de65652cfb minigbm: Reduce allocation size for MT2T allocations
On MTK, when we allocate MT2T surfaces for protected content, these are
sent in as P010 instead. However, P010 uses 16bpp where MT2T requires
only 10bpp. This adjusts the allocation sizes to only be what is needed
so we reduce memory usage by 5/8.

BUG=b:339091167
TEST=Netflix 4K 10-bit HEVC plays on Ciri

Change-Id: Ia34b7d3aa962f3138da130077d723748592023bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5582540
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Auto-Submit: Jeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: Miguel Casas <mcasas@google.com>
Tested-by: Jeffrey Kardatzke <jkardatzke@google.com>
Commit-Queue: Miguel Casas <mcasas@google.com>
2024-05-31 22:59:05 +00:00
Hsin-Yi Wang
44265d2f9f mediatek: Add MT8196
BUG=b:336924470
TEST=emerge-rauru minigbm

Cq-Depend: chromium:5579120
Change-Id: I63a5352ecc60a98dd9438129e3a33aebb71361cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5577798
Commit-Queue: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Justin Green <greenjustin@google.com>
Tested-by: Hsin-Yi Wang <hsinyi@chromium.org>
2024-05-30 01:06:04 +00:00
Justin Green
1b84258e66 mediatek: Add AR30 overlay support
Add support for AR30 overlays to select MTK devices.

BUG=b:325625530
TEST=Tested by running MT2T->AR30 image processing tests on MT8188G.

Change-Id: I570ee740e49b5d9c61a1e1d0da777fdcc937321d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5345669
Reviewed-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Commit-Queue: Justin Green <greenjustin@google.com>
Reviewed-by: Jeffrey Kardatzke <jkardatzke@google.com>
Tested-by: Justin Green <greenjustin@google.com>
2024-03-11 19:08:31 +00:00
Fritz Koenig
e81321da13 mediatek: Add support for P010 allocation
Bug: b:278935312
Change-Id: Ia7f8a12d4edd60b1f1336787455942f1c750cda0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5241804
Tested-by: Fritz Koenig <frkoenig@chromium.org>
Commit-Queue: Fritz Koenig <frkoenig@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
2024-01-31 02:04:58 +00:00
Bartłomiej Grzesik
6a402a9d24 mediatek: limit recent changes to MTK8173
Previous change introduced a regression to CTS tests on other mediatek
board then MTK8173. This CL fixes this by switching to relying on
MTK_MT8173 compile define.

BUG=b:305347887
TEST=android.mediav2.cts.CodecEncoderSurfaceTest

Cq-Depend: chromium:4887244
Change-Id: I30f814222423e1b77d25c3256e9fcb0319c6339f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4946471
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Tested-by: Bartłomiej Grzesik <bgrzesik@google.com>
Commit-Queue: Kazuhiro Inaba <kinaba@chromium.org>
2023-11-30 05:44:32 +00:00
Bartłomiej Grzesik
90b2d47732 mediatek: allow BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER on MTK8173
This patch fixes the allocation of BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER
on MTK8173 in order to pass CTS tests. The tests were failing due to
lack of resolved combo for DRM_FORMAT_FLEX_YCbCr_420_888 with
BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER. Furthermore a change in
buffer alignment was required to avoid V4L2VDA failures.

BUG=b:292507490
TEST=CtsMediaV2TestCases android.mediav2.cts.CodecEncoderSurfaceTest

Change-Id: I41170169098e9110154328288710832a436bc9d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4916803
Auto-Submit: Bartłomiej Grzesik <bgrzesik@google.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Tested-by: Bartłomiej Grzesik <bgrzesik@google.com>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
2023-10-11 16:20:11 +00:00
Yiwei Zhang
118166a788 tiny format fixes
Also absorbs:
https://android-review.git.corp.google.com/c/platform/external/minigbm/+/2768266

BUG=n/a
TEST=./presubmit.sh

Change-Id: I7b781090762ed86b0d0c6c1736d0eeea6e2058ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4903262
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dawn Han <dawnhan@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
2023-10-11 08:08:59 +00:00
Dawn Han
aefedf94d8 minigbm: update format of mediatek.c
Run clang-format to correct the format in mediatek.c

BUG=N/A
TEST=CQ

Change-Id: I2c6630792ade67fd09a4fd8e7d13140ec4da7c90
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4517884
Commit-Queue: Dawn Han <dawnhan@google.com>
Tested-by: Dawn Han <dawnhan@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
2023-07-17 22:26:45 +00:00
Jason-JH.Lin
844c5e5c09 mediatek: Add BO_USE_PROTECTED use_flag for gpu and video decoder
BO_USE_PROTECTED use_flag is for allocating a secure buffer from GEM,
so we also need to add it for the formats of gpu and video decoder.

BUG=b:248609774
TEST="emerge-cherry libdrm minigbm" pass

Change-Id: I36f433ac173724a4c3794ad9642dea1f8d9db051
Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4603653
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Jeffrey Kardatzke <jkardatzke@google.com>
Tested-by: Jeffrey Kardatzke <jkardatzke@google.com>
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
2023-06-27 18:14:25 +00:00
Nathan Lu
b56c26b51c mediatek: Add BO_USE_PROTECTED use_flag to support secure buffer allocation
Add BO_USE_PROTECTED use_flag to allocated a secure buffer from GEM.

BUG=b:248609774
TEST="emerge-cherry libdrm minigbm" pass

Cq-Depend: chromium:4482938
Change-Id: I32acaf265a128314f59e8f46fdbbed4254b8600e
Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4145439
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
Tested-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
2023-05-02 11:16:02 +00:00
Fei Shao
eb1d691736 mediatek: Exclude MT8173's FP16 and 10-bit ABGR support
MT8173's IMG driver doesn't seem to support these texture formats, and
that causes CTS failures when we upgrade Android version to container-R.
Use an allow-list approach to exclude the formats from MT8173.

While at it, also do a minor renaming for alignment.

BUG=b:278492435
TEST=CtsGraphicsTestCases

Change-Id: Ic7ce5510f986c4cf3176b72a5f196b648387de34
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4453148
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Fei Shao <fshao@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
2023-04-21 14:16:46 +00:00
Dawn Han
84b3a09ef0 minigbm: clean up bo.handles
The multi-planar formats are being allocated into a single plane,
and the minigbm exynos backend is dropped. So we can use `handle` instead of handles as of now.

Remove some of the helper functions that calculate the number of planes.
There is no need to check if there is more than one kernel buffer per buffer object.

Added a new function `drv_gem_close` in `drv_helpers` that can be used by `drv_gem_bo_destroy` and `drv_prime_bo_import`. It can be used to clean the unused gem_handle.

Bug=b:266776512
TEST=camera and screenshot work fine after deploying the change #strongbad
TEST=camera and screenshot work fine after deploying the change #kukui-arc-r
TEST=camera and screenshot work fine after deploying the change, tested a couple of apps in the Google Play Store, and checked file `dma_buf/bufinfo` to see there's no object leaking. #guybrush

Change-Id: Ib63559504e4cb8f1a32ae90170925146613d694f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4297873
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Dawn Han <dawnhan@google.com>
2023-04-09 18:57:40 +00:00
Yiwei Zhang
8a2270e573 mediatek: refactor for readability and moving local var declare up
BUG=n/a
TEST=emerge-$BOARD minigbm

Change-Id: I517289a9abb82f9dc228320f70edc8f28aa1ec6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4373889
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dawn Han <dawnhan@google.com>
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2023-03-28 18:09:00 +00:00
Yiwei Zhang
1f491e1e6f mediatek: avoid unnecessary padding for blob buffer as well
Just use the default 64 alignment for blob. This further avoids a huge
unnecessary alloc.

BUG=b:270850022
BUG=b:242495495
TEST=things work

Change-Id: I8a9c554265749b8d690d993f04e61d15b4402dfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4368800
Reviewed-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Hsin-Yi Wang <hsinyi@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
Tested-by: Fei Shao <fshao@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2023-03-24 08:43:37 +00:00
Yiwei Zhang
8244653b11 mediatek: avoid vertical alignment for FORMAT_BLOB
HAL_PIXEL_FORMAT_BLOB gets resolved into DRM_FORMAT_R8 with height of 1.
Avoid doing any vertical alignment for this case. This format should be
exempt from the 32 vertical alignment requirement from mtk video encoder
in the kernel driver.

BUG=b:270850022
BUG=b:242495495
TEST=test and app work

Change-Id: Ic635c708597b5f5548ad95f34a81943d4cc2c801
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4364500
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2023-03-23 16:14:24 +00:00
Chia-I Wu
5ff4a55d37 drv: pass stride_align to drv_bo_from_format
drv_bo_from_format will apply stride_align to all planes.  Since we
always pass 1 for stride_align, there is no change except when the
format is DRM_FORMAT_YVU420_ANDROID.

When the format is DRM_FORMAT_YVU420_ANDROID, and when stride_align is 0
or 1, drv_bo_from_format assumes there is no hw requirement and forces
stride_align to 16.  But because we used to require stride to be aligned
to 32, there is no actual change either.

BUG=b:265746435
TEST=subset of CTS and CTS Verifier on grunt, guybrush and skyrim

Change-Id: Ia6ef89bb744c39d2baead07bc47f11b0eea96b97
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4336265
Tested-by: Chia-I Wu <olv@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dawn Han <dawnhan@google.com>
2023-03-15 05:13:37 +00:00
Dawn Han
ecbc89179e minigbm: Remove plane in bo_map
Remove the parameter to align with upstream gbm.
For some places that use the number of planes. The number is 1. The
multi-planar formats are being allocated into a single plane, and
minigbm exynos backend is dropped. So we can just set the plane
index to 0 if needed.

Fixed the format in i915.c.

Bug=b:266776512
TEST=camera works after deploying the change #strongbad
TEST=camera works after deploying the change #corsola

Change-Id: I0880917754c01b9d0f27d21f3c42d87f00a09f50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4249501
Commit-Queue: Dawn Han <dawnhan@google.com>
Tested-by: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2023-02-27 19:34:38 +00:00
Fei Shao
a375189f06 mediatek: Add MT8188G definition
To support MT8188G video pipeline.

BUG=b:256980241
TEST=emerge-geralt minigbm

Change-Id: If128d828aaae425813db283ed5aee28dcf16e753
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3998336
Tested-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
2022-11-08 17:06:15 +00:00
Fei Shao
cb639821e4 mediatek: One line per board definition
To reserve the blame history, make it easier to extend and ensure the
lines don't get too lengthy in the future.

BUG=None
TEST=emerge-geralt minigbm

Change-Id: Id176ac4b113f61472c171874884d14037591c5e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3998335
Tested-by: Fei Shao <fshao@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
2022-11-08 17:06:13 +00:00
Yiwei Zhang
6fb145be9c Revert "mediatek: ensure stride meets Android requirement for YVU420"
This reverts commit 23d5fb3e83.

Reason for revert: breaks mtk boards with img gpu

Original change's description:
> mediatek: ensure stride meets Android requirement for YVU420
>
> Android YV12 requires "c_stride = ALIGN(stride/2, 16)", and is
reflected
> in drv_bo_from_format_and_padding.
>
> BUG=b:239243515
> TEST=build
>
> Change-Id: Ifb7641f5f818f96d40af460fc9d266cd9689f48a
> Reviewed-on:
https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3919605
> Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
> Commit-Queue: Fei Shao <fshao@chromium.org>
> Reviewed-by: Ryan Neph <ryanneph@google.com>
> Tested-by: Yiwei Zhang <zzyiwei@chromium.org>

BUG=b:251373007
BUG=b:251376604
BUG=b:251377527
BUG=b:251372443
BUG=b:251035349
BUG=b:251721989
TEST=regression fixed

Change-Id: I00b8dddd40fe313cecf99468ef97cb4064322628
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3939484
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-10-08 19:00:58 +00:00
Yiwei Zhang
b2dde01e1d mediatek: ensure total size satisfy luma padding for Sigurd based GPU
BUG=b:239243515
TEST=testGLViewLargerWidthDecodeAccuracy[40]

Change-Id: I3c172a93a85c878beb10ecc6f65ed90438c85d89
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3919606
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-09-29 17:42:35 +00:00
Yiwei Zhang
23d5fb3e83 mediatek: ensure stride meets Android requirement for YVU420
Android YV12 requires "c_stride = ALIGN(stride/2, 16)", and is reflected
in drv_bo_from_format_and_padding.

BUG=b:239243515
TEST=build

Change-Id: Ifb7641f5f818f96d40af460fc9d266cd9689f48a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3919605
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-09-29 17:42:34 +00:00
Yiwei Zhang
fcc59f7d71 Revert "mediatek: temporarily workaround a gpu driver bug to unblock cts"
This reverts commit 64de5175a0.

BUG=b:239243515
TEST=build

Change-Id: Ia538be20966ac7a39fb9393672afdc0c96ec26a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3919604
Reviewed-by: Fei Shao <fshao@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
2022-09-29 17:42:32 +00:00
Yiwei Zhang
185a139697 mediatek: advertise fp16 and 10bit rgba as supported texture format
They are both supported on mt8192 and mt8195

BUG=b:245663059
BUG=b:245662197
BUG=b:245693521
TEST=cts

Change-Id: Ib372d08caadbae37501b801a2c6e2e12c37d1e20
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3884975
Tested-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
Commit-Queue: Fei Shao <fshao@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
2022-09-12 07:27:23 +00:00
Justin Green
1805193a2a platform/minigbm: Add BO_USE_TEXTURE to YUYV flags for MTK
Add BO_USE_TEXTURE to YUYV planes for Mediatek devices. This allows them
to be used as hardware overlays.

BUG=b:238137982
TEST=Tested on Asurada and Cherry

Change-Id: Ib0b6d91f64fe4e0af737594de976d5d5154e223d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3864630
Tested-by: Justin Green <greenjustin@google.com>
Commit-Queue: Justin Green <greenjustin@google.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
2022-09-02 19:03:58 +00:00
Justin Green
c9f6462456 platform/minigbm: Add YUY2 support for Mediatek
Add YUY2 (DRM_FORMAT_YUYV) support for Mediatek platforms. Mediatek
devices support YUY2 hardware overlays, which we would like to exploit
to reduce video frame latency.

BUG=b:238137982
TEST=Tested with atomictest on Asurada

Change-Id: I42937956cb1017fea5f8997dd38d591a1b0b80b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3846866
Reviewed-by: Rob Clark <robdclark@chromium.org>
Tested-by: Justin Green <greenjustin@google.com>
Commit-Queue: Justin Green <greenjustin@google.com>
2022-08-23 15:01:58 +00:00
Yiwei Zhang
64de5175a0 mediatek: temporarily workaround a gpu driver bug to unblock cts
BUG=b:231660103
BUG=b:239243515
TEST=android.media.cts.DecodeAccuracyTest#testGLViewLargerWidthDecodeAccuracy[40]

Change-Id: I3349497aa9d6952dd330fdb725116fcc6e50a918
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3824600
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
2022-08-14 07:13:34 +00:00
Yiwei Zhang
5c93742e6c mediatek: align with hardware workaround on Sigurd based GPU
BUG=b:239243515
TEST=android.media.cts.DecodeAccuracyTest#testGLViewLargerWidthDecodeAccuracy[40]

Change-Id: I7b4dcf0325e0776a2554d10898cffcc515cb8473
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3824599
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2022-08-14 07:13:33 +00:00
Jason Macnak
80f664c422 minigbm: passthrough SENSOR_DIRECT_DATA via gbm frontend
BUG=b:238609372
TEST=vts -m VtsHalSensorsV2_1TargetTest

Change-Id: I37834f80d71e453e6e29b88198efc1584c109456
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3773926
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
Tested-by: Jason Macnak <natsu@google.com>
2022-07-26 23:41:35 +00:00
Yiwei Zhang
bbe1fd3a8c minigbm: passthrough GPU_DATA_BUFFER via gbm frontend
This is required for modern Android atop a gralloc with the cross_domain
backend or other native backend.

BUG=b:238609372
TEST=build and AHB cts

Change-Id: Id963eeec62c4400cc009384e127c93588c99346e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3777566
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-21 05:37:37 +00:00
Yiwei Zhang
0495473b90 minigbm: deprecate drv_log to favor log level
TEST=build

Change-Id: I3f0021bfd05eb1ab7c3b35ae2f31d806bc0a58dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761446
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-19 04:16:15 +00:00
Hsin-Yi Wang
2581c470d6 minigbm: mediatek: check BO_USE_CAMERA_WRITE flag on camera preview case
We only want camera preview use case to use the same padding as
BO_USE_HW_VIDEO_ENCODER. Previously we check this by BO_USE_SCANOUT
flag. This would cause some format issues in CTS drm tests. This patch
updates CL:3551188 to check for BO_USE_CAMERA_WRITE flag as well.

BUG=b:227983122
TEST=check camera is normal on kukui
TEST=android.media.cts.MediaDrmClearkeyTest#* pass on kukui

Change-Id: I1606b677678dfafc6331713f67d327a2b6030394
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3574581
Tested-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Reviewed-by: Miguel Casas <mcasas@google.com>
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Tested-by: Kazuhiro Inaba <kinaba@chromium.org>
Commit-Queue: Hsin-Yi Wang <hsinyi@chromium.org>
2022-04-08 09:24:14 +00:00
Hsin-Yi Wang
d4df3d57eb minigbm: mediatek: remove USE_SCANOUT in yuv format
minigbm clients use the SCANOUT flag whenever they want the
minigbm-allocated buffers to be promoted to overlays. Mediatek doesn't
support YUV overlays, so remove the SCANOUT flag.

BUG=b:224698291
TEST=emerge on elm, emerge and deploy on kukui/jacuzzi

Change-Id: If3ee2fb925c7e729269c31caab991bb0bc56b0de
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3555233
Tested-by: Hsin-Yi Wang <hsinyi@chromium.org>
Feels: Hsin-Yi Wang <hsinyi@chromium.org>
Auto-Submit: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Miguel Casas <mcasas@google.com>
Commit-Queue: Hsin-Yi Wang <hsinyi@chromium.org>
2022-04-02 09:27:02 +00:00
Hsin-Yi Wang
c37de98240 minigbm: mediatek: use the HW_VIDEO_ENCODE padding for camera preview
Since CL:3515652, preview under photo mode no longer uses hw video
encoder. This results in the wrong padding set in minigbm. Make camera
preview mode to use the original padding by detecting the
GRALLOC_USAGE_HW_COMPOSER (BO_USE_SCANOUT) flag.

BUG=b:224698291
TEST=check camera preview on krane

Change-Id: I299886a8f2106678f19ffff308331afec9627614
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3551188
Tested-by: Hsin-Yi Wang <hsinyi@chromium.org>
Auto-Submit: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Reviewed-by: Miguel Casas <mcasas@google.com>
Commit-Queue: Hsin-Yi Wang <hsinyi@chromium.org>
2022-03-31 11:34:43 +00:00
Miguel Casas
35fd7d23bb mediatek.c: Don't use 64-stride alignment for video on 8173 (hana)
Video buffers are forced to use 64 alignment because of some nebulous
argument around better cache performance (b/35560932, it was mostly
about kevin and somehow hana got bundled in).

On Mediatek, however, video decoder and image processor use 16-
alignment (like macroblocks), forcing the use of the image processor
to reconcile these two, negating any performance/cache improvements.

This CL changes that to only use 64-alignment to non-YUV (hence,
video) quads, and this only for Hana.

BUG=b:220175010
TEST=video.DecodeAccel.* on hana

Change-Id: I48ee1beac29f915734830eda64705a2b4827a901
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3475099
Tested-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Tested-by: Miguel Casas <mcasas@google.com>
Reviewed-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Miguel Casas <mcasas@google.com>
Commit-Queue: Miguel Casas <mcasas@google.com>
2022-02-23 17:13:37 +00:00
Hsin-Yi Wang
8fe9f19018 minigbm/mediatek: allocate NV12 video buffers for MT8186
BUG=b:214886582
TEST=emerge-corsola minigbm

Change-Id: Ic1f4e153c4c32050de86abe8827ad5f246f7fd3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3398070
Tested-by: Hsin-Yi Wang <hsinyi@chromium.org>
Auto-Submit: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Reviewed-by: Miguel Casas <mcasas@google.com>
Commit-Queue: Hsin-Yi Wang <hsinyi@chromium.org>
2022-01-25 04:36:56 +00:00
Yiwei Zhang
f4c1725d38 mediatek: support fp16 and 10bit rgba formats
These are VIRGL_BIND_SAMPLER_VIEW compatible formats checked by vrend.
So virtgpu advertises texture support for them correspondingly. When it
comes to host gbm allocation, minigbm failed because of no support,
which breaks the api contract. Advertising them for mt8183 fixes it.

BUG=b:204633833
TEST=dEQP-VK.api.external.memory.android_hardware_buffer.*

Change-Id: I2429f2f5ac04b8193ac3505774deba224f464d92
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3253838
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-11-02 06:05:03 +00:00
Yiwei Zhang
3a171db9be gralloc: move the logic to strip BO_USE_HW_VIDEO_ENCODER to the backends
BUG=b:199524294
TEST=CQ

Change-Id: I2b36a0ef17cd6ecb77723d4a9d95196ad27ff4ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3200148
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
2021-10-05 11:05:13 +00:00
Yiwei Zhang
b3caf22272 mediatek: strip scanout on resolved YVU420 format
If the FLEX_YCbCr_420_888 format gets resolved into YVU420, the backend
must strip scanout to satisfy the format support.

BUG=b:201686603
TEST=gralloctest alloc_combinations

Change-Id: I9206cb4d695b9a7eb052d2bbf2ea1032d706abb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3198681
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-05 03:43:19 +00:00
Yiwei Zhang
b8ad7b88ca minigbm: refactor to add unified resolve_format_and_use_flags helper
It makes more sense to resovle the format and use_flags together to
avoid duplicates.

Add the helper to vc4 and dumb_driver backends since that's missed
from prior frontend refactoring.

Split the resolve helper in virtgpu_virgl for the 3d and 2d paths to
make code logic cleaner.

BUG=b:199524294
TEST=CQ

Change-Id: I89b633ea484f0fc5bb9b4e0548cad017b9970cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3200143
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-05 03:43:18 +00:00