From 481b7f0468b3f5928f8f0fc6aa21e4836fb3f3c5 Mon Sep 17 00:00:00 2001 From: Chris Dimich Date: Mon, 9 Jan 2023 10:52:50 -0800 Subject: chromium-ozone-wayland: add bbappend and patches as per NXP 5.15.71_2.2.0 rel Changes include: - support on i.MX 8 series platform. - 8MM/8MP/8MQ support h264/hevc/vp8/vp9 hardware decoding. - 8QM/8QXP support h264/hevc/vp8 hardware decoding. - support seek, playrate change and resolution change. - support video acceleration for online media platform such as Youtube, bilibili. Signed-off-by: Chris Dimich (cherry picked from commit 23bdb51b7858db363e56f7748f5523d44f78ac98) --- ...VDA-Use-dlopen-to-dynamically-use-g2d-api.patch | 306 +++++++++++++++++++++ 1 file changed, 306 insertions(+) create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch (limited to 'dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch') diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch new file mode 100644 index 00000000..7cd0b852 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch @@ -0,0 +1,306 @@ +From 59bf28174104b591088a08e2ed61644cc93101fd Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Thu, 22 Sep 2022 11:10:46 +0800 +Subject: [PATCH] V4L2VDA: Use dlopen to dynamically use g2d api + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/BUILD.gn | 1 - + media/gpu/v4l2/v4l2_device.cc | 205 ++++++++++++++++++++++++++++++++-- + 2 files changed, 194 insertions(+), 12 deletions(-) + +diff --git a/media/gpu/v4l2/BUILD.gn b/media/gpu/v4l2/BUILD.gn +index 273f6066de175..ebd0a4ad64646 100644 +--- a/media/gpu/v4l2/BUILD.gn ++++ b/media/gpu/v4l2/BUILD.gn +@@ -86,7 +86,6 @@ source_set("v4l2") { + "EGL", + "GLESv2", + ] +- libs += [ "g2d" ] + + if (use_v4l2_codec_aml) { + sources += [ +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index 42cd8386f41cb..af71f54d141aa 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -40,10 +40,12 @@ + #include "media/gpu/v4l2/aml_v4l2_device.h" + #endif + +-#include "g2d.h" +-#include "g2dExt.h" ++// #include "g2d.h" ++// #include "g2dExt.h" ++ + #include + #include ++#include + + namespace media { + +@@ -142,6 +144,158 @@ void V4L2ProcessingTrace(const struct v4l2_buffer* v4l2_buffer, bool start) { + + } // namespace + ++/* g2d.h g2dExt.h */ ++enum g2d_format ++{ ++//rgb formats ++ G2D_RGB565 = 0, /* [0:4] Blue; [5:10] Green; [11:15] Red */ ++ G2D_RGBA8888 = 1, /* [0:7] Red; [8:15] Green; [16:23] Blue; [23:31] Alpha */ ++ G2D_RGBX8888 = 2, /* [0:7] Red; [8:15] Green; [16:23] Blue; [23:31] don't care */ ++ G2D_BGRA8888 = 3, /* [0:7] Blue; [8:15] Green; [16:23] Red; [23:31] Alpha */ ++ G2D_BGRX8888 = 4, /* [0:7] Blue; [8:15] Green; [16:23] Red; [23:31] don't care */ ++ G2D_BGR565 = 5, /* [0:4] Red; [5:10] Green; [11:15] Blue */ ++ ++ G2D_ARGB8888 = 6, /* [0:7] Alpha; [8:15] Red; [16:23] Green; [23:31] Blue */ ++ G2D_ABGR8888 = 7, /* [0:7] Alpha; [8:15] Blue; [16:23] Green; [23:31] Red */ ++ G2D_XRGB8888 = 8, /* [0:7] don't care; [8:15] Red; [16:23] Green; [23:31] Blue */ ++ G2D_XBGR8888 = 9, /* [0:7] don't care; [8:15] Blue; [16:23] Green; [23:31] Red */ ++ G2D_RGB888 = 10, /* [0:7] Red; [8:15] Green; [16:23] Blue */ ++ G2D_BGR888 = 11, /* [0:7] Blue; [8:15] Green; [16:23] Red */ ++ ++ G2D_RGBA5551 = 12, /* [0:4] Red; [5:9] Green; [10:14] Blue; [15] Alpha */ ++ G2D_RGBX5551 = 13, /* [0:4] Red; [5:9] Green; [10:14] Blue; [15] don't care */ ++ G2D_BGRA5551 = 14, /* [0:4] Blue; [5:9] Green; [10:14] Red; [15] Alpha */ ++ G2D_BGRX5551 = 15, /* [0:4] Blue; [5:9] Green; [10:14] Red; [15] don't care */ ++ ++//yuv formats ++ G2D_NV12 = 20, /* 2 plane 420 format; plane 1: [0:7] Y ; plane 2: [0:7] U; [8:15] V */ ++ G2D_I420 = 21, /* 3 plane 420 format; plane 1: [0:7] Y ; plane 2: [0:7] U; plane 3: [0:7] V */ ++ G2D_YV12 = 22, /* 3 plane 420 format; plane 1: [0:7] Y ; plane 2: [0:7] V; plane 3: [0:7] U */ ++ G2D_NV21 = 23, /* 2 plane 420 format; plane 1: [0:7] Y ; plane 2: [0:7] V; [8:15] U */ ++ G2D_YUYV = 24, /* 1 plane 422 format; [0:7] Y; [8:15; U; [16:23] Y; [24:31] V */ ++ G2D_YVYU = 25, /* 1 plane 422 format; [0:7] Y; [8:15; V; [16:23] Y; [24:31] U */ ++ G2D_UYVY = 26, /* 1 plane 422 format; [0:7] U; [8:15; Y; [16:23] V; [24:31] Y */ ++ G2D_VYUY = 27, /* 1 plane 422 format; [0:7] V; [8:15; Y; [16:23] U; [24:31] Y */ ++ G2D_NV16 = 28, /* 2 plane 422 format; plane 1: [0:7] Y ; plane 2: [0:7] U; [8:15] V */ ++ G2D_NV61 = 29, /* 2 plane 422 format; plane 1: [0:7] Y ; plane 2: [0:7] V; [8:15] U */ ++}; ++ ++enum g2d_tiling ++{ ++ G2D_LINEAR = 0x1, ++ G2D_TILED = 0x2, ++ G2D_SUPERTILED = 0x4, ++ G2D_AMPHION_TILED = 0x8, ++ G2D_AMPHION_INTERLACED = 0x10, ++ G2D_TILED_STATUS = 0x20, ++ G2D_AMPHION_TILED_10BIT = 0x40, ++}; ++ ++struct g2d_tile_status ++{ ++ unsigned int ts_addr; ++ ++ unsigned int fc_enabled; ++ unsigned int fc_value; ++ unsigned int fc_value_upper; ++}; ++ ++struct g2d_buf ++{ ++ void *buf_handle; ++ void *buf_vaddr; ++ int buf_paddr; ++ int buf_size; ++}; ++ ++enum g2d_blend_func ++{ ++//basic blend ++ G2D_ZERO = 0, ++ G2D_ONE = 1, ++ G2D_SRC_ALPHA = 2, ++ G2D_ONE_MINUS_SRC_ALPHA = 3, ++ G2D_DST_ALPHA = 4, ++ G2D_ONE_MINUS_DST_ALPHA = 5, ++ ++// extensive blend is set with basic blend together, ++// such as, G2D_ONE | G2D_PRE_MULTIPLIED_ALPHA ++ G2D_PRE_MULTIPLIED_ALPHA = 0x10, ++ G2D_DEMULTIPLY_OUT_ALPHA = 0x20, ++}; ++ ++enum g2d_rotation ++{ ++ G2D_ROTATION_0 = 0, ++ G2D_ROTATION_90 = 1, ++ G2D_ROTATION_180 = 2, ++ G2D_ROTATION_270 = 3, ++ G2D_FLIP_H = 4, ++ G2D_FLIP_V = 5, ++}; ++ ++struct g2d_surface ++{ ++ enum g2d_format format; ++ ++ int planes[3];//surface buffer addresses are set in physical planes separately ++ //RGB: planes[0] - RGB565/RGBA8888/RGBX8888/BGRA8888/BRGX8888 ++ //NV12: planes[0] - Y, planes[1] - packed UV ++ //I420: planes[0] - Y, planes[1] - U, planes[2] - V ++ //YV12: planes[0] - Y, planes[1] - V, planes[2] - U ++ //NV21: planes[0] - Y, planes[1] - packed VU ++ //YUYV: planes[0] - packed YUYV ++ //YVYU: planes[0] - packed YVYU ++ //UYVY: planes[0] - packed UYVY ++ //VYUY: planes[0] - packed VYUY ++ //NV16: planes[0] - Y, planes[1] - packed UV ++ //NV61: planes[0] - Y, planes[1] - packed VU ++ ++ //blit rectangle in surface ++ int left; ++ int top; ++ int right; ++ int bottom; ++ int stride; ///< buffer stride, in Pixels ++ int width; ///< surface width, in Pixels ++ int height; ///< surface height, in Pixels ++ enum g2d_blend_func blendfunc; ///< alpha blending parameters ++ int global_alpha; ///< value is 0 ~ 255 ++ //clrcolor format is RGBA8888, used as dst for clear, as src for blend dim ++ int clrcolor; ++ ++ //rotation degree ++ enum g2d_rotation rot; ++}; ++ ++struct g2d_surfaceEx ++{ ++ struct g2d_surface base; ++ enum g2d_tiling tiling; ++ ++ struct g2d_tile_status ts; ++ int reserved[8]; ++}; ++ ++void *dl_handle = NULL; ++ ++typedef int (*g2d_api_open)(void **handle); ++typedef int (*g2d_api_close)(void *handle); ++typedef int (*g2d_api_free)(struct g2d_buf *buf); ++typedef struct g2d_buf* (*g2d_api_alloc)(int size, int cacheable); ++typedef int (*g2d_api_buf_export_fd)(struct g2d_buf *); ++typedef int (*g2d_api_blitEx)(void *handle, struct g2d_surfaceEx *srcEx, struct g2d_surfaceEx *dstEx); ++ ++#define G2D_API_SYM(name) g2d_api_##name g2d_##name = nullptr ++G2D_API_SYM(open); ++G2D_API_SYM(close); ++G2D_API_SYM(free); ++G2D_API_SYM(alloc); ++G2D_API_SYM(buf_export_fd); ++G2D_API_SYM(blitEx); ++#undef G2D_API_SYM ++/* g2d.h g2dExt.h */ ++ + V4L2ExtCtrl::V4L2ExtCtrl(uint32_t id) { + memset(&ctrl, 0, sizeof(ctrl)); + ctrl.id = id; +@@ -261,7 +415,7 @@ V4L2Buffer::~V4L2Buffer() { + } + } + } +- if(g2dbuf_p0 && g2dbuf_p1) { ++ if(g2d_free && g2dbuf_p0 && g2dbuf_p1) { + g2d_free(g2dbuf_p0); + g2d_free(g2dbuf_p1); + } +@@ -399,14 +553,18 @@ scoped_refptr V4L2Buffer::CreateVideoFrame() { + else + phys_1 = query1.phys; + +- g2dbuf_p0 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height, 0); +- g2dbuf_p1 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height / 2, 0); ++ if (g2d_alloc) { ++ g2dbuf_p0 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height, 0); ++ g2dbuf_p1 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height / 2, 0); ++ } + if((!g2dbuf_p0) || (!g2dbuf_p1)){ + DLOG(ERROR)<<"g2d buf alloc failed"; + return nullptr; + } + +- int tmpfd = g2d_buf_export_fd(g2dbuf_p0); ++ int tmpfd = -1; ++ if (g2d_buf_export_fd) ++ tmpfd = g2d_buf_export_fd(g2dbuf_p0); + tmpfd = dup(tmpfd); + if(tmpfd > 0) + g2dbufs_fds.push_back(base::ScopedFD(tmpfd)); +@@ -416,7 +574,8 @@ scoped_refptr V4L2Buffer::CreateVideoFrame() { + return nullptr; + } + +- tmpfd = g2d_buf_export_fd(g2dbuf_p1); ++ if (g2d_buf_export_fd) ++ tmpfd = g2d_buf_export_fd(g2dbuf_p1); + tmpfd = dup(tmpfd); + if(tmpfd>0) + g2dbufs_fds.push_back(base::ScopedFD(tmpfd)); +@@ -1152,7 +1311,7 @@ V4L2Queue::V4L2Queue(scoped_refptr dev, + #endif + + g2d_handle = NULL; +- if(g2d_open(&g2d_handle)) ++ if(g2d_open && g2d_open(&g2d_handle)) + VLOGF(1) << "g2d_open fail"; + } + +@@ -1172,7 +1331,7 @@ V4L2Queue::~V4L2Queue() { + DeallocateBuffers(); + } + +- if(g2d_handle) ++ if(g2d_close && g2d_handle) + g2d_close(g2d_handle); + + std::move(destroy_cb_).Run(); +@@ -1573,7 +1732,8 @@ std::pair V4L2Queue::DequeueBuffer() { + src->global_alpha = 0xff; + src->blendfunc = G2D_ONE; + +- g2d_blitEx(g2d_handle, &srcEx, &dstEx); ++ if (g2d_blitEx) ++ g2d_blitEx(g2d_handle, &srcEx, &dstEx); + } + + return std::make_pair(true, V4L2BufferRefFactory::CreateReadableRef( +@@ -1747,8 +1907,31 @@ scoped_refptr V4L2Device::Create() { + #endif + + device = new GenericV4L2Device(); +- if (device->Initialize()) ++ if (device->Initialize()) { ++ dl_handle = dlopen("/usr/lib/libg2d.so", ++ RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE | RTLD_LAZY); ++ if (!dl_handle) { ++ VLOGF(1) << "Has no libg2d.so"; ++ return device; ++ } ++ ++#define G2D_API_DLSYM(lib, name) \ ++ do { \ ++ g2d_##name = reinterpret_cast(dlsym(lib, "g2d_" #name)); \ ++ if (!(g2d_##name)) \ ++ VLOGF(1) << "Failed to dlsym g2d_" #name; \ ++ } while (0) ++ ++ G2D_API_DLSYM(dl_handle, open); ++ G2D_API_DLSYM(dl_handle, close); ++ G2D_API_DLSYM(dl_handle, free); ++ G2D_API_DLSYM(dl_handle, alloc); ++ G2D_API_DLSYM(dl_handle, buf_export_fd); ++ G2D_API_DLSYM(dl_handle, blitEx); ++ + return device; ++ } ++ + + VLOGF(1) << "Failed to create a V4L2Device"; + return nullptr; +-- +2.17.1 + -- cgit v1.2.3-54-g00ecf