-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MarcA711
committed
Nov 4, 2023
0 parents
commit 5b7816f
Showing
270 changed files
with
65,399 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CMakeCache.txt | ||
CMakeFiles/ | ||
Makefile | ||
cmake_install.cmake | ||
install_manifest.txt | ||
librga.so | ||
rgaImDemo | ||
.vscode/ | ||
*.patch | ||
build/ | ||
build_linux/ | ||
build_android_ndk/ | ||
.DS_Store | ||
local_* | ||
*.cpp.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
bootstrap_go_package { | ||
name: "soong-librga", | ||
pkgPath: "android/soong/librga", | ||
deps: [ | ||
"blueprint", | ||
"blueprint-pathtools", | ||
"soong", | ||
"soong-android", | ||
"soong-cc", | ||
"soong-genrule", | ||
], | ||
srcs: [ | ||
"Android.go", | ||
], | ||
pluginFor: ["soong_build"], | ||
} | ||
|
||
cc_librga { | ||
name: "cc_librga_defaults" | ||
} | ||
|
||
cc_library_shared { | ||
name: "librga", | ||
defaults: [ | ||
"cc_librga_defaults" | ||
], | ||
|
||
vendor_available: true, | ||
|
||
header_libs: [ | ||
"gl_headers", | ||
"libgui_headers", | ||
"libhardware_headers", | ||
"libbinder_headers", | ||
"liblog_headers", | ||
], | ||
srcs: [ | ||
"core/utils/android_utils/src/android_utils.cpp", | ||
"core/utils/drm_utils/src/drm_utils.cpp", | ||
"core/utils/utils.cpp", | ||
"core/RockchipRga.cpp", | ||
"core/GrallocOps.cpp", | ||
"core/NormalRga.cpp", | ||
"core/NormalRgaApi.cpp", | ||
"core/RgaApi.cpp", | ||
"core/RgaUtils.cpp", | ||
"core/rga_sync.cpp", | ||
"im2d_api/src/im2d_log.cpp", | ||
"im2d_api/src/im2d_impl.cpp", | ||
"im2d_api/src/im2d.cpp", | ||
], | ||
export_include_dirs: [ | ||
"include", | ||
"im2d_api", | ||
], | ||
include_dirs: [ | ||
"hardware/rockchip/librga/core/hardware", | ||
"hardware/rockchip/librga/core/utils", | ||
"hardware/rockchip/librga/core/3rdparty/libdrm/include/drm", | ||
"frameworks/native/libs/nativewindow/include", | ||
], | ||
|
||
shared_libs: [ | ||
"liblog", | ||
"libui", | ||
"libutils", | ||
"libcutils", | ||
"libhardware", | ||
"libsync", | ||
], | ||
|
||
cflags: ["-Wno-error"] +["-DLOG_TAG=\"librga\""] + ["-DRK_DRM_GRALLOC=1"] + ["-DANDROID_8"] + ["-DANDROID_7_DRM"] + ["-DUSE_AHARDWAREBUFFER=1"] + ["-DANDROID"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
package librga | ||
|
||
import ( | ||
"android/soong/android" | ||
"android/soong/cc" | ||
"fmt" | ||
"strings" | ||
"strconv" | ||
"unsafe" | ||
) | ||
|
||
func init() { | ||
fmt.Println("librga want to conditional Compile") | ||
android.RegisterModuleType("cc_librga", DefaultsFactory) | ||
} | ||
|
||
func DefaultsFactory() (android.Module) { | ||
module := cc.DefaultsFactory() | ||
android.AddLoadHook(module, Defaults) | ||
return module | ||
} | ||
|
||
func Defaults(ctx android.LoadHookContext) { | ||
sdkVersion := ctx.AConfig().PlatformSdkVersion() | ||
sdkVersionInt, err := strconv.Atoi(*(*string)(unsafe.Pointer(&sdkVersion))) | ||
if err != nil { | ||
fmt.Printf("librga cannot get ApiLevel, %q could not be parsed as an integer\n", sdkVersion) | ||
panic(1) | ||
} | ||
|
||
if (sdkVersionInt >= 29 ) { | ||
type props struct { | ||
Srcs []string | ||
Cflags []string | ||
Shared_libs []string | ||
Include_dirs []string | ||
Header_libs []string | ||
Export_header_lib_headers []string | ||
Double_loadable *bool | ||
} | ||
|
||
p := &props{} | ||
p.Srcs = getSrcs(ctx, sdkVersionInt) | ||
p.Cflags = getCflags(ctx, sdkVersionInt) | ||
p.Shared_libs = getSharedLibs(ctx, sdkVersionInt) | ||
p.Include_dirs = getIncludeDirs(ctx, sdkVersionInt) | ||
p.Header_libs = getHeaders(ctx, sdkVersionInt) | ||
p.Export_header_lib_headers = getExportHeaders(ctx, sdkVersionInt) | ||
|
||
double_loadable := true | ||
p.Double_loadable = &double_loadable | ||
|
||
ctx.AppendProperties(p) | ||
} else { | ||
type props struct { | ||
Srcs []string | ||
Cflags []string | ||
Shared_libs []string | ||
Include_dirs []string | ||
} | ||
|
||
p := &props{} | ||
p.Srcs = getSrcs(ctx, sdkVersionInt) | ||
p.Cflags = getCflags(ctx, sdkVersionInt) | ||
p.Shared_libs = getSharedLibs(ctx, sdkVersionInt) | ||
p.Include_dirs = getIncludeDirs(ctx, sdkVersionInt) | ||
|
||
ctx.AppendProperties(p) | ||
} | ||
} | ||
|
||
//条件编译主要修改函数 | ||
func getSrcs(ctx android.BaseContext, sdkVersion int) ([]string) { | ||
var src []string | ||
|
||
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_RK_GRALLOC_VERSION"),"4") ) { | ||
if (sdkVersion >= 30 ) { | ||
src = append(src, "core/platform_gralloc4.cpp") | ||
} | ||
} | ||
|
||
return src | ||
} | ||
|
||
func getCflags(ctx android.BaseContext, sdkVersion int) ([]string) { | ||
var cppflags []string | ||
|
||
//该打印输出为: TARGET_PRODUCT:rk3328 fmt.Println("TARGET_PRODUCT:",ctx.AConfig().Getenv("TARGET_PRODUCT")) //通过 strings.EqualFold 比较字符串,可参考go语言字符串对比 | ||
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_BOARD_PLATFORM"),"rk3368") ) { | ||
//添加 DEBUG 宏定义 | ||
cppflags = append(cppflags,"-DRK3368=1") | ||
} | ||
|
||
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_RK_GRALLOC_VERSION"),"4") ) { | ||
if (sdkVersion >= 30 ) { | ||
cppflags = append(cppflags,"-DUSE_GRALLOC_4") | ||
} | ||
} | ||
|
||
//Android 12开始使用libhardware_rockchip存放RK私有定义 | ||
if (sdkVersion >= 31 ) { | ||
cppflags = append(cppflags,"-DUSE_HARDWARE_ROCKCHIP") | ||
} | ||
|
||
//将需要区分的环境变量在此区域添加 //.... | ||
return cppflags | ||
} | ||
|
||
func getSharedLibs(ctx android.BaseContext, sdkVersion int) ([]string) { | ||
var libs []string | ||
|
||
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_RK_GRALLOC_VERSION"),"4") ) { | ||
if (sdkVersion >= 30 ) { | ||
libs = append(libs, "libgralloctypes") | ||
libs = append(libs, "libhidlbase") | ||
libs = append(libs, "[email protected]") | ||
} | ||
} | ||
|
||
if (sdkVersion < 29 ) { | ||
libs = append(libs, "libdrm") | ||
} | ||
|
||
return libs | ||
} | ||
|
||
func getIncludeDirs(ctx android.BaseContext, sdkVersion int) ([]string) { | ||
var dirs []string | ||
|
||
if (strings.EqualFold(ctx.AConfig().Getenv("TARGET_RK_GRALLOC_VERSION"),"4") ) { | ||
if (sdkVersion >= 30 ) { | ||
dirs = append(dirs, "hardware/rockchip/libgralloc/bifrost") | ||
dirs = append(dirs, "hardware/rockchip/libgralloc/bifrost/src") | ||
} | ||
} | ||
// Add libion for RK3368 | ||
if (sdkVersion >= 29) { | ||
if (sdkVersion >= 30) { | ||
dirs = append(dirs, "system/memory/libion/original-kernel-headers") | ||
} else { | ||
dirs = append(dirs, "system/core/libion/original-kernel-headers") | ||
} | ||
} | ||
|
||
return dirs | ||
} | ||
|
||
func getHeaders(ctx android.BaseContext, sdkVersion int) ([]string) { | ||
var headers []string | ||
|
||
if (sdkVersion >= 31 ) { | ||
headers = append(headers, "libhardware_rockchip_headers") | ||
} | ||
|
||
return headers | ||
} | ||
|
||
func getExportHeaders(ctx android.BaseContext, sdkVersion int) ([]string) { | ||
var headers []string | ||
|
||
if (sdkVersion >= 31 ) { | ||
headers = append(headers, "libhardware_rockchip_headers") | ||
} | ||
|
||
return headers | ||
} |
Oops, something went wrong.