diff --git a/README.md b/README.md old mode 100644 new mode 100755 index ede79e243076bc142b5d812916a88ccadfac55a5..1d073c39fa6880683e53ccdd56d569b2bf88fcb7 --- a/README.md +++ b/README.md @@ -5,9 +5,11 @@ ## 项目简介 -该项目介绍,如何在飞腾信息科技有限公司SOC硬件平台上运行 OpenHarmony 标准系统[OpenHamony 4.1 release](https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v4.1-release.md)。其中腾锐D系列芯片没有图形模块,需要搭配GPU使用,目前仓库中支持的显卡包含飞腾X100套片、AMD显卡、JM9100显卡。 -支持GPU图形硬件加速,以及X100提供的视频解码硬件加速。 -支持Linux kernel 5.10。 +该项目介绍,如何在飞腾信息科技有限公司SOC硬件平台上运行 OpenHarmony 标准系统[OpenHamony 4.1 release](https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v4.1-release.md)。其中腾锐D系列芯片没有图形模块,需要搭配显卡使用,目前仓库中支持的显卡包含飞腾X100套片、AMD显卡、JM9100显卡,以及cpu模拟mesa3d方案。 +- 支持GPU图形硬件加速,以及X100提供的视频解码硬件加速。 +- 支持Linux kernel 5.10。 +- 支持cpu模拟的mesa3d方案,经优化后,在E系列的芯片上也有流畅体验。 +具体支持状态详见:[开发板简介](./device_soc_phytium/README.md) ## 飞腾公司简介 飞腾信息技术有限公司(以下简称“飞腾公司”)是国内领先的自主核心芯片提供商,由中国电子信息产业集团、天津市滨海新区政府和天津先进技术研究院于2014年联合支持成立。详情请参考[飞腾官网](https://www.phytium.com.cn/homepage/index/)介绍。 @@ -76,7 +78,7 @@ repo forall -c 'git lfs pull' 使用安装包方式获取编译工具链。 ``` -sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby openjdk-11-jdk libtinfo5 npm dosfstools parted kpartx genext2fs libxt-dev libx11-dev xorg-dev mtools +sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby openjdk-11-jdk libtinfo5 npm dosfstools parted libxt-dev libx11-dev xorg-dev mtools mk2fs ``` ## 1.5 执行prebuilts @@ -99,18 +101,19 @@ export PHY_DEV=$WORK_SPACE/phytium_device mkdir $PHY_DEV cd $PHY_DEV git clone git@gitee.com:phytium_embedded/phytium-openharmony-device.git +git checkout 4.1_release ``` -## 2.2 整合内核源码 -D系列cpu通用内核已开源,但是其设备树,以及X100的内核源码未开源。如果使用Uboot,或者X100,需要邮件联系phytium嵌入式软件部(linan1284@phytium.com.cn)获取。 +## 2.2 获取未开源代码 +**D系列设备树,以及X100的内核源码未开源,如果用到这部分代码**,需要邮件联系phytium嵌入式软件部(linan1284@phytium.com.cn)获取,获取到后拷贝到如下路径。 ``` -设备树文件放置位置:device_board_phytium/common/kernel_source/dts/phytium -X100驱动放置位置:vendor_phytium/gpu_model/x100/kernel_source +D系列设备树文件位置:device_board_phytium/tengrui_d/dts +X100内核驱动位置:vendor_phytium/gpu_model/x100/kernel_source ``` ## 2.3 整合phytium device源码 -执行phytium_env.sh脚本,将phytium device代码,以及针对openharmony修改的patch集成到OpenHarmony中。 +以腾锐D系列为例,执行phytium_env.sh脚本,将phytium device代码,以及针对openharmony修改的patch集成到OpenHarmony中。 ``` ./phytium_env.sh $PROJ_ROOT 0 @@ -137,13 +140,25 @@ THE DEVICE: tengrui_d(0) ## 2.4 适配fstab文件 +***这个步骤非常重要,未配置正确的fstab会导致启动kernel panic!!!*** 确认存储介质的类型,参考wiki文档[Openharmony多种存储介质配置说明](https://gitee.com/phytium_embedded/phytium-openharmony-device/wikis/%E9%95%9C%E5%83%8F%E7%94%9F%E6%88%90%E4%B8%8E%E7%83%A7%E5%BD%95/Openharmony%E5%A4%9A%E7%A7%8D%E5%AD%98%E5%82%A8%E4%BB%8B%E8%B4%A8%E9%85%8D%E7%BD%AE%E8%AF%B4%E6%98%8E),根据自己需求修改fstab文件。 + # 代码编译 ## 3.1 编译OpenHarmony源码 -不同显卡目前驱动无法兼容,在编译时需要根据不同硬件添加对应的参数 --gn-args gpu_model=xxx +通过build.sh脚本进行编译,脚本需要带入的几个必要参数说明如下表: +|参数|说明| +|----|----| +| --product-name |产品名称,飞腾产品对应tengrui_d,和tenglong_e| +| --target-cpu |产品芯片架构,飞腾产品对应为arm64| +| --gn-args gpu_model|gn扩展参数,由于不同显卡目前驱动无法兼容,飞腾扩展了一个参数gpu_model,允许用户在编译时需要根据不同的硬件添加对应的参数,即--gn-args xxx,支持x100、amd、jm、sw| +| --gn-args linux_kernel_version|gn扩展参数,配置Linux版本,默认版本是5.10,OpenHarmony 5.0.0 Release以后的版本支持指定Linux kernel 6.6, --gn-args linux_kernel_version="linux-6.6"| +| --ccache |通过ccache加快编译速度| + +更多的编译参数说明,可以通过./build.sh --help获取。 +以下是以tengrui_d为例的编译参数。 ``` cd $PROJ_ROOT @@ -155,7 +170,11 @@ cd $PROJ_ROOT #### 如果显卡是JM9100 ./build.sh --product-name tengrui_d --ccache --target-cpu arm64 --gn-args gpu_model=jm + +#### 如果没有显卡,可采用cpu模拟的mesa3d方案 +./build.sh --product-name tengrui_d --ccache --target-cpu arm64 --gn-args gpu_model=sw ``` +>注:product-name类型目前支持tengrui_d和tenglong_e 编译成功提示: @@ -167,21 +186,21 @@ post_process 编译生成的文件 ``` -$PROJ_ROOT/out/tengrui_d/packages/phone/images/boot_uboot.img -$PROJ_ROOT/out/tengrui_d/packages/phone/images/boot_efi.img +$PROJ_ROOT/out/tengrui_d/packages/phone/images/boot.img $PROJ_ROOT/out/tengrui_d/packages/phone/images/system.img $PROJ_ROOT/out/tengrui_d/packages/phone/images/vendor.img $PROJ_ROOT/out/tengrui_d/packages/phone/images/ramdisk.img ``` >注: ->1. boot_uboot.img和boot_efi.img,分别对应uboot启动和UEFI启动的boot分区镜像。 ->2. boot分区镜像中主要包含内核镜像Image,ramdisk.img,以及uboot启动必备的设备树文件,UEFI启动必备的引导文件。如果内核源码中缺少设备树文件源文件,不会编译生成设备树文件,boot_uboot.img也就不会生成。 +>1. boot.img分区镜像格式为fat32,既支持boot启动也支持UEFI启动。 +>2. boot分区镜像中主要包含内核镜像Image,ramdisk.img,以及uboot启动必备的设备树文件,UEFI启动必备的引导文件。 # 镜像烧写 +目前提供了两种镜像烧录方式,***按分区烧录***与***整体镜像烧录***,可以根据硬件形态选择其中一种合适的烧录方式。 -## 4.1 硬盘分区 - +## 4.1 按分区烧录 +1.硬盘分区: 准备一块SATA硬盘,删除原有分区后,在linux下,使用fdsik命令分区,创建4个分区,依次为boot,system,vendor,userdata,根据实际情况设定,比如可以设定为64M,1.5G,500M,1G。 ``` p1 64MB for BOOT/EFI @@ -192,9 +211,7 @@ p4 1G for data > fdisk命令详细使用方法可自行百度谷歌,或者参考[飞腾嵌入式 LINUX 用户 > 手册](https://gitee.com/phytium_embedded/phytium-sdk/blob/master/%E9%A3%9E%E8%85%BE%E5%B5%8C%E5%85%A5%E5%BC%8FLinux%E7%94%A8%E6%88%B7%E6%89%8B%E5%86%8C.pdf)中的磁盘分区部分内容。 -## 4.2 烧录system/vendor/userdata分区 - -将这三个分区并格式化为ext4,sdX中的X烧写之前先用df命令确认一下是多少,可能是b,c...等,这里一定要注意不要烧错。 +2.将这三个分区并格式化为ext4,sdX中的X烧写之前先用df命令确认一下是多少,可能是b,c...等,这里一定要注意不要烧错。 ``` sudo mkfs.ext4 sdx2 @@ -207,25 +224,13 @@ sudo mkfs.ext4 sdx4 使用dd命令将[3.1 编译OpenHarmony源码](#31-编译openharmony源码)章节编译生成的镜像文件烧写到对应分区中。 ``` +sudo dd if=boot.img of=/dev/sdx1 bs=1M sudo dd if=system.img of=/dev/sdx2 bs=1M sudo dd if=vendor.img of=/dev/sdx3 bs=1M ``` - -## 4.3. 烧录boot分区 - -boot分区的烧录,启动方式不一样,烧录方法不一样,区分为Uboot启动和UEFI启动两种。 -``` -###uboot 启动 -sudo mkfs.ext4 sdx1 -sudo dd if=boot_uboot.img of=/dev/sdx1 bs=1M - -###UEFI启动 -sudo mkfs.vfat sdx1 -sudo dd if=boot_efi.img of=/dev/sdx1 bs=1M -``` -## 4.4 镜像打包工具 - -区别于前面提到的烧写流程,我们还提供了一个镜像打包工具,可以将几个分区的img文件打包成一个镜像,通过dd或者winddows下的烧写工具将打包后的镜像一次性烧写到磁盘,不需要对磁盘分区。 +## 4.2 整体镜像烧录 +1.使用generate_image.sh工具打包镜像: +区别于前面提到的按分区烧写流程,我们还提供了一个镜像打包工具,可以将几个分区的img文件打包成一个镜像,通过dd或者winddows下的烧写工具将打包后的镜像一次性烧写到磁盘,不需要对磁盘分区。 工具所在位置: ``` device_board_phytium/common/tools/generate_image/generate_image.sh @@ -236,12 +241,7 @@ device_board_phytium/common/tools/generate_image/generate_image.sh 参考命令: ``` cd out/tengrui_d/packages/phone/images/ - -#uboot启动 ./generate_image.sh - -#UEFI启动 -./generate_image.sh efi ``` 打包时会有如下打印信息: ``` @@ -252,7 +252,12 @@ start creating empty image, please wait...... losetup loopdevice...... generate phytium_oh_xxx.img successfully!!!!!! ``` - +2.将生成的整体镜像烧入磁盘 +Linux环境下,使用dd命令烧录即可. +``` +$sudo dd if=openharmony_img_xxx.img of=/dev/sdb bs=1M +``` +也可以在windows环境下,使用win32Diskimager、rufus、balenaEtcher等烧录工具进行烧录。 # 设备启动 将烧写好的SATA硬盘和调试串口线,连接到开发板上。上位机的串口调试工具波特率设置为115200,上电开机。 @@ -263,15 +268,30 @@ generate phytium_oh_xxx.img successfully!!!!!! ``` setenv bootargs console=ttyAMA1,115200 root=/dev/ram0 elevator=deadline rootwait rw loglevel=1 hardware=tengrui_d rootfstype=ext4 initrd=0x93000000,90M -setenv bootcmd "ext4load scsi 0:1 0x90100000 pd2008-devboard-dsk.dtb;ext4load scsi 0:1 0x90200000 Image;ext4load scsi 0:1 0x93000000 ramdisk.img;booti 0x90200000 - 0x90100000" + +setenv bootcmd "fatload scsi 0:1 0x90100000 pd2008-devboard-dsk.dtb;fatload scsi 0:1 0x90200000 Image;fatload scsi 0:1 0x93000000 ramdisk.img;booti 0x90200000 - 0x90100000" + saveenv + boot ``` +> 注:这里hardware分别可以选择tengrui_d和tenglong_e ## 5.2 UEFI启动 启动参数已经在烧写EFI分区时已写好,上电后,会直接进入系统。 +## 5.3 sw模式启动参数 +gpu_model=sw模式下,cpu模拟mesa,需要给DC预留更多内存才能正常启动,需要在启动参数中增加相关配置。 +- E2000 sw模式下,不需要搭配其他显卡,CMA需要配置512M。 +``` +setenv bootargs console=ttyAMA1,115200 root=/dev/ram0 elevator=deadline rootwait rw loglevel=1 hardware=tenglong_e rootfstype=ext4 initrd=0x93000000,90M cma=512M +``` +- D2000 sw模式下,还是需要搭配显卡,CMA配置1024M。此外建议将显卡配置成从主存申请内存,以x100为例,通过配置phytium-dc-drm.x100_dc_sysmem可以让x100从主存申请内存。 +``` +setenv bootargs console=ttyAMA1,115200 root=/dev/ram0 elevator=deadline rootwait rw loglevel=1 hardware=tengrui_d rootfstype=ext4 initrd=0x93000000,90M cma=1024M phytium-dc-drm.x100_dc_sysmem +``` + # 维护者邮箱 飞腾信息技术有限公司 diff --git a/device_board_phytium/README.md b/device_board_phytium/README.md old mode 100644 new mode 100755 index 4a056f061e1d293f5366dc8bf667481b1f12dbaa..902435aef0cbf331ad36268d9f1b864a3e2289b2 --- a/device_board_phytium/README.md +++ b/device_board_phytium/README.md @@ -2,13 +2,14 @@ ## 简介 -### 开发板简介 +### 1. 开发板简介 -飞腾腾锐D系列芯片,主要包含D2000和D3000,板载已测试的外设如下清单所示: +#### 1.1 外设状况 +飞腾腾锐D与腾珑E系列芯片,主要包含D2000、D3000、E2000Q,板载已测试的外设如下清单所示: |外设|支持状况| |-------|-----------| |USB Host HID|YES| -|USB OTG HDC|无硬件接口,未测试| +|USB OTG HDC|D系列无硬件接口,未测试;E系列支持| |SD控制器|YES| |以太网接口测试|YES| |WiFi|无硬件,未测试| @@ -17,36 +18,98 @@ |I2C|YES| |GPIO|YES| -D系列芯片,本身没有图形接口,需要外接显卡才能显示。仓库中支持的显卡包含飞腾X100套片、AMD显卡、JM9100显卡。在编译时需要根据不同硬件添加对应的参数 --gn-args gpu_model=xxx,编译参数与具体型号对应表如下: -|gpu_model|厂商|型号|支持状况| -|-------|-----|------|----| -|x100|飞腾|X100套片|支持3D硬件加速,硬解码加速| -|jm|景嘉微|JM9100|支持3D硬件加速| -|amd|AMD|RX550、RX640、RX570|支持3D硬件加速| ->amd型号众多,理论上驱动支持原子操作的型号均能支持,测试样本有限,已测试支持显卡包含RX550、RX640、RX570 +#### 1.2 GPU Model支持状况 +仓库中支持的显卡包含飞腾X100套片、AMD显卡、JM9100显卡、cpu模拟mesa3d。在编译时需要根据不同硬件添加对应的参数 --gn-args gpu_model=xxx。 -## 目录 + +gpu_model支持列表: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
gpu_model厂商型号不同版本支持情况
OH 4.1
Kernel 5.10 +
OH 5.0.0
Kernel 5.10 +
OH 5.0.0
Kernel 6.6
(E系列暂不支持) +
sw飞腾ALL支持CPU模拟mesa3d支持CPU模拟mesa3d支持CPU模拟mesa3d
x100飞腾X100套片支持3D硬件加速,硬解码加速支持3D硬件加速,硬解码加速支持3D硬件加速,硬解码加速
jm景嘉微JM9100支持3D硬件加速不支持,暂未适配不支持,编译失败
amdANDRX550、RX640、RX570支持3D硬件加速支持3D硬件加速支持3D硬件加速
RX6400不支持不支持支持3D硬件加速
+ +- amd型号众多,理论上驱动支持原子操作的型号均能支持,测试样本有限,已测试支持显卡包含RX550、RX640、RX570、RX4600。 +- D系列芯片本身没有图形模块,使用sw时,要插入DRM驱动支持的显卡,主要使用场景为qmue、虚拟化以及其他测试场景。 +- E系列芯片有图形模块,使用sw时,不需要外插显卡,图形复杂度较低的场景下可以独立使用。对图形要求较高的场景,建议外插显卡。 + +## 2. 目录结构 ``` -device/board/phytium ├── common │   ├── build_kernel +│   ├── distributedhardware +│   ├── hap │   ├── kernel_source +│   ├── patch │   └── tools ├── LICENSE ├── README.md +├── tenglong_e +│   ├── audio_alsa +│   ├── BUILD.gn +│   ├── cfg +│   ├── device.gni +│   ├── dts +│   ├── loader +│   └── ohos.build └── tengrui_d ├── audio_alsa ├── BUILD.gn ├── cfg ├── device.gni - ├── distributedhardware + ├── dts ├── loader - ├── ohos.build - └── patch + └── ohos.build + ``` -## 相关仓 +## 3. 相关仓 * [vendor/phytium](..vendor_phytium) * [device/soc/phytium](../device_soc_phytium) diff --git a/device_board_phytium/common/build_kernel/build_dts.sh b/device_board_phytium/common/build_kernel/build_dts.sh new file mode 100755 index 0000000000000000000000000000000000000000..c47fae305a8cc66902ba38d0fb768259f7565c98 --- /dev/null +++ b/device_board_phytium/common/build_kernel/build_dts.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Copyright (c) 2023 Phytium Technology Co., Ltd. All rights reserved. +# This file contains confidential and proprietary information of +# OSWare Technology Co., Ltd +# +# 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. + +set -e + +DTS_SRC_DIR=${1} +DTS_TARGET_DIR=${2} + +cp ${DTS_SRC_DIR}/*.dts* ${DTS_TARGET_DIR} + +dts_files=$(find "$DTS_SRC_DIR" -type f -name "*.dts") + +for dts_file in $dts_files; do + dts_name=$(basename "$dts_file" .dts) + echo "dtb-\$(CONFIG_ARCH_PHYTIUM) += ${dts_name}.dtb" >> "${DTS_TARGET_DIR}/Makefile" +done \ No newline at end of file diff --git a/device_board_phytium/common/build_kernel/kernel.mk b/device_board_phytium/common/build_kernel/kernel.mk index 9aa1a02e440d8180f16dd084f17dd1a6af128d73..d693acf982a8554d182a4eb4cd6bce8d73bab201 100755 --- a/device_board_phytium/common/build_kernel/kernel.mk +++ b/device_board_phytium/common/build_kernel/kernel.mk @@ -60,7 +60,7 @@ $(KERNEL_IMAGE_FILE): $(hide) $(OHOS_BUILD_HOME)/device/board/phytium/common/build_kernel/patch_phytium.sh $(PHYTIUM_PATCH_PATH)/phytium_patch $(KERNEL_SRC_TMP_PATH) $(GPU_KERNEL_PATH) $(hide) $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME) $(hide) cp $(PHYTIUM_PATCH_PATH)/${DEFCONFIG_FILE} $(KERNEL_SRC_TMP_PATH)/arch/$(KERNEL_ARCH)/configs/ - $(hide) cp $(PHYTIUM_PATCH_PATH)/dts/phytium $(KERNEL_SRC_TMP_PATH)/arch/$(KERNEL_ARCH)/boot/dts/ -rf + $(hide) $(OHOS_BUILD_HOME)/device/board/phytium/common/build_kernel/build_dts.sh $(OHOS_BUILD_HOME)/device/board/phytium/$(DEVICE_NAME)/dts $(KERNEL_SRC_TMP_PATH)/arch/$(KERNEL_ARCH)/boot/dts/phytium $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) LLVM=1 LLVM_IAS=1 $(KERNEL_CROSS_COMPILE) distclean $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) LLVM=1 LLVM_IAS=1 $(KERNEL_CROSS_COMPILE) $(DEFCONFIG_FILE) $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) LLVM=1 LLVM_IAS=1 $(KERNEL_CROSS_COMPILE) -j$(JOB) diff --git a/device_board_phytium/tengrui_d/distributedhardware/BUILD.gn b/device_board_phytium/common/distributedhardware/BUILD.gn old mode 100644 new mode 100755 similarity index 100% rename from device_board_phytium/tengrui_d/distributedhardware/BUILD.gn rename to device_board_phytium/common/distributedhardware/BUILD.gn diff --git a/device_board_phytium/tengrui_d/distributedhardware/dinput_business_event_whitelist.cfg b/device_board_phytium/common/distributedhardware/dinput_business_event_whitelist.cfg old mode 100644 new mode 100755 similarity index 100% rename from device_board_phytium/tengrui_d/distributedhardware/dinput_business_event_whitelist.cfg rename to device_board_phytium/common/distributedhardware/dinput_business_event_whitelist.cfg diff --git a/device_board_phytium/tengrui_d/distributedhardware/distributed_hardware_components_cfg.json b/device_board_phytium/common/distributedhardware/distributed_hardware_components_cfg.json old mode 100644 new mode 100755 similarity index 100% rename from device_board_phytium/tengrui_d/distributedhardware/distributed_hardware_components_cfg.json rename to device_board_phytium/common/distributedhardware/distributed_hardware_components_cfg.json diff --git a/device_board_phytium/common/hap/Browser.hap b/device_board_phytium/common/hap/Browser.hap new file mode 100644 index 0000000000000000000000000000000000000000..1937183f650eb2c4f0f415699bc6415019a65cfb Binary files /dev/null and b/device_board_phytium/common/hap/Browser.hap differ diff --git a/device_board_phytium/common/kernel_source/phytium_patch/phytium.patch b/device_board_phytium/common/kernel_source/phytium_patch/phytium.patch index c40895b6b1d8f9bf3b1ff4dbfae53200362d63a9..5d323bd68728ed890f81846c11fd1f3817b9303c 100644 --- a/device_board_phytium/common/kernel_source/phytium_patch/phytium.patch +++ b/device_board_phytium/common/kernel_source/phytium_patch/phytium.patch @@ -1158,10 +1158,10 @@ index 9b1170658d60..dd2db8f54578 100644 +subdir-y += phytium diff --git a/arch/arm64/boot/dts/phytium/Makefile b/arch/arm64/boot/dts/phytium/Makefile new file mode 100644 -index 000000000000..19ada101b7ce +index 000000000000..3a0ef31e2cdf --- /dev/null +++ b/arch/arm64/boot/dts/phytium/Makefile -@@ -0,0 +1,8 @@ +@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 + +## pe220x general demo development board series. @@ -1170,6 +1170,7 @@ index 000000000000..19ada101b7ce + +## pe220x specific industry development board series. +dtb-$(CONFIG_ARCH_PHYTIUM) += phytiumpi_firefly.dtb ++dtb-$(CONFIG_ARCH_PHYTIUM) += phytiumpi_firefly_emmc.dtb diff --git a/arch/arm64/boot/dts/phytium/e2000d-demo-board.dts b/arch/arm64/boot/dts/phytium/e2000d-demo-board.dts new file mode 100644 index 000000000000..ff80c255cb1c @@ -3476,6 +3477,332 @@ index 000000000000..eef59ef90842 +&vpu0 { + status = "okay"; +}; +diff --git a/arch/arm64/boot/dts/phytium/phytiumpi_firefly_emmc.dts b/arch/arm64/boot/dts/phytium/phytiumpi_firefly_emmc.dts +new file mode 100644 +index 000000000000..95fe0187da7b +--- /dev/null ++++ b/arch/arm64/boot/dts/phytium/phytiumpi_firefly_emmc.dts +@@ -0,0 +1,320 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * DTS file for Phytium Pi development board. ++ * ++ * Copyright (c) 2024 Phytium Technology Co., Ltd. ++ * ++ * Shaojun Yang ++ */ ++ ++/dts-v1/; ++/memreserve/ 0x80000000 0x10000; ++ ++#include "pe2204.dtsi" ++ ++/{ ++ model = "Phytium Pi Board"; ++ compatible = "phytium,pe2204"; ++ ++ chosen { ++ stdout-path = "serial1:115200n8"; ++ }; ++ aliases { ++ serial4 = &mio0; ++ serial5 = &mio11; ++ serial6 = &mio15; ++ }; ++ ++ memory@00{ ++ device_type = "memory"; ++ reg = <0x0 0x80000000 0x2 0x00000000>; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ sysled { ++ label = "sysled"; ++ gpios = <&gpio1 5 0>; ++ linux,default-trigger = "none"; ++ }; ++ }; ++ ++ sound_card: sound { ++ compatible = "simple-audio-card"; ++ simple-audio-card,format = "i2s"; ++ simple-audio-card,name = "phytium,pe220x-i2s-audio"; ++ simple-audio-card,pin-switches = "mic-in"; ++ simple-audio-card,widgets = "Microphone","mic-in"; ++ simple-audio-card,routing = "MIC2","mic-in"; ++ simple-audio-card,cpu { ++ sound-dai = <&i2s0>; ++ }; ++ simple-audio-card,codec{ ++ sound-dai = <&codec0>; ++ }; ++ }; ++}; ++ ++&soc { ++ mio9: i2c@28026000 { ++ compatible = "phytium,i2c"; ++ reg = <0x0 0x28026000 0x0 0x1000>; ++ interrupts = ; ++ clocks = <&sysclk_50mhz>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ }; ++ ++ mio14: i2c@28030000 { ++ compatible = "phytium,i2c"; ++ reg = <0x0 0x28030000 0x0 0x1000>; ++ interrupts = ; ++ clocks = <&sysclk_50mhz>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ codec0: es8336@10 { ++ det-gpios = <&gpio2 11 0>; ++ sel-gpios = <&gpio2 7 0>; ++ #sound-dai-cells = <0>; ++ compatible = "everest,es8336"; ++ reg = <0x10>; ++ }; ++ }; ++ ++ ++ mio0: uart@28014000 { ++ compatible = "arm,pl011","arm,primecell"; ++ reg = <0x0 0x28014000 0x0 0x1000>; ++ interrupts = ; ++ clocks = <&sysclk_50mhz &sysclk_50mhz>; ++ clock-names = "uartclk", "apb_pclk"; ++ status = "okay"; ++ }; ++ ++ mio1: i2c@28016000 { ++ compatible = "phytium,i2c"; ++ reg = <0x0 0x28016000 0x0 0x1000>; ++ interrupts = ; ++ clocks = <&sysclk_50mhz>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ }; ++ ++ mio8: i2c@28024000 { ++ compatible = "phytium,i2c"; ++ reg = <0x0 0x28024000 0x0 0x1000>; ++ interrupts = ; ++ clocks = <&sysclk_50mhz>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ }; ++ ++ mio11: uart@2802A000 { ++ compatible = "arm,pl011","arm,primecell"; ++ reg = <0x0 0x2802A000 0x0 0x1000>; ++ interrupts = ; ++ clocks = <&sysclk_50mhz &sysclk_50mhz>; ++ clock-names = "uartclk", "apb_pclk"; ++ status = "okay"; ++ }; ++ ++ mio15: uart@28032000 { ++ compatible = "arm,pl011","arm,primecell"; ++ reg = <0x0 0x28032000 0x0 0x1000>; ++ interrupts = ; ++ clocks = <&sysclk_50mhz &sysclk_50mhz>; ++ clock-names = "uartclk", "apb_pclk"; ++ status = "okay"; ++ }; ++}; ++ ++&gpio0 { ++ status = "okay"; ++}; ++ ++&gpio1 { ++ status = "okay"; ++}; ++ ++&gpio2 { ++ status = "okay"; ++}; ++ ++&gpio3 { ++ status = "okay"; ++}; ++ ++&gpio4 { ++ status = "okay"; ++}; ++ ++&gpio5 { ++ status = "okay"; ++}; ++ ++&watchdog0 { ++ status = "okay"; ++}; ++ ++&watchdog1 { ++ status = "okay"; ++}; ++ ++&pcie { ++ status = "okay"; ++}; ++ ++&usb3_0 { ++ status = "okay"; ++}; ++ ++&usb3_1 { ++ status = "okay"; ++}; ++ ++&usb2_0 { ++ dr_mode = "host"; ++ status = "okay"; ++}; ++ ++&usb2_1 { ++ dr_mode = "peripheral"; ++ status = "disabled"; ++}; ++ ++&usb2_2 { ++ dr_mode = "peripheral"; ++ status = "disabled"; ++}; ++ ++&usb2_3 { ++ dr_mode = "host"; ++ status = "okay"; ++}; ++ ++&usb2_4 { ++ dr_mode = "host"; ++ status = "okay"; ++}; ++ ++&macb0 { ++ phy-mode = "sgmii"; ++ use-mii; ++ status = "okay"; ++}; ++ ++&macb1 { ++ phy-mode = "sgmii"; ++ use-mii; ++ status = "okay"; ++}; ++ ++&dc0 { ++ pipe_mask = /bits/ 8 <0x1>; ++ edp_mask = /bits/ 8 <0x0>; ++ status = "okay"; ++}; ++ ++&i2s0 { ++ #sound-dai-cells = <0>; ++ dai-name = "phytium-i2s-lsd"; ++ status = "okay"; ++}; ++ ++&i2s_dp0 { ++ dai-name = "phytium-i2s-dp0"; ++ status = "okay"; ++}; ++ ++&qspi0 { ++ status = "okay"; ++ ++ flash@0 { ++ status = "okay"; ++ }; ++}; ++ ++&spi0 { ++ global-cs = <1>; ++ status = "okay"; ++ ++ spidev0: spidev@0 { ++ compatible = "spidev"; ++ reg = <0>; ++ spi-max-frequency = <50000000>; ++ status = "disabled"; ++ }; ++}; ++ ++&mmc0 { ++ bus-width = <0x00000004>; ++ max-frequency = <25000000>; ++ cap-sdio-irq; ++ cap-sd-highspeed; ++ no-mmc; ++ status = "okay"; ++}; ++ ++&mmc1 { ++ bus-width = <0x00000004>; ++ max-frequency = <50000000>; ++ cap-sdio-irq; ++ cap-sd-highspeed; ++ no-mmc; ++ no-sd; ++ non-removable; ++ status = "okay"; ++}; ++ ++&pwm0 { ++ phytium,db = <0 0 100 1000 1000 0>; ++ status = "okay"; ++}; ++ ++&pwm1 { ++ phytium,db = <0 0 100 1000 1000 0>; ++ status = "okay"; ++}; ++ ++&uart0 { ++ status = "okay"; ++}; ++ ++&uart1 { ++ status = "okay"; ++}; ++ ++&uart2 { ++ status = "okay"; ++}; ++ ++&uart3 { ++ status = "okay"; ++}; ++ ++&can0 { ++ status = "okay"; ++}; ++ ++&can1 { ++ status = "okay"; ++}; ++ ++&pmdk_dp { ++ num-dp = <1>; ++ dp-mask = /bits/ 8 <0x1>; ++ status = "okay"; ++}; ++ ++&rng0 { ++ status = "okay"; ++}; ++ ++&vpu0 { ++ status = "okay"; ++}; diff --git a/arch/arm64/configs/phytium_hdf_standard_defconfig b/arch/arm64/configs/phytium_hdf_standard_defconfig new file mode 100644 index 000000000000..d8d4d167c5e4 @@ -4274,10 +4601,10 @@ index 000000000000..d8d4d167c5e4 +# CONFIG_SUSPEND is not set diff --git a/arch/arm64/configs/phytium_standard_defconfig b/arch/arm64/configs/phytium_standard_defconfig new file mode 100644 -index 000000000000..65deb6861763 +index 000000000000..cc114bb9112a --- /dev/null +++ b/arch/arm64/configs/phytium_standard_defconfig -@@ -0,0 +1,794 @@ +@@ -0,0 +1,806 @@ +CONFIG_LOCALVERSION="-phytium-embeded" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_SYSVIPC=y @@ -5052,6 +5379,9 @@ index 000000000000..65deb6861763 +# CONFIG_FTRACE is not set +CONFIG_MEMTEST=y + ++CONFIG_GPIO_SYSFS=y ++CONFIG_HID_MULTITOUCH=y ++ +CONFIG_HIEVENT=y +CONFIG_BBOX_BUFFER_SIZE=2048 +CONFIG_HISYSEVENT=y @@ -5072,6 +5402,15 @@ index 000000000000..65deb6861763 + +# CONFIG_SUSPEND is not set +CONFIG_VIDEO_PHYTIUM_VPU=y ++ ++CONFIG_DRM_RADEON=y ++CONFIG_DRM_RADEON_USERPTR=y ++CONFIG_DRM_AMDGPU=y ++CONFIG_DRM_AMDGPU_SI=y ++CONFIG_DRM_AMDGPU_CIK=y ++CONFIG_DRM_AMDGPU_USERPTR=y ++CONFIG_DRM_AMDGPU_GART_DEBUGFS=y ++CONFIG_DRM_MWV207=y diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index 88d20f04c64a..af1fafbe7e1d 100644 --- a/arch/arm64/include/asm/arch_timer.h @@ -11023,10 +11362,10 @@ index 000000000000..2dc7ea1118cd +CFLAGS_REMOVE_phytium_crtc.o += -mgeneral-regs-only diff --git a/drivers/gpu/drm/phytium/pe220x_dc.c b/drivers/gpu/drm/phytium/pe220x_dc.c new file mode 100644 -index 000000000000..b465dbb615f1 +index 000000000000..cfdecad43561 --- /dev/null +++ b/drivers/gpu/drm/phytium/pe220x_dc.c -@@ -0,0 +1,255 @@ +@@ -0,0 +1,297 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Phytium Pe220x display controller DRM driver @@ -11036,7 +11375,9 @@ index 000000000000..b465dbb615f1 + +#include +#include ++#if defined(__arm__) || defined(__aarch64__) +#include ++#endif +#include +#include "phytium_display_drv.h" +#include "pe220x_reg.h" @@ -11085,6 +11426,10 @@ index 000000000000..b465dbb615f1 + DRM_FORMAT_NV21, +}; + ++static const unsigned int pe220x_bmc_primary_formats[] = { ++ DRM_FORMAT_XRGB8888, ++}; ++ +static uint64_t pe220x_primary_formats_modifiers[] = { + DRM_FORMAT_MOD_LINEAR, + DRM_FORMAT_MOD_INVALID @@ -11138,49 +11483,76 @@ index 000000000000..b465dbb615f1 + int config = 0; + int phys_pipe = phytium_crtc->phys_pipe; + -+ /* disable pixel clock for bmc mode */ -+ if (phys_pipe == 0) -+ pe220x_dc_hw_disable(crtc); -+ + config = phytium_readl_reg(priv, 0, PE220X_DC_CLOCK_CONTROL); -+ config &= (~(DC0_CORE_RESET | DC1_CORE_RESET | AXI_RESET | AHB_RESET)); + -+ if (phys_pipe == 0) { -+ phytium_writel_reg(priv, config | DC0_CORE_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config | DC0_CORE_RESET | AXI_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config | DC0_CORE_RESET | AXI_RESET | AHB_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config | DC0_CORE_RESET | AXI_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config | DC0_CORE_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config, 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ } else { -+ phytium_writel_reg(priv, config | DC1_CORE_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config | DC1_CORE_RESET | AXI_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config | DC1_CORE_RESET | AXI_RESET | AHB_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config | DC1_CORE_RESET | AXI_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config | DC1_CORE_RESET, -+ 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); -+ phytium_writel_reg(priv, config, 0, PE220X_DC_CLOCK_CONTROL); -+ udelay(20); ++ if (priv->info.bmc_mode) { ++ pe220x_dc_hw_disable(crtc); ++ config &= (~(DC0_CORE_RESET | DC1_CORE_RESET | AHB_RESET)); ++ if (phys_pipe == 0) { ++ phytium_writel_reg(priv, config | DC0_CORE_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC0_CORE_RESET | AHB_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC0_CORE_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config, 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ } else { ++ phytium_writel_reg(priv, config | DC1_CORE_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC1_CORE_RESET | AHB_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC1_CORE_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config, 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ } ++ ++ } else { ++ config &= (~(DC0_CORE_RESET | DC1_CORE_RESET | AXI_RESET | AHB_RESET)); ++ if (phys_pipe == 0) { ++ phytium_writel_reg(priv, config | DC0_CORE_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC0_CORE_RESET | AXI_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC0_CORE_RESET | AXI_RESET | AHB_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC0_CORE_RESET | AXI_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC0_CORE_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config, 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ } else { ++ phytium_writel_reg(priv, config | DC1_CORE_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC1_CORE_RESET | AXI_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC1_CORE_RESET | AXI_RESET | AHB_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC1_CORE_RESET | AXI_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config | DC1_CORE_RESET, ++ 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ phytium_writel_reg(priv, config, 0, PE220X_DC_CLOCK_CONTROL); ++ udelay(20); ++ } + } +} + @@ -11245,6 +11617,15 @@ index 000000000000..b465dbb615f1 + *format_count = ARRAY_SIZE(pe220x_primary_formats); +} + ++void pe220x_dc_bmc_hw_plane_get_primary_format(const uint64_t **format_modifiers, ++ const uint32_t **formats, ++ uint32_t *format_count) ++{ ++ *format_modifiers = pe220x_primary_formats_modifiers; ++ *formats = pe220x_bmc_primary_formats; ++ *format_count = ARRAY_SIZE(pe220x_bmc_primary_formats); ++} ++ +void pe220x_dc_hw_plane_get_cursor_format(const uint64_t **format_modifiers, + const uint32_t **formats, + uint32_t *format_count) @@ -11284,10 +11665,10 @@ index 000000000000..b465dbb615f1 +} diff --git a/drivers/gpu/drm/phytium/pe220x_dc.h b/drivers/gpu/drm/phytium/pe220x_dc.h new file mode 100644 -index 000000000000..5840795cbae6 +index 000000000000..1fd0db3b8d3f --- /dev/null +++ b/drivers/gpu/drm/phytium/pe220x_dc.h -@@ -0,0 +1,31 @@ +@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Phytium Pe220x display controller DRM driver @@ -11312,6 +11693,9 @@ index 000000000000..5840795cbae6 +extern void pe220x_dc_hw_plane_get_primary_format(const uint64_t **format_modifiers, + const uint32_t **formats, + uint32_t *format_count); ++extern void pe220x_dc_bmc_hw_plane_get_primary_format(const uint64_t **format_modifiers, ++ const uint32_t **formats, ++ uint32_t *format_count); +extern void pe220x_dc_hw_plane_get_cursor_format(const uint64_t **format_modifiers, + const uint32_t **formats, + uint32_t *format_count); @@ -11321,10 +11705,10 @@ index 000000000000..5840795cbae6 +#endif /* __PE220X_DC_H__ */ diff --git a/drivers/gpu/drm/phytium/pe220x_dp.c b/drivers/gpu/drm/phytium/pe220x_dp.c new file mode 100644 -index 000000000000..08597ae2f2aa +index 000000000000..b56484361084 --- /dev/null +++ b/drivers/gpu/drm/phytium/pe220x_dp.c -@@ -0,0 +1,514 @@ +@@ -0,0 +1,508 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Phytium display port DRM driver @@ -11332,6 +11716,9 @@ index 000000000000..08597ae2f2aa + * Copyright (c) 2021-2024 Phytium Technology Co., Ltd. + */ + ++#include ++#include ++#include +#include "phytium_display_drv.h" +#include "pe220x_reg.h" +#include "phytium_dp.h" @@ -11706,13 +12093,9 @@ index 000000000000..08597ae2f2aa +{ + struct drm_device *dev = phytium_dp->dev; + struct phytium_display_private *priv = dev->dev_private; -+ int port = phytium_dp->port; + int ret = 0; + -+ phytium_writel_reg(priv, FLAG_REQUEST | CMD_BACKLIGHT | PANEL_POWER_ENABLE, -+ 0, PE220X_DC_CMD_REGISTER(port)); -+ ret = phytium_wait_cmd_done(priv, PE220X_DC_CMD_REGISTER(port), -+ FLAG_REQUEST, FLAG_REPLY); ++ gpiod_set_value(priv->edp_power_en, 1); + if (ret < 0) + DRM_ERROR("%s: failed to poweron panel\n", __func__); +} @@ -11721,13 +12104,9 @@ index 000000000000..08597ae2f2aa +{ + struct drm_device *dev = phytium_dp->dev; + struct phytium_display_private *priv = dev->dev_private; -+ int port = phytium_dp->port; + int ret = 0; + -+ phytium_writel_reg(priv, FLAG_REQUEST | CMD_BACKLIGHT | PANEL_POWER_DISABLE, -+ 0, PE220X_DC_CMD_REGISTER(port)); -+ ret = phytium_wait_cmd_done(priv, PE220X_DC_CMD_REGISTER(port), -+ FLAG_REQUEST, FLAG_REPLY); ++ gpiod_set_value(priv->edp_power_en, 0); + if (ret < 0) + DRM_ERROR("%s: failed to poweroff panel\n", __func__); +} @@ -11736,12 +12115,15 @@ index 000000000000..08597ae2f2aa +{ + struct drm_device *dev = phytium_dp->dev; + struct phytium_display_private *priv = dev->dev_private; -+ int port = phytium_dp->port, ret = 0; ++ struct pwm_state state; ++ int ret = 0; + -+ phytium_writel_reg(priv, FLAG_REQUEST | CMD_BACKLIGHT | BACKLIGHT_ENABLE, -+ 0, PE220X_DC_CMD_REGISTER(port)); -+ ret = phytium_wait_cmd_done(priv, PE220X_DC_CMD_REGISTER(port), -+ FLAG_REQUEST, FLAG_REPLY); ++ pwm_get_state(phytium_dp->pwm, &state); ++ state.enabled = true; ++ pwm_set_relative_duty_cycle(&state, 50, 100); ++ ret = pwm_apply_state(phytium_dp->pwm, &state); ++ ++ gpiod_set_value(priv->edp_bl_en, 1); + if (ret < 0) + DRM_ERROR("%s: failed to enable backlight\n", __func__); +} @@ -11750,45 +12132,41 @@ index 000000000000..08597ae2f2aa +{ + struct drm_device *dev = phytium_dp->dev; + struct phytium_display_private *priv = dev->dev_private; -+ int port = phytium_dp->port; + int ret = 0; + -+ phytium_writel_reg(priv, FLAG_REQUEST | CMD_BACKLIGHT | BACKLIGHT_DISABLE, -+ 0, PE220X_DC_CMD_REGISTER(port)); -+ ret = phytium_wait_cmd_done(priv, PE220X_DC_CMD_REGISTER(port), -+ FLAG_REQUEST, FLAG_REPLY); ++ gpiod_set_value(priv->edp_bl_en, 0); + if (ret < 0) -+ DRM_ERROR("%s: failed to disable backlight\n", __func__); ++ DRM_ERROR("%s: failed to disable backlight, ret = %d\n", __func__, ret); +} + +static uint32_t pe220x_dp_hw_get_backlight(struct phytium_dp_device *phytium_dp) +{ -+ struct drm_device *dev = phytium_dp->dev; -+ struct phytium_display_private *priv = dev->dev_private; -+ int config; -+ uint32_t group_offset = priv->address_transform_base; ++ struct pwm_state state; ++ uint32_t level; + -+ config = phytium_readl_reg(priv, group_offset, PE220X_DC_ADDRESS_TRANSFORM_BACKLIGHT_VALUE); -+ return ((config >> BACKLIGHT_VALUE_SHIFT) & BACKLIGHT_VALUE_MASK); ++ pwm_get_state(phytium_dp->pwm, &state); ++ level = pwm_get_relative_duty_cycle(&state, 100); ++ return level; +} + +static int pe220x_dp_hw_set_backlight(struct phytium_dp_device *phytium_dp, uint32_t level) +{ -+ struct drm_device *dev = phytium_dp->dev; -+ struct phytium_display_private *priv = dev->dev_private; -+ int port = phytium_dp->port; -+ int config = 0; ++ struct pwm_state state; + int ret = 0; + + if (level > PE220X_DP_BACKLIGHT_MAX) { + ret = -EINVAL; + goto out; + } ++ pwm_get_state(phytium_dp->pwm, &state); ++ state.enabled = true; ++ state.period = phytium_dp->pwm->args.period; ++ if (state.period == 0) ++ DRM_ERROR("%s: set pwm period to 0\n", __func__); + -+ config = FLAG_REQUEST | CMD_BACKLIGHT | ((level & BACKLIGHT_MASK) << BACKLIGHT_SHIFT); -+ phytium_writel_reg(priv, config, 0, PE220X_DC_CMD_REGISTER(port)); -+ ret = phytium_wait_cmd_done(priv, PE220X_DC_CMD_REGISTER(port), -+ FLAG_REQUEST, FLAG_REPLY); ++ pwm_set_relative_duty_cycle(&state, level, 100); ++ ++ ret = pwm_apply_state(phytium_dp->pwm, &state); + if (ret < 0) + DRM_ERROR("%s: failed to set backlight\n", __func__); +out: @@ -11841,10 +12219,10 @@ index 000000000000..08597ae2f2aa +} diff --git a/drivers/gpu/drm/phytium/pe220x_dp.h b/drivers/gpu/drm/phytium/pe220x_dp.h new file mode 100644 -index 000000000000..78bb26c7b75c +index 000000000000..f9cf8a0d4f51 --- /dev/null +++ b/drivers/gpu/drm/phytium/pe220x_dp.h -@@ -0,0 +1,14 @@ +@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Phytium display port DRM driver @@ -11855,7 +12233,8 @@ index 000000000000..78bb26c7b75c +#ifndef __PE220X_DP_H__ +#define __PE220X_DP_H__ + -+#define PE220X_DP_BACKLIGHT_MAX 100 ++#define PE220X_DP_BACKLIGHT_MAX 99 ++#define PE220X_DP_BACKLIGHT_MIN 2 + +void pe220x_dp_func_register(struct phytium_dp_device *phytium_dp); +#endif /* __PE220X_DP_H__ */ @@ -12076,10 +12455,10 @@ index 000000000000..696be3006734 +#endif /* __PE220X_REG_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_crtc.c b/drivers/gpu/drm/phytium/phytium_crtc.c new file mode 100644 -index 000000000000..567c5251db00 +index 000000000000..2e932418d981 --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_crtc.c -@@ -0,0 +1,829 @@ +@@ -0,0 +1,856 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Phytium display drm driver + * @@ -12088,7 +12467,11 @@ index 000000000000..567c5251db00 + +#include +#include ++#if defined(__arm__) || defined(__aarch64__) +#include ++#elif defined(__x86_64) ++#include ++#endif +#include +#include "phytium_display_drv.h" +#include "phytium_crtc.h" @@ -12358,14 +12741,22 @@ index 000000000000..567c5251db00 + memset(&kernel_info_width, 0, sizeof(struct filter_blit_array)); + kernel_info_width.kernelStates = tmp; + memset(kernel_info_width.kernelStates, 0, KERNELSTATES); ++#if defined(__arm__) || defined(__aarch64__) + kernel_neon_begin(); ++#elif defined(__x86_64__) ++ kernel_fpu_begin(); ++#endif + dc_calculate_sync_table(FRAMEBUFFER_HORIZONTAL_FILTER_TAP, + phytium_crtc->src_width, + phytium_crtc->dst_width, + &kernel_info_width); + memset(kernelStates, 0, sizeof(kernelStates)); + memcpy(kernelStates, kernel_info_width.kernelStates + 1, KERNELSTATES - 4); ++#if defined(__arm__) || defined(__aarch64__) + kernel_neon_end(); ++#elif defined(__x86_64__) ++ kernel_fpu_end(); ++#endif + phytium_writel_reg(priv, HORI_FILTER_INDEX, + group_offset, PHYTIUM_DC_FRAMEBUFFER_HORI_FILTER_INDEX); + for (i = 0; i < 128; i++) { @@ -12376,12 +12767,20 @@ index 000000000000..567c5251db00 + memset(&kernel_info_width, 0, sizeof(struct filter_blit_array)); + kernel_info_width.kernelStates = tmp; + memset(kernel_info_width.kernelStates, 0, KERNELSTATES); ++#if defined(__arm__) || defined(__aarch64__) + kernel_neon_begin(); ++#elif defined(__x86_64__) ++ kernel_fpu_begin(); ++#endif + dc_calculate_sync_table(FRAMEBUFFER_FILTER_TAP, phytium_crtc->src_height, + phytium_crtc->dst_height, &kernel_info_width); + memset(kernelStates, 0, sizeof(kernelStates)); + memcpy(kernelStates, kernel_info_width.kernelStates + 1, KERNELSTATES - 4); ++#if defined(__arm__) || defined(__aarch64__) + kernel_neon_end(); ++#elif defined(__x86_64__) ++ kernel_fpu_end(); ++#endif + phytium_writel_reg(priv, VERT_FILTER_INDEX, + group_offset, PHYTIUM_DC_FRAMEBUFFER_VERT_FILTER_INDEX); + for (i = 0; i < 128; i++) @@ -12654,7 +13053,8 @@ index 000000000000..567c5251db00 + else + config &= (~FRAMEBUFFER_SCALE_ENABLE); + -+ config |= FRAMEBUFFER_GAMMA_ENABLE; ++ if (!priv->info.bmc_mode) ++ config |= FRAMEBUFFER_GAMMA_ENABLE; + + if (crtc->state->gamma_lut) + phytium_crtc_gamma_set(crtc); @@ -12831,6 +13231,7 @@ index 000000000000..567c5251db00 + struct phytium_crtc_state *phytium_crtc_state; + struct phytium_plane *phytium_primary_plane = NULL; + struct phytium_plane *phytium_cursor_plane = NULL; ++ struct drm_plane *cursor_base = NULL; + struct phytium_display_private *priv = dev->dev_private; + int ret; + @@ -12873,16 +13274,21 @@ index 000000000000..567c5251db00 + goto failed_create_primary; + } + -+ phytium_cursor_plane = phytium_cursor_plane_create(dev, phys_pipe); -+ if (IS_ERR(phytium_cursor_plane)) { -+ ret = PTR_ERR(phytium_cursor_plane); -+ DRM_ERROR("create cursor plane failed, phys_pipe(%d)\n", phys_pipe); -+ goto failed_create_cursor; ++ if (priv->info.bmc_mode) { ++ cursor_base = NULL; ++ } else { ++ phytium_cursor_plane = phytium_cursor_plane_create(dev, phys_pipe); ++ if (IS_ERR(phytium_cursor_plane)) { ++ ret = PTR_ERR(phytium_cursor_plane); ++ DRM_ERROR("create cursor plane failed, phys_pipe(%d)\n", phys_pipe); ++ goto failed_create_cursor; ++ } ++ cursor_base = &phytium_cursor_plane->base; + } + + ret = drm_crtc_init_with_planes(dev, &phytium_crtc->base, + &phytium_primary_plane->base, -+ &phytium_cursor_plane->base, ++ cursor_base, + &phytium_crtc_funcs, + "phys_pipe %d", phys_pipe); + @@ -13437,10 +13843,10 @@ index 000000000000..7e632bf9c521 +#endif /* __PHYTIUM_DEBUGFS_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_display_drv.c b/drivers/gpu/drm/phytium/phytium_display_drv.c new file mode 100644 -index 000000000000..5a22116e1a73 +index 000000000000..3f0084610fb1 --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_display_drv.c -@@ -0,0 +1,439 @@ +@@ -0,0 +1,475 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Phytium display drm driver + * @@ -13496,7 +13902,7 @@ index 000000000000..5a22116e1a73 + uint32_t request_bit, + uint32_t reply_bit) +{ -+ int timeout = 500, config = 0, ret = 0; ++ int timeout = 1000, config = 0, ret = 0; + + do { + mdelay(1); @@ -13693,7 +14099,7 @@ index 000000000000..5a22116e1a73 + goto failed_modeset_init; + } + -+ if (priv->support_memory_type & MEMORY_TYPE_VRAM) ++ if (priv->support_memory_type & (MEMORY_TYPE_VRAM_WC | MEMORY_TYPE_VRAM_DEVICE)) + priv->vram_hw_init(priv); + + ret = drm_irq_install(dev, priv->irq); @@ -13724,8 +14130,43 @@ index 000000000000..5a22116e1a73 + drm_mode_config_cleanup(dev); +} + ++static const struct vm_operations_struct phytium_vm_ops = { ++ .open = drm_gem_vm_open, ++ .close = drm_gem_vm_close, ++}; ++ ++/* phytium display specific ioctls ++ * The device specific ioctl range is 0x40 to 0x79. ++ */ ++#define DRM_PHYTIUM_VRAM_TYPE_DEVICE 0x0 ++#define DRM_PHYTIUM_BMC_DEVICE 0x1 ++#define DRM_IOCTL_PHYTIUM_VRAM_TYPE_DEVICE DRM_IO(DRM_COMMAND_BASE\ ++ + DRM_PHYTIUM_VRAM_TYPE_DEVICE) ++#define DRM_IOCTL_PHYTIUM_IS_BMC_DEVICE DRM_IO(DRM_COMMAND_BASE\ ++ + DRM_PHYTIUM_BMC_DEVICE) ++ ++static int phytium_ioctl_check_vram_device(struct drm_device *dev, void *data, ++ struct drm_file *file_priv) ++{ ++ struct phytium_display_private *priv = dev->dev_private; ++ ++ return ((priv->support_memory_type == MEMORY_TYPE_VRAM_DEVICE) ? 1 : 0); ++} ++ ++static int phytium_ioctl_check_bmc_device(struct drm_device *dev, void *data, ++ struct drm_file *file_priv) ++{ ++ struct phytium_display_private *priv = dev->dev_private; ++ ++ return priv->info.bmc_mode ? 1 : 0; ++} ++ +static const struct drm_ioctl_desc phytium_ioctls[] = { + /* for test, none so far */ ++ DRM_IOCTL_DEF_DRV(PHYTIUM_VRAM_TYPE_DEVICE, phytium_ioctl_check_vram_device, ++ DRM_AUTH|DRM_UNLOCKED), ++ DRM_IOCTL_DEF_DRV(PHYTIUM_IS_BMC_DEVICE, phytium_ioctl_check_bmc_device, ++ DRM_AUTH|DRM_UNLOCKED), +}; + +static const struct file_operations phytium_drm_driver_fops = { @@ -13825,7 +14266,7 @@ index 000000000000..5a22116e1a73 + phytium_crtc_resume(dev); + phytium_gem_resume(dev); + -+ if (priv->support_memory_type & MEMORY_TYPE_VRAM) ++ if (priv->support_memory_type & (MEMORY_TYPE_VRAM_WC | MEMORY_TYPE_VRAM_DEVICE)) + priv->vram_hw_init(priv); + + ret = drm_atomic_helper_resume(dev, dev->mode_config.suspend_state); @@ -13877,15 +14318,16 @@ index 000000000000..5a22116e1a73 +module_exit(phytium_display_exit); + +MODULE_LICENSE("GPL"); ++MODULE_VERSION(DC_DRIVER_VERSION); +MODULE_AUTHOR("Yang Xun "); +MODULE_AUTHOR("Shaojun Yang "); +MODULE_DESCRIPTION("Phytium Display Controller"); diff --git a/drivers/gpu/drm/phytium/phytium_display_drv.h b/drivers/gpu/drm/phytium/phytium_display_drv.h new file mode 100644 -index 000000000000..f36fff9b8754 +index 000000000000..e15fc6aba2ac --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_display_drv.h -@@ -0,0 +1,178 @@ +@@ -0,0 +1,187 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Phytium display drm driver + * @@ -13900,6 +14342,7 @@ index 000000000000..f36fff9b8754 +#include +#endif +#include ++#include +#include + +#define DEBUG_LOG 0 @@ -13912,6 +14355,7 @@ index 000000000000..f36fff9b8754 +#define DRV_DATE "20201220" +#define DRV_MAJOR 1 +#define DRV_MINOR 1 ++#define DC_DRIVER_VERSION "1.0.0" + +/* come from GPU */ +#define DRM_FORMAT_MOD_VENDOR_PHYTIUM 0x92 @@ -13941,9 +14385,10 @@ index 000000000000..f36fff9b8754 + PHYTIUM_MEM_STATE_TYPE_COUNT, +}; + -+#define MEMORY_TYPE_VRAM 0x1 ++#define MEMORY_TYPE_VRAM_WC 0x1 +#define MEMORY_TYPE_SYSTEM_CARVEOUT 0x2 +#define MEMORY_TYPE_SYSTEM_UNIFIED 0x4 ++#define MEMORY_TYPE_VRAM_DEVICE 0x8 + +#define IS_PLATFORM(priv, p) ((priv)->info.platform_mask & BIT(p)) + @@ -13956,11 +14401,15 @@ index 000000000000..f36fff9b8754 + unsigned char num_pipes; + unsigned char total_pipes; + unsigned char edp_mask; ++ bool bmc_mode; ++ unsigned char reserve[2]; + unsigned int crtc_clock_max; + unsigned int hdisplay_max; + unsigned int vdisplay_max; + unsigned int backlight_max; ++ unsigned int backlight_min; + unsigned long address_mask; ++ struct pwm_device *pwm; +}; + +struct phytium_display_private { @@ -14006,6 +14455,8 @@ index 000000000000..f36fff9b8754 + /* DMA info */ + int dma_inited; + struct dma_chan *dma_chan; ++ /*BL GPIO info*/ ++ struct gpio_desc *edp_bl_en, *edp_power_en; +}; + +static inline unsigned int @@ -14066,10 +14517,10 @@ index 000000000000..f36fff9b8754 +#endif /* __PHYTIUM_DISPLAY_DRV_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_dp.c b/drivers/gpu/drm/phytium/phytium_dp.c new file mode 100644 -index 000000000000..7eefd69766a7 +index 000000000000..92ad326d06fb --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_dp.c -@@ -0,0 +1,2662 @@ +@@ -0,0 +1,2666 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Phytium display drm driver + * @@ -16291,13 +16742,13 @@ index 000000000000..7eefd69766a7 + case 8: + break; + default: -+ DRM_INFO("not support bpc(%d)\n", display_info->bpc); ++ DRM_DEBUG_KMS("not support bpc(%d)\n", display_info->bpc); + display_info->bpc = 8; + break; + } + + if ((display_info->color_formats & DRM_COLOR_FORMAT_RGB444) == 0) { -+ DRM_INFO("not support color_format(%d)\n", display_info->color_formats); ++ DRM_DEBUG_KMS("not support color_format(%d)\n", display_info->color_formats); + display_info->color_formats = DRM_COLOR_FORMAT_RGB444; + } + @@ -16497,8 +16948,7 @@ index 000000000000..7eefd69766a7 + .hook_plugged_cb = phytium_dp_audio_hook_plugged_cb, +}; + -+static int phytium_dp_audio_codec_init(struct phytium_dp_device *phytium_dp, -+ const int port) ++static int phytium_dp_audio_codec_init(struct phytium_dp_device *phytium_dp) +{ + struct device *dev = phytium_dp->dev->dev; + struct hdmi_codec_pdata codec_data = { @@ -16510,9 +16960,12 @@ index 000000000000..7eefd69766a7 + }; + + phytium_dp->audio_pdev = platform_device_register_data(dev, HDMI_CODEC_DRV_NAME, -+ codec_id + port, ++ codec_id, + &codec_data, sizeof(codec_data)); + ++ if (!PTR_ERR_OR_ZERO(phytium_dp->audio_pdev)) ++ codec_id += 1; ++ + return PTR_ERR_OR_ZERO(phytium_dp->audio_pdev); +} + @@ -16521,6 +16974,7 @@ index 000000000000..7eefd69766a7 + if (!PTR_ERR_OR_ZERO(phytium_dp->audio_pdev)) + platform_device_unregister(phytium_dp->audio_pdev); + phytium_dp->audio_pdev = NULL; ++ codec_id -= 1; +} + +static long phytium_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) @@ -16679,6 +17133,7 @@ index 000000000000..7eefd69766a7 + if (phytium_dp_is_edp(phytium_dp, port)) { + phytium_dp->is_edp = true; + type = DRM_MODE_CONNECTOR_eDP; ++ phytium_dp->pwm = priv->info.pwm; + phytium_dp_panel_init_backlight_funcs(phytium_dp); + phytium_edp_backlight_off(phytium_dp); + phytium_edp_panel_poweroff(phytium_dp); @@ -16714,7 +17169,7 @@ index 000000000000..7eefd69766a7 + drm_connector_helper_add(&phytium_dp->connector, &phytium_connector_helper_funcs); + drm_connector_attach_encoder(&phytium_dp->connector, &phytium_dp->encoder); + -+ ret = phytium_dp_audio_codec_init(phytium_dp, port); ++ ret = phytium_dp_audio_codec_init(phytium_dp); + if (ret) { + DRM_ERROR("failed to initialize audio codec\n"); + goto failed_connector_init; @@ -16734,10 +17189,10 @@ index 000000000000..7eefd69766a7 +} diff --git a/drivers/gpu/drm/phytium/phytium_dp.h b/drivers/gpu/drm/phytium/phytium_dp.h new file mode 100644 -index 000000000000..047357a0d523 +index 000000000000..bbcf133d6663 --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_dp.h -@@ -0,0 +1,155 @@ +@@ -0,0 +1,156 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Phytium display drm driver + * @@ -16852,6 +17307,7 @@ index 000000000000..047357a0d523 + + struct phytium_panel panel; + struct drm_display_mode native_mode; ++ struct pwm_device *pwm; +}; + +union phytium_phy_tp { @@ -16895,10 +17351,10 @@ index 000000000000..047357a0d523 +#endif /* __PHYTIUM_DP_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_fb.c b/drivers/gpu/drm/phytium/phytium_fb.c new file mode 100644 -index 000000000000..749aaa0eac95 +index 000000000000..feb17920a986 --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_fb.c -@@ -0,0 +1,143 @@ +@@ -0,0 +1,146 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Phytium display drm driver + * @@ -16963,6 +17419,9 @@ index 000000000000..749aaa0eac95 + + drm_helper_mode_fill_fb_struct(dev, &phytium_fb->base, mode_cmd); + ++ /* In UEFI, efifb may also use dc hardware, remove it and use dcdrmfb */ ++ drm_fb_helper_remove_conflicting_framebuffers(NULL, "dcdrmfb", false); ++ + ret = drm_framebuffer_init(dev, &phytium_fb->base, &viv_fb_funcs); + + if (ret) { @@ -17269,10 +17728,10 @@ index 000000000000..ff63ba84d772 +#endif /* _PHYTIUM_FBDEV_H */ diff --git a/drivers/gpu/drm/phytium/phytium_gem.c b/drivers/gpu/drm/phytium/phytium_gem.c new file mode 100644 -index 000000000000..03a3070a3a56 +index 000000000000..d6f5494d940c --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_gem.c -@@ -0,0 +1,535 @@ +@@ -0,0 +1,544 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Phytium display drm driver + * @@ -17362,14 +17821,15 @@ index 000000000000..03a3070a3a56 + return ERR_PTR(-ENOMEM); + } + -+ if ((phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM) || ++ if ((phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM_WC) || ++ (phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM_DEVICE) || + (phytium_gem_obj->memory_type == MEMORY_TYPE_SYSTEM_CARVEOUT)) { + ret = sg_alloc_table(sgt, 1, GFP_KERNEL); + if (ret) { + DRM_ERROR("failed to allocate sg\n"); + goto sgt_free; + } -+ page = phys_to_page(phytium_gem_obj->phys_addr); ++ page = pfn_to_page(__phys_to_pfn(phytium_gem_obj->phys_addr)); + sg_set_page(sgt->sgl, page, PAGE_ALIGN(phytium_gem_obj->size), 0); + } else if (phytium_gem_obj->memory_type == MEMORY_TYPE_SYSTEM_UNIFIED) { + ret = dma_get_sgtable_attrs(dev->dev, sgt, phytium_gem_obj->vaddr, @@ -17556,7 +18016,8 @@ index 000000000000..03a3070a3a56 + int ret = 0; + + list_for_each_entry(phytium_gem_obj, &priv->gem_list_head, list) { -+ if (phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM) ++ if ((phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM_WC) && ++ (phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM_DEVICE)) + continue; + + phytium_gem_obj->vaddr_save = vmalloc(phytium_gem_obj->size); @@ -17575,7 +18036,8 @@ index 000000000000..03a3070a3a56 + return 0; +malloc_failed: + list_for_each_entry(phytium_gem_obj, &priv->gem_list_head, list) { -+ if (phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM) ++ if ((phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM_WC) && ++ (phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM_DEVICE)) + continue; + + if (phytium_gem_obj->vaddr_save) { @@ -17592,7 +18054,8 @@ index 000000000000..03a3070a3a56 + struct phytium_gem_object *phytium_gem_obj = NULL; + + list_for_each_entry(phytium_gem_obj, &priv->gem_list_head, list) { -+ if (phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM) ++ if ((phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM_WC) && ++ (phytium_gem_obj->memory_type != MEMORY_TYPE_VRAM_DEVICE)) + continue; + + memcpy(phytium_gem_obj->vaddr, phytium_gem_obj->vaddr_save, phytium_gem_obj->size); @@ -17611,7 +18074,8 @@ index 000000000000..03a3070a3a56 + DRM_DEBUG_KMS("free phytium_gem_obj iova:0x%pa size:0x%lx\n", + &phytium_gem_obj->iova, phytium_gem_obj->size); + if (phytium_gem_obj->vaddr) { -+ if (phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM) { ++ if ((phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM_WC) || ++ (phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM_DEVICE)) { + phytium_memory_pool_free(priv, phytium_gem_obj->vaddr, size); + priv->mem_state[PHYTIUM_MEM_VRAM_ALLOC] -= size; + } else if (phytium_gem_obj->memory_type == MEMORY_TYPE_SYSTEM_CARVEOUT) { @@ -17644,10 +18108,14 @@ index 000000000000..03a3070a3a56 + vma->vm_pgoff = 0; + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); + -+ if (phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM) { ++ if (phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM_WC) { + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + ret = remap_pfn_range(vma, vma->vm_start, pfn, + vma->vm_end - vma->vm_start, vma->vm_page_prot); ++ } else if (phytium_gem_obj->memory_type == MEMORY_TYPE_VRAM_DEVICE) { ++ vma->vm_page_prot = pgprot_device(vma->vm_page_prot); ++ ret = remap_pfn_range(vma, vma->vm_start, pfn, ++ vma->vm_end - vma->vm_start, vma->vm_page_prot); + } else if (phytium_gem_obj->memory_type == MEMORY_TYPE_SYSTEM_CARVEOUT) { + ret = remap_pfn_range(vma, vma->vm_start, pfn, + vma->vm_end - vma->vm_start, vma->vm_page_prot); @@ -17712,7 +18180,7 @@ index 000000000000..03a3070a3a56 + goto failed_object_init; + } + -+ if (priv->support_memory_type & MEMORY_TYPE_VRAM) { ++ if (priv->support_memory_type & (MEMORY_TYPE_VRAM_WC | MEMORY_TYPE_VRAM_DEVICE)) { + ret = phytium_memory_pool_alloc(priv, &phytium_gem_obj->vaddr, + &phytium_gem_obj->phys_addr, size); + if (ret) { @@ -17720,7 +18188,7 @@ index 000000000000..03a3070a3a56 + goto failed_dma_alloc; + } + phytium_gem_obj->iova = phytium_gem_obj->phys_addr; -+ phytium_gem_obj->memory_type = MEMORY_TYPE_VRAM; ++ phytium_gem_obj->memory_type = priv->support_memory_type; + priv->mem_state[PHYTIUM_MEM_VRAM_ALLOC] += size; + } else if (priv->support_memory_type & MEMORY_TYPE_SYSTEM_CARVEOUT) { + ret = phytium_memory_pool_alloc(priv, &phytium_gem_obj->vaddr, @@ -17729,7 +18197,7 @@ index 000000000000..03a3070a3a56 + DRM_ERROR("fail to allocate carveout memory with size %lx\n", size); + goto failed_dma_alloc; + } -+ page = phys_to_page(phytium_gem_obj->phys_addr); ++ page = pfn_to_page(__phys_to_pfn(phytium_gem_obj->phys_addr)); + phytium_gem_obj->iova = dma_map_page(dev->dev, page, 0, size, DMA_TO_DEVICE); + if (dma_mapping_error(dev->dev, phytium_gem_obj->iova)) { + DRM_ERROR("fail to dma map carveout memory with size %lx\n", size); @@ -17861,7 +18329,7 @@ index 000000000000..50fb4f4f7b6b +#endif /* __PHYTIUM_GEM_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_panel.c b/drivers/gpu/drm/phytium/phytium_panel.c new file mode 100644 -index 000000000000..efb839ae02ea +index 000000000000..60a20b9e645c --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_panel.c @@ -0,0 +1,420 @@ @@ -18062,7 +18530,7 @@ index 000000000000..efb839ae02ea + struct phytium_display_private *priv = dev->dev_private; + + panel->max = priv->info.backlight_max; -+ panel->min = 0; ++ panel->min = priv->info.backlight_min; + panel->level = phytium_dp_hw_get_backlight(panel); +} + @@ -18078,7 +18546,7 @@ index 000000000000..efb839ae02ea + phytium_dp->panel.set_backlight = phytium_dp_aux_set_backlight; + phytium_dp->panel.get_backlight = phytium_dp_aux_get_backlight; + } else { -+ DRM_DEBUG_KMS("SE Backlight Control Supported!\n"); ++ DRM_DEBUG_KMS("PWM Backlight Control Supported!\n"); + phytium_dp->panel.setup_backlight = phytium_dp_hw_setup_backlight; + phytium_dp->panel.enable_backlight = phytium_dp_hw_enable_backlight; + phytium_dp->panel.disable_backlight = phytium_dp_hw_disable_backlight; @@ -18339,10 +18807,10 @@ index 000000000000..ff4d760d8400 +#endif /* __PHYTIUM_PANEL_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_pci.c b/drivers/gpu/drm/phytium/phytium_pci.c new file mode 100644 -index 000000000000..47f739e55db2 +index 000000000000..bafb8410701e --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_pci.c -@@ -0,0 +1,401 @@ +@@ -0,0 +1,446 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Phytium display drm driver + * @@ -18351,6 +18819,7 @@ index 000000000000..47f739e55db2 + +#include +#include ++#include +#include +#include "phytium_display_drv.h" +#include "phytium_pci.h" @@ -18364,9 +18833,6 @@ index 000000000000..47f739e55db2 +int dc_msi_enable; +module_param(dc_msi_enable, int, 0644); +MODULE_PARM_DESC(dc_msi_enable, "Enable DC msi interrupt (0-disabled; 1-enabled; default-0)"); -+static bool x100_dc_sysmem = false; -+module_param(x100_dc_sysmem, bool, 0644); -+MODULE_PARM_DESC(x100_dc_sysmem, "x100 dc alloc location (1-system_mem; 0-vram; default-0)"); + +void phytium_pci_vram_hw_init(struct phytium_display_private *priv) +{ @@ -18375,25 +18841,40 @@ index 000000000000..47f739e55db2 + pci_priv->dc_hw_vram_init(priv, priv->pool_phys_addr, priv->pool_size); +} + ++static bool phytium_pci_host_is_5c01(struct pci_bus *bus) ++{ ++ struct pci_bus *child = bus; ++ struct pci_dev *root = NULL; ++ ++ while (child) { ++ if (child->parent->parent) ++ child = child->parent; ++ else ++ break; ++ } ++ ++ root = child->self; ++ if ((root->vendor == 0x1db7) && (root->device == 0x5c01)) ++ return true; ++ return false; ++} ++ +int phytium_pci_vram_init(struct pci_dev *pdev, struct phytium_display_private *priv) +{ + int ret = 0; + -+ /* The dumb buffer is forced to be requested from system memory, -+ * we need to add the following parameter to grub.cfg or uboot (cmdline): -+ * cma=1024M phytium-dc-drm.x100_dc_sysmem -+ */ -+ if(!x100_dc_sysmem) { -+ priv->pool_phys_addr = pci_resource_start(pdev, 2); -+ priv->pool_size = pci_resource_len(pdev, 2); -+ } else { -+ priv->pool_phys_addr = 0; -+ priv->pool_size = 0; -+ } -+ ++ priv->pool_phys_addr = pci_resource_start(pdev, 2); ++ priv->pool_size = pci_resource_len(pdev, 2); + if ((priv->pool_phys_addr != 0) && (priv->pool_size != 0)) { -+ priv->pool_virt_addr = devm_ioremap_wc(&pdev->dev, priv->pool_phys_addr, -+ priv->pool_size); ++ if ((pdev->device == 0xdc3e) && phytium_pci_host_is_5c01(pdev->bus)) { ++ priv->pool_virt_addr = devm_ioremap(&pdev->dev, priv->pool_phys_addr, ++ priv->pool_size); ++ priv->support_memory_type = MEMORY_TYPE_VRAM_DEVICE; ++ } else { ++ priv->pool_virt_addr = devm_ioremap_wc(&pdev->dev, priv->pool_phys_addr, ++ priv->pool_size); ++ priv->support_memory_type = MEMORY_TYPE_VRAM_WC; ++ } + if (priv->pool_virt_addr == NULL) { + DRM_ERROR("pci vram ioremap fail, addr:0x%llx, size:0x%llx\n", + priv->pool_phys_addr, priv->pool_size); @@ -18405,7 +18886,6 @@ index 000000000000..47f739e55db2 + goto failed_init_memory_pool; + + priv->mem_state[PHYTIUM_MEM_VRAM_TOTAL] = priv->pool_size; -+ priv->support_memory_type = MEMORY_TYPE_VRAM; + priv->vram_hw_init = phytium_pci_vram_hw_init; + } else { + DRM_DEBUG_KMS("not support vram\n"); @@ -18425,7 +18905,8 @@ index 000000000000..47f739e55db2 + +void phytium_pci_vram_fini(struct pci_dev *pdev, struct phytium_display_private *priv) +{ -+ if (priv->support_memory_type == MEMORY_TYPE_VRAM) { ++ if ((priv->support_memory_type == MEMORY_TYPE_VRAM_WC) || ++ (priv->support_memory_type == MEMORY_TYPE_VRAM_DEVICE)) { + phytium_memory_pool_fini(&pdev->dev, priv); + devm_iounmap(&pdev->dev, priv->pool_virt_addr); + } @@ -18571,11 +19052,39 @@ index 000000000000..47f739e55db2 + devm_kfree(&pdev->dev, pci_priv); +} + ++static int phytium_kick_out_firmware_fb(struct pci_dev *pdev) ++{ ++ struct apertures_struct *ap; ++ ++ ap = alloc_apertures(1); ++ if (!ap) ++ return -ENOMEM; ++ ++ ap->ranges[0].base = pci_resource_start(pdev, 2); ++ ap->ranges[0].size = pci_resource_len(pdev, 2); ++ ++ drm_fb_helper_remove_conflicting_framebuffers(ap, "phytiumdrmfb", ++ false); ++ kfree(ap); ++ ++ return 0; ++} ++ +static int phytium_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + struct phytium_display_private *priv = NULL; + struct drm_device *dev = NULL; + int ret = 0; ++ struct phytium_device_info *phytium_info = (struct phytium_device_info *)ent->driver_data; ++ ++ if (phytium_info) { ++ if (phytium_info->platform_mask & BIT(PHYTIUM_PLATFORM_PE220X)) ++ phytium_display_drm_driver.name = "pe220x"; ++ } ++ ++ ret = phytium_kick_out_firmware_fb(pdev); ++ if (ret) ++ DRM_ERROR("failed to remove conflicting framebuffers\n"); + + dev = drm_dev_alloc(&phytium_display_drm_driver, &pdev->dev); + if (IS_ERR(dev)) { @@ -18717,6 +19226,8 @@ index 000000000000..47f739e55db2 + .vdisplay_max = PX210_DC_VDISPLAY_MAX, + .address_mask = PX210_DC_ADDRESS_MASK, + .backlight_max = PX210_DP_BACKLIGHT_MAX, ++ .backlight_min = PX210_DP_BACKLIGHT_MIN, ++ .bmc_mode = false, +}; + +static const struct phytium_device_info pe220x_info = { @@ -18727,6 +19238,8 @@ index 000000000000..47f739e55db2 + .vdisplay_max = PE220X_DC_VDISPLAY_MAX, + .address_mask = PE220X_DC_ADDRESS_MASK, + .backlight_max = PE220X_DP_BACKLIGHT_MAX, ++ .backlight_min = PE220X_DP_BACKLIGHT_MIN, ++ .bmc_mode = false, +}; + +static const struct pci_device_id phytium_display_pci_ids[] = { @@ -18778,10 +19291,10 @@ index 000000000000..7ac37971759c +#endif /* __PHYTIUM_PCI_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_plane.c b/drivers/gpu/drm/phytium/phytium_plane.c new file mode 100644 -index 000000000000..813944676d3c +index 000000000000..d5b3d9544f85 --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_plane.c -@@ -0,0 +1,683 @@ +@@ -0,0 +1,688 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Phytium display drm driver + * @@ -19375,7 +19888,12 @@ index 000000000000..813944676d3c + phytium_plane->dc_hw_update_primary_hi_addr = px210_dc_hw_update_primary_hi_addr; + phytium_plane->dc_hw_update_cursor_hi_addr = NULL; + } else if (IS_PE220X(priv)) { -+ phytium_plane->dc_hw_plane_get_format = pe220x_dc_hw_plane_get_primary_format; ++ if (priv->info.bmc_mode) ++ phytium_plane->dc_hw_plane_get_format = ++ pe220x_dc_bmc_hw_plane_get_primary_format; ++ else ++ phytium_plane->dc_hw_plane_get_format = ++ pe220x_dc_hw_plane_get_primary_format; + phytium_plane->dc_hw_update_dcreq = NULL; + phytium_plane->dc_hw_update_primary_hi_addr = pe220x_dc_hw_update_primary_hi_addr; + phytium_plane->dc_hw_update_cursor_hi_addr = NULL; @@ -19519,10 +20037,10 @@ index 000000000000..25b6bba6c87d +#endif /* __PHYTIUM_PLANE_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_platform.c b/drivers/gpu/drm/phytium/phytium_platform.c new file mode 100644 -index 000000000000..f4e35234339a +index 000000000000..42aa8206353a --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_platform.c -@@ -0,0 +1,309 @@ +@@ -0,0 +1,388 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Phytium display engine DRM driver @@ -19531,9 +20049,13 @@ index 000000000000..f4e35234339a + */ + +#include ++#include +#include +#include +#include ++#include ++#include ++#include +#include "phytium_display_drv.h" +#include "phytium_platform.h" +#include "phytium_dp.h" @@ -19544,13 +20066,29 @@ index 000000000000..f4e35234339a +int phytium_platform_carveout_mem_init(struct platform_device *pdev, + struct phytium_display_private *priv) +{ -+ struct resource *res; ++ struct device_node *np; ++ struct resource res; ++ struct resource *pres; + int ret = 0; + -+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1); -+ if (res) { -+ priv->pool_size = resource_size(res); -+ priv->pool_phys_addr = res->start; ++ if (pdev->dev.of_node) { ++ np = of_parse_phandle(pdev->dev.of_node, "memory-region", 0); ++ if(!np) ++ goto next; ++ ret = of_address_to_resource(np, 0, &res); ++ if(ret) ++ DRM_ERROR("No memory address assigned to the region\n"); ++ else { ++ priv->pool_size = resource_size(&res); ++ priv->pool_phys_addr = res.start; ++ } ++ } ++ ++next: ++ pres = platform_get_resource(pdev, IORESOURCE_MEM, 1); ++ if (pres) { ++ priv->pool_size = resource_size(pres); ++ priv->pool_phys_addr = pres->start; + } + + if ((priv->pool_phys_addr != 0) && (priv->pool_size != 0)) { @@ -19633,6 +20171,27 @@ index 000000000000..f4e35234339a + dev_err(&pdev->dev, "missing edp_mask property from dts\n"); + goto failed; + } ++ if (priv->info.edp_mask) { ++ priv->info.pwm = devm_pwm_get(&pdev->dev, NULL); ++ if (IS_ERR(priv->info.pwm)) { ++ dev_err(&pdev->dev, "Failed to request PWM device: %ld\n", ++ PTR_ERR(priv->info.pwm)); ++ goto failed; ++ } ++ priv->edp_bl_en = gpiod_get(&pdev->dev, "edp-bl-en", GPIOD_OUT_HIGH); ++ if (!priv->edp_bl_en) { ++ dev_err(&pdev->dev, "Failed to get edp_en gpio\n"); ++ goto failed; ++ } ++ priv->edp_power_en = gpiod_get(&pdev->dev, "edp-power-en", GPIOD_OUT_HIGH); ++ if (!priv->edp_power_en) { ++ dev_err(&pdev->dev, "Failed to get edp_pwr_en gpio\n"); ++ goto failed; ++ } ++ // set GPIO pin output ++ gpiod_direction_output(priv->edp_power_en, 0); ++ gpiod_direction_output(priv->edp_bl_en, 0); ++ } + } else if (has_acpi_companion(&pdev->dev)) { + phytium_info = (struct phytium_device_info *)acpi_device_get_match_data(&pdev->dev); + if (!phytium_info) { @@ -19652,6 +20211,27 @@ index 000000000000..f4e35234339a + dev_err(&pdev->dev, "missing edp_mask property from acpi\n"); + goto failed; + } ++ if (priv->info.edp_mask) { ++ priv->info.pwm = devm_pwm_get(&pdev->dev, NULL); ++ if (IS_ERR(priv->info.pwm)) { ++ dev_err(&pdev->dev, "Failed to request PWM device: %ld\n", ++ PTR_ERR(priv->info.pwm)); ++ goto failed; ++ } ++ priv->edp_bl_en = gpiod_get(&pdev->dev, "edp-bl-en", GPIOD_OUT_HIGH); ++ if (!priv->edp_bl_en) { ++ dev_err(&pdev->dev, "Failed to get edp_en gpio\n"); ++ goto failed; ++ } ++ priv->edp_power_en = gpiod_get(&pdev->dev, "edp-power-en", GPIOD_OUT_HIGH); ++ if (!priv->edp_power_en) { ++ dev_err(&pdev->dev, "Failed to get edp_pwr_en gpio\n"); ++ goto failed; ++ } ++ // set GPIO pin output ++ gpiod_direction_output(priv->edp_power_en, 0); ++ gpiod_direction_output(priv->edp_bl_en, 0); ++ } + } + + priv->info.num_pipes = 0; @@ -19701,8 +20281,23 @@ index 000000000000..f4e35234339a +{ + struct phytium_display_private *priv = NULL; + struct drm_device *dev = NULL; ++ struct phytium_device_info *phytium_info = NULL; + int ret = 0; + ++ if (pdev->dev.of_node) { ++ phytium_info = (struct phytium_device_info *)of_device_get_match_data(&pdev->dev); ++ if (phytium_info) { ++ if (phytium_info->platform_mask & BIT(PHYTIUM_PLATFORM_PE220X)) ++ phytium_display_drm_driver.name = "pe220x"; ++ } ++ } else if (has_acpi_companion(&pdev->dev)) { ++ phytium_info = (struct phytium_device_info *)acpi_device_get_match_data(&pdev->dev); ++ if (phytium_info) { ++ if (phytium_info->platform_mask & BIT(PHYTIUM_PLATFORM_PE220X)) ++ phytium_display_drm_driver.name = "pe220x"; ++ } ++ } ++ + dev = drm_dev_alloc(&phytium_display_drm_driver, &pdev->dev); + if (IS_ERR(dev)) { + DRM_ERROR("failed to allocate drm_device\n"); @@ -19795,6 +20390,8 @@ index 000000000000..f4e35234339a + .vdisplay_max = PE220X_DC_VDISPLAY_MAX, + .address_mask = PE220X_DC_ADDRESS_MASK, + .backlight_max = PE220X_DP_BACKLIGHT_MAX, ++ .backlight_min = PE220X_DP_BACKLIGHT_MIN, ++ .bmc_mode = false, +}; + +static const struct of_device_id display_of_match[] = { @@ -19858,7 +20455,7 @@ index 000000000000..b754ef0a137a +#endif /* __PHYTIUM_PLATFORM_H__ */ diff --git a/drivers/gpu/drm/phytium/phytium_reg.h b/drivers/gpu/drm/phytium/phytium_reg.h new file mode 100644 -index 000000000000..4dca6c023127 +index 000000000000..f5d4a6945c35 --- /dev/null +++ b/drivers/gpu/drm/phytium/phytium_reg.h @@ -0,0 +1,366 @@ @@ -20132,7 +20729,7 @@ index 000000000000..4dca6c023127 +#define PHYTIUM_DP_INTERRUPT_MASK 0x0144 + #define HPD_IRQ_MASK (1<<1) + #define HPD_EVENT_MASK (1<<0) -+ #define HPD_OTHER_MASK 0x3c ++ #define HPD_OTHER_MASK 0x7c +#define PHYTIUM_DP_AUX_REPLY_DATA_COUNT 0x0148 +#define PHYTIUM_DP_AUX_STATUS 0x014C + #define REPLY_RECEIVED 0x1 @@ -20230,10 +20827,10 @@ index 000000000000..4dca6c023127 +#endif /* __PHYTIUM_REG_H__ */ diff --git a/drivers/gpu/drm/phytium/px210_dc.c b/drivers/gpu/drm/phytium/px210_dc.c new file mode 100644 -index 000000000000..84fd44a130f0 +index 000000000000..6b416fc7737e --- /dev/null +++ b/drivers/gpu/drm/phytium/px210_dc.c -@@ -0,0 +1,326 @@ +@@ -0,0 +1,328 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Phytium display drm driver + * @@ -20242,7 +20839,9 @@ index 000000000000..84fd44a130f0 + +#include +#include ++#if defined(__arm__) || defined(__aarch64__) +#include ++#endif +#include +#include "phytium_display_drv.h" +#include "px210_reg.h" @@ -21524,10 +22123,10 @@ index 000000000000..7c655563132a +} diff --git a/drivers/gpu/drm/phytium/px210_dp.h b/drivers/gpu/drm/phytium/px210_dp.h new file mode 100644 -index 000000000000..07e40265f02c +index 000000000000..b62a3c833ac7 --- /dev/null +++ b/drivers/gpu/drm/phytium/px210_dp.h -@@ -0,0 +1,13 @@ +@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Phytium display drm driver + * @@ -21538,6 +22137,7 @@ index 000000000000..07e40265f02c +#define __PX210_DP_H__ + +#define PX210_DP_BACKLIGHT_MAX 100 ++#define PX210_DP_BACKLIGHT_MIN 0 + +void px210_dp_func_register(struct phytium_dp_device *phytium_dp); +#endif /* __PX210_DP_H__ */ @@ -886848,10 +887448,10 @@ index 000000000000..3ac0baee920c +MODULE_LICENSE("GPL v2"); diff --git a/drivers/spi/spi-phytium.c b/drivers/spi/spi-phytium.c new file mode 100644 -index 000000000000..2dfea3f9046a +index 000000000000..4fae2cd2cac1 --- /dev/null +++ b/drivers/spi/spi-phytium.c -@@ -0,0 +1,510 @@ +@@ -0,0 +1,509 @@ + // SPDX-License-Identifier: GPL-2.0 +/* + * Phytium SPI core controller driver. @@ -887269,6 +887869,8 @@ index 000000000000..2dfea3f9046a + fts->dma_addr = (dma_addr_t)(fts->paddr + DR); + snprintf(fts->name, sizeof(fts->name), "phytium_spi%d", fts->bus_num); + ++ spi_hw_init(dev, fts); ++ + ret = request_irq(fts->irq, phytium_spi_irq, IRQF_SHARED, fts->name, master); + if (ret < 0) { + dev_err(dev, "can not get IRQ\n"); @@ -887290,9 +887892,6 @@ index 000000000000..2dfea3f9046a + master->flags = SPI_MASTER_GPIO_SS; + master->cs_gpios = fts->cs; + -+ spi_hw_init(dev, fts); -+ -+ + if (fts->dma_ops && fts->dma_ops->dma_init) { + ret = fts->dma_ops->dma_init(dev, fts); + if (ret) { diff --git a/device_board_phytium/common/kernel_source/phytium_standard_defconfig b/device_board_phytium/common/kernel_source/phytium_standard_defconfig index e11c849500692c67cf3739a5e74f9e060885fb58..cc114bb9112ad5e154afaaba6a1b7b0d6fe6f43f 100644 --- a/device_board_phytium/common/kernel_source/phytium_standard_defconfig +++ b/device_board_phytium/common/kernel_source/phytium_standard_defconfig @@ -772,6 +772,9 @@ CONFIG_DEBUG_KERNEL=y # CONFIG_FTRACE is not set CONFIG_MEMTEST=y +CONFIG_GPIO_SYSFS=y +CONFIG_HID_MULTITOUCH=y + CONFIG_HIEVENT=y CONFIG_BBOX_BUFFER_SIZE=2048 CONFIG_HISYSEVENT=y diff --git a/device_board_phytium/tengrui_d/patch/0000=arkcompiler-runtime_core=fix_build.patch b/device_board_phytium/common/patch/0000=arkcompiler-runtime_core=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=arkcompiler-runtime_core=fix_build.patch rename to device_board_phytium/common/patch/0000=arkcompiler-runtime_core=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=base-global-i18n=fix_build.patch b/device_board_phytium/common/patch/0000=base-global-i18n=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=base-global-i18n=fix_build.patch rename to device_board_phytium/common/patch/0000=base-global-i18n=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=base-hiviewdfx-hiview=fix_build.patch b/device_board_phytium/common/patch/0000=base-hiviewdfx-hiview=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=base-hiviewdfx-hiview=fix_build.patch rename to device_board_phytium/common/patch/0000=base-hiviewdfx-hiview=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=base-location=fix_build.patch b/device_board_phytium/common/patch/0000=base-location=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=base-location=fix_build.patch rename to device_board_phytium/common/patch/0000=base-location=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=base-notification-distributed_notification_service=fix_build.patch b/device_board_phytium/common/patch/0000=base-notification-distributed_notification_service=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=base-notification-distributed_notification_service=fix_build.patch rename to device_board_phytium/common/patch/0000=base-notification-distributed_notification_service=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=base-startup-appspawn=fix_build.patch b/device_board_phytium/common/patch/0000=base-startup-appspawn=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=base-startup-appspawn=fix_build.patch rename to device_board_phytium/common/patch/0000=base-startup-appspawn=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=base-time-time_service=fix_build.patch b/device_board_phytium/common/patch/0000=base-time-time_service=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=base-time-time_service=fix_build.patch rename to device_board_phytium/common/patch/0000=base-time-time_service=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=developtools-profiler=fix_build.patch b/device_board_phytium/common/patch/0000=developtools-profiler=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=developtools-profiler=fix_build.patch rename to device_board_phytium/common/patch/0000=developtools-profiler=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-CastEngine-castengine_cast_framework=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-CastEngine-castengine_cast_framework=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-CastEngine-castengine_cast_framework=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-CastEngine-castengine_cast_framework=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-ability-ability_runtime=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-ability-ability_runtime=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-ability-ability_runtime=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-ability-ability_runtime=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-ability-form_fwk=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-ability-form_fwk=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-ability-form_fwk=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-ability-form_fwk=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-arkui-ace_engine=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-arkui-ace_engine=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-arkui-ace_engine=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-arkui-ace_engine=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-bundlemanager-bundle_framework=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-bundlemanager-bundle_framework=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-bundlemanager-bundle_framework=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-bundlemanager-bundle_framework=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-communication-bluetooth_service=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-communication-bluetooth_service=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-communication-bluetooth_service=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-communication-bluetooth_service=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-communication-netmanager_base=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-communication-netmanager_base=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-communication-netmanager_base=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-communication-netmanager_base=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-communication-netstack=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-communication-netstack=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-communication-netstack=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-communication-netstack=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-communication-wifi=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-communication-wifi=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-communication-wifi=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-communication-wifi=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-distributeddatamgr-datamgr_service=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-distributeddatamgr-datamgr_service=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-distributeddatamgr-datamgr_service=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-distributeddatamgr-datamgr_service=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-filemanagement-dfs_service=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-filemanagement-dfs_service=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-filemanagement-dfs_service=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-filemanagement-dfs_service=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-graphic-graphic_2d=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-graphic-graphic_2d=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-graphic-graphic_2d=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-graphic-graphic_2d=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-multimedia-camera_framework=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-multimedia-camera_framework=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-multimedia-camera_framework=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-multimedia-camera_framework=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-multimedia-media_library=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-multimedia-media_library=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-multimedia-media_library=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-multimedia-media_library=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=foundation-window-window_manager=fix_build.patch b/device_board_phytium/common/patch/0000=foundation-window-window_manager=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=foundation-window-window_manager=fix_build.patch rename to device_board_phytium/common/patch/0000=foundation-window-window_manager=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0000=third_party-pulseaudio=fix_build.patch b/device_board_phytium/common/patch/0000=third_party-pulseaudio=fix_build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0000=third_party-pulseaudio=fix_build.patch rename to device_board_phytium/common/patch/0000=third_party-pulseaudio=fix_build.patch diff --git a/device_board_phytium/tengrui_d/patch/0001=base-theme-screenlock_mgr=add_retrytimes.patch b/device_board_phytium/common/patch/0001=base-theme-screenlock_mgr=add_retrytimes.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0001=base-theme-screenlock_mgr=add_retrytimes.patch rename to device_board_phytium/common/patch/0001=base-theme-screenlock_mgr=add_retrytimes.patch diff --git a/device_board_phytium/tengrui_d/patch/0002=build=add_phytium_whitelist.patch b/device_board_phytium/common/patch/0002=build=add_phytium_whitelist.patch similarity index 62% rename from device_board_phytium/tengrui_d/patch/0002=build=add_phytium_whitelist.patch rename to device_board_phytium/common/patch/0002=build=add_phytium_whitelist.patch index 5bf6e155370799e16e3aa409844e297428399209..a25a1fd69ecc095c541b0194dd1e1b934281ed5f 100644 --- a/device_board_phytium/tengrui_d/patch/0002=build=add_phytium_whitelist.patch +++ b/device_board_phytium/common/patch/0002=build=add_phytium_whitelist.patch @@ -2,63 +2,64 @@ diff --git a/compile_standard_whitelist.json b/compile_standard_whitelist.json index ce4ca863..9286614a 100644 --- a/compile_standard_whitelist.json +++ b/compile_standard_whitelist.json -@@ -6,6 +6,7 @@ +@@ -6,6 +6,8 @@ "device/qemu/arm_virt/linux/ohos.build", "third_party/flutter/glfw/bundle.json", "vendor/hihope/rk3568/ohos.build", ++ "device/board/phytium/tenglong_e/ohos.build", + "device/board/phytium/tengrui_d/ohos.build", "vendor/hihope/ipcamera/ohos.build" ], "subsystem_components": [], -@@ -28,6 +29,12 @@ +@@ -28,6 +30,12 @@ "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vdi_impl", "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vendor", "//device/soc/rockchip/rk3568/hardware/display:libdisplay_composer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:display_composer_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:display_gfx", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_buffer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_buffer_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_composer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:libhigbm_vendor", ++ "//device/soc/phytium/common/hardware/display:display_composer_vendor", ++ "//device/soc/phytium/common/hardware/display:display_gfx", ++ "//device/soc/phytium/common/hardware/display:libdisplay_buffer_vdi_impl", ++ "//device/soc/phytium/common/hardware/display:libdisplay_buffer_vendor", ++ "//device/soc/phytium/common/hardware/display:libdisplay_composer_vdi_impl", ++ "//device/soc/phytium/common/hardware/display:libhigbm_vendor", "//device/soc/rockchip/rk3568/hardware/mpp/mpp/legacy:librockchip_vpu", "//device/soc/rockchip/rk3568/hardware/omx_il/component/common:libRkOMX_Resourcemanager", "//device/soc/rockchip/rk3568/hardware/omx_il/component/video/dec:libomxvpu_dec", -@@ -120,6 +127,12 @@ +@@ -120,6 +128,12 @@ "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vdi_impl", "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vendor", "//device/soc/rockchip/rk3568/hardware/display:libdisplay_composer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:display_composer_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:display_gfx", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_buffer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_buffer_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_composer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:libhigbm_vendor", ++ "//device/soc/phytium/common/hardware/display:display_composer_vendor", ++ "//device/soc/phytium/common/hardware/display:display_gfx", ++ "//device/soc/phytium/common/hardware/display:libdisplay_buffer_vdi_impl", ++ "//device/soc/phytium/common/hardware/display:libdisplay_buffer_vendor", ++ "//device/soc/phytium/common/hardware/display:libdisplay_composer_vdi_impl", ++ "//device/soc/phytium/common/hardware/display:libhigbm_vendor", "//device/soc/rockchip/rk3568/hardware/mpp/mpp/hdi_mpp:hdi_mpp", "//device/soc/rockchip/rk3568/hardware/mpp/mpp/legacy:librockchip_vpu", "//device/soc/rockchip/rk3568/hardware/mpp/mpp/legacy:rockchip_vpu_src", -@@ -410,6 +423,12 @@ +@@ -410,6 +424,12 @@ "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vendor", "//device/soc/rockchip/rk3568/hardware/display:libdisplay_composer_vdi_impl", "//device/soc/rockchip/rk3568/hardware/display:libhigbm_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:display_composer_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:display_gfx", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_buffer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_buffer_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_composer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:libhigbm_vendor", ++ "//device/soc/phytium/common/hardware/display:display_composer_vendor", ++ "//device/soc/phytium/common/hardware/display:display_gfx", ++ "//device/soc/phytium/common/hardware/display:libdisplay_buffer_vdi_impl", ++ "//device/soc/phytium/common/hardware/display:libdisplay_buffer_vendor", ++ "//device/soc/phytium/common/hardware/display:libdisplay_composer_vdi_impl", ++ "//device/soc/phytium/common/hardware/display:libhigbm_vendor", "//device/soc/rockchip/rk3568/hardware/mpp/mpp/hdi_mpp:hdi_mpp", "//device/soc/rockchip/rk3568/hardware/mpp/mpp/legacy:rockchip_vpu_src", "//device/soc/rockchip/rk3568/hardware/omx_il/component/common:RkOMX_Basecomponent", -@@ -458,6 +477,12 @@ +@@ -458,6 +478,12 @@ "//device/soc/rockchip/rk3568/hardware/display:display_composer_vendor", "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vendor", "//device/soc/rockchip/rk3568/hardware/display:libhigbm_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:display_composer_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:display_gfx", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_buffer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_buffer_vendor", -+ "//device/soc/phytium/pd2x08/hardware/display:libdisplay_composer_vdi_impl", -+ "//device/soc/phytium/pd2x08/hardware/display:libhigbm_vendor", ++ "//device/soc/phytium/common/hardware/display:display_composer_vendor", ++ "//device/soc/phytium/common/hardware/display:display_gfx", ++ "//device/soc/phytium/common/hardware/display:libdisplay_buffer_vdi_impl", ++ "//device/soc/phytium/common/hardware/display:libdisplay_buffer_vendor", ++ "//device/soc/phytium/common/hardware/display:libdisplay_composer_vdi_impl", ++ "//device/soc/phytium/common/hardware/display:libhigbm_vendor", "//drivers/peripheral/codec/test/demo/adapter:codec_hdi_adapter_decode", "//drivers/peripheral/codec/test/demo/adapter:codec_hdi_adapter_encode", "//drivers/peripheral/codec/test/demo/v2.0:codec_hdi_omx_decode", diff --git a/device_board_phytium/tengrui_d/patch/0003=developtools-integration_verification=add_alsa_in_chipsetsdk_whitelist.patch b/device_board_phytium/common/patch/0003=developtools-integration_verification=add_alsa_in_chipsetsdk_whitelist.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0003=developtools-integration_verification=add_alsa_in_chipsetsdk_whitelist.patch rename to device_board_phytium/common/patch/0003=developtools-integration_verification=add_alsa_in_chipsetsdk_whitelist.patch diff --git a/device_board_phytium/tengrui_d/patch/0004=drivers-peripheral=support_alsa.patch b/device_board_phytium/common/patch/0004=drivers-peripheral=support_alsa.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0004=drivers-peripheral=support_alsa.patch rename to device_board_phytium/common/patch/0004=drivers-peripheral=support_alsa.patch diff --git a/device_board_phytium/tengrui_d/patch/0005=foundation-graphic-graphic_2d=modify-the-uid-of-bootanimation.patch b/device_board_phytium/common/patch/0005=foundation-graphic-graphic_2d=modify-the-uid-of-bootanimation.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0005=foundation-graphic-graphic_2d=modify-the-uid-of-bootanimation.patch rename to device_board_phytium/common/patch/0005=foundation-graphic-graphic_2d=modify-the-uid-of-bootanimation.patch diff --git a/device_board_phytium/common/patch/0006=base-startup-init=fix_get_fstab_fail_from_cmdline.patch b/device_board_phytium/common/patch/0006=base-startup-init=fix_get_fstab_fail_from_cmdline.patch new file mode 100644 index 0000000000000000000000000000000000000000..808de81aa5f89671e6681dd16460ff0354688b68 --- /dev/null +++ b/device_board_phytium/common/patch/0006=base-startup-init=fix_get_fstab_fail_from_cmdline.patch @@ -0,0 +1,130 @@ +diff --git a/interfaces/innerkits/fs_manager/fstab.c b/interfaces/innerkits/fs_manager/fstab.c +index 3cfaccb2..cfeac1a1 100644 +--- a/interfaces/innerkits/fs_manager/fstab.c ++++ b/interfaces/innerkits/fs_manager/fstab.c +@@ -515,6 +515,39 @@ int GetBlockDevicePath(const char *partName, char *path, size_t size) + return ret; + } + ++#define MAX_PARTITION_NUM 3 ++/* ++ * Parse fstab by option ohos.required_mount.device. ++ * ohos.required_mount.device= ++ * /dev/block/ /usr ext4 ro,barrier=1 wait,required ++ * /dev/block/ /vendor ext4 ro,barrier=1 wait,required ++ * /dev/block/ /data ext4 nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc wait,reservedsize=104857600 ++ * e.g. ++ * ohos.required_mount.device=sda ++*/ ++int ParseFstabDevice(char *str, Fstab *fstab) ++{ ++ int ret = -1; ++ //MAX_BUFFER_LEN 256 ++ //MAX_PARTITION_NUM 3 ++ char fstab_str[MAX_PARTITION_NUM][MAX_BUFFER_LEN]; ++ const char fstab_str_pre[] = "/dev/block/"; ++ const char *fstab_str_end[MAX_PARTITION_NUM] = { ++ "2@/usr@ext4@ro,barrier=1@wait,required", ++ "3@/vendor@ext4@ro,barrier=1@wait,required", ++ "4@/data@ext4@nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc@wait,reservedsize=104857600" ++ }; ++ for (size_t i = 0; i < MAX_PARTITION_NUM; i++) { ++ snprintf(fstab_str[i], MAX_BUFFER_LEN, "%s%s%s", fstab_str_pre, str, fstab_str_end[i]); ++ ret = ParseFstabPerLine(fstab_str[i], fstab, false, "@"); ++ if ( ret < 0 ){ ++ BEGET_LOGE("Failed to parse mount options of [%s]", fstab_str[i]); ++ break; ++ } ++ } ++ return ret; ++} ++ + #define OHOS_REQUIRED_MOUNT_PREFIX "ohos.required_mount." + /* + * Fstab includes block device node, mount point, file system type, MNT_ Flags and options. +@@ -524,6 +557,18 @@ int GetBlockDevicePath(const char *partName, char *path, size_t size) + * @@@@ + * e.g. + * ohos.required_mount.system=/dev/block/xxx/by-name/system@/usr@ext4@ro,barrier=1@wait,required ++ * ++ * EX: ++ * Due to the fact that the configurations of different storage media are the same except for the storage nodes. ++ * We extend a simple configuration option ohos.required_mount.device to configure the storage node, ++ * which will then parse the corresponding fstab configuration. ++ * The configuration is parsed through the interface: int ParseFstabDevice(char *str, Fstab *fstab). ++ * e.g. ++ * ohos.required_mount.device=sda ++ * means: ++ * /dev/block/sda2 /usr ext4 ro,barrier=1 wait,required ++ * /dev/block/sda3 /vendor ext4 ro,barrier=1 wait,required ++ * /dev/block/sda4 /data ext4 nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc wait,reservedsize=104857600 + */ + static int ParseRequiredMountInfo(const char *item, Fstab *fstab) + { +@@ -543,7 +588,10 @@ static int ParseRequiredMountInfo(const char *item, Fstab *fstab) + return -1, "Failed to copy required mount info: %s", item); + } + BEGET_LOGV("Config mount option of partition %s is [%s]", partName, mountOptions); +- if (ParseFstabPerLine(mountOptions, fstab, false, "@") < 0) { ++ if (strcmp(partName, "device") == 0) { ++ return ParseFstabDevice(mountOptions, fstab); ++ } ++ else if (ParseFstabPerLine(mountOptions, fstab, false, "@") < 0) { + BEGET_LOGE("Failed to parse mount options of partition \' %s \', options: %s", partName, mountOptions); + return -1; + } +@@ -591,14 +639,14 @@ Fstab* LoadFstabFromCommandLine(void) + + // handle last one + if (start < end) { +- if (strncmp(start, OHOS_REQUIRED_MOUNT_PREFIX, +- strlen(OHOS_REQUIRED_MOUNT_PREFIX)) == 0 && +- ParseRequiredMountInfo(start, fstab) < 0) { +- BEGET_LOGE("Failed to parse \' %s \'", start); +- isDone = false; ++ if (strncmp(start, OHOS_REQUIRED_MOUNT_PREFIX, strlen(OHOS_REQUIRED_MOUNT_PREFIX)) == 0) { ++ isDone = true; ++ if (ParseRequiredMountInfo(start, fstab) < 0) { ++ BEGET_LOGE("Failed to parse \' %s \'", start); ++ isDone = false; ++ } + } + } +- + if (!isDone) { + ReleaseFstab(fstab); + fstab = NULL; +diff --git a/interfaces/innerkits/fs_manager/fstab_mount.c b/interfaces/innerkits/fs_manager/fstab_mount.c +index 0ce3a1e0..eea7cb26 100755 +--- a/interfaces/innerkits/fs_manager/fstab_mount.c ++++ b/interfaces/innerkits/fs_manager/fstab_mount.c +@@ -684,9 +684,12 @@ int MountAllWithFstabFile(const char *fstabFile, bool required) + BEGET_CHECK(!isFile, return -1); + + Fstab *fstab = NULL; +- if ((fstab = ReadFstabFromFile(fstabFile, false)) == NULL) { +- BEGET_LOGE("[fs_manager][error] Read fstab file \" %s \" failed\n", fstabFile); +- return -1; ++ fstab = LoadFstabFromCommandLine(); ++ if (fstab == NULL) { ++ if ((fstab = ReadFstabFromFile(fstabFile, false)) == NULL) { ++ BEGET_LOGE("[fs_manager][error] Read fstab file \" %s \" failed\n", fstabFile); ++ return -1; ++ } + } + + int rc = MountAllWithFstab(fstab, required); +@@ -704,8 +707,11 @@ int UmountAllWithFstabFile(const char *fstabFile) + BEGET_CHECK(!isFile, return -1); + + Fstab *fstab = NULL; +- fstab = ReadFstabFromFile(fstabFile, false); +- BEGET_ERROR_CHECK(fstab != NULL, return -1, "Read fstab file \" %s \" failed.", fstabFile); ++ fstab = LoadFstabFromCommandLine(); ++ if (fstab == NULL) { ++ fstab = ReadFstabFromFile(fstabFile, false); ++ BEGET_ERROR_CHECK(fstab != NULL, return -1, "Read fstab file \" %s \" failed.", fstabFile); ++ } + + FstabItem *item = NULL; + int rc = -1; diff --git a/device_board_phytium/tengrui_d/patch/0007=drivers-peripheral=omx_calling_modification.patch b/device_board_phytium/common/patch/0007=drivers-peripheral=omx_calling_modification.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0007=drivers-peripheral=omx_calling_modification.patch rename to device_board_phytium/common/patch/0007=drivers-peripheral=omx_calling_modification.patch diff --git a/device_board_phytium/tengrui_d/patch/0008=foundation-multimedia-player_framework=add-yuvconvert-in-PlayBin.patch b/device_board_phytium/common/patch/0008=foundation-multimedia-player_framework=add-yuvconvert-in-PlayBin.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0008=foundation-multimedia-player_framework=add-yuvconvert-in-PlayBin.patch rename to device_board_phytium/common/patch/0008=foundation-multimedia-player_framework=add-yuvconvert-in-PlayBin.patch diff --git a/device_board_phytium/tengrui_d/patch/0009=third_party-gstreamer=add-registration-of-h263-h265-vc1-vp9parse-plugins.patch b/device_board_phytium/common/patch/0009=third_party-gstreamer=add-registration-of-h263-h265-vc1-vp9parse-plugins.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0009=third_party-gstreamer=add-registration-of-h263-h265-vc1-vp9parse-plugins.patch rename to device_board_phytium/common/patch/0009=third_party-gstreamer=add-registration-of-h263-h265-vc1-vp9parse-plugins.patch diff --git a/device_board_phytium/tengrui_d/patch/0010=drivers-interface-display-composer-v1_0=add-dp-con-type.patch b/device_board_phytium/common/patch/0010=drivers-interface-display-composer-v1_0=add-dp-con-type.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0010=drivers-interface-display-composer-v1_0=add-dp-con-type.patch rename to device_board_phytium/common/patch/0010=drivers-interface-display-composer-v1_0=add-dp-con-type.patch diff --git a/device_board_phytium/tengrui_d/patch/0010=foundation-graphic-graphic_2d=add-dp-con-type.patch b/device_board_phytium/common/patch/0010=foundation-graphic-graphic_2d=add-dp-con-type.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0010=foundation-graphic-graphic_2d=add-dp-con-type.patch rename to device_board_phytium/common/patch/0010=foundation-graphic-graphic_2d=add-dp-con-type.patch diff --git a/device_board_phytium/tengrui_d/patch/0011=base-hiviewdfx-hidumper=cancel-dump-privilege-check.patch b/device_board_phytium/common/patch/0011=base-hiviewdfx-hidumper=cancel-dump-privilege-check.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0011=base-hiviewdfx-hidumper=cancel-dump-privilege-check.patch rename to device_board_phytium/common/patch/0011=base-hiviewdfx-hidumper=cancel-dump-privilege-check.patch diff --git a/device_board_phytium/tengrui_d/patch/0013=build=make_boot_image.patch b/device_board_phytium/common/patch/0013=build=make_boot_image.patch similarity index 60% rename from device_board_phytium/tengrui_d/patch/0013=build=make_boot_image.patch rename to device_board_phytium/common/patch/0013=build=make_boot_image.patch index 3b138644a63133bcce0720b58bce8dfa16ae03bb..c543672ab471792a970cbeacab05102d3bf1a5e8 100644 --- a/device_board_phytium/tengrui_d/patch/0013=build=make_boot_image.patch +++ b/device_board_phytium/common/patch/0013=build=make_boot_image.patch @@ -1,17 +1,14 @@ diff --git a/ohos/images/mkimage/mkimages.py b/ohos/images/mkimage/mkimages.py -index dfa56711..75d6c3b6 100755 +index dfa56711..312904c5 100755 --- a/ohos/images/mkimage/mkimages.py +++ b/ohos/images/mkimage/mkimages.py -@@ -134,6 +134,12 @@ def mk_images(args): +@@ -134,6 +134,9 @@ def mk_images(args): mk_system_img(mkfs_tools, mk_configs, device, src_dir, is_sparse) elif image_name == "ramdisk.img": mk_ramdisk_img(mkfs_tools, mk_configs, device, src_dir, is_sparse) -+ ret = os.system('sh ./packages/phone/images/make_boot.sh ./packages/phone/images/ uboot') ++ ret = os.system('sh ./packages/phone/images/make_boot.sh ./packages/phone/images/') + if ret: -+ print("execute make_boot.sh uboot fail, ret: %s" % str(ret)) -+ ret = os.system('sh ./packages/phone/images/make_boot.sh ./packages/phone/images/ efi') -+ if ret: -+ print("execute make_boot.sh efi fail, ret: %s" % str(ret)) ++ print("execute make_boot.sh fail, ret: %s" % str(ret)) elif image_name == "updater_ramdisk.img": if config.get('component_type', '') == 'system_component': return diff --git a/device_board_phytium/tengrui_d/patch/0014=foundation-filemanagement-storage_service=auto_mount_usb_storage_device.patch b/device_board_phytium/common/patch/0014=foundation-filemanagement-storage_service=auto_mount_usb_storage_device.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0014=foundation-filemanagement-storage_service=auto_mount_usb_storage_device.patch rename to device_board_phytium/common/patch/0014=foundation-filemanagement-storage_service=auto_mount_usb_storage_device.patch diff --git a/device_board_phytium/tengrui_d/patch/0015=build=ohos_var_add_gn_args_gpu_model.patch b/device_board_phytium/common/patch/0015=build=ohos_var_add_gn_args_gpu_model.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0015=build=ohos_var_add_gn_args_gpu_model.patch rename to device_board_phytium/common/patch/0015=build=ohos_var_add_gn_args_gpu_model.patch diff --git a/device_board_phytium/tengrui_d/patch/0015=foundation-resourceschedule-memmgr=add-hyperhold-switch.patch b/device_board_phytium/common/patch/0015=foundation-resourceschedule-memmgr=add-hyperhold-switch.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0015=foundation-resourceschedule-memmgr=add-hyperhold-switch.patch rename to device_board_phytium/common/patch/0015=foundation-resourceschedule-memmgr=add-hyperhold-switch.patch diff --git a/device_board_phytium/tengrui_d/patch/0016=foundation-multimedia-player_framework=disable-decoding-in-avmetadata.patch b/device_board_phytium/common/patch/0016=foundation-multimedia-player_framework=disable-decoding-in-avmetadata.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0016=foundation-multimedia-player_framework=disable-decoding-in-avmetadata.patch rename to device_board_phytium/common/patch/0016=foundation-multimedia-player_framework=disable-decoding-in-avmetadata.patch diff --git a/device_board_phytium/tengrui_d/patch/0017=foundation-multimedia-av_codec=modify-hcodec-for-histreamer.patch b/device_board_phytium/common/patch/0017=foundation-multimedia-av_codec=modify-hcodec-for-histreamer.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0017=foundation-multimedia-av_codec=modify-hcodec-for-histreamer.patch rename to device_board_phytium/common/patch/0017=foundation-multimedia-av_codec=modify-hcodec-for-histreamer.patch diff --git a/device_board_phytium/tengrui_d/patch/0018=foundation-graphic-graphic_2d=modify-bootanimation-for-histreamer.patch b/device_board_phytium/common/patch/0018=foundation-graphic-graphic_2d=modify-bootanimation-for-histreamer.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0018=foundation-graphic-graphic_2d=modify-bootanimation-for-histreamer.patch rename to device_board_phytium/common/patch/0018=foundation-graphic-graphic_2d=modify-bootanimation-for-histreamer.patch diff --git a/device_board_phytium/tengrui_d/patch/0019=third_party-ffmpeg=enable-hevc-related-compilation-for-histreamer.patch b/device_board_phytium/common/patch/0019=third_party-ffmpeg=enable-hevc-related-compilation-for-histreamer.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0019=third_party-ffmpeg=enable-hevc-related-compilation-for-histreamer.patch rename to device_board_phytium/common/patch/0019=third_party-ffmpeg=enable-hevc-related-compilation-for-histreamer.patch diff --git a/device_board_phytium/tengrui_d/patch/0020=build=ramdisk_image_conf.patch b/device_board_phytium/common/patch/0020=build=ramdisk_image_conf.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0020=build=ramdisk_image_conf.patch rename to device_board_phytium/common/patch/0020=build=ramdisk_image_conf.patch diff --git a/device_board_phytium/tengrui_d/patch/0021=developtools-integration_verification=chipsetsdk_whitelist.patch b/device_board_phytium/common/patch/0021=developtools-integration_verification=chipsetsdk_whitelist.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0021=developtools-integration_verification=chipsetsdk_whitelist.patch rename to device_board_phytium/common/patch/0021=developtools-integration_verification=chipsetsdk_whitelist.patch diff --git a/device_board_phytium/tengrui_d/patch/0022=third_party-libdrm=amdgpu-and-radeon-build.patch b/device_board_phytium/common/patch/0022=third_party-libdrm=amdgpu-and-radeon-build.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0022=third_party-libdrm=amdgpu-and-radeon-build.patch rename to device_board_phytium/common/patch/0022=third_party-libdrm=amdgpu-and-radeon-build.patch diff --git a/device_board_phytium/tengrui_d/patch/0023=third_party-elfutils=build-libelf-so.patch b/device_board_phytium/common/patch/0023=third_party-elfutils=build-libelf-so.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0023=third_party-elfutils=build-libelf-so.patch rename to device_board_phytium/common/patch/0023=third_party-elfutils=build-libelf-so.patch diff --git a/device_board_phytium/tengrui_d/patch/0024=base-startup-init=reduce_certain_cmds_loglevel.patch b/device_board_phytium/common/patch/0024=base-startup-init=reduce_certain_cmds_loglevel.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0024=base-startup-init=reduce_certain_cmds_loglevel.patch rename to device_board_phytium/common/patch/0024=base-startup-init=reduce_certain_cmds_loglevel.patch diff --git a/device_board_phytium/tengrui_d/patch/0025=build=vendor_image_conf.patch b/device_board_phytium/common/patch/0025=build=vendor_image_conf.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0025=build=vendor_image_conf.patch rename to device_board_phytium/common/patch/0025=build=vendor_image_conf.patch diff --git a/device_board_phytium/tengrui_d/patch/0026=build=add_execscripts.patch b/device_board_phytium/common/patch/0026=build=add_execscripts.patch similarity index 79% rename from device_board_phytium/tengrui_d/patch/0026=build=add_execscripts.patch rename to device_board_phytium/common/patch/0026=build=add_execscripts.patch index 2fc0448bab9641e148baafa293a9644162dce876..fdc0500b1132ad35b2180ec425316737f5c0b2c3 100644 --- a/device_board_phytium/tengrui_d/patch/0026=build=add_execscripts.patch +++ b/device_board_phytium/common/patch/0026=build=add_execscripts.patch @@ -2,10 +2,11 @@ diff --git a/core/gn/ohos_exec_script_allowlist.gni b/core/gn/ohos_exec_script_a index 0a986f4..2641850 100644 --- a/core/gn/ohos_exec_script_allowlist.gni +++ b/core/gn/ohos_exec_script_allowlist.gni -@@ -198,5 +198,6 @@ ohos_exec_script_config = { +@@ -198,5 +198,7 @@ ohos_exec_script_config = { "//build_plugins/config/ios/ios_sdk.gni", "//build_plugins/templates/java/rules.gni", "//build_plugins/templates/java/internal_rules.gni", ++ "//vendor/phytium/tenglong_e/hdf_config/uhdf/BUILD.gn", + "//vendor/phytium/tengrui_d/hdf_config/uhdf/BUILD.gn", ] } diff --git a/device_board_phytium/tengrui_d/patch/0026=drivers-peripheral=amixer_cset_two_values.patch b/device_board_phytium/common/patch/0026=drivers-peripheral=amixer_cset_two_values.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0026=drivers-peripheral=amixer_cset_two_values.patch rename to device_board_phytium/common/patch/0026=drivers-peripheral=amixer_cset_two_values.patch diff --git a/device_board_phytium/tengrui_d/patch/0027=foundation-graphic-graphic_2d=gpu_mwv207.patch b/device_board_phytium/common/patch/0027=foundation-graphic-graphic_2d=gpu_mwv207.patch similarity index 100% rename from device_board_phytium/tengrui_d/patch/0027=foundation-graphic-graphic_2d=gpu_mwv207.patch rename to device_board_phytium/common/patch/0027=foundation-graphic-graphic_2d=gpu_mwv207.patch diff --git a/device_board_phytium/common/patch/0028=build=set_userdata_ext4.patch b/device_board_phytium/common/patch/0028=build=set_userdata_ext4.patch new file mode 100644 index 0000000000000000000000000000000000000000..be02c4526d2d7d40c756a72cc03774f93aef5f59 --- /dev/null +++ b/device_board_phytium/common/patch/0028=build=set_userdata_ext4.patch @@ -0,0 +1,14 @@ +diff --git a/ohos/images/mkimage/userdata_image_conf.txt b/ohos/images/mkimage/userdata_image_conf.txt +index 273af2e5..223e2ec4 100644 +--- a/ohos/images/mkimage/userdata_image_conf.txt ++++ b/ohos/images/mkimage/userdata_image_conf.txt +@@ -1,6 +1,6 @@ + /data + 1468006400 +---fs_type=f2fs ++--fs_type=ext4 + --dac_config ../../build/ohos/images/mkimage/dac.txt + --file_context obj/base/security/selinux_adapter/file_contexts.bin +---prjquota +\ No newline at end of file ++--prjquota diff --git a/device_board_phytium/common/patch/0029=applications-standard-hap=add_browser_hap.patch b/device_board_phytium/common/patch/0029=applications-standard-hap=add_browser_hap.patch new file mode 100644 index 0000000000000000000000000000000000000000..c4b018594173bb91fddd3bde86c8c19a117c6fcd --- /dev/null +++ b/device_board_phytium/common/patch/0029=applications-standard-hap=add_browser_hap.patch @@ -0,0 +1,26 @@ +diff --git a/BUILD.gn b/BUILD.gn +index 4b6bd3b..30b7ab8 100755 +--- a/BUILD.gn ++++ b/BUILD.gn +@@ -276,6 +276,13 @@ ohos_prebuilt_etc("calendarData_hap") { + subsystem_name = "applications" + } + ++ohos_prebuilt_etc("Browser_hap") { ++ source = "//device/board/phytium/common/hap/Browser.hap" ++ module_install_dir = "app/ohos.samples.browser1" ++ part_name = "prebuilt_hap" ++ subsystem_name = "applications" ++} ++ + group("hap") { + deps = [ + ":calendarData_hap", +@@ -314,6 +321,7 @@ group("hap") { + "//applications/standard/hap:statusBar_hap", + "//applications/standard/hap:systemui_hap", + "//applications/standard/hap:volumePanel_hap", ++ ":Browser_hap", + ] + if (defined(product_name) && product_name == "watchos") { + deps -= [ diff --git a/device_board_phytium/common/tools/generate_image/generate_image.sh b/device_board_phytium/common/tools/generate_image/generate_image.sh old mode 100644 new mode 100755 index e527373c44947812f4b30ef9b56683af87dbfa37..263603fb9185ea635a4aa64f5f74a202472bdac2 --- a/device_board_phytium/common/tools/generate_image/generate_image.sh +++ b/device_board_phytium/common/tools/generate_image/generate_image.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) 2023 Phytium Technology Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,27 +16,26 @@ # this script is used to generate image of phytium android and openharmony product. #tools needed: # before use this script, make sure 3 tools intalled firstly. -# tools: 1. dosfstools 2. parted 3. kpartx +# tools: parted, mke2fs # if not, install them with command sudo apt-get install #usage: # how to generate image, only 3 steps. -# step1. copy system.img,vendor.img,ramdisk.img,kernel Image,product dtb file,part.cfg and this script to a directroy -# step2. if want to change image name and partition size, modify them in part.cfg file. unit size in config file is -# Mbytes.for example,boot_partition_size=256,It means allocate 256MBytes for boot partition. but for reason MBR -# also occupy some disk space,actual size is a little smaller than config size. with command "sudo fdisk -l" , -# check the real size of all partitions after burned the image to disk. -# step3. execute this script, if no err, an image will be generated in the directory. +# step1. make sure boot.img or boot_efi.img, system.img, vendor.img, userdata.img have been maked. +# step2. if you want to include uboot, copy uboot img to same folder +# step3. execute this script, if with uboot img, add the path of uboot img as a parameter. +# for example: $ ./generate_image.sh +# $ ./generate_image.sh # how to burn image, It supports two ways. # in linux: sudo dd if=imagename of=/dev/sdX bs=1M # in windows:burn it with tool Win32DiskImager.exe, this tool can be downloaded from web very easily. #company: -# phytium +# phytium #verion: -# V0.1.0 original -# V0.1.1 fix mistake that node /dev/loopx was occupied by others. +# V0.1.0 original +# V0.1.1 fix mistake that node /dev/loopx was occupied by others. +# v1.0.1 rm losetup tool, rm sudo requirement, add mke2fs ext4 userdata.img ############################################################################################################################ - set -o errexit ############################################################################################################################## #set color defination in echo info @@ -44,68 +43,108 @@ green="\e[32;1m" red="\e[31;1m" normal="\e[0m" ############################################################################################################################## - +# Local functions + +#function: get_file_size_decimal_mib +#check image file exists or not, and get image file size in decimal MiB +function get_file_size_decimal_mib(){ + local file="$1" + local size=$(stat -c%s "$file" 2>/dev/null) + + if [ -z "$size" ]; then + echo "-1" + else + echo "$size" | awk '{printf "%d\n", (int($1 / (1000*1000)) + 1)}' + fi +} + +#function: convert_1000mib_to_1024mib +#convert unit from decimal MiB to binary MiB +function convert_1000mib_to_1024mib(){ + #0.95367431640625 = (1000*1000)/(1024*1024) + local tmp=0.95367431640625 # convert:1000*1000 MiB -> 1024*1024 MiB + local out=$(echo "scale=0; ($1*$tmp + 0.5) / 1" | bc) + echo "$out" +} + +#fuction: make a ext4 image +function make_ext4_image() +{ + src=$1 + dis=$2 + size=$3 + block_size=$4 + block_num=$((${size} * 1024 * 1024 / ${block_size})) + + mke2fs -F -b ${block_size} -d ${src} -i 8192 -t ext4 ${dis} ${block_num} + return $? +} + +#fuction :check image file is ext4 or not +function is_ext4_image() +{ + # Check if the file exists + if [ ! -f "$1" ]; then + echo "-1" + fi + + # Use blkid to check the filesystem type of the image + local fstype=$(blkid -o value -s TYPE "$1") + + echo "$fstype" +} ############################################################################################################################## +#1.Analyze input parameters +UBOOT_NAME="no_uboot" +if [ -f $1 ]; then + UBOOT_NAME=$1 +fi + +#2.Check the image file, obtain the file size in decimal MiB +#check uboot image +LABLE_RESERVE_SIZE=$(get_file_size_decimal_mib $UBOOT_NAME) +if [ ${LABLE_RESERVE_SIZE} == -1 ]; then + UBOOT_NAME="no_uboot" + LABLE_RESERVE_SIZE=1 + IMAGE_NAME_END="no_uboot" +else + IMAGE_NAME_END="with_uboot" +fi -#partion sizes are defined in part.cfg, Unit size is MByte -CONFIG=part.cfg +IMAGE_NAME_EX="openharmony_img" +IMAGE_NAME="${IMAGE_NAME_EX}_${IMAGE_NAME_END}.img" +echo -e "${green}start generate $IMAGE_NAME with gpt mode !!!${normal}" -UBOOT_NAME="no_uboot" -IMAGE_NAME_END="uboot" -BOOT_IMG="boot_uboot.img" -BOOT_PART_FORMAT="ext4" -PART_MODE="msdos" - -while [ -n "$1" ] -do - case $1 in - efi) - BOOT_IMG="boot_efi.img" - IMAGE_NAME_END="efi" - BOOT_PART_FORMAT="fat32" - ;; - uboot) - BOOT_IMG="boot_uboot.img" - IMAGE_NAME_END="uboot" - BOOT_PART_FORMAT="ext4" - ;; - msdos) - PART_MODE="msdos" - ;; - gpt) - PART_MODE="gpt" - ;; - *) - if [ -f $1 ]; then - UBOOT_NAME=$1 - fi - ;; - esac - shift -done - -#### only uboot mode support to burn uboot image -if [ -f $UBOOT_NAME ]&&[ $IMAGE_NAME_END == "uboot" ]; then - UBOOT_NAME_BASENAME=$(basename $UBOOT_NAME) - IMAGE_NAME_END="uboot_"${UBOOT_NAME_BASENAME%.*} +#check boot image +BOOT_IMG="boot.img" +if [ -e "boot.img" ]; then + BOOT_IMG="boot.img" else - UBOOT_NAME="no_uboot" + BOOT_IMG="boot_efi.img" +fi +BOOT_PARTION_SIZE=$(get_file_size_decimal_mib "$BOOT_IMG") + +#check system and vendor image +SYSTEM_PARTION_SIZE=$(get_file_size_decimal_mib "system.img") +VENDOR_PARTION_SIZE=$(get_file_size_decimal_mib "vendor.img") +if [ ${BOOT_PARTION_SIZE} == -1 ] || [ ${SYSTEM_PARTION_SIZE} == -1 ] || [ ${VENDOR_PARTION_SIZE} == -1 ]; then + echo -e "${red}check boot.img system.img vendor.img fail !!!${normal}" + exit fi -#### The GPT partition table occupies 34 blocks of space, which may interfere with uboot. -#### If you need to package the uboot image, you can only use the partition format of msdos. -if [ -f $UBOOT_NAME ]&&[ $PART_MODE == "gpt" ]; then - echo -e "${red}Interference between GPT partition table and uboot, switch to MSDOS mode!!!${normal}" - PART_MODE="msdos" +#check userdata image +userdata_fstype=$(is_ext4_image "userdata.img") +if [ ${userdata_fstype} == "ext4" ]; then + USERDATA_PARTION_SIZE=$(get_file_size_decimal_mib "userdata.img") +else + echo -e "${green}userdata.img is not exsit or its fstype is not ext4, make a new one with size 1GB.${normal}" + USERDATA_PARTION_SIZE=1024 + mkdir data + make_ext4_image "./data" "userdata.img" ${USERDATA_PARTION_SIZE} 4096 + rm data -rf fi -IMAGE_NAME_EX=$(awk '/^image_name_ex/{print $3}' "$CONFIG") -IMAGE_NAME="${IMAGE_NAME_EX}_${IMAGE_NAME_END}.img" -LABLE_RESERVE_SIZE=$(awk '/^label_reserve_size/{print $3}' "$CONFIG") -BOOT_PARTION_SIZE=$(awk '/^boot_partition_size/{print $3}' "$CONFIG") -SYSTEM_PARTION_SIZE=$(awk '/^system_partition_size/{print $3}' "$CONFIG") -VENDOR_PARTION_SIZE=$(awk '/^vendor_partition_size/{print $3}' "$CONFIG") -USERDATA_PARTION_SIZE=$(awk '/^userdata_partition_size/{print $3}' "$CONFIG") +#3.Calculate the start and end addresses of partition image burning and image size START_BOOT_ADDR=$LABLE_RESERVE_SIZE let END_BOOT_ADDR=$LABLE_RESERVE_SIZE+$BOOT_PARTION_SIZE START_SYSTEM_ADDR=$END_BOOT_ADDR @@ -115,61 +154,37 @@ let END_VENDOR_ADDR=$START_VENDOR_ADDR+$VENDOR_PARTION_SIZE START_USERDATA_ADDR=$END_VENDOR_ADDR let END_USERDATA_ADDR=$START_USERDATA_ADDR+$USERDATA_PARTION_SIZE let TOTAL_IMAGE_SIZE=$LABLE_RESERVE_SIZE+$BOOT_PARTION_SIZE+$SYSTEM_PARTION_SIZE+$VENDOR_PARTION_SIZE+$USERDATA_PARTION_SIZE -############################################################################################################################### -echo -e "${green}start generate $IMAGE_NAME with ${PART_MODE} mode !!!${normal}" - -if [ ! -f ${BOOT_IMG} ]; then - ./make_boot.sh . ${IMAGE_NAME_END} -fi -sudo -v +#4.creating empty image echo -e "${green}1.start creating empty image, please wait......${normal}" -sudo dd if=/dev/zero of=$IMAGE_NAME bs=1MB count=$TOTAL_IMAGE_SIZE -echo -e "${green}2.parting image with ${PART_MODE} mode......${normal}" - -if [ ${PART_MODE} == "gpt" ]; then - sudo parted $IMAGE_NAME --script -- mklabel gpt - sudo parted $IMAGE_NAME --script -- mkpart boot ${BOOT_PART_FORMAT} ${START_BOOT_ADDR}M ${END_BOOT_ADDR}M-1 - sudo parted $IMAGE_NAME --script -- mkpart system ext4 ${START_SYSTEM_ADDR}M ${END_SYSTEM_ADDR}M-1 - sudo parted $IMAGE_NAME --script -- mkpart vendor ext4 ${START_VENDOR_ADDR}M ${END_VENDOR_ADDR}M-1 - sudo parted $IMAGE_NAME --script -- mkpart userdata ext4 ${START_USERDATA_ADDR}M ${END_USERDATA_ADDR}M-1 -else - sudo parted $IMAGE_NAME --script -- mklabel msdos - sudo parted $IMAGE_NAME --script -- mkpart primary ${BOOT_PART_FORMAT} ${START_BOOT_ADDR}M ${END_BOOT_ADDR}M-1 - sudo parted $IMAGE_NAME --script -- mkpart primary ext4 ${START_SYSTEM_ADDR}M ${END_SYSTEM_ADDR}M-1 - sudo parted $IMAGE_NAME --script -- mkpart primary ext4 ${START_VENDOR_ADDR}M ${END_VENDOR_ADDR}M-1 - sudo parted $IMAGE_NAME --script -- mkpart primary ext4 ${START_USERDATA_ADDR}M ${END_USERDATA_ADDR}M-1 -fi - -loopdevice=`sudo losetup -f --show ${IMAGE_NAME}` -device=`sudo kpartx -va $loopdevice | sed -E 's/.*(loop[1-9]?[0-9])p.*/\1/g' | head -1` -device="/dev/mapper/${device}" -partBoot="${device}p1" -partSystem="${device}p2" -partVendor="${device}p3" -partUserdata="${device}p4" - -echo -e "${green}3.start dd boot/system/vendor images......${normal}" -sudo dd if=${BOOT_IMG} of=$partBoot bs=1M -sudo dd if=system.img of=$partSystem bs=1M -sudo dd if=vendor.img of=$partVendor bs=1M - -echo -e "${green}4.start to generate userdata partition......${normal}" -sudo mkfs.ext4 -L userdata $partUserdata - +dd if=/dev/zero of=$IMAGE_NAME bs=1MB count=$TOTAL_IMAGE_SIZE + +#5.part image with gpt mode +echo -e "${green}2.parting image with gpt mode......${normal}" +parted $IMAGE_NAME --script -- mklabel gpt +parted $IMAGE_NAME --script -- mkpart boot fat32 ${START_BOOT_ADDR}M ${END_BOOT_ADDR}M-1 +parted $IMAGE_NAME --script -- mkpart system ext4 ${START_SYSTEM_ADDR}M ${END_SYSTEM_ADDR}M-1 +parted $IMAGE_NAME --script -- mkpart vendor ext4 ${START_VENDOR_ADDR}M ${END_VENDOR_ADDR}M-1 +parted $IMAGE_NAME --script -- mkpart userdata ext4 ${START_USERDATA_ADDR}M ${END_USERDATA_ADDR}M-1 + +#6.dd partition images +echo -e "${green}3.start dd partition images......${normal}" +DD_START_BOOT_ADDR=$(convert_1000mib_to_1024mib "$START_BOOT_ADDR") +DD_START_SYSTEM_ADDR=$(convert_1000mib_to_1024mib "$START_SYSTEM_ADDR") +DD_START_VENDOR_ADDR=$(convert_1000mib_to_1024mib "$START_VENDOR_ADDR") +DD_START_USRERDATA_ADDR=$(convert_1000mib_to_1024mib "$START_USERDATA_ADDR") +dd if=${BOOT_IMG} of=${IMAGE_NAME} seek=$DD_START_BOOT_ADDR bs=1M conv=notrunc +dd if=system.img of=${IMAGE_NAME} seek=$DD_START_SYSTEM_ADDR bs=1M conv=notrunc +dd if=vendor.img of=${IMAGE_NAME} seek=$DD_START_VENDOR_ADDR bs=1M conv=notrunc +dd if=userdata.img of=${IMAGE_NAME} seek=$DD_START_USRERDATA_ADDR bs=1M conv=notrunc + +#7.save partion table and burn uboot image if [ -f $UBOOT_NAME ];then -echo -e "${green}5.start to burn uboot img......${normal}" -sudo dd if=$loopdevice of=table.bin bs=1 skip=446 count=66 -sudo dd if=$UBOOT_NAME of=$loopdevice -sudo dd if=table.bin of=$loopdevice bs=1 seek=446 count=66 -rm table.bin -f + echo -e "${green}5.start to burn uboot img......${normal}" + dd if=${IMAGE_NAME} of=table.bin bs=1 skip=440 count=17410 + dd if=$UBOOT_NAME of=${IMAGE_NAME} conv=notrunc + dd if=table.bin of=${IMAGE_NAME} bs=1 seek=440 conv=notrunc + rm table.bin -f fi -sync -sleep 5 - -echo "kpart loopdevice......" -sudo kpartx -d $loopdevice -echo "losetup loopdevice......" -sudo losetup -d $loopdevice echo -e "${green}generate $IMAGE_NAME successfully!!!!!! ${normal}" diff --git a/device_board_phytium/common/tools/generate_image/make_boot.sh b/device_board_phytium/common/tools/generate_image/make_boot.sh index 1543e02d3d7a235a78f5cde323f1e82a48a68049..c7964497d4768788f59c1a71b12d9655513b7b46 100755 --- a/device_board_phytium/common/tools/generate_image/make_boot.sh +++ b/device_board_phytium/common/tools/generate_image/make_boot.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) 2023 Phytium Technology Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,11 +21,12 @@ red="\e[31;1m" normal="\e[0m" OUT_PATH=${1} -FORMATE=uboot -if [ $# -eq 2 ] && [ "efi" = $2 ]; then - FORMATE=efi +FORMATE=efi +IMG_NAME=${OUT_PATH}/boot.img +if [ $# -eq 2 ] && [ "uboot" = $2 ]; then + FORMATE=uboot + IMG_NAME=${OUT_PATH}/boot_uboot.img fi -IMG_NAME=${OUT_PATH}/boot_${FORMATE}.img BOOT_PATH=${OUT_PATH}/boot/ IMAGE_SIZE=64 # 64M @@ -120,13 +121,8 @@ function check_boot_files() formate=$2 check_Image="Image " check_ramdisk="ramdisk.img " - check_dtb="" - check_efi="" - if [ "efi" = ${formate} ]; then - check_efi="EFI " - else - check_dtb="dtb " - fi + check_efi="EFI " + check_dtb="dtb " for FILE in `ls ${src}` do diff --git a/device_board_phytium/common/tools/generate_image/part.cfg b/device_board_phytium/common/tools/generate_image/part.cfg deleted file mode 100644 index 86286a5b864d3f8b407cc599d6e8277b6612649b..0000000000000000000000000000000000000000 --- a/device_board_phytium/common/tools/generate_image/part.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[partition] -image_name_ex = tengrui_d -label_reserve_size = 64 -boot_partition_size = 256 -system_partition_size = 2048 -vendor_partition_size = 512 -userdata_partition_size = 1024 diff --git a/device_board_phytium/tenglong_e/BUILD.gn b/device_board_phytium/tenglong_e/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..80729e5a6dad02b3e748c8e0b064c5acb275cd0d --- /dev/null +++ b/device_board_phytium/tenglong_e/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) 2024 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +import("//build/ohos.gni") + +print("${device_name}_group in") +group("${device_name}_group") { + deps = [ + "cfg:init_configs", + "//device/board/phytium/common/distributedhardware:distributedhardware", + "//device/board/phytium/common/build_kernel:build_kernel", + "//vendor/phytium/gpu_model/$gpu_model:gpu_group", + "//device/soc/phytium/common/hardware/display:display_buffer_model", + "//device/soc/phytium/common/hardware/display:display_composer_model", + ] +} diff --git a/device_board_phytium/tenglong_e/audio_alsa/alc662_common.h b/device_board_phytium/tenglong_e/audio_alsa/alc662_common.h new file mode 100644 index 0000000000000000000000000000000000000000..7ebe0d44b7d640790c027c4d36a303b5f8189265 --- /dev/null +++ b/device_board_phytium/tenglong_e/audio_alsa/alc662_common.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + * 2024.11.21 Phytium change. + */ + +#ifndef ALSA_SND_COMMON_H +#define ALSA_SND_COMMON_H + +/* AUDIO CODEC ALC662 amxier definitions */ + +/* SND playback path */ +#define SND_NUMID_MASTER_PLAYBACK_SWICH 31 +#define SND_ELEM_MASTER_PLAYBACK_SWICH "Master Playback Switch" +#define SND_OUT_CARD_ON "on" +#define SND_OUT_CARD_OFF "off" + +/* SND Master Playback Volume */ +#define SND_NUMID_MASTER_PLAYBACK_VOLUME 30 +#define SND_ELEM_MASTER_PLAYBACK_VOLUME "Master Playback Volume" +#define SND_OUT_PLAYBACK_DEFAULT_VOLUME "77" /* min:0 max:87 77=0.6*max */ + +/* SND Front Playback Switch */ +#define SND_NUMID_FRONT_PLAYBACK_SWITCH 3 +#define SND_ELEM_FRONT_PLAYBACK_SWITCH "Front Playback Switch" +#define SND_OUT_CARD_DACR_DACL_ON "on,on" +#define SND_OUT_CARD_DACR_DACL_OFF "off,off" + +/* Front Playback Volume */ +#define SND_NUMID_FRONT_PLAYBACK_VOLUME 2 +#define SND_ELEM_FRONT_PLAYBACK_VOLUME "Front Playback Volume" +#define SND_OUT_FRONT_PLAYBACK_DEFAULT_VOLUME "87" /* min:0 max:87 */ + + +/* Capture Intput Source Path */ +#define SND_NUMID_INPUT_SOURCE 19 +#define SND_ELEM_INPUT_SOURCE "Input Source" +#define SND_IN_CARD_FRONT_MIC "0" /* Front Mic */ +#define SND_IN_CARD_REAR_MIC "1" /* Rear Mic */ +#define SND_IN_CARD_LINE "2" /* Line */ + +/* Capture Input Switch */ +#define SND_NUMID_CAPTURE_SWITCH 22 +#define SND_ELEM_CAPTURE_SWITCH "Capture Switch" +#define SND_IN_CAPTURE_SWITCH_ON "on,on" +#define SND_IN_CAPTURE_SWITCH_OFF "off,off" + +/* cature Volume */ +#define SND_NUMID_CAPTURE_VOLUME 21 +#define SND_ELEM_CAPTURE_VOLUME "Capture Volume" +#define SND_IN_CAPTURE_DEFAULT_VOLUME "58" /* min:0, max:63 */ + +/* Front Playback Volume */ +#define SND_NUMID_REAR_MIC_BOOST_VOLUME 26 +#define SND_ELEM_REAR_MIC_BOOST_VOLUME "Rear Mic Boost Volume" +#define SND_IN_REAR_MIC_BOOST_DEFAULT_VOLUME "1,1" /* min:0,0 max:3,3 step:1,1 */ + + +#endif /* ALSA_SND_COMMON_H */ diff --git a/device_board_phytium/tenglong_e/audio_alsa/common.h b/device_board_phytium/tenglong_e/audio_alsa/common.h new file mode 100644 index 0000000000000000000000000000000000000000..cbfa0adc07690d15950977f0d6472d449712f7e6 --- /dev/null +++ b/device_board_phytium/tenglong_e/audio_alsa/common.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + * 2024.11.21 Phytium change. + */ + +#ifndef ALSA_SND_COMMON_H +#define ALSA_SND_COMMON_H + +/* AUDIO CODEC ALC897 amxier definitions */ + +/* SND playback path */ +#define SND_NUMID_MASTER_PLAYBACK_SWICH 36 +#define SND_ELEM_MASTER_PLAYBACK_SWICH "Master Playback Switch" +#define SND_OUT_CARD_ON "on" +#define SND_OUT_CARD_OFF "off" + +/* SND Master Playback Volume */ +#define SND_NUMID_MASTER_PLAYBACK_VOLUME 35 +#define SND_ELEM_MASTER_PLAYBACK_VOLUME "Master Playback Volume" +#define SND_OUT_PLAYBACK_DEFAULT_VOLUME "77" /* min:0 max:87 77=0.6*max */ + +/* SND Front Playback Switch */ +#define SND_NUMID_FRONT_PLAYBACK_SWITCH 2 +#define SND_ELEM_FRONT_PLAYBACK_SWITCH "Front Playback Switch" +#define SND_OUT_CARD_DACR_DACL_ON "on,on" +#define SND_OUT_CARD_DACR_DACL_OFF "off,off" + +/* Front Playback Volume */ +#define SND_NUMID_FRONT_PLAYBACK_VOLUME 1 +#define SND_ELEM_FRONT_PLAYBACK_VOLUME "Front Playback Volume" +#define SND_OUT_FRONT_PLAYBACK_DEFAULT_VOLUME "87" /* min:0 max:87 */ + + +/* Capture Intput Source Path */ +#define SND_NUMID_INPUT_SOURCE 21 +#define SND_ELEM_INPUT_SOURCE "Input Source" +#define SND_IN_CARD_FRONT_MIC "0" /* Front Mic */ +#define SND_IN_CARD_REAR_MIC "1" /* Rear Mic */ +#define SND_IN_CARD_LINE "2" /* Line */ + +/* Capture Input Switch */ +#define SND_NUMID_CAPTURE_SWITCH 24 +#define SND_ELEM_CAPTURE_SWITCH "Capture Switch" +#define SND_IN_CAPTURE_SWITCH_ON "on,on" +#define SND_IN_CAPTURE_SWITCH_OFF "off,off" + +/* cature Volume */ +#define SND_NUMID_CAPTURE_VOLUME 23 +#define SND_ELEM_CAPTURE_VOLUME "Capture Volume" +#define SND_IN_CAPTURE_DEFAULT_VOLUME "58" /* min:0, max:63 */ + +/* MIC Boost Volume */ +#define SND_NUMID_REAR_MIC_BOOST_VOLUME 28 +#define SND_ELEM_REAR_MIC_BOOST_VOLUME "Rear Mic Boost Volume" +#define SND_IN_REAR_MIC_BOOST_DEFAULT_VOLUME "1,1" /* min:0,0 max:3,3 step:1,1 */ + + +#endif /* ALSA_SND_COMMON_H */ diff --git a/device_board_phytium/tenglong_e/audio_alsa/vendor_capture.c b/device_board_phytium/tenglong_e/audio_alsa/vendor_capture.c new file mode 100644 index 0000000000000000000000000000000000000000..b882f8af33ac30612e81a6cb2b72928a64ca48c0 --- /dev/null +++ b/device_board_phytium/tenglong_e/audio_alsa/vendor_capture.c @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + * 2024.11.21 Phytium change. + */ + +#include "alsa_snd_capture.h" +#include "common.h" + +#define HDF_LOG_TAG HDF_AUDIO_HAL_CAPTURE + +typedef struct _CAPTURE_DATA_ { + struct AlsaMixerCtlElement ctrlVolume; + long tempVolume; +}CaptureData; + +static int32_t CaptureInitImpl(struct AlsaCapture* captureIns) +{ + struct AlsaMixerCtlElement mixerItem; + if (captureIns->priData != NULL) { + return HDF_SUCCESS; + } + CHECK_NULL_PTR_RETURN_DEFAULT(captureIns); + + CaptureData *priData = (CaptureData *)OsalMemCalloc(sizeof(CaptureData)); + if (priData == NULL) { + AUDIO_FUNC_LOGE("Failed to allocate memory!"); + return HDF_FAILURE; + } + + SndElementItemInit(&priData->ctrlVolume); + priData->ctrlVolume.numid = SND_NUMID_CAPTURE_VOLUME; + priData->ctrlVolume.name = SND_ELEM_CAPTURE_VOLUME; + CaptureSetPriData(captureIns, (CapturePriData)priData); + + SndElementItemInit(&mixerItem); + mixerItem.numid = SND_NUMID_INPUT_SOURCE; + mixerItem.name = SND_ELEM_INPUT_SOURCE; + mixerItem.value = SND_IN_CARD_REAR_MIC; + SndElementWrite(&captureIns->soundCard, &mixerItem); + + SndElementItemInit(&mixerItem); + mixerItem.numid = SND_NUMID_REAR_MIC_BOOST_VOLUME; + mixerItem.name = SND_ELEM_REAR_MIC_BOOST_VOLUME; + mixerItem.value = SND_IN_REAR_MIC_BOOST_DEFAULT_VOLUME; + SndElementWrite(&captureIns->soundCard, &mixerItem); + + AUDIO_FUNC_LOGI("CaptureInitImpl init success!!!"); + + return HDF_SUCCESS; +} + +static int32_t CaptureSelectSceneImpl(struct AlsaCapture *captureIns, enum AudioPortPin descPins, + const struct PathDeviceInfo *deviceInfo) +{ + return HDF_SUCCESS; +} + +static int32_t CaptureGetVolThresholdImpl(struct AlsaCapture *captureIns, long *volMin, long *volMax) +{ + int32_t ret; + long _volMin = 0; + long _volMax = 0; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)captureIns; + CaptureData *priData = CaptureGetPriData(captureIns); + CHECK_NULL_PTR_RETURN_DEFAULT(cardIns); + CHECK_NULL_PTR_RETURN_DEFAULT(priData); + + ret = SndElementReadRange(cardIns, &priData->ctrlVolume, &_volMin, &_volMax); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("SndElementReadRange fail!"); + return HDF_FAILURE; + } + *volMin = _volMin; + *volMax = _volMax; + + return HDF_SUCCESS; +} + +static int32_t CaptureGetVolumeImpl(struct AlsaCapture *captureIns, long *volume) +{ + int32_t ret; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)captureIns; + CaptureData *priData = CaptureGetPriData(captureIns); + CHECK_NULL_PTR_RETURN_DEFAULT(cardIns); + CHECK_NULL_PTR_RETURN_DEFAULT(priData); + + ret = SndElementReadInt(cardIns, &priData->ctrlVolume, volume); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("Read volume fail!"); + return HDF_FAILURE; + } + AUDIO_FUNC_LOGI("Read volume %ld!!!",*volume); + return HDF_SUCCESS; +} + +static int32_t CaptureSetVolumeImpl(struct AlsaCapture *captureIns, long volume) +{ + int32_t ret; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)captureIns; + CaptureData *priData = CaptureGetPriData(captureIns); + CHECK_NULL_PTR_RETURN_DEFAULT(cardIns); + CHECK_NULL_PTR_RETURN_DEFAULT(priData); + ret = SndElementWriteIntExt(cardIns, &priData->ctrlVolume, volume); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("Write volume fail!"); + return HDF_FAILURE; + } + AUDIO_FUNC_LOGI("Set volume %ld!!!",volume); + return HDF_SUCCESS; +} + +static int32_t CaptureSetMuteImpl(struct AlsaCapture *captureIns, bool muteFlag) +{ + int32_t ret; + long vol, setVol; + CaptureData *priData = CaptureGetPriData(captureIns); + CHECK_NULL_PTR_RETURN_DEFAULT(captureIns); + CHECK_NULL_PTR_RETURN_DEFAULT(priData); + ret = captureIns->GetVolume(captureIns, &vol); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("GetVolume failed!"); + return HDF_FAILURE; + } + + if (muteFlag) { + priData->tempVolume = vol; + setVol = 0; + } else { + setVol = priData->tempVolume; + } + captureIns->SetVolume(captureIns, setVol); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("SetVolume failed!"); + return HDF_FAILURE; + } + captureIns->muteState = muteFlag; + return HDF_SUCCESS; +} + +static int32_t CaptureStartImpl(struct AlsaCapture *captureIns) +{ + struct AlsaMixerCtlElement mixerItem; + CHECK_NULL_PTR_RETURN_DEFAULT(captureIns); + + SndElementItemInit(&mixerItem); + mixerItem.numid = SND_NUMID_CAPTURE_SWITCH; + mixerItem.name = SND_ELEM_CAPTURE_SWITCH; + mixerItem.value = SND_IN_CAPTURE_SWITCH_ON; + SndElementWrite(&captureIns->soundCard, &mixerItem); + + return HDF_SUCCESS; +} + +static int32_t CaptureStopImpl(struct AlsaCapture *captureIns) +{ + struct AlsaMixerCtlElement mixerItem; + CHECK_NULL_PTR_RETURN_DEFAULT(captureIns); + + SndElementItemInit(&mixerItem); + mixerItem.numid = SND_NUMID_CAPTURE_SWITCH; + mixerItem.name = SND_ELEM_CAPTURE_SWITCH; + mixerItem.value = SND_IN_CAPTURE_SWITCH_OFF; + SndElementWrite(&captureIns->soundCard, &mixerItem); + snd_pcm_drop(captureIns->soundCard.pcmHandle); + return HDF_SUCCESS; +} + +static int32_t CaptureGetGainThresholdImpl(struct AlsaCapture *captureIns, float *gainMin, float *gainMax) +{ + AUDIO_FUNC_LOGE("8541e not support gain operation"); + return HDF_SUCCESS; +} + +static int32_t CaptureGetGainImpl(struct AlsaCapture *captureIns, float *volume) +{ + AUDIO_FUNC_LOGE("8541e not support gain operation"); + return HDF_SUCCESS; +} + +static int32_t CaptureSetGainImpl(struct AlsaCapture *captureIns, float volume) +{ + AUDIO_FUNC_LOGE("8541e not support gain operation"); + return HDF_SUCCESS; +} + +static bool CaptureGetMuteImpl(struct AlsaCapture *captureIns) +{ + return captureIns->muteState; +} + +int32_t CaptureOverrideFunc(struct AlsaCapture *captureIns) +{ + if (captureIns == NULL) { + return HDF_FAILURE; + } + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)captureIns; + + if (cardIns->cardType == SND_CARD_PRIMARY) { + captureIns->Init = CaptureInitImpl; + captureIns->SelectScene = CaptureSelectSceneImpl; + captureIns->Start = CaptureStartImpl; + captureIns->Stop = CaptureStopImpl; + captureIns->GetVolThreshold = CaptureGetVolThresholdImpl; + captureIns->GetVolume = CaptureGetVolumeImpl; + captureIns->SetVolume = CaptureSetVolumeImpl; + captureIns->GetGainThreshold = CaptureGetGainThresholdImpl; + captureIns->GetGain = CaptureGetGainImpl; + captureIns->SetGain = CaptureSetGainImpl; + captureIns->GetMute = CaptureGetMuteImpl; + captureIns->SetMute = CaptureSetMuteImpl; + } + + return HDF_SUCCESS; +} diff --git a/device_board_phytium/tenglong_e/audio_alsa/vendor_render.c b/device_board_phytium/tenglong_e/audio_alsa/vendor_render.c new file mode 100644 index 0000000000000000000000000000000000000000..82be5ecbb703cfaf2e18b61abec331fdfc4bc97f --- /dev/null +++ b/device_board_phytium/tenglong_e/audio_alsa/vendor_render.c @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + * 2024.11.21 Phytium change. + */ + +#include "alsa_snd_render.h" +#include "common.h" + +#define HDF_LOG_TAG HDF_AUDIO_HAL_RENDER + +typedef struct _RENDER_DATA_ { + struct AlsaMixerCtlElement ctrlVolume; + long tempVolume; +}RenderData; + +static int32_t RenderInitImpl(struct AlsaRender *renderIns) +{ + int32_t ret; + struct AlsaMixerCtlElement elem; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)renderIns; + + if (renderIns->priData != NULL) { + return HDF_SUCCESS; + } + CHECK_NULL_PTR_RETURN_DEFAULT(renderIns); + + RenderData *priData = (RenderData *)OsalMemCalloc(sizeof(RenderData)); + if (priData == NULL) { + AUDIO_FUNC_LOGE("Failed to allocate memory!"); + return HDF_FAILURE; + } + + SndElementItemInit(&priData->ctrlVolume); + priData->ctrlVolume.numid = SND_NUMID_MASTER_PLAYBACK_VOLUME; + priData->ctrlVolume.name = SND_ELEM_MASTER_PLAYBACK_VOLUME; + RenderSetPriData(renderIns, (RenderPriData)priData); + + + SndElementItemInit(&elem); + elem.numid = SND_NUMID_FRONT_PLAYBACK_SWITCH; + elem.name = SND_ELEM_FRONT_PLAYBACK_SWITCH; + elem.value = SND_OUT_CARD_DACR_DACL_ON; + ret = SndElementWrite(cardIns, &elem); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("open front playback switch fail!"); + return HDF_FAILURE; + } + + SndElementItemInit(&elem); + elem.numid = SND_NUMID_MASTER_PLAYBACK_VOLUME; + elem.name = SND_ELEM_MASTER_PLAYBACK_VOLUME; + elem.value = SND_OUT_PLAYBACK_DEFAULT_VOLUME; + ret = SndElementWrite(cardIns, &elem); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("set default volume fail!"); + return HDF_FAILURE; + } + + AUDIO_FUNC_LOGI("RenderInitImpl success!"); + return HDF_SUCCESS; +} + +static int32_t RenderSelectSceneImpl(struct AlsaRender *renderIns, enum AudioPortPin descPins, + const struct PathDeviceInfo *deviceInfo) +{ + AUDIO_FUNC_LOGI("Not support descPins"); + return HDF_SUCCESS; +} + +static int32_t RenderGetVolThresholdImpl(struct AlsaRender *renderIns, long *volMin, long *volMax) +{ + int32_t ret; + long _volMin = 0; + long _volMax = 0; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)renderIns; + RenderData *priData = RenderGetPriData(renderIns); + CHECK_NULL_PTR_RETURN_DEFAULT(cardIns); + CHECK_NULL_PTR_RETURN_DEFAULT(priData); + + ret = SndElementReadRange(cardIns, &priData->ctrlVolume, &_volMin, &_volMax); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("SndElementReadRange fail!"); + return HDF_FAILURE; + } + *volMin = _volMin; + *volMax = _volMax; + AUDIO_FUNC_LOGI("RenderGetVolumeImpl min=%ld max=%ld !",_volMin,_volMax); + return HDF_SUCCESS; +} + +static int32_t RenderGetVolumeImpl(struct AlsaRender *renderIns, long *volume) +{ + int32_t ret; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)renderIns; + RenderData *priData = RenderGetPriData(renderIns); + CHECK_NULL_PTR_RETURN_DEFAULT(cardIns); + CHECK_NULL_PTR_RETURN_DEFAULT(priData); + + ret = SndElementReadInt(cardIns, &priData->ctrlVolume, volume); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("Read Volume fail!"); + return HDF_FAILURE; + } + + AUDIO_FUNC_LOGI("RenderGetVolumeImpl %ld !!!!!",*volume); + return HDF_SUCCESS; +} + +static int32_t RenderSetVolumeImpl(struct AlsaRender *renderIns, long volume) +{ + int32_t ret; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)renderIns; + RenderData *priData = RenderGetPriData(renderIns); + CHECK_NULL_PTR_RETURN_DEFAULT(cardIns); + CHECK_NULL_PTR_RETURN_DEFAULT(priData); + + ret = SndElementWriteInt(cardIns, &priData->ctrlVolume, volume); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("Write volume fail!"); + return HDF_FAILURE; + } + AUDIO_FUNC_LOGI("RenderSetVolumeImpl %ld !!!!!",volume); + return HDF_SUCCESS; +} + +static bool RenderGetMuteImpl(struct AlsaRender *renderIns) +{ + return renderIns->muteState; +} + +static int32_t RenderSetMuteImpl(struct AlsaRender *renderIns, bool muteFlag) +{ + int32_t ret; + long vol, setVol; + RenderData *priData = RenderGetPriData(renderIns); + CHECK_NULL_PTR_RETURN_DEFAULT(renderIns); + CHECK_NULL_PTR_RETURN_DEFAULT(priData); + + ret = renderIns->GetVolume(renderIns, &vol); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("GetVolume failed!"); + return HDF_FAILURE; + } + + if (muteFlag) { + priData->tempVolume = vol; + setVol = 0; + } else { + setVol = priData->tempVolume; + } + + renderIns->SetVolume(renderIns, setVol); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("SetVolume failed!"); + return HDF_FAILURE; + } + renderIns->muteState = muteFlag; + + return HDF_SUCCESS; +} + +static int32_t RenderStartImpl(struct AlsaRender *renderIns) +{ + int32_t ret; + struct AlsaMixerCtlElement elem; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)renderIns; + + SndElementItemInit(&elem); + elem.numid = SND_NUMID_MASTER_PLAYBACK_SWICH; + elem.name = SND_ELEM_MASTER_PLAYBACK_SWICH; + elem.value = SND_OUT_CARD_ON; + + ret = SndElementWrite(cardIns, &elem); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("write render fail!"); + return HDF_FAILURE; + } + + AUDIO_FUNC_LOGI("RenderStartImpl success!"); + return HDF_SUCCESS; +} + +static int32_t RenderStopImpl(struct AlsaRender *renderIns) +{ + int32_t ret; + struct AlsaMixerCtlElement elem; + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)renderIns; + + SndElementItemInit(&elem); + elem.numid = SND_NUMID_MASTER_PLAYBACK_SWICH; + elem.name = SND_ELEM_MASTER_PLAYBACK_SWICH; + elem.value = SND_OUT_CARD_OFF; + ret = SndElementWrite(cardIns, &elem); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("write render fail!"); + return HDF_FAILURE; + } + + snd_pcm_drain(renderIns->soundCard.pcmHandle); + AUDIO_FUNC_LOGI("RenderStopImpl success!"); + return HDF_SUCCESS; +} + +static int32_t RenderGetGainThresholdImpl(struct AlsaRender *renderIns, float *gainMin, float *gainMax) +{ + AUDIO_FUNC_LOGI("Not support gain operation"); + return HDF_SUCCESS; +} + +static int32_t RenderGetGainImpl(struct AlsaRender *renderIns, float *volume) +{ + AUDIO_FUNC_LOGI("Not support gain operation"); + return HDF_SUCCESS; +} + +static int32_t RenderSetGainImpl(struct AlsaRender *renderIns, float volume) +{ + AUDIO_FUNC_LOGI("Not support gain operation"); + return HDF_SUCCESS; +} + +static int32_t RenderGetChannelModeImpl(struct AlsaRender *renderIns, enum AudioChannelMode *mode) +{ + return HDF_SUCCESS; +} + +static int32_t RenderSetChannelModeImpl(struct AlsaRender *renderIns, enum AudioChannelMode mode) +{ + return HDF_SUCCESS; +} + +int32_t RenderOverrideFunc(struct AlsaRender *renderIns) +{ + struct AlsaSoundCard *cardIns = (struct AlsaSoundCard *)renderIns; + + if (cardIns->cardType == SND_CARD_PRIMARY) { + renderIns->Init = RenderInitImpl; + renderIns->SelectScene = RenderSelectSceneImpl; + renderIns->Start = RenderStartImpl; + renderIns->Stop = RenderStopImpl; + renderIns->GetVolThreshold = RenderGetVolThresholdImpl; + renderIns->GetVolume = RenderGetVolumeImpl; + renderIns->SetVolume = RenderSetVolumeImpl; + renderIns->GetGainThreshold = RenderGetGainThresholdImpl; + renderIns->GetGain = RenderGetGainImpl; + renderIns->SetGain = RenderSetGainImpl; + renderIns->GetMute = RenderGetMuteImpl; + renderIns->SetMute = RenderSetMuteImpl; + renderIns->GetChannelMode = RenderGetChannelModeImpl; + renderIns->SetChannelMode = RenderSetChannelModeImpl; + } + + return HDF_SUCCESS; +} diff --git a/device_board_phytium/tenglong_e/cfg/BUILD.gn b/device_board_phytium/tenglong_e/cfg/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..2058346f68b9109b5afdb1c23b9b3dee9a1a744b --- /dev/null +++ b/device_board_phytium/tenglong_e/cfg/BUILD.gn @@ -0,0 +1,63 @@ +# Copyright (c) 2024 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +import("//build/ohos.gni") + +ohos_prebuilt_etc("init.${device_name}.cfg") { + source = "init.${device_name}.cfg" + part_name = "device_${device_name}" + install_images = [ chipset_base_dir ] + install_enable = true +} + +ohos_prebuilt_etc("init.${device_name}.usb.cfg") { + source = "init.${device_name}.usb.cfg" + part_name = "device_${device_name}" + install_images = [ chipset_base_dir ] + install_enable = true +} + +ohos_prebuilt_etc("fstab.${device_name}") { + source = "fstab.${device_name}" + part_name = "device_${device_name}" + install_images = [ vendor_base_dir ] + install_enable = true +} + +if (enable_ramdisk) { + ohos_prebuilt_etc("fstab.required") { + source = "fstab.required" + part_name = "device_${device_name}" + install_enable = true + install_images = [ + "ramdisk", + ] + } +} else { + ohos_prebuilt_etc("fstab.required") { + source = "fstab.required" + part_name = "device_${device_name}" + install_images = [ "system" ] + install_enable = true + } +} + + +group("init_configs") { + deps = [ + ":fstab.required", + ":fstab.${device_name}", + ":init.${device_name}.cfg", + ":init.${device_name}.usb.cfg", + ] +} diff --git a/device_board_phytium/tenglong_e/cfg/fstab.required b/device_board_phytium/tenglong_e/cfg/fstab.required new file mode 100755 index 0000000000000000000000000000000000000000..3d01c257dab9e065e38ab16e90c18124b80bb586 --- /dev/null +++ b/device_board_phytium/tenglong_e/cfg/fstab.required @@ -0,0 +1,12 @@ +# fstab file. +# + +#SATA hard disk and USB disk config +/dev/block/sda2 /usr ext4 ro,barrier=1 wait,required +/dev/block/sda3 /vendor ext4 ro,barrier=1 wait,required +/dev/block/sda4 /data ext4 nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc wait,reservedsize=104857600 + +#NVME disk config +#/dev/block/nvme0n1p2 /usr ext4 ro,barrier=1 wait,required +#/dev/block/nvme0n1p3 /vendor ext4 ro,barrier=1 wait,required +#/dev/block/nvme0n1p4 /data ext4 nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc wait,reservedsize=104857600 diff --git a/device_board_phytium/tenglong_e/cfg/fstab.tenglong_e b/device_board_phytium/tenglong_e/cfg/fstab.tenglong_e new file mode 100755 index 0000000000000000000000000000000000000000..3d01c257dab9e065e38ab16e90c18124b80bb586 --- /dev/null +++ b/device_board_phytium/tenglong_e/cfg/fstab.tenglong_e @@ -0,0 +1,12 @@ +# fstab file. +# + +#SATA hard disk and USB disk config +/dev/block/sda2 /usr ext4 ro,barrier=1 wait,required +/dev/block/sda3 /vendor ext4 ro,barrier=1 wait,required +/dev/block/sda4 /data ext4 nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc wait,reservedsize=104857600 + +#NVME disk config +#/dev/block/nvme0n1p2 /usr ext4 ro,barrier=1 wait,required +#/dev/block/nvme0n1p3 /vendor ext4 ro,barrier=1 wait,required +#/dev/block/nvme0n1p4 /data ext4 nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc wait,reservedsize=104857600 diff --git a/device_board_phytium/tenglong_e/cfg/init.tenglong_e.cfg b/device_board_phytium/tenglong_e/cfg/init.tenglong_e.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b84e065d3e97cdba4f1e93634dfcae7ade3fec73 --- /dev/null +++ b/device_board_phytium/tenglong_e/cfg/init.tenglong_e.cfg @@ -0,0 +1,51 @@ +{ + "import" : [ + "init.${ohos.boot.hardware}.usb.cfg" + ], + "jobs" : [{ + "name" : "pre-init", + "cmds" : [ + "write /proc/sys/vm/min_free_kbytes 10240", + "mount debugfs /sys/kernel/debug /sys/kernel/debug mode=755", + "write /sys/kernel/debug/hisi_inno_phy/role peripheral", + "export GST_OMX_CONFIG_DIR /system/lib64/media/plugins/", + "insmod /system/lib64/media/plugins/img_mem.ko", + "insmod /system/lib64/media/plugins/vxd.ko" + ] + }, { + "name" : "init", + "cmds" : [ + "write /proc/1/oom_score_adj -1000", + "write /proc/sys/kernel/hung_task_timeout_secs 90", + "write /sys/kernel/hungtask/enable on", + "write /sys/kernel/hungtask/monitorlist whitelist,init,appspawn", + "symlink /dev/block/platform/soc/40000000.pcie/by-name /dev/block/by-name", + "chown system system /sys/kernel/hungtask/userlist", + "chmod 0666 /dev/pvr_sync", + "chmod 0666 /dev/vxd0", + "chmod 0666 /dev/dri/card1" + ] + }, { + "name" : "boot", + "cmds" : [ + "chmod 777 /dev/ttyAMA2", + "chmod 0440 /proc/interrupts", + "chmod 0440 /proc/stat", + "chown system graphics /dev/graphics/fb0", + "start ispserver" + ] + }, { + "name" : "post-fs-data", + "cmds" : [ + "restorecon", + "param set const.security.developermode.state true" + ] + } + ], + "services" : [{ + "name" : "ispserver", + "path" : ["/vendor/bin/ispserver"], + "once" : 1 + } + ] +} diff --git a/device_board_phytium/tenglong_e/cfg/init.tenglong_e.usb.cfg b/device_board_phytium/tenglong_e/cfg/init.tenglong_e.usb.cfg new file mode 100755 index 0000000000000000000000000000000000000000..59cfed979d50933639ab0decb72600ab2ecaa3d6 --- /dev/null +++ b/device_board_phytium/tenglong_e/cfg/init.tenglong_e.usb.cfg @@ -0,0 +1,51 @@ +{ + "jobs" : [{ + "name" : "boot", + "cmds" : [ + "mkdir /dev/usb-ffs 0770 shell shell", + "mkdir /dev/usb-ffs/hdc 0770 shell shell", + "mount configfs none /config", + "mkdir /config/usb_gadget/g1 0770 shell shell", + "write /config/usb_gadget/g1/idVendor 0x2207", + "write /config/usb_gadget/g1/idProduct 0x0018", + "write /config/usb_gadget/g1/os_desc/use 1", + "write /config/usb_gadget/g1/bcdDevice 0x0223", + "write /config/usb_gadget/g1/bcdUSB 0x0200", + "mkdir /config/usb_gadget/g1/strings/0x409 0770", + "copy /sys/block/mmcblk0/device/cid /config/usb_gadget/g1/strings/0x409/serialnumber", + "write /config/usb_gadget/g1/strings/0x409/manufacturer Phytium", + "write /config/usb_gadget/g1/strings/0x409/product \"HDC Device\"", + "mkdir /config/usb_gadget/g1/functions/ffs.hdc", + "mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell", + "mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell", + "write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1", + "write /config/usb_gadget/g1/os_desc/qw_sign MSFT100", + "write /config/usb_gadget/g1/configs/b.1/MaxPower 500", + "symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1", + "mount functionfs hdc /dev/usb-ffs/hdc uid=2000,gid=2000", + "setparam sys.usb.configfs 1", + "setparam sys.usb.controller fcc00000.dwc3" + ] + }, { + "name" : "param:sys.usb.config=none && param:sys.usb.configfs=1", + "condition" : "sys.usb.config=none && sys.usb.configfs=1", + "cmds" : [ + "write /config/usb_gadget/g1/os_desc/use 0", + "setparam sys.usb.ffs.ready 0" + ] + }, { + "name" : "param:init.svc.hdcd=stopped", + "condition" : "init.svc.hdcd=stopped", + "cmds" : [ + "setparam sys.usb.ffs.ready 0" + ] + }, { + "name" : "param:sys.usb.config=hdc && param:sys.usb.configfs=1", + "condition" : "sys.usb.config=hdc && sys.usb.configfs=1", + "cmds" : [ + "write /config/usb_gadget/g1/idProduct 0x5000", + "write /config/usb_gadget/g1/os_desc/use 1" + ] + } + ] +} diff --git a/device_board_phytium/tenglong_e/device.gni b/device_board_phytium/tenglong_e/device.gni new file mode 100644 index 0000000000000000000000000000000000000000..f22f18c6a4454325d8f8da28aa14013a29ee8a69 --- /dev/null +++ b/device_board_phytium/tenglong_e/device.gni @@ -0,0 +1,24 @@ +# Copyright (c) 2024 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +soc_company = "phytium" +soc_name = "pe2x04" + +import("//device/soc/${soc_company}/${soc_name}/soc.gni") + +import("//build/ohos.gni") +if (!defined(defines)) { + defines = [] +} + + diff --git a/device_board_phytium/tenglong_e/loader/EFI/BOOT/bootaa64.efi b/device_board_phytium/tenglong_e/loader/EFI/BOOT/bootaa64.efi new file mode 100644 index 0000000000000000000000000000000000000000..1a7f4e5294da5ee58b6077d5e4736a7b1494d4f3 Binary files /dev/null and b/device_board_phytium/tenglong_e/loader/EFI/BOOT/bootaa64.efi differ diff --git a/device_board_phytium/tenglong_e/loader/EFI/BOOT/grub.cfg b/device_board_phytium/tenglong_e/loader/EFI/BOOT/grub.cfg new file mode 100755 index 0000000000000000000000000000000000000000..65b33a54ca68196fb4ddeb14e3b29b9340045c0d --- /dev/null +++ b/device_board_phytium/tenglong_e/loader/EFI/BOOT/grub.cfg @@ -0,0 +1,10 @@ +# Automatically created by OE +serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 +search --no-floppy --set=root -l 'boot' +default=boot +timeout=10 + +menuentry 'boot'{ +linux /Image LABEL=boot root=/dev/ram0 hardware=tenglong_e selinux=0 rootfstype=ext4 loglevel=1 +initrd /ramdisk.img +} diff --git a/device_board_phytium/tenglong_e/ohos.build b/device_board_phytium/tenglong_e/ohos.build new file mode 100755 index 0000000000000000000000000000000000000000..66ee1a0120999d650b2d6ccb0d97e841d09b3d9e --- /dev/null +++ b/device_board_phytium/tenglong_e/ohos.build @@ -0,0 +1,10 @@ +{ + "subsystem": "phytium_products", + "parts": { + "device_tenglong_e": { + "module_list": [ + "//device/board/phytium/${device_name}:${device_name}_group" + ] + } + } +} diff --git a/device_board_phytium/tengrui_d/BUILD.gn b/device_board_phytium/tengrui_d/BUILD.gn index 2262fea0ec299c71a3919676bd4a864d73d71519..80729e5a6dad02b3e748c8e0b064c5acb275cd0d 100755 --- a/device_board_phytium/tengrui_d/BUILD.gn +++ b/device_board_phytium/tengrui_d/BUILD.gn @@ -17,10 +17,10 @@ print("${device_name}_group in") group("${device_name}_group") { deps = [ "cfg:init_configs", - "distributedhardware:distributedhardware", - "../common/build_kernel:build_kernel", + "//device/board/phytium/common/distributedhardware:distributedhardware", + "//device/board/phytium/common/build_kernel:build_kernel", "//vendor/phytium/gpu_model/$gpu_model:gpu_group", - "//device/soc/phytium/pd2x08/hardware/display:display_buffer_model", - "//device/soc/phytium/pd2x08/hardware/display:display_composer_model", + "//device/soc/phytium/common/hardware/display:display_buffer_model", + "//device/soc/phytium/common/hardware/display:display_composer_model", ] } diff --git a/device_board_phytium/tengrui_d/cfg/init.tengrui_d.cfg b/device_board_phytium/tengrui_d/cfg/init.tengrui_d.cfg index 76b2ce3a419c1200292dd7497b8ecc068f9c27a3..b84e065d3e97cdba4f1e93634dfcae7ade3fec73 100755 --- a/device_board_phytium/tengrui_d/cfg/init.tengrui_d.cfg +++ b/device_board_phytium/tengrui_d/cfg/init.tengrui_d.cfg @@ -21,8 +21,9 @@ "write /sys/kernel/hungtask/monitorlist whitelist,init,appspawn", "symlink /dev/block/platform/soc/40000000.pcie/by-name /dev/block/by-name", "chown system system /sys/kernel/hungtask/userlist", - "chmod 0666 /dev/pvr_sync", - "chmod 0666 /dev/vxd0" + "chmod 0666 /dev/pvr_sync", + "chmod 0666 /dev/vxd0", + "chmod 0666 /dev/dri/card1" ] }, { "name" : "boot", @@ -36,7 +37,8 @@ }, { "name" : "post-fs-data", "cmds" : [ - "restorecon" + "restorecon", + "param set const.security.developermode.state true" ] } ], diff --git a/device_board_phytium/tengrui_d/dts/.gitkeep b/device_board_phytium/tengrui_d/dts/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/device_board_phytium/tengrui_d/patch/0006=base-startup-init=fix_get_fstab_fail_from_cmdline.patch b/device_board_phytium/tengrui_d/patch/0006=base-startup-init=fix_get_fstab_fail_from_cmdline.patch deleted file mode 100644 index b51eddca166dbb37d348ac5078ea5b48c9257557..0000000000000000000000000000000000000000 --- a/device_board_phytium/tengrui_d/patch/0006=base-startup-init=fix_get_fstab_fail_from_cmdline.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/interfaces/innerkits/fs_manager/fstab_mount.c b/interfaces/innerkits/fs_manager/fstab_mount.c -index 65dc09a7..9878c5c3 100755 ---- a/interfaces/innerkits/fs_manager/fstab_mount.c -+++ b/interfaces/innerkits/fs_manager/fstab_mount.c -@@ -480,9 +480,12 @@ int MountAllWithFstabFile(const char *fstabFile, bool required) - BEGET_CHECK(!isFile, return -1); - - Fstab *fstab = NULL; -- if ((fstab = ReadFstabFromFile(fstabFile, false)) == NULL) { -- BEGET_LOGE("[fs_manager][error] Read fstab file \" %s \" failed\n", fstabFile); -- return -1; -+ fstab = LoadFstabFromCommandLine(); -+ if (fstab == NULL) { -+ if ((fstab = ReadFstabFromFile(fstabFile, false)) == NULL) { -+ BEGET_LOGE("[fs_manager][error] Read fstab file \" %s \" failed\n", fstabFile); -+ return -1; -+ } - } - - int rc = MountAllWithFstab(fstab, required); -@@ -497,8 +500,11 @@ int UmountAllWithFstabFile(const char *fstabFile) - BEGET_CHECK(!isFile, return -1); - - Fstab *fstab = NULL; -- fstab = ReadFstabFromFile(fstabFile, false); -- BEGET_ERROR_CHECK(fstab != NULL, return -1, "Read fstab file \" %s \" failed.", fstabFile); -+ fstab = LoadFstabFromCommandLine(); -+ if (fstab == NULL) { -+ fstab = ReadFstabFromFile(fstabFile, false); -+ BEGET_ERROR_CHECK(fstab != NULL, return -1, "Read fstab file \" %s \" failed.", fstabFile); -+ } - - FstabItem *item = NULL; - int rc = -1; diff --git a/device_soc_phytium/README.md b/device_soc_phytium/README.md old mode 100644 new mode 100755 index 942836f6ac1acd26f515a249e0505197afbae783..cab9b0c6b07cf4773258398698873874648f1e5d --- a/device_soc_phytium/README.md +++ b/device_soc_phytium/README.md @@ -1,6 +1,6 @@ # phytium hardware组件 -#### 简介 +## 简介 ### 1.1 芯片简介 飞腾芯片产品具有谱系全、自主性强、性能优、安全性高等特点,通算处理器包括高性能服务器CPU(飞腾腾云S系列)、高效能桌面CPU(飞腾腾锐D系列)、高端嵌入式CPU(飞腾腾珑E系列)和飞腾XPU系列四大系列,产品性能达到国内领先、国际一流水平,能够为从端到云的各型设备提供核心算力支撑。 * [腾锐D2000](https://www.phytium.com.cn/homepage/production/1/) @@ -35,25 +35,42 @@ |其他接口|4 个 UART 接口、64 个 GPIO、4 路 PWM、2路通用 SPI master、3 路 I2C/PMBUS、2 路 I3C、2 路 CAN-FD、1 路 LocalBus| |安全技术|支持PSPA 1.0 安全规范| +* [腾珑E2000](https://www.phytium.com.cn/homepage/production/12/) +飞腾腾珑E2000系列包括E2000Q、E2000D、E2000S三个系列,芯片集成飞腾自主研发的高能效和低功耗处理器核,E2000Q集成2个FTC664和2个FTC310处理器核,标准系统只支持E2000Q。 + +|类型|参数| +|-----|-----| +|核心|飞腾自主高能效处理器核FTC664、低功耗处理器核FTC310| +|核数|4核2×FTC664,2×FTC310| +|主频|FTC664:1.8/2.0GHz FTC310:1.5GHz| +|二级缓存|2MB+256KB| +|视频编解码|H.264/265 解码,2K@30fps| +|存储控制器|1个DDR4接口| +|PCIe接口|6 lanes PCIe 3.0| +|网络接口|2个千兆自适应SGMII或万兆 USXGMII + 2个千兆自适应SGMII/RGMII以太网接口| +|其他接口|1个SD,1个SD/SDIO/eMMC,4路PWM,1个QSPI,1个NandFlash,4个UART,16个MIO(可配置成 I2C 或 UART),4个SPI master,96路GPIO,1个LocalBus,1个ADC,1个JTAG master,2个WDT,2个CAN和CANFD,1个Keypad(8×8)| +|安全技术|支持PSPA 1.0 安全规范| + ### 1.2 仓库简介 媒体及wifi南向接口实现、框架及对接层库目录。 ### 1.3 约束 -目前支持飞腾腾锐D系列。 +目前支持飞腾腾锐D系列和腾珑E系列。 ## 目录 ``` ├── common -│ └── hal -│ └── usb -├── pd2x08 -│ ├── hardware -│ │ ├── display -│ │ └── ... -│ └── ... -└── ... +│   └── hardware +├── LICENSE +├── pd2x08 +│   ├── hal +│   └── soc.gni +├── pe2x04 +│   ├── hal +│   └── soc.gni +└── README.md ``` ## 相关仓 diff --git a/device_soc_phytium/pd2x08/hardware/display/BUILD.gn b/device_soc_phytium/common/hardware/display/BUILD.gn similarity index 98% rename from device_soc_phytium/pd2x08/hardware/display/BUILD.gn rename to device_soc_phytium/common/hardware/display/BUILD.gn index 92946b427b11b1f0ba30efbab40a6e8e4505761b..104697989383c6e418dad4cc30dff3fb89089d9f 100755 --- a/device_soc_phytium/pd2x08/hardware/display/BUILD.gn +++ b/device_soc_phytium/common/hardware/display/BUILD.gn @@ -155,7 +155,7 @@ ohos_shared_library("libdisplay_composer_vdi_impl") { deps = [ ":display_composer_vendor", "//third_party/libdrm:libdrm", - ":${device_name}.para.dac", + ":phytium.para.dac", ] external_deps = [ @@ -267,8 +267,8 @@ ohos_shared_library("display_gfx") { part_name = "device_${device_name}" } -ohos_prebuilt_etc("${device_name}.para.dac") { - source = "${device_name}.para.dac" +ohos_prebuilt_etc("phytium.para.dac") { + source = "phytium.para.dac" subsystem_name = "phytium_products" part_name = "device_${device_name}" module_install_dir = "etc/param" diff --git a/device_soc_phytium/pd2x08/hardware/display/include/display_gralloc_private.h b/device_soc_phytium/common/hardware/display/include/display_gralloc_private.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/include/display_gralloc_private.h rename to device_soc_phytium/common/hardware/display/include/display_gralloc_private.h diff --git a/device_soc_phytium/pd2x08/hardware/display/include/phytium_display_log.h b/device_soc_phytium/common/hardware/display/include/phytium_display_log.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/include/phytium_display_log.h rename to device_soc_phytium/common/hardware/display/include/phytium_display_log.h diff --git a/device_soc_phytium/pd2x08/hardware/display/tengrui_d.para.dac b/device_soc_phytium/common/hardware/display/phytium.para.dac similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/tengrui_d.para.dac rename to device_soc_phytium/common/hardware/display/phytium.para.dac diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/display_composer_vdi_impl.cpp b/device_soc_phytium/common/hardware/display/src/display_device/composer/display_composer_vdi_impl.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/display_composer_vdi_impl.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/composer/display_composer_vdi_impl.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/display_composer_vdi_impl.h b/device_soc_phytium/common/hardware/display/src/display_device/composer/display_composer_vdi_impl.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/display_composer_vdi_impl.h rename to device_soc_phytium/common/hardware/display/src/display_device/composer/display_composer_vdi_impl.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/display_gfx.h b/device_soc_phytium/common/hardware/display/src/display_device/composer/display_gfx.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/display_gfx.h rename to device_soc_phytium/common/hardware/display/src/display_device/composer/display_gfx.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/hdi_composer.cpp b/device_soc_phytium/common/hardware/display/src/display_device/composer/hdi_composer.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/hdi_composer.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/composer/hdi_composer.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/hdi_composer.h b/device_soc_phytium/common/hardware/display/src/display_device/composer/hdi_composer.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/hdi_composer.h rename to device_soc_phytium/common/hardware/display/src/display_device/composer/hdi_composer.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/hdi_gfx_composition.cpp b/device_soc_phytium/common/hardware/display/src/display_device/composer/hdi_gfx_composition.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/hdi_gfx_composition.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/composer/hdi_gfx_composition.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/hdi_gfx_composition.h b/device_soc_phytium/common/hardware/display/src/display_device/composer/hdi_gfx_composition.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/composer/hdi_gfx_composition.h rename to device_soc_phytium/common/hardware/display/src/display_device/composer/hdi_gfx_composition.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_device_common.h b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_device_common.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_device_common.h rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_device_common.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_device_interface.cpp b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_device_interface.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_device_interface.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_device_interface.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_device_interface.h b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_device_interface.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_device_interface.h rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_device_interface.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_display.cpp b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_display.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_display.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_display.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_display.h b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_display.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_display.h rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_display.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_fd.h b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_fd.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_fd.h rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_fd.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_layer.cpp b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_layer.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_layer.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_layer.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_layer.h b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_layer.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_layer.h rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_layer.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_netlink_monitor.cpp b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_netlink_monitor.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_netlink_monitor.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_netlink_monitor.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_netlink_monitor.h b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_netlink_monitor.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_netlink_monitor.h rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_netlink_monitor.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_session.cpp b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_session.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_session.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_session.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_session.h b/device_soc_phytium/common/hardware/display/src/display_device/core/hdi_session.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/core/hdi_session.h rename to device_soc_phytium/common/hardware/display/src/display_device/core/hdi_session.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_connector.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_connector.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_connector.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_connector.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_connector.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_connector.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_connector.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_connector.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_crtc.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_crtc.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_crtc.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_crtc.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_crtc.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_crtc.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_crtc.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_crtc.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_device.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_device.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_device.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_device.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_device.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_device.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_device.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_device.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_display.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_display.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_display.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_display.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_display.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_display.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_display.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_display.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_encoder.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_encoder.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_encoder.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_encoder.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_encoder.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_encoder.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_encoder.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_encoder.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_plane.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_plane.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_plane.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_plane.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_plane.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_plane.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_plane.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_plane.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_vsync_worker.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_vsync_worker.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_vsync_worker.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_vsync_worker.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_vsync_worker.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/drm_vsync_worker.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/drm_vsync_worker.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/drm_vsync_worker.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_composition.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_composition.cpp similarity index 94% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_composition.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_composition.cpp index caba35bbd16755e3dac116e79b7598d8f710fba0..4a8c67504fe2fbbb7f2d31b34e300346fa53b3e5 100644 --- a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_composition.cpp +++ b/device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_composition.cpp @@ -92,9 +92,23 @@ int32_t HdiDrmComposition::ApplyPlane(HdiDrmLayer &layer, DrmPlane &drmPlane, dr int fenceFd = layer.GetAcquireFenceFd(); int propId = drmPlane.GetPropFenceInId(); HdiLayerBuffer *layerBuffer = layer.GetCurrentBuffer(); - int32_t bufferW = layerBuffer->GetWidth(); - int32_t bufferH = layerBuffer->GetHeight(); - DISPLAY_LOGD(); + + /* get current resolution */ + DrmMode mode; + mConnector->GetModeFromId(mCrtc->GetActiveModeId(), mode); + int32_t mode_w = mode.GetModeInfoPtr()->hdisplay; + int32_t mode_h = mode.GetModeInfoPtr()->vdisplay; + /* print the resolution */ + DISPLAY_LOGD("ApplyPlane Resolution: %{public}d x %{public}d", + mode.GetModeInfoPtr()->hdisplay, + mode.GetModeInfoPtr()->vdisplay); + + int32_t layerbuffer_w = layerBuffer->GetWidth(); + int32_t layerbuffer_h = layerBuffer->GetHeight(); + int32_t bufferW = layerbuffer_w > mode_w ? mode_w : layerbuffer_w; + int32_t bufferH = layerbuffer_h > mode_h ? mode_h : layerbuffer_h; + DISPLAY_LOGD("bufferW: %{public}d, bufferH: %{public}d", bufferW, bufferH); + if (propId != 0) { DISPLAY_LOGD("set the fence in prop"); if (fenceFd >= 0) { diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_composition.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_composition.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_composition.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_composition.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_layer.cpp b/device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_layer.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_layer.cpp rename to device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_layer.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_layer.h b/device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_layer.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_device/drm/hdi_drm_layer.h rename to device_soc_phytium/common/hardware/display/src/display_device/drm/hdi_drm_layer.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_gfx/display_gfx.c b/device_soc_phytium/common/hardware/display/src/display_gfx/display_gfx.c similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_gfx/display_gfx.c rename to device_soc_phytium/common/hardware/display/src/display_gfx/display_gfx.c diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_buffer_vdi_impl.cpp b/device_soc_phytium/common/hardware/display/src/display_gralloc/display_buffer_vdi_impl.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_buffer_vdi_impl.cpp rename to device_soc_phytium/common/hardware/display/src/display_gralloc/display_buffer_vdi_impl.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_buffer_vdi_impl.h b/device_soc_phytium/common/hardware/display/src/display_gralloc/display_buffer_vdi_impl.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_buffer_vdi_impl.h rename to device_soc_phytium/common/hardware/display/src/display_gralloc/display_buffer_vdi_impl.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_gralloc_gbm.cpp b/device_soc_phytium/common/hardware/display/src/display_gralloc/display_gralloc_gbm.cpp similarity index 89% rename from device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_gralloc_gbm.cpp rename to device_soc_phytium/common/hardware/display/src/display_gralloc/display_gralloc_gbm.cpp index 02ff09b508a07522aeb9954525321893cd250fde..4a78e72ecddc07570c9f2983a821749c61a8c796 100644 --- a/device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_gralloc_gbm.cpp +++ b/device_soc_phytium/common/hardware/display/src/display_gralloc/display_gralloc_gbm.cpp @@ -42,6 +42,7 @@ using namespace OHOS::HDI::Display::Composer::V1_0; using namespace OHOS::HDI::Display::Buffer::V1_0; const char *g_drmFileNode = "/dev/dri/card0"; +const char *g_drmFileNode1 = "/dev/dri/card1"; static GrallocManager *g_grallocManager = nullptr; static pthread_mutex_t g_lock; @@ -425,6 +426,35 @@ int32_t GbmGrallocUninitialize(void) return HDF_SUCCESS; } +static bool isPvrCard(const char *drmFile){ + char *driver; + int fd = open(drmFile, O_RDWR | O_CLOEXEC); + if (fd < 0) { + perror("open"); + DISPLAY_LOGE("failed to open %{public}s: %{public}s", drmFile, strerror(errno)); + return false; + } + drmVersionPtr version = drmGetVersion(fd); + + if (!version) { + DISPLAY_LOGE("failed drmGetVersion for drmFile %{public}s fd %{public}d", drmFile, fd); + close(fd); + return false; + } + + driver = strndup(version->name, version->name_len); + DISPLAY_LOGE("using driver %{public}s for %{public}d", + driver, fd); + + drmFreeVersion(version); + close(fd); + if(strcmp("pvr", driver) == 0){ + DISPLAY_LOGE("drmFile:%{public}s is pvr card", drmFile); + return true; + } + return false; +} + int32_t GbmGrallocInitialize(void) { DISPLAY_LOGD(); @@ -432,7 +462,25 @@ int32_t GbmGrallocInitialize(void) GrallocManager *grallocManager = GetGrallocManager(); DISPLAY_CHK_RETURN((grallocManager == nullptr), HDF_ERR_INVALID_PARAM, DISPLAY_LOGE("gralloc manager failed"); \ GRALLOC_UNLOCK()); - int ret = InitGbmDevice(g_drmFileNode, grallocManager); + /** + * @brief + * 逻辑处理如下: + * 1.首先判断card1是否存在,存在如果不是pvr gpu的节点,则使用card1 + * 2.如果不存在,则使用card0 + */ + int ret = -1; + if (access(g_drmFileNode1, F_OK) != -1) {//card1存在,还要处理D2000上的逻辑 + if(isPvrCard(g_drmFileNode1)){//使用card0 + DISPLAY_LOGI("card1 is pvr gpu, so use card0"); + ret = InitGbmDevice(g_drmFileNode, grallocManager); + }else{//使用card1 + DISPLAY_LOGI("use card1"); + ret = InitGbmDevice(g_drmFileNode1, grallocManager); + } + } else { + ret = InitGbmDevice(g_drmFileNode, grallocManager); + DISPLAY_LOGI("only g_drmFileNode exist, so use g_drmFileNode"); + } DISPLAY_CHK_RETURN((ret != HDF_SUCCESS), ret, DISPLAY_LOGE("gralloc manager failed"); \ GRALLOC_UNLOCK()); grallocManager->referCount++; diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_gralloc_gbm.h b/device_soc_phytium/common/hardware/display/src/display_gralloc/display_gralloc_gbm.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/display_gralloc_gbm.h rename to device_soc_phytium/common/hardware/display/src/display_gralloc/display_gralloc_gbm.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/phytium_gbm.cpp b/device_soc_phytium/common/hardware/display/src/display_gralloc/phytium_gbm.cpp similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/phytium_gbm.cpp rename to device_soc_phytium/common/hardware/display/src/display_gralloc/phytium_gbm.cpp diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/phytium_gbm.h b/device_soc_phytium/common/hardware/display/src/display_gralloc/phytium_gbm.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/phytium_gbm.h rename to device_soc_phytium/common/hardware/display/src/display_gralloc/phytium_gbm.h diff --git a/device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/phytium_gbm_internal.h b/device_soc_phytium/common/hardware/display/src/display_gralloc/phytium_gbm_internal.h similarity index 100% rename from device_soc_phytium/pd2x08/hardware/display/src/display_gralloc/phytium_gbm_internal.h rename to device_soc_phytium/common/hardware/display/src/display_gralloc/phytium_gbm_internal.h diff --git a/device_soc_phytium/common/hal/usb/pd2x08/include/default_config.h b/device_soc_phytium/pd2x08/hal/usb/include/default_config.h similarity index 100% rename from device_soc_phytium/common/hal/usb/pd2x08/include/default_config.h rename to device_soc_phytium/pd2x08/hal/usb/include/default_config.h diff --git a/device_soc_phytium/pd2x08/soc.gni b/device_soc_phytium/pd2x08/soc.gni index 2868ecf75a7ca8e04f232029a920790de7c0d68c..21519119cd380e664316128c21f3882e2a71c3e5 100644 --- a/device_soc_phytium/pd2x08/soc.gni +++ b/device_soc_phytium/pd2x08/soc.gni @@ -11,5 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -usb_default_config_path = "//device/soc/phytium/common/hal/usb/${soc_name}/include" -display_device_hal = "soc/phytium/${soc_name}/hardware" +usb_default_config_path = "//device/soc/phytium/pd2x08/hal/usb/include" +display_device_hal = "//device/soc/phytium/common/hardware" diff --git a/device_soc_phytium/pe2x04/hal/usb/include/default_config.h b/device_soc_phytium/pe2x04/hal/usb/include/default_config.h new file mode 100644 index 0000000000000000000000000000000000000000..1902b55d4de80d3f21f03e994f53a477436dcf00 --- /dev/null +++ b/device_soc_phytium/pe2x04/hal/usb/include/default_config.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + * 2024.11.21 Phytium change. + */ + +#ifndef DEFAULT_CONFIG_H +#define DEFAULT_CONFIG_H +#ifdef __cplusplus +extern "C" { +#endif + +#define PORT_FILE_PATH "/sys/kernel/debug/usb/fcc00000.dwc3/mode" +#define UDC_NAME "fcc00000.dwc3" + +#ifdef __cplusplus +} +#endif +#endif // DEFAULT_CONFIG_H diff --git a/device_soc_phytium/pe2x04/soc.gni b/device_soc_phytium/pe2x04/soc.gni new file mode 100644 index 0000000000000000000000000000000000000000..d1754104c76b9cfde90c5a81a3910eeff1f7de83 --- /dev/null +++ b/device_soc_phytium/pe2x04/soc.gni @@ -0,0 +1,15 @@ +# Copyright (c) 2024 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +usb_default_config_path = "//device/soc/phytium/pe2x04/hal/usb/include" +display_device_hal = "//device/soc/phytium/common/hardware" diff --git a/phytium_env.sh b/phytium_env.sh index 082f45fdd1728a15400f25406a51c2cc20875390..392d6721cf85c4204f2c2cb63ee343055f2e9e17 100755 --- a/phytium_env.sh +++ b/phytium_env.sh @@ -58,7 +58,7 @@ fi echo -e "\033[32mTHE OHOS_PATH_ROOT: $OHOS_PATH_ROOT \033[0m" echo -e "\033[32mTHE DEVICE: $DEVICE($DEVICE_ID) \033[0m" -echo -e "\033[32m #### sync phytium env start! #### \033[0m" +echo -e "\033[32m #### sync phytium env start! #### \033[0m" CURRENTPWD=$(pwd) @@ -138,15 +138,6 @@ function apply_git_patch(){ } PATCH_PATH=$CURRENTPWD/device_board_phytium/common/patch -if [ $DEVICE == tengrui_d ]; then - PATCH_PATH=$CURRENTPWD/device_board_phytium/tengrui_d/patch -fi - -#PATCH_PATH=$OHOS_PATH_ROOT/device/board/phytium/common/patch -#if [ ! -d $PATCH_PATH ];then -# echo -e "\033[31mMake sure you have copied phytium device code to OHOS_PATH_ROOT! \033[0m" -# exit 1; -#fi echo -e "" echo -e "######################################################################" @@ -169,4 +160,4 @@ cd $CURRENTPWD echo -e "\033[32m #### apply patch end ####\n \033[0m" -echo -e "\033[32m #### sync phytium end! #### \033[0m" +echo -e "\033[32m #### sync phytium end! #### \033[0m" diff --git a/vendor_phytium/README.md b/vendor_phytium/README.md old mode 100644 new mode 100755 index e7caf0523a043f4e86dc07e3f6eb10a04df9461d..4b5bcb2d4826c5f640866a7a57a05794090f2264 --- a/vendor_phytium/README.md +++ b/vendor_phytium/README.md @@ -19,9 +19,21 @@ vendor/phytium │   ├── product.gni │   ├── resourceschedule │   └── window_config +├── tenglong_e +│   ├── bluetooth +│   ├── bundle.json +│   ├── config.json +│   ├── etc +│   ├── hals +│   ├── hdf_config +│   ├── preinstall-config +│   ├── product.gni +│   ├── resourceschedule +│   └── window_config ├── gpu_model # 显卡相关驱动 │   ├── amd # AMD显卡驱动 │   ├── jm # JM9100显卡驱动 +│   ├── sw # cpu模拟显卡硬件加速驱动 │   └── x100 # X100套片驱动 ├── LICENSE └── README.md diff --git a/vendor_phytium/gpu_model/README.md b/vendor_phytium/gpu_model/README.md old mode 100644 new mode 100755 index b10198c249b498e5ed85c1641d2d0963067c9695..a65f443e9bc2f8fe88ff67603a3641293a9fb6c3 --- a/vendor_phytium/gpu_model/README.md +++ b/vendor_phytium/gpu_model/README.md @@ -2,7 +2,7 @@ ## 介绍 -显卡相关驱动,目前支持AMD显卡、JM9100、X100套片。 +显卡相关驱动,目前支持AMD显卡、JM9100、X100套片、cpu模拟mesa3D驱动。 ## 目录 @@ -24,6 +24,10 @@ vendor/phytium/gpu_model │   ├── gpu │   ├── kernel_source │   └── readme.txt +├── sw +| ├── BUILD.gn +│   ├── gpu +│   └── readme.txt └── README.md ``` diff --git a/vendor_phytium/gpu_model/amd/gpu/BUILD.gn b/vendor_phytium/gpu_model/amd/gpu/BUILD.gn old mode 100644 new mode 100755 index b77e985bb2b623ef97abd30c0495b63d47537961..5c52b16c61ba10c7bcbd04838e036de562474fe7 --- a/vendor_phytium/gpu_model/amd/gpu/BUILD.gn +++ b/vendor_phytium/gpu_model/amd/gpu/BUILD.gn @@ -85,4 +85,4 @@ if (enable_ramdisk) { group("mesa-pvr-gpu-libs"){ deps = mesa3d_all_lib_deps -} +} \ No newline at end of file diff --git a/vendor_phytium/gpu_model/jm/gpu/mesa3d_jm9100/libomx_mesa.so b/vendor_phytium/gpu_model/jm/gpu/mesa3d_jm9100/libomx_mesa.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/jm/gpu/mesa3d_jm9100/mwv207_dri.so b/vendor_phytium/gpu_model/jm/gpu/mesa3d_jm9100/mwv207_dri.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/sw/BUILD.gn b/vendor_phytium/gpu_model/sw/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d12a4a3febf5dbf07a2941d2405a8119e33a420c --- /dev/null +++ b/vendor_phytium/gpu_model/sw/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright (c) 2024 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +import("//build/ohos.gni") + +group("gpu_group") { + deps = [ + "//vendor/phytium/gpu_model/${gpu_model}/gpu:mesa-pvr-gpu-libs", + ] +} \ No newline at end of file diff --git a/vendor_phytium/gpu_model/sw/gpu/BUILD.gn b/vendor_phytium/gpu_model/sw/gpu/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4eace0ede7e1561248b62cfc42531dc971b881bd --- /dev/null +++ b/vendor_phytium/gpu_model/sw/gpu/BUILD.gn @@ -0,0 +1,48 @@ +# Copyright (c) 2024 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +partname="device_${product_name}" +mesa3d_libs_dir = "mesa3d_swrast" + +mesa3d_all_lib_items = [ + ["libEGL.so.1.0.0", ["libEGL.so.1","libEGL_impl.so"]], + ["libgbm.so.1.0.0", ["libgbm.so", "libgbm.so.1"]], + ["libglapi.so.0.0.0", ["libglapi.so", "libglapi.so.0"]], + ["libGLESv1_CM.so.1.1.0", ["libGLESv1_CM.so", "libGLESv1_CM.so.1","libGLESv1_impl.so"]], + ["libGLESv2.so.2.0.0", ["libGLESv2.so.2","libGLESv2_impl.so","libGLESv3_impl.so"]], + ["kms_swrast_dri.so", ["kms_swrast_dri.so"]] +] + +mesa3d_all_lib_deps = [] +foreach(item, mesa3d_all_lib_items) { + name = item[0] + ohos_prebuilt_shared_library(name) { + source = "$mesa3d_libs_dir/$name" + symlink_target_name = item[1] + install_enable = true + install_images = [ chipset_base_dir ] + relative_install_dir = "chipsetsdk" + subsystem_name = "phytium_products" + part_name = "${partname}" + } + mesa3d_all_lib_deps += [ ":$name" ] +} + +group("mesa-pvr-gpu-libs"){ + deps = + mesa3d_all_lib_deps +} + diff --git a/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/kms_swrast_dri.so b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/kms_swrast_dri.so new file mode 100755 index 0000000000000000000000000000000000000000..ccd0a26bc4efaf4a1d4bf28380954710baf1ef84 Binary files /dev/null and b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/kms_swrast_dri.so differ diff --git a/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libEGL.so.1.0.0 b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libEGL.so.1.0.0 new file mode 100755 index 0000000000000000000000000000000000000000..139b3495374b45526dac0c1e5ac0023c239c859a Binary files /dev/null and b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libEGL.so.1.0.0 differ diff --git a/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libGLESv1_CM.so.1.1.0 b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libGLESv1_CM.so.1.1.0 new file mode 100755 index 0000000000000000000000000000000000000000..320197833507485890c5a2233c51683121185993 Binary files /dev/null and b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libGLESv1_CM.so.1.1.0 differ diff --git a/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libGLESv2.so.2.0.0 b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libGLESv2.so.2.0.0 new file mode 100755 index 0000000000000000000000000000000000000000..175de8bf3b3fb1e9962a41cc99c3cdcf6afb0111 Binary files /dev/null and b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libGLESv2.so.2.0.0 differ diff --git a/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libgbm.so.1.0.0 b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libgbm.so.1.0.0 new file mode 100755 index 0000000000000000000000000000000000000000..1706561f95f32b2ad0604f96f06c1cd29aab05fa Binary files /dev/null and b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libgbm.so.1.0.0 differ diff --git a/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libglapi.so.0.0.0 b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libglapi.so.0.0.0 new file mode 100755 index 0000000000000000000000000000000000000000..20bf3dc7bce340d66af1bd052d0ae71e4eb07727 Binary files /dev/null and b/vendor_phytium/gpu_model/sw/gpu/mesa3d_swrast/libglapi.so.0.0.0 differ diff --git a/vendor_phytium/gpu_model/sw/readme.txt b/vendor_phytium/gpu_model/sw/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..a72340450b0082eb82c7df3eebf17260d66c1350 --- /dev/null +++ b/vendor_phytium/gpu_model/sw/readme.txt @@ -0,0 +1,8 @@ +GPU Vendor: kms_swrast +Support GPU Model:tengrui_d cpu +um version:[ + mesa_3d OpenHarmony-v5.0.0-Release +] +note:[ + grub或uboot启动参数加入cma=1024M phytium-dc-drm.x100_dc_sysmem配置 +] \ No newline at end of file diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libGLESv1_CM_PVR_MESA.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libGLESv1_CM_PVR_MESA.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libGLESv1_CM_PVR_MESA.so.1.15.6052913 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libGLESv1_CM_PVR_MESA.so.1.15.6052913 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libGLESv2_PVR_MESA.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libGLESv2_PVR_MESA.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libGLESv2_PVR_MESA.so.1.15.6052913 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libGLESv2_PVR_MESA.so.1.15.6052913 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libsrv_um.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libsrv_um.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libsrv_um.so.1.15.6052913 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libsrv_um.so.1.15.6052913 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libstdc++.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libstdc++.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libstdc++.so.6 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libstdc++.so.6 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libstdc++.so.6.0.29 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libstdc++.so.6.0.29 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libusc.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libusc.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libusc.so.1.15.6052913 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/libusc.so.1.15.6052913 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/pvr_dri.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_4.19/pvr_dri.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv1_CM_PVR_MESA.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv1_CM_PVR_MESA.so deleted file mode 120000 index 75298782ca46e5c44ed16531fc38fbbe84817606..0000000000000000000000000000000000000000 --- a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv1_CM_PVR_MESA.so +++ /dev/null @@ -1 +0,0 @@ -libGLESv1_CM_PVR_MESA.so.1.16.6099580 \ No newline at end of file diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv1_CM_PVR_MESA.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv1_CM_PVR_MESA.so new file mode 100755 index 0000000000000000000000000000000000000000..f63b281f0db845c23dcac6598dfd1e09aa79bc5b Binary files /dev/null and b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv1_CM_PVR_MESA.so differ diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv1_CM_PVR_MESA.so.1.16.6099580 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv1_CM_PVR_MESA.so.1.16.6099580 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so deleted file mode 120000 index a3d5de7f9a174de1805eee5a3353381025d17ec3..0000000000000000000000000000000000000000 --- a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so +++ /dev/null @@ -1 +0,0 @@ -libGLESv2_PVR_MESA.so.1.16.6099580 \ No newline at end of file diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so new file mode 100755 index 0000000000000000000000000000000000000000..1d59b4fa39e910749e98b64bbeb686e052e9beef Binary files /dev/null and b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so differ diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so.1.16.6099580 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so.1.16.6099580 old mode 100644 new mode 100755 index b87316b83a57db81c6b4c395064b7a4949801561..1d59b4fa39e910749e98b64bbeb686e052e9beef Binary files a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so.1.16.6099580 and b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libGLESv2_PVR_MESA.so.1.16.6099580 differ diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libsrv_um.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libsrv_um.so deleted file mode 120000 index 1cba1042671bacd0eb76749b914aa6b813568755..0000000000000000000000000000000000000000 --- a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libsrv_um.so +++ /dev/null @@ -1 +0,0 @@ -libsrv_um.so.1.16.6099580 \ No newline at end of file diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libsrv_um.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libsrv_um.so new file mode 100755 index 0000000000000000000000000000000000000000..5a4940738816d2b35862bed48f1ae20628118f20 Binary files /dev/null and b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libsrv_um.so differ diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libsrv_um.so.1.16.6099580 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libsrv_um.so.1.16.6099580 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libstdc++.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libstdc++.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libstdc++.so.6 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libstdc++.so.6 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libstdc++.so.6.0.29 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libstdc++.so.6.0.29 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libusc.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libusc.so deleted file mode 120000 index 8226d0c5bf275480ff4ca6dffb2d7e93ff6e0ef9..0000000000000000000000000000000000000000 --- a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libusc.so +++ /dev/null @@ -1 +0,0 @@ -libusc.so.1.16.6099580 \ No newline at end of file diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libusc.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libusc.so new file mode 100755 index 0000000000000000000000000000000000000000..7b926f7c34d7dd8751b910b030eabfe715895267 Binary files /dev/null and b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libusc.so differ diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libusc.so.1.16.6099580 b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/libusc.so.1.16.6099580 old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/pvr_dri.so b/vendor_phytium/gpu_model/x100/gpu/mesa3d_kernel_5.10/pvr_dri.so old mode 100644 new mode 100755 diff --git a/vendor_phytium/gpu_model/x100/gpu/phytiumvr.ini b/vendor_phytium/gpu_model/x100/gpu/phytiumvr.ini old mode 100644 new mode 100755 diff --git a/vendor_phytium/tenglong_e/bluetooth/BCM4362A2.hcd b/vendor_phytium/tenglong_e/bluetooth/BCM4362A2.hcd new file mode 100755 index 0000000000000000000000000000000000000000..95c69b42ac17d0791aa8ad73d416c5d75e537346 Binary files /dev/null and b/vendor_phytium/tenglong_e/bluetooth/BCM4362A2.hcd differ diff --git a/vendor_phytium/tenglong_e/bluetooth/BUILD.gn b/vendor_phytium/tenglong_e/bluetooth/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..ffde97b8bb5c0b6437a7af385f6f3dfa7d6544d7 --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/BUILD.gn @@ -0,0 +1,70 @@ +# + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +config("bt_warnings") { + cflags = [ + "-Wall", + "-Werror", + "-Wno-switch", + "-Wno-unused-function", + "-Wno-unused-parameter", + "-Wno-unused-variable", + "-Wno-implicit-function-declaration", + "-Wno-incompatible-pointer-types", + ] +} + +ohos_prebuilt_etc("BCM4362A2.hcd") { + source = "//vendor/${product_company}/${product_name}/bluetooth/BCM4362A2.hcd" + install_images = [ vendor_base_dir ] + relative_install_dir = "firmware" + part_name = "phytium_products" + install_enable = true +} + +ohos_shared_library("libbt_vendor") { + output_name = "libbt_vendor" + sources = [ + "src/bt_vendor_brcm.c", + "src/conf.c", + "src/hardware.c", + "src/upio.c", + "src/userial_vendor.c", + ] + + include_dirs = [ + "include", + "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", + "//foundation/communication/bluetooth/services/bluetooth/hardware/include", + ] + + cflags = [ + "-DUSE_CONTROLLER_BDADDR=TRUE", + "-DFW_AUTO_DETECTION=TRUE", + "-DBT_WAKE_VIA_PROC=FALSE", + "-DSCO_PCM_ROUTING=0", + "-DSCO_PCM_IF_CLOCK_RATE=1", + "-DSCO_PCM_IF_FRAME_TYPE=0", + "-DSCO_PCM_IF_SYNC_MODE=0", + "-DSCO_PCM_IF_CLOCK_MODE=0", + "-DPCM_DATA_FMT_SHIFT_MODE=0", + "-DPCM_DATA_FMT_FILL_BITS=0x03", + "-DPCM_DATA_FMT_FILL_METHOD=0", + "-DPCM_DATA_FMT_FILL_NUM=0", + "-DPCM_DATA_FMT_JUSTIFY_MODE=0", + ] + + configs = [ ":bt_warnings" ] + + deps = [ "//utils/native/base:utils" ] + + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + + install_enable = true + install_images = [ "system" ] + + part_name = "phytium_products" + subsystem_name = "phytium_products" +} diff --git a/vendor_phytium/tenglong_e/bluetooth/include/bt_hci_bdroid.h b/vendor_phytium/tenglong_e/bluetooth/include/bt_hci_bdroid.h new file mode 100755 index 0000000000000000000000000000000000000000..de44eb28f43726b662e4f25783484a6b5628640d --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/include/bt_hci_bdroid.h @@ -0,0 +1,75 @@ +/****************************************************************************** + * + * Copyright 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: bt_hci_bdroid.h + * + * Description: A wrapper header file of bt_hci_lib.h + * + * Contains definitions specific for interfacing with Bluedroid + * Bluetooth stack + * + ******************************************************************************/ + +#ifndef BT_VENDOR_HCI_BDROID_H +#define BT_VENDOR_HCI_BDROID_H + +#ifdef HAS_BDROID_BUILDCFG +#include "bdroid_buildcfg.h" +#endif + +/****************************************************************************** + * Constants & Macros + *****************************************************************************/ +#define HCI_ACL_MAX_SIZE 1024 +#define HCI_MAX_FRAME_SIZE (HCI_ACL_MAX_SIZE + 4) + +/* Host/Controller lib internal event ID */ +typedef enum { + HC_EVENT_LPM_IDLE_TIMEOUT, +} bthc_event_t; + +/* Message event mask across Host/Controller lib and stack */ +#define MSG_EVT_MASK 0xFF00 /* eq. BT_EVT_MASK */ +#define MSG_SUB_EVT_MASK 0x00FF /* eq. BT_SUB_EVT_MASK */ + +/* Message event ID passed from Host/Controller lib to stack */ +#define MSG_HC_TO_STACK_HCI_ERR 0x1300 /* eq. BT_EVT_TO_BTU_HCIT_ERR */ +#define MSG_HC_TO_STACK_HCI_ACL 0x1100 /* eq. BT_EVT_TO_BTU_HCI_ACL */ +#define MSG_HC_TO_STACK_HCI_SCO 0x1200 /* eq. BT_EVT_TO_BTU_HCI_SCO */ +#define MSG_HC_TO_STACK_HCI_EVT 0x1000 /* eq. BT_EVT_TO_BTU_HCI_EVT */ +#define MSG_HC_TO_STACK_L2C_SEG_XMIT 0x1900 /* BT_EVT_TO_BTU_L2C_SEG_XMIT */ + +/* Message event ID passed from stack to vendor lib */ +#define MSG_STACK_TO_HC_HCI_ACL 0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */ +#define MSG_STACK_TO_HC_HCI_SCO 0x2200 /* eq. BT_EVT_TO_LM_HCI_SCO */ +#define MSG_STACK_TO_HC_HCI_CMD 0x2000 /* eq. BT_EVT_TO_LM_HCI_CMD */ + +/* Local Bluetooth Controller ID for BR/EDR */ +#define LOCAL_BR_EDR_CONTROLLER_ID 0 + +#define BT_HC_HDR_SIZE (sizeof(HC_BT_HDR)) +/****************************************************************************** + * Extern variables and functions + *****************************************************************************/ + +/****************************************************************************** + * Functions + *****************************************************************************/ +#endif \ No newline at end of file diff --git a/vendor_phytium/tenglong_e/bluetooth/include/bt_vendor_brcm.h b/vendor_phytium/tenglong_e/bluetooth/include/bt_vendor_brcm.h new file mode 100755 index 0000000000000000000000000000000000000000..ba35c07d25dae4681c001fdf0cc71516840c25bc --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/include/bt_vendor_brcm.h @@ -0,0 +1,453 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: bt_vendor_brcm.h + * + * Description: A wrapper header file of bt_vendor_lib.h + * + * Contains definitions specific for interfacing with Broadcom + * Bluetooth chipsets + * + ******************************************************************************/ + +#ifndef BT_VENDOR_BRCM_H +#define BT_VENDOR_BRCM_H + +#include "bt_vendor_lib.h" + +/****************************************************************************** +** Constants & Macros +******************************************************************************/ + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE (!FALSE) +#endif + +#ifndef VENDOR_LIB_RUNTIME_TUNING_ENABLED +#define VENDOR_LIB_RUNTIME_TUNING_ENABLED FALSE +#endif + +/* Run-time configuration file */ +#ifndef VENDOR_LIB_CONF_FILE +#define VENDOR_LIB_CONF_FILE "/vendor/etc/bluetooth/bt_vendor.conf" +#endif + +/* Device port name where Bluetooth controller attached */ +#ifndef BLUETOOTH_UART_DEVICE_PORT +#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyS8" /* maguro */ +#endif + +/* Location of firmware patch files */ +#ifndef FW_PATCHFILE_LOCATION +#define FW_PATCHFILE_LOCATION "/vendor/etc/firmware/" /* maguro */ +#endif + +#ifndef UART_TARGET_BAUD_RATE +#define UART_TARGET_BAUD_RATE 3000000 +#endif + +/* The millisecond delay pauses on HCI transport after firmware patches + * were downloaded. This gives some time for firmware to restart with + * patches before host attempts to send down any HCI commands. + * + * Note: It has been discovered that BCM43241B0 needs at least 200ms + * settlement delay in here. Without the delay, a Hardware Error event + * from BCM43241B0 had been seen in HCI upstream path right after the + * host sent the HCI_VSC_SET_BDADDR commad to the controller at higher + * baud. + */ +#ifndef FW_PATCH_SETTLEMENT_DELAY_MS +#define FW_PATCH_SETTLEMENT_DELAY_MS 0 +#endif + +#ifndef USERIAL_VENDOR_SET_BAUD_DELAY_US +#define USERIAL_VENDOR_SET_BAUD_DELAY_US 0 +#endif + +#ifndef FW_AUTO_DETECTION +#define FW_AUTO_DETECTION FALSE +#endif + +/* The Bluetooth Device Address source switch: + * + * -FALSE- (default value) + * Get the factory BDADDR from device's file system. Normally the BDADDR is + * stored in the location pointed by the PROPERTY_BT_BDADDR_PATH (defined in + * btif_common.h file) property. + * + * -TRUE- + * If the Bluetooth Controller has equipped with a non-volatile memory (such + * as BCM4330's OTP memory), the factory BDADDR can be stored in there and + * retrieved by the stack while enabling BT. + * !!! WARNING !!! Make sure that the OTP feature has been enabled in the + * firmware patchram (.hcd) file. + */ +#ifndef USE_CONTROLLER_BDADDR +#define USE_CONTROLLER_BDADDR FALSE +#endif + +/* sleep mode + + 0: disable + 1: UART with Host wake/BT wake out of band signals +*/ +#ifndef LPM_SLEEP_MODE +#define LPM_SLEEP_MODE 0 +#endif + +/* Host Stack Idle Threshold in 300ms or 25ms + In sleep mode 1, this is the number of firmware loops executed with no + action before the Host wake line is deasserted. action includes HCI + traffic excluding certain sleep mode commands and the presence of SCO + connections if the "Allow Host Sleep During SCO" flag is not set to 1. + Each count of this parameter is roughly equivalent to 300ms or 25ms. +*/ +#ifndef LPM_IDLE_THRESHOLD +#define LPM_IDLE_THRESHOLD 1 +#endif + +/* Host Controller Idle Threshold in 300ms or 25ms + + This is the number of firmware loops executed with no action before the + HC is considered idle. Depending on the mode, HC may then attempt to sleep. + Action includes HCI traffic excluding certain sleep mode commands and + the presence of ACL/SCO connections. +*/ +#ifndef LPM_HC_IDLE_THRESHOLD +#define LPM_HC_IDLE_THRESHOLD 1 +#endif + +/* BT_WAKE Polarity - 0=Active Low, 1= Active High */ +#ifndef LPM_BT_WAKE_POLARITY +#define LPM_BT_WAKE_POLARITY 1 /* maguro */ +#endif + +/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */ +#ifndef LPM_HOST_WAKE_POLARITY +#define LPM_HOST_WAKE_POLARITY 1 /* maguro */ +#endif + +/* LPM_ALLOW_HOST_SLEEP_DURING_SCO + + When this flag is set to 0, the host is not allowed to sleep while + an SCO is active. In sleep mode 1, the device will keep the host + wake line asserted while an SCO is active. + When this flag is set to 1, the host can sleep while an SCO is active. + This flag should only be set to 1 if SCO traffic is directed to the PCM + interface. +*/ +#ifndef LPM_ALLOW_HOST_SLEEP_DURING_SCO +#define LPM_ALLOW_HOST_SLEEP_DURING_SCO 1 +#endif + +/* LPM_COMBINE_SLEEP_MODE_AND_LPM + + In Mode 0, always set byte 7 to 0. In sleep mode 1, device always + requires permission to sleep between scans / periodic inquiries regardless + of the setting of this byte. In sleep mode 1, if byte is set, device must + have "permission" to sleep during the low power modes of sniff, hold, and + park. If byte is not set, device can sleep without permission during these + modes. Permission to sleep in Mode 1 is obtained if the BT_WAKE signal is + not asserted. +*/ +#ifndef LPM_COMBINE_SLEEP_MODE_AND_LPM +#define LPM_COMBINE_SLEEP_MODE_AND_LPM 1 +#endif + +/* LPM_ENABLE_UART_TXD_TRI_STATE + + When set to 0, the device will not tristate its UART TX line before going + to sleep. + When set to 1, the device will tristate its UART TX line before going to + sleep. +*/ +#ifndef LPM_ENABLE_UART_TXD_TRI_STATE +#define LPM_ENABLE_UART_TXD_TRI_STATE 0 +#endif + +/* LPM_PULSED_HOST_WAKE +*/ +#ifndef LPM_PULSED_HOST_WAKE +#define LPM_PULSED_HOST_WAKE 0 +#endif + +/* LPM_IDLE_TIMEOUT_MULTIPLE + + The multiple factor of host stack idle threshold in 300ms/25ms +*/ +#ifndef LPM_IDLE_TIMEOUT_MULTIPLE +#define LPM_IDLE_TIMEOUT_MULTIPLE 10 +#endif + +/* BT_WAKE_VIA_USERIAL_IOCTL + + Use userial ioctl function to control BT_WAKE signal +*/ +#ifndef BT_WAKE_VIA_USERIAL_IOCTL +#define BT_WAKE_VIA_USERIAL_IOCTL FALSE +#endif + +/* BT_WAKE_USERIAL_LDISC + + Use line discipline if the BT_WAKE control is in line discipline +*/ +#ifndef BT_WAKE_USERIAL_LDISC +#define BT_WAKE_USERIAL_LDISC FALSE +#endif + +/* BT_WAKE_VIA_PROC + + LPM & BT_WAKE control through PROC nodes +*/ +#ifndef BT_WAKE_VIA_PROC +#define BT_WAKE_VIA_PROC FALSE +#endif + +#ifndef BT_WAKE_VIA_PROC_NOTIFY_DEASSERT +#define BT_WAKE_VIA_PROC_NOTIFY_DEASSERT FALSE +#endif + +/* N_BRCM_HCI + + UART ioctl line discipline +*/ +#ifndef N_BRCM_HCI +#define N_BRCM_HCI 25 +#endif + +/* SCO_CFG_INCLUDED + + Do SCO configuration by default. If the firmware patch had been embedded + with desired SCO configuration, set this FALSE to bypass configuration + from host software. +*/ +#ifndef SCO_CFG_INCLUDED +#define SCO_CFG_INCLUDED TRUE +#endif + +#ifndef SCO_USE_I2S_INTERFACE +#define SCO_USE_I2S_INTERFACE FALSE +#endif + +#define SCO_I2SPCM_PARAM_IF_MODE 0 +#define SCO_I2SPCM_PARAM_IF_ROLE 1 +#define SCO_I2SPCM_PARAM_IF_SAMPLE_RATE 2 +#define SCO_I2SPCM_PARAM_IF_CLOCK_RATE 3 +#define SCO_I2SPCM_PARAM_SIZE 4 + +/* SCO_WBS_SAMPLE_RATE + 0 : 8K + 1 : 16K + 2 : 4K + This macro is used for setting WBS sampling rate for a SCO connection + If the mobile network supports WBS, we need to use 16KHz as default + but if the platform doesn't support 16KHz, the sample rate can be + overriden to 8KHz by setting this to 0. +*/ +#ifndef SCO_WBS_SAMPLE_RATE +#define SCO_WBS_SAMPLE_RATE 1 +#endif + +/* SCO_I2SPCM_IF_MODE - 0=Disable, 1=Enable */ +#ifndef SCO_I2SPCM_IF_MODE +#define SCO_I2SPCM_IF_MODE 1 +#endif + +/* SCO_I2SPCM_IF_ROLE - 0=Slave, 1=Master */ +#ifndef SCO_I2SPCM_IF_ROLE +#define SCO_I2SPCM_IF_ROLE 1 +#endif + +/* SCO_I2SPCM_IF_SAMPLE_RATE + + 0 : 8K + 1 : 16K + 2 : 4K +*/ +#ifndef SCO_I2SPCM_IF_SAMPLE_RATE +#define SCO_I2SPCM_IF_SAMPLE_RATE 0 +#endif + +/* SCO_I2SPCM_IF_CLOCK_RATE + + 0 : 128K + 1 : 256K + 2 : 512K + 3 : 1024K + 4 : 2048K +*/ +#ifndef SCO_I2SPCM_IF_CLOCK_RATE +#define SCO_I2SPCM_IF_CLOCK_RATE 1 +#endif + +/* SCO_I2SPCM_IF_CLOCK_RATE4WBS + + 0 : 128K + 1 : 256K + 2 : 512K + 3 : 1024K + 4 : 2048K +*/ +#ifndef SCO_I2SPCM_IF_CLOCK_RATE4WBS +#define SCO_I2SPCM_IF_CLOCK_RATE4WBS 2 +#endif + +#define SCO_PCM_PARAM_ROUTING 0 +#define SCO_PCM_PARAM_IF_CLOCK_RATE 1 +#define SCO_PCM_PARAM_IF_FRAME_TYPE 2 +#define SCO_PCM_PARAM_IF_SYNC_MODE 3 +#define SCO_PCM_PARAM_IF_CLOCK_MODE 4 +#define SCO_PCM_PARAM_SIZE 5 + +/* SCO_PCM_ROUTING + + 0 : PCM + 1 : Transport + 2 : Codec + 3 : I2S +*/ +#ifndef SCO_PCM_ROUTING +#define SCO_PCM_ROUTING 0 +#endif + +/* SCO_PCM_IF_CLOCK_RATE + + NOTICE: suggested to be consistent with SCO_I2SPCM_IF_CLOCK_RATE + + 0 : 128K + 1 : 256K + 2 : 512K + 3 : 1024K + 4 : 2048K +*/ +#ifndef SCO_PCM_IF_CLOCK_RATE +#define SCO_PCM_IF_CLOCK_RATE 4 +#endif + +/* SCO_PCM_IF_FRAME_TYPE - 0=Short, 1=Long */ +#ifndef SCO_PCM_IF_FRAME_TYPE +#define SCO_PCM_IF_FRAME_TYPE 0 +#endif + +/* SCO_PCM_IF_SYNC_MODE + + NOTICE: in most usage cases the value will be the same as + SCO_PCM_IF_CLOCK_MODE setting + + 0 : Slave + 1 : Master +*/ +#ifndef SCO_PCM_IF_SYNC_MODE +#define SCO_PCM_IF_SYNC_MODE 0 +#endif + +/* SCO_PCM_IF_CLOCK_MODE + + NOTICE: suggested to be consistent with SCO_I2SPCM_IF_ROLE + + 0 : Slave + 1 : Master +*/ +#ifndef SCO_PCM_IF_CLOCK_MODE +#define SCO_PCM_IF_CLOCK_MODE 0 +#endif + +#define PCM_DATA_FORMAT_PARAM_SIZE 5 + +/* PCM_DATA_FMT_SHIFT_MODE + + 0 : MSB first + 1 : LSB first +*/ +#ifndef PCM_DATA_FMT_SHIFT_MODE +#define PCM_DATA_FMT_SHIFT_MODE 0 +#endif + +/* PCM_DATA_FMT_FILL_BITS + + Specifies the value with which to fill unused bits + if Fill_Method is set to programmable +*/ +#ifndef PCM_DATA_FMT_FILL_BITS +#define PCM_DATA_FMT_FILL_BITS 0 +#endif + +/* PCM_DATA_FMT_FILL_METHOD + + 0 : 0's + 1 : 1's + 2 : Signed + 3 : Programmable +*/ +#ifndef PCM_DATA_FMT_FILL_METHOD +#define PCM_DATA_FMT_FILL_METHOD 3 +#endif + +/* PCM_DATA_FMT_FILL_NUM + + Specifies the number of bits to be filled +*/ +#ifndef PCM_DATA_FMT_FILL_NUM +#define PCM_DATA_FMT_FILL_NUM 0 +#endif + +/* PCM_DATA_FMT_JUSTIFY_MODE + + 0 : Left justify (fill data shifted out last) + 1 : Right justify (fill data shifted out first) +*/ +#ifndef PCM_DATA_FMT_JUSTIFY_MODE +#define PCM_DATA_FMT_JUSTIFY_MODE 0 +#endif + +/* HW_END_WITH_HCI_RESET + + Sample code implementation of sending a HCI_RESET command during the epilog + process. It calls back to the callers after command complete of HCI_RESET + is received. +*/ +#ifndef HW_END_WITH_HCI_RESET +#define HW_END_WITH_HCI_RESET TRUE +#endif + +#define BD_ADDR_LEN 6 +#define BT_VENDOR_TIME_RAIDX 1000 +/****************************************************************************** +** Extern variables and functions +******************************************************************************/ + +extern bt_vendor_callbacks_t *bt_vendor_cbacks; +/** audio (SCO) state changes triggering VS commands for configuration */ +typedef struct { + uint16_t handle; + uint16_t peer_codec; + uint16_t state; +} bt_vendor_op_audio_state_t; + +extern int hw_set_audio_state(bt_vendor_op_audio_state_t *p_state); +extern uint8_t vnd_local_bd_addr[BD_ADDR_LEN]; + +extern void hw_process_event(HC_BT_HDR *); + +#endif /* BT_VENDOR_BRCM_H */ diff --git a/vendor_phytium/tenglong_e/bluetooth/include/esco_parameters.h b/vendor_phytium/tenglong_e/bluetooth/include/esco_parameters.h new file mode 100755 index 0000000000000000000000000000000000000000..3796bb91b181d829b44789d720300030da921492 --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/include/esco_parameters.h @@ -0,0 +1,122 @@ +/****************************************************************************** + * + * Copyright 2015 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ +#ifndef BT_VENDOR_ESCO_PARAMETER_H +#define BT_VENDOR_ESCO_PARAMETER_H + +#include +/******************* + * SCO Codec Types + *******************/ +typedef enum { + SCO_CODEC_NONE = 0x0000, + SCO_CODEC_CVSD = 0x0001, + SCO_CODEC_MSBC = 0x0002, +} sco_codec_t; + +typedef enum { + ESCO_CODEC_CVSD = 0, + ESCO_CODEC_MSBC_T1, + ESCO_CODEC_MSBC_T2, +} esco_codec_t; + +#define ESCO_NUM_CODECS 3 + +// Coding Formats (BT 4.1 or later Assigned numbers) +#define ESCO_CODING_FORMAT_ULAW ((uint8_t)0x00) /* u-Law log */ +#define ESCO_CODING_FORMAT_ALAW ((uint8_t)0x01) /* A-Law log */ +#define ESCO_CODING_FORMAT_CVSD ((uint8_t)0x02) /* CVSD */ +#define ESCO_CODING_FORMAT_TRANSPNT ((uint8_t)0x03) /* Transparent */ +#define ESCO_CODING_FORMAT_LINEAR ((uint8_t)0x04) /* Linear PCM */ +#define ESCO_CODING_FORMAT_MSBC ((uint8_t)0x05) /* MSBC PCM */ +#define ESCO_CODING_FORMAT_VS ((uint8_t)0xFF) /* Specifies VSC used */ + +// PCM Data Formats (BT 4.1 or later Assigned numbers) +#define ESCO_PCM_DATA_FORMAT_NA ((uint8_t)0x00) /* N/A to coding format in use */ +#define ESCO_PCM_DATA_FORMAT_1_COMP ((uint8_t)0x01) /* 1's complement */ +#define ESCO_PCM_DATA_FORMAT_2_COMP ((uint8_t)0x02) /* 2's complement */ +#define ESCO_PCM_DATA_FORMAT_SIGN ((uint8_t)0x03) /* Sign-magnitude */ +#define ESCO_PCM_DATA_FORMAT_UNSIGN ((uint8_t)0x04) /* Unsigned */ + +// SCO Data Path +#define ESCO_DATA_PATH_PCM 1 /* 0x01-0xFE (PCM Chan) */ +#define ESCO_DATA_PATH_HCI ((uint8_t)0x00) /* HCI-0, 0x01-0xFE (PCM Chan) */ +#define ESCO_DATA_PATH_TEST ((uint8_t)0xFF) /* 0xFF-Audio Test */ + +// eSCO constants +#define TXRX_64KBITS_RATE 0x00001f40 /* 64 kbits/sec data rate */ +#define TXRX_128KBITS_RATE 0x00003E80 /* 128 kbits/sec data rate */ + +#define INPUT_OUTPUT_64K_RATE 0x00003E80 /* 16000 Bytes/sec over transport */ +#define INPUT_OUTPUT_128K_RATE 0x00007D00 /* 32000 Bytes/sec over transport */ + +// Retransmission effort +#define ESCO_RETRANSMISSION_OFF 0 +#define ESCO_RETRANSMISSION_POWER 1 +#define ESCO_RETRANSMISSION_QUALITY 2 +#define ESCO_RETRANSMISSION_DONTCARE 0xff + +// Definitions for eSCO packet type masks (BT1.2 and BT2.0 definitions) +#define ESCO_PKT_TYPES_MASK_HV1 0x0001 +#define ESCO_PKT_TYPES_MASK_HV2 0x0002 +#define ESCO_PKT_TYPES_MASK_HV3 0x0004 +#define ESCO_PKT_TYPES_MASK_EV3 0x0008 +#define ESCO_PKT_TYPES_MASK_EV4 0x0010 +#define ESCO_PKT_TYPES_MASK_EV5 0x0020 +#define ESCO_PKT_TYPES_MASK_NO_2_EV3 0x0040 +#define ESCO_PKT_TYPES_MASK_NO_3_EV3 0x0080 +#define ESCO_PKT_TYPES_MASK_NO_2_EV5 0x0100 +#define ESCO_PKT_TYPES_MASK_NO_3_EV5 0x0200 + +// type definition +typedef struct { + uint8_t coding_format; /* Coding Format */ + uint16_t company_id; /* Company ID from BT SIG Assigned Numbers */ + uint16_t vendor_specific_codec_id; /* Vendor Specific Codec ID */ +} esco_coding_id_format_t; + +// Enhanced setup/accept synchronous connection See BT 4.1 or later HCI spec for +// details +typedef struct { + uint32_t transmit_bandwidth; /* Transmit Bandwidth (in octets/second) */ + uint32_t receive_bandwidth; /* RX BW (# of octets/second) */ + esco_coding_id_format_t transmit_coding_format; /* TX coding format */ + esco_coding_id_format_t receive_coding_format; /* RX coding format */ + uint16_t transmit_codec_frame_size; /* TX CODEC frame size (OTA frame size) */ + uint16_t receive_codec_frame_size; /* RX CODEC frame size (OTA frame size) */ + uint32_t input_bandwidth; /* Input BW (nominal rate octets/sec) */ + uint32_t output_bandwidth; /* Output BW (nominal rate octets/sec) */ + esco_coding_id_format_t input_coding_format; /* Input coding format */ + esco_coding_id_format_t output_coding_format; /* Output coding format */ + uint16_t input_coded_data_size; /* Input coded data size (in bits) */ + uint16_t output_coded_data_size; /* Output coded data size (in bits) */ + uint8_t input_pcm_data_format; /* Input PCM data format (see hcidefs.h) */ + uint8_t output_pcm_data_format; /* Output PCM data format (see hcidefs.h) */ + uint8_t input_pcm_payload_msb_position; /* Input PCM sample payload MSB position */ + uint8_t output_pcm_payload_msb_position; /* Output PCM sample payload MSB position */ + uint8_t input_data_path; /* 0x00 - HCI, or 0x01-0xFE for VS) */ + uint8_t output_data_path; /* 0x00 - HCI, or 0x01-0xFE for VS) */ + uint8_t input_transport_unit_size; /* Input transport unit size */ + uint8_t output_transport_unit_size; /* Output transport unit size */ + uint16_t max_latency_ms; /* Maximum latency (0x4-0xFFFE in msecs) */ + uint16_t packet_types; /* Packet Types */ + uint8_t retransmission_effort; /* 0x00-0x02, 0xFF don't care */ +} enh_esco_params_t; + +// Get the enhanced eSCO configuration parameters for the provided |codec| +enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec); +#endif \ No newline at end of file diff --git a/vendor_phytium/tenglong_e/bluetooth/include/uipc_msg.h b/vendor_phytium/tenglong_e/bluetooth/include/uipc_msg.h new file mode 100755 index 0000000000000000000000000000000000000000..a7123a94478c905d3a14c47f78e12a0f4f26b00c --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/include/uipc_msg.h @@ -0,0 +1,732 @@ +/****************************************************************************** + * + * Copyright (C) 1999-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This file contains sync message over UIPC + * + ******************************************************************************/ + +#ifndef BT_VENDOR_UIPC_MSG_H +#define BT_VENDOR_UIPC_MSG_H + +#include "bt_types.h" + +/****************************************************************************/ +/* UIPC version number: 1.0 */ +/****************************************************************************/ +#define UIPC_VERSION_MAJOR 0x0001 +#define UIPC_VERSION_MINOR 0x0000 + +/******************************** + + UIPC Management Messages + +********************************/ + +/* tUIPC_STATUS codes */ +enum { + UIPC_STATUS_SUCCESS, + UIPC_STATUS_FAIL +}; + +/* op_code */ +#define UIPC_OPEN_REQ 0x00 +#define UIPC_OPEN_RSP 0x01 +#define UIPC_CLOSE_REQ 0x02 +#define UIPC_CLOSE_RSP 0x03 + +#pragma pack(push) /* push current alignment to stack */ +#pragma pack(1) /* set alignment to 1 byte boundary to allow for offset mappings */ + +/* Structure of UIPC_OPEN_REQ message */ +typedef struct { + uint8_t opcode; /* UIPC_OPEN_REQ */ +} tUIPC_OPEN_REQ; +#define UIPC_OPEN_REQ_MSGLEN (1) + +/* Structure of UIPC_OPEN_RSP message */ +typedef struct { + uint8_t opcode; /* UIPC_OPEN_RESP */ + uint8_t status; /* UIPC_STATUS */ + uint16_t version_major; /* UIPC_VERSION_MAJOR */ + uint16_t version_minor; /* UIPC_VERSION_MINOR */ + uint8_t num_streams; /* Number of simultaneous streams supported by the light stack */ +} tUIPC_OPEN_RSP; +#define UIPC_OPEN_RSP_MSGLEN (7) + +/* Structure of UIPC_CLOSE_REQ message */ +typedef struct t_uipc_close_req { + uint8_t opcode; /* UIPC_CLOSE_REQ */ +} tUIPC_CLOSE_REQ; +#define UIPC_CLOSE_REQ_MSGLEN (1) + +/* Structure of UIPC_CLOSE_RSP message, only for BTC, full stack may ignore it */ +typedef struct t_uipc_close_rsp { + uint8_t opcode; /* UIPC_CLOSE_RSP */ +} tUIPC_CLOSE_RSP; +#define UIPC_CLOSE_RSP_MSGLEN (1) + +/* UIPC management message structures */ +typedef union { + uint8_t opcode; + tUIPC_OPEN_REQ open_req; + tUIPC_OPEN_RSP open_resp; + tUIPC_CLOSE_REQ close_req; +} tUIPC_MSG; + +#define UIPC_MGMT_MSG_MAXLEN (sizeof(tUIPC_MSG)) + +#define IPC_LOG_MSG_LEN 100 +typedef struct t_uipc_log_msg { + uint32_t trace_set_mask; + uint8_t msg[IPC_LOG_MSG_LEN]; +} tUIPC_LOG_MSG; +#define UIPC_LOG_MSGLEN (IPC_LOG_MSG_LEN + 4) + +/******************************** + + H5 Sync Message + +********************************/ + +/* op_code */ +#define SLIP_SYNC_TO_LITE_REQ 0 +#define SLIP_SYNC_TO_LITE_RESP 1 +#define SLIP_SYNC_TO_FULL_REQ 2 +#define SLIP_SYNC_TO_FULL_RESP 3 +#define SLIP_SYNC_NOTIFY 4 + +/* status */ +#define SLIP_SYNC_SUCCESS 0 +#define SLIP_SYNC_FAILURE 1 + +typedef struct { + uint8_t op_code; + uint8_t status; + uint16_t acl_pkt_size; + uint8_t state; + uint8_t lp_state; /* Low Power state */ + uint8_t next_seqno; /* next send seq */ + uint8_t ack; /* next ack seq, expected seq from peer */ + uint8_t sent_ack; /* last sent ack */ + uint8_t sliding_window_size; /* window size */ + bool oof_flow_control; /* Out of Frame SW Flow Control */ + bool data_integrity_type; /* Level of Data Integrity Check */ + uint8_t rx_state; /* rx state for incoming packet processing */ +} tSLIP_SYNC_INFO; + +/******************************** + + L2CAP Sync Message + +********************************/ + +/* op_code */ +#define L2C_SYNC_TO_LITE_REQ 0 +#define L2C_SYNC_TO_LITE_RESP 1 +#define L2C_REMOVE_TO_LITE_REQ 2 +#define L2C_REMOVE_TO_LITE_RESP 3 +#define L2C_FLUSH_TO_FULL_IND 4 + +/* status */ +#define L2C_SYNC_SUCCESS 0 +#define L2C_SYNC_FAILURE 1 + +typedef struct t_l2c_stream_info { + uint16_t local_cid; /* Local CID */ + uint16_t remote_cid; /* Remote CID */ + uint16_t out_mtu; /* Max MTU we will send */ + uint16_t handle; /* The handle used with LM */ + uint16_t link_xmit_quota; /* Num outstanding pkts allowed */ + bool is_flushable; /* TRUE if flushable channel */ +} tL2C_STREAM_INFO; + +typedef struct t_l2c_sync_to_lite_req { + uint8_t op_code; /* L2C_SYNC_TO_LITE_REQ */ + uint16_t light_xmit_quota; /* Total quota for light stack */ + uint16_t acl_data_size; /* Max ACL data size across HCI transport */ + uint16_t non_flushable_pbf; /* L2CAP_PKT_START_NON_FLUSHABLE if controller supports */ + /* Otherwise, L2CAP_PKT_START */ + uint8_t multi_av_data_cong_start; /* Multi-AV queue size to start congestion */ + uint8_t multi_av_data_cong_end; /* Multi-AV queue size to end congestion */ + uint8_t multi_av_data_cong_discard; /* Multi-AV queue size to discard */ + uint8_t num_stream; + tL2C_STREAM_INFO stream; +} tL2C_SYNC_TO_LITE_REQ; + +typedef struct t_l2c_sync_to_lite_resp_stream { + uint16_t lcid; + uint8_t status; +} tL2C_SYNC_TO_LITE_RESP_STREAM; + +typedef struct t_l2c_sync_to_lite_resp { + uint8_t op_code; /* L2C_SYNC_TO_LITE_RESP */ + uint16_t light_xmit_unacked; /* unacked packet more than quota in light stack */ + uint8_t num_stream; + tL2C_SYNC_TO_LITE_RESP_STREAM stream; +} tL2C_SYNC_TO_LITE_RESP; + +typedef struct t_l2c_remove_to_lite_req { + uint8_t op_code; /* L2C_REMOVE_TO_LITE_REQ */ + uint16_t light_xmit_quota; /* Total quota for light stack */ + uint8_t num_stream; + uint16_t lcid; +} tL2C_REMOVE_TO_LITE_REQ; + +typedef tL2C_SYNC_TO_LITE_RESP tL2C_REMOVE_TO_LITE_RESP; +typedef tL2C_REMOVE_TO_LITE_REQ tL2C_FLUSH_TO_FULL_IND; + +typedef union t_l2c_sync_msg { + uint8_t op_code; + tL2C_SYNC_TO_LITE_REQ sync_req; + tL2C_SYNC_TO_LITE_RESP sync_resp; + tL2C_REMOVE_TO_LITE_REQ remove_req; + tL2C_REMOVE_TO_LITE_RESP remove_resp; + tL2C_FLUSH_TO_FULL_IND flush_ind; +} tL2C_SYNC_MSG; + +/******************************** + + AVDTP Sync Message + +********************************/ + +/* op_code */ +#define AVDT_SYNC_TO_LITE_REQ 0 +#define AVDT_SYNC_TO_LITE_RESP 1 +#define AVDT_RESYNC_TO_LITE_REQ 2 +#define AVDT_RESYNC_TO_LITE_RESP 3 +#define AVDT_SYNC_TO_FULL_REQ 4 +#define AVDT_SYNC_TO_FULL_RESP 5 +#define AVDT_REMOVE_TO_LITE_REQ 6 +#define AVDT_REMOVE_TO_LITE_RESP 7 +#define AVDT_SYNC_TO_BTC_LITE_REQ 8 +#define AVDT_SYNC_TO_BTC_LITE_RESP 9 + +/* status */ +#define AVDT_SYNC_SUCCESS 0 +#define AVDT_SYNC_FAILURE 1 + +typedef struct { + uint16_t lcid; + uint32_t ssrc; +} tAVDT_SYNC_TO_BTC_LITE_REQ_STREAM; + +typedef struct { + uint8_t opcode; /* AVDT_SYNC_TO_BTC_LITE_REQ */ + uint8_t num_stream; + tAVDT_SYNC_TO_BTC_LITE_REQ_STREAM stream; +} tAVDT_SYNC_TO_BTC_LITE_REQ; + +typedef struct { + uint8_t opcode; /* AVDT_SYNC_TO_BTC_LITE_RESP */ + uint8_t status; +} tAVDT_SYNC_TO_BTC_LITE_RESP; + +typedef struct t_avdt_scb_sync_info { + uint8_t handle; /* SCB handle */ + BD_ADDR peer_addr; /* BD address of peer */ + uint16_t local_cid; /* Local CID */ + uint16_t peer_mtu; /* L2CAP mtu of the peer device */ + uint8_t mux_tsid_media; /* TSID for media transport session */ + uint16_t media_seq; /* media packet sequence number */ +} tAVDT_SCB_SYNC_INFO; + +typedef struct t_avdt_sync_info { + uint8_t op_code; + uint8_t status; + tAVDT_SCB_SYNC_INFO scb_info; +} tAVDT_SYNC_INFO; + +typedef union t_avdt_sync_msg { + uint8_t op_code; + tAVDT_SYNC_INFO sync_info; + tAVDT_SYNC_TO_BTC_LITE_REQ btc_sync_req; + tAVDT_SYNC_TO_BTC_LITE_RESP btc_sync_resp; +} tAVDT_SYNC_MSG; + +/******************************** + + BTA AV Sync Message + +********************************/ + +/* op_code for MM light stack */ +#define BTA_AV_SYNC_TO_LITE_REQ 0 +#define BTA_AV_SYNC_TO_LITE_RESP 1 +#define BTA_AV_STR_START_TO_LITE_REQ 2 +#define BTA_AV_STR_START_TO_LITE_RESP 3 +#define BTA_AV_STR_STOP_TO_LITE_REQ 4 +#define BTA_AV_STR_STOP_TO_LITE_RESP 5 +#define BTA_AV_STR_CLEANUP_TO_LITE_REQ 6 +#define BTA_AV_STR_CLEANUP_TO_LITE_RESP 7 +#define BTA_AV_STR_SUSPEND_TO_LITE_REQ 8 +#define BTA_AV_STR_SUSPEND_TO_LITE_RESP 9 +#define BTA_AV_SYNC_ERROR_RESP 10 + +/* op_code for BTC light stack */ +#define A2DP_START_REQ 11 +#define A2DP_START_RESP 12 +#define A2DP_STOP_REQ 13 +#define A2DP_STOP_RESP 14 +#define A2DP_CLEANUP_REQ 15 +#define A2DP_CLEANUP_RESP 16 +#define A2DP_SUSPEND_REQ 17 +#define A2DP_SUSPEND_RESP 18 + +#define A2DP_JITTER_DONE_IND 41 /* For BTSNK */ + +#define AUDIO_CODEC_CONFIG_REQ 19 +#define AUDIO_CODEC_CONFIG_RESP 20 +#define AUDIO_CODEC_SET_BITRATE_REQ 21 +#define AUDIO_CODEC_FLUSH_REQ 22 +#define AUDIO_ROUTE_CONFIG_REQ 23 +#define AUDIO_ROUTE_CONFIG_RESP 24 +#define AUDIO_MIX_CONFIG_REQ 25 +#define AUDIO_MIX_CONFIG_RESP 26 +#define AUDIO_BURST_FRAMES_IND 27 +#define AUDIO_BURST_END_IND 28 +#define AUDIO_EQ_MODE_CONFIG_REQ 29 +#define AUDIO_SCALE_CONFIG_REQ 30 + +/* For TIVO, only applicable for I2S -> DAC */ +#define AUDIO_SUB_ROUTE_REQ 51 +#define AUDIO_SUB_ROUTE_RESP 52 + +typedef struct { + uint8_t opcode; /* A2DP_START_REQ */ + uint16_t lcid; + uint16_t curr_mtu; +} tA2DP_START_REQ; + +typedef struct { + uint8_t opcode; /* A2DP_STOP_REQ */ + uint16_t lcid; +} tA2DP_STOP_REQ; + +typedef struct { + uint8_t opcode; /* A2DP_SUSPEND_REQ */ + uint16_t lcid; +} tA2DP_SUSPEND_REQ; + +typedef struct { + uint8_t opcode; /* A2DP_CLEANUP_REQ */ + uint16_t lcid; + uint16_t curr_mtu; +} tA2DP_CLEANUP_REQ; + +typedef struct { + uint8_t opcode; /* A2DP_START_RESP, A2DP_STOP_RESP, A2DP_CLEANUP_RESP, A2DP_SUSPEND_RESP */ + uint16_t lcid; +} tA2DP_GENERIC_RESP; + +#define AUDIO_CODEC_NONE 0x0000 +#define AUDIO_CODEC_SBC_ENC 0x0001 +#define AUDIO_CODEC_SBC_DEC 0x0002 +#define AUDIO_CODEC_MP3_ENC 0x0004 +#define AUDIO_CODEC_MP3_DEC 0x0008 +#define AUDIO_CODEC_AAC_ENC 0x0010 +#define AUDIO_CODEC_AAC_DEC 0x0020 +#define AUDIO_CODEC_AAC_PLUS_ENC 0x0040 +#define AUDIO_CODEC_AAC_PLUS_DEC 0x0080 +#define AUDIO_CODEC_MP2_ENC 0x0100 +#define AUDIO_CODEC_MP2_DEC 0x0200 +#define AUDIO_CODEC_MP2_5_ENC 0x0400 +#define AUDIO_CODEC_MP2_5_DEC 0x0800 + +/* SBC CODEC Parameters */ + +#define CODEC_INFO_SBC_SF_16K 0x00 +#define CODEC_INFO_SBC_SF_32K 0x01 +#define CODEC_INFO_SBC_SF_44K 0x02 +#define CODEC_INFO_SBC_SF_48K 0x03 + +#define CODEC_INFO_SBC_BLOCK_4 0x00 +#define CODEC_INFO_SBC_BLOCK_8 0x01 +#define CODEC_INFO_SBC_BLOCK_12 0x02 +#define CODEC_INFO_SBC_BLOCK_16 0x03 + +#define CODEC_INFO_SBC_CH_MONO 0x00 +#define CODEC_INFO_SBC_CH_DUAL 0x01 +#define CODEC_INFO_SBC_CH_STEREO 0x02 +#define CODEC_INFO_SBC_CH_JS 0x03 + +#define CODEC_INFO_SBC_ALLOC_LOUDNESS 0x00 +#define CODEC_INFO_SBC_ALLOC_SNR 0x01 + +#define CODEC_INFO_SBC_SUBBAND_4 0x00 +#define CODEC_INFO_SBC_SUBBAND_8 0x01 + +/* MPEG audio version ID */ +#define CODEC_INFO_MP25_ID 0x00 +#define CODEC_INFO_RESERVE 0x01 +#define CODEC_INFO_MP2_ID 0x02 +#define CODEC_INFO_MP3_ID 0x03 + +#define CODEC_INFO_MP3_PROTECTION_ON 0x00 +#define CODEC_INFO_MP3_PROTECTION_OFF 0x01 + +#define CODEC_INFO_MP3_BR_IDX_FREE 0x00 +#define CODEC_INFO_MP3_BR_IDX_32K 0x01 +#define CODEC_INFO_MP3_BR_IDX_40K 0x02 +#define CODEC_INFO_MP3_BR_IDX_48K 0x03 +#define CODEC_INFO_MP3_BR_IDX_56K 0x04 +#define CODEC_INFO_MP3_BR_IDX_64K 0x05 +#define CODEC_INFO_MP3_BR_IDX_80K 0x06 +#define CODEC_INFO_MP3_BR_IDX_96K 0x07 +#define CODEC_INFO_MP3_BR_IDX_112K 0x08 +#define CODEC_INFO_MP3_BR_IDX_128K 0x09 +#define CODEC_INFO_MP3_BR_IDX_160K 0x0A +#define CODEC_INFO_MP3_BR_IDX_192K 0x0B +#define CODEC_INFO_MP3_BR_IDX_224K 0x0C +#define CODEC_INFO_MP3_BR_IDX_256K 0x0D +#define CODEC_INFO_MP3_BR_IDX_320K 0x0E + +#define CODEC_INFO_MP3_SF_44K 0x00 +#define CODEC_INFO_MP3_SF_48K 0x01 +#define CODEC_INFO_MP3_SF_32K 0x02 + +#define CODEC_INFO_MP3_MODE_STEREO 0x00 +#define CODEC_INFO_MP3_MODE_JS 0x01 +#define CODEC_INFO_MP3_MODE_DUAL 0x02 +#define CODEC_INFO_MP3_MODE_SINGLE 0x03 + +/* layer 3, type of joint stereo coding method (intensity and ms) */ +#define CODEC_INFO_MP3_MODE_EXT_OFF_OFF 0x00 +#define CODEC_INFO_MP3_MODE_EXT_ON_OFF 0x01 +#define CODEC_INFO_MP3_MODE_EXT_OFF_ON 0x02 +#define CODEC_INFO_MP3_MODE_EXT_ON_ON 0x03 + +#define CODEC_INFO_MP2_PROTECTION_ON 0x00 +#define CODEC_INFO_MP2_PROTECTION_OFF 0x01 + +#define CODEC_INFO_MP2_BR_IDX_FREE 0x00 +#define CODEC_INFO_MP2_BR_IDX_8K 0x01 +#define CODEC_INFO_MP2_BR_IDX_16K 0x02 +#define CODEC_INFO_MP2_BR_IDX_24K 0x03 +#define CODEC_INFO_MP2_BR_IDX_32K 0x04 +#define CODEC_INFO_MP2_BR_IDX_40K 0x05 +#define CODEC_INFO_MP2_BR_IDX_48K 0x06 +#define CODEC_INFO_MP2_BR_IDX_56K 0x07 +#define CODEC_INFO_MP2_BR_IDX_64K 0x08 +#define CODEC_INFO_MP2_BR_IDX_80K 0x09 +#define CODEC_INFO_MP2_BR_IDX_96K 0x0A +#define CODEC_INFO_MP2_BR_IDX_112K 0x0B +#define CODEC_INFO_MP2_BR_IDX_128K 0x0C +#define CODEC_INFO_MP2_BR_IDX_144K 0x0D +#define CODEC_INFO_MP2_BR_IDX_160K 0x0E + +#define CODEC_INFO_MP2_SF_22K 0x00 +#define CODEC_INFO_MP2_SF_24K 0x01 +#define CODEC_INFO_MP2_SF_16K 0x02 + +#define CODEC_INFO_MP2_MODE_STEREO 0x00 +#define CODEC_INFO_MP2_MODE_JS 0x01 +#define CODEC_INFO_MP2_MODE_DUAL 0x02 +#define CODEC_INFO_MP2_MODE_SINGLE 0x03 + +/* layer 3, type of joint stereo coding method (intensity and ms) */ +#define CODEC_INFO_MP2_MODE_EXT_OFF_OFF 0x00 +#define CODEC_INFO_MP2_MODE_EXT_ON_OFF 0x01 +#define CODEC_INFO_MP2_MODE_EXT_OFF_ON 0x02 +#define CODEC_INFO_MP2_MODE_EXT_ON_ON 0x03 + +#define CODEC_INFO_MP2_SAMPLE_PER_FRAME 576 + +/* mpeg 2.5 layer 3 decoder */ + +#define CODEC_INFO_MP25_PROTECTION_ON 0x00 +#define CODEC_INFO_MP25_PROTECTION_OFF 0x01 + +#define CODEC_INFO_MP25_BR_IDX_FREE 0x00 +#define CODEC_INFO_MP25_BR_IDX_8K 0x01 +#define CODEC_INFO_MP25_BR_IDX_16K 0x02 +#define CODEC_INFO_MP25_BR_IDX_24K 0x03 +#define CODEC_INFO_MP25_BR_IDX_32K 0x04 +#define CODEC_INFO_MP25_BR_IDX_40K 0x05 +#define CODEC_INFO_MP25_BR_IDX_48K 0x06 +#define CODEC_INFO_MP25_BR_IDX_56K 0x07 +#define CODEC_INFO_MP25_BR_IDX_64K 0x08 +#define CODEC_INFO_MP25_BR_IDX_80K 0x09 +#define CODEC_INFO_MP25_BR_IDX_96K 0x0A +#define CODEC_INFO_MP25_BR_IDX_112K 0x0B +#define CODEC_INFO_MP25_BR_IDX_128K 0x0C +#define CODEC_INFO_MP25_BR_IDX_144K 0x0D +#define CODEC_INFO_MP25_BR_IDX_160K 0x0E + +#define CODEC_INFO_MP25_SF_11K 0x00 +#define CODEC_INFO_MP25_SF_12K 0x01 +#define CODEC_INFO_MP25_SF_8K 0x02 + +#define CODEC_INFO_MP25_MODE_STEREO 0x00 +#define CODEC_INFO_MP25_MODE_JS 0x01 +#define CODEC_INFO_MP25_MODE_DUAL 0x02 +#define CODEC_INFO_MP25_MODE_SINGLE 0x03 + +/* layer 3, type of joint stereo coding method (intensity and ms) */ +#define CODEC_INFO_MP25_MODE_EXT_OFF_OFF 0x00 +#define CODEC_INFO_MP25_MODE_EXT_ON_OFF 0x01 +#define CODEC_INFO_MP25_MODE_EXT_OFF_ON 0x02 +#define CODEC_INFO_MP25_MODE_EXT_ON_ON 0x03 + +#define CODEC_INFO_MP25_SAMPLE_PER_FRAME 576 + +/* AAC/AAC+ CODEC Parameters */ +#define CODEC_INFO_AAC_SF_IDX_96K 0x0 +#define CODEC_INFO_AAC_SF_IDX_88K 0x1 +#define CODEC_INFO_AAC_SF_IDX_64K 0x2 +#define CODEC_INFO_AAC_SF_IDX_48K 0x3 +#define CODEC_INFO_AAC_SF_IDX_44K 0x4 +#define CODEC_INFO_AAC_SF_IDX_32K 0x5 +#define CODEC_INFO_AAC_SF_IDX_24K 0x6 +#define CODEC_INFO_AAC_SF_IDX_22K 0x7 +#define CODEC_INFO_AAC_SF_IDX_16K 0x8 +#define CODEC_INFO_AAC_SF_IDX_12K 0x9 +#define CODEC_INFO_AAC_SF_IDX_11K 0xA +#define CODEC_INFO_AAC_SF_IDX_08K 0xB +#define CODEC_INFO_AAC_SF_IDX_RESERVE 0xC + +#define CODEC_INFO_AAC_BR_RATE_48K 288000 +#define CODEC_INFO_AAC_BR_RATE_44K 264600 +#define CODEC_INFO_AAC_BR_RATE_32K 192000 + +#define CODEC_INFO_AAC_1_CH 1 /* center front speaker */ +#define CODEC_INFO_AAC_2_CH 2 /* left, right front speaker */ +#define CODEC_INFO_AAC_3_CH 3 /* center front speaker, left right front speaker */ +#define CODEC_INFO_AAC_4_CH 4 /* center/rear front speaker, left/right front speaker */ +#define CODEC_INFO_AAC_5_CH 5 /* center, left, right front speaker, left/right surround */ +#define CODEC_INFO_AAC_6_CH 6 /* center, left, right front speaker, left/right surround, LFE */ +#define CODEC_INFO_AAC_7_CH 7 /* (left, right)center/left,right front speaker, left/right surround, LFE */ + +typedef struct { + uint8_t sampling_freq; + uint8_t channel_mode; + uint8_t block_length; + uint8_t num_subbands; + uint8_t alloc_method; + uint8_t bitpool_size; /* 2 - 250 */ +} tCODEC_INFO_SBC; + +typedef struct { + uint8_t ch_mode; + uint8_t sampling_freq; + uint8_t bitrate_index; /* 0 - 14 */ +} tCODEC_INFO_MP3; + +typedef struct { + uint8_t ch_mode; + uint8_t sampling_freq; + uint8_t bitrate_index; /* 0 - 14 */ +} tCODEC_INFO_MP2; + +typedef struct { + uint8_t ch_mode; + uint8_t sampling_freq; + uint8_t bitrate_index; /* 0 - 14 */ +} tCODEC_INFO_MP2_5; + +typedef struct { + uint16_t sampling_freq; + uint8_t channel_mode; /* 0x02:mono, 0x01:dual */ + uint32_t bitrate; /* 0 - 320K */ + uint32_t sbr_profile; /* 1: ON, 0: OFF */ +} tCODEC_INFO_AAC; + +typedef union { + tCODEC_INFO_SBC sbc; + tCODEC_INFO_MP3 mp3; + tCODEC_INFO_MP2 mp2; + tCODEC_INFO_MP2_5 mp2_5; + tCODEC_INFO_AAC aac; +} tCODEC_INFO; + +typedef struct { + uint8_t opcode; /* AUDIO_CODEC_CONFIG_REQ */ + uint16_t codec_type; + tCODEC_INFO codec_info; +} tAUDIO_CODEC_CONFIG_REQ; + +#define AUDIO_CONFIG_SUCCESS 0x00 +#define AUDIO_CONFIG_NOT_SUPPORTED 0x01 +#define AUDIO_CONFIG_FAIL_OUT_OF_MEMORY 0x02 +#define AUDIO_CONFIG_FAIL_CODEC_USED 0x03 +#define AUDIO_CONFIG_FAIL_ROUTE 0x04 + +typedef struct { + uint8_t opcode; /* AUDIO_CODEC_CONFIG_RESP */ + uint8_t status; +} tAUDIO_CODEC_CONFIG_RESP; + +typedef struct { + uint8_t opcode; /* AUDIO_CODEC_SET_BITRATE_REQ */ + uint16_t codec_type; + union { + uint8_t sbc; + uint8_t mp3; + uint32_t aac; + } codec_bitrate; +} tAUDIO_CODEC_SET_BITRATE_REQ; + +#define AUDIO_ROUTE_SRC_FMRX 0x00 +#define AUDIO_ROUTE_SRC_I2S 0x01 +#define AUDIO_ROUTE_SRC_ADC 0x02 +#define AUDIO_ROUTE_SRC_HOST 0x03 +#define AUDIO_ROUTE_SRC_PTU 0x04 +#define AUDIO_ROUTE_SRC_BTSNK 0x05 +#define AUDIO_ROUTE_SRC_NONE 0x80 +#define MAX_AUDIO_ROUTE_SRC 6 + +#define AUDIO_ROUTE_MIX_NONE 0x00 +#define AUDIO_ROUTE_MIX_HOST 0x01 +#define AUDIO_ROUTE_MIX_PCM 0x02 +#define AUDIO_ROUTE_MIX_CHIRP 0x03 +#define AUDIO_ROUTE_MIX_I2S 0x04 +#define AUDIO_ROUTE_MIX_ADC 0x05 +#define AUDIO_ROUTE_MIX_RESERVED 0x06 +#define MAX_AUDIO_ROUTE_MIX 7 + +#define AUDIO_ROUTE_OUT_NONE 0x0000 +#define AUDIO_ROUTE_OUT_BTA2DP 0x0001 +#define AUDIO_ROUTE_OUT_FMTX 0x0002 +#define AUDIO_ROUTE_OUT_BTSCO 0x0004 +#define AUDIO_ROUTE_OUT_HOST 0x0008 +#define AUDIO_ROUTE_OUT_DAC 0x0010 +#define AUDIO_ROUTE_OUT_I2S 0x0020 +#define AUDIO_ROUTE_OUT_BTA2DP_DAC 0x0040 +#define AUDIO_ROUTE_OUT_BTA2DP_I2S 0x0080 +#define AUDIO_ROUTE_OUT_BTSCO_DAC 0x0100 +#define AUDIO_ROUTE_OUT_BTSCO_I2S 0x0200 +#define AUDIO_ROUTE_OUT_HOST_BTA2DP 0x0400 +#define AUDIO_ROUTE_OUT_HOST_BTSCO 0x0800 +#define AUDIO_ROUTE_OUT_HOST_DAC 0x1000 +#define AUDIO_ROUTE_OUT_HOST_I2S 0x2000 +#define AUDIO_ROUTE_OUT_DAC_I2S 0x4000 +#define AUDIO_ROUTE_OUT_RESERVED_2 0x8000 + +#define MAX_AUDIO_SINGLE_ROUTE_OUT 6 +#define MAX_AUDIO_MULTI_ROUTE_OUT 16 + +#define AUDIO_ROUTE_SF_8K 0x00 +#define AUDIO_ROUTE_SF_16K 0x01 +#define AUDIO_ROUTE_SF_32K 0x02 +#define AUDIO_ROUTE_SF_44_1K 0x03 +#define AUDIO_ROUTE_SF_48K 0x04 +#define AUDIO_ROUTE_SF_11K 0x05 +#define AUDIO_ROUTE_SF_12K 0x06 +#define AUDIO_ROUTE_SF_22K 0x07 +#define AUDIO_ROUTE_SF_24K 0x08 +#define AUDIO_ROUTE_SF_NA 0xFF + +#define AUDIO_ROUTE_EQ_BASS_BOOST 0x00 +#define AUDIO_ROUTE_EQ_CLASSIC 0x01 +#define AUDIO_ROUTE_EQ_JAZZ 0x02 +#define AUDIO_ROUTE_EQ_LIVE 0x03 +#define AUDIO_ROUTE_EQ_NORMAL 0x04 +#define AUDIO_ROUTE_EQ_ROCK 0x05 +#define AUDIO_ROUTE_EQ_BYPASS 0x06 + +#define AUDIO_ROUTE_DIGITAL_VOLUME_CONTROL 0x07 + +#define AUDIO_ROUTE_EQ_CONFIG_GAIN 0xFF /* Custion Gain Config */ + +typedef struct { + uint8_t opcode; /* AUDIO_ROUTE_CONFIG_REQ */ + uint8_t src; + uint8_t src_sf; + uint8_t out; + uint8_t out_codec_sf; + uint8_t out_i2s_sf; + uint8_t eq_mode; +} tAUDIO_ROUTE_CONFIG_REQ; + +typedef struct { + uint8_t opcode; /* AUDIO_ROUTE_CONFIG_RESP */ + uint8_t status; +} tAUDIO_ROUTE_CONFIG_RESP; + +typedef struct { + uint16_t amp[2]; /* left/right 15 bit amplitude value */ + uint16_t tone[2]; /* left/right 12 bit frequency 0 - 4096Hz */ + uint16_t mark[2]; /* left/right 16 bit mark time 0 - 65535ms */ + uint16_t space[2]; /* left/right 16 bit space time 0 - 65535ms */ +} tCHIRP_CONFIG; + +typedef struct { + uint8_t pri_l; /* Primary Left scale : 0 ~ 255 */ + uint8_t mix_l; /* Mixing Left scale : 0 ~ 255 */ + uint8_t pri_r; /* Primary Right scale : 0 ~ 255 */ + uint8_t mix_r; /* Mixing Right scale : 0 ~ 255 */ +} tMIX_SCALE_CONFIG; + +/* For custon equalizer gain configuration */ +typedef struct { + uint32_t audio_l_g0; /* IIR biquad filter left ch gain 0 */ + uint32_t audio_l_g1; /* IIR biquad filter left ch gain 1 */ + uint32_t audio_l_g2; /* IIR biquad filter left ch gain 2 */ + uint32_t audio_l_g3; /* IIR biquad filter left ch gain 3 */ + uint32_t audio_l_g4; /* IIR biquad filter left ch gain 4 */ + uint32_t audio_l_gl; /* IIR biquad filter left ch global gain */ + uint32_t audio_r_g0; /* IIR biquad filter left ch gain 0 */ + uint32_t audio_r_g1; /* IIR biquad filter left ch gain 1 */ + uint32_t audio_r_g2; /* IIR biquad filter left ch gain 2 */ + uint32_t audio_r_g3; /* IIR biquad filter left ch gain 3 */ + uint32_t audio_r_g4; /* IIR biquad filter left ch gain 4 */ + uint32_t audio_r_gl; /* IIR biquad filter left ch global gain */ +} tEQ_GAIN_CONFIG; + +typedef struct { + uint8_t opcode; /* AUDIO_MIX_CONFIG_REQ */ + uint8_t mix_src; + uint8_t mix_src_sf; + tMIX_SCALE_CONFIG mix_scale; + tCHIRP_CONFIG chirp_config; +} tAUDIO_MIX_CONFIG_REQ; + +typedef struct { + uint8_t opcode; /* AUDIO_MIX_CONFIG_RESP */ + uint8_t status; +} tAUDIO_MIX_CONFIG_RESP; + +typedef struct { + uint8_t opcode; /* AUDIO_BURST_FRAMES_IND */ + uint32_t burst_size; /* in bytes */ +} tAUDIO_BURST_FRAMES_IND; + +typedef struct { + uint8_t opcode; /* AUDIO_BURST_END_IND */ +} tAUDIO_BURST_END_IND; + +typedef struct { + uint8_t opcode; /* AUDIO_CODEC_FLUSH_REQ */ +} tAUDIO_CODEC_FLUSH_REQ; + +typedef struct { + uint8_t opcode; /* AUDIO_EQ_MODE_CONFIG_REQ */ + uint8_t eq_mode; + tEQ_GAIN_CONFIG filter_gain; /* Valid only when eq_mode is 0xFF */ +} tAUDIO_EQ_MODE_CONFIG_REQ; + +typedef struct { + uint8_t opcode; /* AUDIO_SCALE_CONFIG_REQ */ + tMIX_SCALE_CONFIG mix_scale; +} tAUDIO_SCALE_CONFIG_REQ; + +#pragma pack(pop) /* pop saved alignment to stack */ + +#endif /* BT_VENDOR_UIPC_MSG_H */ diff --git a/vendor_phytium/tenglong_e/bluetooth/include/upio.h b/vendor_phytium/tenglong_e/bluetooth/include/upio.h new file mode 100755 index 0000000000000000000000000000000000000000..b22edf6ae06d86a9995c110c53e77e57ce56bcda --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/include/upio.h @@ -0,0 +1,108 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: upio.h + * + * Description: Contains definitions used for I/O controls + * + ******************************************************************************/ + +#ifndef UPIO_H +#define UPIO_H + +#include +/****************************************************************************** +** Constants & Macros +******************************************************************************/ + +#define UPIO_BT_POWER_OFF 0 +#define UPIO_BT_POWER_ON 1 + +/* UPIO signals */ +enum { + UPIO_BT_WAKE = 0, + UPIO_HOST_WAKE, + UPIO_LPM_MODE, + UPIO_MAX_COUNT +}; + +/* UPIO assertion/deassertion */ +enum { + UPIO_UNKNOWN = 0, + UPIO_DEASSERT, + UPIO_ASSERT +}; + +/****************************************************************************** +** Extern variables and functions +******************************************************************************/ + +/****************************************************************************** +** Functions +******************************************************************************/ + +/******************************************************************************* +** +** Function upio_init +** +** Description Initialization +** +** Returns None +** +*******************************************************************************/ +void upio_init(void); + +/******************************************************************************* +** +** Function upio_cleanup +** +** Description Clean up +** +** Returns None +** +*******************************************************************************/ +void upio_cleanup(void); + +/******************************************************************************* +** +** Function upio_set_bluetooth_power +** +** Description Interact with low layer driver to set Bluetooth power +** on/off. +** +** Returns 0 : SUCCESS or Not-Applicable +** <0 : ERROR +** +*******************************************************************************/ +int upio_set_bluetooth_power(int on); + +/******************************************************************************* +** +** Function upio_set +** +** Description Set i/o based on polarity +** +** Returns None +** +*******************************************************************************/ +void upio_set(uint8_t pio, uint8_t action, uint8_t polarity); + +#endif /* UPIO_H */ + diff --git a/vendor_phytium/tenglong_e/bluetooth/include/userial.h b/vendor_phytium/tenglong_e/bluetooth/include/userial.h new file mode 100755 index 0000000000000000000000000000000000000000..a4b219090964b712fdd3c6e8b9d3bf84d51c57f5 --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/include/userial.h @@ -0,0 +1,73 @@ +/****************************************************************************** + * + * Copyright 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +// This module manages the serial port over which HCI commands +// and data are sent/received. + +#ifndef BT_VENDOR_USERIAL_H +#define BT_VENDOR_USERIAL_H + +#include +#include + +typedef enum { + USERIAL_PORT_1, + USERIAL_PORT_2, + USERIAL_PORT_3, + USERIAL_PORT_4, + USERIAL_PORT_5, + USERIAL_PORT_6, + USERIAL_PORT_7, + USERIAL_PORT_8, + USERIAL_PORT_9, + USERIAL_PORT_10, + USERIAL_PORT_11, + USERIAL_PORT_12, + USERIAL_PORT_13, + USERIAL_PORT_14, + USERIAL_PORT_15, + USERIAL_PORT_16, + USERIAL_PORT_17, + USERIAL_PORT_18, +} userial_port_t; + +// Initializes the userial module. This function should only be called once. +// It returns true if the module was initialized, false if there was an error. +bool userial_init(void); + +// Opens the given serial port. Returns true if successful, false otherwise. +// Once this function is called, the userial module will begin producing +// buffers from data read off the serial port. If you wish to pause the +// production of buffers, call |userial_pause_reading|. You can then resume +// by calling |userial_resume_reading|. This function returns true if the +// serial port was successfully opened and buffer production has started. It +// returns false if there was an error. +bool userial_open(userial_port_t port); +void userial_close(void); +void userial_close_reader(void); + +// Reads a maximum of |len| bytes from the serial port into |p_buffer|. +// This function returns the number of bytes actually read, which may be +// less than |len|. This function will not block. +uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len); + +// Writes a maximum of |len| bytes from |p_data| to the serial port. +// This function returns the number of bytes actually written, which may be +// less than |len|. This function may block. +uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len); +#endif \ No newline at end of file diff --git a/vendor_phytium/tenglong_e/bluetooth/include/userial_vendor.h b/vendor_phytium/tenglong_e/bluetooth/include/userial_vendor.h new file mode 100755 index 0000000000000000000000000000000000000000..658ac69436224f75e4ae812806eefd911613b798 --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/include/userial_vendor.h @@ -0,0 +1,188 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: userial_vendor.h + * + * Description: Contains vendor-specific definitions used in serial port + * controls + * + ******************************************************************************/ + +#ifndef USERIAL_VENDOR_H +#define USERIAL_VENDOR_H + +#include "bt_vendor_brcm.h" +#include "userial.h" + +/****************************************************************************** +** Constants & Macros +******************************************************************************/ + +/**** baud rates ****/ +#define USERIAL_BAUD_300 0 +#define USERIAL_BAUD_600 1 +#define USERIAL_BAUD_1200 2 +#define USERIAL_BAUD_2400 3 +#define USERIAL_BAUD_9600 4 +#define USERIAL_BAUD_19200 5 +#define USERIAL_BAUD_57600 6 +#define USERIAL_BAUD_115200 7 +#define USERIAL_BAUD_230400 8 +#define USERIAL_BAUD_460800 9 +#define USERIAL_BAUD_921600 10 +#define USERIAL_BAUD_1M 11 +#define USERIAL_BAUD_1_5M 12 +#define USERIAL_BAUD_2M 13 +#define USERIAL_BAUD_3M 14 +#define USERIAL_BAUD_4M 15 +#define USERIAL_BAUD_AUTO 16 + +#define USERIAL_LINESPEED_600 600 +#define USERIAL_LINESPEED_1200 1200 +#define USERIAL_LINESPEED_2400 2400 +#define USERIAL_LINESPEED_9600 9600 +#define USERIAL_LINESPEED_19200 19200 +#define USERIAL_LINESPEED_57600 57600 +#define USERIAL_LINESPEED_115200 115200 +#define USERIAL_LINESPEED_230400 230400 +#define USERIAL_LINESPEED_460800 460800 +#define USERIAL_LINESPEED_921600 921600 +#define USERIAL_LINESPEED_1M 1000000 +#define USERIAL_LINESPEED_1_5M 1500000 +#define USERIAL_LINESPEED_2M 2000000 +#define USERIAL_LINESPEED_3M 3000000 +#define USERIAL_LINESPEED_4M 4000000 + +/**** Data Format ****/ +/* Stop Bits */ +#define USERIAL_STOPBITS_1 1 +#define USERIAL_STOPBITS_1_5 (1 << 1) +#define USERIAL_STOPBITS_2 (1 << 2) + +/* Parity Bits */ +#define USERIAL_PARITY_NONE (1 << 3) +#define USERIAL_PARITY_EVEN (1 << 4) +#define USERIAL_PARITY_ODD (1 << 5) + +/* Data Bits */ +#define USERIAL_DATABITS_5 (1 << 6) +#define USERIAL_DATABITS_6 (1 << 7) +#define USERIAL_DATABITS_7 (1 << 8) +#define USERIAL_DATABITS_8 (1 << 9) + +#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE) +/* These are the ioctl values used for bt_wake ioctl via UART driver. you may + * need to redefine them on you platform! + * Logically they need to be unique and not colide with existing uart ioctl's. + */ +#ifndef USERIAL_IOCTL_BT_WAKE_ASSERT +#define USERIAL_IOCTL_BT_WAKE_ASSERT 0x8003 +#endif +#ifndef USERIAL_IOCTL_BT_WAKE_DEASSERT +#define USERIAL_IOCTL_BT_WAKE_DEASSERT 0x8004 +#endif +#ifndef USERIAL_IOCTL_BT_WAKE_GET_ST +#define USERIAL_IOCTL_BT_WAKE_GET_ST 0x8005 +#endif +#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) + +/****************************************************************************** +** Type definitions +******************************************************************************/ + +/* Structure used to configure serial port during open */ +typedef struct { + uint16_t fmt; /* Data format */ + uint8_t baud; /* Baud rate */ +} tUSERIAL_CFG; + +typedef enum { +#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE) + USERIAL_OP_ASSERT_BT_WAKE, + USERIAL_OP_DEASSERT_BT_WAKE, + USERIAL_OP_GET_BT_WAKE_STATE, +#endif + USERIAL_OP_NOP, +} userial_vendor_ioctl_op_t; + +/****************************************************************************** +** Extern variables and functions +******************************************************************************/ + +/****************************************************************************** +** Functions +******************************************************************************/ + +/******************************************************************************* +** +** Function userial_vendor_init +** +** Description Initialize userial vendor-specific control block +** +** Returns None +** +*******************************************************************************/ +void userial_vendor_init(void); + +/******************************************************************************* +** +** Function userial_vendor_open +** +** Description Open the serial port with the given configuration +** +** Returns device fd +** +*******************************************************************************/ +int userial_vendor_open(tUSERIAL_CFG *p_cfg); + +/******************************************************************************* +** +** Function userial_vendor_close +** +** Description Conduct vendor-specific close work +** +** Returns None +** +*******************************************************************************/ +void userial_vendor_close(void); + +/******************************************************************************* +** +** Function userial_vendor_set_baud +** +** Description Set new baud rate +** +** Returns None +** +*******************************************************************************/ +void userial_vendor_set_baud(uint8_t userial_baud); + +/******************************************************************************* +** +** Function userial_vendor_ioctl +** +** Description ioctl inteface +** +** Returns None +** +*******************************************************************************/ +void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data); + +#endif /* USERIAL_VENDOR_H */ diff --git a/vendor_phytium/tenglong_e/bluetooth/include/utils/Log.h b/vendor_phytium/tenglong_e/bluetooth/include/utils/Log.h new file mode 100755 index 0000000000000000000000000000000000000000..8b4bb5d36d6a663326181b07678058376cede9a8 --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/include/utils/Log.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + * 2024.11.21 Phytium change + */ +#ifndef BT_VENDOR_LOG_H +#define BT_VENDOR_LOG_H + +#include "hilog/log.h" + +#define HILOGD(...) HiLogPrint(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, "BTVENDOR", __VA_ARGS__) +#define HILOGI(...) HiLogPrint(LOG_CORE, LOG_INFO, LOG_DOMAIN, "BTVENDOR", __VA_ARGS__) +#define HILOGW(...) HiLogPrint(LOG_CORE, LOG_WARN, LOG_DOMAIN, "BTVENDOR", __VA_ARGS__) +#define HILOGE(...) HiLogPrint(LOG_CORE, LOG_ERROR, LOG_DOMAIN, "BTVENDOR", __VA_ARGS__) + +#endif diff --git a/vendor_phytium/tenglong_e/bluetooth/src/bt_vendor_brcm.c b/vendor_phytium/tenglong_e/bluetooth/src/bt_vendor_brcm.c new file mode 100755 index 0000000000000000000000000000000000000000..8754a733ddf53279fdce0cbeda579a6997fbc7a7 --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/src/bt_vendor_brcm.c @@ -0,0 +1,219 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: bt_vendor_brcm.c + * + * Description: Broadcom vendor specific library implementation + * + ******************************************************************************/ + +#define LOG_TAG "bt_vendor" + +#include +#include +#include "upio.h" +#include "userial_vendor.h" +#include "bt_vendor_brcm.h" + +#ifndef BTVND_DBG +#define BTVND_DBG FALSE +#endif + +#if (BTVND_DBG == TRUE) +#define BTVNDDBG(param, ...) \ + { \ + HILOGD(param, ##__VA_ARGS__); \ + } +#else +#define BTVNDDBG(param, ...) \ + { \ + HILOGD(param, ##__VA_ARGS__); \ + } +#endif + +/****************************************************************************** +** Externs +******************************************************************************/ + +void hw_config_start(void); +uint8_t hw_lpm_enable(uint8_t turn_on); +uint32_t hw_lpm_get_idle_timeout(void); +void hw_lpm_set_wake_state(uint8_t wake_assert); +#if (SCO_CFG_INCLUDED == TRUE) +void hw_sco_config(void); +#endif +void vnd_load_conf(const char *p_path); +#if (HW_END_WITH_HCI_RESET == TRUE) +void hw_epilog_process(void); +#endif + +/****************************************************************************** +** Variables +******************************************************************************/ + +bt_vendor_callbacks_t *bt_vendor_cbacks = NULL; +uint8_t vnd_local_bd_addr[BD_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +/****************************************************************************** +** Local type definitions +******************************************************************************/ + +/****************************************************************************** +** Static Variables +******************************************************************************/ + +static const tUSERIAL_CFG userial_init_cfg = { + (USERIAL_DATABITS_8 | USERIAL_PARITY_NONE | USERIAL_STOPBITS_1), + USERIAL_BAUD_115200 +}; + +/****************************************************************************** +** Functions +******************************************************************************/ + +/***************************************************************************** +** +** BLUETOOTH VENDOR INTERFACE LIBRARY FUNCTIONS +** +*****************************************************************************/ +/** LPM disable/enable request */ +typedef enum { + BT_VND_LPM_DISABLE, + BT_VND_LPM_ENABLE, +} bt_vendor_lpm_mode_t; + +static int init(const bt_vendor_callbacks_t *p_cb, unsigned char *local_bdaddr) +{ + HILOGI("init, bdaddr:%02x%02x:%02x%02x:%02x%02x", local_bdaddr[0], local_bdaddr[1], local_bdaddr[2], + local_bdaddr[3], local_bdaddr[4], local_bdaddr[5]); + + if (p_cb == NULL) { + HILOGE("init failed with no user callbacks!"); + return -1; + } + +#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE) + HILOGW("*****************************************************************"); + HILOGW("*****************************************************************"); + HILOGW("** Warning - BT Vendor Lib is loaded in debug tuning mode!"); + HILOGW("**"); + HILOGW("** If this is not intentional, rebuild libbt-vendor.so "); + HILOGW("** with VENDOR_LIB_RUNTIME_TUNING_ENABLED=FALSE and "); + HILOGW("** check if any run-time tuning parameters needed to be"); + HILOGW("** carried to the build-time configuration accordingly."); + HILOGW("*****************************************************************"); + HILOGW("*****************************************************************"); +#endif + + userial_vendor_init(); + upio_init(); + + vnd_load_conf(VENDOR_LIB_CONF_FILE); + + /* store reference to user callbacks */ + bt_vendor_cbacks = (bt_vendor_callbacks_t *)p_cb; + +#if (BRCM_A2DP_OFFLOAD == TRUE) + brcm_vnd_a2dp_init(bt_vendor_cbacks); +#endif + + /* This is handed over from the stack */ + return memcpy_s(vnd_local_bd_addr, BD_ADDR_LEN, local_bdaddr, BD_ADDR_LEN); +} + +/** Requested operations */ +static int op(bt_opcode_t opcode, void *param) +{ + int retval = 0; + + switch (opcode) { + case BT_OP_POWER_ON: // BT_VND_OP_POWER_CTRL + upio_set_bluetooth_power(UPIO_BT_POWER_OFF); + upio_set_bluetooth_power(UPIO_BT_POWER_ON); + break; + + case BT_OP_POWER_OFF: // BT_VND_OP_POWER_CTRL + upio_set_bluetooth_power(UPIO_BT_POWER_OFF); + hw_lpm_set_wake_state(false); + break; + + case BT_OP_HCI_CHANNEL_OPEN: { // BT_VND_OP_USERIAL_OPEN + int(*fd_array)[] = (int(*)[])param; + int fd, idx; + fd = userial_vendor_open((tUSERIAL_CFG *)&userial_init_cfg); + if (fd != -1) { + for (idx = 0; idx < HCI_MAX_CHANNEL; idx++) + (*fd_array)[idx] = fd; + + retval = 1; + } + /* retval contains numbers of open fd of HCI channels */ + break; + } + case BT_OP_HCI_CHANNEL_CLOSE: // BT_VND_OP_USERIAL_CLOSE + userial_vendor_close(); + break; + + case BT_OP_INIT: // BT_VND_OP_FW_CFG + hw_config_start(); + break; + + case BT_OP_GET_LPM_TIMER: { // BT_VND_OP_GET_LPM_IDLE_TIMEOUT + uint32_t *timeout_ms = (uint32_t *)param; + *timeout_ms = hw_lpm_get_idle_timeout(); + break; + } + + case BT_OP_LPM_ENABLE: + retval = hw_lpm_enable(BT_VND_LPM_ENABLE); + break; + + case BT_OP_LPM_DISABLE: + retval = hw_lpm_enable(BT_VND_LPM_DISABLE); + break; + + case BT_OP_WAKEUP_LOCK: + hw_lpm_set_wake_state(TRUE); + break; + case BT_OP_WAKEUP_UNLOCK: + hw_lpm_set_wake_state(FALSE); + break; + case BT_OP_EVENT_CALLBACK: + hw_process_event((HC_BT_HDR *)param); + break; + } + + return retval; +} + +/** Closes the interface */ +static void cleanup(void) +{ + BTVNDDBG("cleanup"); + upio_cleanup(); + bt_vendor_cbacks = NULL; +} + +// Entry point of DLib +const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = { + sizeof(bt_vendor_interface_t), + init, + op, + cleanup}; diff --git a/vendor_phytium/tenglong_e/bluetooth/src/conf.c b/vendor_phytium/tenglong_e/bluetooth/src/conf.c new file mode 100755 index 0000000000000000000000000000000000000000..b64bd9830ba559bd90678108b605d3ac29586d8d --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/src/conf.c @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: conf.c + * + * Description: Contains functions to conduct run-time module configuration + * based on entries present in the .conf file + * + ******************************************************************************/ + +#define LOG_TAG "bt_vnd_conf" + +#include +#include +#include +#include "bt_vendor_brcm.h" + +/****************************************************************************** +** Externs +******************************************************************************/ +int userial_set_port(char *p_conf_name, char *p_conf_value, int param); +int hw_set_patch_file_path(char *p_conf_name, char *p_conf_value, int param); +int hw_set_patch_file_name(char *p_conf_name, char *p_conf_value, int param); +#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE) +int hw_set_patch_settlement_delay(char *p_conf_name, char *p_conf_value, int param); +#endif + +/****************************************************************************** +** Local type definitions +******************************************************************************/ + +#define CONF_COMMENT '#' +#define CONF_DELIMITERS " =\n\r\t" +#define CONF_VALUES_DELIMITERS "=\n\r\t" +#define CONF_MAX_LINE_LEN 255 + +typedef int(conf_action_t)(char *p_conf_name, char *p_conf_value, int param); + +typedef struct { + const char *conf_entry; + conf_action_t *p_action; + int param; +} conf_entry_t; + +/****************************************************************************** +** Static variables +******************************************************************************/ + +/* + * Current supported entries and corresponding action functions + */ +static const conf_entry_t conf_table[] = { + {"UartPort", userial_set_port, 0}, + {"FwPatchFilePath", hw_set_patch_file_path, 0}, + {"FwPatchFileName", hw_set_patch_file_name, 0}, +#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE) + {"FwPatchSettlementDelay", hw_set_patch_settlement_delay, 0}, +#endif + {(const char *)NULL, NULL, 0} +}; + +/***************************************************************************** +** CONF INTERFACE FUNCTIONS +*****************************************************************************/ + +/******************************************************************************* +** +** Function vnd_load_conf +** +** Description Read conf entry from p_path file one by one and call +** the corresponding config function +** +** Returns None +** +*******************************************************************************/ +void vnd_load_conf(const char *p_path) +{ + FILE *p_file; + char *p_name; + char *p_value; + conf_entry_t *p_entry; + char line[CONF_MAX_LINE_LEN + 1]; /* add 1 for \0 char */ + + HILOGI("Attempt to load conf from %s", p_path); + if ((p_file = fopen(p_path, "r")) == NULL) { + HILOGI("vnd_load_conf file >%s< not found", p_path); + return; + } + + /* read line by line */ + while (fgets(line, CONF_MAX_LINE_LEN + 1, p_file) != NULL) { + if (line[0] == CONF_COMMENT) { + continue; + } + + p_name = strtok(line, CONF_DELIMITERS); + if (p_name == NULL) { + continue; + } + + p_value = strtok(NULL, CONF_DELIMITERS); + if (p_value == NULL) { + HILOGW("vnd_load_conf: missing value for name: %s", p_name); + continue; + } + + p_entry = (conf_entry_t *)conf_table; + while (p_entry->conf_entry != NULL) { + if (strcmp(p_entry->conf_entry, (const char *)p_name) == 0) { + p_entry->p_action(p_name, p_value, p_entry->param); + break; + } + + p_entry++; + } + } + + (void)fclose(p_file); +} diff --git a/vendor_phytium/tenglong_e/bluetooth/src/hardware.c b/vendor_phytium/tenglong_e/bluetooth/src/hardware.c new file mode 100755 index 0000000000000000000000000000000000000000..40b49b4da951d3fe8c515abff5f954d910a27c5d --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/src/hardware.c @@ -0,0 +1,1528 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: hardware.c + * + * Description: Contains controller-specific functions, like + * firmware patch download + * low power mode operations + * + ******************************************************************************/ + +#define LOG_TAG "bt_hwcfg" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "bt_hci_bdroid.h" +#include "bt_vendor_brcm.h" +#include "esco_parameters.h" +#include "userial.h" +#include "userial_vendor.h" +#include "upio.h" + +/****************************************************************************** +** Constants & Macros +******************************************************************************/ + +#ifndef BTHW_DBG +#define BTHW_DBG FALSE +#endif + +#if (BTHW_DBG == TRUE) +#define BTHWDBG(param, ...) \ +{ \ + HILOGD(param, ##__VA_ARGS__); \ +} +#else +#define BTHWDBG(param, ...) \ +{ \ + HILOGD(param, ##__VA_ARGS__); \ +} +#endif + +#define FW_PATCHFILE_EXTENSION ".hcd" +#define FW_PATCHFILE_EXTENSION_LEN 4 +#define FW_PATCHFILE_PATH_MAXLEN 248 /* Local_Name length of return of \ + HCI_Read_Local_Name */ + +#define HCI_CMD_MAX_LEN 258 + +#define HCI_RESET 0x0C03 +#define HCI_VSC_WRITE_UART_CLOCK_SETTING 0xFC45 +#define HCI_VSC_UPDATE_BAUDRATE 0xFC18 +#define HCI_READ_LOCAL_NAME 0x0C14 +#define HCI_VSC_DOWNLOAD_MINIDRV 0xFC2E +#define HCI_VSC_WRITE_FIRMWARE 0xFC4C +#define HCI_VSC_WRITE_BD_ADDR 0xFC01 +#define HCI_VSC_WRITE_SLEEP_MODE 0xFC27 +#define HCI_VSC_WRITE_SCO_PCM_INT_PARAM 0xFC1C +#define HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM 0xFC1E +#define HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM 0xFC6D +#define HCI_VSC_ENABLE_WBS 0xFC7E +#define HCI_VSC_LAUNCH_RAM 0xFC4E +#define HCI_READ_LOCAL_BDADDR 0x1009 + +#define HCI_EVT_CMD_CMPL_STATUS_RET_BYTE 5 +#define HCI_EVT_CMD_CMPL_LOCAL_NAME_STRING 6 +#define HCI_EVT_CMD_CMPL_LOCAL_BDADDR_ARRAY 6 +#define HCI_EVT_CMD_CMPL_OPCODE 3 +#define LPM_CMD_PARAM_SIZE 12 +#define UPDATE_BAUDRATE_CMD_PARAM_SIZE 6 +#define HCI_CMD_PREAMBLE_SIZE 3 +#define HCD_REC_PAYLOAD_LEN_BYTE 2 +#define LOCAL_NAME_BUFFER_LEN 32 +#define LOCAL_BDADDR_PATH_BUFFER_LEN 256 + +#define STREAM_TO_UINT16(u16, p) \ +do \ +{ \ + u16 = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); \ + (p) += 2; \ +} while (0) +#define UINT8_TO_STREAM(p, u8) \ +do \ +{ \ + *(p)++ = (uint8_t)(u8); \ +} while (0) +#define UINT16_TO_STREAM(p, u16) \ +do \ +{ \ + *(p)++ = (uint8_t)(u16); \ + *(p)++ = (uint8_t)((u16) >> 8); \ +} while (0) +#define UINT32_TO_STREAM(p, u32) \ +do \ +{ \ + *(p)++ = (uint8_t)(u32); \ + *(p)++ = (uint8_t)((u32) >> 8); \ + *(p)++ = (uint8_t)((u32) >> 16); \ + *(p)++ = (uint8_t)((u32) >> 24); \ +} while (0) + +#define SCO_INTERFACE_PCM 0 +#define SCO_INTERFACE_I2S 1 + +/* one byte is for enable/disable + next 2 bytes are for codec type */ +#define SCO_CODEC_PARAM_SIZE 3 + +#define BT_VENDOR_CFG_TIMEDELAY_ 40 +#define BT_VENDOR_LDM_DEFAULT_IDLE 300 +/****************************************************************************** +** Local type definitions +******************************************************************************/ + +/* Hardware Configuration State */ +enum { + HW_CFG_START = 1, + HW_CFG_SET_UART_CLOCK, + HW_CFG_SET_UART_BAUD_1, + HW_CFG_READ_LOCAL_NAME, + HW_CFG_DL_MINIDRIVER, + HW_CFG_DL_FW_PATCH, + HW_CFG_SET_UART_BAUD_2, + HW_CFG_SET_BD_ADDR, + HW_CFG_READ_BD_ADDR +}; + +/* h/w config control block */ +typedef struct { + uint8_t state; /* Hardware configuration state */ + int fw_fd; /* FW patch file fd */ + uint8_t f_set_baud_2; /* Baud rate switch state */ + char local_chip_name[LOCAL_NAME_BUFFER_LEN]; +} bt_hw_cfg_cb_t; + +/* low power mode parameters */ +typedef struct { + uint8_t sleep_mode; /* 0(disable),1(UART),9(H5) */ + uint8_t host_stack_idle_threshold; /* Unit scale 300ms/25ms */ + uint8_t host_controller_idle_threshold; /* Unit scale 300ms/25ms */ + uint8_t bt_wake_polarity; /* 0=Active Low, 1= Active High */ + uint8_t host_wake_polarity; /* 0=Active Low, 1= Active High */ + uint8_t allow_host_sleep_during_sco; + uint8_t combine_sleep_mode_and_lpm; + uint8_t enable_uart_txd_tri_state; /* UART_TXD Tri-State */ + uint8_t sleep_guard_time; /* sleep guard time in 12.5ms */ + uint8_t wakeup_guard_time; /* wakeup guard time in 12.5ms */ + uint8_t txd_config; /* TXD is high in sleep state */ + uint8_t pulsed_host_wake; /* pulsed host wake if mode = 1 */ +} bt_lpm_param_t; + +/* Firmware re-launch settlement time */ +typedef struct { + const char *chipset_name; + const uint32_t delay_time; +} fw_settlement_entry_t; + +#if (FW_AUTO_DETECTION == TRUE) +/* AMPAK FW auto detection table */ +typedef struct { + char *chip_id; + char *updated_chip_id; +} fw_auto_detection_entry_t; +#endif + +/****************************************************************************** +** Externs +******************************************************************************/ + +void hw_config_cback(void *p_mem); + +/****************************************************************************** +** Static variables +******************************************************************************/ + +static char fw_patchfile_path[256] = FW_PATCHFILE_LOCATION; +static char fw_patchfile_name[128] = {0}; +#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE) +static int fw_patch_settlement_delay = -1; +#endif + +static int wbs_sample_rate = SCO_WBS_SAMPLE_RATE; +static bt_hw_cfg_cb_t hw_cfg_cb; + +static bt_lpm_param_t lpm_param = { + LPM_SLEEP_MODE, + LPM_IDLE_THRESHOLD, + LPM_HC_IDLE_THRESHOLD, + LPM_BT_WAKE_POLARITY, + LPM_HOST_WAKE_POLARITY, + LPM_ALLOW_HOST_SLEEP_DURING_SCO, + LPM_COMBINE_SLEEP_MODE_AND_LPM, + LPM_ENABLE_UART_TXD_TRI_STATE, + 0, /* not applicable */ + 0, /* not applicable */ + 0, /* not applicable */ + LPM_PULSED_HOST_WAKE +}; + +/* need to update the bt_sco_i2spcm_param as well + bt_sco_i2spcm_param will be used for WBS setting + update the bt_sco_param and bt_sco_i2spcm_param */ +static uint8_t bt_sco_param[SCO_PCM_PARAM_SIZE] = { + SCO_PCM_ROUTING, + SCO_PCM_IF_CLOCK_RATE, + SCO_PCM_IF_FRAME_TYPE, + SCO_PCM_IF_SYNC_MODE, + SCO_PCM_IF_CLOCK_MODE +}; + +static uint8_t bt_pcm_data_fmt_param[PCM_DATA_FORMAT_PARAM_SIZE] = { + PCM_DATA_FMT_SHIFT_MODE, + PCM_DATA_FMT_FILL_BITS, + PCM_DATA_FMT_FILL_METHOD, + PCM_DATA_FMT_FILL_NUM, + PCM_DATA_FMT_JUSTIFY_MODE +}; + +static uint8_t bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_SIZE] = { + SCO_I2SPCM_IF_MODE, + SCO_I2SPCM_IF_ROLE, + SCO_I2SPCM_IF_SAMPLE_RATE, + SCO_I2SPCM_IF_CLOCK_RATE +}; + +/* + * The look-up table of recommended firmware settlement delay (milliseconds) on + * known chipsets. + */ +static const fw_settlement_entry_t fw_settlement_table[] = { + {"BCM43241", 200}, + {"BCM43341", 100}, + {(const char *)NULL, 200} // Giving the generic fw settlement delay setting. +}; + +/* + * NOTICE: + * If the platform plans to run I2S interface bus over I2S/PCM port of the + * BT Controller with the Host AP, explicitly set "SCO_USE_I2S_INTERFACE = TRUE" + * in the correspodning include/vnd_.txt file. + * Otherwise, leave SCO_USE_I2S_INTERFACE undefined in the vnd_.txt file. + * And, PCM interface will be set as the default bus format running over I2S/PCM + * port. + */ +#if (defined(SCO_USE_I2S_INTERFACE) && SCO_USE_I2S_INTERFACE == TRUE) +static uint8_t sco_bus_interface = SCO_INTERFACE_I2S; +#else +static uint8_t sco_bus_interface = SCO_INTERFACE_PCM; +#endif + +#define INVALID_SCO_CLOCK_RATE 0xFF +static uint8_t sco_bus_clock_rate = INVALID_SCO_CLOCK_RATE; +static uint8_t sco_bus_wbs_clock_rate = INVALID_SCO_CLOCK_RATE; + +#if (FW_AUTO_DETECTION == TRUE) +#define FW_TABLE_VERSION "v1.1 20161117" +static const fw_auto_detection_entry_t fw_auto_detection_table[] = { + {"4343A0", "BCM43438A0"}, // AP6212 + {"BCM43430A1", "BCM43438A1"}, // AP6212A + {"BCM20702A", "BCM20710A1"}, // AP6210B + {"BCM4335C0", "BCM4339A0"}, // AP6335 + {"BCM4330B1", "BCM40183B2"}, // AP6330 + {"BCM4324B3", "BCM43241B4"}, // AP62X2 + {"BCM4350C0", "BCM4354A1"}, // AP6354 + {"BCM4354A2", "BCM4356A2"}, // AP6356 + {"BCM4345C0", "BCM4345C0"}, // AP6255 + {"BCM4345C5", "BCM4345C5"}, // AP6256 + {"BCM43430B0", "BCM4343B0"}, // AP6236 + {"BCM4359C0", "BCM4359C0"}, // AP6359 + {"BCM4349B1", "BCM4359B1"}, // AP6359 + {NULL, NULL} +}; +#endif + +/****************************************************************************** +** Static functions +******************************************************************************/ +static void hw_sco_i2spcm_config(uint16_t codec); +static void hw_sco_i2spcm_config_from_command(void *p_mem, uint16_t codec); + +/****************************************************************************** +** Controller Initialization Static Functions +******************************************************************************/ + +/******************************************************************************* +** +** Function look_up_fw_settlement_delay +** +** Description If FW_PATCH_SETTLEMENT_DELAY_MS has not been explicitly +** re-defined in the platform specific build-time configuration +** file, we will search into the look-up table for a +** recommended firmware settlement delay value. +** +** Although the settlement time might be also related to board +** configurations such as the crystal clocking speed. +** +** Returns Firmware settlement delay +** +*******************************************************************************/ +uint32_t look_up_fw_settlement_delay(void) +{ + uint32_t ret_value; + fw_settlement_entry_t *p_entry; + + if (FW_PATCH_SETTLEMENT_DELAY_MS > 0) + ret_value = FW_PATCH_SETTLEMENT_DELAY_MS; +#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE) + else if (fw_patch_settlement_delay >= 0) { + ret_value = fw_patch_settlement_delay; + } +#endif + else { + p_entry = (fw_settlement_entry_t *)fw_settlement_table; + + while (p_entry->chipset_name != NULL) { + if (strstr(hw_cfg_cb.local_chip_name, p_entry->chipset_name) != NULL) { + break; + } + + p_entry++; + } + + ret_value = p_entry->delay_time; + } + + BTHWDBG("Settlement delay -- %d ms", ret_value); + + return (ret_value); +} + +/******************************************************************************* +** +** Function ms_delay +** +** Description sleep unconditionally for timeout milliseconds +** +** Returns None +** +*******************************************************************************/ +void ms_delay(uint32_t timeout) +{ + struct timespec delay; + int err; + + if (timeout == 0) + return; + + delay.tv_sec = timeout / BT_VENDOR_TIME_RAIDX; + delay.tv_nsec = BT_VENDOR_TIME_RAIDX * BT_VENDOR_TIME_RAIDX * (timeout % BT_VENDOR_TIME_RAIDX); + + /* [u]sleep can't be used because it uses SIGALRM */ + do { + err = nanosleep(&delay, &delay); + } while (err < 0 && errno == EINTR); +} + +/******************************************************************************* +** +** Function line_speed_to_userial_baud +** +** Description helper function converts line speed number into USERIAL baud +** rate symbol +** +** Returns unit8_t (USERIAL baud symbol) +** +*******************************************************************************/ +uint8_t line_speed_to_userial_baud(uint32_t line_speed) +{ + uint8_t baud; + + if (line_speed == USERIAL_LINESPEED_4M) + baud = USERIAL_BAUD_4M; + else if (line_speed == USERIAL_LINESPEED_3M) + baud = USERIAL_BAUD_3M; + else if (line_speed == USERIAL_LINESPEED_2M) + baud = USERIAL_BAUD_2M; + else if (line_speed == USERIAL_LINESPEED_1_5M) + baud = USERIAL_BAUD_1_5M; + else if (line_speed == USERIAL_LINESPEED_1M) + baud = USERIAL_BAUD_1M; + else if (line_speed == USERIAL_LINESPEED_921600) + baud = USERIAL_BAUD_921600; + else if (line_speed == USERIAL_LINESPEED_460800) + baud = USERIAL_BAUD_460800; + else if (line_speed == USERIAL_LINESPEED_230400) + baud = USERIAL_BAUD_230400; + else if (line_speed == USERIAL_LINESPEED_115200) + baud = USERIAL_BAUD_115200; + else if (line_speed == USERIAL_LINESPEED_57600) + baud = USERIAL_BAUD_57600; + else if (line_speed == USERIAL_LINESPEED_19200) + baud = USERIAL_BAUD_19200; + else if (line_speed == USERIAL_LINESPEED_9600) + baud = USERIAL_BAUD_9600; + else if (line_speed == USERIAL_LINESPEED_1200) + baud = USERIAL_BAUD_1200; + else if (line_speed == USERIAL_LINESPEED_600) + baud = USERIAL_BAUD_600; + else { + HILOGE("userial vendor: unsupported baud speed %d", line_speed); + baud = USERIAL_BAUD_115200; + } + + return baud; +} + +/******************************************************************************* +** +** Function hw_strncmp +** +** Description Used to compare two strings in caseless +** +** Returns 0: match, otherwise: not match +** +*******************************************************************************/ +static int hw_strncmp(const char *p_str1, const char *p_str2, const int len) +{ + int i; + + if (!p_str1 || !p_str2) { + return (1); + } + + for (i = 0; i < len; i++) { + if (toupper(p_str1[i]) != toupper(p_str2[i])) { + return (i + 1); + } + } + + return 0; +} + +/******************************************************************************* +** +** Function hw_config_set_bdaddr +** +** Description Program controller's Bluetooth Device Address +** +** Returns xmit bytes +** +*******************************************************************************/ +static ssize_t hw_config_set_bdaddr(HC_BT_HDR *p_buf) +{ + uint8_t retval = FALSE; + uint8_t *p = (uint8_t *)(p_buf + 1); + int i = BD_ADDR_LEN; + + UINT16_TO_STREAM(p, HCI_VSC_WRITE_BD_ADDR); + *p++ = BD_ADDR_LEN; /* parameter length */ + *p++ = vnd_local_bd_addr[--i]; + *p++ = vnd_local_bd_addr[--i]; + *p++ = vnd_local_bd_addr[--i]; + *p++ = vnd_local_bd_addr[--i]; + *p++ = vnd_local_bd_addr[--i]; + *p = vnd_local_bd_addr[--i]; + + p_buf->len = HCI_CMD_PREAMBLE_SIZE + BD_ADDR_LEN; + hw_cfg_cb.state = HW_CFG_SET_BD_ADDR; + + retval = bt_vendor_cbacks->xmit_cb(HCI_VSC_WRITE_BD_ADDR, p_buf); + + return (retval); +} + +#if (USE_CONTROLLER_BDADDR == TRUE) +/******************************************************************************* +** +** Function hw_config_read_bdaddr +** +** Description Read controller's Bluetooth Device Address +** +** Returns xmit bytes +** +*******************************************************************************/ +static ssize_t hw_config_read_bdaddr(HC_BT_HDR *p_buf) +{ + uint8_t retval = FALSE; + uint8_t *p = (uint8_t *)(p_buf + 1); + + UINT16_TO_STREAM(p, HCI_READ_LOCAL_BDADDR); + *p = 0; /* parameter length */ + + p_buf->len = HCI_CMD_PREAMBLE_SIZE; + hw_cfg_cb.state = HW_CFG_READ_BD_ADDR; + + retval = bt_vendor_cbacks->xmit_cb(HCI_READ_LOCAL_BDADDR, p_buf); + + return (retval); +} +#endif // (USE_CONTROLLER_BDADDR == TRUE) + +typedef void (*tTIMER_HANDLE_CBACK)(union sigval sigval_value); + +static timer_t OsAllocateTimer(tTIMER_HANDLE_CBACK timer_callback) +{ + struct sigevent sigev; + timer_t timerid; + + (void)memset_s(&sigev, sizeof(struct sigevent), 0, sizeof(struct sigevent)); + // Create the POSIX timer to generate signo + sigev.sigev_notify = SIGEV_THREAD; + sigev.sigev_notify_function = timer_callback; + sigev.sigev_value.sival_ptr = &timerid; + + // Create the Timer using timer_create signal + + if (timer_create(CLOCK_REALTIME, &sigev, &timerid) == 0) { + return timerid; + } else { + HILOGE("timer_create error!"); + return (timer_t)-1; + } +} + +int OsFreeTimer(timer_t timerid) +{ + int ret = 0; + ret = timer_delete(timerid); + if (ret != 0) { + HILOGE("timer_delete fail with errno(%d)", errno); + } + + return ret; +} + +static int OsStartTimer(timer_t timerid, int msec, int mode) +{ + struct itimerspec itval; + + itval.it_value.tv_sec = msec / BT_VENDOR_TIME_RAIDX; + itval.it_value.tv_nsec = (long)(msec % BT_VENDOR_TIME_RAIDX) * (BT_VENDOR_TIME_RAIDX * BT_VENDOR_TIME_RAIDX); + + if (mode == 1) { + itval.it_interval.tv_sec = itval.it_value.tv_sec; + itval.it_interval.tv_nsec = itval.it_value.tv_nsec; + } else { + itval.it_interval.tv_sec = 0; + itval.it_interval.tv_nsec = 0; + } + + // Set the Timer when to expire through timer_settime + + if (timer_settime(timerid, 0, &itval, NULL) != 0) { + HILOGE("time_settime error!"); + return -1; + } + + return 0; +} + +static timer_t localtimer = 0; +static void local_timer_handler(union sigval sigev_value) +{ + bt_vendor_cbacks->init_cb(BTC_OP_RESULT_SUCCESS); + OsFreeTimer(localtimer); +} +static void start_fwcfg_cbtimer(void) +{ + if (localtimer == 0) { + localtimer = OsAllocateTimer(local_timer_handler); + } + OsStartTimer(localtimer, BT_VENDOR_CFG_TIMEDELAY_, 0); +} + +void hw_sco_config(void); + +/******************************************************************************* +** +** Function hw_config_cback +** +** Description Callback function for controller configuration +** +** Returns None +** +*******************************************************************************/ +void hw_config_cback(void *p_mem) +{ + HC_BT_HDR *p_evt_buf = (HC_BT_HDR *)p_mem; + char *p_name, *p_tmp; + uint8_t *p, status; + uint16_t opcode; + HC_BT_HDR *p_buf = NULL; + ssize_t xmit_bytes = 0; + int i; + int delay = 100; +#if (USE_CONTROLLER_BDADDR == TRUE) + const uint8_t null_bdaddr[BD_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; +#endif + + status = *((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE); + p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE; + STREAM_TO_UINT16(opcode, p); + + /* Ask a new buffer big enough to hold any HCI commands sent in here */ + if ((status == 0) && bt_vendor_cbacks) + p_buf = (HC_BT_HDR *)bt_vendor_cbacks->alloc(BT_HC_HDR_SIZE + HCI_CMD_MAX_LEN); + + if (p_buf != NULL) { + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; + p_buf->offset = 0; + p_buf->len = 0; + p_buf->layer_specific = 0; + + p = (uint8_t *)(p_buf + 1); + switch (hw_cfg_cb.state) { + case HW_CFG_SET_UART_BAUD_1: + /* update baud rate of host's UART port */ + HILOGI("bt vendor lib: set UART baud %i", UART_TARGET_BAUD_RATE); + userial_vendor_set_baud(line_speed_to_userial_baud(UART_TARGET_BAUD_RATE)); +#if 0 + /* read local name */ + UINT16_TO_STREAM(p, HCI_READ_LOCAL_NAME); + *p = 0; /* parameter length */ + + p_buf->len = HCI_CMD_PREAMBLE_SIZE; + hw_cfg_cb.state = HW_CFG_READ_LOCAL_NAME; + + xmit_bytes = bt_vendor_cbacks->xmit_cb(HCI_READ_LOCAL_NAME, p_buf); + break; +#endif + case HW_CFG_READ_LOCAL_NAME: +#if 0 + p_tmp = p_name = (char *)(p_evt_buf + 1) + + HCI_EVT_CMD_CMPL_LOCAL_NAME_STRING; + + for (i = 0; (i < LOCAL_NAME_BUFFER_LEN) || (*(p_name + i) != 0); i++) + *(p_name + i) = toupper(*(p_name + i)); + + if ((p_name = strstr(p_name, "BCM")) != NULL) { + strncpy(hw_cfg_cb.local_chip_name, p_name, + LOCAL_NAME_BUFFER_LEN - 1); +#ifdef USE_BLUETOOTH_BCM4343 + } else if ((p_name = strstr(p_tmp, "4343")) != NULL) { + snprintf(hw_cfg_cb.local_chip_name, + LOCAL_NAME_BUFFER_LEN - 1, "BCM%s", p_name); + strncpy(p_name, hw_cfg_cb.local_chip_name, + LOCAL_NAME_BUFFER_LEN - 1); + } +#endif + else { + strncpy(hw_cfg_cb.local_chip_name, "UNKNOWN", + LOCAL_NAME_BUFFER_LEN - 1); + p_name = p_tmp; + } + + hw_cfg_cb.local_chip_name[LOCAL_NAME_BUFFER_LEN - 1] = 0; + + BTHWDBG("Chipset %s", hw_cfg_cb.local_chip_name); +#endif + { + // /vendor/etc/firmware + p_name = FW_PATCHFILE_LOCATION "BCM4362A2.hcd"; + if ((hw_cfg_cb.fw_fd = open(p_name, O_RDONLY)) == -1) { + HILOGE("vendor lib preload failed to open [%s]", p_name); + } else { + /* vsc_download_minidriver */ + UINT16_TO_STREAM(p, HCI_VSC_DOWNLOAD_MINIDRV); + *p = 0; /* parameter length */ + + p_buf->len = HCI_CMD_PREAMBLE_SIZE; + hw_cfg_cb.state = HW_CFG_DL_MINIDRIVER; + + xmit_bytes = bt_vendor_cbacks->xmit_cb(HCI_VSC_DOWNLOAD_MINIDRV, p_buf); + } + } + + if (xmit_bytes <= 0) { + HILOGE("vendor lib preload failed to locate firmware patch file and set bdaddr"); + xmit_bytes = hw_config_set_bdaddr(p_buf); + } + break; + + case HW_CFG_DL_MINIDRIVER: + /* give time for placing firmware in download mode */ + ms_delay(50); + hw_cfg_cb.state = HW_CFG_DL_FW_PATCH; + /* fall through intentionally */ + case HW_CFG_DL_FW_PATCH: + // HILOGD("HW_CFG_DL_FW_PATCH, opcode:0x%02x", opcode); + p_buf->len = read(hw_cfg_cb.fw_fd, p, HCI_CMD_PREAMBLE_SIZE); + if (p_buf->len > 0) { + if ((p_buf->len < HCI_CMD_PREAMBLE_SIZE) || + (opcode == HCI_VSC_LAUNCH_RAM)) { + HILOGW("firmware patch file might be altered!"); + } else { + p_buf->len += read(hw_cfg_cb.fw_fd, + p + HCI_CMD_PREAMBLE_SIZE, + *(p + HCD_REC_PAYLOAD_LEN_BYTE)); + STREAM_TO_UINT16(opcode, p); + xmit_bytes = bt_vendor_cbacks->xmit_cb(opcode, p_buf); + break; + } + } + + close(hw_cfg_cb.fw_fd); + hw_cfg_cb.fw_fd = -1; + + /* Normally the firmware patch configuration file + * sets the new starting baud rate at 115200. + * So, we need update host's baud rate accordingly. + */ + HILOGI("bt vendor lib: set UART baud 115200"); + userial_vendor_set_baud(USERIAL_BAUD_115200); + + /* Next, we would like to boost baud rate up again + * to desired working speed. + */ + hw_cfg_cb.f_set_baud_2 = TRUE; + + /* Check if we need to pause a few hundred milliseconds + * before sending down any HCI command. + */ + delay = look_up_fw_settlement_delay(); + HILOGI("Setting fw settlement delay to %d ", delay); + ms_delay(delay); + + p_buf->len = HCI_CMD_PREAMBLE_SIZE; + UINT16_TO_STREAM(p, HCI_RESET); + *p = 0; /* parameter length */ + hw_cfg_cb.state = HW_CFG_START; + xmit_bytes = bt_vendor_cbacks->xmit_cb(HCI_RESET, p_buf); + break; + + case HW_CFG_START: + if (UART_TARGET_BAUD_RATE > 3000000) { /* 3000000 */ + /* set UART clock to 48MHz */ + UINT16_TO_STREAM(p, HCI_VSC_WRITE_UART_CLOCK_SETTING); + *p++ = 1; /* parameter length */ + *p = 1; /* (1,"UART CLOCK 48 MHz")(2,"UART CLOCK 24 MHz") */ + + p_buf->len = HCI_CMD_PREAMBLE_SIZE + 1; + hw_cfg_cb.state = HW_CFG_SET_UART_CLOCK; + + xmit_bytes = bt_vendor_cbacks->xmit_cb(HCI_VSC_WRITE_UART_CLOCK_SETTING, p_buf); + break; + } + /* fall through intentionally */ + case HW_CFG_SET_UART_CLOCK: + /* set controller's UART baud rate to 3M */ + UINT16_TO_STREAM(p, HCI_VSC_UPDATE_BAUDRATE); + *p++ = UPDATE_BAUDRATE_CMD_PARAM_SIZE; /* parameter length */ + *p++ = 0; /* encoded baud rate */ + *p++ = 0; /* use encoded form */ + UINT32_TO_STREAM(p, UART_TARGET_BAUD_RATE); + + p_buf->len = HCI_CMD_PREAMBLE_SIZE + + UPDATE_BAUDRATE_CMD_PARAM_SIZE; + hw_cfg_cb.state = (hw_cfg_cb.f_set_baud_2) ? HW_CFG_SET_UART_BAUD_2 : HW_CFG_SET_UART_BAUD_1; + + xmit_bytes = bt_vendor_cbacks->xmit_cb(HCI_VSC_UPDATE_BAUDRATE, p_buf); + break; + + case HW_CFG_SET_UART_BAUD_2: + /* update baud rate of host's UART port */ + HILOGI("bt vendor lib: set UART baud %i", UART_TARGET_BAUD_RATE); + userial_vendor_set_baud( + line_speed_to_userial_baud(UART_TARGET_BAUD_RATE)); + +#if (USE_CONTROLLER_BDADDR == TRUE) + if ((xmit_bytes = hw_config_read_bdaddr(p_buf)) > 0) + break; +#else + if ((xmit_bytes = hw_config_set_bdaddr(p_buf)) > 0) + break; +#endif + /* fall through intentionally */ + case HW_CFG_SET_BD_ADDR: + HILOGI("vendor lib fwcfg completed"); + bt_vendor_cbacks->dealloc(p_buf); + // bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS); + hw_sco_config(); + start_fwcfg_cbtimer(); + + hw_cfg_cb.state = 0; + + if (hw_cfg_cb.fw_fd != -1) { + close(hw_cfg_cb.fw_fd); + hw_cfg_cb.fw_fd = -1; + } + + xmit_bytes = 1; + break; + +#if (USE_CONTROLLER_BDADDR == TRUE) + case HW_CFG_READ_BD_ADDR: + p_tmp = (char *)(p_evt_buf + 1) + + HCI_EVT_CMD_CMPL_LOCAL_BDADDR_ARRAY; + HILOGI("entering HW_CFG_READ_BD_ADDR"); + if (memcmp(p_tmp, null_bdaddr, BD_ADDR_LEN) == 0) { + HILOGI("entering HW_CFG_READ_BD_ADDR"); + // Controller does not have a valid OTP BDADDR! + // Set the BTIF initial BDADDR instead. + if ((xmit_bytes = hw_config_set_bdaddr(p_buf)) > 0) + break; + } else { + HILOGI("Controller OTP bdaddr %02X:%02X:%02X:%02X:%02X:%02X", + *(p_tmp + 5), *(p_tmp + 4), *(p_tmp + 3), + *(p_tmp + 2), *(p_tmp + 1), *p_tmp); + } + + HILOGI("vendor lib fwcfg completed"); + bt_vendor_cbacks->dealloc(p_buf); + // bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS); + hw_sco_config(); + start_fwcfg_cbtimer(); + + hw_cfg_cb.state = 0; + + if (hw_cfg_cb.fw_fd != -1) { + close(hw_cfg_cb.fw_fd); + hw_cfg_cb.fw_fd = -1; + } + + xmit_bytes = 1; + break; +#endif // (USE_CONTROLLER_BDADDR == TRUE) + } // switch(hw_cfg_cb.state) + } // if (p_buf != NULL) + + /* Free the RX event buffer */ + // if (bt_vendor_cbacks) + // bt_vendor_cbacks->dealloc(p_evt_buf); + + if (xmit_bytes <= 0) { + HILOGE("vendor lib fwcfg aborted!!!"); + if (bt_vendor_cbacks) { + if (p_buf != NULL) + bt_vendor_cbacks->dealloc(p_buf); + + bt_vendor_cbacks->init_cb(BTC_OP_RESULT_FAIL); + } + + if (hw_cfg_cb.fw_fd != -1) { + close(hw_cfg_cb.fw_fd); + hw_cfg_cb.fw_fd = -1; + } + + hw_cfg_cb.state = 0; + } +} + +/****************************************************************************** +** LPM Static Functions +******************************************************************************/ + +/******************************************************************************* +** +** Function hw_lpm_ctrl_cback +** +** Description Callback function for lpm enable/disable request +** +** Returns None +** +*******************************************************************************/ +void hw_lpm_ctrl_cback(void *p_mem) +{ + HC_BT_HDR *p_evt_buf = (HC_BT_HDR *)p_mem; + bt_op_result_t status = BTC_OP_RESULT_FAIL; + + if (*((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE) == 0) { + status = BTC_OP_RESULT_SUCCESS; + } + + if (bt_vendor_cbacks) { + // bt_vendor_cbacks->dealloc(p_evt_buf); + } +} + +#if (SCO_CFG_INCLUDED == TRUE) +/***************************************************************************** +** SCO Configuration Static Functions +*****************************************************************************/ + +static void hw_sco_i2spcm_proc_interface_param(void) +{ + bt_op_result_t status = BTC_OP_RESULT_FAIL; + uint8_t ret = FALSE; + uint8_t *p; + HC_BT_HDR *p_buf = NULL; + + /* Ask a new buffer to hold WRITE_SCO_PCM_INT_PARAM command */ + if (bt_vendor_cbacks) { + p_buf = (HC_BT_HDR *)bt_vendor_cbacks->alloc(BT_HC_HDR_SIZE + + HCI_CMD_PREAMBLE_SIZE + SCO_PCM_PARAM_SIZE); + } + if (p_buf) { + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; + p_buf->offset = 0; + p_buf->layer_specific = 0; + p_buf->len = HCI_CMD_PREAMBLE_SIZE + SCO_PCM_PARAM_SIZE; + p = (uint8_t *)(p_buf + 1); + + /* do we need this VSC for I2S??? */ + UINT16_TO_STREAM(p, HCI_VSC_WRITE_SCO_PCM_INT_PARAM); + *p++ = SCO_PCM_PARAM_SIZE; + memcpy_s(p, &bt_sco_param, SCO_PCM_PARAM_SIZE); + if ((ret = bt_vendor_cbacks->xmit_cb(HCI_VSC_WRITE_SCO_PCM_INT_PARAM, p_buf)) == FALSE) { + bt_vendor_cbacks->dealloc(p_buf); + } else + return; + } + status = BTC_OP_RESULT_FAIL; + + HILOGI("sco I2S/PCM config interface result %d [0-Success, 1-Fail]", status); +} + +static void hw_sco_i2spcm_proc_int_param(void) +{ + bt_op_result_t status = BTC_OP_RESULT_FAIL; + uint8_t ret = FALSE; + uint8_t *p; + HC_BT_HDR *p_buf = NULL; + + /* Ask a new buffer to hold WRITE_PCM_DATA_FORMAT_PARAM command */ + if (bt_vendor_cbacks) + p_buf = (HC_BT_HDR *)bt_vendor_cbacks->alloc( + BT_HC_HDR_SIZE + HCI_CMD_PREAMBLE_SIZE + PCM_DATA_FORMAT_PARAM_SIZE); + if (p_buf) { + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; + p_buf->offset = 0; + p_buf->layer_specific = 0; + p_buf->len = HCI_CMD_PREAMBLE_SIZE + PCM_DATA_FORMAT_PARAM_SIZE; + + p = (uint8_t *)(p_buf + 1); + UINT16_TO_STREAM(p, HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM); + *p++ = PCM_DATA_FORMAT_PARAM_SIZE; + memcpy_s(p, &bt_pcm_data_fmt_param, PCM_DATA_FORMAT_PARAM_SIZE); + + if ((ret = bt_vendor_cbacks->xmit_cb(HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM, p_buf)) == FALSE) { + bt_vendor_cbacks->dealloc(p_buf); + } else + return; + } + status = BTC_OP_RESULT_FAIL; + + HILOGI("sco I2S/PCM config int result %d [0-Success, 1-Fail]", status); +} + +/******************************************************************************* +** +** Function hw_sco_i2spcm_cfg_cback +** +** Description Callback function for SCO I2S/PCM configuration request +** +** Returns None +** +*******************************************************************************/ +static void hw_sco_i2spcm_cfg_cback(void *p_mem) +{ + HC_BT_HDR *p_evt_buf = (HC_BT_HDR *)p_mem; + uint8_t *p; + uint16_t opcode; + HC_BT_HDR *p_buf = NULL; + bt_op_result_t status = BTC_OP_RESULT_FAIL; + + p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE; + STREAM_TO_UINT16(opcode, p); + + if (*((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE) == 0) { + status = BTC_OP_RESULT_SUCCESS; + } + + /* Free the RX event buffer */ + if (bt_vendor_cbacks) { + // bt_vendor_cbacks->dealloc(p_evt_buf); + } + + if (status != BTC_OP_RESULT_SUCCESS) { + return; + } + + if ((opcode == HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM) && + (sco_bus_interface == SCO_INTERFACE_PCM)) { + hw_sco_i2spcm_proc_interface_param(); + } else if ((opcode == HCI_VSC_WRITE_SCO_PCM_INT_PARAM) && + (sco_bus_interface == SCO_INTERFACE_PCM)) { + hw_sco_i2spcm_proc_int_param(); + } +} + +/******************************************************************************* +** +** Function hw_set_MSBC_codec_cback +** +** Description Callback function for setting WBS codec +** +** Returns None +** +*******************************************************************************/ +static void hw_set_MSBC_codec_cback(void *p_mem) +{ + /* whenever update the codec enable/disable, need to update I2SPCM */ + HILOGI("SCO I2S interface change the sample rate to 16K"); + hw_sco_i2spcm_config_from_command(p_mem, SCO_CODEC_MSBC); +} + +/******************************************************************************* +** +** Function hw_set_CVSD_codec_cback +** +** Description Callback function for setting NBS codec +** +** Returns None +** +*******************************************************************************/ +static void hw_set_CVSD_codec_cback(void *p_mem) +{ + /* whenever update the codec enable/disable, need to update I2SPCM */ + HILOGI("SCO I2S interface change the sample rate to 8K"); + hw_sco_i2spcm_config_from_command(p_mem, SCO_CODEC_CVSD); +} + +#endif // SCO_CFG_INCLUDED + +/***************************************************************************** +** Hardware Configuration Interface Functions +*****************************************************************************/ + +/******************************************************************************* +** +** Function hw_config_start +** +** Description Kick off controller initialization process +** +** Returns None +** +*******************************************************************************/ +void hw_config_start(void) +{ + HC_BT_HDR *p_buf = NULL; + uint8_t *p; + + hw_cfg_cb.state = 0; + hw_cfg_cb.fw_fd = -1; + hw_cfg_cb.f_set_baud_2 = FALSE; + + // bt_vendor_cbacks->init_cb(BTC_OP_RESULT_SUCCESS); + // Start from sending HCI_RESET + + if (bt_vendor_cbacks) { + p_buf = (HC_BT_HDR *)bt_vendor_cbacks->alloc(BT_HC_HDR_SIZE + + HCI_CMD_PREAMBLE_SIZE); + } + + if (p_buf) { + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; + p_buf->offset = 0; + p_buf->layer_specific = 0; + p_buf->len = HCI_CMD_PREAMBLE_SIZE; + + p = (uint8_t *)(p_buf + 1); + UINT16_TO_STREAM(p, HCI_RESET); + *p = 0; + + hw_cfg_cb.state = HW_CFG_START; + bt_vendor_cbacks->xmit_cb(HCI_RESET, p_buf); + } else { + if (bt_vendor_cbacks) { + HILOGE("vendor lib fw conf aborted [no buffer]"); + bt_vendor_cbacks->init_cb(BTC_OP_RESULT_FAIL); + } + } +} + +/******************************************************************************* +** +** Function hw_lpm_enable +** +** Description Enalbe/Disable LPM +** +** Returns TRUE/FALSE +** +*******************************************************************************/ +uint8_t hw_lpm_enable(uint8_t turn_on) +{ + HILOGD("entering hw_lpm_enable11"); + HC_BT_HDR *p_buf = NULL; + uint8_t *p; + uint8_t ret = FALSE; + + if (bt_vendor_cbacks) + p_buf = (HC_BT_HDR *)bt_vendor_cbacks->alloc(BT_HC_HDR_SIZE + + HCI_CMD_PREAMBLE_SIZE + + LPM_CMD_PARAM_SIZE); + + if (p_buf) { + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; + p_buf->offset = 0; + p_buf->layer_specific = 0; + p_buf->len = HCI_CMD_PREAMBLE_SIZE + LPM_CMD_PARAM_SIZE; + + p = (uint8_t *)(p_buf + 1); + UINT16_TO_STREAM(p, HCI_VSC_WRITE_SLEEP_MODE); + *p++ = LPM_CMD_PARAM_SIZE; /* parameter length */ + + if (turn_on) { + memcpy(p, &lpm_param, LPM_CMD_PARAM_SIZE); + upio_set(UPIO_LPM_MODE, UPIO_ASSERT, 0); + } else { + memset(p, 0, LPM_CMD_PARAM_SIZE); + upio_set(UPIO_LPM_MODE, UPIO_DEASSERT, 0); + } + + if ((ret = bt_vendor_cbacks->xmit_cb(HCI_VSC_WRITE_SLEEP_MODE, p_buf)) <= 0) { + bt_vendor_cbacks->dealloc(p_buf); + } + } + + if ((ret <= 0) && bt_vendor_cbacks) { + // bt_vendor_cbacks->lpm_cb(BT_VND_OP_RESULT_FAIL); + } + HILOGD("hw_lpm_enable ret:%d", ret); + return ret; +} + +/******************************************************************************* +** +** Function hw_lpm_get_idle_timeout +** +** Description Calculate idle time based on host stack idle threshold +** +** Returns idle timeout value +** +*******************************************************************************/ +uint32_t hw_lpm_get_idle_timeout(void) +{ + uint32_t timeout_ms; + + /* set idle time to be LPM_IDLE_TIMEOUT_MULTIPLE times of + * host stack idle threshold (in 300ms/25ms) + */ + timeout_ms = (uint32_t)lpm_param.host_stack_idle_threshold * LPM_IDLE_TIMEOUT_MULTIPLE; + timeout_ms *= BT_VENDOR_LDM_DEFAULT_IDLE; + return timeout_ms; +} + +/******************************************************************************* +** +** Function hw_lpm_set_wake_state +** +** Description Assert/Deassert BT_WAKE +** +** Returns None +** +*******************************************************************************/ +void hw_lpm_set_wake_state(uint8_t wake_assert) +{ + uint8_t state = (wake_assert) ? UPIO_ASSERT : UPIO_DEASSERT; + + upio_set(UPIO_BT_WAKE, state, lpm_param.bt_wake_polarity); +} + +#if (SCO_CFG_INCLUDED == TRUE) +/******************************************************************************* +** +** Function hw_sco_config +** +** Description Configure SCO related hardware settings +** +** Returns None +** +*******************************************************************************/ +void hw_sco_config(void) +{ + if (sco_bus_interface == SCO_INTERFACE_I2S) { + /* 'Enable' I2S mode */ + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_MODE] = 1; + + /* set nbs clock rate as the value in SCO_I2SPCM_IF_CLOCK_RATE field */ + sco_bus_clock_rate = bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_CLOCK_RATE]; + } else { + /* 'Disable' I2S mode */ + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_MODE] = 0; + + /* set nbs clock rate as the value in SCO_PCM_IF_CLOCK_RATE field */ + sco_bus_clock_rate = bt_sco_param[SCO_PCM_PARAM_IF_CLOCK_RATE]; + + /* sync up clock mode setting */ + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_MODE] = bt_sco_param[SCO_PCM_PARAM_IF_CLOCK_MODE]; + } + + if (sco_bus_wbs_clock_rate == INVALID_SCO_CLOCK_RATE) { + /* set default wbs clock rate */ + sco_bus_wbs_clock_rate = SCO_I2SPCM_IF_CLOCK_RATE4WBS; + + if (sco_bus_wbs_clock_rate < sco_bus_clock_rate) + sco_bus_wbs_clock_rate = sco_bus_clock_rate; + } + + /* + * To support I2S/PCM port multiplexing signals for sharing Bluetooth audio + * and FM on the same PCM pins, we defer Bluetooth audio (SCO/eSCO) + * configuration till SCO/eSCO is being established; + * i.e. in hw_set_audio_state() call. + * When configured as I2S only, Bluetooth audio configuration is executed + * immediately with SCO_CODEC_CVSD by default. + */ + + if (sco_bus_interface == SCO_INTERFACE_I2S) { + hw_sco_i2spcm_config(SCO_CODEC_CVSD); + } else { + hw_sco_i2spcm_config(SCO_CODEC_NONE); + } + + if (bt_vendor_cbacks) { + // bt_vendor_cbacks->scocfg_cb(BT_VND_OP_RESULT_SUCCESS); + } +} + +static void hw_sco_i2spcm_config_from_command(void *p_mem, uint16_t codec) +{ + HC_BT_HDR *p_evt_buf = (HC_BT_HDR *)p_mem; + bool command_success = *((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE) == 0; + + /* Free the RX event buffer */ + if (bt_vendor_cbacks) { + // bt_vendor_cbacks->dealloc(p_evt_buf); + } + + if (command_success) { + hw_sco_i2spcm_config(codec); + } else if (bt_vendor_cbacks) { + // bt_vendor_cbacks->audio_state_cb(BT_VND_OP_RESULT_FAIL); + } +} + +/******************************************************************************* +** +** Function hw_sco_i2spcm_config +** +** Description Configure SCO over I2S or PCM +** +** Returns None +** +*******************************************************************************/ +static void hw_sco_i2spcm_config(uint16_t codec) +{ + HC_BT_HDR *p_buf = NULL; + uint8_t *p, ret; + uint16_t cmd_u16 = HCI_CMD_PREAMBLE_SIZE + SCO_I2SPCM_PARAM_SIZE; + + if (bt_vendor_cbacks) { + p_buf = (HC_BT_HDR *)bt_vendor_cbacks->alloc(BT_HC_HDR_SIZE + cmd_u16); + } + + if (p_buf) { + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; + p_buf->offset = 0; + p_buf->layer_specific = 0; + p_buf->len = cmd_u16; + + p = (uint8_t *)(p_buf + 1); + + UINT16_TO_STREAM(p, HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM); + *p++ = SCO_I2SPCM_PARAM_SIZE; + if (codec == SCO_CODEC_CVSD) { + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_SAMPLE_RATE] = 0; /* SCO_I2SPCM_IF_SAMPLE_RATE 8k */ + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_CLOCK_RATE] = + bt_sco_param[SCO_PCM_PARAM_IF_CLOCK_RATE] = sco_bus_clock_rate; + } else if (codec == SCO_CODEC_MSBC) { + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_SAMPLE_RATE] = wbs_sample_rate; /* SCO_I2SPCM_IF_SAMPLE_RATE 16K */ + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_CLOCK_RATE] = + bt_sco_param[SCO_PCM_PARAM_IF_CLOCK_RATE] = sco_bus_wbs_clock_rate; + } else { + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_SAMPLE_RATE] = 0; /* SCO_I2SPCM_IF_SAMPLE_RATE 8k */ + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_CLOCK_RATE] = + bt_sco_param[SCO_PCM_PARAM_IF_CLOCK_RATE] = sco_bus_clock_rate; + HILOGE("wrong codec is use in hw_sco_i2spcm_config, goes default NBS"); + } + memcpy_s(p, &bt_sco_i2spcm_param, SCO_I2SPCM_PARAM_SIZE); + cmd_u16 = HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM; + HILOGI("I2SPCM config {0x%x, 0x%x, 0x%x, 0x%x}", + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_MODE], bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_ROLE], + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_SAMPLE_RATE], + bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_CLOCK_RATE]); + + if ((ret = bt_vendor_cbacks->xmit_cb(cmd_u16, p_buf)) <= 0) { + bt_vendor_cbacks->dealloc(p_buf); + } else { + return; + } + } + // bt_vendor_cbacks->audio_state_cb(BT_VND_OP_RESULT_FAIL); +} + +/******************************************************************************* +** +** Function hw_set_SCO_codec +** +** Description This functgion sends command to the controller to setup +** WBS/NBS codec for the upcoming eSCO connection. +** +** Returns -1 : Failed to send VSC +** 0 : Success +** +*******************************************************************************/ +static int hw_set_SCO_codec(uint16_t codec) +{ + HC_BT_HDR *p_buf = NULL; + uint8_t *p; + uint8_t ret; + int ret_val = 0; + return ret_val; +} + +/******************************************************************************* +** +** Function hw_set_audio_state +** +** Description This function configures audio base on provided audio state +** +** Paramters pointer to audio state structure +** +** Returns 0: ok, -1: error +** +*******************************************************************************/ +int hw_set_audio_state(bt_vendor_op_audio_state_t *p_state) +{ + int ret_val = -1; + + if (!bt_vendor_cbacks) { + return ret_val; + } + + ret_val = hw_set_SCO_codec(p_state->peer_codec); + return ret_val; +} +#endif +/******************************************************************************* +** +** Function hw_set_patch_file_path +** +** Description Set the location of firmware patch file +** +** Returns 0 : Success +** Otherwise : Fail +** +*******************************************************************************/ +int hw_set_patch_file_path(char *p_conf_name, char *p_conf_value, int param) +{ + if (strcpy_s(fw_patchfile_path, sizeof(fw_patchfile_path), p_conf_value) != 0) { + return -1; + } + return 0; +} + +/******************************************************************************* +** +** Function hw_set_patch_file_name +** +** Description Give the specific firmware patch filename +** +** Returns 0 : Success +** Otherwise : Fail +** +*******************************************************************************/ +int hw_set_patch_file_name(char *p_conf_name, char *p_conf_value, int param) +{ + if (strcpy_s(fw_patchfile_name, sizeof(fw_patchfile_name), p_conf_value) != 0) { + return -1; + } + return 0; +} + +#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE) +/******************************************************************************* +** +** Function hw_set_patch_settlement_delay +** +** Description Give the specific firmware patch settlement time in milliseconds +** +** Returns 0 : Success +** Otherwise : Fail +** +*******************************************************************************/ +int hw_set_patch_settlement_delay(char *p_conf_name, char *p_conf_value, int param) +{ + fw_patch_settlement_delay = atoi(p_conf_value); + return 0; +} +#endif // VENDOR_LIB_RUNTIME_TUNING_ENABLED + +/***************************************************************************** +** Sample Codes Section +*****************************************************************************/ + +#if (HW_END_WITH_HCI_RESET == TRUE) +/******************************************************************************* +** +** Function hw_epilog_cback +** +** Description Callback function for Command Complete Events from HCI +** commands sent in epilog process. +** +** Returns None +** +*******************************************************************************/ +void hw_epilog_cback(void *p_mem) +{ + HC_BT_HDR *p_evt_buf = (HC_BT_HDR *)p_mem; + uint8_t *p, status; + uint16_t opcode; + + status = *((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE); + p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE; + STREAM_TO_UINT16(opcode, p); + + BTHWDBG("%s Opcode:0x%04X Status: %d", __FUNCTION__, opcode, status); + + if (bt_vendor_cbacks) { + /* Must free the RX event buffer */ + // bt_vendor_cbacks->dealloc(p_evt_buf); + /* Once epilog process is done, must call epilog_cb callback + to notify caller */ + // bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS); + } +} + +/******************************************************************************* +** +** Function hw_epilog_process +** +** Description Sample implementation of epilog process +** +** Returns None +** +*******************************************************************************/ +void hw_epilog_process(void) +{ + HC_BT_HDR *p_buf = NULL; + uint8_t *p; + + BTHWDBG("hw_epilog_process"); + + /* Sending a HCI_RESET */ + if (bt_vendor_cbacks) { + /* Must allocate command buffer via HC's alloc API */ + p_buf = (HC_BT_HDR *)bt_vendor_cbacks->alloc(BT_HC_HDR_SIZE + + HCI_CMD_PREAMBLE_SIZE); + } + + if (p_buf) { + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; + p_buf->offset = 0; + p_buf->layer_specific = 0; + p_buf->len = HCI_CMD_PREAMBLE_SIZE; + + p = (uint8_t *)(p_buf + 1); + UINT16_TO_STREAM(p, HCI_RESET); + *p = 0; /* parameter length */ + + /* Send command via HC's xmit_cb API */ + bt_vendor_cbacks->xmit_cb(HCI_RESET, p_buf); + } else { + if (bt_vendor_cbacks) { + HILOGE("vendor lib epilog process aborted [no buffer]"); + } + } +} +#endif // (HW_END_WITH_HCI_RESET == TRUE) + +void hw_process_event(HC_BT_HDR *p_buf) +{ + uint16_t opcode; + uint8_t *p = (uint8_t *)(p_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE; + STREAM_TO_UINT16(opcode, p); + + HILOGI("%s, opcode:0x%04x", __FUNCTION__, opcode); + switch (opcode) { + case HCI_VSC_WRITE_BD_ADDR: +#if (USE_CONTROLLER_BDADDR == TRUE) + case HCI_READ_LOCAL_BDADDR: +#endif + case HCI_READ_LOCAL_NAME: + case HCI_VSC_DOWNLOAD_MINIDRV: + case HCI_VSC_WRITE_FIRMWARE: + case HCI_VSC_LAUNCH_RAM: + case HCI_RESET: + case HCI_VSC_WRITE_UART_CLOCK_SETTING: + case HCI_VSC_UPDATE_BAUDRATE: + hw_config_cback(p_buf); + break; + + case HCI_VSC_WRITE_SCO_PCM_INT_PARAM: + case HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM: + case HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM: + hw_sco_i2spcm_cfg_cback(p_buf); + break; + + case HCI_VSC_WRITE_SLEEP_MODE: + hw_lpm_ctrl_cback(p_buf); + break; + + case HCI_VSC_ENABLE_WBS: + break; + } + + HILOGI("%s, Complete", __FUNCTION__); +} diff --git a/vendor_phytium/tenglong_e/bluetooth/src/upio.c b/vendor_phytium/tenglong_e/bluetooth/src/upio.c new file mode 100755 index 0000000000000000000000000000000000000000..03cb83d95245aab131f1ad0097a1198978249869 --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/src/upio.c @@ -0,0 +1,496 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: upio.c + * + * Description: Contains I/O functions, like + * rfkill control + * BT_WAKE/HOST_WAKE control + * + ******************************************************************************/ + +#define LOG_TAG "bt_upio" + +#include +#include +#include +#include +#include +#include +#include +#include "bt_vendor_brcm.h" +#include "userial_vendor.h" +#include "upio.h" + +/****************************************************************************** +** Constants & Macros +******************************************************************************/ + +#ifndef UPIO_DBG +#define UPIO_DBG FALSE +#endif + +#if (UPIO_DBG == TRUE) +#define UPIODBG(param, ...) \ + { \ + HILOGD(param, ##__VA_ARGS__); \ + } +#else +#define UPIODBG(param, ...) \ + { \ + HILOGD(param, ##__VA_ARGS__); \ + } +#endif + +/****************************************************************************** +** Local type definitions +******************************************************************************/ + +#if (BT_WAKE_VIA_PROC == TRUE) + +/* proc fs node for enable/disable lpm mode */ +#ifndef VENDOR_LPM_PROC_NODE +#define VENDOR_LPM_PROC_NODE "/proc/bluetooth/sleep/lpm" +#endif + +/* proc fs node for notifying write request */ +#ifndef VENDOR_BTWRITE_PROC_NODE +#define VENDOR_BTWRITE_PROC_NODE "/proc/bluetooth/sleep/btwrite" +#endif + +/* + * Maximum btwrite assertion holding time without consecutive btwrite kicking. + * This value is correlative(shorter) to the in-working timeout period set in + * the bluesleep LPM code. The current value used in bluesleep is 10sec. + */ +#ifndef PROC_BTWRITE_TIMER_TIMEOUT_MS +#define PROC_BTWRITE_TIMER_TIMEOUT_MS 8000 +#endif + +/* lpm proc control block */ +typedef struct { + uint8_t btwrite_active; + uint8_t timer_created; + timer_t timer_id; + uint32_t timeout_ms; +} vnd_lpm_proc_cb_t; + +static vnd_lpm_proc_cb_t lpm_proc_cb; +#endif + +/****************************************************************************** +** Static variables +******************************************************************************/ + +static uint8_t upio_state[UPIO_MAX_COUNT]; +static int rfkill_id = -1; +static int bt_emul_enable = 0; +static char rfkill_state_path[128]; + +/****************************************************************************** +** Static functions +******************************************************************************/ + +/* for friendly debugging outpout string */ +static char *lpm_mode[] = { + "UNKNOWN", + "disabled", + "enabled" +}; + +static char *lpm_state[] = { + "UNKNOWN", + "de-asserted", + "asserted" +}; + +/***************************************************************************** +** Bluetooth On/Off Static Functions +*****************************************************************************/ +static int is_emulator_context(void) +{ + return 0; +} + +static int is_rfkill_disabled(void) +{ + return UPIO_BT_POWER_OFF; +} + +static int init_rfkill(void) +{ + char path[64]; + char buf[16]; + int fd, sz, id; + + for (id = 0;; id++) { + if (snprintf_s(path, sizeof(path), sizeof(path), "/sys/class/rfkill/rfkill%d/type", id) < 0) { + return -1; + } + + fd = open(path, O_RDONLY); + if (fd < 0) { + HILOGE("init_rfkill : open(%s) failed: %s (%d)\n", + path, strerror(errno), errno); + return -1; + } + + sz = read(fd, &buf, sizeof(buf)); + close(fd); + + if (sz >= (int)strlen("bluetooth") && memcmp(buf, "bluetooth", strlen("bluetooth")) == 0) { + rfkill_id = id; + break; + } + } + + (void)sprintf_s(rfkill_state_path, sizeof(rfkill_state_path), "/sys/class/rfkill/rfkill%d/state", rfkill_id); + return 0; +} + +/***************************************************************************** +** LPM Static Functions +*****************************************************************************/ + +#if (BT_WAKE_VIA_PROC == TRUE) +/******************************************************************************* +** +** Function proc_btwrite_timeout +** +** Description Timeout thread of proc/.../btwrite assertion holding timer +** +** Returns None +** +*******************************************************************************/ +static void proc_btwrite_timeout(union sigval arg) +{ + UPIODBG("..%s..", __FUNCTION__); + lpm_proc_cb.btwrite_active = FALSE; + /* drive LPM down; this timer should fire only when BT is awake; */ + upio_set(UPIO_BT_WAKE, UPIO_DEASSERT, 1); +} + +/****************************************************************************** + ** + ** Function upio_start_stop_timer + ** + ** Description Arm user space timer in case lpm is left asserted + ** + ** Returns None + ** + *****************************************************************************/ +void upio_start_stop_timer(int action) +{ + struct itimerspec ts; + + if (action == UPIO_ASSERT) { + lpm_proc_cb.btwrite_active = TRUE; + if (lpm_proc_cb.timer_created == TRUE) { + ts.it_value.tv_sec = PROC_BTWRITE_TIMER_TIMEOUT_MS / BT_VENDOR_TIME_RAIDX; + ts.it_value.tv_nsec = BT_VENDOR_TIME_RAIDX * BT_VENDOR_TIME_RAIDX * + (PROC_BTWRITE_TIMER_TIMEOUT_MS % BT_VENDOR_TIME_RAIDX); + ts.it_interval.tv_sec = 0; + ts.it_interval.tv_nsec = 0; + } + } else { + /* unarm timer if writing 0 to lpm; reduce unnecessary user space wakeup */ + (void)memset_s(&ts, sizeof(ts), 0, sizeof(ts)); + } + + if (timer_settime(lpm_proc_cb.timer_id, 0, &ts, 0) == 0) { + UPIODBG("%s : timer_settime success", __FUNCTION__); + } else { + UPIODBG("%s : timer_settime failed", __FUNCTION__); + } +} +#endif + +/***************************************************************************** +** UPIO Interface Functions +*****************************************************************************/ + +/******************************************************************************* +** +** Function upio_init +** +** Description Initialization +** +** Returns None +** +*******************************************************************************/ +void upio_init(void) +{ + memset_s(upio_state, sizeof(upio_state), UPIO_UNKNOWN, UPIO_MAX_COUNT); +#if (BT_WAKE_VIA_PROC == TRUE) + memset_s(&lpm_proc_cb, sizeof(vnd_lpm_proc_cb_t), 0, sizeof(vnd_lpm_proc_cb_t)); +#endif +} + +/******************************************************************************* +** +** Function upio_cleanup +** +** Description Clean up +** +** Returns None +** +*******************************************************************************/ +void upio_cleanup(void) +{ +#if (BT_WAKE_VIA_PROC == TRUE) + if (lpm_proc_cb.timer_created == TRUE) + timer_delete(lpm_proc_cb.timer_id); + + lpm_proc_cb.timer_created = FALSE; +#endif +} + +/******************************************************************************* +** +** Function upio_set_bluetooth_power +** +** Description Interact with low layer driver to set Bluetooth power +** on/off. +** +** Returns 0 : SUCCESS or Not-Applicable +** <0 : ERROR +** +*******************************************************************************/ +int upio_set_bluetooth_power(int on) +{ + int sz; + int fd = -1; + int ret = -1; + char buffer = '0'; + + switch (on) { + case UPIO_BT_POWER_OFF: + buffer = '0'; + break; + + case UPIO_BT_POWER_ON: + buffer = '1'; + break; + default: + return 0; + } + + if (is_emulator_context()) { + /* if new value is same as current, return -1 */ + if (bt_emul_enable == on) { + return ret; + } + + UPIODBG("set_bluetooth_power [emul] %d", on); + bt_emul_enable = on; + return 0; + } + + /* check if we have rfkill interface */ + if (is_rfkill_disabled()) { + return 0; + } + + if (rfkill_id == -1) { + if (init_rfkill()) { + return ret; + } + } + + fd = open(rfkill_state_path, O_WRONLY); + if (fd < 0) { + HILOGE("set_bluetooth_power : open(%s) for write failed: %s (%d)", + rfkill_state_path, strerror(errno), errno); + return ret; + } + + sz = write(fd, &buffer, 1); + if (sz < 0) { + HILOGE("set_bluetooth_power : write(%s) failed: %s (%d)", + rfkill_state_path, strerror(errno), errno); + } else { + ret = 0; + } + + if (fd >= 0) { + close(fd); + } + + return ret; +} + +/******************************************************************************* +** +** Function upio_set +** +** Description Set i/o based on polarity +** +** Returns None +** +*******************************************************************************/ +void upio_set(uint8_t pio, uint8_t action, uint8_t polarity) +{ + int rc; +#if (BT_WAKE_VIA_PROC == TRUE) + int fd = -1; + char buffer; +#endif + + UPIODBG("%s : pio %d action %d, polarity %d", __FUNCTION__, pio, action, polarity); + switch (pio) { + case UPIO_LPM_MODE: + if (upio_state[UPIO_LPM_MODE] == action) { + UPIODBG("LPM is %s already", lpm_mode[action]); + return; + } + + upio_state[UPIO_LPM_MODE] = action; + +#if (BT_WAKE_VIA_PROC == TRUE) + fd = open(VENDOR_LPM_PROC_NODE, O_WRONLY); + if (fd < 0) { + LOGE("upio_set : open(%s) for write failed: %s (%d)", + VENDOR_LPM_PROC_NODE, strerror(errno), errno); + return; + } + + if (action == UPIO_ASSERT) { + buffer = '1'; + } else { + buffer = '0'; + + // delete btwrite assertion holding timer + if (lpm_proc_cb.timer_created == TRUE) { + timer_delete(lpm_proc_cb.timer_id); + lpm_proc_cb.timer_created = FALSE; + } + } + + if (write(fd, &buffer, 1) < 0) { + LOGE("upio_set : write(%s) failed: %s (%d)", + VENDOR_LPM_PROC_NODE, strerror(errno),errno); + } +#if (PROC_BTWRITE_TIMER_TIMEOUT_MS != 0) + else { + if (action == UPIO_ASSERT) { + // create btwrite assertion holding timer + if (lpm_proc_cb.timer_created == FALSE) { + int status; + struct sigevent se; + + se.sigev_notify = SIGEV_THREAD; + se.sigev_value.sival_ptr = &lpm_proc_cb.timer_id; + se.sigev_notify_function = proc_btwrite_timeout; + se.sigev_notify_attributes = NULL; + + status = timer_create(CLOCK_MONOTONIC, &se, + &lpm_proc_cb.timer_id); + if (status == 0) + lpm_proc_cb.timer_created = TRUE; + } + } + } +#endif + + if (fd >= 0) + close(fd); +#endif + break; + + case UPIO_BT_WAKE: + if (upio_state[UPIO_BT_WAKE] == action) { + UPIODBG("BT_WAKE is %s already", lpm_state[action]); + +#if (BT_WAKE_VIA_PROC == TRUE) + if (lpm_proc_cb.btwrite_active == TRUE) + /* + * The proc btwrite node could have not been updated for + * certain time already due to heavy downstream path flow. + * In this case, we want to explicity touch proc btwrite + * node to keep the bt_wake assertion in the LPM kernel + * driver. The current kernel bluesleep LPM code starts + * a 10sec internal in-activity timeout timer before it + * attempts to deassert BT_WAKE line. + */ + return; +#else + return; +#endif + } + + upio_state[UPIO_BT_WAKE] = action; + +#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE) + + userial_vendor_ioctl( ( (action==UPIO_ASSERT) ? \ + USERIAL_OP_ASSERT_BT_WAKE : USERIAL_OP_DEASSERT_BT_WAKE),\ + NULL); + +#elif (BT_WAKE_VIA_PROC == TRUE) + + /* + * Kick proc btwrite node only at UPIO_ASSERT + */ +#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == FALSE) + if (action == UPIO_DEASSERT) + return; +#endif + fd = open(VENDOR_BTWRITE_PROC_NODE, O_WRONLY); + if (fd < 0) { + LOGE("upio_set : open(%s) for write failed: %s (%d)", + VENDOR_BTWRITE_PROC_NODE, strerror(errno), errno); + return; + } +#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == TRUE) + if (action == UPIO_DEASSERT) + buffer = '0'; + else +#endif + buffer = '1'; + + if (write(fd, &buffer, 1) < 0) { + LOGE("upio_set : write(%s) failed: %s (%d)", + VENDOR_BTWRITE_PROC_NODE, strerror(errno), errno); + } +#if (PROC_BTWRITE_TIMER_TIMEOUT_MS != 0) + else { + /* arm user space timer based on action */ + upio_start_stop_timer(action); + } +#endif + +#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == TRUE) + lpm_proc_cb.btwrite_active = TRUE; +#endif + + UPIODBG("%s: proc btwrite assertion, buffer: %c, timer_armed %d %d", + __FUNCTION__, buffer, lpm_proc_cb.btwrite_active, lpm_proc_cb.timer_created); + + if (fd >= 0) + close(fd); +#endif + + break; + + case UPIO_HOST_WAKE: + UPIODBG("upio_set: UPIO_HOST_WAKE"); + break; + } +} diff --git a/vendor_phytium/tenglong_e/bluetooth/src/userial_vendor.c b/vendor_phytium/tenglong_e/bluetooth/src/userial_vendor.c new file mode 100755 index 0000000000000000000000000000000000000000..7cc89e52361501324196a41f4ef47b24b2085af1 --- /dev/null +++ b/vendor_phytium/tenglong_e/bluetooth/src/userial_vendor.c @@ -0,0 +1,364 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: userial_vendor.c + * + * Description: Contains vendor-specific userial functions + * + ******************************************************************************/ + +#define LOG_TAG "bt_userial_vendor" + +#include +#include +#include +#include +#include +#include +#include +#include "bt_vendor_brcm.h" +#include "userial.h" +#include "userial_vendor.h" + +/****************************************************************************** +** Constants & Macros +******************************************************************************/ + +#ifndef VNDUSERIAL_DBG +#define VNDUSERIAL_DBG FALSE +#endif + +#if (VNDUSERIAL_DBG == TRUE) +#define VNDUSERIALDBG(param, ...) \ +{ \ + HILOGD(param, ##__VA_ARGS__); \ +} +#else +#define VNDUSERIALDBG(param, ...) \ +{ \ + HILOGD(param, ##__VA_ARGS__); \ +} +#endif + +#define VND_PORT_NAME_MAXLEN 256 + +/****************************************************************************** +** Local type definitions +******************************************************************************/ + +/* vendor serial control block */ +typedef struct { + int fd; /* fd to Bluetooth device */ + struct termios termios; /* serial terminal of BT port */ + char port_name[VND_PORT_NAME_MAXLEN]; +} vnd_userial_cb_t; + +/****************************************************************************** +** Static variables +******************************************************************************/ + +static vnd_userial_cb_t vnd_userial; + +/***************************************************************************** +** Helper Functions +*****************************************************************************/ + +/******************************************************************************* +** +** Function userial_to_tcio_baud +** +** Description helper function converts USERIAL baud rates into TCIO +** conforming baud rates +** +** Returns TRUE/FALSE +** +*******************************************************************************/ +uint8_t userial_to_tcio_baud(uint8_t cfg_baud, uint32_t *baud) +{ + if (cfg_baud == USERIAL_BAUD_115200) + *baud = B115200; + else if (cfg_baud == USERIAL_BAUD_4M) + *baud = B4000000; + else if (cfg_baud == USERIAL_BAUD_3M) + *baud = B3000000; + else if (cfg_baud == USERIAL_BAUD_2M) + *baud = B2000000; + else if (cfg_baud == USERIAL_BAUD_1_5M) + *baud = B1500000; + else if (cfg_baud == USERIAL_BAUD_1M) + *baud = B1000000; + else if (cfg_baud == USERIAL_BAUD_921600) + *baud = B921600; + else if (cfg_baud == USERIAL_BAUD_460800) + *baud = B460800; + else if (cfg_baud == USERIAL_BAUD_230400) + *baud = B230400; + else if (cfg_baud == USERIAL_BAUD_57600) + *baud = B57600; + else if (cfg_baud == USERIAL_BAUD_19200) + *baud = B19200; + else if (cfg_baud == USERIAL_BAUD_9600) + *baud = B9600; + else if (cfg_baud == USERIAL_BAUD_1200) + *baud = B1200; + else if (cfg_baud == USERIAL_BAUD_600) + *baud = B600; + else { + HILOGE("userial vendor open: unsupported baud idx %i", cfg_baud); + *baud = B115200; + return FALSE; + } + + return TRUE; +} + +#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE) +/******************************************************************************* +** +** Function userial_ioctl_init_bt_wake +** +** Description helper function to set the open state of the bt_wake if ioctl +** is used. it should not hurt in the rfkill case but it might +** be better to compile it out. +** +** Returns none +** +*******************************************************************************/ +void userial_ioctl_init_bt_wake(int fd) +{ + uint32_t bt_wake_state; + +#if (BT_WAKE_USERIAL_LDISC == TRUE) + int ldisc = N_BRCM_HCI; /* brcm sleep mode support line discipline */ + + /* attempt to load enable discipline driver */ + if (ioctl(vnd_userial.fd, TIOCSETD, &ldisc) < 0) { + VNDUSERIALDBG("USERIAL_Open():fd %d, TIOCSETD failed: error %d for ldisc: %d", + fd, errno, ldisc); + } +#endif + + /* assert BT_WAKE through ioctl */ + ioctl(fd, USERIAL_IOCTL_BT_WAKE_ASSERT, NULL); + ioctl(fd, USERIAL_IOCTL_BT_WAKE_GET_ST, &bt_wake_state); + VNDUSERIALDBG("userial_ioctl_init_bt_wake read back BT_WAKE state=%i", + bt_wake_state); +} +#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) + +/***************************************************************************** +** Userial Vendor API Functions +*****************************************************************************/ + +/******************************************************************************* +** +** Function userial_vendor_init +** +** Description Initialize userial vendor-specific control block +** +** Returns None +** +*******************************************************************************/ +void userial_vendor_init(void) +{ + vnd_userial.fd = -1; + (void)snprintf_s(vnd_userial.port_name, VND_PORT_NAME_MAXLEN, VND_PORT_NAME_MAXLEN, "%s", + BLUETOOTH_UART_DEVICE_PORT); +} + +/******************************************************************************* +** +** Function userial_vendor_open +** +** Description Open the serial port with the given configuration +** +** Returns device fd +** +*******************************************************************************/ +int userial_vendor_open(tUSERIAL_CFG *p_cfg) +{ + uint32_t baud; + uint8_t data_bits; + uint16_t parity; + uint8_t stop_bits; + + vnd_userial.fd = -1; + + if (!userial_to_tcio_baud(p_cfg->baud, &baud)) { + return -1; + } + + if (p_cfg->fmt & USERIAL_DATABITS_8) + data_bits = CS8; + else if (p_cfg->fmt & USERIAL_DATABITS_7) + data_bits = CS7; + else if (p_cfg->fmt & USERIAL_DATABITS_6) + data_bits = CS6; + else if (p_cfg->fmt & USERIAL_DATABITS_5) + data_bits = CS5; + + if (p_cfg->fmt & USERIAL_PARITY_NONE) + parity = 0; + else if (p_cfg->fmt & USERIAL_PARITY_EVEN) + parity = PARENB; + else if (p_cfg->fmt & USERIAL_PARITY_ODD) + parity = (PARENB | PARODD); + + if (p_cfg->fmt & USERIAL_STOPBITS_1) + stop_bits = 0; + else if (p_cfg->fmt & USERIAL_STOPBITS_2) + stop_bits = CSTOPB; + + HILOGI("userial vendor open: opening %s", vnd_userial.port_name); + + if ((vnd_userial.fd = open(vnd_userial.port_name, O_RDWR)) == -1) { + return -1; + } + + tcflush(vnd_userial.fd, TCIOFLUSH); + + tcgetattr(vnd_userial.fd, &vnd_userial.termios); + cfmakeraw(&vnd_userial.termios); + vnd_userial.termios.c_cflag |= (CRTSCTS | stop_bits); + tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios); + tcflush(vnd_userial.fd, TCIOFLUSH); + + tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios); + tcflush(vnd_userial.fd, TCIOFLUSH); + tcflush(vnd_userial.fd, TCIOFLUSH); + + /* set input/output baudrate */ + cfsetospeed(&vnd_userial.termios, baud); + cfsetispeed(&vnd_userial.termios, baud); + tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios); + +#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE) + userial_ioctl_init_bt_wake(vnd_userial.fd); +#endif + + HILOGI("device fd = %d open", vnd_userial.fd); + return vnd_userial.fd; +} + +/******************************************************************************* +** +** Function userial_vendor_close +** +** Description Conduct vendor-specific close work +** +** Returns None +** +*******************************************************************************/ +void userial_vendor_close(void) +{ + int result; + + if (vnd_userial.fd == -1) { + return; + } + +#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE) + /* de-assert bt_wake BEFORE closing port */ + ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL); +#endif + + HILOGI("device fd = %d close", vnd_userial.fd); + // flush Tx before close to make sure no chars in buffer + tcflush(vnd_userial.fd, TCIOFLUSH); + if ((result = close(vnd_userial.fd)) < 0) { + HILOGE("close(fd:%d) FAILED result:%d", vnd_userial.fd, result); + } + + vnd_userial.fd = -1; +} + +/******************************************************************************* +** +** Function userial_vendor_set_baud +** +** Description Set new baud rate +** +** Returns None +** +*******************************************************************************/ +void userial_vendor_set_baud(uint8_t userial_baud) +{ + uint32_t tcio_baud; + + if (USERIAL_VENDOR_SET_BAUD_DELAY_US > 0) { + usleep(USERIAL_VENDOR_SET_BAUD_DELAY_US); + } + + userial_to_tcio_baud(userial_baud, &tcio_baud); + + cfsetospeed(&vnd_userial.termios, tcio_baud); + cfsetispeed(&vnd_userial.termios, tcio_baud); + tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios); +} + +/******************************************************************************* +** +** Function userial_vendor_ioctl +** +** Description ioctl inteface +** +** Returns None +** +*******************************************************************************/ +void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data) +{ + switch (op) { +#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE) + case USERIAL_OP_ASSERT_BT_WAKE: + VNDUSERIALDBG("## userial_vendor_ioctl: Asserting BT_Wake ##"); + ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_ASSERT, NULL); + break; + + case USERIAL_OP_DEASSERT_BT_WAKE: + VNDUSERIALDBG("## userial_vendor_ioctl: De-asserting BT_Wake ##"); + ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL); + break; + + case USERIAL_OP_GET_BT_WAKE_STATE: + ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_GET_ST, p_data); + break; +#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) + + default: + break; + } +} + +/******************************************************************************* +** +** Function userial_set_port +** +** Description Configure UART port name +** +** Returns 0 : Success +** Otherwise : Fail +** +*******************************************************************************/ +int userial_set_port(char *p_conf_name, char *p_conf_value, int param) +{ + (void)strcpy_s(vnd_userial.port_name, VND_PORT_NAME_MAXLEN, p_conf_value); + + return 0; +} diff --git a/vendor_phytium/tenglong_e/bundle.json b/vendor_phytium/tenglong_e/bundle.json new file mode 100755 index 0000000000000000000000000000000000000000..1b2c12f76dab7bff2dda3f7fe3fa28a4cb92e598 --- /dev/null +++ b/vendor_phytium/tenglong_e/bundle.json @@ -0,0 +1,28 @@ +{ + "name": "@ohos/phytium_tenglong_e", + "version": "4.1", + "license": "Apache License 2.0", + "private": false, + "scripts": {}, + "dirs": [""], + "component": { + "name": "product_tenglong_e", + "subsystem": "product_tenglong_e", + "syscap": [], + "features": [], + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//vendor/phytium/tenglong_e/resourceschedule:resourceschedule", + "//vendor/phytium/tenglong_e/preinstall-config:preinstall-config", + "//vendor/phytium/tenglong_e/hdf_config/uhdf:hdf_config", + "//vendor/phytium/tenglong_e/etc:product_etc_conf", + "//vendor/phytium/tenglong_e/hals/audio:hdf_audio_config", + "//vendor/phytium/tenglong_e/window_config:window_config" + ] + } + } +} diff --git a/vendor_phytium/tenglong_e/config.json b/vendor_phytium/tenglong_e/config.json new file mode 100755 index 0000000000000000000000000000000000000000..930b6c128f32dc2a80225bbfb2536d61ae4a3d15 --- /dev/null +++ b/vendor_phytium/tenglong_e/config.json @@ -0,0 +1,107 @@ +{ + "product_name": "tenglong_e", + "device_company": "phytium", + "device_build_path": "device/board/phytium/tenglong_e", + "target_cpu": "arm64", + "type": "standard", + "version": "3.0", + "board": "tenglong_e", + "enable_ramdisk": true, + "build_selinux": false, + "inherit": [ "productdefine/common/inherit/rich.json", "productdefine/common/inherit/chipset_common.json" ], + "subsystems": [ + { + "subsystem": "security", + "components": [ + { + "component": "selinux_adapter", + "features": [] + } + ] + }, + { + "subsystem": "graphic", + "components": [ + { + "component": "graphic_2d", + "features": [ + "graphic_2d_feature_ace_enable_gpu = true", + "graphic_2d_feature_rs_enable_eglimage = true" + ] + } + ] + }, + + { + "subsystem": "communication", + "components": [ + { + "component": "netmanager_ext", + "features": [] + } + ] + }, + { + "subsystem": "phytium_products", + "components": [] + }, + { + "subsystem": "arkui", + "components": [ + { + "component": "ace_engine", + "features": [ + "ace_engine_feature_enable_accessibility = true", + "ace_engine_feature_enable_web = true" + ] + } + ] + }, + { + "subsystem": "wpa_supplicant", + "components": [ + { + "component": "wpa_supplicant", + "features": [ + "wpa_supplicant_driver_nl80211 = true" + ] + } + ] + }, + { + "subsystem": "startup", + "components": [ + { + "component": "init", + "features": [ + "enable_ohos_startup_init_feature_ab_partition = true", + "enable_ohos_startup_init_feature_loader = true" + ] + } + ] + }, + { + "subsystem": "hdf", + "components": [ + { + "component": "drivers_interface_audio", + "features": [] + }, + { + "component": "drivers_peripheral_audio", + "features": [ + "drivers_peripheral_audio_feature_full_test_suite = true", + "drivers_peripheral_audio_feature_alsa_lib = true", + "drivers_peripheral_audio_feature_effect = false" + ] + }, + { + "component": "drivers_peripheral_display", + "features": [ + "drivers_peripheral_display_community = true" + ] + } + ] + } + ] +} diff --git a/vendor_phytium/tenglong_e/etc/BUILD.gn b/vendor_phytium/tenglong_e/etc/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..515c8e27391808af74bafdf255dd06048d5f5699 --- /dev/null +++ b/vendor_phytium/tenglong_e/etc/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. +# 2024.11.21 Phytium change + +import("//build/ohos.gni") + +ohos_prebuilt_etc("para_for_chip_prod") { + source = "./param/hardware_${device_name}.para" + install_images = [ chipset_base_dir ] + relative_install_dir = "param" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("para_for_sys_prod") { + source = "./param/product_${device_name}.para" + install_images = [ chipset_base_dir ] + relative_install_dir = "param" + part_name = "product_${device_name}" +} + +group("product_etc_conf") { + deps = [ + ":para_for_chip_prod", + ":para_for_sys_prod", + ] +} diff --git a/vendor_phytium/tenglong_e/etc/param/hardware_tenglong_e.para b/vendor_phytium/tenglong_e/etc/param/hardware_tenglong_e.para new file mode 100755 index 0000000000000000000000000000000000000000..4aea8ae1c864c4d8f8f23a2ce711a20de1df1737 --- /dev/null +++ b/vendor_phytium/tenglong_e/etc/param/hardware_tenglong_e.para @@ -0,0 +1,15 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. +# 2024.11.21 Phytium change. + +const.product.hardwareversion=default diff --git a/vendor_phytium/tenglong_e/etc/param/product_tenglong_e.para b/vendor_phytium/tenglong_e/etc/param/product_tenglong_e.para new file mode 100755 index 0000000000000000000000000000000000000000..e1d15dbbf8fc4b72cb50f124b91b353912a00a78 --- /dev/null +++ b/vendor_phytium/tenglong_e/etc/param/product_tenglong_e.para @@ -0,0 +1,17 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. +# 2024.11.21 Phytium change. + +const.product.brand=default +const.build.product=default +const.product.name=Phytium tenglong_e diff --git a/vendor_phytium/tenglong_e/hals/audio/BUILD.gn b/vendor_phytium/tenglong_e/hals/audio/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..daa90b0a19927383ba17b78b8601703a2c2349e8 --- /dev/null +++ b/vendor_phytium/tenglong_e/hals/audio/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (C) 2023 Phytium Open Source Organization . +# 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. + +import("//build/ohos.gni") + +ohos_prebuilt_etc("hdf_alsa_adapter_json") { + source = "alsa_adapter.json" + + relative_install_dir = "hdfconfig" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("hdf_alsa_path_json") { + source = "alsa_paths.json" + + relative_install_dir = "hdfconfig" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("audio_policy_config") { + source = "config/audio_policy_config.xml" + subsystem_name = "hdf" + relative_install_dir = "audio" + install_images = [ chipset_base_dir ] + part_name = "product_${device_name}" +} + +group("hdf_audio_config") { + deps = [ + ":audio_policy_config", + ":hdf_alsa_adapter_json", + ":hdf_alsa_path_json", + ] +} + diff --git a/vendor_phytium/tenglong_e/hals/audio/alsa_adapter.json b/vendor_phytium/tenglong_e/hals/audio/alsa_adapter.json new file mode 100755 index 0000000000000000000000000000000000000000..9e33f16471a6796a24ecd6d488cde54e63a9015d --- /dev/null +++ b/vendor_phytium/tenglong_e/hals/audio/alsa_adapter.json @@ -0,0 +1,8 @@ +{ + "adapters": [{ + "name": "primary", + "cardId": 0, + "cardName": "fthda" + } + ] +} diff --git a/vendor_phytium/tenglong_e/hals/audio/alsa_paths.json b/vendor_phytium/tenglong_e/hals/audio/alsa_paths.json new file mode 100755 index 0000000000000000000000000000000000000000..6474a1f3440599166a2850a3b277fdccd28ab735 --- /dev/null +++ b/vendor_phytium/tenglong_e/hals/audio/alsa_paths.json @@ -0,0 +1,98 @@ +{ + "hdf_audio_codec_primary_dev0": [ + { + "deep-buffer-playback": [ + { + "headphones": [ + { + "name": "Headphone", + "value": 1 + } + ], + "Speaker": [ + { + "name": "Master", + "value": 1 + } + ], + "mic": [ + { + "name": "mic-in", + "value": 0 + } + ] + } + ], + "low-latency-communication": [ + { + "Speaker": [ + { + "name": "Playback Path", + "value": 2 + } + ], + "headphones": [ + { + "name": "Playback Path", + "value": 3 + } + ], + "mic": [ + { + "name": "Capture MIC Path", + "value": 1 + } + ] + } + ], + "ringtone-playback": [ + { + "Speaker": [ + { + "name": "Playback Path", + "value": 10 + } + ] + } + ], + "voice-call": [ + { + "Speaker": [ + { + "name": "Playback Path", + "value": 7 + } + ], + "Headphones": [ + { + "name": "Playback Path", + "value": 8 + } + ], + "MIC": [ + { + "name": "Capture MIC Path", + "value": 1 + } + ] + } + ], + "low-latency-noirq-playback": [ + { + "Speaker": [ + { + "name": "Playback Path", + "value": 2 + } + ], + "Headphones": [ + { + "name": "Playback Path", + "value": 3 + } + ] + } + ] + } + ] +} diff --git a/vendor_phytium/tenglong_e/hals/audio/config/audio_policy_config.xml b/vendor_phytium/tenglong_e/hals/audio/config/audio_policy_config.xml new file mode 100755 index 0000000000000000000000000000000000000000..0f4ef08c98ddc5041723eac945e406903c4f16c8 --- /dev/null +++ b/vendor_phytium/tenglong_e/hals/audio/config/audio_policy_config.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + false + 90 + + + + + + + + + + + + + + + diff --git a/vendor_phytium/tenglong_e/hals/audio/product.gni b/vendor_phytium/tenglong_e/hals/audio/product.gni new file mode 100755 index 0000000000000000000000000000000000000000..86dba9c8ee29837173acdfdffb560dbe8dc624c7 --- /dev/null +++ b/vendor_phytium/tenglong_e/hals/audio/product.gni @@ -0,0 +1,19 @@ +# Copyright (c) 2023 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +enable_audio_hal_hdf_log = true +enable_audio_alsa_mode = true +drivers_peripheral_audio_feature_hdf_proxy_stub = true +drivers_peripheral_audio_feature_hal_notsupport_pathselect = false +drivers_peripheral_audio_feature_policy_config = true +enable_audio_analog_headset = true diff --git a/vendor_phytium/tenglong_e/hals/wlan/product.gni b/vendor_phytium/tenglong_e/hals/wlan/product.gni new file mode 100755 index 0000000000000000000000000000000000000000..e87a41fccad4cf992cc966cfd47c939b3adcdc2c --- /dev/null +++ b/vendor_phytium/tenglong_e/hals/wlan/product.gni @@ -0,0 +1,16 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. +# 2024.11.21 Phytium change. + +enable_HDF_NL80211 = true +enable_HDF_UT = false diff --git a/vendor_phytium/tenglong_e/hdf_config/uhdf/BUILD.gn b/vendor_phytium/tenglong_e/hdf_config/uhdf/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..58ff8918a94d4c79132568e463b1c24b277a5c88 --- /dev/null +++ b/vendor_phytium/tenglong_e/hdf_config/uhdf/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# 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. +# 2023.11 Phytium change BUILD.gn. + +import("//drivers/hdf_core/adapter/uhdf2/hcs/hcs.gni") + +check_path = "//vendor/phytium/gpu_model/${gpu_model}/uhdf/hdf.hcs" +test_result = exec_script(rebase_path("//build/scripts/check_file_exist.py"),[ rebase_path("${check_path}") ],"string") + +if (test_result != "") { + hdf_hcs_source = "//vendor/phytium/gpu_model/${gpu_model}/uhdf/hdf.hcs" +} +else { + hdf_hcs_source = "./hdf.hcs" +} +hdf_hcb("hdf_default.hcb") { + source = hdf_hcs_source + part_name = "product_${device_name}" + subsystem_name = "product_${device_name}" +} + +hdf_cfg("hdf_devhost.cfg") { + source = hdf_hcs_source + part_name = "product_${device_name}" + subsystem_name = "product_${device_name}" +} + +group("hdf_config") { + deps = [ + ":hdf_default.hcb", + ":hdf_devhost.cfg", + ] +} diff --git a/vendor_phytium/tenglong_e/hdf_config/uhdf/device_info.hcs b/vendor_phytium/tenglong_e/hdf_config/uhdf/device_info.hcs new file mode 100755 index 0000000000000000000000000000000000000000..4237df646b3559a2e69839aa955b25babb742525 --- /dev/null +++ b/vendor_phytium/tenglong_e/hdf_config/uhdf/device_info.hcs @@ -0,0 +1,517 @@ + root { + device_info { + match_attr = "hdf_manager"; + template host { + hostName = ""; + priority = 100; + uid = ""; + gid = [""]; + caps = [""]; + critical = []; + template device { + template deviceNode { + policy = 0; + priority = 100; + preload = 0; + permission = 0664; + moduleName = ""; + serviceName = ""; + deviceMatchAttr = ""; + } + } + } + platform :: host { + hostName = "sample_host"; + priority = 50; + gid = ["sample_host", "uhdf_driver"]; + sample_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libsample_driver.z.so"; + serviceName = "sample_driver_service"; + } + device1 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libsample1_driver.z.so"; + serviceName = "sample1_driver_service"; + } + } + } + bluetooth :: host { + hostName = "blue_host"; + priority = 50; + caps = ["NET_ADMIN"]; + bluetooth_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libbluetooth_hci_hdi_driver.z.so"; + serviceName = "hci_interface_service"; + } + } + } + audio_bluetooth :: host { + hostName = "a2dp_host"; + priority = 50; + bluetooth_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libaudio_bluetooth_hdi_adapter_server.z.so"; + serviceName = "audio_bluetooth_hdi_service"; + } + } + } + usb :: host { + hostName = "usb_host"; + priority = 50; + caps = ["DAC_OVERRIDE"]; + usb_pnp_manager_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 70; + moduleName = "libusb_pnp_manager.z.so"; + serviceName = "usb_pnp_manager"; + } + } + usbfn_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 80; + preload = 2; + moduleName = "libusbfn.z.so"; + serviceName = "usbfn"; + deviceMatchAttr = "usbfn_driver"; + } + } + ecm_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 81; + preload = 2; + moduleName = "libusbfn_cdcecm.z.so"; + serviceName = "usbfn_cdcecm"; + deviceMatchAttr = "usbfn_cdcecm_driver"; + } + } + acm_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libusbfn_cdcacm.z.so"; + serviceName = "usbfn_cdcacm"; + deviceMatchAttr = "usbfn_cdcacm_driver"; + } + } + mtp_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 90; + preload = 2; + moduleName = "libusbfn_mtp_driver.z.so"; + serviceName = "usbfn_mtp_interface_service"; + deviceMatchAttr = "usbfn_mtp_interface_driver"; + } + } + usb_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libusb_driver.z.so"; + serviceName = "usb_interface_service"; + deviceMatchAttr = "usb_device_interface_driver"; + } + } + ddk_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libusb_ddk_driver.z.so"; + serviceName = "usb_ddk_service"; + } + } + } + power :: host { + hostName = "power_host"; + priority = 50; + uid = "power_host"; + gid = ["power_host", "system", "log"]; + caps = ["BLOCK_SUSPEND"]; + power_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libpower_driver.z.so"; + serviceName = "power_interface_service"; + } + } + battery_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libbattery_driver.z.so"; + serviceName = "battery_interface_service"; + } + } + thermal_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libthermal_driver.z.so"; + serviceName = "thermal_interface_service"; + } + } + } + wlan :: host { + hostName = "wifi_host"; + priority = 50; + gid = ["wifi_host", "wifi_group"]; + wifi_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libwifi_hdi_c_device.z.so"; + serviceName = "wlan_interface_service"; + } + } + } + audio :: host { + hostName = "audio_host"; + priority = 50; + gid = ["audio_host", "uhdf_driver", "root", "audio"]; + audio_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libhdi_audio_primary_server.z.so"; + serviceName = "audio_hdi_service"; + } + } + audio_usb_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libhdi_audio_usb_server.z.so"; + serviceName = "audio_hdi_usb_service"; + } + } + audio_a2dp_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libhdi_audio_a2dp_server.z.so"; + serviceName = "audio_hdi_a2dp_service"; + } + } + audio_pnp_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 110; + moduleName = "libhdi_audio_pnp_server.z.so"; + serviceName = "audio_hdi_pnp_service"; + } + } + idl_audio_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libaudio_primary_driver.z.so"; + serviceName = "audio_manager_service"; + } + } + effect_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libeffect_model_service.z.so"; + serviceName = "effect_model_service"; + } + } + trigger_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libintell_voice_trigger_driver.z.so"; + serviceName = "intell_voice_trigger_manager_service"; + } + } + + } + hdi_server :: host { + hostName = "camera_host"; + priority = 50; + gid = ["camera_host", "uhdf_driver", "vendor_mpp_driver"]; + camera_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libcamera_host_service_1.0.z.so"; + serviceName = "camera_service"; + } + } + display_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 120; + moduleName = "libhdi_media_layer_service.z.so"; + serviceName = "hdi_media_layer_service"; + } + } + } + input_hal :: host { + hostName = "input_user_host"; + priority = 50; + gid = ["input_user_host", "uhdf_driver"]; + input_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 150; + moduleName = "libhdf_input_hotplug.z.so"; + serviceName = "input_service"; + } + } + input_hdi_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libinput_driver.z.so"; + serviceName = "input_interfaces_service"; + } + } + } + display_composer :: host { + hostName = "composer_host"; + priority = 40; + processPriority = -8; + threadPriority = 1; + caps = ["SYS_NICE"]; + uid = ["composer_host"]; + gid = ["composer_host", "graphics", "vendor_mpp_driver"]; + composer_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 160; + moduleName = "libdisplay_composer_driver_1.0.z.so"; + serviceName = "display_composer_service"; + } + } + } + allocator :: host { + hostName = "allocator_host"; + priority = 40; + allocator_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 160; + moduleName = "liballocator_driver_1.0.z.so"; + serviceName = "allocator_service"; + } + } + } + sensor :: host { + hostName = "sensor_host"; + priority = 50; + gid = ["sensor_host", "uhdf_driver"]; + sensor_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libsensor_driver.z.so"; + serviceName = "sensor_interface_service"; + } + } + } + vibrator :: host { + hostName = "vibrator_host"; + priority = 50; + vibrator_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libvibrator_driver.z.so"; + serviceName = "vibrator_interface_service"; + } + } + } + light :: host { + hostName = "light_host"; + priority = 50; + light_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "liblight_driver.z.so"; + serviceName = "light_interface_service"; + } + } + } + distributed_camera_host :: host { + hostName = "dcamera_host"; + priority = 50; + distributed_camera_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libdistributed_camera_host_config.z.so"; + serviceName = "distributed_camera_service"; + } + device1 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libdistributed_camera_provider_config.z.so"; + serviceName = "distributed_camera_provider_service"; + } + } + } + + distributed_audio_host :: host { + hostName = "daudio_host"; + priority = 50; + distributed_audio_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libdaudio_primary_driver.z.so"; + serviceName = "daudio_primary_service"; + } + device1 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libdaudio_ext_driver.z.so"; + serviceName = "daudio_ext_service"; + } + } + } + + face_auth :: host { + hostName = "face_auth_host"; + priority = 50; + uid = "face_auth_host"; + gid = ["face_auth_host"]; + face_auth_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 200; + moduleName = "libface_auth_driver.z.so"; + serviceName = "face_auth_interface_service"; + } + } + } + + pin_auth :: host { + hostName = "pin_auth_host"; + priority = 50; + uid = "pin_auth_host"; + gid = ["pin_auth_host"]; + pin_auth_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 200; + moduleName = "libpin_auth_driver.z.so"; + serviceName = "pin_auth_interface_service"; + } + } + } + + user_auth :: host { + hostName = "user_auth_host"; + priority = 50; + uid = "user_auth_host"; + gid = ["user_auth_host"]; + user_auth_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 200; + moduleName = "libuser_auth_driver.z.so"; + serviceName = "user_auth_interface_service"; + } + } + } + + fingerprint_auth :: host { + hostName = "fingerprint_auth_host"; + priority = 50; + uid = "fingerprint_auth_host"; + gid = ["fingerprint_auth_host"]; + fingerprint_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 200; + moduleName = "libfingerprint_auth_driver.z.so"; + serviceName = "fingerprint_auth_interface_service"; + } + } + } + + location :: host { + hostName = "location_host"; + priority = 50; + uid = "location_host"; + gid = ["location_host"]; + location_gnss_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "liblocation_gnss_hdi_driver.z.so"; + serviceName = "gnss_interface_service"; + } + } + location_agnss_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "liblocation_agnss_hdi_driver.z.so"; + serviceName = "agnss_interface_service"; + } + } + location_geofence_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "liblocation_geofence_hdi_driver.z.so"; + serviceName = "geofence_interface_service"; + } + } + } + partitionslot :: host { + hostName = "partitionslot_host"; + priority = 100; + uid = "useriam"; + gid = ["useriam", "update"]; + partitionslot_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 2; + moduleName = "libpartitionslot_driver.z.so"; + serviceName = "partition_slot_service"; + } + } + } + intell_voice :: host { + hostName = "intell_voice_host"; + priority = 100; + intell_voice_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libintell_voice_engine_driver.z.so"; + serviceName = "intell_voice_engine_manager_service"; + } + } + } + } +} diff --git a/vendor_phytium/tenglong_e/hdf_config/uhdf/hdf.hcs b/vendor_phytium/tenglong_e/hdf_config/uhdf/hdf.hcs new file mode 100755 index 0000000000000000000000000000000000000000..bf8dc250cb2744b277f7ffeac187299008b04d44 --- /dev/null +++ b/vendor_phytium/tenglong_e/hdf_config/uhdf/hdf.hcs @@ -0,0 +1,5 @@ +#include "device_info.hcs" + +root { + module = "default"; +} diff --git a/vendor_phytium/tenglong_e/preinstall-config/BUILD.gn b/vendor_phytium/tenglong_e/preinstall-config/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..1419ec2f41f1f38b6877f09dfaecb0ff6610e278 --- /dev/null +++ b/vendor_phytium/tenglong_e/preinstall-config/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. +# +# 2023.11 Phytium change BUILD.gn. + +import("//build/ohos.gni") + +ohos_prebuilt_etc("install_list_config") { + source = "./install_list.json" + relative_install_dir = "app" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("uninstall_list_config") { + source = "./uninstall_list.json" + relative_install_dir = "app" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("install_list_capability_config") { + source = "./install_list_capability.json" + relative_install_dir = "app" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("install_list_permissions_config") { + source = "./install_list_permissions.json" + relative_install_dir = "app" + part_name = "product_${device_name}" +} + +group("preinstall-config") { + deps = [ + ":install_list_capability_config", + ":install_list_config", + ":install_list_permissions_config", + ":uninstall_list_config", + ] +} diff --git a/vendor_phytium/tenglong_e/preinstall-config/install_list.json b/vendor_phytium/tenglong_e/preinstall-config/install_list.json new file mode 100755 index 0000000000000000000000000000000000000000..165920a15940cfde4751f49df89daa28a7c55d5a --- /dev/null +++ b/vendor_phytium/tenglong_e/preinstall-config/install_list.json @@ -0,0 +1,200 @@ +{ + "install_list" : [ + { + "app_dir" : "/system/app/com.ohos.systemui", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.launcher", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.settings", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.note", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.settingsdata", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.screenshot", + "removable" : false + }, + { + "app_dir" : "/system/app/ohos.samples.clock", + "removable" : false + }, + { + "app_dir" : "/system/app/ohos.samples.airquality", + "removable" : false + }, + { + "app_dir" : "/system/app/com.example.distributedcalc", + "removable" : false + }, + { + "app_dir" : "/system/app/ohos.samples.flashlight", + "removable" : false + }, + { + "app_dir" : "/system/app/ohos.samples.ecg", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.photos", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.distributedmusicplayer", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.camera", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.devicemanagerui", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.dlpmanager", + "removable" : false + }, + { + "app_dir" : "/system/app/com.example.kikakeyboard", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.medialibrary.MediaLibraryData", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.callui", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.mms", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.contacts", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.permissionmanager", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.settings.faceauth", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.useriam.authwidget", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.adminprovisioning", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.filepicker", + "removable" : false + }, + { + "app_dir" : "/system/app/ohos.global.systemres", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.contactsdataability", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.nweb", + "removable" : false + }, + { + "app_dir" : "/system/app/ohos.telephony.resources", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.download", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.telephonydataability", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.UserFile.ExternalFileManager", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.gameperceptio", + "removable" : false + }, + { + "app_dir" : "/system/app/ohos.backgroundtaskmgr.resources", + "removable" : false + }, + { + "app_dir" : "/system/app/ohos.sample.shopping", + "removable" : false + }, + { + "app_dir" : "/system/app/com.ohos.wallpaper", + "removable" : true + }, + { + "app_dir" : "/system/app/cn.openharmony.inputmethodchoosedialog", + "removable" : false + }, + { + "app_dir": "/system/app/com.ohos.sharepickerdialog", + "removable": false + }, + { + "app_dir" : "/system/app/cn.openharmony.pasteboarddialog", + "removable" : true + }, + { + "app_dir": "/system/app/com.ohos.amsdialog", + "removable": false + }, + { + "app_dir": "/system/app/com.usb.right", + "removable": true + }, + { + "app_dir": "/system/app/com.ohos.certificatemanager", + "removable": true + }, + { + "app_dir": "/system/app/com.ohos.powerdialog", + "removable": false + }, + { + "app_dir": "/system/app/com.ohos.notificationdialog", + "removable": true + }, + { + "app_dir": "/system/app/com.ohos.formrenderservice", + "removable": false + }, + { + "app_dir": "/system/app/com.ohos.updateapp", + "removable": false + }, + { + "app_dir": "/system/app/com.ohos.spooler", + "removable": false + }, + { + "app_dir": "/system/app/com.ohos.calendardata", + "removable": false + } + ] +} diff --git a/vendor_phytium/tenglong_e/preinstall-config/install_list_capability.json b/vendor_phytium/tenglong_e/preinstall-config/install_list_capability.json new file mode 100755 index 0000000000000000000000000000000000000000..388a0da150a07564f6bed784d96065089416257b --- /dev/null +++ b/vendor_phytium/tenglong_e/preinstall-config/install_list_capability.json @@ -0,0 +1,214 @@ +{ + "install_list": [ + { + "bundleName": "com.example.kikakeyboard", + "singleton": true, + "runningResourcesApply": false, + "associatedWakeUp": false, + "app_signature" : ["9AED2A79925ECA050CD2BB9D2A7F694E49E5E135D28EBDCE53836DE76B5080ED"], + "allowCommonEvent": [], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.systemui", + "singleton": true, + "keepAlive": true, + "runningResourcesApply": false, + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "associatedWakeUp": false, + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.callui", + "app_signature" : ["E64B13B84E6D2167F73B46530C6E02E323DA43C9C2DA251D7C64D20E091B936F"], + "singleton": true, + "keepAlive": false, + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.contacts", + "app_signature" : ["04AC9C3F045EAB7DB992B7C4E38B59468CA3EABB7D654AE47641471B9785EA04"], + "singleton": true, + "keepAlive": false, + "allowCommonEvent": ["usual.event.INCOMING_CALL_MISSED","contact.event.CANCEL_MISSED"] + }, + { + "bundleName": "com.ohos.mms", + "app_signature" : ["04AC9C3F045EAB7DB992B7C4E38B59468CA3EABB7D654AE47641471B9785EA04"], + "singleton": true, + "keepAlive": false, + "allowCommonEvent": ["usual.event.SMS_RECEIVE_COMPLETED"] + }, + { + "bundleName": "com.ohos.settingsdata", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "singleton": true, + "keepAlive": true, + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "ohos.backgroundtaskmgr.resources", + "app_signature" : ["72BE2C651A9E0C57B4BB67825BA6F8180FC883858434712150A55C17C7E1A6F7"], + "singleton": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "ohos.global.systemres", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "singleton": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.devicetest", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "runningResourcesApply": true, + "associatedWakeUp": true, + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.contactsdataability", + "app_signature" : ["D729F438E1EF2E154994E2B077F6C0CD592BA9F9C938BB428FCDA564FF805EE4"], + "associatedWakeUp": true, + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.telephonydataability", + "app_signature" : ["D729F438E1EF2E154994E2B077F6C0CD592BA9F9C938BB428FCDA564FF805EE4"], + "associatedWakeUp": true, + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.huawei.ohos.hiviewx", + "singleton": true, + "keepAlive": true, + "app_signature" : ["57D4E9DFE7504D12EB6ACAF39876F420BCABCA2F4721989B90FD2E4F1FB7ED2B"], + "allowCommonEvent": [], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "cn.openharmony.inputmethodchoosedialog", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppDesktopIconHide": true, + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "cn.openharmony.pasteboarddialog", + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.amsdialog", + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppUsePrivilegeExtension": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.devicemanagerui", + "app_signature": ["DFBBF5BC714865FCCCACA69F30BEF951B499329F66C98523795BAD817E49D1A0"], + "allowAppDesktopIconHide": true, + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.launcher", + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.medialibrary.medialibrarydata", + "app_signature": ["F9431859ED7A3959B5D72EF36FBE8B210A00082B044063E4424F823A01B3B7CA"], + "allowAppUsePrivilegeExtension": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.permissionmanager", + "app_signature": ["68079CC9CB1BD69283D70790305645FFF61CD1E46CAFD7AA53B9FA8540432B81"], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.dlpmanager", + "app_signature": [ + "E3F4322139E0109BAFAD8DA4096762068E31708C3CF201780E736D377D60B639", + "5FEDFF587F4109E565B96512404D606D539C8DFFCE1424ACBD1B2A7D3E843D4D" + ], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.photos", + "app_signature": ["9AED2A79925ECA050CD2BB9D2A7F694E49E5E135D28EBDCE53836DE76B5080ED"], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.powerdialog", + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppUsePrivilegeExtension": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.sharepickerdialog", + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.usb.right", + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppUsePrivilegeExtension": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.screenshot", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppUsePrivilegeExtension": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.notificationdialog", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "allowAppUsePrivilegeExtension": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.nweb", + "app_signature" : [ + "49D779C85200D36A00DE63E2D85AEF22FE5C72FB268BE13923E589B49BFAFFDA", + "8AFD891FA100D478BEDB6962B157055F26CDD407ACAAD525CBA9FDE490BD23D9" + ], + "singleton": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.settings.faceauth", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "singleton": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.useriam.authwidget", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "singleton": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.formrenderservice", + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "singleton": true, + "allowAppUsePrivilegeExtension": true, + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.updateapp", + "app_signature" : ["BA6EBDF53DD63B7D5616F3789F8C15FD4DE134B2587C577B01DA4D027B44A23C"], + "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "com.ohos.spooler", + "app_signature" : ["B68D7BE6599CA7ADEDBC95CD1CE176AA96D996D3F41588A487E5F5C4E5DC9427"], + "allowAppDesktopIconHide": true + }, + { + "bundleName": "com.ohos.calendardata", + "app_signature" : ["1C6905C65DE22F5160790D34ADA462EE9ED3D9EEAA4FCBD4FEC7FFEE7D1D4FD2"], + "allowAppDesktopIconHide": true, + "allowAppUsePrivilegeExtension": true + } + ] +} diff --git a/vendor_phytium/tenglong_e/preinstall-config/install_list_permissions.json b/vendor_phytium/tenglong_e/preinstall-config/install_list_permissions.json new file mode 100755 index 0000000000000000000000000000000000000000..bc487ce8c78efad9aa9ec4c2f4dae33c80d48528 --- /dev/null +++ b/vendor_phytium/tenglong_e/preinstall-config/install_list_permissions.json @@ -0,0 +1,320 @@ +[ + { + "bundleName" : "com.ohos.screenshot", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "permissions" : [ + { + "name" : "ohos.permission.MEDIA_LOCATION", + "userCancellable" : true + }, + { + "name" : "ohos.permission.READ_MEDIA", + "userCancellable" : true + }, + { + "name" : "ohos.permission.WRITE_MEDIA", + "userCancellable" : true + } + ] + }, + { + "bundleName" : "com.ohos.medialibrary.medialibrarydata", + "app_signature" : ["F9431859ED7A3959B5D72EF36FBE8B210A00082B044063E4424F823A01B3B7CA"], + "permissions" : [ + { + "name" : "ohos.permission.DISTRIBUTED_DATASYNC", + "userCancellable" : false + } + ] + }, + { + "bundleName" : "com.ohos.callui", + "app_signature" : ["E64B13B84E6D2167F73B46530C6E02E323DA43C9C2DA251D7C64D20E091B936F"], + "permissions" : [ + { + "name" : "ohos.permission.READ_CONTACTS", + "userCancellable" : false + }, + { + "name" : "ohos.permission.SEND_MESSAGES", + "userCancellable" : false + }, + { + "name" : "ohos.permission.ANSWER_CALL", + "userCancellable" : false + } + ] + }, + { + "bundleName" : "com.ohos.mms", + "app_signature" : ["04AC9C3F045EAB7DB992B7C4E38B59468CA3EABB7D654AE47641471B9785EA04"], + "permissions" : [ + { + "name" : "ohos.permission.READ_CONTACTS", + "userCancellable" : true + }, + { + "name" : "ohos.permission.READ_MESSAGES", + "userCancellable" : false + }, + { + "name" : "ohos.permission.SEND_MESSAGES", + "userCancellable" : false + }, + { + "name" : "ohos.permission.RECEIVE_SMS", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.systemui", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "permissions" : [ + { + "name" : "ohos.permission.DISTRIBUTED_DATASYNC", + "userCancellable" : false + }, + { + "name" : "ohos.permission.GET_INSTALLED_BUNDLE_LIST", + "userCancellable" : false + }, + { + "name" : "ohos.permission.ACCESS_BLUETOOTH", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.contacts", + "app_signature" : ["04AC9C3F045EAB7DB992B7C4E38B59468CA3EABB7D654AE47641471B9785EA04"], + "permissions" : [ + { + "name" : "ohos.permission.READ_CONTACTS", + "userCancellable" : false + }, + { + "name" : "ohos.permission.WRITE_CONTACTS", + "userCancellable" : false + }, + { + "name" : "ohos.permission.READ_CALL_LOG", + "userCancellable" : false + }, + { + "name" : "ohos.permission.WRITE_CALL_LOG", + "userCancellable" : false + }, + { + "name" : "ohos.permission.MANAGE_VOICEMAIL", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.photos", + "app_signature" : ["9AED2A79925ECA050CD2BB9D2A7F694E49E5E135D28EBDCE53836DE76B5080ED"], + "permissions" : [ + { + "name" : "ohos.permission.READ_IMAGEVIDEO", + "userCancellable" : false + }, + { + "name" : "ohos.permission.WRITE_IMAGEVIDEO", + "userCancellable" : false + }, + { + "name" : "ohos.permission.READ_MEDIA", + "userCancellable" : false + }, + { + "name" : "ohos.permission.WRITE_MEDIA", + "userCancellable" : false + }, + { + "name" : "ohos.permission.MEDIA_LOCATION", + "userCancellable" : false + }, + { + "name" : "ohos.permission.DISTRIBUTED_DATASYNC", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.filepicker", + "app_signature" : ["C902DDEE3286715B8BA26175A1EF967985D22AEF44BE747702B604D956A76CFA"], + "permissions" : [ + { + "name" : "ohos.permission.READ_MEDIA", + "userCancellable" : false + }, + { + "name" : "ohos.permission.WRITE_MEDIA", + "userCancellable" : false + }, + { + "name" : "ohos.permission.MEDIA_LOCATION", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.camera", + "app_signature" : ["62C298EE70BEEB3D58082FFEFFEAD4F26BE83350B46B75C393281BA6AAED2A91"], + "permissions" : [ + { + "name" : "ohos.permission.READ_IMAGEVIDEO", + "userCancellable" : false + }, + { + "name" : "ohos.permission.WRITE_IMAGEVIDEO", + "userCancellable" : false + }, + { + "name" : "ohos.permission.MEDIA_LOCATION", + "userCancellable" : false + }, + { + "name" : "ohos.permission.DISTRIBUTED_DATASYNC", + "userCancellable" : false + }, + { + "name" : "ohos.permission.CAMERA", + "userCancellable" : false + }, + { + "name" : "ohos.permission.MICROPHONE", + "userCancellable" : false + }, + { + "name" : "ohos.permission.LOCATION", + "userCancellable" : false + }, + { + "name" : "ohos.permission.LOCATION_IN_BACKGROUND", + "userCancellable" : false + }, + { + "name" : "ohos.permission.APPROXIMATELY_LOCATION", + "userCancellable" : false + } + ] + }, + { + "bundleName": "cn.openharmony.inputmethodchoosedialog", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "permissions" : [ + { + "name" : "ohos.permission.CONNECT_IME_ABILITY", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.huawei.ohos.hiviewx", + "app_signature" : ["57D4E9DFE7504D12EB6ACAF39876F420BCABCA2F4721989B90FD2E4F1FB7ED2B"], + "permissions" : [ + { + "name" : "ohos.permission.sec.ACCESS_UDID", + "userCancellable" : false + }, + { + "name" : "ohos.permission.GET_WIFI_INFO", + "userCancellable" : false + }, + { + "name" : "ohos.permission.GET_NETWORK_INFO", + "userCancellable" : false + }, + { + "name" : "ohos.permission.INTERNET", + "userCancellable" : false + }, + { + "name" : "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "userCancellable" : false + }, + { + "name" : "ohos.permission.READ_DFX_SYSEVENT", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.permissionmanager", + "app_signature" : ["68079CC9CB1BD69283D70790305645FFF61CD1E46CAFD7AA53B9FA8540432B81"], + "permissions" : [ + { + "name" : "ohos.permission.GET_INSTALLED_BUNDLE_LIST", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.dlpmanager", + "app_signature" : ["E3F4322139E0109BAFAD8DA4096762068E31708C3CF201780E736D377D60B639"], + "permissions" : [ + { + "name": "ohos.permission.READ_MEDIA", + "userCancellable" : false + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "userCancellable" : false + }, + { + "name": "ohos.permission.ACCESS_DLP_FILE", + "userCancellable" : false + }, + { + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "userCancellable" : false + }, + { + "name":"ohos.permission.FILE_ACCESS_MANAGER", + "userCancellable" : false + }, + { + "name":"ohos.permission.START_ABILIIES_FROM_BACKGROUND", + "userCancellable" : false + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "userCancellable" : false + }, + { + "name": "ohos.permission.MEDIA_LOCATION", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.useriam.authwidget", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "permissions" : [ + { + "name" : "ohos.permission.ACCESS_PIN_AUTH", + "userCancellable" : false + }, + { + "name" : "ohos.permission.ACCESS_BIOMETRIC", + "userCancellable" : false + }, + { + "name" : "ohos.permission.SUPPORT_USER_AUTH", + "userCancellable" : false + } + ] + }, + { + "bundleName": "com.ohos.settings", + "app_signature" : ["EB5DBE52EE8DD7206DDE612E7484E88CE264E74958704D0712BFA774C87F4DA1"], + "permissions" : [ + { + "name" : "ohos.permission.GET_INSTALLED_BUNDLE_LIST", + "userCancellable" : false + } + ] + } +] diff --git a/vendor_phytium/tenglong_e/preinstall-config/uninstall_list.json b/vendor_phytium/tenglong_e/preinstall-config/uninstall_list.json new file mode 100755 index 0000000000000000000000000000000000000000..0e0e7784a452341a6f996559c248e81323307a30 --- /dev/null +++ b/vendor_phytium/tenglong_e/preinstall-config/uninstall_list.json @@ -0,0 +1,4 @@ +{ + "uninstall_list" : [], + "recover_list" : [] +} \ No newline at end of file diff --git a/vendor_phytium/tenglong_e/product.gni b/vendor_phytium/tenglong_e/product.gni new file mode 100755 index 0000000000000000000000000000000000000000..b8817f1f581d895a1c50a979b8b08c0ec769c8b2 --- /dev/null +++ b/vendor_phytium/tenglong_e/product.gni @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +import("//device/board/phytium/${device_name}/device.gni") diff --git a/vendor_phytium/tenglong_e/resourceschedule/BUILD.gn b/vendor_phytium/tenglong_e/resourceschedule/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..0194664d6c60785e57e4125ef5e2db02a7eb4099 --- /dev/null +++ b/vendor_phytium/tenglong_e/resourceschedule/BUILD.gn @@ -0,0 +1,66 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. +# +# 2023.11 Phytium change BUILD.gn. + +import("//build/ohos.gni") + +ohos_prebuilt_etc("res_sched_config") { + source = "./ressched/res_sched_config.xml" + install_enable = true + install_images = [ chipset_base_dir ] + module_install_dir = "etc/ressched" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("res_sched_plugin_switch") { + source = "./ressched/res_sched_plugin_switch.xml" + install_enable = true + install_images = [ chipset_base_dir ] + module_install_dir = "etc/ressched" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("cgroup_action_config") { + source = "./cgroup_sched/cgroup_action_config.json" + install_enable = true + install_images = [ chipset_base_dir ] + module_install_dir = "etc/cgroup_sched" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("socperf_boost_config") { + source = "./soc_perf/socperf_boost_config.xml" + install_enable = true + install_images = [ chipset_base_dir ] + module_install_dir = "etc/soc_perf" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("socperf_resource_config") { + source = "./soc_perf/socperf_resource_config.xml" + install_enable = true + install_images = [ chipset_base_dir ] + module_install_dir = "etc/soc_perf" + part_name = "product_${device_name}" +} + +group("resourceschedule") { + deps = [ + ":cgroup_action_config", + ":res_sched_config", + ":res_sched_plugin_switch", + ":socperf_boost_config", + ":socperf_resource_config", + ] +} diff --git a/vendor_phytium/tenglong_e/resourceschedule/cgroup_sched/cgroup_action_config.json b/vendor_phytium/tenglong_e/resourceschedule/cgroup_sched/cgroup_action_config.json new file mode 100755 index 0000000000000000000000000000000000000000..62881f345656076f433deac4873b8eb832b5718d --- /dev/null +++ b/vendor_phytium/tenglong_e/resourceschedule/cgroup_sched/cgroup_action_config.json @@ -0,0 +1,26 @@ +{ + "Cgroups": [ + { + "controller": "cpu", + "path": "/dev/cpuctl", + "sched_policy": { + "sp_default": "", + "sp_background": "background", + "sp_foreground": "foreground", + "sp_system_background": "system-background", + "sp_top_app": "top-app" + } + }, + { + "controller": "cpuset", + "path": "/dev/cpuset", + "sched_policy": { + "sp_default": "", + "sp_background": "background", + "sp_foreground": "foreground", + "sp_system_background": "system-background", + "sp_top_app": "top-app" + } + } + ] +} diff --git a/vendor_phytium/tenglong_e/resourceschedule/ressched/res_sched_config.xml b/vendor_phytium/tenglong_e/resourceschedule/ressched/res_sched_config.xml new file mode 100755 index 0000000000000000000000000000000000000000..638f7843803212232266481fc252b6154f7c07da --- /dev/null +++ b/vendor_phytium/tenglong_e/resourceschedule/ressched/res_sched_config.xml @@ -0,0 +1,18 @@ + + + + diff --git a/vendor_phytium/tenglong_e/resourceschedule/ressched/res_sched_plugin_switch.xml b/vendor_phytium/tenglong_e/resourceschedule/ressched/res_sched_plugin_switch.xml new file mode 100755 index 0000000000000000000000000000000000000000..e9d5ad03f1e135ef3ef7b5541366488fe471216e --- /dev/null +++ b/vendor_phytium/tenglong_e/resourceschedule/ressched/res_sched_plugin_switch.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/vendor_phytium/tenglong_e/resourceschedule/soc_perf/socperf_boost_config.xml b/vendor_phytium/tenglong_e/resourceschedule/soc_perf/socperf_boost_config.xml new file mode 100755 index 0000000000000000000000000000000000000000..0a84fed62c040ae3351f12bda6e77aa99a53eb51 --- /dev/null +++ b/vendor_phytium/tenglong_e/resourceschedule/soc_perf/socperf_boost_config.xml @@ -0,0 +1,85 @@ + + + + + + 1500 + 1992000 + + + + + 400 + 1800000 + + + + + 400 + 1608000 + + + + + 250 + 1992000 + + + + + 300 + 1608000 + + + + + 5000 + 1992000 + + + + + 5000 + 1992000 + + + + + 100 + 1608000 + + + + + 200 + 1416000 + + + + + 800 + 1992000 + 800000000 + + + + + 400 + 1608000 + + + diff --git a/vendor_phytium/tenglong_e/resourceschedule/soc_perf/socperf_resource_config.xml b/vendor_phytium/tenglong_e/resourceschedule/soc_perf/socperf_resource_config.xml new file mode 100755 index 0000000000000000000000000000000000000000..4021d9a024dbc64529eeaa82954b90863c333583 --- /dev/null +++ b/vendor_phytium/tenglong_e/resourceschedule/soc_perf/socperf_resource_config.xml @@ -0,0 +1,40 @@ + + + + + + 408000 + /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + 408000 600000 816000 1104000 1416000 1608000 1800000 1992000 + + + 1992000 + /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq + 408000 600000 816000 1104000 1416000 1608000 1800000 1992000 + + + 200000000 + /sys/class/devfreq/fde60000.gpu/min_freq + 200000000 300000000 400000000 600000000 700000000 800000000 + + + 800000000 + /sys/class/devfreq/fde60000.gpu/max_freq + 200000000 300000000 400000000 600000000 700000000 800000000 + + + diff --git a/vendor_phytium/tenglong_e/window_config/BUILD.gn b/vendor_phytium/tenglong_e/window_config/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..5a5f55e616eb126d772c2f5068cba90eae8254f1 --- /dev/null +++ b/vendor_phytium/tenglong_e/window_config/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2024 Phytium Technology Co., Ltd. All rights reserved. +# 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. + +import("//build/ohos.gni") + +ohos_prebuilt_etc("window_manager_config") { + source = "window_manager_config.xml" + install_enable = true + relative_install_dir = "window/resources" + part_name = "product_${device_name}" +} + +ohos_prebuilt_etc("display_manager_config") { + source = "display_manager_config.xml" + install_enable = true + relative_install_dir = "window/resources" + part_name = "product_${device_name}" +} + +group("window_config") { + deps = [ + ":display_manager_config", + ":window_manager_config", + ] +} diff --git a/vendor_phytium/tenglong_e/window_config/display_manager_config.xml b/vendor_phytium/tenglong_e/window_config/display_manager_config.xml new file mode 100755 index 0000000000000000000000000000000000000000..00fca5dbdf93bf6517c6dffe3b28a2d22d015839 --- /dev/null +++ b/vendor_phytium/tenglong_e/window_config/display_manager_config.xml @@ -0,0 +1,57 @@ + + + + + 150 + + + 0 + + + + + + + + + + 0 0 0 0 + + + + + + + + + + + + + + + + + + + 0 + + + + + + 0 + diff --git a/vendor_phytium/tenglong_e/window_config/window_manager_config.xml b/vendor_phytium/tenglong_e/window_config/window_manager_config.xml new file mode 100755 index 0000000000000000000000000000000000000000..55c2bc32b5af387298c0fc26b6a450f71ed69936 --- /dev/null +++ b/vendor_phytium/tenglong_e/window_config/window_manager_config.xml @@ -0,0 +1,121 @@ + + + + + + + floating fullscreen + + + 100 + + + + 50 50 50 + + + + 0.1 0.9 + + 0.5 0.33 0.67 + + 1 + + + + + 350 + + + + + 0.7 0.7 + + 0 0 1 0 + + 0 0 + + 0 + + + + + + + + 150 + + 0.2 0.0 0.2 1.0 + + + + + + + 150 + + 0.2 0.0 0.2 1.0 + + + + + + + + 200 + + + + + 1 + + 0 + + + + + + + + + + off + off + off + + + + 0 + #000000 + 0 + 0 + 0 + + + 0 + #000000 + 0 + 0 + 0 + + + + + diff --git a/vendor_phytium/tengrui_d/bluetooth/BCM4362A2.hcd b/vendor_phytium/tengrui_d/bluetooth/BCM4362A2.hcd old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/BUILD.gn b/vendor_phytium/tengrui_d/bluetooth/BUILD.gn old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/include/bt_hci_bdroid.h b/vendor_phytium/tengrui_d/bluetooth/include/bt_hci_bdroid.h old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/include/bt_vendor_brcm.h b/vendor_phytium/tengrui_d/bluetooth/include/bt_vendor_brcm.h old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/include/esco_parameters.h b/vendor_phytium/tengrui_d/bluetooth/include/esco_parameters.h old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/include/uipc_msg.h b/vendor_phytium/tengrui_d/bluetooth/include/uipc_msg.h old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/include/upio.h b/vendor_phytium/tengrui_d/bluetooth/include/upio.h old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/include/userial.h b/vendor_phytium/tengrui_d/bluetooth/include/userial.h old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/include/userial_vendor.h b/vendor_phytium/tengrui_d/bluetooth/include/userial_vendor.h old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/include/utils/Log.h b/vendor_phytium/tengrui_d/bluetooth/include/utils/Log.h old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/src/bt_vendor_brcm.c b/vendor_phytium/tengrui_d/bluetooth/src/bt_vendor_brcm.c old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/src/conf.c b/vendor_phytium/tengrui_d/bluetooth/src/conf.c old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/src/hardware.c b/vendor_phytium/tengrui_d/bluetooth/src/hardware.c old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/src/upio.c b/vendor_phytium/tengrui_d/bluetooth/src/upio.c old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/bluetooth/src/userial_vendor.c b/vendor_phytium/tengrui_d/bluetooth/src/userial_vendor.c old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/etc/BUILD.gn b/vendor_phytium/tengrui_d/etc/BUILD.gn old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/etc/param/hardware_tengrui_d.para b/vendor_phytium/tengrui_d/etc/param/hardware_tengrui_d.para old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/hals/audio/BUILD.gn b/vendor_phytium/tengrui_d/hals/audio/BUILD.gn old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/hals/audio/alsa_paths.json b/vendor_phytium/tengrui_d/hals/audio/alsa_paths.json old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/hals/audio/config/audio_policy_config.xml b/vendor_phytium/tengrui_d/hals/audio/config/audio_policy_config.xml old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/hals/audio/product.gni b/vendor_phytium/tengrui_d/hals/audio/product.gni old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/hdf_config/uhdf/BUILD.gn b/vendor_phytium/tengrui_d/hdf_config/uhdf/BUILD.gn old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/hdf_config/uhdf/device_info.hcs b/vendor_phytium/tengrui_d/hdf_config/uhdf/device_info.hcs old mode 100644 new mode 100755 index 4237df646b3559a2e69839aa955b25babb742525..a740544e09323d01c87024b30617d896b0867cfb --- a/vendor_phytium/tengrui_d/hdf_config/uhdf/device_info.hcs +++ b/vendor_phytium/tengrui_d/hdf_config/uhdf/device_info.hcs @@ -67,76 +67,6 @@ } } } - usb :: host { - hostName = "usb_host"; - priority = 50; - caps = ["DAC_OVERRIDE"]; - usb_pnp_manager_device :: device { - device0 :: deviceNode { - policy = 2; - priority = 70; - moduleName = "libusb_pnp_manager.z.so"; - serviceName = "usb_pnp_manager"; - } - } - usbfn_device :: device { - device0 :: deviceNode { - policy = 2; - priority = 80; - preload = 2; - moduleName = "libusbfn.z.so"; - serviceName = "usbfn"; - deviceMatchAttr = "usbfn_driver"; - } - } - ecm_device :: device { - device0 :: deviceNode { - policy = 2; - priority = 81; - preload = 2; - moduleName = "libusbfn_cdcecm.z.so"; - serviceName = "usbfn_cdcecm"; - deviceMatchAttr = "usbfn_cdcecm_driver"; - } - } - acm_device :: device { - device0 :: deviceNode { - policy = 2; - priority = 100; - preload = 2; - moduleName = "libusbfn_cdcacm.z.so"; - serviceName = "usbfn_cdcacm"; - deviceMatchAttr = "usbfn_cdcacm_driver"; - } - } - mtp_device :: device { - device0 :: deviceNode { - policy = 2; - priority = 90; - preload = 2; - moduleName = "libusbfn_mtp_driver.z.so"; - serviceName = "usbfn_mtp_interface_service"; - deviceMatchAttr = "usbfn_mtp_interface_driver"; - } - } - usb_device :: device { - device0 :: deviceNode { - policy = 2; - priority = 100; - moduleName = "libusb_driver.z.so"; - serviceName = "usb_interface_service"; - deviceMatchAttr = "usb_device_interface_driver"; - } - } - ddk_device :: device { - device0 :: deviceNode { - policy = 2; - priority = 100; - moduleName = "libusb_ddk_driver.z.so"; - serviceName = "usb_ddk_service"; - } - } - } power :: host { hostName = "power_host"; priority = 50; diff --git a/vendor_phytium/tengrui_d/preinstall-config/BUILD.gn b/vendor_phytium/tengrui_d/preinstall-config/BUILD.gn old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/preinstall-config/install_list.json b/vendor_phytium/tengrui_d/preinstall-config/install_list.json old mode 100644 new mode 100755 index 165920a15940cfde4751f49df89daa28a7c55d5a..bcd127ac0b07f91eb4a711e5a0bbc2b84d04cdcf --- a/vendor_phytium/tengrui_d/preinstall-config/install_list.json +++ b/vendor_phytium/tengrui_d/preinstall-config/install_list.json @@ -195,6 +195,10 @@ { "app_dir": "/system/app/com.ohos.calendardata", "removable": false + }, + { + "app_dir": "/system/app/ohos.samples.browser1", + "removable": false } ] } diff --git a/vendor_phytium/tengrui_d/preinstall-config/install_list_capability.json b/vendor_phytium/tengrui_d/preinstall-config/install_list_capability.json old mode 100644 new mode 100755 index 388a0da150a07564f6bed784d96065089416257b..b75b2043640ba1a626029b53404b595f05dd5989 --- a/vendor_phytium/tengrui_d/preinstall-config/install_list_capability.json +++ b/vendor_phytium/tengrui_d/preinstall-config/install_list_capability.json @@ -209,6 +209,12 @@ "app_signature" : ["1C6905C65DE22F5160790D34ADA462EE9ED3D9EEAA4FCBD4FEC7FFEE7D1D4FD2"], "allowAppDesktopIconHide": true, "allowAppUsePrivilegeExtension": true + }, + { + "bundleName": "ohos.samples.browser1", + "app_signature": ["208850C05E411A1EA7B1F26B4D5865208415D8D878D6CA42F9290BF6D6CA6D8A"], + "allowAppUsePrivilegeExtension": true, + "allowAppDesktopIconHide": false } ] } diff --git a/vendor_phytium/tengrui_d/preinstall-config/install_list_permissions.json b/vendor_phytium/tengrui_d/preinstall-config/install_list_permissions.json old mode 100644 new mode 100755 index bc487ce8c78efad9aa9ec4c2f4dae33c80d48528..d5b95845a89b650a97d9f8bd7aa327ab4f5207b0 --- a/vendor_phytium/tengrui_d/preinstall-config/install_list_permissions.json +++ b/vendor_phytium/tengrui_d/preinstall-config/install_list_permissions.json @@ -316,5 +316,47 @@ "userCancellable" : false } ] + }, + { + "bundleName": "ohos.samples.browser1", + "app_signature" : ["208850C05E411A1EA7B1F26B4D5865208415D8D878D6CA42F9290BF6D6CA6D8A"], + "permissions" : [ + { + "name" : "ohos.permission.GET_INSTALLED_BUNDLE_LIST", + "userCancellable" : false + }, + { + "name": "ohos.permission.READ_MEDIA", + "userCancellable" : false + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "userCancellable" : false + }, + { + "name": "ohos.permission.ACCESS_DLP_FILE", + "userCancellable" : false + }, + { + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "userCancellable" : false + }, + { + "name":"ohos.permission.FILE_ACCESS_MANAGER", + "userCancellable" : false + }, + { + "name":"ohos.permission.START_ABILIIES_FROM_BACKGROUND", + "userCancellable" : false + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "userCancellable" : false + }, + { + "name": "ohos.permission.MEDIA_LOCATION", + "userCancellable" : false + } + ] } ] diff --git a/vendor_phytium/tengrui_d/preinstall-config/uninstall_list.json b/vendor_phytium/tengrui_d/preinstall-config/uninstall_list.json old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/product.gni b/vendor_phytium/tengrui_d/product.gni old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/resourceschedule/BUILD.gn b/vendor_phytium/tengrui_d/resourceschedule/BUILD.gn old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/resourceschedule/cgroup_sched/cgroup_action_config.json b/vendor_phytium/tengrui_d/resourceschedule/cgroup_sched/cgroup_action_config.json old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/resourceschedule/ressched/res_sched_config.xml b/vendor_phytium/tengrui_d/resourceschedule/ressched/res_sched_config.xml old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/resourceschedule/ressched/res_sched_plugin_switch.xml b/vendor_phytium/tengrui_d/resourceschedule/ressched/res_sched_plugin_switch.xml old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/resourceschedule/soc_perf/socperf_boost_config.xml b/vendor_phytium/tengrui_d/resourceschedule/soc_perf/socperf_boost_config.xml old mode 100644 new mode 100755 diff --git a/vendor_phytium/tengrui_d/resourceschedule/soc_perf/socperf_resource_config.xml b/vendor_phytium/tengrui_d/resourceschedule/soc_perf/socperf_resource_config.xml old mode 100644 new mode 100755