replace common qcom sources with samsung ones
This commit is contained in:
52
qcom/opensource/display/libgbm/Makefile.am
Normal file
52
qcom/opensource/display/libgbm/Makefile.am
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
AM_CFLAGS = -Wundef -Wstrict-prototypes -Wno-trigraphs -std=c++11
|
||||
AM_CFLAGS+= -I./inc -I$(WORKSPACE)/vendor/qcom/opensource/commonsys-intf/display/include
|
||||
AM_CFLAGS+= -DGBM_DEBUG -DALLOCATE_SURFACE_BO_AT_CREATION -DBUILD_HAS_WAYLAND_SUPPORT -DVENUS_COLOR_FORMAT
|
||||
|
||||
AM_CPPFLAGS = -Wundef -Wstrict-prototypes -Wno-trigraphs -std=c++11
|
||||
AM_CPPFLAGS+= -I./inc -I$(WORKSPACE)/vendor/qcom/opensource/commonsys-intf/display/include
|
||||
AM_CPPFLAGS+= -DGBM_DEBUG -DALLOCATE_SURFACE_BO_AT_CREATION -DBUILD_HAS_WAYLAND_SUPPORT -DVENUS_COLOR_FORMAT
|
||||
|
||||
if IS_QRBX210
|
||||
AM_CFLAGS += -DENABLE_CAM_MIMAS
|
||||
AM_CPPFLAGS += -DENABLE_CAM_MIMAS
|
||||
endif
|
||||
|
||||
if IS_QCS610
|
||||
AM_CFLAGS += -DENABLE_CAM_NV12_128
|
||||
AM_CPPFLAGS += -DENABLE_CAM_NV12_128
|
||||
endif
|
||||
|
||||
if ENABLE_COMPILEWITHDRM
|
||||
AM_CFLAGS += -DENABLE_DRM
|
||||
AM_CPPFLAGS += -DENABLE_DRM
|
||||
else
|
||||
AM_CFLAGS += -DENABLE_FB
|
||||
AM_CPPFLAGS += -DENABLE_FB
|
||||
endif
|
||||
|
||||
lib_LTLIBRARIES = libgbm.la
|
||||
libgbm_la_CFLAGS = $(AM_CFLAGS)
|
||||
libgbm_la_CPPFLAGS = $(AM_CFLAGS)
|
||||
libgbm_la_LDFLAGS = -shared -avoid-version -lm -ldl -lwayland-server -lwayland-client
|
||||
libgbm_la_SOURCES = src/gbm.c \
|
||||
src/msmgbm_camera.c \
|
||||
src/msmgbm_video.c \
|
||||
src/msmgbm_common.c \
|
||||
src/msmgbm_platform_wrapper.cpp \
|
||||
src/msmgbm_adreno_utils.cpp \
|
||||
src/msmgbm_mapper.cpp
|
||||
|
||||
if ENABLE_COMPILEWITHDRM
|
||||
libgbm_la_SOURCES += src/msmgbm.c
|
||||
else
|
||||
libgbm_la_SOURCES += src/msmgbm_fb.c
|
||||
endif
|
||||
|
||||
bin_PROGRAMS = gbmtest
|
||||
gbmtest_SOURCES = test/gbmtest.c
|
||||
gbmtest_LDADD = libgbm.la
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = gbm.pc
|
||||
EXTRA_DIST = $(pkgconfig_DATA)
|
78
qcom/opensource/display/libgbm/NOTICE
Normal file
78
qcom/opensource/display/libgbm/NOTICE
Normal file
@@ -0,0 +1,78 @@
|
||||
Copyright (c) 2021 The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
________________________________________
|
||||
|
||||
/*
|
||||
* Copyright © 2011 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Benjamin Franzke <benjaminfranzke@googlemail.com>
|
||||
*/
|
||||
|
||||
________________________________________
|
||||
/*
|
||||
* Copyright 2014 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
________________________________________
|
||||
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
________________________________________
|
147
qcom/opensource/display/libgbm/configure.ac
Normal file
147
qcom/opensource/display/libgbm/configure.ac
Normal file
@@ -0,0 +1,147 @@
|
||||
# Copyright (c) 2021 The Linux Foundation. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of The Linux Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
|
||||
AC_INIT([libgbm],
|
||||
20.1.0,
|
||||
[],
|
||||
libgbm)
|
||||
|
||||
AM_INIT_AUTOMAKE([-Wall -Wno-error foreign subdir-objects])
|
||||
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||
LT_INIT
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
|
||||
AC_ARG_WITH([glib],
|
||||
AC_HELP_STRING([--with-glib],
|
||||
[enable glib, building HLOS systems which use glib]))
|
||||
|
||||
if (test "x${with_glib}" = "xyes"); then
|
||||
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
|
||||
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
|
||||
AC_MSG_ERROR(GThread >= 2.16 is required))
|
||||
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
|
||||
AC_MSG_ERROR(GLib >= 2.16 is required))
|
||||
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
|
||||
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
|
||||
|
||||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
fi
|
||||
|
||||
if test "x${with_glib}" = "xyes"; then
|
||||
CFLAGS="$CFLAGS -I$GLIB_CFLAGS -DUSE_GLIB"
|
||||
LDFLAGS="$LDFLAGS -lglib-2.0"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([core_includes],
|
||||
AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],
|
||||
[Specify the location of the core headers]),
|
||||
[core_incdir=$withval],
|
||||
with_core_includes=no)
|
||||
|
||||
if test "x$with_core_includes" != "xno"; then
|
||||
CFLAGS="${CFLAGS} -I${core_incdir}"
|
||||
fi
|
||||
|
||||
#pkgconfigdir=${libdir}/pkgconfig
|
||||
#AC_SUBST(pkgconfigdir)
|
||||
|
||||
AC_ARG_WITH(sanitized-headers,
|
||||
AS_HELP_STRING([--with-sanitized-headers=DIR],
|
||||
[Specify the location of the sanitized Linux headers]),
|
||||
[CPPFLAGS="$CPPFLAGS -I$withval"])
|
||||
|
||||
AC_ARG_ENABLE([compilewithdrm],
|
||||
AC_HELP_STRING([--enable-compilewithdrm],
|
||||
[enable compilewithdrm, build gbm with compilewithdrm]),
|
||||
[enable_compilewithdrm="${enableval}"],
|
||||
enable_compilewithdrm=no)
|
||||
AM_CONDITIONAL([ENABLE_COMPILEWITHDRM], [test "x${enable_compilewithdrm}" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE([wayland-support],
|
||||
AC_HELP_STRING([--enable-wayland-support],
|
||||
[with wayland support, build gbm with wayland-support]),
|
||||
[enable_waylandsupport="${enableval}"],
|
||||
enable_waylandsupport=no)
|
||||
AM_CONDITIONAL(BUILD_HAS_WAYLAND_SUPPORT, test "x${enable_waylandsupport}" = "xyes")
|
||||
if test "x${enable_waylandsupport}" = "xyes"; then
|
||||
AC_DEFINE(BUILD_HAS_WAYLAND_SUPPORT, 1, [Enable when build has wayland support])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([target-qrbx210],
|
||||
AC_HELP_STRING([--enable-target-qrbx210],
|
||||
[Enable conditional compile for target qrbx210]),
|
||||
[target_qrbx210="${enableval}"],
|
||||
target_qrbx210=no)
|
||||
AM_CONDITIONAL([IS_QRBX210], [test "x$target_qrbx210" = xyes])
|
||||
|
||||
AC_ARG_ENABLE([target-qcs610],
|
||||
AC_HELP_STRING([--enable-target-qcs610],
|
||||
[Enable conditional compile for target qcs610]),
|
||||
[target_qcs610="${enableval}"],
|
||||
target_qcs610=no)
|
||||
AM_CONDITIONAL([IS_QCS610], [test "x$target_qcs610" = xyes])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_AWK
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
#PKG_CHECK_MODULES(LIBDRM, [libdrm])
|
||||
|
||||
ALLOCATE_SURFACE_BO_AT_CREATION=yes
|
||||
|
||||
AM_CONDITIONAL(ALLOCATE_SURFACE_BO_AT_CREATION, test $ALLOCATE_SURFACE_BO_AT_CREATION = yes)
|
||||
|
||||
if test $ALLOCATE_SURFACE_BO_AT_CREATION = yes; then
|
||||
AC_DEFINE(ALLOCATE_SURFACE_BO_AT_CREATION, 1, [Enable surface's BO creation at surface creation time])
|
||||
fi
|
||||
|
||||
|
||||
AC_CONFIG_FILES([ \
|
||||
Makefile \
|
||||
gbm.pc
|
||||
])
|
||||
|
||||
AC_SUBST([CFLAGS])
|
||||
AC_SUBST([CPPFLAGS])
|
||||
AC_SUBST([LIBS])
|
||||
|
||||
AC_OUTPUT
|
||||
#AC_OUTPUT([Makefile src/Makefile])
|
10
qcom/opensource/display/libgbm/gbm.pc.in
Normal file
10
qcom/opensource/display/libgbm/gbm.pc.in
Normal file
@@ -0,0 +1,10 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: libgbm
|
||||
Description: Userspace interface to kernel ION Memory services
|
||||
Version: @PACKAGE_VERSION@
|
||||
Libs: -L${libdir} -lgbm
|
||||
Cflags: -I${includedir}
|
450
qcom/opensource/display/libgbm/inc/gbm.h
Normal file
450
qcom/opensource/display/libgbm/inc/gbm.h
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Not a Contribution.
|
||||
*
|
||||
* Copyright (c) 2017, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright © 2011 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Benjamin Franzke <benjaminfranzke@googlemail.com>
|
||||
*/
|
||||
|
||||
#ifndef _GBM_H_
|
||||
#define _GBM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define __GBM__ 1
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* \file gbm.h
|
||||
* \brief Generic Buffer Manager
|
||||
*/
|
||||
|
||||
struct gbm_device;
|
||||
struct gbm_bo;
|
||||
struct gbm_surface;
|
||||
|
||||
/**
|
||||
* \mainpage The Generic Buffer Manager
|
||||
*
|
||||
* This module provides an abstraction that the caller can use to request a
|
||||
* buffer from the underlying memory management system for the platform.
|
||||
*
|
||||
* This allows the creation of portable code whilst still allowing access to
|
||||
* the underlying memory manager.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstraction representing the handle to a buffer allocated by the
|
||||
* manager
|
||||
*/
|
||||
union gbm_bo_handle {
|
||||
void *ptr;
|
||||
int32_t s32;
|
||||
uint32_t u32;
|
||||
int64_t s64;
|
||||
uint64_t u64;
|
||||
};
|
||||
|
||||
/** Format of the allocated buffer */
|
||||
enum gbm_bo_format {
|
||||
/** RGB with 8 bits per channel in a 32 bit value */
|
||||
GBM_BO_FORMAT_XRGB8888,
|
||||
/** ARGB with 8 bits per channel in a 32 bit value */
|
||||
GBM_BO_FORMAT_ARGB8888
|
||||
};
|
||||
|
||||
#define __gbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
|
||||
((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
|
||||
|
||||
#define GBM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */
|
||||
|
||||
/* color index */
|
||||
#define GBM_FORMAT_C8 __gbm_fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
|
||||
|
||||
/* 8 bpp Red */
|
||||
#define GBM_FORMAT_R8 __gbm_fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
|
||||
|
||||
/* 16 bpp Red */
|
||||
#define GBM_FORMAT_R16 __gbm_fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */
|
||||
|
||||
/* 16 bpp RG */
|
||||
#define GBM_FORMAT_RG88 __gbm_fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */
|
||||
|
||||
/* 32 bpp RG */
|
||||
#define GBM_FORMAT_RG1616 __gbm_fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */
|
||||
|
||||
/* 8 bpp RGB */
|
||||
#define GBM_FORMAT_RGB332 __gbm_fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */
|
||||
#define GBM_FORMAT_BGR233 __gbm_fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */
|
||||
|
||||
/* 16 bpp RGB */
|
||||
#define GBM_FORMAT_XRGB4444 __gbm_fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_XBGR4444 __gbm_fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_RGBX4444 __gbm_fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_BGRX4444 __gbm_fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */
|
||||
|
||||
#define GBM_FORMAT_ARGB4444 __gbm_fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_ABGR4444 __gbm_fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_RGBA4444 __gbm_fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_BGRA4444 __gbm_fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */
|
||||
|
||||
#define GBM_FORMAT_XRGB1555 __gbm_fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */
|
||||
#define GBM_FORMAT_XBGR1555 __gbm_fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */
|
||||
#define GBM_FORMAT_RGBX5551 __gbm_fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */
|
||||
#define GBM_FORMAT_BGRX5551 __gbm_fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */
|
||||
|
||||
#define GBM_FORMAT_ARGB1555 __gbm_fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */
|
||||
#define GBM_FORMAT_ABGR1555 __gbm_fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */
|
||||
#define GBM_FORMAT_RGBA5551 __gbm_fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */
|
||||
#define GBM_FORMAT_BGRA5551 __gbm_fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */
|
||||
|
||||
#define GBM_FORMAT_RGB565 __gbm_fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */
|
||||
#define GBM_FORMAT_BGR565 __gbm_fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */
|
||||
|
||||
/* 24 bpp RGB */
|
||||
#define GBM_FORMAT_RGB888 __gbm_fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */
|
||||
#define GBM_FORMAT_BGR888 __gbm_fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */
|
||||
|
||||
/* 32 bpp RGB */
|
||||
#define GBM_FORMAT_XRGB8888 __gbm_fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_XBGR8888 __gbm_fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_RGBX8888 __gbm_fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_BGRX8888 __gbm_fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */
|
||||
|
||||
#define GBM_FORMAT_ARGB8888 __gbm_fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_ABGR8888 __gbm_fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_RGBA8888 __gbm_fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_BGRA8888 __gbm_fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */
|
||||
|
||||
#define GBM_FORMAT_XRGB2101010 __gbm_fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */
|
||||
#define GBM_FORMAT_XBGR2101010 __gbm_fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */
|
||||
#define GBM_FORMAT_RGBX1010102 __gbm_fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */
|
||||
#define GBM_FORMAT_BGRX1010102 __gbm_fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */
|
||||
|
||||
#define GBM_FORMAT_ARGB2101010 __gbm_fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */
|
||||
#define GBM_FORMAT_ABGR2101010 __gbm_fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */
|
||||
#define GBM_FORMAT_RGBA1010102 __gbm_fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */
|
||||
#define GBM_FORMAT_BGRA1010102 __gbm_fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */
|
||||
|
||||
/* packed YCbCr */
|
||||
#define GBM_FORMAT_YUYV __gbm_fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_YVYU __gbm_fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_UYVY __gbm_fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_VYUY __gbm_fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
|
||||
|
||||
#define GBM_FORMAT_AYUV __gbm_fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
|
||||
|
||||
/*
|
||||
* 2 plane YCbCr
|
||||
* index 0 = Y plane, [7:0] Y
|
||||
* index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
|
||||
* or
|
||||
* index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
|
||||
*/
|
||||
#define GBM_FORMAT_NV12 __gbm_fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */
|
||||
#define GBM_FORMAT_NV21 __gbm_fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */
|
||||
#define GBM_FORMAT_NV16 __gbm_fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */
|
||||
#define GBM_FORMAT_NV61 __gbm_fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */
|
||||
|
||||
/*
|
||||
* 3 plane YCbCr
|
||||
* index 0: Y plane, [7:0] Y
|
||||
* index 1: Cb plane, [7:0] Cb
|
||||
* index 2: Cr plane, [7:0] Cr
|
||||
* or
|
||||
* index 1: Cr plane, [7:0] Cr
|
||||
* index 2: Cb plane, [7:0] Cb
|
||||
*/
|
||||
#define GBM_FORMAT_YUV410 __gbm_fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU410 __gbm_fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */
|
||||
#define GBM_FORMAT_YUV411 __gbm_fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU411 __gbm_fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */
|
||||
#define GBM_FORMAT_YUV420 __gbm_fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU420 __gbm_fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */
|
||||
#define GBM_FORMAT_YUV422 __gbm_fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU422 __gbm_fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */
|
||||
#define GBM_FORMAT_YUV444 __gbm_fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU444 __gbm_fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
|
||||
|
||||
struct gbm_format_name_desc {
|
||||
char name[5];
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags to indicate the intended use for the buffer - these are passed into
|
||||
* gbm_bo_create(). The caller must set the union of all the flags that are
|
||||
* appropriate
|
||||
*
|
||||
* \sa Use gbm_device_is_format_supported() to check if the combination of format
|
||||
* and use flags are supported
|
||||
*/
|
||||
enum gbm_bo_flags {
|
||||
/**
|
||||
* Buffer is going to be presented to the screen using an API such as KMS
|
||||
*/
|
||||
GBM_BO_USE_SCANOUT = (1 << 0),
|
||||
/**
|
||||
* Buffer is going to be used as cursor
|
||||
*/
|
||||
GBM_BO_USE_CURSOR = (1 << 1),
|
||||
/**
|
||||
* Deprecated
|
||||
*/
|
||||
GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR,
|
||||
/**
|
||||
* Buffer is to be used for rendering - for example it is going to be used
|
||||
* as the storage for a color buffer
|
||||
*/
|
||||
GBM_BO_USE_RENDERING = (1 << 2),
|
||||
/**
|
||||
* Buffer can be used for gbm_bo_write. This is guaranteed to work
|
||||
* with GBM_BO_USE_CURSOR. but may not work for other combinations.
|
||||
*/
|
||||
GBM_BO_USE_WRITE = (1 << 3),
|
||||
/**
|
||||
* Buffer is linear, i.e. not tiled.
|
||||
*/
|
||||
GBM_BO_USE_LINEAR = (1 << 4),
|
||||
};
|
||||
|
||||
int
|
||||
gbm_device_get_fd(struct gbm_device *gbm);
|
||||
|
||||
const char *
|
||||
gbm_device_get_backend_name(struct gbm_device *gbm);
|
||||
|
||||
int
|
||||
gbm_device_is_format_supported(struct gbm_device *gbm,
|
||||
uint32_t format, uint32_t usage);
|
||||
|
||||
int
|
||||
gbm_device_get_format_modifier_plane_count(struct gbm_device *gbm,
|
||||
uint32_t format,
|
||||
uint64_t modifier);
|
||||
|
||||
void
|
||||
gbm_device_destroy(struct gbm_device *gbm);
|
||||
|
||||
struct gbm_device *
|
||||
gbm_create_device(int fd);
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_bo_create(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t flags);
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_bo_create_with_modifiers(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format,
|
||||
const uint64_t *modifiers,
|
||||
const unsigned int count);
|
||||
|
||||
#define GBM_BO_IMPORT_WL_BUFFER 0x5501
|
||||
#define GBM_BO_IMPORT_EGL_IMAGE 0x5502
|
||||
#define GBM_BO_IMPORT_FD 0x5503
|
||||
#define GBM_BO_IMPORT_FD_MODIFIER 0x5504
|
||||
|
||||
struct gbm_import_fd_data {
|
||||
int fd;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t stride;
|
||||
uint32_t format;
|
||||
};
|
||||
|
||||
#define GBM_MAX_PLANES 4
|
||||
|
||||
struct gbm_import_fd_modifier_data {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
uint32_t num_fds;
|
||||
int fds[GBM_MAX_PLANES];
|
||||
int strides[GBM_MAX_PLANES];
|
||||
int offsets[GBM_MAX_PLANES];
|
||||
uint64_t modifier;
|
||||
};
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_bo_import(struct gbm_device *gbm, uint32_t type,
|
||||
void *buffer, uint32_t usage);
|
||||
|
||||
/**
|
||||
* Flags to indicate the type of mapping for the buffer - these are
|
||||
* passed into gbm_bo_map(). The caller must set the union of all the
|
||||
* flags that are appropriate.
|
||||
*
|
||||
* These flags are independent of the GBM_BO_USE_* creation flags. However,
|
||||
* mapping the buffer may require copying to/from a staging buffer.
|
||||
*
|
||||
* See also: pipe_transfer_usage
|
||||
*/
|
||||
enum gbm_bo_transfer_flags {
|
||||
/**
|
||||
* Buffer contents read back (or accessed directly) at transfer
|
||||
* create time.
|
||||
*/
|
||||
GBM_BO_TRANSFER_READ = (1 << 0),
|
||||
/**
|
||||
* Buffer contents will be written back at unmap time
|
||||
* (or modified as a result of being accessed directly).
|
||||
*/
|
||||
GBM_BO_TRANSFER_WRITE = (1 << 1),
|
||||
/**
|
||||
* Read/modify/write
|
||||
*/
|
||||
GBM_BO_TRANSFER_READ_WRITE = (GBM_BO_TRANSFER_READ | GBM_BO_TRANSFER_WRITE),
|
||||
};
|
||||
|
||||
void *
|
||||
gbm_bo_map(struct gbm_bo *bo,
|
||||
uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
uint32_t flags, uint32_t *stride, void **map_data);
|
||||
|
||||
void
|
||||
gbm_bo_unmap(struct gbm_bo *bo, void *map_data);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_width(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_height(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_stride(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_stride_for_plane(struct gbm_bo *bo, int plane);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_format(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_bpp(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_offset(struct gbm_bo *bo, int plane);
|
||||
|
||||
struct gbm_device *
|
||||
gbm_bo_get_device(struct gbm_bo *bo);
|
||||
|
||||
union gbm_bo_handle
|
||||
gbm_bo_get_handle(struct gbm_bo *bo);
|
||||
|
||||
int
|
||||
gbm_bo_get_fd(struct gbm_bo *bo);
|
||||
|
||||
uint64_t
|
||||
gbm_bo_get_modifier(struct gbm_bo *bo);
|
||||
|
||||
int
|
||||
gbm_bo_get_plane_count(struct gbm_bo *bo);
|
||||
|
||||
union gbm_bo_handle
|
||||
gbm_bo_get_handle_for_plane(struct gbm_bo *bo, int plane);
|
||||
|
||||
int
|
||||
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
|
||||
|
||||
void
|
||||
gbm_bo_set_user_data(struct gbm_bo *bo, void *data,
|
||||
void (*destroy_user_data)(struct gbm_bo *, void *));
|
||||
|
||||
void *
|
||||
gbm_bo_get_user_data(struct gbm_bo *bo);
|
||||
|
||||
void
|
||||
gbm_bo_destroy(struct gbm_bo *bo);
|
||||
|
||||
struct gbm_surface *
|
||||
gbm_surface_create(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t flags);
|
||||
|
||||
struct gbm_surface *
|
||||
gbm_surface_create_with_modifiers(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format,
|
||||
const uint64_t *modifiers,
|
||||
const unsigned int count);
|
||||
|
||||
int
|
||||
gbm_surface_needs_lock_front_buffer(struct gbm_surface *surface);
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_surface_lock_front_buffer(struct gbm_surface *surface);
|
||||
|
||||
void
|
||||
gbm_surface_release_buffer(struct gbm_surface *surface, struct gbm_bo *bo);
|
||||
|
||||
int
|
||||
gbm_surface_has_free_buffers(struct gbm_surface *surface);
|
||||
|
||||
void
|
||||
gbm_surface_destroy(struct gbm_surface *surface);
|
||||
|
||||
char *
|
||||
gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
812
qcom/opensource/display/libgbm/inc/gbm_priv.h
Normal file
812
qcom/opensource/display/libgbm/inc/gbm_priv.h
Normal file
@@ -0,0 +1,812 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Not a Contribution.
|
||||
*
|
||||
* Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
*Not a contribution
|
||||
*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright © 2011 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Benjamin Franzke <benjaminfranzke@googlemail.com>
|
||||
*/
|
||||
|
||||
#ifndef GBM_PRIV_H_
|
||||
#define GBM_PRIV_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \file gbm_priv.h
|
||||
* \brief: This header file would be an interface for Graphics and video clients
|
||||
*
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <gbm.h>
|
||||
#include <color_metadata.h>
|
||||
/**
|
||||
* These are the flags used by the clients during allocation to
|
||||
* indicate the purpose of allocation to the gbm backend.
|
||||
* Gbm backend can use them to decide on the ION heap id and ION flags to be
|
||||
* used as part of ION allocation.
|
||||
* NOTE:
|
||||
* These usage flags are extension to the open source gbm.h defined
|
||||
* flags, so the initial integer value of these flags has spacing to avoid
|
||||
* conflicts
|
||||
*/
|
||||
/** These allocation heap are used to select the corresponding ION heap id. */
|
||||
#define GBM_BO_ALLOC_SYSTEM_HEAP_QTI 0x00000100 /*BO allocation from system heap*/
|
||||
#define GBM_BO_ALLOC_SECURE_HEAP_QTI 0x00000200 /*BO allocation from secure heap*/
|
||||
#define GBM_BO_ALLOC_SECURE_DISPLAY_HEAP_QTI 0x00000400 /*BO allocation from secure-display heap*/
|
||||
#define GBM_BO_ALLOC_ADSP_HEAP_QTI 0x00000800 /*BO allocation from ADSP heap*/
|
||||
#define GBM_BO_ALLOC_CAMERA_HEAP_QTI 0x00001000 /*BO allocation from camera heap*/
|
||||
#define GBM_BO_ALLOC_IOMMU_HEAP_QTI 0x00002000 /*BO allocation from IOMMU heap*/
|
||||
#define GBM_BO_ALLOC_MM_HEAP_QTI 0x00004000 /*BO allocation from MM heap*/
|
||||
|
||||
/** These usage flags are used to inform GBM backend about the usage of the allcated BO.*/
|
||||
#define GBM_BO_USAGE_PROTECTED_QTI 0x00008000 /*BO allocation flag to get protected BO*/
|
||||
#define GBM_BO_USAGE_UNCACHED_QTI 0x00010000 /*BO allocation flag to get uncached BO*/
|
||||
#define GBM_BO_USAGE_CPU_READ_QTI 0x00020000 /*BO has CPU read access */
|
||||
#define GBM_BO_USAGE_CPU_WRITE_QTI 0x00040000 /*BO has CPU write access */
|
||||
#define GBM_BO_USAGE_NON_CPU_WRITER_QTI 0x00080000 /*BO has non-CPU writer access */
|
||||
#define GBM_BO_USAGE_UBWC_ALIGNED_QTI 0x00100000 /*BO allocation for UBWC enabled client request*/
|
||||
#define GBM_BO_USAGE_CAMERA_READ_QTI 0x00200000 /*BO used for camera consumer */
|
||||
#define GBM_BO_USAGE_CAMERA_WRITE_QTI 0x00400000 /*BO used for camera producer */
|
||||
#define GBM_BO_USAGE_VIDEO_ENCODER_QTI 0x00800000 /*BO used for video encoder */
|
||||
#define GBM_BO_USAGE_HW_COMPOSER_QTI 0x01000000 /*BO used for video encoder */
|
||||
#define GBM_BO_USAGE_HW_RENDERING_QTI 0x02000000 /*BO allocation for GPU based rendering operation */
|
||||
#define GBM_BO_USAGE_10BIT_QTI 0x04000000 /*BO allocation for 10 bit */
|
||||
#define GBM_BO_USAGE_10BIT_TP_QTI 0x08000000 /*BO allocation for 10 bit TP */
|
||||
#define GBM_BO_USAGE_EGL_IMAGE_QTI 0x10000000 /*BO allocation for EGL image operation */
|
||||
|
||||
/**
|
||||
* These are the parameter types to be used by the clients to query metadata info from gbm backend
|
||||
*
|
||||
*/
|
||||
#define GBM_METADATA_GET_INTERLACED 0x00000001 /*Param type to query Interlaced field*/
|
||||
|
||||
#define GBM_METADATA_GET_REFRESH_RATE 0x00000002 /*Param type to query Refresh rate field*/
|
||||
|
||||
#define GBM_METADATA_GET_MAP_SECURE_BUFFER 0x00000004 /*Param type to query map secure buffer field*/
|
||||
|
||||
#define GBM_METADATA_GET_LINEAR_FORMAT 0x00000008 /*Param type to query linear format field*/
|
||||
|
||||
#define GBM_METADATA_GET_COLOR_SPACE 0x00000010 /*Param type to query Color space field*/
|
||||
|
||||
#define GBM_METADATA_GET_IGC 0x00000020 /*Param type to query IGC field*/
|
||||
|
||||
#define GBM_METADATA_GET_S3DFORMAT 0x00000040 /*Param type to query S3D format field*/
|
||||
|
||||
#define GBM_METADATA_GET_SECURE_BUF_STAT 0x00000080 /*Param type to query secure buffer status*/
|
||||
|
||||
#define GBM_METADATA_GET_COLOR_METADATA 0x00000100 /*Param type to query Color Metadata*/
|
||||
|
||||
#define GBM_METADATA_GET_UBWC_BUF_STAT 0x00000200 /*Param type to query UBWC buffer status*/
|
||||
|
||||
#define GBM_METADATA_GET_VT_TIMESTAMP 0x00000400 /*Param type to query VT timestamp*/
|
||||
|
||||
#define GBM_METADATA_GET_VIDEO_PERF_MODE 0x00000800 /*Param type to query Video Perf mode*/
|
||||
|
||||
#define GBM_METADATA_GET_CVP_METADATA 0x00001000 /*Param type to query CVPMetadata*/
|
||||
|
||||
#define GBM_METADATA_GET_VIDEO_HIST_STAT 0x00002000 /*Param type to query Video Histogram Stat*/
|
||||
|
||||
/**
|
||||
* These are the parameter types to be used by the clients to set metadata info from gbm backend
|
||||
*
|
||||
*/
|
||||
#define GBM_METADATA_SET_INTERLACED 0x00000001 /*Param type to set Interlaced field*/
|
||||
|
||||
#define GBM_METADATA_SET_REFRESH_RATE 0x00000002 /*Param type to set Refresh rate field*/
|
||||
|
||||
#define GBM_METADATA_SET_MAP_SECURE_BUFFER 0x00000004 /*Param type to set map secure buffer field*/
|
||||
|
||||
#define GBM_METADATA_SET_LINEAR_FORMAT 0x00000008 /*Param type to set linear format field*/
|
||||
|
||||
#define GBM_METADATA_SET_COLOR_SPACE 0x00000010 /*Param type to set Color space field*/
|
||||
|
||||
#define GBM_METADATA_SET_IGC 0x00000020 /*Param type to set IGC field*/
|
||||
|
||||
#define GBM_METADATA_SET_S3DFORMAT 0x00000040 /*Param type to set S3D format field*/
|
||||
|
||||
#define GBM_METADATA_SET_COLOR_METADATA 0x00000080 /*Param type to set Color Metadata*/
|
||||
|
||||
#define GBM_METADATA_SET_VT_TIMESTAMP 0x00000100 /*Param type to set VT timestamp*/
|
||||
|
||||
#define GBM_METADATA_SET_VIDEO_PERF_MODE 0x00000200 /*Param type to set Video Perf mode*/
|
||||
|
||||
#define GBM_METADATA_SET_CVP_METADATA 0x00000400 /*Param type to set CVPMetadata*/
|
||||
|
||||
#define GBM_METADATA_SET_VIDEO_HIST_STAT 0x00000800 /*Param type to set Video Histogram Stat*/
|
||||
|
||||
/**
|
||||
* These define the color space value for the Metadata Color space entry
|
||||
*
|
||||
*/
|
||||
#define GBM_METADATA_COLOR_SPACE_ITU_R_601 0x1
|
||||
|
||||
#define GBM_METADATA_COLOR_SPACE_ITU_R_601_FR 0x2
|
||||
|
||||
#define GBM_METADATA_COLOR_SPACE_ITU_R_709 0x3
|
||||
|
||||
#define GBM_METADATA_COLOR_SPACE_ITU_R_2020 0x4
|
||||
|
||||
#define GBM_METADATA_COLOR_SPACE_ITU_R_2020_FR 0x5
|
||||
|
||||
|
||||
/**
|
||||
* These define the IGC value for the Metadata IGC entry
|
||||
*
|
||||
*/
|
||||
#define GBM_METADATA_IGC_NONE 0x1
|
||||
|
||||
#define GBM_METADATA_IGC_sRGB 0x2
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Supported Perform API Operation Opcodes
|
||||
*
|
||||
*/
|
||||
#define GBM_PERFORM_GET_SURFACE_FORMAT 0x0 /*Query user provided format from the
|
||||
gbm surface*/
|
||||
|
||||
#define GBM_PERFORM_GET_SURFACE_WIDTH 0x1 /*Query user provided width from the
|
||||
gbm surface */
|
||||
|
||||
#define GBM_PERFORM_GET_SURFACE_HEIGHT 0x2 /*Query user provided height from the
|
||||
gbm surface*/
|
||||
|
||||
#define GBM_PERFORM_SET_SURFACE_FRONT_BO 0x3 /*Update the current state to
|
||||
NEW_FRONT_BUFFER of the BO associated
|
||||
with the gbm surface*/
|
||||
|
||||
#define GBM_PERFORM_GET_SURFACE_FREE_BO 0x4 /*Return the BO which is marked free
|
||||
associated with the gbm surface */
|
||||
|
||||
#define GBM_PERFORM_VALIDATE_SURFACE 0x5 /*Validate the GBM Surface*/
|
||||
|
||||
#define GBM_PERFORM_CPU_MAP_FOR_BO 0x6 /*Return the mapped address to the
|
||||
BO buffer*/
|
||||
|
||||
#define GBM_PERFORM_CPU_UNMAP_FOR_BO 0x7 /*Unmap the already mapped BO buffer*/
|
||||
|
||||
#define GBM_PERFORM_GET_BO_SIZE 0x8 /*Query BO buffer size*/
|
||||
|
||||
#define GBM_PERFORM_GET_BO_NAME 0x9 /*Query BO buffer name*/
|
||||
|
||||
#define GBM_PERFORM_IMPORT_BO_FROM_NAME 0x11 /*Import BO from specified name*/
|
||||
|
||||
#define GBM_PERFORM_GET_DRM_DEVICE_MAGIC 0x12 /*Query DRM Device magic id */
|
||||
|
||||
#define GBM_PERFORM_AUTH_DRM_DEVICE_MAGIC 0x13 /*Authenticate DRM Device magic id */
|
||||
|
||||
#define GBM_PERFORM_GET_DRM_DEVICE_NAME 0x14 /*Query DRM Device name */
|
||||
|
||||
#define GBM_PERFORM_VALIDATE_DEVICE 0x15 /*Validate the GBM Device*/
|
||||
|
||||
#define GBM_PERFORM_GET_METADATA 0x16 /*Query Metadata info */
|
||||
|
||||
#define GBM_PERFORM_SET_METADATA 0x17 /*Set Metadata info */
|
||||
|
||||
#define GBM_PERFORM_GET_YUV_PLANE_INFO 0x18 /*Query YUV plane info */
|
||||
|
||||
#define GBM_PERFORM_GET_UBWC_STATUS 0x19 /*Query if the BO Allocation was
|
||||
with UBWC enabled hardware*/
|
||||
|
||||
#define GBM_PERFORM_GET_RGB_DATA_ADDRESS 0x20 /*Query for RGB data base address*/
|
||||
|
||||
#define GBM_PERFORM_SET_GPU_ADDR_FOR_BO 0x21 /*Set GPU addr */
|
||||
|
||||
#define GBM_PERFORM_GET_GPU_ADDR_FOR_BO 0x22 /* Query GPU Addr */
|
||||
|
||||
#define GBM_PERFORM_GET_SECURE_BUFFER_STATUS 0x23 /* Query Buffer is secured */
|
||||
|
||||
#define GBM_PERFORM_GET_METADATA_ION_FD 0x24 /* Get Metadata ion fd from BO*/
|
||||
|
||||
#define GBM_PERFORM_DUMP_HASH_MAP 0x25 /* Dump the existing hash map
|
||||
table contents*/
|
||||
|
||||
#define GBM_PERFORM_DUMP_BO_CONTENT 0x26 /* Dump the BO buffer contents
|
||||
on to a file*/
|
||||
|
||||
#define GBM_PERFORM_GET_BO_ALIGNED_WIDTH 0x27 /* Get Aligned width from BO*/
|
||||
|
||||
#define GBM_PERFORM_GET_BO_ALIGNED_HEIGHT 0x28 /* Get Aligned height from BO*/
|
||||
|
||||
#define GBM_PERFORM_GET_PLANE_INFO 0x29 /* Get Plane Info from BO*/
|
||||
|
||||
#define GBM_PERFORM_DEFAULT_INIT_COLOR_META 0x30 /* Initialize Color Meta structure with
|
||||
default values to validate */
|
||||
|
||||
#define GBM_PERFORM_DUMP_COLOR_META 0x31 /* Dump Color Meta structure */
|
||||
|
||||
#define GBM_PERFORM_GET_BUFFER_SIZE_DIMENSIONS 0x32 /* Query Buffer size and dimenstions
|
||||
(aligned width, aligned height and size)*/
|
||||
|
||||
#define GBM_PERFORM_GET_SURFACE_UBWC_STATUS 0x33 /* Query if the Surface BO Allocation was
|
||||
with UBWC enabled hardware */
|
||||
|
||||
#define GBM_PERFORM_GET_WL_RESOURCE_FROM_GBM_BUF_INFO 0x34 /* Get wl_resource from gbm_buf_info*/
|
||||
|
||||
#define GBM_PERFORM_GET_GBM_BUF_INFO_FROM_WL_RESOURCE 0x35 /* Retrieve gbm_buf_info from
|
||||
wl_resource */
|
||||
|
||||
#define GBM_PERFORM_GET_RENDER_DEVICE_NAME 0x36 /* Get render node for user */
|
||||
|
||||
#define GBM_PERFORM_GET_BUFFER_STRIDE_SCANLINE_SIZE 0x37 /* Query Buffer stride, scanline and size
|
||||
(stride, scanline and size)*/
|
||||
|
||||
#define GBM_PERFORM_GET_FD_WITH_NEW 0x38 /* Query whether get fd with new */
|
||||
/**
|
||||
* Error representation for GBM API's
|
||||
*
|
||||
*/
|
||||
#define GBM_ERROR_NONE 0x0
|
||||
|
||||
#define GBM_ERROR_BAD_DESCRIPTOR 0x1
|
||||
|
||||
#define GBM_ERROR_BAD_HANDLE 0x2
|
||||
|
||||
#define GBM_ERROR_BAD_VALUE 0x3
|
||||
|
||||
#define GBM_ERROR_NOT_SHARED 0x4
|
||||
|
||||
#define GBM_ERROR_NO_RESOURCES 0x5
|
||||
|
||||
#define GBM_ERROR_UNDEFINED 0x6
|
||||
|
||||
#define GBM_ERROR_UNSUPPORTED 0x7
|
||||
|
||||
/**
|
||||
* Custom import type define
|
||||
* In case there are more enums added to GBM import,
|
||||
* they'd be in sequential order.To avoid conflicts it's
|
||||
* best to have an unused range ... 0x4FFF and decremented
|
||||
* if we have any more imports added
|
||||
*/
|
||||
#define GBM_BO_IMPORT_GBM_BUF_TYPE 0x4FFF
|
||||
|
||||
/**
|
||||
* Custom 4CC Modifiers
|
||||
*
|
||||
* Format Modifiers info extracted from open source drm_fourcc.h:
|
||||
*
|
||||
* Format modifiers describe, typically, a re-ordering or modification
|
||||
* of the data in a plane of an FB. This can be used to express tiled/
|
||||
* swizzled formats, or compression, or a combination of the two.
|
||||
*
|
||||
* The upper 4 bits of the format modifier are a vendor-id as assigned
|
||||
* below. The lower 28 bits are assigned as vendor sees fit.
|
||||
*/
|
||||
|
||||
/* Vendor Ids: */
|
||||
#define GBM_FORMAT_MOD_VENDOR_QTI 0x05
|
||||
|
||||
/* add more to the end as needed */
|
||||
#define fourcc_mod_code_qti(vendor, val) \
|
||||
((((uint32_t)GBM_FORMAT_MOD_VENDOR_## vendor) << 28) | (val & 0x0fffffffULL))
|
||||
|
||||
/**
|
||||
* Below is the list of Custom 4CC modes supported by libgbm
|
||||
*
|
||||
*/
|
||||
#define GBM_FORMAT_RAW16 fourcc_mod_code_qti(QTI, 1)
|
||||
|
||||
#define GBM_FORMAT_RAW10 fourcc_mod_code_qti(QTI, 2)
|
||||
|
||||
#define GBM_FORMAT_RAW12 fourcc_mod_code_qti(QTI, 3)
|
||||
|
||||
#define GBM_FORMAT_RAW8 fourcc_mod_code_qti(QTI, 4)
|
||||
|
||||
#define GBM_FORMAT_YV12 fourcc_mod_code_qti(QTI, 5)
|
||||
|
||||
#define GBM_FORMAT_YCbCr_420_SP fourcc_mod_code_qti(QTI, 6)
|
||||
|
||||
#define GBM_FORMAT_YCrCb_420_SP fourcc_mod_code_qti(QTI, 7)
|
||||
|
||||
#define GBM_FORMAT_YCbCr_422_SP fourcc_mod_code_qti(QTI, 8)
|
||||
|
||||
#define GBM_FORMAT_YCrCb_422_SP fourcc_mod_code_qti(QTI, 9)
|
||||
|
||||
#define GBM_FORMAT_YCbCr_422_I fourcc_mod_code_qti(QTI, 10)
|
||||
|
||||
#define GBM_FORMAT_YCrCb_422_I fourcc_mod_code_qti(QTI, 11)
|
||||
|
||||
#define GBM_FORMAT_YCbCr_420_SP_VENUS fourcc_mod_code_qti(QTI, 12)
|
||||
|
||||
#define GBM_FORMAT_NV12_ENCODEABLE fourcc_mod_code_qti(QTI, 13)
|
||||
|
||||
#define GBM_FORMAT_YCrCb_420_SP_VENUS fourcc_mod_code_qti(QTI, 14)
|
||||
|
||||
#define GBM_FORMAT_NV21_ZSL fourcc_mod_code_qti(QTI, 15)
|
||||
|
||||
#define GBM_FORMAT_BLOB fourcc_mod_code_qti(QTI, 16)
|
||||
|
||||
#define GBM_FORMAT_RAW_OPAQUE fourcc_mod_code_qti(QTI, 17)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR fourcc_mod_code_qti(QTI, 18)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR fourcc_mod_code_qti(QTI, 19)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR fourcc_mod_code_qti(QTI, 20)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR fourcc_mod_code_qti(QTI, 21)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR fourcc_mod_code_qti(QTI, 22)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR fourcc_mod_code_qti(QTI, 23)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR fourcc_mod_code_qti(QTI, 24)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR fourcc_mod_code_qti(QTI, 25)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR fourcc_mod_code_qti(QTI, 26)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR fourcc_mod_code_qti(QTI, 27)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR fourcc_mod_code_qti(QTI, 28)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR fourcc_mod_code_qti(QTI, 29)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR fourcc_mod_code_qti(QTI, 30)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR fourcc_mod_code_qti(QTI, 31)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR fourcc_mod_code_qti(QTI, 32)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR fourcc_mod_code_qti(QTI, 33)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR fourcc_mod_code_qti(QTI, 34)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR fourcc_mod_code_qti(QTI, 35)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR fourcc_mod_code_qti(QTI, 36)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR fourcc_mod_code_qti(QTI, 37)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR fourcc_mod_code_qti(QTI, 38)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR fourcc_mod_code_qti(QTI, 39)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR fourcc_mod_code_qti(QTI, 40)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR fourcc_mod_code_qti(QTI, 41)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR fourcc_mod_code_qti(QTI, 42)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR fourcc_mod_code_qti(QTI, 43)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR fourcc_mod_code_qti(QTI, 44)
|
||||
|
||||
#define GBM_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR fourcc_mod_code_qti(QTI, 45)
|
||||
|
||||
#define GBM_FORMAT_YCbCr_420_SP_VENUS_UBWC fourcc_mod_code_qti(QTI, 46)
|
||||
|
||||
#define GBM_FORMAT_YCbCr_420_888 fourcc_mod_code_qti(QTI, 47)
|
||||
|
||||
#define GBM_FORMAT_IMPLEMENTATION_DEFINED fourcc_mod_code_qti(QTI, 48)
|
||||
|
||||
#define GBM_FORMAT_NV12_HEIF fourcc_mod_code_qti(QTI, 49)
|
||||
|
||||
#define GBM_FORMAT_YCbCr_420_P010_VENUS fourcc_mod_code_qti(QTI, 50)
|
||||
|
||||
#define GBM_FORMAT_NV12_LINEAR_FLEX fourcc_mod_code_qti(QTI, 51)
|
||||
|
||||
#define GBM_FORMAT_NV12_UBWC_FLEX fourcc_mod_code_qti(QTI, 52)
|
||||
|
||||
#define GBM_FORMAT_MULTIPLANAR_FLEX fourcc_mod_code_qti(QTI, 53)
|
||||
|
||||
#define GBM_FORMAT_RGBA16161616F fourcc_mod_code_qti(QTI, 54)
|
||||
|
||||
#define GBM_FORMAT_RGB161616F fourcc_mod_code_qti(QTI, 55)
|
||||
|
||||
#define GBM_FORMAT_RGBA32323232F fourcc_mod_code_qti(QTI, 56)
|
||||
|
||||
#define GBM_FORMAT_RGB323232F fourcc_mod_code_qti(QTI, 57)
|
||||
|
||||
#define GBM_FORMAT_YCbCr_420_TP10_UBWC __gbm_fourcc_code('Q', '1', '2', 'A')
|
||||
|
||||
#define GBM_FORMAT_YCbCr_420_P010_UBWC __gbm_fourcc_code('Q', '1', '2', 'B')
|
||||
|
||||
/* Y/CbCr 4:2:0 P10 format*/
|
||||
#define GBM_FORMAT_P010 __gbm_fourcc_code('P', '0', '1', '0')
|
||||
|
||||
/**
|
||||
* Pixel component ID defines
|
||||
* to be used at the generic plane object
|
||||
*
|
||||
*/
|
||||
/* luma */
|
||||
#define PIXEL_COMPONENT_Y 0x00000001
|
||||
/* chroma blue */
|
||||
#define PIXEL_COMPONENT_Cb 0x00000002
|
||||
/* chroma red */
|
||||
#define PIXEL_COMPONENT_Cr 0x00000004
|
||||
/* red */
|
||||
#define PIXEL_COMPONENT_R 0x00000100
|
||||
/* green */
|
||||
#define PIXEL_COMPONENT_G 0x00000200
|
||||
/* blue */
|
||||
#define PIXEL_COMPONENT_B 0x00000400
|
||||
/*RAW 10 */
|
||||
#define PIXEL_COMPONENT_RAW10 0x00010000
|
||||
/*RAW 16 */
|
||||
#define PIXEL_COMPONENT_RAW16 0x00020000
|
||||
/* alpha */
|
||||
#define PIXEL_COMPONENT_A 0x00100000
|
||||
|
||||
|
||||
/* Maximum count of planes for given frame buffer
|
||||
Different from GBM_MAX_PLANES
|
||||
*/
|
||||
#define MAX_NUM_OF_PLANES 5
|
||||
#define MAX_NUM_MODIFIERS 4
|
||||
|
||||
/* possible formats for 3D content*/
|
||||
enum {
|
||||
HAL_NO_3D = 0x0,
|
||||
HAL_3D_SIDE_BY_SIDE_L_R = 0x1,
|
||||
HAL_3D_SIDE_BY_SIDE_R_L = 0x2,
|
||||
HAL_3D_TOP_BOTTOM = 0x4,
|
||||
HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, // unused legacy format
|
||||
};
|
||||
|
||||
enum UBWC_Version {
|
||||
UBWC_UNUSED = 0,
|
||||
UBWC_1_0 = 0x1,
|
||||
UBWC_2_0 = 0x2,
|
||||
UBWC_3_0 = 0x3,
|
||||
UBWC_4_0 = 0x4,
|
||||
UBWC_MAX_VERSION = 0xFF,
|
||||
};
|
||||
|
||||
#define MAX_UBWC_STATS_LENGTH 32
|
||||
struct UBWC_2_0_Stats {
|
||||
uint32_t nCRStatsTile32; /**< UBWC Stats info for 32 Byte Tile */
|
||||
uint32_t nCRStatsTile64; /**< UBWC Stats info for 64 Byte Tile */
|
||||
uint32_t nCRStatsTile96; /**< UBWC Stats info for 96 Byte Tile */
|
||||
uint32_t nCRStatsTile128; /**< UBWC Stats info for 128 Byte Tile */
|
||||
uint32_t nCRStatsTile160; /**< UBWC Stats info for 160 Byte Tile */
|
||||
uint32_t nCRStatsTile192; /**< UBWC Stats info for 192 Byte Tile */
|
||||
uint32_t nCRStatsTile256; /**< UBWC Stats info for 256 Byte Tile */
|
||||
};
|
||||
|
||||
struct UBWCStats {
|
||||
enum UBWC_Version version; /* Union depends on this version. */
|
||||
uint8_t bDataValid; /* If [non-zero], CR Stats data is valid.
|
||||
90 * Consumers may use stats data.
|
||||
91 * If [zero], CR Stats data is invalid.
|
||||
92 * Consumers *Shall* not use stats data */
|
||||
union {
|
||||
struct UBWC_2_0_Stats ubwc_stats;
|
||||
uint32_t reserved[MAX_UBWC_STATS_LENGTH]; /* This is for future */
|
||||
};
|
||||
};
|
||||
|
||||
#define VIDEO_HISTOGRAM_STATS_SIZE (4 * 1024)
|
||||
/* Frame type bit mask */
|
||||
#define QD_SYNC_FRAME (0x1 << 0)
|
||||
struct VideoHistogramMetadata {
|
||||
uint32_t stats_info[1024]; /* video stats payload */
|
||||
uint32_t stat_len; /* Payload size in bytes */
|
||||
uint32_t frame_type; /* bit mask to indicate frame type */
|
||||
uint32_t display_width;
|
||||
uint32_t display_height;
|
||||
uint32_t decode_width;
|
||||
uint32_t decode_height;
|
||||
uint32_t reserved[12];
|
||||
};
|
||||
|
||||
#define CVP_METADATA_SIZE 1024
|
||||
enum CVPMetadataFlags {
|
||||
/* bit wise flags */
|
||||
CVP_METADATA_FLAG_NONE = 0x00000000,
|
||||
CVP_METADATA_FLAG_REPEAT = 0x00000001,
|
||||
};
|
||||
|
||||
typedef struct CVPMetadata {
|
||||
uint32_t size; /* payload size in bytes */
|
||||
uint8_t payload[CVP_METADATA_SIZE];
|
||||
uint32_t capture_frame_rate;
|
||||
/* Frame rate in Q16 format.
|
||||
Eg: fps = 7.5, then
|
||||
capture_frame_rate = 7 << 16 --> Upper 16 bits to represent 7
|
||||
capture_frame_rate |= 5 -------> Lower 16 bits to represent 5
|
||||
|
||||
If size > 0, framerate is valid
|
||||
If size = 0, invalid data, so ignore all parameters */
|
||||
uint32_t cvp_frame_rate;
|
||||
enum CVPMetadataFlags flags;
|
||||
uint32_t reserved[8];
|
||||
} CVPMetadata;
|
||||
|
||||
/**
|
||||
* The generic_buf_layout structure is used with any pixel format that can be
|
||||
* represented by it, such as:
|
||||
* - GBM_FORMAT_YCbCr_*_888
|
||||
* - GBM_FORMAT_FLEX_RGB*_888
|
||||
* - GBM_FORMAT_RGB[AX]_888[8],BGRA_8888,RGB_888
|
||||
* - GBM_FORMAT_YV12,Y8,Y16,YCbCr_422_SP/I,YCrCb_420_SP
|
||||
* - even implementation defined formats that can be represented by
|
||||
* the structures
|
||||
*
|
||||
* Vertical increment (aka. row increment or stride) describes the distance in
|
||||
* bytes from the first pixel of one row to the first pixel of the next row
|
||||
* (below) for the component plane. This can be negative.
|
||||
*
|
||||
* Horizontal increment (aka. column or pixel increment) describes the distance
|
||||
* in bytes from one pixel to the next pixel (to the right) on the same row for
|
||||
* the component plane. This can be negative.
|
||||
*
|
||||
* Each plane can be subsampled either vertically or horizontally by
|
||||
* a power-of-two factor.
|
||||
*
|
||||
* The bit-depth of each component can be arbitrary, as long as the pixels are
|
||||
* laid out on whole bytes, in native byte-order, using the most significant
|
||||
* bits of each unit.
|
||||
*
|
||||
*
|
||||
* generic planar layout object definition
|
||||
*
|
||||
*/
|
||||
typedef struct generic_plane {
|
||||
uint32_t *top_left; /* pointer to the first byte of the top-left
|
||||
pixel of the plane. */
|
||||
/* NOTE: For secured buffers this pointer is
|
||||
NULL */
|
||||
uint32_t offset; /* offset to the first byte of the top-left
|
||||
pixel of the plane */
|
||||
int32_t component_id; /* ID to represent */
|
||||
uint32_t aligned_width; /* Aligned width in pixels */
|
||||
uint32_t aligned_height; /* Aligned height in pixels*/
|
||||
uint32_t size; /* size in bytes*/
|
||||
int32_t bits_per_component; /* bits allocated for the component in each
|
||||
pixel. Must be a positive multiple of 8. */
|
||||
int32_t bits_used; /* number of the most significant bits used
|
||||
in the format for this component.
|
||||
Must be between 1 and bits_per_component */
|
||||
int32_t h_increment; /* horizontal increment */
|
||||
int32_t v_increment; /* vertical increment */
|
||||
int32_t h_subsampling; /* horizontal subsampling. Must be a positive
|
||||
power of 2. */
|
||||
int32_t v_subsampling; /* vertical subsampling. Must be a positive
|
||||
power of 2. */
|
||||
uint32_t stride; /* stride for plane */
|
||||
} generic_plane_t;
|
||||
|
||||
|
||||
typedef struct generic_buf_layout {
|
||||
int pixel_format; /* the kind of pixel format */
|
||||
uint32_t num_planes; /* number of planes
|
||||
0 for FLEX_FORMAT_INVALID */
|
||||
generic_plane_t planes[MAX_NUM_OF_PLANES]; /* a plane for each component,
|
||||
ordered in increasing
|
||||
component value order.
|
||||
E.g. FLEX_FORMAT_RGBA
|
||||
maps 0 -> R, 1 -> G, etc.
|
||||
Can be NULL for FLEX_FORMAT_INVALID */
|
||||
} generic_buf_layout_t;
|
||||
|
||||
/**
|
||||
* gbm device object definition
|
||||
*
|
||||
*/
|
||||
struct gbm_device {
|
||||
int fd; /*gbm device fd */
|
||||
const char *name; /* gbm device name*/
|
||||
unsigned refcount; /* used to track the gbm device open call
|
||||
reference*/
|
||||
void (*destroy)(struct gbm_device *gbm);
|
||||
int (*is_format_supported)(struct gbm_device *gbm,
|
||||
uint32_t format,
|
||||
uint32_t usage);
|
||||
struct gbm_bo *(*bo_create)(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format,
|
||||
uint32_t usage,
|
||||
const uint64_t *modifiers,
|
||||
const unsigned int count);
|
||||
struct gbm_bo *(*bo_import)(struct gbm_device *gbm, uint32_t type,
|
||||
void *buffer, uint32_t usage);
|
||||
int (*get_format_modifier_plane_count)(uint32_t format,
|
||||
uint64_t modifier);
|
||||
|
||||
struct gbm_surface *(*surface_create)(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t flags,
|
||||
uint64_t *modifiers, unsigned int count);
|
||||
};
|
||||
|
||||
/**
|
||||
* The Metadata structure whose buffer handle is associated with
|
||||
* gbm buffer object
|
||||
*
|
||||
* The members of this structure are accessed by gbm perform API only
|
||||
*/
|
||||
struct meta_data_t {
|
||||
uint32_t operation; /* specific operation or state*/
|
||||
uint32_t interlaced; /* video buffer scan */
|
||||
uint32_t s3d_format; /* 3D video format supported */
|
||||
uint32_t linear_format; /* Producer output buffer is linear for UBWC Interlaced video */
|
||||
uint32_t color_space; /* color space specfics */
|
||||
uint32_t map_secure_buffer; /* Flag to represent SecureBuffer being used for GPU*/
|
||||
int is_buffer_secure; /* Flag to query if buffer is secure*/
|
||||
int is_buffer_ubwc; /* Flag to query if buffer is UBWC allocated */
|
||||
int igc; /* IGC value*/
|
||||
float refresh_rate; /* video referesh rate*/
|
||||
ColorMetaData color_info; /* Color Aspects + HDR info */
|
||||
uint64_t vt_timestamp; /* timestamp set by camera, intended for VT*/
|
||||
uint32_t isVideoPerfMode; /* set by camera indicates buffer will be used for
|
||||
High performace video use case */
|
||||
struct VideoHistogramMetadata histMetadata; /*histogram metadata*/
|
||||
CVPMetadata cvpMetadata; /* Metadata from cvp */
|
||||
};
|
||||
|
||||
/**
|
||||
* The allocated gbm buffer object.
|
||||
*
|
||||
* The members in this structure should not be accessed directly.
|
||||
*/
|
||||
struct gbm_bo {
|
||||
int ion_fd; /* ION buffer fd */
|
||||
int ion_metadata_fd; /* ION metadata fd */
|
||||
union gbm_bo_handle handle; /* GEM handle */
|
||||
union gbm_bo_handle metadata_handle; /* GEM metadata handle */
|
||||
uint32_t format; /* buffer format */
|
||||
uint32_t width; /* unaligned width of the buffer in pixels */
|
||||
uint32_t height; /* unaligned height of the buffer in pixels */
|
||||
uint32_t aligned_width; /* aligned width of the buffer in pixels */
|
||||
uint32_t aligned_height; /* aligned height of the buffer in pixels */
|
||||
uint32_t size; /* size of the buffer in bytes */
|
||||
uint32_t stride; /* stride of the buffer in bytes */
|
||||
uint32_t usage_flags; /* usage flags */
|
||||
uint32_t fbid; /* framebuffer id */
|
||||
uint32_t bpp; /* bytes per pixel*/
|
||||
uint32_t plane_count; /* plane count*/
|
||||
generic_buf_layout_t buf_lyt;
|
||||
uint64_t modifier;
|
||||
int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);
|
||||
int (*bo_get_fd)(struct gbm_bo *bo);
|
||||
struct gbm_device* (*bo_get_device)(struct gbm_bo *bo);
|
||||
void (*bo_destroy)(struct gbm_bo *bo);
|
||||
void *user_data;
|
||||
void (*destroy_user_data)(struct gbm_bo *, void *);
|
||||
void * (*bo_map)(uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
uint32_t flags, uint32_t *stride, void **map_data);
|
||||
|
||||
void (*bo_unmap)(void *map_data);
|
||||
uint32_t (*stride_for_plane)(int plane, struct gbm_bo *);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The allocated gbm surface object.
|
||||
*
|
||||
* The members in this structure should not be accessed directly.
|
||||
*/
|
||||
struct gbm_surface {
|
||||
uint32_t format; /* pixel format */
|
||||
uint32_t width; /* width of surface in pixels */
|
||||
uint32_t height; /* height of surface in pixels */
|
||||
uint32_t flags; /* usage flags */
|
||||
void (*surface_release_buffer)(struct gbm_surface *surface,
|
||||
struct gbm_bo *bo);
|
||||
int (*surface_has_free_buffers)(struct gbm_surface *surface);
|
||||
void (*surface_destroy)(struct gbm_surface *surface);
|
||||
struct gbm_bo* (*surface_lock_front_buffer)(struct gbm_surface *surface);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The gbm buffer data object used by the import fd API.
|
||||
*
|
||||
*/
|
||||
struct gbm_buf_info {
|
||||
int fd; /* ion fd */
|
||||
int metadata_fd; /* ion metadata fd*/
|
||||
uint32_t width; /* width of surface in pixels */
|
||||
uint32_t height; /* height of surface in pixels */
|
||||
uint32_t format; /* pixel format*/
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* gbm backend interface object.
|
||||
*
|
||||
*/
|
||||
struct gbm_backendpriv{
|
||||
const char *backend_name;
|
||||
struct gbm_device *(*create_device)(int fd);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* gbm backend interface .
|
||||
*
|
||||
*/
|
||||
struct gbm_backendpriv *gbm_get_priv(void);
|
||||
|
||||
/**
|
||||
* Perform supported queries
|
||||
* Input : operation opcodes
|
||||
* : Arguments depending on the operation
|
||||
* Return = gbm_error value
|
||||
*
|
||||
*/
|
||||
int gbm_perform(int operation,...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //GBM_PRIV_H_
|
521
qcom/opensource/display/libgbm/inc/msmgbm.h
Normal file
521
qcom/opensource/display/libgbm/inc/msmgbm.h
Normal file
@@ -0,0 +1,521 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Changes from Qualcomm Innovation Center are provided under the following license:
|
||||
*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted (subject to the limitations in the
|
||||
* disclaimer below) provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
|
||||
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
|
||||
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _MSM_GBM_H_
|
||||
#define _MSM_GBM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <display/drm/sde_drm.h>
|
||||
|
||||
//Enables debug log
|
||||
#ifdef GBM_DEBUG
|
||||
#define GBM_DBG_LOG fprintf
|
||||
#else
|
||||
#define GBM_DBG_LOG(...) {}
|
||||
#endif
|
||||
|
||||
#define LOG_FATAL (1)
|
||||
#define LOG_ERR (2)
|
||||
#define LOG_WARN (3)
|
||||
#define LOG_INFO (4)
|
||||
#define LOG_DBG (5)
|
||||
|
||||
extern int g_debug_level;
|
||||
|
||||
#define LOG(level, ...) do { \
|
||||
if (level <= g_debug_level) { \
|
||||
if(level==LOG_FATAL) \
|
||||
fprintf(stderr,"%s","GBM_FATAL::"); \
|
||||
if(level==LOG_ERR) \
|
||||
fprintf(stderr,"%s", "GBM_ERR::"); \
|
||||
if(level==LOG_WARN) \
|
||||
fprintf(stderr,"%s", "GBM_WARN::"); \
|
||||
if(level==LOG_INFO) \
|
||||
fprintf(stderr,"%s", "GBM_INFO::"); \
|
||||
if(level==LOG_DBG) \
|
||||
fprintf(stderr,"%s", "GBM_DBG::"); \
|
||||
fprintf(stderr,"%s(%d)::",__func__,__LINE__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
fflush(stderr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
|
||||
/*Currently three buffer mechanism is used for GPU rendering and Hardware Composition sync*/
|
||||
#ifdef ALLOCATE_SURFACE_BO_AT_CREATION
|
||||
#define NUM_BACK_BUFFERS 3
|
||||
#else
|
||||
#define NUM_BACK_BUFFERS 2
|
||||
#endif
|
||||
|
||||
#define MAX_NUM_PLANES 3
|
||||
#define QCMAGIC 0XDFDFECBA // need to compe up with something unique
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* State representation of the gbm buffer object
|
||||
*
|
||||
*/
|
||||
#define GBM_BO_STATE_FREE (0x0) /* Unused/Free state of the Buffer Object */
|
||||
|
||||
#define GBM_BO_STATE_INUSE_BY_COMPOSITOR (0x1) /* Buffer Object locked for composition */
|
||||
|
||||
#define GBM_BO_STATE_INUSE_BY_GPU (0x2) /* Buffer Object locked for GPU rendering */
|
||||
|
||||
#define GBM_BO_STATE_NEW_FRONT_BUFFER (0x3) /* Buffer Object currently available for
|
||||
* grab by GPU or Compositor */
|
||||
|
||||
|
||||
/**
|
||||
* State representation of the gbm buffer object during
|
||||
* gbm surface creation if enabled
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ALLOCATE_SURFACE_BO_AT_CREATION
|
||||
|
||||
#define SURFACE_BOSLOT_STATE_FREE (0x0) /* Unused/Free state of the Buffer Object */
|
||||
|
||||
#define SURFACE_BOSLOT_STATE_INUSE_BY_COMPOSITOR (0x1) /* BO locked for composition */
|
||||
|
||||
#define SURFACE_BOSLOT_STATE_HAS_NEW_FRONT_BUFFER (0x2) /* BO currently available for
|
||||
* grab by GPU or Compositor */
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* msm gbm device object corresponding to the gbm device object instance
|
||||
*
|
||||
* The members in this structure should not be accessed directly.
|
||||
*/
|
||||
|
||||
struct msmgbm_device {
|
||||
struct gbm_device base;
|
||||
uint32_t magic;
|
||||
int fd; /* device fd */
|
||||
int iondev_fd; /* ION device fd */
|
||||
};
|
||||
|
||||
struct msmgbm_surface {
|
||||
struct gbm_surface base;
|
||||
uint32_t magic;
|
||||
struct msmgbm_device* device;
|
||||
struct msmgbm_bo *bo[NUM_BACK_BUFFERS];
|
||||
int inuse_index;
|
||||
#ifndef ALLOCATE_SURFACE_BO_AT_CREATION
|
||||
int bo_slot[NUM_BACK_BUFFERS];
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* The allocated local msm buffer object for the corresponding gbm buffer object.
|
||||
*
|
||||
* The members in this structure should not be accessed directly.
|
||||
*/
|
||||
struct msmgbm_bo {
|
||||
struct gbm_bo base;
|
||||
uint32_t magic;
|
||||
struct msmgbm_device* device;
|
||||
uint32_t name;
|
||||
uint64_t gpuaddr;
|
||||
void* cpuaddr;
|
||||
void* mt_cpuaddr;
|
||||
size_t size;
|
||||
size_t mt_size;
|
||||
uint32_t current_state;
|
||||
uint32_t fbid;
|
||||
int ion_handle;
|
||||
int ion_mt_handle;
|
||||
int import_flg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Buffer Descriptor used for param passing between API's
|
||||
*
|
||||
*/
|
||||
struct gbm_bufdesc {
|
||||
uint32_t Width;
|
||||
uint32_t Height;
|
||||
uint32_t Format;
|
||||
uint32_t Usage;
|
||||
};
|
||||
|
||||
struct gbm_buf_resource {
|
||||
struct gbm_buf_info *buffer_info;
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
/**
|
||||
* The gbm buffer data object related
|
||||
* information stored in hashmap
|
||||
*/
|
||||
struct msmgbm_private_info {
|
||||
void* cpuaddr; /* gbm bo cpu address */
|
||||
void* mt_cpuaddr; /* gbm bo meta data address */
|
||||
};
|
||||
|
||||
/*
|
||||
* Function prototypes of all supported API's by backend
|
||||
*
|
||||
*/
|
||||
|
||||
/** create the gbm bo
|
||||
*
|
||||
* \param handle to gbm device
|
||||
* \param width
|
||||
* \param height
|
||||
* \param format
|
||||
* \param usage flag
|
||||
* \return gbm bo handle
|
||||
*
|
||||
*/
|
||||
static struct gbm_bo *msmgbm_bo_create(struct gbm_device *gbm,uint32_t width,
|
||||
uint32_t height,uint32_t format,
|
||||
uint32_t usage, const uint64_t *modifiers,
|
||||
const unsigned int count);
|
||||
|
||||
|
||||
/** Destroy the gbm bo
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return None
|
||||
*
|
||||
*/
|
||||
static void msmgbm_bo_destroy(struct gbm_bo *bo);
|
||||
|
||||
/** To query gbm device pointer
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return gbm device handle
|
||||
*
|
||||
*/
|
||||
static struct gbm_device* msmgbm_bo_get_device(struct gbm_bo *bo);
|
||||
|
||||
/** query gbm bo name
|
||||
*
|
||||
* \param gbm bo handle
|
||||
* \return id
|
||||
*
|
||||
*/
|
||||
|
||||
int msmgbm_bo_get_name(struct gbm_bo* bo);
|
||||
|
||||
|
||||
/** Perform write operation onto the gbm bo
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \param user buffer handle
|
||||
* \param byte count
|
||||
* \return =0 for success
|
||||
* >0 for fail
|
||||
*
|
||||
*/
|
||||
static int msmgbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
|
||||
|
||||
/** create the gbm bo
|
||||
*
|
||||
* \param import gbm bo handle depending on type
|
||||
* \param gbm device
|
||||
* \param type
|
||||
* \param void pointer
|
||||
* \param usage flag
|
||||
* \return gbm bo handle
|
||||
*
|
||||
*/
|
||||
struct gbm_bo * msmgbm_bo_import(struct gbm_device *gbm,uint32_t type,
|
||||
void *buffer, uint32_t usage);
|
||||
|
||||
/** Import gbm bo handle from fd
|
||||
*
|
||||
* \param handle to msmgbm_device
|
||||
* \param fd via void *
|
||||
* \param usage flags
|
||||
* \return gbm bo handle
|
||||
*
|
||||
*/
|
||||
struct gbm_bo * msmgbm_bo_import_fd(struct msmgbm_device *msm_dev,
|
||||
void *buffer, uint32_t usage);
|
||||
|
||||
/** Import gbm bo handle from name element of the wl buffer resource
|
||||
*
|
||||
* \param msmgbm_device handle
|
||||
* \param wl buffer handle
|
||||
* \param usage flag
|
||||
* \return gbm bo handle
|
||||
*
|
||||
*/
|
||||
struct gbm_bo * msmgbm_bo_import_wl_buffer(struct msmgbm_device *msm_dev,
|
||||
void *buffer, uint32_t usage);
|
||||
|
||||
/** create the gbm bo
|
||||
*
|
||||
* \param msmgbm_device handle
|
||||
* \param egl buffer handle
|
||||
* \param usage flag
|
||||
* \return gbm bo handle
|
||||
*
|
||||
*/
|
||||
struct gbm_bo * msmgbm_bo_import_egl_image(struct msmgbm_device *msm_dev,
|
||||
void *buffer, uint32_t usage);
|
||||
|
||||
/** create requested gbm surface with the dimensions
|
||||
*
|
||||
* \param gbm device handle
|
||||
* \param width
|
||||
* \param height
|
||||
* \param format
|
||||
* \param usage flag
|
||||
* \return gbm surface
|
||||
*
|
||||
*/
|
||||
static struct gbm_surface *
|
||||
msmgbm_surface_create(struct gbm_device *gbm, uint32_t width,
|
||||
uint32_t height, uint32_t format, uint32_t flags,
|
||||
uint64_t *modifiers, unsigned int count);
|
||||
|
||||
/** destroy gbm surface
|
||||
*
|
||||
* \param handle to gbm surface
|
||||
* \return None
|
||||
*
|
||||
*/
|
||||
static void msmgbm_surface_destroy(struct gbm_surface *surf);
|
||||
/** Verifies if surface is allocated by MSM GBM backend
|
||||
*
|
||||
* \Returns GBM_ERROR values
|
||||
*
|
||||
*/
|
||||
static inline
|
||||
int msmgbm_validate_surface(struct gbm_surface *surf);
|
||||
/** update the state of the current bo associated with the surface to used by compositor
|
||||
*
|
||||
* \param surface handle
|
||||
* \return gbm bo handle
|
||||
*
|
||||
*/
|
||||
static struct gbm_bo * msmgbm_surface_lock_front_buffer(struct gbm_surface *surf);
|
||||
/** update the state of the current bo associated with the surface to free
|
||||
*
|
||||
* \param surface handle
|
||||
* \return gbm bo handle
|
||||
*
|
||||
*/
|
||||
static void msmgbm_surface_release_buffer(struct gbm_surface *surf,
|
||||
struct gbm_bo *bo);
|
||||
/* Returns bo which can be used as front buffer on success
|
||||
* \Returns GBM_ERROR values
|
||||
*
|
||||
*/
|
||||
struct gbm_bo* msmgbm_surface_get_free_bo(struct gbm_surface *surf);
|
||||
/** update the state machine of a bo to be used as the surface front buffer
|
||||
* \Returns GBM_ERROR values
|
||||
*
|
||||
*/
|
||||
int msmgbm_surface_set_front_bo(struct gbm_surface *surf, struct gbm_bo *gbo);
|
||||
|
||||
/** Returns the CPU address of metadata
|
||||
* if fails returns NULL
|
||||
*/
|
||||
void* msmgbm_cpu_map_metafd(int meta_ion_fd, unsigned int metadata_size);
|
||||
/** Returns the cpu address of non secure bo
|
||||
* if mmap fails or buffer is secure, returns NULL
|
||||
*/
|
||||
void* msmgbm_cpu_map_ionfd(int ion_fd, unsigned int size, struct meta_data_t *meta_data);
|
||||
/** Returns the CPU access address for the BO buffer
|
||||
* \Returns CPU address on Success / Null on fail
|
||||
*
|
||||
*/
|
||||
|
||||
void * msmgbm_bo_cpu_map(struct gbm_bo *gbo);
|
||||
/* Unmap the BO buffer from CPU access
|
||||
* \Returns GBM_ERROR values
|
||||
*
|
||||
*/
|
||||
int msmgbm_bo_cpu_unmap(struct gbm_bo *gbo);
|
||||
/* Returns BO size on success
|
||||
* \Returns size on Success/ GBM_ERROR Values on Failure
|
||||
*
|
||||
*/
|
||||
static inline
|
||||
size_t msmgbm_bo_get_size(struct gbm_bo *bo);
|
||||
/** create gbm device
|
||||
*
|
||||
* \param display driver device fd
|
||||
* \return gbm device handle
|
||||
*
|
||||
*/
|
||||
static struct gbm_device * msmgbm_device_create(int fd);
|
||||
/** destroy the gbm device handle
|
||||
*
|
||||
* \param gbm device handle
|
||||
* \return none
|
||||
*
|
||||
*/
|
||||
static void msmgbm_device_destroy(struct gbm_device *gbm);
|
||||
/** To query gbm device fd
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return fd
|
||||
*
|
||||
*/
|
||||
static int msmgbm_device_get_fd(struct gbm_bo *bo);
|
||||
/** query device unique id
|
||||
*
|
||||
* \param handle to gbm device
|
||||
* \return ID
|
||||
*
|
||||
*/
|
||||
unsigned int msmgbm_device_get_magic(struct gbm_device *dev);
|
||||
/** query drm device file name
|
||||
*
|
||||
* \return gbm bo handle
|
||||
*
|
||||
*/
|
||||
static inline
|
||||
const char* msmgbm_drm_device_get_name(void);
|
||||
/** Authenticate the DRM magic ID
|
||||
*
|
||||
* \Returns 0 on success
|
||||
* \Returns -1 on failure
|
||||
*
|
||||
*/
|
||||
int msmgbm_device_authenticate_magic(struct gbm_device *dev,
|
||||
uint32_t magic);
|
||||
/** Import a BO handle from a unique ID/name
|
||||
*
|
||||
* \Returns imported BO pointer on success
|
||||
* \Returns NULL on failure
|
||||
*
|
||||
*/
|
||||
struct gbm_bo* msmgbm_bo_import_from_name(struct gbm_device *dev,
|
||||
unsigned int name);
|
||||
/** Returns global name on success
|
||||
*
|
||||
* \Returns GBM_ERROR values on failure
|
||||
*
|
||||
*/
|
||||
int msmgbm_bo_get_name(struct gbm_bo* bo);
|
||||
|
||||
/** Verifies if device is allocated by MSM GBM backend
|
||||
*
|
||||
* \Returns GBM_ERROR values
|
||||
*
|
||||
*/
|
||||
static inline
|
||||
int msmgbm_validate_device(struct gbm_device *dev);
|
||||
/** Query metadata info depending on the operation/paramtype
|
||||
*
|
||||
* \Returns GBM_ERROR values
|
||||
*
|
||||
*/
|
||||
int msmgbm_get_metadata(struct gbm_bo *gbo, int paramType,void *param);
|
||||
/** Set metadata info depending on the operation/paramtype
|
||||
*
|
||||
* \Returns GBM_ERROR values
|
||||
*
|
||||
*/
|
||||
int msmgbm_set_metadata(struct gbm_bo *gbo, int paramType,void *param);
|
||||
|
||||
/** Get RGB Data Address for a given gbm buffer object
|
||||
*
|
||||
* \Returns GBM_ERROR values
|
||||
*
|
||||
*/
|
||||
int msmgbm_get_rgb_data_address(struct gbm_bo *gbo, void **rgb_data);
|
||||
|
||||
/**
|
||||
* C wrapper function to increment the reference count for the valid gem_handle
|
||||
* @input param: device fd
|
||||
* @input param: gem handle
|
||||
* @return : none
|
||||
*
|
||||
*/
|
||||
void incr_handle_refcnt(int device_fd, uint32_t handle);
|
||||
|
||||
/**
|
||||
* C wrapper function to decrement the reference count for the valid map gem_handle
|
||||
* @input param: device fd
|
||||
* @input param: gem handle
|
||||
* @return : 1 for delete key from map /0 for decremented ref count
|
||||
*
|
||||
*/
|
||||
int decr_handle_refcnt(int device_fd, uint32_t handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_MSM_GBM_H_
|
||||
|
151
qcom/opensource/display/libgbm/inc/msmgbm_adreno_utils.h
Normal file
151
qcom/opensource/display/libgbm/inc/msmgbm_adreno_utils.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Not a Contribution.
|
||||
*
|
||||
* Copyright (c) 2017-2018, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __MSMGBM_ADRENO_UTILS_H__
|
||||
#define __MSMGBM_ADRENO_UTILS_H__
|
||||
|
||||
namespace msm_gbm {
|
||||
|
||||
// Adreno Pixel Formats
|
||||
typedef enum {
|
||||
ADRENO_PIXELFORMAT_UNKNOWN = 0,
|
||||
ADRENO_PIXELFORMAT_R32G32B32A32_FLOAT = 2,
|
||||
ADRENO_PIXELFORMAT_R32G32B32_FLOAT = 6,
|
||||
ADRENO_PIXELFORMAT_R16G16B16A16_FLOAT = 10,
|
||||
ADRENO_PIXELFORMAT_R10G10B10A2_UNORM = 24, // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES
|
||||
ADRENO_PIXELFORMAT_R8G8B8A8 = 28,
|
||||
ADRENO_PIXELFORMAT_R8G8B8A8_SRGB = 29,
|
||||
ADRENO_PIXELFORMAT_R16G16_UNORM = 35,
|
||||
ADRENO_PIXELFORMAT_R8G8_UNORM = 49,
|
||||
ADRENO_PIXELFORMAT_R16_UNORM = 56,
|
||||
ADRENO_PIXELFORMAT_R8_UNORM = 61,
|
||||
ADRENO_PIXELFORMAT_B5G6R5 = 85,
|
||||
ADRENO_PIXELFORMAT_B5G5R5A1 = 86,
|
||||
ADRENO_PIXELFORMAT_B8G8R8A8 = 90,
|
||||
ADRENO_PIXELFORMAT_B8G8R8A8_SRGB = 91,
|
||||
ADRENO_PIXELFORMAT_B8G8R8X8_SRGB = 93,
|
||||
ADRENO_PIXELFORMAT_NV12 = 103,
|
||||
ADRENO_PIXELFORMAT_P010 = 104,
|
||||
ADRENO_PIXELFORMAT_YUY2 = 107,
|
||||
ADRENO_PIXELFORMAT_B4G4R4A4 = 115,
|
||||
ADRENO_PIXELFORMAT_NV12_EXT = 506, // NV12 with non-std alignment and offsets
|
||||
ADRENO_PIXELFORMAT_R8G8B8X8 = 507, // GL_RGB8 (Internal)
|
||||
ADRENO_PIXELFORMAT_R8G8B8 = 508, // GL_RGB8
|
||||
ADRENO_PIXELFORMAT_A1B5G5R5 = 519, // GL_RGB5_A1
|
||||
ADRENO_PIXELFORMAT_R8G8B8X8_SRGB = 520, // GL_SRGB8
|
||||
ADRENO_PIXELFORMAT_R8G8B8_SRGB = 521, // GL_SRGB8
|
||||
ADRENO_PIXELFORMAT_R16G16B16_FLOAT = 523,
|
||||
ADRENO_PIXELFORMAT_R5G6B5 = 610, // RGBA version of B5G6R5
|
||||
ADRENO_PIXELFORMAT_R5G5B5A1 = 611, // RGBA version of B5G5R5A1
|
||||
ADRENO_PIXELFORMAT_R4G4B4A4 = 612, // RGBA version of B4G4R4A4
|
||||
ADRENO_PIXELFORMAT_UYVY = 614, // YUV 4:2:2 packed progressive (1 plane)
|
||||
ADRENO_PIXELFORMAT_NV21 = 619,
|
||||
ADRENO_PIXELFORMAT_Y8U8V8A8 = 620, // YUV 4:4:4 packed (1 plane)
|
||||
ADRENO_PIXELFORMAT_Y8 = 625, // Single 8-bit luma only channel YUV format
|
||||
ADRENO_PIXELFORMAT_TP10 = 654, // YUV 4:2:0 planar 10 bits/comp (2 planes)
|
||||
} ADRENOPIXELFORMAT;
|
||||
|
||||
class adreno_mem_info {
|
||||
public:
|
||||
bool init();
|
||||
adreno_mem_info();
|
||||
~adreno_mem_info();
|
||||
|
||||
/**
|
||||
* Function to compute the adreno aligned width and aligned height
|
||||
* based on the width and format.
|
||||
*
|
||||
* @return aligned width, aligned height
|
||||
*/
|
||||
void get_aligned_wdth_hght_uncmprsd_rgb_fmt(int width, int height, int format, int tileEnabled,
|
||||
unsigned int *aligned_w, unsigned int *aligned_h);
|
||||
|
||||
/**
|
||||
* Function to compute the adreno aligned width and aligned height
|
||||
* based on the width and format.
|
||||
*
|
||||
* @return aligned width, aligned height
|
||||
*/
|
||||
void get_aligned_wdth_hght_cmprsd_rgb_fmt(int width, int height, int format, unsigned int *aligned_w,
|
||||
unsigned int *aligned_h);
|
||||
|
||||
/**
|
||||
* Function to compute the pixel alignment requirement.
|
||||
*
|
||||
* @return alignment
|
||||
*/
|
||||
unsigned int get_gpu_pxl_align();
|
||||
|
||||
/**
|
||||
* Function to return whether GPU support MacroTile feature
|
||||
*
|
||||
* @return >0 : supported
|
||||
* 0 : not supported
|
||||
*/
|
||||
bool is_mcro_tiling_supported();
|
||||
|
||||
/**
|
||||
* Function to query whether GPU supports UBWC for given GBM format
|
||||
* @return > 0 : supported
|
||||
* 0 : not supported
|
||||
*/
|
||||
bool is_ubwc_supported_gpu(unsigned int gbm_format);
|
||||
|
||||
/**
|
||||
* Function to get the corresponding Adreno format for given GBM format
|
||||
*/
|
||||
ADRENOPIXELFORMAT get_gpu_pxl_fmt(unsigned int gbm_format);
|
||||
|
||||
private:
|
||||
// link(s)to adreno surface padding library.
|
||||
int (*LINK_adreno_compute_padding)(int width, int bpp, int surface_tile_height,
|
||||
int screen_tile_height, int padding_threshold) = NULL;
|
||||
void (*LINK_adreno_compute_fmt_aligned_width_and_height)(int width, int height, int plane_id,
|
||||
ADRENOPIXELFORMAT format, int num_samples,
|
||||
int tile_mode, int raster_mode,
|
||||
int padding_threshold, int *aligned_w,
|
||||
int *aligned_h) = NULL;
|
||||
int (*LINK_adreno_is_mcro_tile_supportd_gpu)(void) = NULL;
|
||||
void (*LINK_adreno_compute_compressedfmt_aligned_width_and_height)(
|
||||
int width, int height, int format, int tile_mode, int raster_mode, int padding_threshold,
|
||||
int *aligned_w, int *aligned_h, int *bpp) = NULL;
|
||||
int (*LINK_adreno_is_ubwc_supportd_gpu)(ADRENOPIXELFORMAT format) = NULL;
|
||||
unsigned int (*LINK_adreno_get_gpu_pixel_alignment)() = NULL;
|
||||
|
||||
bool gfx_ubwc_disable_ = false;
|
||||
bool map_fb_ = false;
|
||||
void *libadreno_utils_ = NULL;
|
||||
};
|
||||
|
||||
} // namespace msm_gbm
|
||||
|
||||
#endif // __MSMGBM_ADRENO_UTILS_H__
|
59
qcom/opensource/display/libgbm/inc/msmgbm_common.h
Normal file
59
qcom/opensource/display/libgbm/inc/msmgbm_common.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MSMGBM_COMMON_H_
|
||||
#define MSMGBM_COMMON_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool IsImplDefinedFormat(uint32_t format);
|
||||
uint32_t GetImplDefinedFormat(uint32_t usage_flags, uint32_t format);
|
||||
uint32_t GetIonAllocFlags(uint32_t alloc_flags);
|
||||
uint32_t GetIonHeapId(uint32_t alloc_flags);
|
||||
|
||||
/*camera specific functions*/
|
||||
uint32_t GetCameraImplDefinedFormat(uint32_t usage_flags, uint32_t format);
|
||||
uint32_t GetCameraIonAllocFlags(uint32_t alloc_flags);
|
||||
uint32_t GetCameraIonHeapId(uint32_t alloc_flags);
|
||||
|
||||
/*video specific functions*/
|
||||
uint32_t GetVideoImplDefinedFormat(uint32_t usage_flags, uint32_t format);
|
||||
uint32_t GetVideoIonAllocFlags(uint32_t alloc_flags);
|
||||
uint32_t GetVideoIonHeapId(uint32_t alloc_flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //MSMGBM_COMMON_H_
|
119
qcom/opensource/display/libgbm/inc/msmgbm_mapper.h
Normal file
119
qcom/opensource/display/libgbm/inc/msmgbm_mapper.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __MSMGBM_MAPPER_H__
|
||||
#define __MSMGBM_MAPPER_H__
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <cstdio>
|
||||
#include <pthread.h>
|
||||
#include "gbm_priv.h"
|
||||
#include "msmgbm.h"
|
||||
|
||||
namespace msm_gbm {
|
||||
|
||||
class msmgbm_mapper {
|
||||
public:
|
||||
msmgbm_mapper();
|
||||
~msmgbm_mapper();
|
||||
bool init();
|
||||
|
||||
//Structure definition to maintain hash table on a per process basis
|
||||
//to manage metadata.
|
||||
struct msmgbm_buffer {
|
||||
int ion_fd;
|
||||
int ion_metadata_fd;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
int ref_count=0;
|
||||
void *cpuaddr = NULL;
|
||||
void *mt_cpuaddr = NULL;
|
||||
|
||||
explicit msmgbm_buffer(int fd, int mtadta_fd, uint32_t wdth, uint32_t hght, uint32_t fmt,
|
||||
void *cpu_addr, void *mt_cpu_addr):
|
||||
ion_fd(fd),
|
||||
ion_metadata_fd(mtadta_fd),
|
||||
width(wdth),
|
||||
height(hght),
|
||||
format(fmt),
|
||||
cpuaddr(cpu_addr),
|
||||
mt_cpuaddr(mt_cpu_addr) {
|
||||
}
|
||||
|
||||
void IncRef() {++ref_count;}
|
||||
int DecRef() {return --ref_count == 0;}
|
||||
};
|
||||
|
||||
std::unordered_map<int, std::shared_ptr<msmgbm_buffer>>gbm_buf_map_;
|
||||
|
||||
struct gem_handle_key {
|
||||
int device_fd;
|
||||
uint32_t handle;
|
||||
gem_handle_key(int device_fd, uint32_t handle) : device_fd(device_fd), handle(handle){}
|
||||
};
|
||||
|
||||
struct HashFunc {
|
||||
std::size_t operator()(const gem_handle_key &key) const
|
||||
{
|
||||
using std::size_t;
|
||||
using std::hash;
|
||||
|
||||
return ((hash<int>()(key.device_fd)
|
||||
^ (hash<uint32_t>()(key.handle) << 1)) >> 1);
|
||||
}
|
||||
};
|
||||
struct EqualKey {
|
||||
bool operator () (const gem_handle_key &key1, const gem_handle_key &key2) const
|
||||
{
|
||||
return key1.device_fd == key2.device_fd && key1.handle == key2.handle;
|
||||
}
|
||||
};
|
||||
|
||||
std::unordered_map<gem_handle_key, int, HashFunc, EqualKey>gem_object_map_;
|
||||
void register_to_map(int ion_fd, struct gbm_buf_info * gbm_buf,
|
||||
struct msmgbm_private_info * gbo_private_info);
|
||||
int search_map(int ion_fd, struct gbm_buf_info * gbm_buf,
|
||||
struct msmgbm_private_info * gbo_private_info);
|
||||
int update_map(int ion_fd, struct gbm_buf_info * gbm_buf,
|
||||
struct msmgbm_private_info * gbo_private_info);
|
||||
void map_dump(void);
|
||||
void add_map_entry(int ion_fd);
|
||||
int del_map_entry(int ion_fd);
|
||||
void incr_handle_refcnt(int device_fd, uint32_t handle);
|
||||
int decr_handle_refcnt(int device_fd, uint32_t handle);
|
||||
|
||||
};
|
||||
|
||||
} // namespace msm_gbm
|
||||
|
||||
#endif // __MSMGBM_MAPPER_H__
|
360
qcom/opensource/display/libgbm/inc/msmgbm_platform_wrapper.h
Normal file
360
qcom/opensource/display/libgbm/inc/msmgbm_platform_wrapper.h
Normal file
@@ -0,0 +1,360 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Changes from Qualcomm Innovation Center are provided under the following license:
|
||||
*
|
||||
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted (subject to the limitations in the
|
||||
* disclaimer below) provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
|
||||
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
|
||||
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __MSMGBM_PFM_WRP_H__
|
||||
#define __MSMGBM_PFM_WRP_H__
|
||||
|
||||
#include "msmgbm_adreno_utils.h"
|
||||
#include "gbm_priv.h"
|
||||
#include "msmgbm.h"
|
||||
#include <linux/version.h>
|
||||
|
||||
#ifdef VENUS_COLOR_FORMAT
|
||||
#include <display/media/mmm_color_fmt.h>
|
||||
#else
|
||||
#define VENUS_Y_STRIDE(args...) 0
|
||||
#define VENUS_Y_SCANLINES(args...) 0
|
||||
#define VENUS_BUFFER_SIZE(args...) 0
|
||||
#endif
|
||||
|
||||
namespace msm_gbm {
|
||||
/**
|
||||
* Function to query if CPU access usage flags are set
|
||||
* @return : true/false
|
||||
*
|
||||
*/
|
||||
bool cpu_can_accss(int prod_usage, int cons_usage);
|
||||
/**
|
||||
* Helper function to query if CPU access usage flags are set
|
||||
* @return : true/false
|
||||
*
|
||||
*/
|
||||
bool cpu_can_rd(int prod_usage, int cons_usage);
|
||||
/**
|
||||
* Helper function to query if CPU access usage flags are set
|
||||
* @return : true/false
|
||||
*
|
||||
*/
|
||||
bool cpu_can_wr(int prod_usage);
|
||||
/**
|
||||
* Function to query bpp depending on format
|
||||
* @return : bpp value
|
||||
*
|
||||
*/
|
||||
uint32_t get_bpp_for_uncmprsd_rgb_fmt(int format) ;
|
||||
|
||||
class platform_wrap {
|
||||
public:
|
||||
platform_wrap();
|
||||
~platform_wrap();
|
||||
|
||||
/**
|
||||
* Function to Initialize the platform wrapper object
|
||||
* @return true/
|
||||
* false
|
||||
*/
|
||||
bool init(void);
|
||||
/**
|
||||
* Function to query UBWC support
|
||||
* @return true/
|
||||
* false
|
||||
*/
|
||||
bool is_ubwc_enbld(int format, int prod_usage, int cons_usage);
|
||||
/**
|
||||
* Function to query MacroTile support
|
||||
* @return true/
|
||||
* false
|
||||
*/
|
||||
bool is_mcro_tile_enbld(int format, int prod_usage, int cons_usage);
|
||||
/**
|
||||
* Function to query the UBWC Enabled Buffer Size
|
||||
* @return size on success
|
||||
* 0 on fail
|
||||
*/
|
||||
unsigned int get_ubwc_size(int width, int height, int format, unsigned int alignedw, unsigned int alignedh);
|
||||
/**
|
||||
* Helper Function to query the UBWC Enabled Buffer Size
|
||||
* @return size on success
|
||||
* 0 : fail
|
||||
*/
|
||||
unsigned int get_rgb_ubwc_mb_size(int width, int height, uint32_t bpp);
|
||||
/**
|
||||
* Helper Function to query the UBWC Enabled Buffer Size
|
||||
* @return block width and height
|
||||
*/
|
||||
void get_rgb_ubwc_blk_size(uint32_t bpp, int *block_width, int *block_height);
|
||||
/**
|
||||
* Function to query the RGB format support
|
||||
* @return true : success
|
||||
* false : fail
|
||||
*/
|
||||
int is_valid_rgb_fmt(int gbm_format);
|
||||
|
||||
/**
|
||||
* Function to check whether the format is RAW
|
||||
* @params gbm format
|
||||
* @return true : success
|
||||
* false : fail
|
||||
*
|
||||
*/
|
||||
bool is_valid_raw_fmt(int format);
|
||||
|
||||
uint32_t get_bpp_for_uncmprsd_rgb_fmt(int format);
|
||||
|
||||
/**
|
||||
* Function to check whether the format is uncompressed RGB
|
||||
* @params gbm format
|
||||
* @return boolean 0 (compressed RGB format)
|
||||
* 1 (uncompressed RGB format)
|
||||
*
|
||||
*/
|
||||
bool is_valid_uncmprsd_rgb_fmt(int format);
|
||||
|
||||
/**
|
||||
* Function to check whether the format is uncompressed RGB
|
||||
* @params gbm format
|
||||
* @return boolean 0 (uncompressed RGB format)
|
||||
* 1 (compressed RGB format)
|
||||
*
|
||||
*/
|
||||
bool is_valid_cmprsd_rgb_fmt(int format);
|
||||
|
||||
/**
|
||||
* Function to check whether the format is yuv format
|
||||
* @params gbm format
|
||||
* @return true : success
|
||||
* false : fail
|
||||
*
|
||||
*/
|
||||
bool is_valid_yuv_fmt(int format);
|
||||
|
||||
/**
|
||||
* Function to query UBWC feature support
|
||||
* @return true : success
|
||||
* false : fail
|
||||
*/
|
||||
bool is_ubwc_support_enbld(int format);
|
||||
/**
|
||||
* Function to query UBWC enabled format support
|
||||
* @return true : success
|
||||
* false : fail
|
||||
*/
|
||||
bool is_valid_ubwc_fmt(int format);
|
||||
/**
|
||||
* Function to get aligned width and height depending on the underlying GPU/Video platform
|
||||
* @return aligned_w
|
||||
* aligned_h
|
||||
*/
|
||||
void get_aligned_wdth_hght(gbm_bufdesc *descriptor, unsigned int *aligned_w,
|
||||
unsigned int *aligned_h);
|
||||
|
||||
/**
|
||||
* Function to get stride, scanline and size depending on the underlying GPU/Video platform
|
||||
* @return stride
|
||||
* scanline
|
||||
* size
|
||||
*/
|
||||
void get_stride_scanline_size(gbm_bufdesc *descriptor, unsigned int *stride,
|
||||
unsigned int *scanline, unsigned int *size);
|
||||
|
||||
/**
|
||||
* Function to get size aligned width and height depending on the underlying GPU/Video platform
|
||||
* @params gbm format
|
||||
* width of the buffer
|
||||
* height of the buffer
|
||||
* usage flags
|
||||
* aligned height
|
||||
* aligned weight
|
||||
* @return size of the buffer
|
||||
*/
|
||||
unsigned int get_size(int format, int width, int height, int usage,
|
||||
int alignedw, int alignedh);
|
||||
|
||||
/**
|
||||
* Function to get aligned width and height for YUV format
|
||||
* @params gbm format
|
||||
* width of the buffer
|
||||
* height of the buffer
|
||||
* @return aligned height
|
||||
* aligned weight
|
||||
*
|
||||
*/
|
||||
void get_yuv_ubwc_wdth_hght(int width, int height, int format,
|
||||
unsigned int *aligned_w, unsigned int *aligned_h);
|
||||
|
||||
private:
|
||||
bool gpu_support_macrotile = false;
|
||||
bool display_support_macrotile = false;
|
||||
adreno_mem_info *adreno_helper_ = NULL;
|
||||
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
/**
|
||||
* C wrapper Function to get aligned width and height depending on the underlying GPU/Video platform
|
||||
* @return aligned_w
|
||||
* aligned_h
|
||||
*/
|
||||
void qry_aligned_wdth_hght(gbm_bufdesc *descriptor, unsigned int *alignedw, unsigned int *alignedh);
|
||||
|
||||
/**
|
||||
* C wrapper Function to get stride, scanline and size depending on the underlying GPU/Video platform
|
||||
* @return stride
|
||||
* scanline
|
||||
* size
|
||||
*/
|
||||
void qry_stride_scanline_size(gbm_bufdesc *descriptor, unsigned int *stride,
|
||||
unsigned int *scanline, unsigned int *size);
|
||||
|
||||
/**
|
||||
* C wrapper Function to query size based on format from the platform wrapper
|
||||
* @return : size
|
||||
*
|
||||
*/
|
||||
unsigned int qry_size(gbm_bufdesc *desc, unsigned int alignedw, unsigned int alignedh);
|
||||
|
||||
/**
|
||||
* C wrapper Function to check whether the format is UBWC or not.
|
||||
* @params gbm format
|
||||
* @return boolean 0 (non UBWC format)
|
||||
* 1 (UBWC format)
|
||||
*/
|
||||
bool is_valid_ubwc_format(int format);
|
||||
|
||||
/**
|
||||
* Function to return bytes per pixel for a given uncompressed RGB format
|
||||
* @params uncompressed RGB gbm format
|
||||
* @return bytes per pixel
|
||||
*
|
||||
*/
|
||||
uint32_t get_bpp_for_uncmprsd_rgb_format(int format);
|
||||
|
||||
/**
|
||||
* Function to return bytes needed to represent UBWC RGB Metabuffer
|
||||
* @params RGB gbm format
|
||||
* @return size of UBWC RGB meta buffer
|
||||
*
|
||||
*/
|
||||
uint32_t get_rgb_ubwc_metabuffer_size(int width, int height, int bpp);
|
||||
|
||||
/**
|
||||
* C wrapper Function to check whether the format is uncompressed RGB format or not.
|
||||
* @params gbm format
|
||||
* @return boolean 0 (compressed RGB format)
|
||||
* 1 (uncompressed RGB format)
|
||||
*/
|
||||
bool is_valid_uncmprsd_rgb_format(int format);
|
||||
|
||||
/**
|
||||
* C wrapper Function to check whether the format is uncompressed RGB format or not.
|
||||
* @params gbm format
|
||||
* @return boolean 0 (uncompressed RGB format)
|
||||
* 1 (compressed RGB format)
|
||||
*/
|
||||
bool is_valid_cmprsd_rgb_format(int format);
|
||||
|
||||
/**
|
||||
* C wrapper Function to check whether the format is yuv format or not.
|
||||
* @params gbm format
|
||||
* @return boolean 0 (non yuv format)
|
||||
* 1 (yuv format)
|
||||
*/
|
||||
bool is_valid_yuv_format(int format);
|
||||
|
||||
/**
|
||||
* C wrapper function to know if the format is UBWC
|
||||
*/
|
||||
bool is_ubwc_enbld(int format, int prod_usage,
|
||||
int cons_usage);
|
||||
|
||||
/**
|
||||
* C wrapper Function to check whether the format is RAW format or not.
|
||||
* @params gbm format
|
||||
* @return boolean 0 (non RAW format)
|
||||
* 1 (RAW format)
|
||||
*/
|
||||
bool is_valid_raw_format(int format);
|
||||
|
||||
/**
|
||||
* C wrapper function to know if the format is RGB
|
||||
*/
|
||||
bool is_valid_rgb_fmt(int format);
|
||||
/**
|
||||
* C wrapper Function to delete platform wrapper object
|
||||
* @return : None
|
||||
*
|
||||
*/
|
||||
void platform_wrap_deinstnce(void);
|
||||
|
||||
/**
|
||||
* C wrapper Function to create a cpp object of platform wrapper class
|
||||
* @return 0 : success
|
||||
* 1 : failure
|
||||
*/
|
||||
bool platform_wrap_instnce(void);
|
||||
|
||||
}
|
||||
|
||||
} // namespace msm_gbm
|
||||
|
||||
#endif // __MSMGBM_PFM_WRP_H__
|
791
qcom/opensource/display/libgbm/src/gbm.c
Normal file
791
qcom/opensource/display/libgbm/src/gbm.c
Normal file
@@ -0,0 +1,791 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Copyright © 2011 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Benjamin Franzke <benjaminfranzke@googlemail.com>
|
||||
*
|
||||
* Changes from Qualcomm Innovation Center are provided under the following license:
|
||||
*
|
||||
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <gbm.h>
|
||||
#include <gbm_priv.h>
|
||||
#include <errno.h>
|
||||
|
||||
/** Returns the file description for the gbm device
|
||||
*
|
||||
* \return The fd that the struct gbm_device was created with
|
||||
*/
|
||||
int
|
||||
gbm_device_get_fd(struct gbm_device *gbm_dev)
|
||||
{
|
||||
if(gbm_dev!=NULL){
|
||||
return gbm_dev->fd;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid device pointer\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the backend name for the given gbm device
|
||||
*
|
||||
* \return The backend name string - this belongs to the device and must not
|
||||
* be freed
|
||||
*/
|
||||
const char *
|
||||
gbm_device_get_backend_name(struct gbm_device *gbm_dev)
|
||||
{
|
||||
if(gbm_dev!=NULL){
|
||||
return gbm_dev->name;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid device pointer\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** Test if a format is supported for a given set of usage flags.
|
||||
*
|
||||
* \param gbm The created buffer manager
|
||||
* \param format The format to test
|
||||
* \param usage A bitmask of the usages to test the format against
|
||||
* \return 1 if the format is supported otherwise 0
|
||||
*
|
||||
* \sa enum gbm_bo_flags for the list of flags that the format can be
|
||||
* tested against
|
||||
*
|
||||
* \sa enum gbm_bo_format for the list of formats
|
||||
*/
|
||||
int
|
||||
gbm_device_is_format_supported(struct gbm_device *gbm_dev,
|
||||
unsigned int format, unsigned int usage)
|
||||
{
|
||||
if(gbm_dev!=NULL){
|
||||
return gbm_dev->is_format_supported(gbm_dev, format,usage);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid device pointer\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
gbm_device_get_format_modifier_plane_count(struct gbm_device *gbm,
|
||||
uint32_t format,
|
||||
uint64_t modifier)
|
||||
{
|
||||
return gbm->get_format_modifier_plane_count(format, modifier);
|
||||
}
|
||||
|
||||
/** Destroy the gbm device and free all resources associated with it.
|
||||
*
|
||||
* \param gbm The device created using gbm_create_device()
|
||||
*/
|
||||
void
|
||||
gbm_device_destroy(struct gbm_device *gbm_dev)
|
||||
{
|
||||
if(gbm_dev!=NULL)
|
||||
{
|
||||
gbm_dev->refcount--;
|
||||
if (gbm_dev->refcount == 0) {
|
||||
return gbm_dev->destroy(gbm_dev);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid device pointer\n",__func__,__LINE__);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
/** Create a gbm device for allocating buffers
|
||||
*
|
||||
* The file descriptor passed in is used by the backend to communicate with
|
||||
* platform for allocating the memory. For allocations using DRI this would be
|
||||
* the file descriptor returned when opening a device such as \c
|
||||
* /dev/dri/card0
|
||||
*
|
||||
* \param fd The file descriptor for an backend specific device
|
||||
* \return The newly created struct gbm_device. The resources associated with
|
||||
* the device should be freed with gbm_device_destroy() when it is no longer
|
||||
* needed. If the creation of the device failed NULL will be returned.
|
||||
*/
|
||||
struct gbm_device *
|
||||
gbm_create_device(int fd)
|
||||
{
|
||||
struct gbm_backendpriv *backend =NULL;
|
||||
struct gbm_device *gbm_dev =NULL;
|
||||
backend = gbm_get_priv();
|
||||
|
||||
if(backend == NULL) {
|
||||
fprintf(stderr,"%s(%d): No backend found, Device creation failed\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fd <= 0){
|
||||
fprintf(stderr,"%s(%d): Inavid file descriptor (%d)\n",__func__,__LINE__,fd);
|
||||
}
|
||||
|
||||
gbm_dev = backend->create_device(fd);
|
||||
if(gbm_dev == NULL)
|
||||
{
|
||||
fprintf(stderr,"%s(%d): Device creation failed\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gbm_dev->refcount = 1;
|
||||
gbm_dev->fd = fd;
|
||||
|
||||
if(backend->backend_name != NULL){
|
||||
gbm_dev->name = backend->backend_name;
|
||||
fprintf(stderr,"%s(%d): Info: backend name is: %s\n",__func__,__LINE__,gbm_dev->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
gbm_dev->name = NULL;
|
||||
fprintf(stderr,"%s(%d): Info: backend name is null\n",__func__,__LINE__);
|
||||
}
|
||||
|
||||
return gbm_dev;
|
||||
}
|
||||
|
||||
/** Get the width of the buffer object
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return The width of the allocated buffer object
|
||||
*
|
||||
*/
|
||||
unsigned int
|
||||
gbm_bo_get_width(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->width;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the height of the buffer object
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return The height of the allocated buffer object
|
||||
*/
|
||||
unsigned int
|
||||
gbm_bo_get_height(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->height;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the stride of the buffer object
|
||||
*
|
||||
* This is calculated by the backend when it does the allocation in
|
||||
* gbm_bo_create()
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return The stride of the allocated buffer object in bytes
|
||||
*/
|
||||
unsigned int
|
||||
gbm_bo_get_stride(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
if(bo->usage_flags & GBM_BO_USAGE_UBWC_ALIGNED_QTI){
|
||||
return bo->stride_for_plane(1, bo);
|
||||
} else {
|
||||
return bo->stride_for_plane(0, bo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the stride for the given plane
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \param plane for which you want the stride
|
||||
*
|
||||
* \sa gbm_bo_get_stride()
|
||||
*/
|
||||
uint32_t
|
||||
gbm_bo_get_stride_for_plane(struct gbm_bo *bo, int plane)
|
||||
{
|
||||
if (!bo){
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
if (plane >= MAX_NUM_OF_PLANES) {
|
||||
fprintf(stderr,"%s(%d): invalid plane \n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return bo->stride_for_plane(plane, bo);
|
||||
}
|
||||
|
||||
/** Get the format of the buffer object
|
||||
*
|
||||
* The format of the pixels in the buffer.
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return The format of buffer object, on of the GBM_FORMAT_* codes
|
||||
*/
|
||||
unsigned int
|
||||
gbm_bo_get_format(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->format;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_bpp(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->bpp;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_offset(struct gbm_bo *bo, int plane)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
if (plane <= MAX_NUM_OF_PLANES-1) {
|
||||
return bo->buf_lyt.planes[plane].offset;
|
||||
} else {
|
||||
fprintf(stderr,"%s(%d): invalid plane \n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the handle of the buffer object
|
||||
*
|
||||
* This is stored in the platform generic union gbm_bo_handle type. However
|
||||
* the format of this handle is platform specific.
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return Returns the handle of the allocated buffer object
|
||||
*/
|
||||
union gbm_bo_handle
|
||||
gbm_bo_get_handle(struct gbm_bo *bo)
|
||||
{
|
||||
return bo->handle;
|
||||
}
|
||||
|
||||
/** Returns the file description of the buffer object
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return Returns a file descriptor referring to the underlying buffer
|
||||
*/
|
||||
int
|
||||
gbm_bo_get_fd(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->bo_get_fd(bo);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t
|
||||
gbm_bo_get_modifier(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->modifier;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
gbm_bo_get_plane_count(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return (int)(bo->plane_count);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
union gbm_bo_handle
|
||||
gbm_bo_get_handle_for_plane(struct gbm_bo *bo, int plane)
|
||||
{
|
||||
union gbm_bo_handle handle;
|
||||
if(bo!=NULL){
|
||||
if (plane <= MAX_NUM_OF_PLANES) {
|
||||
return handle;
|
||||
} else {
|
||||
return (handle);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
||||
/** Write data into the buffer object
|
||||
*
|
||||
* If the buffer object was created with the GBM_BO_USE_WRITE flag,
|
||||
* this function can used to write data into the buffer object. The
|
||||
* data is copied directly into the object and it's the responsiblity
|
||||
* of the caller to make sure the data represents valid pixel data,
|
||||
* according to the width, height, stride and format of the buffer object.
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \param buf The data to write
|
||||
* \param count The number of bytes to write
|
||||
* \return Returns -1 on error, 0 otherwise
|
||||
*/
|
||||
int
|
||||
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->bo_write(bo,buf,count);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the gbm device used to create the buffer object
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return Returns the gbm device with which the buffer object was created
|
||||
*/
|
||||
struct gbm_device *
|
||||
gbm_bo_get_device(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->bo_get_device(bo);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the user data associated with a buffer object
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \param data The data to associate to the buffer object
|
||||
* \param destroy_user_data A callback (which may be %NULL) that will be
|
||||
* called prior to the buffer destruction
|
||||
*/
|
||||
void
|
||||
gbm_bo_set_user_data(struct gbm_bo *bo, void *data,
|
||||
void (*destroy_user_data)(struct gbm_bo *, void *))
|
||||
{
|
||||
if(bo!=NULL) {
|
||||
bo->user_data = data;
|
||||
bo->destroy_user_data = destroy_user_data;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/** Get the user data associated with a buffer object
|
||||
*
|
||||
* \param bo The buffer object
|
||||
* \return Returns the user data associated with the buffer object or %NULL
|
||||
* if no data was associated with it
|
||||
*
|
||||
* \sa gbm_bo_set_user_data()
|
||||
*/
|
||||
void *
|
||||
gbm_bo_get_user_data(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
return bo->user_data;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the given buffer object and frees all resources associated with
|
||||
* it.
|
||||
*
|
||||
* \param bo The buffer object
|
||||
*/
|
||||
void
|
||||
gbm_bo_destroy(struct gbm_bo *bo)
|
||||
{
|
||||
if(bo!=NULL){
|
||||
if (bo->destroy_user_data) {
|
||||
bo->destroy_user_data(bo, bo->user_data);
|
||||
}
|
||||
|
||||
bo->bo_destroy(bo);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid bo pointer\n",__func__,__LINE__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a buffer object for the given dimensions
|
||||
*
|
||||
* \param gbm The gbm device returned from gbm_create_device()
|
||||
* \param width The width for the buffer
|
||||
* \param height The height for the buffer
|
||||
* \param format The format to use for the buffer
|
||||
* \param usage The union of the usage flags for this buffer
|
||||
*
|
||||
* \return A newly allocated buffer that should be freed with gbm_bo_destroy()
|
||||
* when no longer needed. If an error occurs during allocation %NULL will be
|
||||
* returned.
|
||||
*
|
||||
* \sa enum gbm_bo_format for the list of formats
|
||||
* \sa enum gbm_bo_flags for the list of usage flags
|
||||
*/
|
||||
struct gbm_bo *
|
||||
gbm_bo_create(struct gbm_device *gbm_dev,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t usage)
|
||||
{
|
||||
if (width == 0 || height == 0){
|
||||
errno = EINVAL;
|
||||
fprintf(stderr,"%s(%d): width(%d) or height(%d) value\n",__func__,__LINE__,width,height);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(gbm_dev!=NULL){
|
||||
return gbm_dev->bo_create(gbm_dev,width,height,format,usage, NULL, 0);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid device pointer\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_bo_create_with_modifiers(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format,
|
||||
const uint64_t *modifiers,
|
||||
const unsigned int count)
|
||||
{
|
||||
if (width == 0 || height == 0) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((count && !modifiers) || (modifiers && !count)) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
if(gbm!=NULL){
|
||||
return gbm->bo_create(gbm,width,height,format, 0, modifiers, count);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid device pointer\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a gbm buffer object from an foreign object
|
||||
*
|
||||
* This function imports a foreign object and creates a new gbm bo for it.
|
||||
* This enabled using the foreign object with a display API such as KMS.
|
||||
* Currently two types of foreign objects are supported, indicated by the type
|
||||
* argument:
|
||||
*
|
||||
* GBM_BO_IMPORT_WL_BUFFER
|
||||
* GBM_BO_IMPORT_EGL_IMAGE
|
||||
*
|
||||
* The the gbm bo shares the underlying pixels but its life-time is
|
||||
* independent of the foreign object.
|
||||
*
|
||||
* \param gbm The gbm device returned from gbm_create_device()
|
||||
* \param gbm The type of object we're importing
|
||||
* \param gbm Pointer to the external object
|
||||
* \param usage The union of the usage flags for this buffer
|
||||
*
|
||||
* \return A newly allocated buffer object that should be freed with
|
||||
* gbm_bo_destroy() when no longer needed.
|
||||
*
|
||||
* \sa enum gbm_bo_flags for the list of usage flags
|
||||
*/
|
||||
struct gbm_bo *
|
||||
gbm_bo_import(struct gbm_device *gbm_dev,
|
||||
uint32_t type, void *buffer, uint32_t usage)
|
||||
{
|
||||
if(gbm_dev!=NULL){
|
||||
return gbm_dev->bo_import(gbm_dev,type,buffer,usage);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid device pointer\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
gbm_bo_map(struct gbm_bo *bo,
|
||||
uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
uint32_t flags, uint32_t *stride, void **map_data){
|
||||
|
||||
bo->bo_map(x, y, width, height, flags, stride, map_data);
|
||||
}
|
||||
|
||||
void
|
||||
gbm_bo_unmap(struct gbm_bo *bo, void *map_data)
|
||||
{
|
||||
if(bo)
|
||||
{
|
||||
bo->bo_unmap(map_data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a surface object
|
||||
*
|
||||
* \param gbm The gbm device returned from gbm_create_device()
|
||||
* \param width The width for the surface
|
||||
* \param height The height for the surface
|
||||
* \param format The format to use for the surface
|
||||
*
|
||||
* \return A newly allocated surface that should be freed with
|
||||
* gbm_surface_destroy() when no longer needed. If an error occurs
|
||||
* during allocation %NULL will be returned.
|
||||
*
|
||||
* \sa enum gbm_bo_format for the list of formats
|
||||
*/
|
||||
struct gbm_surface *
|
||||
gbm_surface_create(struct gbm_device *gbm_dev,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t flags)
|
||||
{
|
||||
if(gbm_dev!=NULL){
|
||||
return gbm_dev->surface_create(gbm_dev,width,height,format,flags, NULL, 0);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid device pointer\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct gbm_surface *
|
||||
gbm_surface_create_with_modifiers(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format,
|
||||
const uint64_t *modifiers,
|
||||
const unsigned int count)
|
||||
{
|
||||
if ((count && !modifiers) || (modifiers && !count)) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return gbm->surface_create(gbm, width, height, format, 0,modifiers,count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the given surface and frees all resources associated with
|
||||
* it.
|
||||
*
|
||||
* All buffers locked with gbm_surface_lock_front_buffer() should be
|
||||
* released prior to calling this function.
|
||||
*
|
||||
* \param surf The surface
|
||||
*/
|
||||
void
|
||||
gbm_surface_destroy(struct gbm_surface *gbm_surf)
|
||||
{
|
||||
if(gbm_surf!=NULL){
|
||||
gbm_surf->surface_destroy(gbm_surf);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid surface pointer\n",__func__,__LINE__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock the surface's current front buffer
|
||||
*
|
||||
* Lock rendering to the surface's current front buffer until it is
|
||||
* released with gbm_surface_release_buffer().
|
||||
*
|
||||
* This function must be called exactly once after calling
|
||||
* eglSwapBuffers. Calling it before any eglSwapBuffer has happened
|
||||
* on the surface or two or more times after eglSwapBuffers is an
|
||||
* error. A new bo representing the new front buffer is returned. On
|
||||
* multiple invocations, all the returned bos must be released in
|
||||
* order to release the actual surface buffer.
|
||||
*
|
||||
* \param surf The surface
|
||||
*
|
||||
* \return A buffer object that should be released with
|
||||
* gbm_surface_release_buffer() when no longer needed. The implementation
|
||||
* is free to reuse buffers released with gbm_surface_release_buffer() so
|
||||
* this bo should not be destroyed using gbm_bo_destroy(). If an error
|
||||
* occurs this function returns %NULL.
|
||||
*/
|
||||
struct gbm_bo *
|
||||
gbm_surface_lock_front_buffer(struct gbm_surface *gbm_surf)
|
||||
{
|
||||
if(gbm_surf!=NULL){
|
||||
return gbm_surf->surface_lock_front_buffer(gbm_surf);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid surface pointer\n",__func__,__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release a locked buffer obtained with gbm_surface_lock_front_buffer()
|
||||
*
|
||||
* Returns the underlying buffer to the gbm surface. Releasing a bo
|
||||
* will typically make gbm_surface_has_free_buffer() return 1 and thus
|
||||
* allow rendering the next frame, but not always. The implementation
|
||||
* may choose to destroy the bo immediately or reuse it, in which case
|
||||
* the user data associated with it is unchanged.
|
||||
*
|
||||
* \param surf The surface
|
||||
* \param bo The buffer object
|
||||
*/
|
||||
void
|
||||
gbm_surface_release_buffer(struct gbm_surface *gbm_surf, struct gbm_bo *bo)
|
||||
{
|
||||
if(gbm_surf != NULL && bo != NULL){
|
||||
gbm_surf->surface_release_buffer(gbm_surf, bo);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid surface pointer\n",__func__,__LINE__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not a surface has free (non-locked) buffers
|
||||
*
|
||||
* Before starting a new frame, the surface must have a buffer
|
||||
* available for rendering. Initially, a gbm surface will have a free
|
||||
* buffer, but after one of more buffers have been locked (\sa
|
||||
* gbm_surface_lock_front_buffer()), the application must check for a
|
||||
* free buffer before rendering.
|
||||
*
|
||||
* If a surface doesn't have a free buffer, the application must
|
||||
* return a buffer to the surface using gbm_surface_release_buffer()
|
||||
* and after that, the application can query for free buffers again.
|
||||
*
|
||||
* \param surf The surface
|
||||
* \return 1 if the surface has free buffers, 0 otherwise
|
||||
*/
|
||||
int
|
||||
gbm_surface_has_free_buffers(struct gbm_surface *gbm_surf)
|
||||
{
|
||||
if(gbm_surf != NULL){
|
||||
return gbm_surf->surface_has_free_buffers(gbm_surf);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"%s(%d): NULL or Invalid surface pointer\n",__func__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the fourcc format name.
|
||||
*
|
||||
* \param desc Caller-provided storage for the format name string.
|
||||
* \return String containing the fourcc of the format.
|
||||
*/
|
||||
char *
|
||||
gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc)
|
||||
{
|
||||
desc->name[0] = gbm_format;
|
||||
desc->name[1] = gbm_format >> 8;
|
||||
desc->name[2] = gbm_format >> 16;
|
||||
desc->name[3] = gbm_format >> 24;
|
||||
desc->name[4] = 0;
|
||||
|
||||
return desc->name;
|
||||
}
|
3586
qcom/opensource/display/libgbm/src/msmgbm.c
Normal file
3586
qcom/opensource/display/libgbm/src/msmgbm.c
Normal file
File diff suppressed because it is too large
Load Diff
269
qcom/opensource/display/libgbm/src/msmgbm_adreno_utils.cpp
Normal file
269
qcom/opensource/display/libgbm/src/msmgbm_adreno_utils.cpp
Normal file
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Not a Contribution.
|
||||
*
|
||||
* Copyright (c) 2017-2018, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
#include <dlfcn.h>
|
||||
#include "msmgbm_adreno_utils.h"
|
||||
#include "gbm_priv.h"
|
||||
#include "msmgbm.h"
|
||||
|
||||
|
||||
#define INT(exp) static_cast<int>(exp)
|
||||
#define UINT(exp) static_cast<unsigned int>(exp)
|
||||
#define ALIGN(x, align) (((x) + ((align)-1)) & ~((align)-1))
|
||||
|
||||
#ifdef GBM_DEBUG
|
||||
#define GBM_DBG_LOG fprintf
|
||||
#else
|
||||
#define GBM_DBG_LOG(...) {}
|
||||
#endif
|
||||
|
||||
namespace msm_gbm {
|
||||
|
||||
adreno_mem_info::adreno_mem_info() {
|
||||
}
|
||||
|
||||
bool adreno_mem_info::init() {
|
||||
dlerror(); //Clear any errors
|
||||
|
||||
libadreno_utils_ = ::dlopen("libadreno_utils.so", RTLD_NOW);
|
||||
if (libadreno_utils_) {
|
||||
*reinterpret_cast<void **>(&LINK_adreno_compute_fmt_aligned_width_and_height) =
|
||||
::dlsym(libadreno_utils_, "compute_fmt_aligned_width_and_height");
|
||||
*reinterpret_cast<void **>(&LINK_adreno_compute_padding) =
|
||||
::dlsym(libadreno_utils_, "compute_surface_padding");
|
||||
*reinterpret_cast<void **>(&LINK_adreno_is_mcro_tile_supportd_gpu) =
|
||||
::dlsym(libadreno_utils_, "isMacroTilingSupportedByGpu");
|
||||
*reinterpret_cast<void **>(&LINK_adreno_compute_compressedfmt_aligned_width_and_height) =
|
||||
::dlsym(libadreno_utils_, "compute_compressedfmt_aligned_width_and_height");
|
||||
*reinterpret_cast<void **>(&LINK_adreno_is_ubwc_supportd_gpu) =
|
||||
::dlsym(libadreno_utils_, "isUBWCSupportedByGpu");
|
||||
*reinterpret_cast<void **>(&LINK_adreno_get_gpu_pixel_alignment) =
|
||||
::dlsym(libadreno_utils_, "get_gpu_pixel_alignment");
|
||||
} else {
|
||||
|
||||
char *error=NULL;
|
||||
if ((error= dlerror()) != NULL)
|
||||
LOG(LOG_ERR, "%s\n", error);
|
||||
LOG(LOG_ERR," Failed to load libadreno_utils.so\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG(LOG_DBG,"adreno_mem_info Success\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
adreno_mem_info::~adreno_mem_info() {
|
||||
if (libadreno_utils_) {
|
||||
LOG(LOG_DBG,"Destroyer\n");
|
||||
::dlclose(libadreno_utils_);
|
||||
}
|
||||
}
|
||||
|
||||
bool adreno_mem_info::is_mcro_tiling_supported() {
|
||||
if (LINK_adreno_is_mcro_tile_supportd_gpu) {
|
||||
LOG(LOG_DBG," func access %p\n",LINK_adreno_is_mcro_tile_supportd_gpu);
|
||||
return LINK_adreno_is_mcro_tile_supportd_gpu();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void adreno_mem_info::get_aligned_wdth_hght_uncmprsd_rgb_fmt(int width,
|
||||
int height, int format, int tile_enabled,unsigned int *aligned_w,
|
||||
unsigned int *aligned_h) {
|
||||
|
||||
*aligned_w = (unsigned int)ALIGN(width, 32);
|
||||
*aligned_h = (unsigned int)ALIGN(height, 32);
|
||||
|
||||
// Don't add any additional padding if debug.gralloc.map_fb_memory
|
||||
// is enabled
|
||||
if (map_fb_) {
|
||||
return;
|
||||
}
|
||||
|
||||
int bpp = 4;
|
||||
|
||||
switch (format) {
|
||||
case GBM_FORMAT_RGBA32323232F:
|
||||
bpp = 16;
|
||||
break;
|
||||
case GBM_FORMAT_RGB323232F:
|
||||
bpp = 12;
|
||||
break;
|
||||
case GBM_FORMAT_RGBA16161616F:
|
||||
bpp = 8;
|
||||
break;
|
||||
case GBM_FORMAT_RGB161616F:
|
||||
bpp = 6;
|
||||
break;
|
||||
case GBM_FORMAT_RGB888:
|
||||
case GBM_FORMAT_BGR888:
|
||||
bpp = 3;
|
||||
break;
|
||||
case GBM_FORMAT_RG88:
|
||||
case GBM_FORMAT_R16:
|
||||
case GBM_FORMAT_RGB565:
|
||||
case GBM_FORMAT_BGR565:
|
||||
case GBM_FORMAT_RGBA5551:
|
||||
case GBM_FORMAT_RGBA4444:
|
||||
bpp = 2;
|
||||
break;
|
||||
case GBM_FORMAT_R8:
|
||||
bpp = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int raster_mode = 0; // Adreno unknown raster mode.
|
||||
int padding_threshold = 512; // Threshold for padding surfaces.
|
||||
// the function below computes aligned width and aligned height
|
||||
// based on linear or macro tile mode selected.
|
||||
|
||||
if (LINK_adreno_compute_fmt_aligned_width_and_height) {
|
||||
|
||||
LOG(LOG_DBG,"Using LINK_adreno_compute_fmt_aligned_width_and_height func:= %p\n",
|
||||
LINK_adreno_compute_fmt_aligned_width_and_height);
|
||||
ADRENOPIXELFORMAT gpu_pixel_format = get_gpu_pxl_fmt(format);
|
||||
if (gpu_pixel_format != ADRENO_PIXELFORMAT_UNKNOWN) {
|
||||
LINK_adreno_compute_fmt_aligned_width_and_height(
|
||||
width, height, 0 /*plane_id*/, gpu_pixel_format, 1 /*num_samples */,
|
||||
tile_enabled, raster_mode, padding_threshold, reinterpret_cast<int *>(aligned_w),
|
||||
reinterpret_cast<int *>(aligned_h));
|
||||
}
|
||||
} else if (LINK_adreno_compute_padding) {
|
||||
int surface_tile_height = 1; // Linear surface
|
||||
LOG(LOG_DBG,"Using LINK_adreno_compute_padding func:= %p\n",LINK_adreno_compute_padding);
|
||||
*aligned_w = UINT(LINK_adreno_compute_padding(width, bpp, surface_tile_height,
|
||||
raster_mode,padding_threshold));
|
||||
LOG(LOG_DBG,"Old GFX API is used to calculate stride\n");
|
||||
|
||||
} else {
|
||||
LOG(LOG_ERR,"Symbols compute_surface_padding and "
|
||||
"compute_aligned_width_and_height not found\n");
|
||||
}
|
||||
}
|
||||
|
||||
void adreno_mem_info::get_aligned_wdth_hght_cmprsd_rgb_fmt(
|
||||
int width, int height, int format, unsigned int *aligned_w,
|
||||
unsigned int *aligned_h) {
|
||||
if (LINK_adreno_compute_compressedfmt_aligned_width_and_height) {
|
||||
int bytesPerPixel = 0;
|
||||
int raster_mode = 0; // Adreno unknown raster mode.
|
||||
int padding_threshold = 512; // Threshold for padding
|
||||
// surfaces.
|
||||
|
||||
LINK_adreno_compute_compressedfmt_aligned_width_and_height(
|
||||
width, height, format, 0, raster_mode, padding_threshold,
|
||||
reinterpret_cast<int *>(aligned_w), reinterpret_cast<int *>(aligned_h), &bytesPerPixel);
|
||||
} else {
|
||||
LOG(LOG_ERR,"compute_compressedfmt_aligned_width_and_height not found");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool adreno_mem_info::is_ubwc_supported_gpu(unsigned int format) {
|
||||
if (!gfx_ubwc_disable_ && LINK_adreno_is_ubwc_supportd_gpu) {
|
||||
ADRENOPIXELFORMAT gpu_format = get_gpu_pxl_fmt(format);
|
||||
return LINK_adreno_is_ubwc_supportd_gpu(gpu_format);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int adreno_mem_info::get_gpu_pxl_align() {
|
||||
if (LINK_adreno_get_gpu_pixel_alignment) {
|
||||
return LINK_adreno_get_gpu_pixel_alignment();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
ADRENOPIXELFORMAT adreno_mem_info::get_gpu_pxl_fmt(unsigned int gbm_format) {
|
||||
|
||||
switch (gbm_format) {
|
||||
case GBM_FORMAT_R8:
|
||||
return ADRENO_PIXELFORMAT_R8_UNORM;
|
||||
case GBM_FORMAT_RG88:
|
||||
return ADRENO_PIXELFORMAT_R8G8_UNORM;
|
||||
case GBM_FORMAT_R16:
|
||||
return ADRENO_PIXELFORMAT_R16_UNORM;
|
||||
case GBM_FORMAT_RG1616:
|
||||
return ADRENO_PIXELFORMAT_R16G16_UNORM;
|
||||
case GBM_FORMAT_BGR888:
|
||||
return ADRENO_PIXELFORMAT_R8G8B8;
|
||||
case GBM_FORMAT_RGBA8888:
|
||||
return ADRENO_PIXELFORMAT_R8G8B8A8;
|
||||
case GBM_FORMAT_XBGR8888:
|
||||
return ADRENO_PIXELFORMAT_R8G8B8X8;
|
||||
case GBM_FORMAT_ABGR8888:
|
||||
return ADRENO_PIXELFORMAT_R8G8B8A8;
|
||||
case GBM_FORMAT_ABGR2101010:
|
||||
return ADRENO_PIXELFORMAT_R10G10B10A2_UNORM;
|
||||
case GBM_FORMAT_RGB565:
|
||||
return ADRENO_PIXELFORMAT_B5G6R5;
|
||||
case GBM_FORMAT_BGR565:
|
||||
return ADRENO_PIXELFORMAT_R5G6B5;
|
||||
case GBM_FORMAT_RGB888:
|
||||
return ADRENO_PIXELFORMAT_R8G8B8;
|
||||
case GBM_FORMAT_NV12_ENCODEABLE:
|
||||
return ADRENO_PIXELFORMAT_NV12;
|
||||
case GBM_FORMAT_UYVY:
|
||||
return ADRENO_PIXELFORMAT_UYVY;
|
||||
case GBM_FORMAT_YCbCr_420_SP_VENUS:
|
||||
case GBM_FORMAT_YCbCr_420_SP_VENUS_UBWC:
|
||||
case GBM_FORMAT_NV12:
|
||||
return ADRENO_PIXELFORMAT_NV12;
|
||||
case GBM_FORMAT_YCbCr_420_TP10_UBWC:
|
||||
return ADRENO_PIXELFORMAT_TP10;
|
||||
case GBM_FORMAT_YCbCr_420_P010_UBWC:
|
||||
return ADRENO_PIXELFORMAT_P010;
|
||||
case GBM_FORMAT_RGB161616F:
|
||||
return ADRENO_PIXELFORMAT_R16G16B16_FLOAT;
|
||||
case GBM_FORMAT_RGB323232F:
|
||||
return ADRENO_PIXELFORMAT_R32G32B32_FLOAT;
|
||||
case GBM_FORMAT_RGBA16161616F:
|
||||
return ADRENO_PIXELFORMAT_R16G16B16A16_FLOAT;
|
||||
case GBM_FORMAT_RGBA32323232F:
|
||||
return ADRENO_PIXELFORMAT_R32G32B32A32_FLOAT;
|
||||
default:
|
||||
LOG(LOG_ERR,":No map for format: 0x%x",gbm_format);
|
||||
break;
|
||||
}
|
||||
|
||||
return ADRENO_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
} // namespace msm_gbm
|
106
qcom/opensource/display/libgbm/src/msmgbm_camera.c
Normal file
106
qcom/opensource/display/libgbm/src/msmgbm_camera.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Not a Contribution.
|
||||
*
|
||||
* Copyright (c) 2018, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <linux/msm_ion.h>
|
||||
#include <linux/ion.h>
|
||||
#include <gbm_priv.h>
|
||||
#include <msmgbm.h>
|
||||
#include <msmgbm_common.h>
|
||||
|
||||
/**
|
||||
* Get the implementaion defined format based on usage flags.
|
||||
* @return - pixel_format to be used for BO
|
||||
* returns input format if none of the combination matches.
|
||||
*/
|
||||
uint32_t GetCameraImplDefinedFormat(uint32_t usage_flags, uint32_t format)
|
||||
{
|
||||
uint32_t pixel_format = format;
|
||||
|
||||
if((usage_flags & GBM_BO_USAGE_CAMERA_READ_QTI) &&
|
||||
(usage_flags & GBM_BO_USAGE_CAMERA_WRITE_QTI)){
|
||||
pixel_format = GBM_FORMAT_NV21_ZSL;
|
||||
}else if(usage_flags & GBM_BO_USAGE_CAMERA_READ_QTI){
|
||||
pixel_format = GBM_FORMAT_YCrCb_420_SP;
|
||||
}else if(usage_flags & GBM_BO_USAGE_CAMERA_WRITE_QTI){
|
||||
if(format == GBM_FORMAT_YCbCr_420_888){
|
||||
pixel_format = GBM_FORMAT_NV21_ZSL;
|
||||
}else{
|
||||
pixel_format = GBM_FORMAT_YCbCr_420_SP_VENUS;
|
||||
}
|
||||
}else if(usage_flags & GBM_BO_USAGE_HW_COMPOSER_QTI){
|
||||
if (GBM_FORMAT_IMPLEMENTATION_DEFINED == format) {
|
||||
pixel_format = GBM_FORMAT_NV12_ENCODEABLE;
|
||||
} else {
|
||||
pixel_format = GBM_FORMAT_RGBA8888;
|
||||
}
|
||||
}
|
||||
|
||||
return pixel_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ion allocation flags based on allocation flags.
|
||||
* @return - ion flags for BO allocation
|
||||
*/
|
||||
uint32_t GetCameraIonAllocFlags(uint32_t alloc_flags)
|
||||
{
|
||||
uint32_t ion_flags = 0;
|
||||
|
||||
if((alloc_flags & GBM_BO_USAGE_PROTECTED_QTI)
|
||||
&& (alloc_flags & GBM_BO_USAGE_CAMERA_WRITE_QTI)){
|
||||
if(alloc_flags & GBM_BO_USAGE_HW_COMPOSER_QTI)
|
||||
ion_flags |= ION_FLAG_CP_CAMERA_PREVIEW;
|
||||
else
|
||||
ion_flags |= ION_FLAG_CP_CAMERA;
|
||||
}
|
||||
|
||||
return ion_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ion heap id based on allocation flags.
|
||||
* @return - ion heap id for BO allocation
|
||||
*/
|
||||
uint32_t GetCameraIonHeapId(uint32_t alloc_flags)
|
||||
{
|
||||
uint32_t ion_heap_id = 0;
|
||||
|
||||
if((alloc_flags & GBM_BO_USAGE_PROTECTED_QTI) &&
|
||||
alloc_flags & GBM_BO_USAGE_CAMERA_WRITE_QTI){
|
||||
ion_heap_id = ION_HEAP(ION_SECURE_DISPLAY_HEAP_ID);
|
||||
}
|
||||
|
||||
return ion_heap_id;
|
||||
}
|
||||
|
158
qcom/opensource/display/libgbm/src/msmgbm_common.c
Normal file
158
qcom/opensource/display/libgbm/src/msmgbm_common.c
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <linux/msm_ion.h>
|
||||
#include <linux/ion.h>
|
||||
#include <gbm_priv.h>
|
||||
#include <msmgbm.h>
|
||||
#include <msmgbm_common.h>
|
||||
|
||||
bool IsImplDefinedFormat(uint32_t format)
|
||||
{
|
||||
if((format == GBM_FORMAT_YCbCr_420_888) ||
|
||||
(format == GBM_FORMAT_IMPLEMENTATION_DEFINED))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t GetDefaultImplDefinedFormat(uint32_t usage_flags, uint32_t format)
|
||||
{
|
||||
uint32_t pixel_format = format;
|
||||
|
||||
if(usage_flags & GBM_BO_USAGE_UBWC_ALIGNED_QTI){
|
||||
pixel_format = GBM_FORMAT_YCbCr_420_SP_VENUS_UBWC;
|
||||
if (usage_flags & GBM_BO_USAGE_10BIT_QTI) {
|
||||
pixel_format = GBM_FORMAT_YCbCr_420_P010_UBWC;
|
||||
} else if (usage_flags & GBM_BO_USAGE_10BIT_TP_QTI) {
|
||||
pixel_format = GBM_FORMAT_YCbCr_420_TP10_UBWC;
|
||||
}
|
||||
} else if (usage_flags & GBM_BO_USAGE_10BIT_QTI) {
|
||||
pixel_format = GBM_FORMAT_YCbCr_420_P010_VENUS;
|
||||
}
|
||||
|
||||
return pixel_format;
|
||||
}
|
||||
|
||||
uint32_t GetImplDefinedFormat(uint32_t usage_flags, uint32_t format)
|
||||
{
|
||||
uint32_t pixel_format = format;
|
||||
|
||||
|
||||
pixel_format = GetDefaultImplDefinedFormat(usage_flags, pixel_format);
|
||||
pixel_format = GetCameraImplDefinedFormat(usage_flags, pixel_format);
|
||||
pixel_format = GetVideoImplDefinedFormat(usage_flags, pixel_format);
|
||||
|
||||
/*default if no valid format is set by camera/video*/
|
||||
if(IsImplDefinedFormat(pixel_format))
|
||||
pixel_format = GBM_FORMAT_NV21_ZSL;
|
||||
|
||||
LOG(LOG_DBG,"%s: format 0x%x\n", __func__, pixel_format);
|
||||
|
||||
return pixel_format;
|
||||
}
|
||||
|
||||
static uint32_t GetDefaultIonAllocFlags(uint32_t alloc_flags)
|
||||
{
|
||||
uint32_t ion_flags = 0;
|
||||
|
||||
/*set heap specific flags*/
|
||||
if(alloc_flags & GBM_BO_ALLOC_SECURE_HEAP_QTI){
|
||||
ion_flags |= ION_FLAG_CP_PIXEL;
|
||||
}else if((alloc_flags & GBM_BO_ALLOC_SECURE_DISPLAY_HEAP_QTI) &&
|
||||
!(alloc_flags & GBM_BO_USAGE_CAMERA_WRITE_QTI)){
|
||||
/*check for secure display*/
|
||||
ion_flags |= ION_FLAG_CP_SEC_DISPLAY;
|
||||
}
|
||||
|
||||
/*check if it is secure allocation*/
|
||||
if(alloc_flags & GBM_BO_USAGE_PROTECTED_QTI){
|
||||
ion_flags |= ION_FLAG_SECURE;
|
||||
}
|
||||
|
||||
/*check if uncached buffer is requested*/
|
||||
if(!(alloc_flags & GBM_BO_USAGE_UNCACHED_QTI)){
|
||||
ion_flags |= ION_FLAG_CACHED;
|
||||
}
|
||||
|
||||
return ion_flags;
|
||||
}
|
||||
|
||||
uint32_t GetIonAllocFlags(uint32_t alloc_flags)
|
||||
{
|
||||
uint32_t ion_flags = 0;
|
||||
|
||||
ion_flags |= GetDefaultIonAllocFlags(alloc_flags);
|
||||
ion_flags |= GetCameraIonAllocFlags(alloc_flags);
|
||||
ion_flags |= GetVideoIonAllocFlags(alloc_flags);
|
||||
|
||||
LOG(LOG_DBG,"%s: ion_flags 0x%x\n", __func__, ion_flags);
|
||||
|
||||
return ion_flags;
|
||||
}
|
||||
|
||||
static uint32_t GetDefaultIonHeapId(uint32_t alloc_flags)
|
||||
{
|
||||
uint32_t ion_heap_id = 0;
|
||||
|
||||
if(alloc_flags & GBM_BO_ALLOC_SECURE_HEAP_QTI){
|
||||
ion_heap_id = ION_HEAP(ION_SECURE_HEAP_ID);
|
||||
}else if(alloc_flags & GBM_BO_ALLOC_SECURE_DISPLAY_HEAP_QTI){
|
||||
ion_heap_id = ION_HEAP(ION_SECURE_DISPLAY_HEAP_ID);
|
||||
}else if(alloc_flags & GBM_BO_ALLOC_ADSP_HEAP_QTI){
|
||||
ion_heap_id = ION_HEAP(ION_ADSP_HEAP_ID);
|
||||
}else if(alloc_flags & GBM_BO_ALLOC_CAMERA_HEAP_QTI){
|
||||
ion_heap_id = ION_HEAP(ION_CAMERA_HEAP_ID);
|
||||
}else if(alloc_flags & GBM_BO_ALLOC_IOMMU_HEAP_QTI){
|
||||
/*IOMMU_HEAP is deprecated, use ION_SYSTEM_HEAP_ID*/
|
||||
ion_heap_id = ION_HEAP(ION_SYSTEM_HEAP_ID);
|
||||
}else if(alloc_flags & GBM_BO_ALLOC_MM_HEAP_QTI){
|
||||
ion_heap_id = ION_HEAP(ION_CP_MM_HEAP_ID);
|
||||
}else{
|
||||
ion_heap_id = ION_HEAP(ION_SYSTEM_HEAP_ID);
|
||||
}
|
||||
|
||||
return ion_heap_id;
|
||||
}
|
||||
|
||||
uint32_t GetIonHeapId(uint32_t alloc_flags)
|
||||
{
|
||||
uint32_t ion_heap_id = 0;
|
||||
|
||||
ion_heap_id |= GetDefaultIonHeapId(alloc_flags);
|
||||
ion_heap_id |= GetCameraIonHeapId(alloc_flags);
|
||||
ion_heap_id |= GetVideoIonHeapId(alloc_flags);
|
||||
|
||||
LOG(LOG_DBG,"%s: ion_heap_id 0x%x\n", __func__, ion_heap_id);
|
||||
|
||||
return ion_heap_id;
|
||||
}
|
2937
qcom/opensource/display/libgbm/src/msmgbm_fb.c
Normal file
2937
qcom/opensource/display/libgbm/src/msmgbm_fb.c
Normal file
File diff suppressed because it is too large
Load Diff
332
qcom/opensource/display/libgbm/src/msmgbm_mapper.cpp
Normal file
332
qcom/opensource/display/libgbm/src/msmgbm_mapper.cpp
Normal file
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "msmgbm_mapper.h"
|
||||
|
||||
namespace msm_gbm {
|
||||
|
||||
extern "C" {
|
||||
|
||||
static msmgbm_mapper *msmgbm_mapper_ = NULL;
|
||||
static unsigned int msmgbm_inst_count_ = 0;
|
||||
static pthread_mutex_t msmgbm_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/**
|
||||
* C wrapper function to create a cpp object of msmgbm mapper class
|
||||
* @input param: None
|
||||
* @return 0 : success
|
||||
* 1 : failure
|
||||
*/
|
||||
bool msmgbm_mapper_instnce(void) {
|
||||
pthread_mutex_lock(&msmgbm_mutex);
|
||||
if (msmgbm_mapper_ == NULL) {
|
||||
msmgbm_mapper_ = new msmgbm_mapper();
|
||||
if (!msmgbm_mapper_->init()) {
|
||||
pthread_mutex_unlock(&msmgbm_mutex);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
msmgbm_inst_count_ ++;
|
||||
pthread_mutex_unlock(&msmgbm_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* C wrapper function to register to the hash map a gbm_buf_info indexed by an ion_fd
|
||||
* @input param: ion_fd , gbm_buf_info object handle
|
||||
* @return : none
|
||||
*/
|
||||
void register_to_hashmap(int fd, struct gbm_buf_info * gbm_buf,
|
||||
struct msmgbm_private_info * gbo_private_info) {
|
||||
msmgbm_mapper_->register_to_map(fd, gbm_buf, gbo_private_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* C wrapper function to search hash map using ion_fd and retrieve the gbm_buf_info
|
||||
* @input param: ion_fd , gbm_buf_info object handle
|
||||
* @return : GBM error status
|
||||
*
|
||||
*/
|
||||
int search_hashmap(int fd, struct gbm_buf_info *buf_info,
|
||||
struct msmgbm_private_info * gbo_private_info) {
|
||||
if(msmgbm_mapper_->search_map(fd,buf_info, gbo_private_info))
|
||||
return GBM_ERROR_NONE;
|
||||
else
|
||||
return GBM_ERROR_BAD_HANDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* C wrapper function to update hash map using ion_fd and retrieve the gbm_buf_info
|
||||
* @input param: ion_fd , gbm_buf_info object handle
|
||||
* @return : GBM error status
|
||||
*
|
||||
*/
|
||||
int update_hashmap(int fd, struct gbm_buf_info *buf_info,
|
||||
struct msmgbm_private_info * gbo_private_info) {
|
||||
if(msmgbm_mapper_->update_map(fd,buf_info, gbo_private_info))
|
||||
return GBM_ERROR_NONE;
|
||||
else
|
||||
return GBM_ERROR_BAD_HANDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* C wrapper function to dump hash map
|
||||
* @input param: void
|
||||
* @return : none
|
||||
*
|
||||
*/
|
||||
void dump_hashmap(void) {
|
||||
msmgbm_mapper_->map_dump();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* C wrapper function to increment the reference count for the valid map entry
|
||||
* @input param: ion_fd
|
||||
* @return : none
|
||||
*
|
||||
*/
|
||||
void incr_refcnt(int fd) {
|
||||
msmgbm_mapper_->add_map_entry(fd);
|
||||
}
|
||||
|
||||
/**
|
||||
* C wrapper function to decrement the reference count for the valid map entry
|
||||
* @input param: ion_fd
|
||||
* @return : 1 for delete map entry /0 for decremented ref count
|
||||
*
|
||||
*/
|
||||
int decr_refcnt(int fd){
|
||||
if (msmgbm_mapper_)
|
||||
return msmgbm_mapper_->del_map_entry(fd);
|
||||
else {
|
||||
LOG(LOG_INFO,"gbm mapper had been de-instantiated\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void incr_handle_refcnt(int device_fd, uint32_t handle) {
|
||||
msmgbm_mapper_->incr_handle_refcnt(device_fd, handle);
|
||||
}
|
||||
|
||||
int decr_handle_refcnt(int device_fd, uint32_t handle){
|
||||
if (msmgbm_mapper_)
|
||||
return msmgbm_mapper_->decr_handle_refcnt(device_fd, handle);
|
||||
else {
|
||||
LOG(LOG_INFO,"gbm mapper had been de-instantiated\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void msmgbm_mapper::incr_handle_refcnt(int device_fd, uint32_t gem_handle) {
|
||||
struct gem_handle_key key(device_fd, gem_handle);
|
||||
auto it = gem_object_map_.find(key);
|
||||
|
||||
if (it != gem_object_map_.end()) {
|
||||
it->second++;
|
||||
} else {
|
||||
gem_object_map_.emplace(std::make_pair(key, 1));
|
||||
}
|
||||
}
|
||||
|
||||
int msmgbm_mapper::decr_handle_refcnt(int device_fd, uint32_t gem_handle) {
|
||||
|
||||
struct gem_handle_key key(device_fd, gem_handle);
|
||||
auto it = gem_object_map_.find(key);
|
||||
if (it != gem_object_map_.end()) {
|
||||
it->second--;
|
||||
if (it->second == 0) {
|
||||
gem_object_map_.erase(key);
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* C wrapper function to delete msmsgbm mapper object
|
||||
* @input param: None
|
||||
* @return : None
|
||||
*
|
||||
*/
|
||||
void msmgbm_mapper_deinstnce(void) {
|
||||
pthread_mutex_lock(&msmgbm_mutex);
|
||||
if (--msmgbm_inst_count_ != 0) {
|
||||
pthread_mutex_unlock(&msmgbm_mutex);
|
||||
return;
|
||||
}
|
||||
if (msmgbm_mapper_) {
|
||||
delete msmgbm_mapper_;
|
||||
msmgbm_mapper_ = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&msmgbm_mutex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
msmgbm_mapper::msmgbm_mapper() {
|
||||
LOG(LOG_INFO,"gbm mapper instantiated\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
msmgbm_mapper::~msmgbm_mapper() {
|
||||
LOG(LOG_INFO,"gbm mapper de-instantiated\n");
|
||||
}
|
||||
|
||||
bool msmgbm_mapper::init() {
|
||||
gbm_buf_map_.clear();
|
||||
gem_object_map_.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to register to the hash map a gbm_buf_info indexed by an ion_fd
|
||||
* @input param: ion_fd , gbm_buf_info object handle
|
||||
* @return : none
|
||||
*/
|
||||
void msmgbm_mapper::register_to_map(int fd, struct gbm_buf_info * gbm_buf,
|
||||
struct msmgbm_private_info *gbo_private_info) {
|
||||
auto buffer = std::make_shared<msmgbm_buffer>(fd,gbm_buf->metadata_fd,
|
||||
gbm_buf->width,gbm_buf->height,gbm_buf->format,
|
||||
gbo_private_info->cpuaddr, gbo_private_info->mt_cpuaddr);
|
||||
gbm_buf_map_.emplace(std::make_pair(fd, buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to search hash map using ion_fd and retrieve the gbm_buf_info
|
||||
* @input param: ion_fd , gbm_buf_info object handle, msmgbm_private_info object handle
|
||||
* @return : 1 or O
|
||||
*
|
||||
*/
|
||||
int msmgbm_mapper::search_map(int fd, struct gbm_buf_info *buf_info,
|
||||
struct msmgbm_private_info *gbo_private_info){
|
||||
auto it = gbm_buf_map_.find(fd);
|
||||
if (it != gbm_buf_map_.end()) {
|
||||
buf_info->fd=it->second->ion_fd;
|
||||
buf_info->metadata_fd=it->second->ion_metadata_fd;
|
||||
buf_info->width=it->second->width;
|
||||
buf_info->height=it->second->height;
|
||||
buf_info->format=it->second->format;
|
||||
gbo_private_info->cpuaddr = it->second->cpuaddr;
|
||||
gbo_private_info->mt_cpuaddr = it->second->mt_cpuaddr;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update hash map entry using ion_fd as hash key
|
||||
* @input param: ion_fd , gbm_buf_info object handle
|
||||
* @return : 1 or O
|
||||
*
|
||||
*/
|
||||
int msmgbm_mapper::update_map(int fd, struct gbm_buf_info *buf_info,
|
||||
struct msmgbm_private_info *gbo_private_info){
|
||||
auto it = gbm_buf_map_.find(fd);
|
||||
if (it != gbm_buf_map_.end()) {
|
||||
it->second->ion_fd=buf_info->fd;
|
||||
it->second->ion_metadata_fd=buf_info->metadata_fd;
|
||||
it->second->width=buf_info->width;
|
||||
it->second->height=buf_info->height;
|
||||
it->second->format=buf_info->format;
|
||||
it->second->cpuaddr=gbo_private_info->cpuaddr;
|
||||
it->second->mt_cpuaddr=gbo_private_info->mt_cpuaddr;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to dump the hash map table
|
||||
* @input void
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
void msmgbm_mapper::map_dump(void) {
|
||||
int count=1;
|
||||
printf("Hash Table dump\n");
|
||||
printf("***********************************************\n");
|
||||
for (auto it : gbm_buf_map_) {
|
||||
auto buf = it.second;
|
||||
printf("ENTRY %d\n",count++);
|
||||
printf("---------------------------------\n");
|
||||
printf("----ion_fd = %d\n",buf->ion_fd);
|
||||
printf("----ion_metadata_fd = %d\n",buf->ion_metadata_fd);
|
||||
printf("----width = %u\n",buf->width);
|
||||
printf("----height = %u\n",buf->height);
|
||||
printf("----format = %u\n",buf->format);
|
||||
printf("----cpuaddr = %p\n",buf->cpuaddr);
|
||||
printf("----mt_cpuaddr = %p\n",buf->mt_cpuaddr);
|
||||
printf("---------------------------------\n");
|
||||
}
|
||||
printf("Total no.of entries=%d\n",count-1);
|
||||
printf("***********************************************\n");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to increment the reference count for the valid map entry
|
||||
* @input param: ion_fd
|
||||
* @return : none
|
||||
*
|
||||
*/
|
||||
void msmgbm_mapper::add_map_entry(int fd) {
|
||||
auto it = gbm_buf_map_.find(fd);
|
||||
if (it != gbm_buf_map_.end()){
|
||||
it->second->IncRef();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to decrement the reference count for the valid map entry
|
||||
* @input param: ion_fd
|
||||
* @return : none
|
||||
*
|
||||
*/
|
||||
int msmgbm_mapper::del_map_entry(int fd) {
|
||||
auto it = gbm_buf_map_.find(fd);
|
||||
if (it!= gbm_buf_map_.end())
|
||||
if(it->second->DecRef()){
|
||||
gbm_buf_map_.erase(fd);
|
||||
return 1;
|
||||
}else
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
} // namespace msm_gbm
|
1100
qcom/opensource/display/libgbm/src/msmgbm_platform_wrapper.cpp
Normal file
1100
qcom/opensource/display/libgbm/src/msmgbm_platform_wrapper.cpp
Normal file
File diff suppressed because it is too large
Load Diff
75
qcom/opensource/display/libgbm/src/msmgbm_video.c
Normal file
75
qcom/opensource/display/libgbm/src/msmgbm_video.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gbm_priv.h>
|
||||
#include <msmgbm.h>
|
||||
#include <msmgbm_common.h>
|
||||
|
||||
/**
|
||||
* Get the implementaion defined format based on usage flags.
|
||||
* @return - pixel_format to be used for BO
|
||||
* returns input format if none of the combination matches.
|
||||
*/
|
||||
uint32_t GetVideoImplDefinedFormat(uint32_t usage_flags, uint32_t format)
|
||||
{
|
||||
uint32_t pixel_format = format;
|
||||
|
||||
if(!IsImplDefinedFormat(format))
|
||||
return pixel_format;
|
||||
|
||||
if(usage_flags & GBM_BO_USAGE_VIDEO_ENCODER_QTI){
|
||||
pixel_format = GBM_FORMAT_NV12_ENCODEABLE;
|
||||
}
|
||||
|
||||
return pixel_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ion allocation flags based on allocation flags.
|
||||
* @return - ion flags for BO allocation
|
||||
*/
|
||||
uint32_t GetVideoIonAllocFlags(uint32_t alloc_flags)
|
||||
{
|
||||
uint32_t ion_flags = 0;
|
||||
|
||||
return ion_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ion heap id based on allocation flags.
|
||||
* @return - ion heap id for BO allocation
|
||||
*/
|
||||
uint32_t GetVideoIonHeapId(uint32_t alloc_flags)
|
||||
{
|
||||
uint32_t ion_heap_id = 0;
|
||||
|
||||
return ion_heap_id;
|
||||
}
|
||||
|
2629
qcom/opensource/display/libgbm/test/gbmtest.c
Normal file
2629
qcom/opensource/display/libgbm/test/gbmtest.c
Normal file
File diff suppressed because it is too large
Load Diff
75
qcom/opensource/display/libgbm/test/gbmtest_all.sh
Normal file
75
qcom/opensource/display/libgbm/test/gbmtest_all.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
|
||||
#Copyright (c) 2020, 2021 The Linux Foundation. All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
#3. Neither the name of the copyright holder nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
#MPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
#ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
#INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
#ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
#THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
number=1
|
||||
res=1
|
||||
|
||||
if [ ! "$1" ]
|
||||
then
|
||||
echo "usage: gbmtest_all <Max Test cases to execute>"
|
||||
echo "Default Max Tests are 25"
|
||||
MAX_TEST_CASE=25
|
||||
else
|
||||
MAX_TEST_CASE=$1
|
||||
fi
|
||||
CHECK_TEST_CASE=`expr $MAX_TEST_CASE + 1`
|
||||
killall weston
|
||||
|
||||
while [ "$number" -lt "$CHECK_TEST_CASE" ]
|
||||
do
|
||||
/usr/bin/gbmtest "$number" > /dev/null 2>&1
|
||||
res=$?
|
||||
echo "TEST " | tr -d '\n';
|
||||
if [ "$res" == 0 ] #success if 0 fail if 1
|
||||
then
|
||||
test_pass="$test_pass $number"
|
||||
echo $number | tr -d '\n'; echo " - PASSED"
|
||||
else
|
||||
test_fail="$test_fail $number"
|
||||
echo $number | tr -d '\n'; echo " - FAILED"
|
||||
fi
|
||||
number=`expr $number + 1`
|
||||
done
|
||||
|
||||
echo ""; echo "RESULTS:"
|
||||
|
||||
echo "Passing Test Cases:"; echo ""
|
||||
|
||||
#print passing test case numbers
|
||||
echo ${test_pass} ; echo ""
|
||||
|
||||
echo "Failing Test Cases:"
|
||||
|
||||
echo ""
|
||||
|
||||
#print failing test case numbers
|
||||
echo "${test_fail}"; echo ""
|
Reference in New Issue
Block a user