Skip to content

Commit

Permalink
sync: xuantie: vpu-vc8000e SDK v2.0.2 code
Browse files Browse the repository at this point in the history
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
  • Loading branch information
RevySR committed Sep 18, 2024
1 parent a41db16 commit 136681b
Show file tree
Hide file tree
Showing 31 changed files with 12,084 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/soc/xuantie/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ config TH1520_IOPMP
source "drivers/soc/xuantie/nna/Kconfig"
source "drivers/soc/xuantie/video_memory/Kconfig"
source "drivers/soc/xuantie/vpu-vc8000d-kernel/Kconfig"
source "drivers/soc/xuantie/vpu-vc8000e-kernel/Kconfig"
endmenu
1 change: 1 addition & 0 deletions drivers/soc/xuantie/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ obj-$(CONFIG_TH1520_IOPMP) += th1520-iopmp.o
obj-y += nna/
obj-$(CONFIG_VIDEO_MEMORY) += video_memory/driver/
obj-$(CONFIG_VIDEO_VC8000D) += vpu-vc8000d-kernel/linux/subsys_driver/ vpu-vc8000d-kernel/linux/memalloc/
obj-$(CONFIG_VIDEO_VC8000E) += vpu-vc8000e-kernel/linux/kernel_module/
10 changes: 10 additions & 0 deletions drivers/soc/xuantie/vpu-vc8000e-kernel/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
##
# Copyright (C) 2021 Alibaba Group Holding Limited
##

LOCAL_PATH := $(call my-dir)

include $(LOCAL_PATH)/Android.mk.def

include $(LOCAL_PATH)/linux/kernel_module/Android.mk

7 changes: 7 additions & 0 deletions drivers/soc/xuantie/vpu-vc8000e-kernel/Android.mk.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-include device/thead/common/build/common.mk.def
-include vendor/thead/build/make/common.mk.def


BUILD_VENDOR_TEST = 1
PLATFORM_VENDOR = 1

674 changes: 674 additions & 0 deletions drivers/soc/xuantie/vpu-vc8000e-kernel/COPYING

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions drivers/soc/xuantie/vpu-vc8000e-kernel/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config VIDEO_VC8000E
tristate "VC8000E support"
default m
91 changes: 91 additions & 0 deletions drivers/soc/xuantie/vpu-vc8000e-kernel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
##
# Copyright (C) 2020 Alibaba Group Holding Limited
##
ifneq ($(wildcard ../.param),)
include ../.param
endif

#CONFIG_DEBUG_MODE=1
CONFIG_OUT_ENV=hwlinux

CONFIG_BUILD_DRV_EXTRA_PARAM:=""

DIR_TARGET_BASE=bsp/venc
DIR_TARGET_KO =bsp/venc/ko
LINUX_DIR ?= $(OUT)/obj/KERNEL_OBJ/

MODULE_NAME=VENC
BUILD_LOG_START="\033[47;30m>>> $(MODULE_NAME) $@ begin\033[0m"
BUILD_LOG_END ="\033[47;30m<<< $(MODULE_NAME) $@ end\033[0m"

#
# Do a parallel build with multiple jobs, based on the number of CPUs online
# in this system: 'make -j8' on a 8-CPU system, etc.
#
# (To override it, run 'make JOBS=1' and similar.)
#

ifeq ($(JOBS),)
JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
ifeq ($(JOBS),)
JOBS := 1
endif
endif

all: info driver install_local_output
.PHONY: info driver install_local_output install_addons install_prepare clean_driver clean_output clean

info:
@echo $(BUILD_LOG_START)
@echo " ====== Build Info from repo project ======"
@echo " BUILDROOT_DIR="$(BUILDROOT_DIR)
@echo " CROSS_COMPILE="$(CROSS_COMPILE)
@echo " LINUX_DIR="$(LINUX_DIR)
@echo " ARCH="$(ARCH)
@echo " BOARD_NAME="$(BOARD_NAME)
@echo " KERNEL_ID="$(KERNELVERSION)
@echo " KERNEL_DIR="$(LINUX_DIR)
@echo " INSTALL_DIR_ROOTFS="$(INSTALL_DIR_ROOTFS)
@echo " INSTALL_DIR_SDK="$(INSTALL_DIR_SDK)
@echo " ====== Build configuration by settings ======"
# @echo " CONFIG_DEBUG_MODE="$(CONFIG_DEBUG_MODE)
@echo " CONFIG_OUT_ENV="$(CONFIG_OUT_ENV)
@echo " JOBS="$(JOBS)
@echo $(BUILD_LOG_END)

driver:
@echo $(BUILD_LOG_START)
make -C linux/kernel_module KDIR=$(LINUX_DIR) ARCH=$(ARCH)
@echo $(BUILD_LOG_END)

clean_driver:
@echo $(BUILD_LOG_START)
make -C linux/kernel_module KDIR=$(LINUX_DIR) clean
@echo $(BUILD_LOG_END)

install_prepare:
mkdir -p ./output/rootfs/$(DIR_TARGET_KO)

install_addons: install_prepare
@if [ -d addons/ko ]; then \
cp -rf addons/ko/* ./output/rootfs/$(DIR_TARGET_KO); \
fi

install_local_output: install_addons install_prepare driver
@echo $(BUILD_LOG_START)
find ./linux -name "*.ko" | xargs -i cp -f {} ./output/rootfs/$(DIR_TARGET_KO)
cp -f ./linux/kernel_module/driver_load.sh ./output/rootfs/$(DIR_TARGET_KO)
chmod +x ./output/rootfs/$(DIR_TARGET_KO)/*.sh
echo "vc8000" > ./output/rootfs/$(DIR_TARGET_KO)/vc8000e.conf
@if [ `command -v tree` != "" ]; then \
tree ./output/rootfs; \
fi
@echo $(BUILD_LOG_END)

clean_output:
@echo $(BUILD_LOG_START)
rm -rf ./output
@echo $(BUILD_LOG_END)

clean: clean_output clean_driver

Empty file.
5 changes: 5 additions & 0 deletions drivers/soc/xuantie/vpu-vc8000e-kernel/addons/ko/insmod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
KERNEL_VER=$(uname -r)
BASE_PATH=/lib/modules/${KERNEL_VER}/extra

insmod $BASE_PATH/vc8000.ko
3 changes: 3 additions & 0 deletions drivers/soc/xuantie/vpu-vc8000e-kernel/addons/ko/rmmod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

rmmod vc8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

VPU_OUT := $(TARGET_OUT_INTERMEDIATES)/VPU_OBJ
VC8000_KO = $(VPU_OUT)/ko/vc8000.ko
VC8000_DIR := $(LOCAL_PATH)

$(VC8000_KO):
$(MAKE_TOOL) -C $(VC8000_DIR) KDIR=$(KERNEL_DIR) CROSS_COMPILE=$(CROSS_COMPILE) ARCH=$(ARCH); \
cp $(VC8000_DIR)/vc8000.ko $(VC8000_KO)

LOCAL_PREBUILT_MODULE_FILE := \
$(VC8000_KO)

LOCAL_GENERATED_SOURCES += \
$(VC8000_KO)

LOCAL_MODULE_RELATIVE_PATH := modules

LOCAL_MODULE := vc8000
LOCAL_MODULE_SUFFIX := .ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_VENDOR_MODULE := true
LOCAL_STRIP_MODULE := false

include $(BUILD_PREBUILT)
211 changes: 211 additions & 0 deletions drivers/soc/xuantie/vpu-vc8000e-kernel/linux/kernel_module/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
#############################################################################
#
# The MIT License (MIT)
#
# Copyright (c) 2014 - 2021 VERISILICON
#
# 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 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.
#
#############################################################################
#
# The GPL License (GPL)
#
# Copyright (C) 2014 - 2021 VERISILICON
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#############################################################################
#
# Note: This software is released under dual MIT and GPL licenses. A
# recipient may use this file under the terms of either the MIT license or
# GPL License. If you wish to use only one license not the other, you can
# indicate your decision by deleting one of the above license notices in your
# version of this file.
#
##############################################################################
ARM_CROSS_COMPILE ?= n

ifeq ($(ARM_CROSS_COMPILE),y)
export ARCH=arm64
export CROSS_COMPILE=/opt/kmb/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-
KDIR := /home/vsi/kmb-evm/kernel/mainline-tracking
endif

SUPPORT_MMU = y
SUPPORT_AXIFE = n
SUPPORT_VCMD_ENABLE_IP = n

ifeq ($(obj),)
obj = .
endif

#################################################
# configuration

MDIR := hantro

# drivers objects
# list-multi := hantro_mmu.o

# # what to build

vc8000-objs := vc8000_driver.o vc8000_vcmd_driver.o bidirect_list.o vcmdswhwregisters.o vc8000_normal_driver.o
obj-m += vc8000.o

ifeq ($(strip $(SUPPORT_MMU)),y)
vc8000-objs += hantro_mmu.o
endif

ifeq ($(strip $(SUPPORT_AXIFE)),y)
vc8000-objs += vc8000_axife.o
endif

tardest := .

#################################################
# compile modules

ifneq ($(KERNELRELEASE),)
# recursive call from kernel build system
dummy := $(shell echo $(KERNELRELEASE) > $(obj)/.version)

ifeq ($(VERSION).$(PATCHLEVEL),2.6)
export-objs :=
list-multi :=
else
multi-m := $(filter $(list-multi), $(obj-m))
int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))
export-objs := $(filter $(int-m) $(obj-m),$(export-objs))
endif

CC += -I$(obj)
EXTRA_CFLAGS += -g

#ifeq ($(CONFIG_ANDROID), y)
#ccflags-y += -DTRACE_INCLUDE_PATH=$(src)
#else
#ccflags-y += -DTRACE_INCLUDE_PATH=$(PWD)
#endif

# Print debugging messages from the device
#EXTRA_CFLAGS += -DHANTRO_DRIVER_DEBUG

#EXTRA_CFLAGS += -DHANTROMMU_DEBUG
#EXTRA_CFLAGS += -DDYNAMIC_MALLOC_VCMDNODE

snapshot := $(wildcard $(obj)/.snapshot)
ifneq ($(snapshot),)
SNAPSHOT_CFLAGS := -DSNAPSHOT='$(shell cat $(snapshot))'
EXTRA_CFLAGS += $(SNAPSHOT_CFLAGS)
endif

ifeq ($(strip $(SUPPORT_MMU)),y)
EXTRA_CFLAGS += -DHANTROMMU_SUPPORT
endif

ifeq ($(strip $(SUPPORT_AXIFE)),y)
EXTRA_CFLAGS += -DHANTROAXIFE_SUPPORT
endif

ifeq ($(strip $(SUPPORT_VCMD_ENABLE_IP)),y)
EXTRA_CFLAGS += -DHANTROVCMD_ENABLE_IP_SUPPORT
endif

-include $(TOPDIR)/Rules.make
else
# take version info from last module build if available
KERNELRELEASE := $(shell cat $(obj)/.version 2>/dev/null || uname -r)
endif
ifneq ($(ARM_CROSS_COMPILE),y)
KDIR_BASE := /afs/hantro.com/projects/Testing/Board_Version_Control

#KDIR := $(KDIR_BASE)/Realview_EB/SW/Linux/v0_0/linux-2.6.19-arm2
#KDIR := $(KDIR_BASE)/Realview_EB/SW/Linux/linux-2.6.21-arm1/v0_0/linux-2.6.21-arm1
#KDIR := $(KDIR_BASE)/Realview_PB/PB926EJS/SW/Linux/linux-2.6.24-arm2-spnlck/v0_1/linux-2.6.24-arm2-spnlck
#KDIR := $(KDIR_BASE)/Realview_PB/PB926EJS/SW/Linux/linux-2.6.28-arm1/v0_1/linux-2.6.28-arm1
#KDIR := $(KDIR_BASE)/SW_Common/ARM_realview_v6/2.6.28-arm1/v0_1-v6/linux-2.6.28-arm1

KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
endif

PWD := $(shell pwd)
DEST := /lib/modules/$(KERNELRELEASE)/$(MDIR)

# which files to install?
inst-m := $(wildcard *.ko)
ifeq ($(inst-m),)
inst-m := $(obj-m)
endif


# locales seem to cause trouble sometimes.
LC_ALL = POSIX
export LC_ALL

default::
$(MAKE) -C $(KDIR) M=$(PWD) modules

install::
strip --strip-debug $(inst-m)
-su -c "mkdir -p $(DEST); cp -v $(inst-m) $(DEST); depmod -a"

clean::
$(MAKE) -C $(KDIR) M=$(PWD) clean
-rm -f .version

#################################################
# build tarballs

thisdir := $(notdir $(PWD))
name := $(shell echo $(thisdir) | sed 's/-.*//')
ver := $(shell echo $(thisdir) | sed 's/.*-//')
date := $(shell date +%Y%m%d)
tardest ?= .

snapdir := $(HOME)/snapshot
snap ?= $(name)

release: clean
rm -f .snapshot
(cd ..; tar cvzf $(tardest)/$(name)-$(ver).tar.gz $(thisdir))

snapshot snap tarball: clean
echo $(date) > .snapshot
(cd ..; tar czf $(snapdir)/$(snap)-$(date).tar.gz $(thisdir))
$(MAKE) -C $(snapdir)

#################################################
# other stuff

%.asm: %.o
objdump -S $< > $@

Loading

0 comments on commit 136681b

Please sign in to comment.