mirror of
https://github.com/openharmony/device_soc_allwinner.git
synced 2026-06-30 22:08:38 -04:00
migrated from t507 sig repository to master
Signed-off-by: weipanga <weipanga@isoftstone.com>
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 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.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
All configurations in this file will be merged to OAT-Default.xml, if you have any questions or concerns, please create issue in OpenHarmony/tools_oat and @jalenchen or chenyaxun.
|
||||
|
||||
licensefile:
|
||||
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
|
||||
|
||||
policylist:
|
||||
1. policy: If the OAT-Default.xml policies do not meet your requirements, please add policies here.
|
||||
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
|
||||
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
|
||||
3. policyitem type:
|
||||
"compatibility" is used to check license compatibility in the specified path;
|
||||
"license" is used to check source license header in the specified path;
|
||||
"copyright" is used to check source copyright header in the specified path;
|
||||
"import" is used to check source dependency in the specified path, such as import ... ,include ...
|
||||
"filetype" is used to check file type in the specified path, supported file types: archive, binary
|
||||
"filename" is used to check whether the specified file exists in the specified path(projectroot means the root dir of the project), supported file names: LICENSE, README, README.OpenSource
|
||||
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
|
||||
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
|
||||
7. policyitem filefilter: Used to bind filefilter which define filter rules.
|
||||
7. policyitem desc: Used to describe the reason of this policy item, committers will check this while merging the code.
|
||||
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
|
||||
|
||||
Note:If the text contains special characters, please escape them according to the following rules:
|
||||
" == "
|
||||
& == &
|
||||
' == '
|
||||
< == <
|
||||
> == >
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="copyright" name="VYAGOO TECHNOLOGY Co., Ltd." path=".*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc=""/>
|
||||
<policyitem type="license" name="EndUserLicenseAgreement" path=".*" desc="License Header Invalid"/>
|
||||
<policyitem type="copyright" name="Rockchip Electronics Co. LTD" path=".*" desc="copyright Header Invalid"/>
|
||||
<policyitem type="copyright" name="Rockchip Electronics Co., Ltd." path=".*" desc="copyright Header Invalid"/>
|
||||
<policyitem type="copyright" name="RockChip Limited. All rights reserved." path=".*" desc="copyright Header Invalid"/>
|
||||
<policyitem type="copyright" name="Allwinner Open Source Organization" path=".*" desc="copyright Header Invalid"/>
|
||||
<policyitem type="copyright" name="HiHope Open Source Organization ." path=".*" desc="copyright Header Invalid"/>
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">>
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<filteritem type="filepath" name="t507/patches/config/t507_linux-5.10_defconfig" desc="Temp files"/>
|
||||
<filteritem type="filepath" name="t507/hardware/gpu/BUILD.gn" desc="Temp files"/>
|
||||
<filteritem type="filepath" name="t507/BUILD.gn " desc="Temp files"/>
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
|
||||
<filteritem type="filepath" name="t507/patches/config/t507_linux-5.10_defconfig" desc="Temp files"/>
|
||||
<filteritem type="filepath" name="t507/hardware/gpu/BUILD.gn" desc="Temp files"/>
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<filteritem type="filename" name="*.bin|*.fex|*.bmp|*.so|*.sft|*.awf|*.gz|*.png|*.bz2" desc="desc files"/>
|
||||
<filteritem type="filepath" name="t507/hardware/gpu/lib-mesa/.*" desc=""/>
|
||||
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
||||
@@ -0,0 +1,34 @@
|
||||
# device_soc_allwinner
|
||||
|
||||
#### 介绍
|
||||
在该目录下,托管珠海研果科技有限公司基于T507小熊派开发板(EVB_OH1)开发的样例代码。
|
||||
|
||||
|
||||
|
||||
|
||||
#### 获取代码流程
|
||||
在 https://gitee.com/openharmony/device_board_isoftstone 链接下的目录下进行详细介绍。
|
||||
|
||||
|
||||
|
||||
#### 代码框架
|
||||
|
||||
```
|
||||
device/soc/allwinner/
|
||||
└──t507 # T507芯片平台
|
||||
└── hardware # 硬件配置
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### 编译流程
|
||||
|
||||
在 https://gitee.com/openharmony/device_board_isoftstone 链接下的目录下进行详细介绍。
|
||||
|
||||
|
||||
|
||||
## 相关仓库
|
||||
|
||||
[vendor_isoftstone](https://gitee.com/openharmony/vendor_isoftstone)
|
||||
|
||||
[device_board_isoftstone](https://gitee.com/openharmony/device_board_isoftstone)
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef DEFAULT_CONFIG_H
|
||||
#define DEFAULT_CONFIG_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PORT_FILE_PATH "/sys/kernel/debug/usb/100e0000.hidwc3_0/mode"
|
||||
#define UDC_NAME "100e0000.hidwc3_0"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // DEFAULT_CONFIG_H
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 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.
|
||||
|
||||
Notes:
|
||||
This is project config file for OpenHarmony OSS Audit Tool, if you have any questions or concerns, please email chenyaxun.
|
||||
-->
|
||||
<!-- OAT(OSS Audit Tool) configuration guide:
|
||||
basedir: Root dir, the basedir + project path is the real source file location.
|
||||
licensefile:
|
||||
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
|
||||
|
||||
tasklist(only for batch mode):
|
||||
1. task: Define oat check thread, each task will start a new thread.
|
||||
2. task name: Only an name, no practical effect.
|
||||
3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
|
||||
4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
|
||||
5. task project: Projects to be checked, the path field define the source root dir of the project.
|
||||
|
||||
|
||||
policyList:
|
||||
1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process.
|
||||
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
|
||||
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
|
||||
3. policyitem type:
|
||||
"compatibility" is used to check license compatibility in the specified path;
|
||||
"license" is used to check source license header in the specified path;
|
||||
"copyright" is used to check source copyright header in the specified path;
|
||||
"import" is used to check source dependency in the specified path, such as import ... ,include ...
|
||||
"filetype" is used to check file type in the specified path, supported file types: archive, binary
|
||||
"filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource
|
||||
|
||||
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
|
||||
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
|
||||
7. policyitem filefilter: Used to bind filefilter which define filter rules.
|
||||
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
|
||||
|
||||
Note:If the text contains special characters, please escape them according to the following rules:
|
||||
" == >
|
||||
& == >
|
||||
' == >
|
||||
< == >
|
||||
> == >
|
||||
-->
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile>build/LICENSE|sdk_linux/open_source/bin/LICENSE</licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="copyright" name="HiSilicon (Shanghai) Technologies CO., LIMITED." path=".*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="小海思开发代码"/>
|
||||
<policyitem type="license" name="EndUserLicenseAgreement" path="sdk_linux/mpp/lib/LICENSE" desc="二进制文件遵循的licence"/>
|
||||
<policyitem type="license" name="EndUserLicenseAgreement" path="sdk_linux/open_source/bin/LICENSE" desc="二进制文件遵循的licence"/>
|
||||
<policyitem type="license" name="ThirdPartyNotice" path="sdk_linux/open_source/bin/NOTICE" desc="三方软件notice"/>
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<filteritem type="filename" name="BUILD.gn" desc="编译脚本本仓涉及多种许可"/>
|
||||
<filteritem type="filename" name="init.cfg" desc="配置文件,不能加其他注释"/>
|
||||
<filteritem type="filename" name="T507-emmc.xml" desc="tool烧写分区,不能加其他注释"/>
|
||||
<filteritem type="filename" name="updater_specified_config.xml" desc="配置文件,不能加其他注释"/>
|
||||
<filteritem type="filename" name="NOTICE" desc="ThirdPartyNotice"/>
|
||||
<filteritem type="filepath" name="build/updater_config/.*" desc="配置文件,不能加其他注释"/>
|
||||
<filteritem type="filepath" name="build/vendor/etc/.*" desc="配置文件,不能加其他注释"/>
|
||||
<filteritem type="filepath" name="updater/.*" desc="配置文件,不能加其他注释"/>
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<filteritem type="filename" name="README.OpenSource"/>
|
||||
<filteritem type="filename" name="README"/>
|
||||
<filteritem type="filename" name="README"/>
|
||||
<filteritem type="filename" name="BUILD.gn" desc="Compilation scripts do not declare license"/>
|
||||
<filteritem type="filename" name="u-boot-T507_emmc.bin" desc="Comply with sdk_linux/open_source/bin/LICENSE"/>
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies" >
|
||||
<filteritem type="filename" name="README.OpenSource"/>
|
||||
<filteritem type="filename" name="README"/>
|
||||
<filteritem type="filename" name="BUILD.gn" desc="HiSilicon copyright"/>
|
||||
<filteritem type="filename" name="u-boot-T507_emmc.bin" desc="Third-party generated"/>
|
||||
</filefilter>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies" >
|
||||
</filefilter>
|
||||
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies" >
|
||||
</filefilter>
|
||||
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies" >
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies" >
|
||||
<filteritem type="filename" name="rsa_private_key2048.pem" desc="key值不可用添加其他信息"/>
|
||||
<filteritem type="filename" name="u-boot-T507_emmc.bin" desc="u-boot源码生成,已放置NOTICE文件,源代码在device_allwinner_third_party_uboot"/>
|
||||
</filefilter>
|
||||
|
||||
</filefilterlist>
|
||||
|
||||
</oatconfig>
|
||||
</configuration>
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2022 VYAGOO 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
group("hardware_group") {
|
||||
deps = [
|
||||
"//device/soc/allwinner/t507/hardware/wifi:xr829",
|
||||
"//device/soc/allwinner/t507/hardware/gpu:mesa-gpu",
|
||||
"//device/soc/allwinner/t507/hardware/codec:codec",
|
||||
]
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
End User License Agreement
|
||||
|
||||
THIS END USER LICENSE AGREEMENT (“AGREEMENT”) IS A LEGAL AGREEMENT BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND Shenzhen Allwinner Online Co., Ltd. (HERE AFTER REFERRED TO AS"AWOL") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS AGREEMENT. AWOL IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS AGREEMENT. BY DOWNDOADING OR BY INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT,AWOL WILL NOT LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE, AND YOU SHALL PROMPTLY DESTROY, DELETE, OR RETURN THE SOFTWARE TO YOUR SUPPLIER.
|
||||
|
||||
“SOFTWARE” means the software in object code provided under the terms of this Agreement.
|
||||
|
||||
Xiangzhou District,Zhuhai,China is the signing place of this Agreement.
|
||||
|
||||
1. GRANT OF LICENSE
|
||||
In consideration of your agreement to abide by the following terms, and subject to the terms and conditions of this Agreement, AWOL hereby grants YOU, a non-transferable, non-exclusive, royalty-free, revocable, worldwide copyright license (without the right to sublicense) to internally use the SOFTWARE and to manufacture, have manufactured, or sell, supply or distribute any products which use or embody any of the SOFTWARE or any of the intellectual property rights therein.
|
||||
|
||||
All rights to the SOFTWARE and all intellectual property rights contained therein are reserved and shall remain the sole and exclusive property of AWOL . The SOFTWARE is licensed but not sold. Except as expressly licensed in Clause 1, in no event shall the license granted in this Clause 1 be construed as granting YOU expressly or by implication, estoppels or otherwise, licenses to any intellectual property rights, including but not limited to patent rights, copyrights, trademark or trade secret in the SOFTWARE.
|
||||
|
||||
|
||||
2. RESTRICTIONS
|
||||
YOU shall reproduce and not remove or obscure any notice incorporated by AWOL in the SOFTWARE to protect AWOL’s intellectual property rights embodied therein.
|
||||
|
||||
YOU shall not decompile, disassemble, or reverse engineer the SOFTWARE.
|
||||
|
||||
YOU shall not distribute the SOFTWARE under an open source license as listed by the Open Source Initiative (a non-profit corporation whose website is www.opensource.org), or other license which requires the source code or object code of the SOFTWARE to be licensed or otherwise shared with any third party.
|
||||
|
||||
3. CONFLICT WITH OPEN SOURCE SOFTWARE LICENSE
|
||||
The SOFTWARE may contain open source software. If the license applied on such open source software has conflict with this Agreement, the license applied on such open source software will prevail and apply to the open source software.
|
||||
|
||||
4. FEEDBACK
|
||||
YOU may choose to provide suggestions, comments, feedback, ideas, modifications or know-how (whether in oral or written form) relating to the use of the SOFTWARE ("Feedback") to AWOL under the terms of this Agreement. YOU hereby grants to AWOL and its affiliates, under all of you and your affiliates’ (as applicable) intellectual property rights, a perpetual, irrevocable, royalty free, non-exclusive, worldwide license to (i) use, copy and modify the Feedback; (ii) sell, supply, or otherwise distribute the Feedback; (iii) design, have designed, manufacture, have manufactured, use, import, sell, and otherwise distribute and dispose of products that incorporate the Feedback; and (iv) sublicense (together with the rights to further sublicense) the rights granted in this paragraph to any third party.
|
||||
|
||||
5. NO WARRANTY
|
||||
YOU AGREE THAT THE SOFTWARE IS PROVIDED BY AWOL ON AN "AS IS" BASIS. AWOL MAKES NO WARRANTY, EXPRESSED OR IMPLIED OR STATUTORY, WITH RESPECT TO ANY OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.
|
||||
|
||||
YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, SOFTWARE APPLICATIONS DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
6. NO LIABILITY
|
||||
PLEASE NOTE THAT YOU SHOULD USE THE SOFTWARE AT YOUR OWN RISK.
|
||||
|
||||
IN NO EVENT SHALL AWOL BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHER LEGAL THEORY, EVEN IF AWOL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF THE SOFTWARE HAS ANY MATERIAL, VERIFIABLE, AND REPRODUCIBLE PROGRAM ERRORS, AWOL SHALL HAVE NO LIABILITY TO MODIFY SUCH ERRORS.
|
||||
|
||||
NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS AGREEMENT, THE MAXIMUM LIABILITY OF AWOL TO YOU IN AGGREGATE FOR ALL CLAIMS MADE AGAINST AWOL IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH THE SUBJECT MATTER OF THIS AGREEMENT SHALL NOT EXCEED THE TOTAL OF SUMS RECEIVED BY AWOL FROM YOU FOR THIS AGREEMENT. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT ENLARGE OR EXTEND THE LIMIT.
|
||||
|
||||
7. CONFIDENTIALITY
|
||||
YOU acknowledge and agree that the SOFTWARE provided under this Agreement contain trade secrets and confidential material of AWOL and YOU agree to maintain all such information in confidence and apply security measures no less stringent than the measures which YOU apply to protect your own like information, but not less than a reasonable degree of care, to prevent their unauthorized disclosure and use. The period of confidentiality shall be indefinite. YOU agree not to use any such information other than in normal use of the SOFTWARE under the license granted in this Agreement.
|
||||
|
||||
8. TERM AND TERMINATION
|
||||
This Agreement shall remain in force until terminated. AWOL may terminate this Agreement at any time with or without any cause. Upon termination of this Agreement, YOU shall immediately stop using the SOFTWARE and confidential information and destroy all copies of the SOFTWARE and confidential information in your possession, together with all documentation and related materials. The provisions of clauses 2, 3, 4, 5, 6, 7,8 and 9 shall survive termination of this Agreement.
|
||||
|
||||
9. GENERAL
|
||||
Any provision of this Agreement which is prohibited or unenforceable in any jurisdiction shall be ineffective to the extent of such prohibition or unenforceability without affecting, impairing or invalidating the remaining provisions hereof.
|
||||
|
||||
The failure by AWOL to enforce any of the provisions of this Agreement, unless waived in writing, shall not constitute a waiver of AWOL's rights to enforce such provision or any other provision of this Agreement in the future.
|
||||
|
||||
This Agreement shall be governed by and construed in accordance with the laws of People’s Republic of China, without reference to the principles of conflicts of laws. Any dispute arising out of or relating to this Agreement shall be submitted to the jurisdiction of the court of the signing place of this Agreement and the parties waive all objections to that jurisdiction and venue.
|
||||
|
||||
---------------------------------------------------------------------
|
||||
Copyright (C) 2022 VYAGOO TECHNOLOGY Co., Ltd. All rights reserved.
|
||||
@@ -0,0 +1,64 @@
|
||||
# Copyright (C) 2022 VYAGOO 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.
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/kernel/kernel.gni")
|
||||
|
||||
CODEC_ETC_DIR="//device/soc/allwinner/t507/hardware/codec/media/etc"
|
||||
CODEC_LIB_DIR="//device/soc/allwinner/t507/hardware/codec/media/lib"
|
||||
|
||||
if (linux_kernel_version == "linux-5.10") {
|
||||
ohos_prebuilt_etc("OmxCore") {
|
||||
source = "$CODEC_LIB_DIR/libOmxCore.z.so"
|
||||
module_install_dir = "lib"
|
||||
install_images = [ "vendor" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("OMX_Pluginhw") {
|
||||
source = "$CODEC_LIB_DIR/libOMX_Pluginhw.z.so"
|
||||
module_install_dir = "lib"
|
||||
install_images = [ "vendor" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("OmxVdec") {
|
||||
source = "$CODEC_LIB_DIR/libOmxVdec.z.so"
|
||||
module_install_dir = "lib"
|
||||
install_images = [ "vendor" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("OmxVenc") {
|
||||
source = "$CODEC_LIB_DIR/libOmxVenc.z.so"
|
||||
module_install_dir = "lib"
|
||||
install_images = [ "vendor" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("cedarc.conf") {
|
||||
source = "$CODEC_ETC_DIR/cedarc.conf"
|
||||
install_images = [ "vendor" ]
|
||||
module_install_dir = "etc"
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
group("codec") {
|
||||
deps = [
|
||||
":cedarc.conf",
|
||||
":OmxCore",
|
||||
":OMX_Pluginhw",
|
||||
":OmxVdec",
|
||||
":OmxVenc",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
########### paramter ############
|
||||
[paramter]
|
||||
# save bitstream in vdecoder.c
|
||||
vdecoder_save_bitstream = 0
|
||||
vdecoder_save_bitstream_path = /data/camera/bs.dat
|
||||
|
||||
# save special bitstream in vdecoder.c
|
||||
vdecoder_save_special_bitstream = 0
|
||||
vdecoder_save_special_bitstream_path = /data/camera/spec.awsp
|
||||
|
||||
# save picture from start_num to start_num + total_num
|
||||
vdecoder_save_picture_en = 0
|
||||
vdecoder_save_md5 = 0
|
||||
vdecoder_save_picture_start_num = 0
|
||||
vdecoder_save_picture_total_num = 10
|
||||
vdecoder_save_picture_path = /data/camera/pic.dat
|
||||
|
||||
vdecoder_show_speed_info = 0
|
||||
|
||||
# printf the log of vdecoder.c
|
||||
vdecoder_printf_log = 0
|
||||
vdecoder_fbm_printf_log = 0
|
||||
vdecoder_sbm_printf_log = 0
|
||||
|
||||
ve_printf_register = 0
|
||||
|
||||
check_malloc_leak = 0
|
||||
|
||||
ipcs_save_picture_en = 0
|
||||
ipcs_save_md5 = 0
|
||||
ipcs_save_picture_start_num = 0
|
||||
ipcs_save_picture_total_num = 10
|
||||
ipcs_save_inpic_path = /mnt/ipcs_input.dat
|
||||
ipcs_save_outpic_path = /mnt/ipcs_output.dat
|
||||
|
||||
# log will output if level >= log_level
|
||||
# #VERBOSE = 2,
|
||||
# #DEBUG = 3,
|
||||
# #INFO = 4,
|
||||
# #WARNING = 5,
|
||||
# #ERROR = 6,
|
||||
# setprop vendor.omx.debuglevel = 3
|
||||
cdc_log_level = 3
|
||||
vdec_log_level = 3
|
||||
venc_log_level = 3
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
+143
@@ -0,0 +1,143 @@
|
||||
# Copyright (c) 2021 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
group("display_group") {
|
||||
deps = [
|
||||
":display_device",
|
||||
":display_gfx",
|
||||
":display_gralloc",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("display_gralloc") {
|
||||
sources = [
|
||||
"src/display_gralloc/display_gralloc.c",
|
||||
"src/display_gralloc/display_gralloc_gbm.c",
|
||||
"src/display_gralloc/seed_gbm.c",
|
||||
]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//drivers/peripheral/display/interfaces/include",
|
||||
"//drivers/peripheral/base",
|
||||
"//drivers/framework/include/utils",
|
||||
"//drivers/adapter/uhdf2/osal/include",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/graphic/standard/utils/include",
|
||||
"//foundation/graphic/standard/prebuilts/librarys/drm/include",
|
||||
"//base/hiviewdfx/interfaces/innerkits/libhilog/include",
|
||||
]
|
||||
output_name = "display_gralloc"
|
||||
cflags = [
|
||||
"-DGRALLOC_GBM_SUPPORT",
|
||||
"-Wno-macro-redefined",
|
||||
]
|
||||
deps = [
|
||||
"//third_party/libdrm:libdrm",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
subsystem_name = "hdf"
|
||||
part_name = "display_device_driver"
|
||||
}
|
||||
|
||||
ohos_shared_library("display_gfx") {
|
||||
sources = [ "src/display_gfx/display_gfx.c" ]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//drivers/peripheral/display/interfaces/include",
|
||||
"//drivers/peripheral/base",
|
||||
"//drivers/framework/include/utils",
|
||||
"//drivers/adapter/uhdf2/adapter/osal/include/",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/graphic/standard/utils/include",
|
||||
"//device/soc/allwinner/t507/hardware/rga/include/",
|
||||
"//base/hiviewdfx/interfaces/innerkits/libhilog/include",
|
||||
]
|
||||
output_name = "display_gfx"
|
||||
cflags = [ "-Wno-macro-redefined" ]
|
||||
deps = [
|
||||
":display_gralloc",
|
||||
"//device/soc/allwinner/t507/hardware/rga:librga",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
subsystem_name = "hdf"
|
||||
part_name = "display_device_driver"
|
||||
}
|
||||
|
||||
ohos_shared_library("display_device") {
|
||||
sources = [
|
||||
"src/display_device/drm_connector.cpp",
|
||||
"src/display_device/drm_crtc.cpp",
|
||||
"src/display_device/drm_device.cpp",
|
||||
"src/display_device/drm_display.cpp",
|
||||
"src/display_device/drm_encoder.cpp",
|
||||
"src/display_device/drm_plane.cpp",
|
||||
"src/display_device/drm_vsync_worker.cpp",
|
||||
"src/display_device/hdi_composer.cpp",
|
||||
"src/display_device/hdi_device_interface.cpp",
|
||||
"src/display_device/hdi_display.cpp",
|
||||
"src/display_device/hdi_drm_composition.cpp",
|
||||
"src/display_device/hdi_drm_layer.cpp",
|
||||
"src/display_device/hdi_layer.cpp",
|
||||
"src/display_device/hdi_session.cpp",
|
||||
]
|
||||
output_name = "display_device"
|
||||
include_dirs = [
|
||||
"src/display_device",
|
||||
"include",
|
||||
"//drivers/peripheral/display/interfaces/include",
|
||||
"//drivers/peripheral/base",
|
||||
"//drivers/framework/include/utils",
|
||||
"//drivers/adapter/uhdf2/osal/include",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/graphic/standard/utils/include",
|
||||
"//foundation/graphic/standard/prebuilts/librarys/drm/include",
|
||||
"//base/hiviewdfx/interfaces/innerkits/libhilog/include",
|
||||
]
|
||||
deps = [
|
||||
":display_gralloc",
|
||||
"//third_party/libdrm:libdrm",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
cflags_cc = [
|
||||
"-Wno-error=unused-function",
|
||||
"-Wno-error=missing-braces",
|
||||
"-Wno-error=#warnings",
|
||||
]
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
subsystem_name = "hdf"
|
||||
part_name = "display_device_driver"
|
||||
}
|
||||
|
||||
group("display_layer") {
|
||||
deps = [
|
||||
":display_device",
|
||||
":display_gfx",
|
||||
":display_gralloc",
|
||||
]
|
||||
}
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DISP_COMMON_H
|
||||
#define DISP_COMMON_H
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "hilog/log.h"
|
||||
#include "stdio.h"
|
||||
#ifdef HDF_LOG_TAG
|
||||
#undef HDF_LOG_TAG
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef LOG_TAG
|
||||
#undef LOG_DOMAIN
|
||||
#define LOG_TAG "DISP_SEED"
|
||||
#define LOG_DOMAIN 0xD001400
|
||||
|
||||
#ifndef DISPLAY_UNUSED
|
||||
#define DISPLAY_UNUSED(x) (void)x
|
||||
#endif
|
||||
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__)
|
||||
|
||||
#ifndef DISPLAY_LOGD
|
||||
#define DISPLAY_LOGD(format, ...) \
|
||||
do { \
|
||||
HILOG_INFO(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n", __FUNCTION__, __FILENAME__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_LOGI
|
||||
#define DISPLAY_LOGI(format, ...) \
|
||||
do { \
|
||||
HILOG_INFO(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n", __FUNCTION__, __FILENAME__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_LOGW
|
||||
#define DISPLAY_LOGW(format, ...) \
|
||||
do { \
|
||||
HILOG_WARN(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n", __FUNCTION__, __FILENAME__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_LOGE
|
||||
#define DISPLAY_LOGE(format, ...) \
|
||||
do { \
|
||||
HILOG_ERROR(LOG_CORE, \
|
||||
"\033[0;32;31m" \
|
||||
"[%{public}s@%{public}s:%{public}d] " format "\033[m" \
|
||||
"\n", \
|
||||
__FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_NULLPOINTER_RETURN_VALUE
|
||||
#define CHECK_NULLPOINTER_RETURN_VALUE(pointer, ret) \
|
||||
do { \
|
||||
if ((pointer) == NULL) { \
|
||||
DISPLAY_LOGE("pointer is null and return ret\n"); \
|
||||
return (ret); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_NULLPOINTER_RETURN
|
||||
#define CHECK_NULLPOINTER_RETURN(pointer) \
|
||||
do { \
|
||||
if ((pointer) == NULL) { \
|
||||
DISPLAY_LOGE("pointer is null and return\n"); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_CHK_RETURN
|
||||
#define DISPLAY_CHK_RETURN(val, ret, ...) \
|
||||
do { \
|
||||
if (val) { \
|
||||
__VA_ARGS__; \
|
||||
return (ret); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_CHK_RETURN_NOT_VALUE
|
||||
#define DISPLAY_CHK_RETURN_NOT_VALUE(val, ret, ...) \
|
||||
do { \
|
||||
if (val) { \
|
||||
__VA_ARGS__; \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DISP_COMMON_H */
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DISPLAY_GRALLOC_INTERNAL_H
|
||||
#define DISPLAY_GRALLOC_INTERNAL_H
|
||||
#include "display_type.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#define GRALLOC_PRIV_NUM_FDS 0
|
||||
#define GRALLOC_PRIV_NUM_INTS ((sizeof(PriBufferHandle) - sizeof(BufferHandle)) / sizeof(int) - GRALLOC_PRIV_NUM_FDS)
|
||||
|
||||
#define INVALID_PIXEL_FMT 0
|
||||
#define MAX_PLANES 3
|
||||
|
||||
typedef struct plane_info {
|
||||
uint32_t offset;
|
||||
uint32_t byte_stride;
|
||||
uint32_t alloc_width;
|
||||
uint32_t alloc_height;
|
||||
}plane_info_t;
|
||||
|
||||
typedef struct {
|
||||
BufferHandle hdl;
|
||||
int yuv_info;
|
||||
int plan_num;
|
||||
plane_info_t plane_info[MAX_PLANES];
|
||||
uint64_t id;
|
||||
} PriBufferHandle;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "drm_connector.h"
|
||||
#include <cinttypes>
|
||||
#include <securec.h>
|
||||
#include "drm_device.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
void DrmMode::ConvertToHdiMode(DisplayModeInfo &hdiMode)
|
||||
{
|
||||
hdiMode.height = mModeInfo.vdisplay;
|
||||
hdiMode.width = mModeInfo.hdisplay;
|
||||
hdiMode.freshRate = mModeInfo.vrefresh;
|
||||
hdiMode.id = mId;
|
||||
}
|
||||
|
||||
DrmConnector::DrmConnector(drmModeConnector c, FdPtr &fd)
|
||||
: mId(c.connector_id),
|
||||
mPhyWidth(c.mmWidth),
|
||||
mPhyHeight(c.mmHeight),
|
||||
mEncoderId(c.encoder_id),
|
||||
mConnectState(c.connection),
|
||||
mDrmFdPtr(fd)
|
||||
{
|
||||
DISPLAY_LOGD("encoder_id %{public}d", mEncoderId);
|
||||
DISPLAY_LOGD("the connect state is %{public}d", mConnectState);
|
||||
|
||||
for (int i = 0; i < c.count_encoders; i++) {
|
||||
mPossibleEncoders.push_back(c.encoders[i]);
|
||||
DISPLAY_LOGD("add possible encoder id %{public}d", c.encoders[i]);
|
||||
}
|
||||
|
||||
ConvertToHdiType(c.connector_type, mType);
|
||||
ConvertTypeToName(mType, mName);
|
||||
InitModes(c);
|
||||
DISPLAY_LOGD("name %{public}s", mName.c_str());
|
||||
}
|
||||
|
||||
void DrmConnector::InitModes(drmModeConnector c)
|
||||
{
|
||||
DISPLAY_LOGD("id %{public}d", mId);
|
||||
mModes.clear();
|
||||
mPreferenceId = INVALID_MODE_ID;
|
||||
for (int i = 0; i < c.count_modes; i++) {
|
||||
drmModeModeInfoPtr mode = c.modes + i;
|
||||
DISPLAY_LOGD("mode: hdisplay %{public}d, vdisplay %{public}d vrefresh %{public}d type %{public}d",
|
||||
mode->hdisplay, mode->vdisplay, mode->vrefresh, mode->type);
|
||||
if ((mPreferenceId == INVALID_MODE_ID) && (mode->type & DRM_MODE_TYPE_PREFERRED)) {
|
||||
DISPLAY_LOGD("set it to prefernce id %{public}d", i);
|
||||
mPreferenceId = i;
|
||||
}
|
||||
mModes.emplace(i, DrmMode { *mode, i });
|
||||
}
|
||||
DISPLAY_LOGD("mode count %{public}zd", mModes.size());
|
||||
}
|
||||
|
||||
int32_t DrmConnector::Init(DrmDevice &drmDevice)
|
||||
{
|
||||
int32_t ret;
|
||||
DrmProperty prop;
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((mDrmFdPtr == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("the mDrmFdPtr is NULL"));
|
||||
DISPLAY_CHK_RETURN((mDrmFdPtr->GetFd() == -1), DISPLAY_FAILURE, DISPLAY_LOGE("the drm fd is -1"));
|
||||
// find dpms prop
|
||||
ret = drmDevice.GetConnectorProperty(*this, PROP_DPMS, prop);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not get mode prop id"));
|
||||
mPropDpmsId = prop.propId;
|
||||
mDpmsState = prop.value;
|
||||
DISPLAY_LOGD("dpms state : %{public}" PRIu64 "", mDpmsState);
|
||||
// find the crtcid
|
||||
ret = drmDevice.GetConnectorProperty(*this, PROP_CRTCID, prop);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get out fence prop id"));
|
||||
mPropCrtcId = prop.propId;
|
||||
DISPLAY_LOGD("encoder_id %{public}d", mEncoderId);
|
||||
DISPLAY_LOGD("mPropCrtcId %{public}d", mPropCrtcId);
|
||||
// find the brightness
|
||||
ret = drmDevice.GetConnectorProperty(*this, PROP_BRIGHTNESS, prop);
|
||||
if (ret == DISPLAY_SUCCESS) {
|
||||
mPropBrightnessId = prop.propId;
|
||||
mBrightnessLevel = static_cast<uint32_t>(prop.value);
|
||||
DISPLAY_LOGD("prop brightness is %{public}d, level is %{public}d", mPropBrightnessId, mBrightnessLevel);
|
||||
} else {
|
||||
DISPLAY_LOGW("can not get the brightness prop, can not set the brightness");
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmConnector::GetBrightness(uint32_t& level) {
|
||||
if (mPropBrightnessId == DRM_INVALID_ID) {
|
||||
DISPLAY_LOGE("the prop id of brightness is invalid");
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
level = mBrightnessLevel;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmConnector::SetBrightness(uint32_t level)
|
||||
{
|
||||
DISPLAY_LOGD("set %{public}d", level);
|
||||
if (mPropBrightnessId == DRM_INVALID_ID) {
|
||||
DISPLAY_LOGE("the prop id of brightness is invalid");
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
int ret = drmModeConnectorSetProperty(mDrmFdPtr->GetFd(), mId, mPropBrightnessId, level);
|
||||
DISPLAY_CHK_RETURN((ret != 0), DISPLAY_FAILURE, DISPLAY_LOGE("can not set dpms"));
|
||||
mBrightnessLevel = level;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
void DrmConnector::GetDisplayCap(DisplayCapability &cap)
|
||||
{
|
||||
cap.phyHeight = mPhyHeight;
|
||||
cap.phyWidth = mPhyWidth;
|
||||
cap.type = mType;
|
||||
memcpy_s(cap.name, sizeof(cap.name), mName.c_str(), mName.size());
|
||||
if (mName.size() >= sizeof(cap.name)) {
|
||||
cap.name[sizeof(cap.name) - 1] = 0;
|
||||
} else {
|
||||
cap.name[mName.size()] = 0;
|
||||
}
|
||||
cap.supportLayers = mSupportLayers;
|
||||
cap.virtualDispCount = mVirtualDispCount;
|
||||
cap.supportWriteBack = mSupportWriteBack;
|
||||
cap.propertyCount = mPropertyCount;
|
||||
}
|
||||
|
||||
void DrmConnector::ConvertTypeToName(uint32_t type, std::string &name)
|
||||
{
|
||||
DISPLAY_LOGD("type %{public}d", type);
|
||||
switch (type) {
|
||||
case DISP_INTF_VGA:
|
||||
name = "VGA";
|
||||
break;
|
||||
case DISP_INTF_HDMI:
|
||||
name = "HDMI";
|
||||
break;
|
||||
case DISP_INTF_MIPI:
|
||||
name = "MIPI";
|
||||
break;
|
||||
default:
|
||||
name = "Unknown";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DrmConnector::ConvertToHdiType(uint32_t type, InterfaceType &hdiType)
|
||||
{
|
||||
switch (type) {
|
||||
case DRM_MODE_CONNECTOR_VGA:
|
||||
hdiType = DISP_INTF_VGA;
|
||||
break;
|
||||
case DRM_MODE_CONNECTOR_DSI:
|
||||
hdiType = DISP_INTF_MIPI;
|
||||
break;
|
||||
case DRM_MODE_CONNECTOR_HDMIA:
|
||||
case DRM_MODE_CONNECTOR_HDMIB:
|
||||
hdiType = DISP_INTF_HDMI;
|
||||
break;
|
||||
default:
|
||||
hdiType = DISP_INTF_BUTT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int32_t DrmConnector::TryPickEncoder(IdMapPtr<DrmEncoder> &encoders, uint32_t encoderId, IdMapPtr<DrmCrtc> &crtcs,
|
||||
uint32_t &crtcId)
|
||||
{
|
||||
int ret;
|
||||
auto encoderIter = encoders.find(encoderId);
|
||||
if (encoderIter == encoders.end()) {
|
||||
DISPLAY_LOGW("can not find encoder for id : %{public}d", encoderId);
|
||||
return DISPLAY_FAILURE;
|
||||
}
|
||||
|
||||
auto &encoder = encoderIter->second;
|
||||
DISPLAY_LOGD("connector : %{public}d encoder : %{public}d", mId, encoder->GetId());
|
||||
ret = encoder->PickIdleCrtcId(crtcs, crtcId);
|
||||
DISPLAY_CHK_RETURN((ret == DISPLAY_SUCCESS), DISPLAY_SUCCESS,
|
||||
DISPLAY_LOGD("connector : %{public}d pick encoder : %{public}d", mId, encoder->GetId()));
|
||||
return DISPLAY_FAILURE;
|
||||
}
|
||||
|
||||
int32_t DrmConnector::PickIdleCrtcId(IdMapPtr<DrmEncoder> &encoders, IdMapPtr<DrmCrtc> &crtcs, uint32_t &crtcId)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_LOGD("encoder_id %{public}d", mEncoderId);
|
||||
int ret = TryPickEncoder(encoders, mEncoderId, crtcs, crtcId);
|
||||
DISPLAY_CHK_RETURN((ret == DISPLAY_SUCCESS), DISPLAY_SUCCESS,
|
||||
DISPLAY_LOGD("connector : %{public}d pick endcoder : %{public}d crtcId : %{public}d",
|
||||
mId, mEncoderId, crtcId));
|
||||
|
||||
for (auto encoder : mPossibleEncoders) {
|
||||
ret = TryPickEncoder(encoders, encoder, crtcs, crtcId);
|
||||
DISPLAY_CHK_RETURN((ret == DISPLAY_SUCCESS), DISPLAY_SUCCESS,
|
||||
DISPLAY_LOGD("connector : %{public}d pick endcoder : %{public}d crtcId : %{public}d", mId, mEncoderId,
|
||||
crtcId));
|
||||
}
|
||||
|
||||
DISPLAY_LOGW("can not pick a crtc for connector");
|
||||
return DISPLAY_FAILURE;
|
||||
}
|
||||
|
||||
int32_t DrmConnector::UpdateModes()
|
||||
{
|
||||
int drmFd = mDrmFdPtr->GetFd();
|
||||
drmModeConnectorPtr c = drmModeGetConnector(drmFd, mId);
|
||||
DISPLAY_CHK_RETURN((c == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("can not get connector"));
|
||||
mConnectState = c->connection;
|
||||
// init the modes
|
||||
InitModes(*c);
|
||||
drmModeFreeConnector(c);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmConnector::GetDisplaySuppportedModes(uint32_t *num, DisplayModeInfo *modes)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((num == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("num is nullptr"));
|
||||
*num = static_cast<int32_t>(mModes.size());
|
||||
if (modes != nullptr) {
|
||||
int i = 0;
|
||||
for (const auto &modeMap : mModes) {
|
||||
DrmMode mode = modeMap.second;
|
||||
mode.ConvertToHdiMode(*(modes + i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmConnector::SetDpmsState(uint64_t dmps)
|
||||
{
|
||||
DISPLAY_LOGD("dmps %{public}" PRIu64 "", dmps);
|
||||
int ret = drmModeConnectorSetProperty(mDrmFdPtr->GetFd(), mId, mPropDpmsId, dmps);
|
||||
DISPLAY_CHK_RETURN((ret != 0), DISPLAY_FAILURE, DISPLAY_LOGE("can not set dpms"));
|
||||
mDpmsState = dmps;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
bool DrmConnector::IsConnected()
|
||||
{
|
||||
return (mConnectState == DRM_MODE_CONNECTED);
|
||||
}
|
||||
|
||||
int32_t DrmConnector::GetModeFromId(int32_t id, DrmMode &mode)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
auto iter = mModes.find(id);
|
||||
if (iter == mModes.end()) {
|
||||
return DISPLAY_FAILURE;
|
||||
}
|
||||
mode = mModes[id];
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
std::unique_ptr<DrmModeBlock> DrmConnector::GetModeBlockFromId(int32_t id)
|
||||
{
|
||||
DISPLAY_LOGD("id %{public}d", id);
|
||||
auto iter = mModes.find(id);
|
||||
DISPLAY_CHK_RETURN((iter == mModes.end()), nullptr, DISPLAY_LOGE("can not the mode %{public}d", id));
|
||||
return std::make_unique<DrmModeBlock>(mModes[id]);
|
||||
}
|
||||
|
||||
DrmModeBlock::DrmModeBlock(DrmMode &mode)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
Init(mode);
|
||||
}
|
||||
|
||||
int32_t DrmModeBlock::Init(DrmMode &mode)
|
||||
{
|
||||
int ret;
|
||||
int drmFd;
|
||||
drmFd = DrmDevice::GetDrmFd();
|
||||
DISPLAY_CHK_RETURN((drmFd < 0), DISPLAY_FAILURE, DISPLAY_LOGE("the drm fd is invalid"));
|
||||
drmModeModeInfo modeInfo = *(mode.GetModeInfoPtr());
|
||||
ret = drmModeCreatePropertyBlob(drmFd, static_cast<void *>(&modeInfo), sizeof(modeInfo), &mBlockId);
|
||||
DISPLAY_CHK_RETURN((ret != 0), DISPLAY_FAILURE, DISPLAY_LOGE("create property blob failed"));
|
||||
DISPLAY_LOGD("mBlockId %{public}d", mBlockId);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
DrmModeBlock::~DrmModeBlock()
|
||||
{
|
||||
DISPLAY_LOGD("mBlockId %{public}d", mBlockId);
|
||||
int drmFd;
|
||||
drmFd = DrmDevice::GetDrmFd();
|
||||
if ((mBlockId != DRM_INVALID_ID) && (drmFd >= 0)) {
|
||||
int ret = drmModeDestroyPropertyBlob(drmFd, mBlockId);
|
||||
if (ret != 0) {
|
||||
DISPLAY_LOGE("destroy property blob failed errno %{public}d", errno);
|
||||
}
|
||||
} else {
|
||||
DISPLAY_LOGE("can not destruct the block id %{public}d drmFd %{public}d", mBlockId, drmFd);
|
||||
}
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DRM_CONNECTOR_H
|
||||
#define DRM_CONNECTOR_H
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include "display_type.h"
|
||||
#include "drm_encoder.h"
|
||||
#include "hdi_device_common.h"
|
||||
#include "hdi_shared_fd.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
const std::string PROP_DPMS = "DPMS";
|
||||
const std::string PROP_CRTCID = "CRTC_ID";
|
||||
const std::string PROP_BRIGHTNESS = "brightness";
|
||||
class DrmDevice;
|
||||
class DrmModeBlock;
|
||||
|
||||
class DrmMode {
|
||||
public:
|
||||
DrmMode() {};
|
||||
DrmMode(drmModeModeInfo &modeInfo, uint32_t id) : mModeInfo(modeInfo), mId(id) {}
|
||||
virtual ~DrmMode() {};
|
||||
drmModeModeInfoPtr GetModeInfoPtr()
|
||||
{
|
||||
return &mModeInfo;
|
||||
}
|
||||
void ConvertToHdiMode(DisplayModeInfo &hdiMode);
|
||||
|
||||
private:
|
||||
drmModeModeInfo mModeInfo = { 0 };
|
||||
int32_t mId = -1;
|
||||
};
|
||||
|
||||
class DrmModeBlock {
|
||||
public:
|
||||
explicit DrmModeBlock(DrmMode &mode);
|
||||
virtual ~DrmModeBlock();
|
||||
int32_t Init(DrmMode &mode);
|
||||
uint32_t GetBlockId() const
|
||||
{
|
||||
return mBlockId;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t mBlockId = DRM_INVALID_ID;
|
||||
};
|
||||
|
||||
class DrmConnector {
|
||||
public:
|
||||
DrmConnector(drmModeConnector c, FdPtr &fd);
|
||||
virtual ~DrmConnector() {};
|
||||
uint32_t GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
uint32_t GetEncoderId() const
|
||||
{
|
||||
return mEncoderId;
|
||||
}
|
||||
void GetDisplayCap(DisplayCapability &cap);
|
||||
int32_t Init(DrmDevice &drmDevice);
|
||||
int32_t PickIdleCrtcId(IdMapPtr<DrmEncoder> &encoders, IdMapPtr<DrmCrtc> &crtcs, uint32_t &crtcId);
|
||||
int32_t GetDisplaySuppportedModes(uint32_t *num, DisplayModeInfo *modes);
|
||||
int32_t GetPreferenceId() const
|
||||
{
|
||||
return mPreferenceId;
|
||||
}
|
||||
uint32_t GetPropCrtcId() const
|
||||
{
|
||||
return mPropCrtcId;
|
||||
}
|
||||
int32_t TryPickEncoder(IdMapPtr<DrmEncoder> &encoders, uint32_t encoderId, IdMapPtr<DrmCrtc> &crtcs,
|
||||
uint32_t &crtcId);
|
||||
// update modes will reset the preference mode id and active mode id
|
||||
int32_t UpdateModes();
|
||||
std::unique_ptr<DrmModeBlock> GetModeBlockFromId(int32_t id);
|
||||
int32_t GetModeFromId(int32_t id, DrmMode &mode);
|
||||
uint64_t GetDpmsState() const
|
||||
{
|
||||
return mDpmsState;
|
||||
}
|
||||
int32_t SetDpmsState(uint64_t dmps);
|
||||
bool IsConnected();
|
||||
|
||||
int32_t GetBrightness(uint32_t& level);
|
||||
int32_t SetBrightness(uint32_t level);
|
||||
|
||||
private:
|
||||
static void ConvertTypeToName(uint32_t type, std::string &name);
|
||||
static void ConvertToHdiType(uint32_t type, InterfaceType &hdiType);
|
||||
|
||||
void InitModes(drmModeConnector c);
|
||||
uint32_t mId;
|
||||
InterfaceType mType;
|
||||
uint32_t mPhyWidth;
|
||||
uint32_t mPhyHeight;
|
||||
uint32_t mSupportLayers = 0;
|
||||
uint32_t mVirtualDispCount = 0;
|
||||
bool mSupportWriteBack = false;
|
||||
uint32_t mPropertyCount = 0;
|
||||
uint32_t mEncoderId;
|
||||
std::vector<uint32_t> mPossibleEncoders;
|
||||
std::string mName;
|
||||
drmModeConnection mConnectState;
|
||||
uint32_t mPropDpmsId = DRM_INVALID_ID;
|
||||
uint64_t mDpmsState = 0;
|
||||
uint32_t mPropCrtcId = DRM_INVALID_ID;
|
||||
uint32_t mPropBrightnessId = DRM_INVALID_ID;
|
||||
uint32_t mBrightnessLevel = 0;
|
||||
std::unordered_map<int32_t, DrmMode> mModes;
|
||||
int32_t mPreferenceId = INVALID_MODE_ID;
|
||||
|
||||
FdPtr mDrmFdPtr;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
#endif // DRM_CONNECTOR_H
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "drm_crtc.h"
|
||||
#include "display_common.h"
|
||||
#include "drm_device.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
DrmCrtc::DrmCrtc(drmModeCrtcPtr c, uint32_t pipe) : mId(c->crtc_id), mPipe(pipe) {}
|
||||
|
||||
int32_t DrmCrtc::Init(DrmDevice &drmDevice)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
int32_t ret;
|
||||
DrmProperty prop;
|
||||
ret = drmDevice.GetCrtcProperty(*this, PROP_MODEID, prop);
|
||||
mModePropId = prop.propId;
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not get mode prop id"));
|
||||
|
||||
ret = drmDevice.GetCrtcProperty(*this, PROP_OUTFENCE, prop);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get out fence prop id"));
|
||||
mOutFencePropId = prop.propId;
|
||||
|
||||
ret = drmDevice.GetCrtcProperty(*this, PROP_ACTIVE, prop);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get out fence prop id"));
|
||||
mActivePropId = prop.propId;
|
||||
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmCrtc::BindToDisplay(uint32_t id)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((mDisplayId != INVALIDE_DISPLAY_ID), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("the crtc has bind to %{public}d", mDisplayId));
|
||||
mDisplayId = id;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
void DrmCrtc::UnBindDisplay(uint32_t id)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
if (mDisplayId == id) {
|
||||
mDisplayId = INVALIDE_DISPLAY_ID;
|
||||
} else {
|
||||
DISPLAY_LOGE("can not unbind");
|
||||
}
|
||||
}
|
||||
|
||||
bool DrmCrtc::CanBind()
|
||||
{
|
||||
return (mDisplayId == INVALIDE_DISPLAY_ID);
|
||||
}
|
||||
|
||||
int32_t DrmCrtc::SetActivieMode(int32_t id)
|
||||
{
|
||||
DISPLAY_LOGD("set activie modeid to %{public}d", id);
|
||||
DISPLAY_CHK_RETURN((id > 0), DISPLAY_PARAM_ERR, DISPLAY_LOGE("id %{public}d is invalid ", id));
|
||||
if (mActiveModeId != id) {
|
||||
mNeedModeSet = true;
|
||||
}
|
||||
mActiveModeId = id;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DRM_CRTC_H
|
||||
#define DRM_CRTC_H
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include "hdi_device_common.h"
|
||||
#include "hdi_display.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
const std::string PROP_ACTIVE = "ACTIVE";
|
||||
const std::string PROP_MODEID = "MODE_ID";
|
||||
const std::string PROP_OUTFENCE = "OUT_FENCE_PTR";
|
||||
|
||||
class DrmDevice;
|
||||
|
||||
class DrmCrtc {
|
||||
public:
|
||||
DrmCrtc(drmModeCrtcPtr c, uint32_t pipe);
|
||||
virtual ~DrmCrtc() {};
|
||||
int32_t BindToDisplay(uint32_t id);
|
||||
void UnBindDisplay(uint32_t id);
|
||||
bool CanBind();
|
||||
uint32_t GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
uint32_t GetModePropId() const
|
||||
{
|
||||
return mModePropId;
|
||||
}
|
||||
uint32_t GetOutFencePropId() const
|
||||
{
|
||||
return mOutFencePropId;
|
||||
}
|
||||
uint32_t GetActivePropId() const
|
||||
{
|
||||
return mActivePropId;
|
||||
}
|
||||
uint32_t GetPipe() const
|
||||
{
|
||||
return mPipe;
|
||||
}
|
||||
int32_t Init(DrmDevice &drmDevice);
|
||||
int32_t SetActivieMode(int32_t id);
|
||||
int32_t GetActiveModeId() const
|
||||
{
|
||||
return mActiveModeId;
|
||||
}
|
||||
bool NeedModeSet()
|
||||
{
|
||||
return mNeedModeSet;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t mId = 0;
|
||||
uint32_t mModePropId = 0;
|
||||
uint32_t mOutFencePropId = 0;
|
||||
uint32_t mActivePropId = 0;
|
||||
uint32_t mDisplayId = INVALIDE_DISPLAY_ID;
|
||||
uint32_t mPipe = 0;
|
||||
int32_t mActiveModeId = INVALID_MODE_ID;
|
||||
bool mNeedModeSet = false;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // DRM_CRTC_H
|
||||
+321
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "drm_device.h"
|
||||
#include <string>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <drm_fourcc.h>
|
||||
#include "display_common.h"
|
||||
#include "drm_display.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
FdPtr DrmDevice::mDrmFd = nullptr;
|
||||
std::shared_ptr<DrmDevice> DrmDevice::mInstance;
|
||||
|
||||
std::shared_ptr<HdiDeviceInterface> DrmDevice::Create()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
if (mDrmFd == nullptr) {
|
||||
const std::string name("sunxi-drm");
|
||||
int drmFd = open("/dev/dri/card1", O_RDWR | O_CLOEXEC);
|
||||
if (drmFd < 0) {
|
||||
DISPLAY_LOGE("drm file:%{public}s open failed %{public}s", name.c_str(), strerror(errno));
|
||||
return nullptr;
|
||||
}
|
||||
printf("the drm fd is %d", drmFd);
|
||||
mDrmFd = std::make_shared<HdiFd>(drmFd);
|
||||
}
|
||||
if (mInstance == nullptr) {
|
||||
mInstance = std::make_shared<DrmDevice>();
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
int DrmDevice::GetDrmFd()
|
||||
{
|
||||
if (mDrmFd == nullptr) {
|
||||
DISPLAY_LOGE("the drmfd is null not open");
|
||||
return -1;
|
||||
}
|
||||
return mDrmFd->GetFd();
|
||||
}
|
||||
|
||||
using PixelFormatConvertTbl = struct PixFmtConvertTbl {
|
||||
uint32_t drmFormat;
|
||||
PixelFormat pixFormat;
|
||||
};
|
||||
|
||||
uint32_t DrmDevice::ConvertToDrmFormat(PixelFormat fmtIn)
|
||||
{
|
||||
static const PixelFormatConvertTbl convertTable[] = {
|
||||
{DRM_FORMAT_XBGR8888, PIXEL_FMT_RGBX_8888}, {DRM_FORMAT_ABGR8888, PIXEL_FMT_RGBA_8888},
|
||||
{DRM_FORMAT_RGB888, PIXEL_FMT_RGB_888}, {DRM_FORMAT_RGB565, PIXEL_FMT_BGR_565},
|
||||
{DRM_FORMAT_BGRX4444, PIXEL_FMT_BGRX_4444}, {DRM_FORMAT_BGRA4444, PIXEL_FMT_BGRA_4444},
|
||||
{DRM_FORMAT_RGBA4444, PIXEL_FMT_RGBA_4444}, {DRM_FORMAT_RGBX4444, PIXEL_FMT_RGBX_4444},
|
||||
{DRM_FORMAT_BGRX5551, PIXEL_FMT_BGRX_5551}, {DRM_FORMAT_BGRA5551, PIXEL_FMT_BGRA_5551},
|
||||
{DRM_FORMAT_BGRX8888, PIXEL_FMT_BGRX_8888}, {DRM_FORMAT_ARGB8888, PIXEL_FMT_BGRA_8888},
|
||||
{DRM_FORMAT_NV12, PIXEL_FMT_YCBCR_420_SP}, {DRM_FORMAT_NV21, PIXEL_FMT_YCRCB_420_SP},
|
||||
{DRM_FORMAT_YUV420, PIXEL_FMT_YCBCR_420_P}, {DRM_FORMAT_YVU420, PIXEL_FMT_YCRCB_420_P},
|
||||
{DRM_FORMAT_NV16, PIXEL_FMT_YCBCR_422_SP}, {DRM_FORMAT_NV61, PIXEL_FMT_YCRCB_422_SP},
|
||||
{DRM_FORMAT_YUV422, PIXEL_FMT_YCBCR_422_P}, {DRM_FORMAT_YVU422, PIXEL_FMT_YCRCB_422_P},
|
||||
};
|
||||
uint32_t fmtOut = 0;
|
||||
for (uint32_t i = 0; i < sizeof(convertTable) / sizeof(convertTable[0]); i++) {
|
||||
if (convertTable[i].pixFormat == fmtIn) {
|
||||
fmtOut = convertTable[i].drmFormat;
|
||||
}
|
||||
}
|
||||
DISPLAY_LOGD("fmtIn %{public}d, outFmt %{public}d", fmtIn, fmtOut);
|
||||
return fmtOut;
|
||||
}
|
||||
|
||||
DrmDevice::DrmDevice() {}
|
||||
|
||||
int32_t DrmDevice::GetCrtcProperty(const DrmCrtc &crtc, const std::string &name, DrmProperty &prop)
|
||||
{
|
||||
return GetProperty(crtc.GetId(), DRM_MODE_OBJECT_CRTC, name, prop);
|
||||
}
|
||||
|
||||
int32_t DrmDevice::GetConnectorProperty(const DrmConnector &connector, const std::string &name, DrmProperty &prop)
|
||||
{
|
||||
return GetProperty(connector.GetId(), DRM_MODE_OBJECT_CONNECTOR, name, prop);
|
||||
}
|
||||
|
||||
int32_t DrmDevice::GetPlaneProperty(const DrmPlane &plane, const std::string &name, DrmProperty &prop)
|
||||
{
|
||||
return GetProperty(plane.GetId(), DRM_MODE_OBJECT_PLANE, name, prop);
|
||||
}
|
||||
|
||||
int32_t DrmDevice::GetProperty(uint32_t objId, uint32_t objType, const std::string &name, DrmProperty &prop)
|
||||
{
|
||||
drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(GetDrmFd(), objId, objType);
|
||||
DISPLAY_CHK_RETURN((!props), DISPLAY_FAILURE, DISPLAY_LOGE("can not get properties"));
|
||||
bool found = false;
|
||||
for (uint32_t i = 0; i < props->count_props; i++) {
|
||||
drmModePropertyPtr p = drmModeGetProperty(GetDrmFd(), props->props[i]);
|
||||
if (strcmp(p->name, name.c_str()) == 0) {
|
||||
found = true;
|
||||
prop.propId = p->prop_id;
|
||||
prop.value = props->prop_values[i];
|
||||
}
|
||||
drmModeFreeProperty(p);
|
||||
}
|
||||
drmModeFreeObjectProperties(props);
|
||||
return found ? DISPLAY_SUCCESS : DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t DrmDevice::Init()
|
||||
{
|
||||
int ret = drmSetClientCap(GetDrmFd(), DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
|
||||
DISPLAY_CHK_RETURN((ret), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("DRM_CLIENT_CAP_UNIVERSAL_PLANES set failed %{public}s", strerror(errno)));
|
||||
ret = drmSetClientCap(GetDrmFd(), DRM_CLIENT_CAP_ATOMIC, 1);
|
||||
DISPLAY_CHK_RETURN((ret), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("DRM_CLIENT_CAP_ATOMIC set failed %{public}s", strerror(errno)));
|
||||
|
||||
ret = drmSetMaster(GetDrmFd());
|
||||
DISPLAY_CHK_RETURN((ret), DISPLAY_FAILURE, DISPLAY_LOGE("can not set to master errno : %{public}d", errno));
|
||||
|
||||
ret = drmIsMaster(GetDrmFd());
|
||||
DISPLAY_CHK_RETURN((!ret), DISPLAY_FAILURE, DISPLAY_LOGE("is not master : %{public}d", errno));
|
||||
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
void DrmDevice::DeInit()
|
||||
{
|
||||
mDisplays.clear();
|
||||
mCrtcs.clear();
|
||||
}
|
||||
|
||||
void DrmDevice::FindAllCrtc(const drmModeResPtr &res)
|
||||
{
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((res == nullptr), DISPLAY_LOGE("the res is null"));
|
||||
mCrtcs.clear();
|
||||
for (int i = 0; i < res->count_crtcs; i++) {
|
||||
drmModeCrtcPtr crtc = drmModeGetCrtc(GetDrmFd(), res->crtcs[i]);
|
||||
if (!crtc) {
|
||||
DISPLAY_LOGE("can not get crtc %{public}d", i);
|
||||
continue;
|
||||
}
|
||||
uint32_t crtc_id = crtc->crtc_id;
|
||||
std::shared_ptr<DrmCrtc> drmCrtc = std::make_shared<DrmCrtc>(crtc, i);
|
||||
int ret = drmCrtc->Init(*this);
|
||||
drmModeFreeCrtc(crtc);
|
||||
if (ret != DISPLAY_SUCCESS) {
|
||||
DISPLAY_LOGE("crtc %{public}d init failed", i);
|
||||
continue;
|
||||
}
|
||||
mCrtcs.emplace(crtc_id, std::move(drmCrtc));
|
||||
}
|
||||
}
|
||||
|
||||
void DrmDevice::FindAllEncoder(const drmModeResPtr &res)
|
||||
{
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((res == nullptr), DISPLAY_LOGE("the res is null"));
|
||||
mEncoders.clear();
|
||||
for (int i = 0; i < res->count_encoders; i++) {
|
||||
drmModeEncoderPtr encoder = drmModeGetEncoder(GetDrmFd(), res->encoders[i]);
|
||||
if (!encoder) {
|
||||
DISPLAY_LOGE("can not get encoder %{public}d", i);
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<DrmEncoder> drmEncoder = std::make_shared<DrmEncoder>(*encoder);
|
||||
mEncoders.emplace(encoder->encoder_id, std::move(drmEncoder));
|
||||
drmModeFreeEncoder(encoder);
|
||||
}
|
||||
DISPLAY_LOGD("find encoder count %{public}zd", mEncoders.size());
|
||||
}
|
||||
|
||||
void DrmDevice::FindAllConnector(const drmModeResPtr &res)
|
||||
{
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((res == nullptr), DISPLAY_LOGE("the res is null"));
|
||||
mConnectors.clear();
|
||||
int ret;
|
||||
for (int i = 0; i < res->count_connectors; i++) {
|
||||
drmModeConnectorPtr connector = drmModeGetConnector(GetDrmFd(), res->connectors[i]);
|
||||
if (!connector) {
|
||||
DISPLAY_LOGE("can not get connector mode %{public}d", i);
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<DrmConnector> drmConnector = std::make_shared<DrmConnector>(*connector, mDrmFd);
|
||||
ret = drmConnector->Init(*this);
|
||||
drmModeFreeConnector(connector);
|
||||
if (ret != DISPLAY_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
int connectorId = drmConnector->GetId();
|
||||
mConnectors.emplace(connectorId, std::move(drmConnector));
|
||||
}
|
||||
DISPLAY_LOGD("find connector count %{public}zd", mConnectors.size());
|
||||
}
|
||||
|
||||
void DrmDevice::FindAllPlane()
|
||||
{
|
||||
mPlanes.clear();
|
||||
int ret;
|
||||
drmModePlaneResPtr planeRes = drmModeGetPlaneResources(GetDrmFd());
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((planeRes == nullptr), DISPLAY_LOGE("can not get plane resource"));
|
||||
DISPLAY_LOGD("count_planes %{public}d", planeRes->count_planes);
|
||||
for (uint32_t i = 0; i < planeRes->count_planes; i++) {
|
||||
drmModePlanePtr p = drmModeGetPlane(GetDrmFd(), planeRes->planes[i]);
|
||||
if (!p) {
|
||||
DISPLAY_LOGE("can not get plane %{public}d", i);
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<DrmPlane> drmPlane = std::make_shared<DrmPlane>(*p);
|
||||
DISPLAY_LOGD();
|
||||
ret = drmPlane->Init(*this);
|
||||
DISPLAY_LOGD();
|
||||
drmModeFreePlane(p);
|
||||
if (ret != DISPLAY_SUCCESS) {
|
||||
DISPLAY_LOGE("drm plane %{public}d init failed", i);
|
||||
continue;
|
||||
}
|
||||
mPlanes.emplace_back(std::move(drmPlane));
|
||||
}
|
||||
DISPLAY_LOGD("find plane count %{public}zd", mPlanes.size());
|
||||
}
|
||||
|
||||
std::shared_ptr<DrmEncoder> DrmDevice::GetDrmEncoderFromId(uint32_t id)
|
||||
{
|
||||
auto iter = mEncoders.find(id);
|
||||
if (iter != mEncoders.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
DISPLAY_LOGE("get drm encoder fail");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<DrmConnector> DrmDevice::GetDrmConnectorFromId(uint32_t id)
|
||||
{
|
||||
auto iter = mConnectors.find(id);
|
||||
if (iter != mConnectors.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
DISPLAY_LOGE("get drm connector fail");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<DrmCrtc> DrmDevice::GetDrmCrtcFromId(uint32_t id)
|
||||
{
|
||||
auto iter = mCrtcs.find(id);
|
||||
if (iter != mCrtcs.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
DISPLAY_LOGE("get drm crtc fail");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<DrmPlane>> DrmDevice::GetDrmPlane(uint32_t pipe, uint32_t type)
|
||||
{
|
||||
std::vector<std::shared_ptr<DrmPlane>> planes;
|
||||
for (const auto &plane : mPlanes) {
|
||||
if (plane->IsIdle() && ((1 << pipe) & plane->GetPossibleCrtcs()) && (type == plane->GetType())) {
|
||||
plane->BindToPipe(pipe);
|
||||
planes.push_back(plane);
|
||||
}
|
||||
}
|
||||
DISPLAY_LOGD("the planes count %{public}zd", planes.size());
|
||||
return planes;
|
||||
}
|
||||
|
||||
|
||||
std::unordered_map<uint32_t, std::shared_ptr<HdiDisplay>> DrmDevice::DiscoveryDisplay()
|
||||
{
|
||||
mDisplays.clear();
|
||||
drmModeResPtr res = drmModeGetResources(GetDrmFd());
|
||||
DISPLAY_CHK_RETURN((res == nullptr), mDisplays, DISPLAY_LOGE("can not get drm resource"));
|
||||
// discovery all drm resource
|
||||
FindAllCrtc(res);
|
||||
FindAllEncoder(res);
|
||||
FindAllConnector(res);
|
||||
FindAllPlane();
|
||||
DISPLAY_LOGD();
|
||||
// travel all connector
|
||||
for (auto &connectorPair : mConnectors) {
|
||||
auto connector = connectorPair.second;
|
||||
uint32_t crtcId = 0;
|
||||
int32_t ret;
|
||||
ret = connector->PickIdleCrtcId(mEncoders, mCrtcs, crtcId);
|
||||
if (ret != DISPLAY_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
DISPLAY_LOGD();
|
||||
|
||||
auto crtcIter = mCrtcs.find(crtcId);
|
||||
if (crtcIter == mCrtcs.end()) {
|
||||
DISPLAY_LOGE("can not find crtc for the id %{public}d", connector->GetId());
|
||||
continue;
|
||||
}
|
||||
DISPLAY_LOGD();
|
||||
auto crtc = crtcIter->second;
|
||||
DISPLAY_LOGD("crtc %{public}p", crtc.get());
|
||||
// create the display
|
||||
std::shared_ptr<HdiDisplay> display = std::make_shared<DrmDisplay>(connector, crtc, mInstance);
|
||||
DISPLAY_LOGD();
|
||||
display->Init();
|
||||
mDisplays.emplace(display->GetId(), std::move(display));
|
||||
}
|
||||
printf("find display size %d", mDisplays.size());
|
||||
return mDisplays;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DRM_DEVICE_H
|
||||
#define DRM_DEVICE_H
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include "drm_connector.h"
|
||||
#include "drm_crtc.h"
|
||||
#include "drm_encoder.h"
|
||||
#include "drm_plane.h"
|
||||
#include "hdi_device_common.h"
|
||||
#include "hdi_device_interface.h"
|
||||
#include "hdi_display.h"
|
||||
#include "hdi_shared_fd.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
struct DrmProperty {
|
||||
uint32_t propId;
|
||||
uint64_t value;
|
||||
};
|
||||
|
||||
class DrmDevice : public HdiDeviceInterface, std::enable_shared_from_this<DrmDevice> {
|
||||
public:
|
||||
static std::shared_ptr<HdiDeviceInterface> Create();
|
||||
static uint32_t ConvertToDrmFormat(PixelFormat fmtIn);
|
||||
static int GetDrmFd();
|
||||
DrmDevice();
|
||||
virtual ~DrmDevice() {}
|
||||
|
||||
std::vector<std::shared_ptr<DrmPlane>> GetDrmPlane(uint32_t pipe, uint32_t type);
|
||||
|
||||
int32_t GetCrtcProperty(const DrmCrtc &crtc, const std::string &name, DrmProperty &prop);
|
||||
int32_t GetConnectorProperty(const DrmConnector &connector, const std::string &name, DrmProperty &prop);
|
||||
int32_t GetPlaneProperty(const DrmPlane &plane, const std::string &name, DrmProperty &prop);
|
||||
|
||||
int32_t GetProperty(uint32_t objId, uint32_t objType, const std::string &name, DrmProperty &prop);
|
||||
std::shared_ptr<DrmEncoder> GetDrmEncoderFromId(uint32_t id);
|
||||
std::shared_ptr<DrmConnector> GetDrmConnectorFromId(uint32_t id);
|
||||
std::shared_ptr<DrmCrtc> GetDrmCrtcFromId(uint32_t id);
|
||||
void CreateCrtc(drmModeCrtcPtr c);
|
||||
virtual std::unordered_map<uint32_t, std::shared_ptr<HdiDisplay>> DiscoveryDisplay();
|
||||
virtual int32_t Init();
|
||||
virtual void DeInit();
|
||||
|
||||
private:
|
||||
static FdPtr mDrmFd;
|
||||
static std::shared_ptr<DrmDevice> mInstance;
|
||||
void FindAllCrtc(const drmModeResPtr &drmRes);
|
||||
void FindAllEncoder(const drmModeResPtr &drmRes);
|
||||
void FindAllConnector(const drmModeResPtr &drmRes);
|
||||
void FindAllPlane();
|
||||
int InitNetLink();
|
||||
IdMapPtr<HdiDisplay> mDisplays;
|
||||
IdMapPtr<DrmCrtc> mCrtcs;
|
||||
IdMapPtr<DrmEncoder> mEncoders;
|
||||
IdMapPtr<DrmConnector> mConnectors;
|
||||
std::vector<std::shared_ptr<DrmPlane>> mPlanes;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // DRM_DEVICE_H
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "drm_display.h"
|
||||
#include <string>
|
||||
#include <errno.h>
|
||||
#include <memory>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include "display_gralloc.h"
|
||||
#include "display_common.h"
|
||||
#include "drm_device.h"
|
||||
#include "drm_vsync_worker.h"
|
||||
#include "hdi_drm_composition.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
DrmDisplay::DrmDisplay(std::shared_ptr<DrmConnector> connector, std::shared_ptr<DrmCrtc> crtc,
|
||||
std::shared_ptr<DrmDevice> drmDevice)
|
||||
: mDrmDevice(drmDevice), mConnector(connector), mCrtc(crtc)
|
||||
{}
|
||||
|
||||
DrmDisplay::~DrmDisplay()
|
||||
{
|
||||
if (mCrtc != nullptr) {
|
||||
mCrtc->UnBindDisplay(GetId());
|
||||
}
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::Init()
|
||||
{
|
||||
int ret;
|
||||
DISPLAY_CHK_RETURN((mCrtc == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("crtc is null"));
|
||||
DISPLAY_CHK_RETURN((mConnector == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("connector is null"));
|
||||
DISPLAY_CHK_RETURN((mDrmDevice == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("drmDevice is null"));
|
||||
ret = HdiDisplay::Init();
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("init failed"));
|
||||
auto postComp = std::make_unique<HdiDrmComposition>(mConnector, mCrtc, mDrmDevice);
|
||||
DISPLAY_CHK_RETURN((postComp == nullptr), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not new HdiDrmComposition errno %{public}d", errno));
|
||||
ret = postComp->Init();
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not init HdiDrmComposition"));
|
||||
mComposer = std::make_unique<HdiComposer>(std::move(postComp));
|
||||
ret = mCrtc->BindToDisplay(GetId());
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("bind crtc failed"));
|
||||
|
||||
ret = ChosePreferenceMode();
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("choose preference mode fialed"));
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::GetDisplayCapability(DisplayCapability *info)
|
||||
{
|
||||
mConnector->GetDisplayCap(*info);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::GetDisplaySuppportedModes(uint32_t *num, DisplayModeInfo *modes)
|
||||
{
|
||||
mConnector->GetDisplaySuppportedModes(num, modes);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::GetDisplayMode(uint32_t *modeId)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((modeId == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("the in modeId is nullptr"));
|
||||
*modeId = mCrtc->GetActiveModeId();
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::SetDisplayMode(uint32_t modeId)
|
||||
{
|
||||
return mCrtc->SetActivieMode(modeId);
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::GetDisplayPowerStatus(DispPowerStatus *status)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((status == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("status is nullptr"));
|
||||
return ConvertToHdiPowerState(mConnector->GetDpmsState(), *status);
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::SetDisplayPowerStatus(DispPowerStatus status)
|
||||
{
|
||||
DISPLAY_LOGD("the status %{public}d ", status);
|
||||
uint32_t drmPowerState = 0;
|
||||
int ret = ConvertToDrmPowerState(status, drmPowerState);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_PARAM_ERR,
|
||||
DISPLAY_LOGE("unknown power status %{public}d", status));
|
||||
mConnector->SetDpmsState(drmPowerState);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::ConvertToHdiPowerState(uint32_t drmPowerState, DispPowerStatus &hdiPowerState)
|
||||
{
|
||||
int32_t ret = DISPLAY_SUCCESS;
|
||||
switch (drmPowerState) {
|
||||
case DRM_MODE_DPMS_OFF:
|
||||
hdiPowerState = POWER_STATUS_OFF;
|
||||
break;
|
||||
case DRM_MODE_DPMS_ON:
|
||||
hdiPowerState = POWER_STATUS_ON;
|
||||
break;
|
||||
case DRM_MODE_DPMS_STANDBY:
|
||||
hdiPowerState = POWER_STATUS_STANDBY;
|
||||
break;
|
||||
case DRM_MODE_DPMS_SUSPEND:
|
||||
hdiPowerState = POWER_STATUS_SUSPEND;
|
||||
break;
|
||||
default:
|
||||
hdiPowerState = POWER_STATUS_BUTT;
|
||||
ret = DISPLAY_FAILURE;
|
||||
break;
|
||||
}
|
||||
DISPLAY_LOGD("hdi power state %{public}u", hdiPowerState);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::ConvertToDrmPowerState(DispPowerStatus hdiPowerState, uint32_t &drmPowerState)
|
||||
{
|
||||
int32_t ret = DISPLAY_SUCCESS;
|
||||
switch (hdiPowerState) {
|
||||
case POWER_STATUS_OFF:
|
||||
drmPowerState = DRM_MODE_DPMS_OFF;
|
||||
break;
|
||||
case POWER_STATUS_ON:
|
||||
drmPowerState = DRM_MODE_DPMS_ON;
|
||||
break;
|
||||
case POWER_STATUS_STANDBY:
|
||||
drmPowerState = DRM_MODE_DPMS_STANDBY;
|
||||
break;
|
||||
case POWER_STATUS_SUSPEND:
|
||||
drmPowerState = DRM_MODE_DPMS_SUSPEND;
|
||||
break;
|
||||
default:
|
||||
ret = DISPLAY_FAILURE;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::unique_ptr<HdiLayer> DrmDisplay::CreateHdiLayer(LayerType type)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
return std::make_unique<HdiDrmLayer>(type);
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::WaitForVBlank(uint64_t *ns)
|
||||
{
|
||||
int ret;
|
||||
constexpr uint64_t nPerS = 1000000000;
|
||||
constexpr uint64_t nPerUS = 1000;
|
||||
drmVBlank vbl = {
|
||||
.request.type = DRM_VBLANK_RELATIVE,
|
||||
.request.sequence = 0,
|
||||
.request.signal = 0,
|
||||
};
|
||||
DISPLAY_CHK_RETURN((ns == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("in ns is nullptr"));
|
||||
ret = drmWaitVBlank(mDrmDevice->GetDrmFd(), &vbl);
|
||||
DISPLAY_CHK_RETURN((ret != 0), DISPLAY_FAILURE, DISPLAY_LOGE("wait vblank failed errno %{public}d", errno));
|
||||
*ns = static_cast<uint64_t>(vbl.reply.tval_sec * nPerS + vbl.reply.tval_usec * nPerUS);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
bool DrmDisplay::IsConnected()
|
||||
{
|
||||
DISPLAY_LOGD("conneted %{public}d", mConnector->IsConnected());
|
||||
return mConnector->IsConnected();
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::PushFirstFrame()
|
||||
{
|
||||
GrallocFuncs *grallocFucs = nullptr;
|
||||
int ret = GrallocInitialize(&grallocFucs);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("Gralloc init failed"));
|
||||
DrmMode mode;
|
||||
ret = mConnector->GetModeFromId(mCrtc->GetActiveModeId(), mode);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not get the mode from id %{public}d", mCrtc->GetActiveModeId()));
|
||||
AllocInfo info = {
|
||||
.width = mode.GetModeInfoPtr()->hdisplay,
|
||||
.height = mode.GetModeInfoPtr()->vdisplay,
|
||||
.usage = HBM_USE_MEM_DMA | HBM_USE_CPU_READ | HBM_USE_CPU_WRITE,
|
||||
.format = PIXEL_FMT_BGRA_8888
|
||||
};
|
||||
|
||||
BufferHandle *buffer = nullptr;
|
||||
ret = grallocFucs->AllocMem(&info, &buffer);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not alloc memory"));
|
||||
mClientLayer->SetLayerBuffer(buffer, -1);
|
||||
|
||||
std::vector<HdiLayer *> layers;
|
||||
HdiDrmComposition *drmComp = static_cast<HdiDrmComposition *>(mComposer->GetPostCompostion());
|
||||
drmComp->SetLayers(layers, *mClientLayer);
|
||||
drmComp->Apply(true);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::ChosePreferenceMode()
|
||||
{
|
||||
int32_t ret;
|
||||
int32_t modeId = mConnector->GetPreferenceId();
|
||||
if (modeId == INVALID_MODE_ID) {
|
||||
uint32_t num = 0;
|
||||
ret = GetDisplaySuppportedModes(&num, nullptr);
|
||||
DISPLAY_CHK_RETURN((num == 0) && (ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not get modes"));
|
||||
modeId = 0;
|
||||
}
|
||||
ret = SetDisplayMode(modeId);
|
||||
// Push first frame to the drm, for that the vblank must init all the componet.
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("set display mode failed"));
|
||||
return PushFirstFrame();
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::RegDisplayVBlankCallback(VBlankCallback cb, void *data)
|
||||
{
|
||||
DISPLAY_LOGD("the VBlankCallback %{public}p ", cb);
|
||||
(void)data;
|
||||
std::shared_ptr<VsyncCallBack> vsyncCb = std::make_shared<VsyncCallBack>(cb, nullptr);
|
||||
DrmVsyncWorker::GetInstance().ReqesterVBlankCb(vsyncCb);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::SetDisplayVsyncEnabled(bool enabled)
|
||||
{
|
||||
DISPLAY_LOGD("enable %{public}d", enabled);
|
||||
DrmVsyncWorker::GetInstance().EnableVsync(enabled);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::GetDisplayBacklight(uint32_t *value)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((value == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("value is nullptr"));
|
||||
return mConnector->GetBrightness(*value);
|
||||
}
|
||||
|
||||
int32_t DrmDisplay::SetDisplayBacklight(uint32_t value)
|
||||
{
|
||||
return mConnector->SetBrightness(value);
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DRM_DISPLAY_H
|
||||
#define DRM_DISPLAY_H
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include "drm_connector.h"
|
||||
#include "drm_crtc.h"
|
||||
#include "drm_device.h"
|
||||
#include "drm_plane.h"
|
||||
#include "hdi_composer.h"
|
||||
#include "hdi_drm_composition.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class DrmDisplay : public HdiDisplay {
|
||||
public:
|
||||
DrmDisplay(std::shared_ptr<DrmConnector> connector, std::shared_ptr<DrmCrtc> crtc,
|
||||
std::shared_ptr<DrmDevice> drmDevice);
|
||||
|
||||
virtual ~DrmDisplay();
|
||||
|
||||
int32_t Init() override;
|
||||
int32_t GetDisplayCapability(DisplayCapability *info) override;
|
||||
int32_t GetDisplaySuppportedModes(uint32_t *num, DisplayModeInfo *modes) override;
|
||||
int32_t GetDisplayMode(uint32_t *modeId) override;
|
||||
int32_t SetDisplayMode(uint32_t modeId) override;
|
||||
int32_t GetDisplayPowerStatus(DispPowerStatus *status) override;
|
||||
int32_t SetDisplayPowerStatus(DispPowerStatus status) override;
|
||||
int32_t GetDisplayBacklight(uint32_t *value) override;
|
||||
int32_t SetDisplayBacklight(uint32_t value) override;
|
||||
int32_t ChosePreferenceMode();
|
||||
virtual int32_t RegDisplayVBlankCallback(VBlankCallback cb, void *data) override;
|
||||
virtual int32_t WaitForVBlank(uint64_t *ns) override;
|
||||
virtual bool IsConnected() override;
|
||||
virtual int32_t SetDisplayVsyncEnabled(bool enabled) override;
|
||||
HdiDrmComposition *GetDrmComposition();
|
||||
|
||||
protected:
|
||||
std::unique_ptr<HdiLayer> CreateHdiLayer(LayerType type) override;
|
||||
|
||||
private:
|
||||
int32_t PushFirstFrame();
|
||||
int32_t ConvertToHdiPowerState(uint32_t drmPowerState, DispPowerStatus &hdiPowerState);
|
||||
int32_t ConvertToDrmPowerState(DispPowerStatus hdiPowerState, uint32_t &drmPowerState);
|
||||
std::shared_ptr<DrmDevice> mDrmDevice;
|
||||
std::shared_ptr<DrmConnector> mConnector;
|
||||
std::shared_ptr<DrmCrtc> mCrtc;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_DISPLAY_H
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "drm_encoder.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
DrmEncoder::DrmEncoder(drmModeEncoder e)
|
||||
{
|
||||
mEncoderId = e.encoder_id;
|
||||
mCrtcId = e.crtc_id;
|
||||
mPossibleCrtcs = e.possible_crtcs;
|
||||
}
|
||||
|
||||
int32_t DrmEncoder::PickIdleCrtcId(IdMapPtr<DrmCrtc> &crtcs, uint32_t &crtcId)
|
||||
{
|
||||
// find the crtc id;
|
||||
DISPLAY_LOGD("crtcs szie %{public}zu", crtcs.size());
|
||||
std::shared_ptr<DrmCrtc> crtc;
|
||||
auto crtcIter = crtcs.find(mCrtcId);
|
||||
if (crtcIter == crtcs.end()) {
|
||||
DISPLAY_LOGW("can not find crtc for id %{public}d", mCrtcId);
|
||||
crtcIter = crtcs.begin();
|
||||
}
|
||||
DISPLAY_CHK_RETURN((crtcIter == crtcs.end()), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("have no crtc %{public}zu ", crtcs.size()));
|
||||
crtc = crtcIter->second;
|
||||
DISPLAY_CHK_RETURN((crtc == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("crtc is null"));
|
||||
|
||||
if (!crtc->CanBind()) {
|
||||
crtc = nullptr;
|
||||
for (const auto &posCrtcPair : crtcs) {
|
||||
auto &posCrts = posCrtcPair.second;
|
||||
DISPLAY_LOGD("try crtc id : %{public}d", posCrts->GetId());
|
||||
if (posCrts->CanBind() && ((1 << posCrts->GetPipe()) & mPossibleCrtcs)) {
|
||||
crtc = posCrts;
|
||||
}
|
||||
}
|
||||
}
|
||||
DISPLAY_CHK_RETURN((crtc == nullptr), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("encoder %{public}d can not bind to idle crtc", mEncoderId));
|
||||
crtcId = crtc->GetId();
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DRM_ENCODER_H
|
||||
#define DRM_ENCODER_H
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include <display_type.h>
|
||||
#include <drm_crtc.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class DrmEncoder {
|
||||
public:
|
||||
explicit DrmEncoder(drmModeEncoder e);
|
||||
virtual ~DrmEncoder() {}
|
||||
uint32_t GetCrtcId() const
|
||||
{
|
||||
return mCrtcId;
|
||||
}
|
||||
void SetCrtcId(uint32_t id)
|
||||
{
|
||||
mCrtcId = id;
|
||||
}
|
||||
uint32_t GetPossibleCrtcs() const
|
||||
{
|
||||
return mPossibleCrtcs;
|
||||
}
|
||||
int32_t PickIdleCrtcId(IdMapPtr<DrmCrtc> &crtcs, uint32_t &crtcId);
|
||||
uint32_t GetId() const
|
||||
{
|
||||
return mEncoderId;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t mEncoderId;
|
||||
uint32_t mCrtcId;
|
||||
uint32_t mPossibleCrtcs;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // DRM_ENCODER_H
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "drm_plane.h"
|
||||
#include "drm_device.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
DrmPlane::DrmPlane(drmModePlane &p)
|
||||
: mId(p.plane_id), mPossibleCrtcs(p.possible_crtcs), mFormats(p.formats, p.formats + p.count_formats)
|
||||
{}
|
||||
|
||||
DrmPlane::~DrmPlane()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
}
|
||||
|
||||
int32_t DrmPlane::Init(DrmDevice &drmDevice)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
int32_t ret;
|
||||
DrmProperty prop;
|
||||
ret = drmDevice.GetPlaneProperty(*this, PROP_FBID, prop);
|
||||
mPropFbId = prop.propId;
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not get plane fb id"));
|
||||
ret = drmDevice.GetPlaneProperty(*this, PROP_IN_FENCE_FD, prop);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get plane in fence prop id"));
|
||||
mPropFenceInId = prop.propId;
|
||||
ret = drmDevice.GetPlaneProperty(*this, PROP_CRTC_ID, prop);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get pane crtc prop id"));
|
||||
mPropCrtcId = prop.propId;
|
||||
ret = drmDevice.GetPlaneProperty(*this, PROP_TYPE, prop);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get pane crtc prop id"));
|
||||
switch (prop.value) {
|
||||
case DRM_PLANE_TYPE_OVERLAY:
|
||||
case DRM_PLANE_TYPE_PRIMARY:
|
||||
case DRM_PLANE_TYPE_CURSOR:
|
||||
mType = static_cast<uint32_t>(prop.value);
|
||||
break;
|
||||
default:
|
||||
DISPLAY_LOGE("unknown type value %{public}" PRIu64 "", prop.value);
|
||||
return DISPLAY_FAILURE;
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DRM_PLANE_H
|
||||
#define DRM_PLANE_H
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
const std::string PROP_FBID = "FB_ID";
|
||||
const std::string PROP_IN_FENCE_FD = "IN_FENCE_FD";
|
||||
const std::string PROP_CRTC_ID = "CRTC_ID";
|
||||
const std::string PROP_TYPE = "type";
|
||||
class DrmDevice;
|
||||
|
||||
class DrmPlane {
|
||||
public:
|
||||
explicit DrmPlane(drmModePlane &p);
|
||||
virtual ~DrmPlane();
|
||||
int32_t Init(DrmDevice &drmDevice);
|
||||
uint32_t GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
uint32_t GetPropFbId() const
|
||||
{
|
||||
return mPropFbId;
|
||||
}
|
||||
uint32_t GetPropFenceInId() const
|
||||
{
|
||||
return mPropFenceInId;
|
||||
}
|
||||
uint32_t GetPropCrtcId() const
|
||||
{
|
||||
return mPropCrtcId;
|
||||
}
|
||||
uint32_t GetPossibleCrtcs() const
|
||||
{
|
||||
return mPossibleCrtcs;
|
||||
}
|
||||
uint32_t GetType() const
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
void BindToPipe(uint32_t pipe)
|
||||
{
|
||||
mPipe = pipe;
|
||||
}
|
||||
void UnBindPipe()
|
||||
{
|
||||
mPipe = 0;
|
||||
}
|
||||
bool IsIdle() const
|
||||
{
|
||||
return (mPipe == 0);
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t mId = 0;
|
||||
uint32_t mPossibleCrtcs = 0;
|
||||
uint32_t mPropFbId = 0;
|
||||
uint32_t mPropFenceInId = 0;
|
||||
uint32_t mPropCrtcId = 0;
|
||||
uint32_t mPipe = 0;
|
||||
uint32_t mType = 0;
|
||||
std::vector<uint32_t> mFormats;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // DRM_PLANE_H
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "drm_vsync_worker.h"
|
||||
#include <chrono>
|
||||
#include "display_common.h"
|
||||
#include "drm_device.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
DrmVsyncWorker::DrmVsyncWorker() {}
|
||||
|
||||
int32_t DrmVsyncWorker::Init(int fd)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((fd < 0), DISPLAY_FAILURE, DISPLAY_LOGE("the fd is invalid"));
|
||||
mDrmFd = fd;
|
||||
DISPLAY_LOGD("the drm fd is %{public}d", fd);
|
||||
mThread = std::make_unique<std::thread>([this]() { WorkThread(); });
|
||||
DISPLAY_CHK_RETURN((mThread == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("can not create thread"));
|
||||
mRunning = true;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
DrmVsyncWorker &DrmVsyncWorker::GetInstance()
|
||||
{
|
||||
static DrmVsyncWorker instance;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&]() {
|
||||
int ret = instance.Init(DrmDevice::GetDrmFd());
|
||||
if (ret != DISPLAY_SUCCESS) {
|
||||
DISPLAY_LOGE("Vsync Worker Init failed");
|
||||
}
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
|
||||
DrmVsyncWorker::~DrmVsyncWorker()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
{
|
||||
std::lock_guard<std::mutex> lg(mMutex);
|
||||
mRunning = false;
|
||||
}
|
||||
DISPLAY_LOGD();
|
||||
mCondition.notify_one();
|
||||
if (mThread != nullptr) {
|
||||
mThread->join();
|
||||
}
|
||||
DISPLAY_LOGD();
|
||||
}
|
||||
|
||||
bool DrmVsyncWorker::WaitSignalAndCheckRuning()
|
||||
{
|
||||
std::unique_lock<std::mutex> ul(mMutex);
|
||||
mCondition.wait(ul, [this]() { return (mEnable || !mRunning); });
|
||||
return mRunning;
|
||||
}
|
||||
|
||||
|
||||
uint64_t DrmVsyncWorker::WaitNextVBlank(unsigned int &sq)
|
||||
{
|
||||
constexpr uint64_t SEC_TO_NSEC = 1000 * 1000 * 1000;
|
||||
constexpr uint64_t USEC_TO_NSEC = 1000;
|
||||
drmVBlank vblank = {
|
||||
.request =
|
||||
drmVBlankReq {
|
||||
.type = DRM_VBLANK_RELATIVE,
|
||||
.sequence = 1,
|
||||
.signal = 0,
|
||||
}
|
||||
};
|
||||
int ret = drmWaitVBlank(mDrmFd, &vblank);
|
||||
DISPLAY_CHK_RETURN((ret < 0), 0,
|
||||
DISPLAY_LOGE("wait vblank failed ret : %{public}d errno %{public}d", ret, errno));
|
||||
sq = vblank.reply.sequence;
|
||||
return (uint64_t)(vblank.reply.tval_sec * SEC_TO_NSEC + vblank.reply.tval_usec * USEC_TO_NSEC);
|
||||
}
|
||||
|
||||
|
||||
void DrmVsyncWorker::EnableVsync(bool enable)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
{
|
||||
std::lock_guard<std::mutex> lg(mMutex);
|
||||
mEnable = enable;
|
||||
}
|
||||
mCondition.notify_one();
|
||||
}
|
||||
|
||||
void DrmVsyncWorker::WorkThread()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
unsigned int seq = 0;
|
||||
while (WaitSignalAndCheckRuning()) {
|
||||
// wait the vblank
|
||||
uint64_t time = 0;
|
||||
time = WaitNextVBlank(seq);
|
||||
if (mCallBack != nullptr) {
|
||||
mCallBack->Vsync(seq, time);
|
||||
} else {
|
||||
DISPLAY_LOGE("the callbac is nullptr");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrmVsyncWorker::ReqesterVBlankCb(std::shared_ptr<VsyncCallBack> &cb)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((cb == nullptr), DISPLAY_LOGE("the VBlankCallback is nullptr "));
|
||||
mCallBack = cb;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DRM_VSYNC_WORKER_H
|
||||
#define DRM_VSYNC_WORKER_H
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <condition_variable>
|
||||
#include "display_device.h"
|
||||
#include "hdi_device_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class DrmVsyncWorker {
|
||||
public:
|
||||
DrmVsyncWorker();
|
||||
virtual ~DrmVsyncWorker();
|
||||
int32_t Init(int fd);
|
||||
static DrmVsyncWorker &GetInstance();
|
||||
|
||||
void EnableVsync(bool enable);
|
||||
void WorkThread();
|
||||
uint64_t WaitNextVBlank(unsigned int &sq);
|
||||
bool WaitSignalAndCheckRuning();
|
||||
void ReqesterVBlankCb(std::shared_ptr<VsyncCallBack> &cb);
|
||||
|
||||
private:
|
||||
int mDrmFd = 0;
|
||||
std::unique_ptr<std::thread> mThread;
|
||||
bool mEnable = false;
|
||||
std::mutex mMutex;
|
||||
std::condition_variable mCondition;
|
||||
std::shared_ptr<VsyncCallBack> mCallBack;
|
||||
bool mRunning = false;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // DRM_VSYNC_WORKER_H
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "hdi_composer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
HdiComposer::HdiComposer(std::unique_ptr<HdiComposition> post)
|
||||
{
|
||||
mPostComp = std::move(post);
|
||||
}
|
||||
|
||||
int32_t HdiComposer::Prepare(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer)
|
||||
{
|
||||
|
||||
int ret = mPostComp->SetLayers(layers, clientLayer);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("post composition prepare failed"));
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiComposer::Commit(bool modeSet)
|
||||
{
|
||||
int ret = mPostComp->Apply(modeSet);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("post composition apply failed"));
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
} // OHOS
|
||||
} // HDI
|
||||
} // DISPLAY
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_COMPOSER_H
|
||||
#define HDI_COMPOSER_H
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "hdi_layer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class HdiComposition {
|
||||
public:
|
||||
HdiComposition() {}
|
||||
virtual int32_t Init()
|
||||
{
|
||||
return DISPLAY_SUCCESS;
|
||||
};
|
||||
virtual int32_t SetLayers(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer)
|
||||
{
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
virtual int32_t Apply(bool modeSet)
|
||||
{
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
virtual ~HdiComposition() {}
|
||||
|
||||
protected:
|
||||
std::vector<HdiLayer *> mCompLayers;
|
||||
};
|
||||
|
||||
class HdiComposer {
|
||||
public:
|
||||
HdiComposer(std::unique_ptr<HdiComposition> post);
|
||||
virtual ~HdiComposer() {};
|
||||
int32_t Prepare(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer);
|
||||
int32_t Commit(bool modeSet);
|
||||
HdiComposition *GetPostCompostion()
|
||||
{
|
||||
return mPostComp.get();
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<HdiComposition> mPostComp;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_COMPOSER_H
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_DEVICE_COMMON_H
|
||||
#define HDI_DEVICE_COMMON_H
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "display_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
const int32_t INVALID_MODE_ID = -1;
|
||||
const uint32_t DRM_INVALID_ID = 0xFFFFFFFF;
|
||||
template<typename T> using IdMapPtr = std::unordered_map<uint32_t, std::shared_ptr<T>>;
|
||||
class DrmEncoder;
|
||||
class DrmCrtc;
|
||||
class DrmPlane;
|
||||
class DrmDevice;
|
||||
class DrmConnector;
|
||||
class VsyncCallBack;
|
||||
class DrmVsyncWorker;
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_DEVICE_COMMON_H
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "hdi_device_interface.h"
|
||||
#include <vector>
|
||||
#include "display_common.h"
|
||||
#include "drm_device.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
std::vector<std::shared_ptr<HdiDeviceInterface>> HdiDeviceInterface::DiscoveryDevice()
|
||||
{
|
||||
|
||||
DISPLAY_LOGD();
|
||||
int ret;
|
||||
std::vector<std::shared_ptr<HdiDeviceInterface>> devices;
|
||||
std::shared_ptr<HdiDeviceInterface> drmDevice = DrmDevice::Create();
|
||||
if (!drmDevice) {
|
||||
DISPLAY_LOGE("can not create drm device");
|
||||
}
|
||||
ret = drmDevice->Init();
|
||||
if (ret == DISPLAY_SUCCESS) {
|
||||
DISPLAY_LOGD("drm device init success");
|
||||
devices.push_back(std::move(drmDevice));
|
||||
} else {
|
||||
DISPLAY_LOGE("drm device init failed");
|
||||
}
|
||||
DISPLAY_LOGD();
|
||||
return devices;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_DEVICE_INTERFACE_H
|
||||
#define HDI_DEVICE_INTERFACE_H
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "hdi_display.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class HdiDeviceInterface {
|
||||
public:
|
||||
static std::vector<std::shared_ptr<HdiDeviceInterface>> DiscoveryDevice();
|
||||
virtual std::unordered_map<uint32_t, std::shared_ptr<HdiDisplay>> DiscoveryDisplay() = 0;
|
||||
virtual int32_t Init() = 0;
|
||||
virtual void DeInit() = 0;
|
||||
virtual ~HdiDeviceInterface() {};
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_DEVICE_INTERFACE_H
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "hdi_display.h"
|
||||
#include <vector>
|
||||
#include "display_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
uint32_t HdiDisplay::mIdleId = 0;
|
||||
std::unordered_set<uint32_t> HdiDisplay::mIdSets;
|
||||
|
||||
uint32_t HdiDisplay::GetIdleId()
|
||||
{
|
||||
const uint32_t oldIdleId = mIdleId;
|
||||
uint32_t id = INVALIDE_DISPLAY_ID;
|
||||
// ensure the mIdleId not INVALIDE_DISPLAY_ID
|
||||
mIdleId = mIdleId % INVALIDE_DISPLAY_ID;
|
||||
do {
|
||||
auto iter = mIdSets.find(mIdleId);
|
||||
if (iter == mIdSets.end()) {
|
||||
id = mIdleId;
|
||||
break;
|
||||
}
|
||||
mIdleId = (mIdleId + 1) % INVALIDE_DISPLAY_ID;
|
||||
} while (oldIdleId != mIdleId);
|
||||
mIdSets.emplace(id);
|
||||
mIdleId++;
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
int32_t HdiDisplay::Init()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
uint32_t id = GetIdleId();
|
||||
DISPLAY_CHK_RETURN((id == INVALIDE_DISPLAY_ID), DISPLAY_FAILURE, DISPLAY_LOGE("have no id to used"));
|
||||
mId = id;
|
||||
auto layer = CreateHdiLayer(LAYER_TYPE_GRAPHIC);
|
||||
DISPLAY_CHK_RETURN((layer.get() == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("can not create hdi layer for client"));
|
||||
mClientLayer = std::move(layer);
|
||||
DISPLAY_LOGD("the id is %{public}d", id);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
HdiDisplay::~HdiDisplay()
|
||||
{
|
||||
mIdSets.erase(mId);
|
||||
}
|
||||
|
||||
int32_t HdiDisplay::SetLayerZorder(uint32_t layerId, uint32_t zorder)
|
||||
{
|
||||
DISPLAY_LOGD("layerId:%{public}d zorder:%{public}d size:%{public}zu", layerId, zorder, mLayers.size());
|
||||
auto iter = mLayersMap.find(layerId);
|
||||
DISPLAY_CHK_RETURN((iter == mLayersMap.end()), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not find the layer %{public}d", layerId));
|
||||
auto layer = mLayersMap[layerId].get();
|
||||
if (layer->GetZorder() == zorder) {
|
||||
DISPLAY_LOGD("zorder no change layerId %{public}d, zorder %{public}d", layerId, zorder);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
// reset to sort
|
||||
auto zRange = mLayers.equal_range(layer);
|
||||
DISPLAY_LOGD("zorder range : zRange.first %{public}p zRange.second %{public}p", *zRange.first, *zRange.second);
|
||||
for (auto c = zRange.first; c != zRange.second; c++) {
|
||||
if (*c == layer) {
|
||||
DISPLAY_LOGD("erase layer:%{public}p", layer);
|
||||
mLayers.erase(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
layer->SetLayerZorder(zorder);
|
||||
mLayers.emplace(layer);
|
||||
DISPLAY_LOGD("SetLayerZorder size:%{public}zu", mLayers.size());
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDisplay::CreateLayer(const LayerInfo *layerInfo, uint32_t *layerId)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
int ret;
|
||||
DISPLAY_CHK_RETURN((layerInfo == nullptr), DISPLAY_PARAM_ERR, DISPLAY_LOGE("LayerInfo is null"));
|
||||
DISPLAY_CHK_RETURN((layerId == nullptr), DISPLAY_PARAM_ERR, DISPLAY_LOGE("layerId is null"));
|
||||
auto layer = CreateHdiLayer(layerInfo->type);
|
||||
DISPLAY_CHK_RETURN((layer.get() == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("can not create hdi layer"));
|
||||
ret = layer->Init();
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("Layer Init failed"));
|
||||
*layerId = layer->GetId();
|
||||
mLayers.insert(layer.get());
|
||||
mLayersMap.emplace(layer->GetId(), std::move(layer));
|
||||
DISPLAY_LOGD("mLayers size %{public}zu", mLayers.size());
|
||||
DISPLAY_LOGD("mLayerMap size %{public}zu", mLayersMap.size());
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
std::unique_ptr<HdiLayer> HdiDisplay::CreateHdiLayer(LayerType type)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
return std::make_unique<HdiLayer>(type);
|
||||
}
|
||||
|
||||
|
||||
int32_t HdiDisplay::CloseLayer(uint32_t layerId)
|
||||
{
|
||||
DISPLAY_LOGD("layerId %{public}d", layerId);
|
||||
auto iter = mLayersMap.find(layerId);
|
||||
DISPLAY_CHK_RETURN((iter == mLayersMap.end()), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not find the layer id %{public}d", layerId));
|
||||
auto layer = iter->second.get();
|
||||
auto zRange = mLayers.equal_range(layer);
|
||||
DISPLAY_LOGD("zorder range:zRange.first %{public}p, zRange.second %{public}p", *zRange.first, *zRange.second);
|
||||
for (auto c = zRange.first; c != zRange.second; c++) {
|
||||
if (*c == layer) {
|
||||
DISPLAY_LOGD("erase layer:%{public}p", layer);
|
||||
mLayers.erase(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mLayersMap.erase(layerId);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDisplay::GetDisplayCompChange(uint32_t *num, uint32_t *layers, int32_t *type)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((num == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("the num is nullptr"));
|
||||
*num = mChangeLayers.size();
|
||||
if ((layers == nullptr) && (type == nullptr)) {
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
DISPLAY_LOGD("set the layers and type");
|
||||
for (uint32_t i = 0; i < mChangeLayers.size(); i++) {
|
||||
HdiLayer *layer = mChangeLayers[i];
|
||||
if (layers != nullptr) {
|
||||
*(layers + i) = layer->GetId();
|
||||
}
|
||||
if (type != nullptr) {
|
||||
*(type + i) = layer->GetCompositionType();
|
||||
}
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDisplay::GetDisplayReleaseFence(uint32_t *num, uint32_t *layers, int32_t *fences)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((num == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("the num is nullptr"));
|
||||
*num = mLayers.size();
|
||||
if ((layers == nullptr) && (fences == nullptr)) {
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
DISPLAY_LOGD("set the layer fences");
|
||||
int i = 0;
|
||||
for (auto layer : mLayers) {
|
||||
if (layers != nullptr) {
|
||||
*(layers + i) = layer->GetId();
|
||||
}
|
||||
if (fences != nullptr) {
|
||||
*(fences + i) = dup(layer->GetReleaseFenceFd());
|
||||
}
|
||||
DISPLAY_LOGD("layer id %{public}d fencefd %{public}d", layer->GetId(), layer->GetReleaseFenceFd());
|
||||
i++;
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDisplay::PrepareDisplayLayers(bool *needFlushFb)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
mChangeLayers.clear();
|
||||
std::vector<HdiLayer *> layers;
|
||||
for (auto c : mLayers) {
|
||||
if (c->IsVisible()) {
|
||||
layers.push_back(c);
|
||||
}
|
||||
}
|
||||
DISPLAY_LOGD(" mLayers size %{public}zu layers size %{public}zu", mLayers.size(), layers.size());
|
||||
|
||||
mComposer->Prepare(layers, *mClientLayer);
|
||||
// get the change layers
|
||||
for (auto &layer : layers) {
|
||||
if (layer->GetDeviceSelect() != layer->GetCompositionType()) {
|
||||
DISPLAY_LOGD("layer change");
|
||||
layer->SetLayerCompositionType(layer->GetDeviceSelect());
|
||||
}
|
||||
mChangeLayers.push_back(layer);
|
||||
}
|
||||
*needFlushFb = true;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDisplay::Commit(int32_t *fence)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
mComposer->Commit(false);
|
||||
*fence = dup(mClientLayer->GetReleaseFenceFd());
|
||||
DISPLAY_LOGD("the release fence is %{public}d", *fence);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDisplay::SetDisplayClientBuffer(const BufferHandle *buffer, int32_t fence)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
mClientLayer->SetLayerBuffer(buffer, fence);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
HdiLayer *HdiDisplay::GetHdiLayer(uint32_t id)
|
||||
{
|
||||
DISPLAY_LOGD("id : %{public}d", id);
|
||||
auto iter = mLayersMap.find(id);
|
||||
DISPLAY_CHK_RETURN((iter == mLayersMap.end()), nullptr, DISPLAY_LOGE("can not find the layer %{public}d", id));
|
||||
return iter->second.get();
|
||||
}
|
||||
|
||||
VsyncCallBack::VsyncCallBack(VBlankCallback cb, void *data) : mVBlankCb(cb), mData(data)
|
||||
{
|
||||
DISPLAY_LOGD("VsyncCallBack %{public}p", cb);
|
||||
}
|
||||
|
||||
void VsyncCallBack::Vsync(unsigned int sequence, uint64_t ns)
|
||||
{
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((mVBlankCb == nullptr), DISPLAY_LOGE("the callback is nullptr"));
|
||||
mVBlankCb(sequence, ns, mData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_DISPLAY_H
|
||||
#define HDI_DISPLAY_H
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <memory.h>
|
||||
#include "display_device.h"
|
||||
#include "hdi_composer.h"
|
||||
#include "hdi_layer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
const uint32_t INVALIDE_DISPLAY_ID = 0xffffffff;
|
||||
const uint32_t DISPLAY_TYPE_DRM = (1 << 31);
|
||||
|
||||
class VsyncCallBack {
|
||||
public:
|
||||
VsyncCallBack(VBlankCallback cb, void *data);
|
||||
virtual void Vsync(unsigned int sequence, uint64_t ns);
|
||||
virtual ~VsyncCallBack() {}
|
||||
|
||||
private:
|
||||
VBlankCallback mVBlankCb;
|
||||
void *mData;
|
||||
};
|
||||
|
||||
|
||||
class HdiDisplay {
|
||||
public:
|
||||
uint32_t GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
virtual int32_t Init();
|
||||
virtual void DeInit() {}
|
||||
HdiDisplay() {}
|
||||
virtual ~HdiDisplay();
|
||||
virtual int32_t GetDisplayCapability(DisplayCapability *info)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t GetDisplaySuppportedModes(uint32_t *num, DisplayModeInfo *modes)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t GetDisplayMode(uint32_t *modeId)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t SetDisplayMode(uint32_t modeId)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t GetDisplayPowerStatus(DispPowerStatus *status)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t SetDisplayPowerStatus(DispPowerStatus status)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t GetDisplayBacklight(uint32_t *value)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t SetDisplayBacklight(uint32_t value)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t CreateLayer(const LayerInfo *layerInfo, uint32_t *layerId);
|
||||
virtual int32_t CloseLayer(uint32_t layerId);
|
||||
virtual int32_t PrepareDisplayLayers(bool *needFlushFb);
|
||||
virtual int32_t Commit(int32_t *fence);
|
||||
virtual int32_t GetDisplayCompChange(uint32_t *num, uint32_t *layers, int32_t *type);
|
||||
virtual int32_t SetLayerZorder(uint32_t layerId, uint32_t zorder);
|
||||
virtual bool IsConnected()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual int32_t RegDisplayVBlankCallback(VBlankCallback cb, void *data)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t SetDisplayVsyncEnabled(bool enabled)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
virtual int32_t GetDisplayReleaseFence(uint32_t *num, uint32_t *layers, int32_t *fences);
|
||||
virtual int32_t SetDisplayClientBuffer(const BufferHandle *buffer, int32_t fence);
|
||||
virtual int32_t WaitForVBlank(uint64_t *ns)
|
||||
{
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
HdiLayer *GetHdiLayer(uint32_t id);
|
||||
|
||||
protected:
|
||||
virtual std::unique_ptr<HdiLayer> CreateHdiLayer(LayerType type);
|
||||
std::unique_ptr<HdiComposer> mComposer;
|
||||
|
||||
static uint32_t GetIdleId();
|
||||
static uint32_t mIdleId;
|
||||
static std::unordered_set<uint32_t> mIdSets;
|
||||
uint32_t mId = INVALIDE_DISPLAY_ID;
|
||||
std::unordered_map<uint32_t, std::unique_ptr<HdiLayer>> mLayersMap;
|
||||
std::multiset<HdiLayer *, SortLayersByZ> mLayers;
|
||||
std::unique_ptr<HdiLayer> mClientLayer;
|
||||
std::vector<HdiLayer *> mChangeLayers;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_DISPLAY_H
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "hdi_drm_composition.h"
|
||||
#include <cerrno>
|
||||
#include "hdi_drm_layer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
HdiDrmComposition::HdiDrmComposition(std::shared_ptr<DrmConnector> connector, std::shared_ptr<DrmCrtc> crtc,
|
||||
std::shared_ptr<DrmDevice> drmDevice)
|
||||
: mDrmDevice(drmDevice), mConnector(connector), mCrtc(crtc)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
}
|
||||
|
||||
int32_t HdiDrmComposition::Init()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
mPrimPlanes.clear();
|
||||
mOverlayPlanes.clear();
|
||||
mPlanes.clear();
|
||||
DISPLAY_CHK_RETURN((mCrtc == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("crtc is null"));
|
||||
DISPLAY_CHK_RETURN((mConnector == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("connector is null"));
|
||||
DISPLAY_CHK_RETURN((mDrmDevice == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("drmDevice is null"));
|
||||
mPrimPlanes = mDrmDevice->GetDrmPlane(mCrtc->GetPipe(), DRM_PLANE_TYPE_PRIMARY);
|
||||
mOverlayPlanes = mDrmDevice->GetDrmPlane(mCrtc->GetPipe(), DRM_PLANE_TYPE_OVERLAY);
|
||||
DISPLAY_CHK_RETURN((mPrimPlanes.size() == 0), DISPLAY_FAILURE, DISPLAY_LOGE("has no primary plane"));
|
||||
mPlanes.insert(mPlanes.end(), mPrimPlanes.begin(), mPrimPlanes.end());
|
||||
mPlanes.insert(mPlanes.end(), mOverlayPlanes.begin(), mOverlayPlanes.end());
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDrmComposition::SetLayers(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer)
|
||||
{
|
||||
// now we do not surpport present direct
|
||||
DISPLAY_LOGD("SetLayers%{public}d\n", layers.size());
|
||||
mCompLayers.clear();
|
||||
//TMP OHOS station support all layer
|
||||
for (auto &layer : layers) {
|
||||
layer->SetDeviceSelect(COMPOSITION_CLIENT);
|
||||
}
|
||||
mCompLayers.push_back(&clientLayer);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDrmComposition::ApplyPlane(HdiDrmLayer &layer, DrmPlane &drmPlane, drmModeAtomicReqPtr pset)
|
||||
{
|
||||
// set fence in
|
||||
int ret;
|
||||
int fenceFd = layer.GetAcquireFenceFd();
|
||||
int propId = drmPlane.GetPropFenceInId();
|
||||
DISPLAY_LOGD();
|
||||
if (propId != 0) {
|
||||
DISPLAY_LOGD("set the fence in prop");
|
||||
if (fenceFd >= 0) {
|
||||
ret = drmModeAtomicAddProperty(pset, drmPlane.GetId(), propId, fenceFd);
|
||||
DISPLAY_LOGD("set the IfenceProp plane id %{public}d, propId %{public}d, fenceFd %{public}d",
|
||||
drmPlane.GetId(), propId, fenceFd);
|
||||
DISPLAY_CHK_RETURN((ret < 0), DISPLAY_FAILURE, DISPLAY_LOGE("set IN_FENCE_FD failed"));
|
||||
}
|
||||
}
|
||||
|
||||
// set fb id
|
||||
DrmGemBuffer *gemBuffer = layer.GetGemBuffer();
|
||||
DISPLAY_CHK_RETURN((gemBuffer == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("current gemBuffer is nullptr"));
|
||||
DISPLAY_CHK_RETURN((!gemBuffer->IsValid()), DISPLAY_FAILURE, DISPLAY_LOGE("the DrmGemBuffer is invalid"));
|
||||
ret = drmModeAtomicAddProperty(pset, drmPlane.GetId(), drmPlane.GetPropFbId(), gemBuffer->GetFbId());
|
||||
DISPLAY_LOGD("set the fb planeid %{public}d, propId %{public}d, fbId %{public}d", drmPlane.GetId(),
|
||||
drmPlane.GetPropFbId(), gemBuffer->GetFbId());
|
||||
DISPLAY_CHK_RETURN((ret < 0), DISPLAY_FAILURE, DISPLAY_LOGE("set fb id fialed errno : %{public}d", errno));
|
||||
|
||||
// set crtc id
|
||||
ret = drmModeAtomicAddProperty(pset, drmPlane.GetId(), drmPlane.GetPropCrtcId(), mCrtc->GetId());
|
||||
DISPLAY_LOGD("set the crtc planeId %{public}d, propId %{public}d, crtcId %{public}d", drmPlane.GetId(),
|
||||
drmPlane.GetPropCrtcId(), mCrtc->GetId());
|
||||
DISPLAY_CHK_RETURN((ret < 0), DISPLAY_FAILURE, DISPLAY_LOGE("set crtc id fialed errno : %{public}d", errno));
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDrmComposition::UpdateMode(std::unique_ptr<DrmModeBlock> &modeBlock, drmModeAtomicReq &pset)
|
||||
{
|
||||
// set the mode
|
||||
DISPLAY_LOGD();
|
||||
if (mCrtc->NeedModeSet()) {
|
||||
modeBlock = mConnector->GetModeBlockFromId(mCrtc->GetActiveModeId());
|
||||
if ((modeBlock != nullptr) && (modeBlock->GetBlockId() != DRM_INVALID_ID)) {
|
||||
// set to active
|
||||
DISPLAY_LOGD("set crtc to active");
|
||||
int ret = drmModeAtomicAddProperty(&pset, mCrtc->GetId(), mCrtc->GetActivePropId(), 1);
|
||||
DISPLAY_CHK_RETURN((ret < 0), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not add the active prop errno %{public}d", errno));
|
||||
|
||||
// set the mode id
|
||||
DISPLAY_LOGD("set the mode");
|
||||
ret = drmModeAtomicAddProperty(&pset, mCrtc->GetId(), mCrtc->GetModePropId(), modeBlock->GetBlockId());
|
||||
DISPLAY_LOGD("set the mode planeId %{public}d, propId %{public}d, GetBlockId: %{public}d", mCrtc->GetId(),
|
||||
mCrtc->GetModePropId(), modeBlock->GetBlockId());
|
||||
DISPLAY_CHK_RETURN((ret < 0), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not add the mode prop errno %{public}d", errno));
|
||||
ret = drmModeAtomicAddProperty(&pset, mConnector->GetId(), mConnector->GetPropCrtcId(), mCrtc->GetId());
|
||||
DISPLAY_LOGD("set the connector id: %{public}d, propId %{public}d, crtcId %{public}d", mConnector->GetId(),
|
||||
mConnector->GetPropCrtcId(), mCrtc->GetId());
|
||||
DISPLAY_CHK_RETURN((ret < 0), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not add the crtc id prop %{public}d", errno));
|
||||
}
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiDrmComposition::Apply(bool modeSet)
|
||||
{
|
||||
uint64_t crtcOutFence = -1;
|
||||
int ret;
|
||||
std::unique_ptr<DrmModeBlock> modeBlock;
|
||||
int drmFd = mDrmDevice->GetDrmFd();
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((mPlanes.size() < mCompLayers.size()), DISPLAY_FAILURE, DISPLAY_LOGE("plane not enough"));
|
||||
drmModeAtomicReqPtr pset = drmModeAtomicAlloc();
|
||||
DISPLAY_CHK_RETURN((pset == nullptr), DISPLAY_NULL_PTR,
|
||||
DISPLAY_LOGE("drm atomic alloc failed errno %{public}d", errno));
|
||||
AtomicReqPtr atomicReqPtr = AtomicReqPtr(pset);
|
||||
|
||||
// set the outFence property
|
||||
ret = drmModeAtomicAddProperty(atomicReqPtr.Get(), mCrtc->GetId(), mCrtc->GetOutFencePropId(),
|
||||
(uint64_t)&crtcOutFence);
|
||||
|
||||
DISPLAY_LOGD("Apply Set OutFence crtc id: %{public}d, fencePropId %{public}d", mCrtc->GetId(),
|
||||
mCrtc->GetOutFencePropId());
|
||||
DISPLAY_CHK_RETURN((ret < 0), DISPLAY_FAILURE, DISPLAY_LOGE("set the outfence property of crtc failed "));
|
||||
|
||||
// set the plane info.
|
||||
DISPLAY_LOGD("mCompLayers size %{public}zd", mCompLayers.size());
|
||||
for (uint32_t i = 0; i < mCompLayers.size(); i++) {
|
||||
HdiDrmLayer *layer = static_cast<HdiDrmLayer *>(mCompLayers[i]);
|
||||
auto &drmPlane = mPlanes[i];
|
||||
ret = ApplyPlane(*layer, *drmPlane, atomicReqPtr.Get());
|
||||
if (ret != DISPLAY_SUCCESS) {
|
||||
DISPLAY_LOGE("apply plane failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret = UpdateMode(modeBlock, *(atomicReqPtr.Get()));
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("update mode failed"));
|
||||
uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
|
||||
ret = drmModeAtomicCommit(drmFd, atomicReqPtr.Get(), flags, nullptr);
|
||||
DISPLAY_CHK_RETURN((ret != 0), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("drmModeAtomicCommit failed %{public}d errno %{public}d", ret, errno));
|
||||
// set the release fence
|
||||
for (auto layer : mCompLayers) {
|
||||
layer->SetReleaseFence(static_cast<int>(crtcOutFence));
|
||||
}
|
||||
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
} // OHOS
|
||||
} // HDI
|
||||
} // DISPLAY
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_DRM_COMPOSITION_H
|
||||
#define HDI_DRM_COMPOSITION_H
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include "drm_device.h"
|
||||
#include "hdi_composer.h"
|
||||
#include "hdi_device_common.h"
|
||||
#include "hdi_drm_layer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class AtomicReqPtr {
|
||||
public:
|
||||
explicit AtomicReqPtr(drmModeAtomicReqPtr ptr) : mPtr(ptr) {}
|
||||
virtual ~AtomicReqPtr()
|
||||
{
|
||||
if (mPtr != nullptr)
|
||||
drmModeAtomicFree(mPtr);
|
||||
}
|
||||
drmModeAtomicReqPtr Get() const
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
private:
|
||||
drmModeAtomicReqPtr mPtr;
|
||||
};
|
||||
|
||||
class HdiDrmComposition : public HdiComposition {
|
||||
public:
|
||||
HdiDrmComposition(std::shared_ptr<DrmConnector> connector, std::shared_ptr<DrmCrtc> crtc,
|
||||
std::shared_ptr<DrmDevice> drmDevice);
|
||||
virtual ~HdiDrmComposition() {}
|
||||
int32_t Init();
|
||||
int32_t SetLayers(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer);
|
||||
int32_t Apply(bool modeSet);
|
||||
int32_t UpdateMode(std::unique_ptr<DrmModeBlock> &modeBlock, drmModeAtomicReq &pset);
|
||||
|
||||
private:
|
||||
int32_t ApplyPlane(HdiDrmLayer &layer, DrmPlane &drmPlane, drmModeAtomicReqPtr pset);
|
||||
std::shared_ptr<DrmDevice> mDrmDevice;
|
||||
std::shared_ptr<DrmConnector> mConnector;
|
||||
std::shared_ptr<DrmCrtc> mCrtc;
|
||||
std::vector<std::shared_ptr<DrmPlane>> mPrimPlanes;
|
||||
std::vector<std::shared_ptr<DrmPlane>> mOverlayPlanes;
|
||||
std::vector<std::shared_ptr<DrmPlane>> mPlanes;
|
||||
};
|
||||
} // OHOS
|
||||
} // HDI
|
||||
} // DISPLAY
|
||||
|
||||
#endif // HDI_DRM_COMPOSITION_H
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "hdi_drm_layer.h"
|
||||
#include <cinttypes>
|
||||
#include <errno.h>
|
||||
#include "drm_device.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
DrmGemBuffer::DrmGemBuffer(int drmfd, HdiLayerBuffer &hdl) : mDrmFd(drmfd)
|
||||
{
|
||||
DISPLAY_LOGD("%{public}p", this);
|
||||
Init(mDrmFd, hdl);
|
||||
}
|
||||
|
||||
void DrmGemBuffer::Init(int drmFd, HdiLayerBuffer &hdl)
|
||||
{
|
||||
int ret;
|
||||
const int MAX_COUNT = 4;
|
||||
uint32_t pitches[MAX_COUNT] = {0};
|
||||
uint32_t gemHandles[MAX_COUNT] = {0};
|
||||
uint32_t offsets[MAX_COUNT] = {0};
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((drmFd < 0), DISPLAY_LOGE("can not init drmfd %{public}d", drmFd));
|
||||
mDrmFormat = DrmDevice::ConvertToDrmFormat(static_cast<PixelFormat>(hdl.GetFormat()));
|
||||
ret = drmPrimeFDToHandle(drmFd, hdl.GetFb(), &mGemHandle);
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((ret != 0), DISPLAY_LOGE("can not get handle errno %{public}d", errno));
|
||||
|
||||
pitches[0] = hdl.GetStride();
|
||||
gemHandles[0] = mGemHandle;
|
||||
offsets[0] = 0;
|
||||
ret = drmModeAddFB2(drmFd, hdl.GetWight(), hdl.GetHeight(), mDrmFormat, gemHandles, pitches, offsets, &mFdId, 0);
|
||||
DISPLAY_LOGD("w: %{public}d h: %{public}d mDrmFormat : %{public}d gemHandles: %{public}d pitches: %{public}d "
|
||||
"offsets: %{public}d",
|
||||
hdl.GetWight(), hdl.GetHeight(), mDrmFormat, gemHandles[0], pitches[0], offsets[0]);
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((ret != 0), DISPLAY_LOGE("can not add fb errno %{public}d", errno));
|
||||
}
|
||||
|
||||
DrmGemBuffer::~DrmGemBuffer()
|
||||
{
|
||||
DISPLAY_LOGD("%{public}p", this);
|
||||
if (mFdId) {
|
||||
if (drmModeRmFB(mDrmFd, mFdId)) {
|
||||
DISPLAY_LOGE("can not free fdid %{public}d errno %{public}d", mFdId, errno);
|
||||
}
|
||||
}
|
||||
|
||||
if (mGemHandle) {
|
||||
struct drm_gem_close gemClose = { 0 };
|
||||
gemClose.handle = mGemHandle;
|
||||
if (drmIoctl(mDrmFd, DRM_IOCTL_GEM_CLOSE, &gemClose)) {
|
||||
DISPLAY_LOGE("can not free gem handle %{public}d errno : %{public}d", mGemHandle, errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DrmGemBuffer::IsValid()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
return (mGemHandle != INVALID_DRM_ID) && (mFdId != INVALID_DRM_ID);
|
||||
}
|
||||
|
||||
DrmGemBuffer *HdiDrmLayer::GetGemBuffer()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
std::unique_ptr<DrmGemBuffer> ptr = std::make_unique<DrmGemBuffer>(DrmDevice::GetDrmFd(), *GetCurrentBuffer());
|
||||
LastBuffer = std::move(mCurrentBuffer);
|
||||
mCurrentBuffer = std::move(ptr);
|
||||
return mCurrentBuffer.get();
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_DRM_LAYER_H
|
||||
#define HDI_DRM_LAYER_H
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include "buffer_handle.h"
|
||||
#include "display_common.h"
|
||||
#include "drm_fourcc.h"
|
||||
#include "hdi_layer.h"
|
||||
#include "hdi_device_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
const int INVALID_DRM_ID = 0;
|
||||
class DrmGemBuffer {
|
||||
public:
|
||||
DrmGemBuffer(int drmFd, HdiLayerBuffer &hdl);
|
||||
virtual ~DrmGemBuffer();
|
||||
uint32_t GetFbId() const
|
||||
{
|
||||
return mFdId;
|
||||
}
|
||||
bool IsValid();
|
||||
|
||||
private:
|
||||
void Init(int drmFd, HdiLayerBuffer &hdl);
|
||||
uint32_t mGemHandle = 0;
|
||||
uint32_t mFdId = 0;
|
||||
int mDrmFd = -1; // the fd can not close. the other module will close it.
|
||||
uint32_t mDrmFormat = DRM_FORMAT_INVALID;
|
||||
};
|
||||
|
||||
class HdiDrmLayer : public HdiLayer {
|
||||
public:
|
||||
explicit HdiDrmLayer(LayerType type) : HdiLayer(type) {}
|
||||
virtual ~HdiDrmLayer() {}
|
||||
// Return value optimization
|
||||
DrmGemBuffer *GetGemBuffer();
|
||||
|
||||
private:
|
||||
std::unique_ptr<DrmGemBuffer> mCurrentBuffer;
|
||||
std::unique_ptr<DrmGemBuffer> LastBuffer;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_DRM_LAYER_H
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "hdi_layer.h"
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "display_gralloc_private.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
uint32_t HdiLayer::mIdleId = 0;
|
||||
std::unordered_set<uint32_t> HdiLayer::mIdSets;
|
||||
|
||||
HdiLayerBuffer::HdiLayerBuffer(const BufferHandle &hdl)
|
||||
: mPhyAddr(hdl.phyAddr), mHeight(hdl.height), mWidth(hdl.width), mStride(hdl.stride), mFormat(hdl.format)
|
||||
{
|
||||
PriBufferHandle &hdlp = (PriBufferHandle&) hdl;
|
||||
mFd = dup(hdl.fd);
|
||||
mHandle = hdl;
|
||||
if (mFd < 0) {
|
||||
DISPLAY_LOGE("the fd : %{public}d dup failed errno %{public}d return:%{public}d gralloc id:%{public}llu", hdl.fd, errno, mFd, hdlp.id);
|
||||
}
|
||||
}
|
||||
|
||||
HdiLayerBuffer::~HdiLayerBuffer()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
if (mFd >= 0) {
|
||||
close(mFd);
|
||||
}
|
||||
}
|
||||
|
||||
HdiLayerBuffer &HdiLayerBuffer::operator = (const BufferHandle &right)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
if (mFd >= 0) {
|
||||
close(mFd);
|
||||
}
|
||||
mFd = right.fd;
|
||||
mPhyAddr = right.phyAddr;
|
||||
mWidth = right.width;
|
||||
mHeight = right.height;
|
||||
mStride = right.stride;
|
||||
mFormat = right.format;
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint32_t HdiLayer::GetIdleId()
|
||||
{
|
||||
const uint32_t oldIdleId = mIdleId;
|
||||
uint32_t id = INVALIDE_LAYER_ID;
|
||||
// ensure the mIdleId not INVALIDE_LAYER_ID
|
||||
mIdleId = mIdleId % INVALIDE_LAYER_ID;
|
||||
do {
|
||||
auto iter = mIdSets.find(mIdleId);
|
||||
if (iter == mIdSets.end()) {
|
||||
id = mIdleId;
|
||||
break;
|
||||
}
|
||||
mIdleId = (mIdleId + 1) % INVALIDE_LAYER_ID;
|
||||
} while (oldIdleId != mIdleId);
|
||||
mIdSets.emplace(id);
|
||||
mIdleId++;
|
||||
DISPLAY_LOGD("id %{public}d mIdleId %{public}d", id, mIdleId);
|
||||
return id;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::Init()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
uint32_t id = GetIdleId();
|
||||
DISPLAY_CHK_RETURN((id == INVALIDE_LAYER_ID), DISPLAY_FAILURE, DISPLAY_LOGE("have no id to used"));
|
||||
mId = id;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerSize(IRect *rect)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((rect == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("in rect is nullptr"));
|
||||
DISPLAY_LOGD(" displayRect x: %{public}d y : %{public}d w : %{public}d h : %{public}d", rect->x, rect->y, rect->w,
|
||||
rect->h);
|
||||
mDisplayRect = *rect;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerCrop(IRect *rect)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((rect == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("in rect is nullptr"));
|
||||
DISPLAY_LOGD("id : %{public}d crop x: %{public}d y : %{public}d w : %{public}d h : %{public}d", mId, rect->x,
|
||||
rect->y, rect->w, rect->h);
|
||||
mCrop = *rect;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
void HdiLayer::SetLayerZorder(uint32_t zorder)
|
||||
{
|
||||
DISPLAY_LOGD("id : %{public}d zorder : %{public}d ", mId, zorder);
|
||||
mZorder = zorder;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerPreMulti(bool preMul)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
mPreMul = preMul;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerAlpha(LayerAlpha *alpha)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((alpha == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("in alpha is nullptr"));
|
||||
DISPLAY_LOGD("enable alpha %{public}d galpha 0x%{public}x", alpha->enGlobalAlpha, alpha->gAlpha);
|
||||
mAlpha = *alpha;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetTransformMode(TransformType type)
|
||||
{
|
||||
DISPLAY_LOGD("TransformType %{public}d", type);
|
||||
mTransformType = type;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerDirtyRegion(IRect *region)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((region == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("the in rect is null"));
|
||||
DISPLAY_LOGD("id : %{public}d DirtyRegion x: %{public}d y : %{public}d w : %{public}d h : %{public}d", mId,
|
||||
region->x, region->y, region->w, region->h);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerVisibleRegion(uint32_t num, IRect *rect)
|
||||
{
|
||||
DISPLAY_LOGD("id : %{public}d DirtyRegion x: %{public}d y : %{public}d w : %{public}d h : %{public}d", mId, rect->x,
|
||||
rect->y, rect->w, rect->h);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerBuffer(const BufferHandle *buffer, int32_t fence)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((buffer == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("buffer is nullptr"));
|
||||
std::unique_ptr<HdiLayerBuffer> layerbuffer = std::make_unique<HdiLayerBuffer>(*buffer);
|
||||
mHdiBuffer = std::move(layerbuffer);
|
||||
mAcquireFence = dup(fence);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerCompositionType(CompositionType type)
|
||||
{
|
||||
DISPLAY_LOGD("CompositionType type %{public}d", type);
|
||||
mCompositionType = type;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerBlendType(BlendType type)
|
||||
{
|
||||
DISPLAY_LOGD("BlendType type %{public}d", type);
|
||||
mBlendType = type;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiLayer::SetLayerVisible(bool visible)
|
||||
{
|
||||
DISPLAY_LOGD("SetLayerVisible type %{public}d", visible);
|
||||
mVisible = visible;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
void HdiLayer::SetPixel(const BufferHandle &handle, int x, int y, uint32_t color)
|
||||
{
|
||||
const int32_t pixelBytes = 4;
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((handle.format <= 0),
|
||||
DISPLAY_LOGE("CheckPixel do not support format %{public}d", handle.format));
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((handle.virAddr == nullptr), DISPLAY_LOGE("CheckPixel viraddr is null must map it"));
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((x < 0 || x >= handle.width),
|
||||
DISPLAY_LOGE("CheckPixel invalid parameter x:%{public}d width:%{public}d", x, handle.width));
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((y < 0 || y >= handle.height),
|
||||
DISPLAY_LOGE("CheckPixel invalid parameter y:%{public}d height:%{public}d", y, handle.height));
|
||||
int32_t position = y * handle.width + x;
|
||||
if ((position * pixelBytes) > handle.size) {
|
||||
DISPLAY_LOGE("the pixel postion outside\n");
|
||||
}
|
||||
uint32_t *pixel = reinterpret_cast<uint32_t *>(handle.virAddr) + position;
|
||||
*pixel = color;
|
||||
}
|
||||
|
||||
void HdiLayer::ClearColor(uint32_t color)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
BufferHandle &handle = mHdiBuffer->mHandle;
|
||||
for (int32_t x = 0; x < handle.width; x++) {
|
||||
for (int32_t y = 0; y < handle.height; y++) {
|
||||
SetPixel(handle, x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_LAYER_H
|
||||
#define HDI_LAYER_H
|
||||
#include <unordered_set>
|
||||
#include <memory>
|
||||
#include "buffer_handle.h"
|
||||
#include "display_common.h"
|
||||
#include "hdi_device_common.h"
|
||||
#include "hdi_shared_fd.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
const uint32_t INVALIDE_LAYER_ID = 0xffffffff;
|
||||
struct HdiLayerBuffer {
|
||||
public:
|
||||
explicit HdiLayerBuffer(const BufferHandle &hdl);
|
||||
virtual ~HdiLayerBuffer();
|
||||
HdiLayerBuffer &operator = (const BufferHandle &right);
|
||||
uint64_t GetPhysicalAddr() const
|
||||
{
|
||||
return mPhyAddr;
|
||||
}
|
||||
int32_t GetHeight() const
|
||||
{
|
||||
return mHeight;
|
||||
}
|
||||
int32_t GetWight() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
int32_t GetStride() const
|
||||
{
|
||||
return mStride;
|
||||
}
|
||||
int32_t GetFormat() const
|
||||
{
|
||||
return mFormat;
|
||||
}
|
||||
int GetFb() const
|
||||
{
|
||||
return mFd;
|
||||
}
|
||||
BufferHandle mHandle;
|
||||
|
||||
private:
|
||||
uint64_t mPhyAddr = 0;
|
||||
int32_t mHeight = 0;
|
||||
int32_t mWidth = 0;
|
||||
int32_t mStride = 0;
|
||||
int32_t mFormat = 0;
|
||||
int mFd = -1;
|
||||
};
|
||||
|
||||
class HdiLayer {
|
||||
public:
|
||||
explicit HdiLayer(LayerType type) : mType(type) {}
|
||||
int32_t Init();
|
||||
uint32_t GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
uint32_t GetZorder() const
|
||||
{
|
||||
return mZorder;
|
||||
}
|
||||
const IRect &GetLayerDisplayRect() const
|
||||
{
|
||||
return mDisplayRect;
|
||||
}
|
||||
const IRect &GetLayerCrop() const
|
||||
{
|
||||
return mCrop;
|
||||
}
|
||||
bool GetLayerPreMulti() const
|
||||
{
|
||||
return mPreMul;
|
||||
}
|
||||
const LayerAlpha &GetAlpha() const
|
||||
{
|
||||
return mAlpha;
|
||||
}
|
||||
LayerType GetType() const
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
TransformType GetTransFormType() const
|
||||
{
|
||||
return mTransformType;
|
||||
}
|
||||
BlendType GetLayerBlenType() const
|
||||
{
|
||||
return mBlendType;
|
||||
}
|
||||
CompositionType GetCompositionType() const
|
||||
{
|
||||
return mCompositionType;
|
||||
}
|
||||
void SetDeviceSelect(CompositionType type)
|
||||
{
|
||||
DISPLAY_LOGD("%{public}d", type);
|
||||
mDeviceSelect = type;
|
||||
}
|
||||
CompositionType GetDeviceSelect() const
|
||||
{
|
||||
return mDeviceSelect;
|
||||
}
|
||||
|
||||
int GetAcquireFenceFd()
|
||||
{
|
||||
return mAcquireFence.GetFd();
|
||||
}
|
||||
|
||||
int GetReleaseFenceFd()
|
||||
{
|
||||
return mReleaseFence.GetFd();
|
||||
}
|
||||
|
||||
bool IsVisible()
|
||||
{
|
||||
return mVisible;
|
||||
}
|
||||
|
||||
void SetReleaseFence(int fd)
|
||||
{
|
||||
mReleaseFence = fd;
|
||||
};
|
||||
void ClearColor(uint32_t color);
|
||||
|
||||
void SetPixel(const BufferHandle &handle, int x, int y, uint32_t color);
|
||||
|
||||
virtual int32_t SetLayerSize(IRect *rect);
|
||||
virtual int32_t SetLayerCrop(IRect *rect);
|
||||
virtual void SetLayerZorder(uint32_t zorder);
|
||||
virtual int32_t SetLayerPreMulti(bool preMul);
|
||||
virtual int32_t SetLayerAlpha(LayerAlpha *alpha);
|
||||
virtual int32_t SetTransformMode(TransformType type);
|
||||
virtual int32_t SetLayerDirtyRegion(IRect *region);
|
||||
virtual int32_t SetLayerVisibleRegion(uint32_t num, IRect *rect);
|
||||
virtual int32_t SetLayerBuffer(const BufferHandle *buffer, int32_t fence);
|
||||
virtual int32_t SetLayerCompositionType(CompositionType type);
|
||||
virtual int32_t SetLayerBlendType(BlendType type);
|
||||
virtual int32_t SetLayerVisible(bool visible);
|
||||
virtual HdiLayerBuffer *GetCurrentBuffer()
|
||||
{
|
||||
return mHdiBuffer.get();
|
||||
}
|
||||
virtual ~HdiLayer() {}
|
||||
|
||||
private:
|
||||
static uint32_t GetIdleId();
|
||||
static uint32_t mIdleId;
|
||||
static std::unordered_set<uint32_t> mIdSets;
|
||||
bool mVisible = true;
|
||||
uint32_t mId = 0;
|
||||
HdiFd mAcquireFence;
|
||||
HdiFd mReleaseFence;
|
||||
LayerType mType;
|
||||
|
||||
IRect mDisplayRect;
|
||||
IRect mCrop;
|
||||
uint32_t mZorder = -1;
|
||||
bool mPreMul = false;
|
||||
LayerAlpha mAlpha;
|
||||
TransformType mTransformType;
|
||||
CompositionType mCompositionType = COMPOSITION_CLIENT;
|
||||
CompositionType mDeviceSelect = COMPOSITION_CLIENT;
|
||||
BlendType mBlendType;
|
||||
std::unique_ptr<HdiLayerBuffer> mHdiBuffer;
|
||||
};
|
||||
|
||||
struct SortLayersByZ {
|
||||
bool operator () (const HdiLayer *lhs, const HdiLayer *rhs) const
|
||||
{
|
||||
if (lhs == nullptr || rhs == nullptr) {
|
||||
return (lhs == nullptr) && (rhs == nullptr);
|
||||
}
|
||||
return lhs->GetZorder() < rhs->GetZorder();
|
||||
}
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_LAYER_H
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "hdi_netlink_monitor.h"
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
HdiNetLinkMonitor::HdiNetLinkMonitor()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
}
|
||||
|
||||
int HdiNetLinkMonitor::Init()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
int fd;
|
||||
struct sockaddr_nl snl = { 0 };
|
||||
int ret;
|
||||
const int32_t bufferSize = 1024;
|
||||
DISPLAY_CHK_RETURN((mScoketFd < 0), DISPLAY_FAILURE, DISPLAY_LOGE("the socket has initial"));
|
||||
fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
|
||||
DISPLAY_CHK_RETURN((fd < 0), DISPLAY_FAILURE, DISPLAY_LOGE("scoket create failed"));
|
||||
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize));
|
||||
ret = bind(fd, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl));
|
||||
DISPLAY_CHK_RETURN((ret < 0), DISPLAY_FAILURE, DISPLAY_LOGE("bind failed errno : %{public}d", errno));
|
||||
|
||||
mThread = std::make_unique<std::thread>([this]() {
|
||||
mRunning = true;
|
||||
MonitorThread();
|
||||
});
|
||||
mScoketFd = fd;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
HdiNetLinkMonitor::~HdiNetLinkMonitor()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
if (mScoketFd >= 0) {
|
||||
close(mScoketFd);
|
||||
}
|
||||
}
|
||||
|
||||
Void HdiNetLinkMonitor::MonitorThread()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
constexpr int BUFFER_SIZE = UEVENT_BUFFER_SIZE * 2;
|
||||
while (mRunning) {
|
||||
char buf[BUFFER_SIZE] = { 0 };
|
||||
recv(mScoketFd, &buf, sizeof(buf), 0);
|
||||
}
|
||||
}
|
||||
} // DISPLAY
|
||||
} // HDI
|
||||
} // OHOS
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_NETLINK_NONITOR_H
|
||||
#define HDI_NETLINK_NONITOR_H
|
||||
#include <thread>
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class HdiNetLinkMonitor {
|
||||
public:
|
||||
HdiNetLinkMonitor();
|
||||
int Init();
|
||||
virtual ~HdiNetLinkMonitor();
|
||||
|
||||
private:
|
||||
Void MonitorThread();
|
||||
volatile bool mRunning = false;
|
||||
int mScoketFd = -1;
|
||||
std::unique_ptr<std::thread> mThread;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_NETLINK_NONITOR_H
|
||||
@@ -0,0 +1,399 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include <hdi_session.h>
|
||||
#include <errno.h>
|
||||
#include <mutex>
|
||||
#include "display_common.h"
|
||||
#include "display_device.h"
|
||||
#include "display_layer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
HdiSession &HdiSession::GetInstance()
|
||||
{
|
||||
static HdiSession instance;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&]() { instance.Init(); });
|
||||
return instance;
|
||||
}
|
||||
|
||||
void HdiSession::Init()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
mHdiDevices = HdiDeviceInterface::DiscoveryDevice();
|
||||
DISPLAY_LOGD("devices size %{public}zd", mHdiDevices.size());
|
||||
mHdiDisplays.clear();
|
||||
for (auto device : mHdiDevices) {
|
||||
auto displays = device->DiscoveryDisplay();
|
||||
mHdiDisplays.insert(displays.begin(), displays.end());
|
||||
}
|
||||
}
|
||||
|
||||
int32_t HdiSession::RegHotPlugCallback(HotPlugCallback callback, void *data)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((callback == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("the callback is nullptr"));
|
||||
mHotPlugCallBacks.emplace(callback, data);
|
||||
for (auto displayMap : mHdiDisplays) {
|
||||
auto display = displayMap.second;
|
||||
if (display->IsConnected()) {
|
||||
DoHotPlugCallback(display->GetId(), true);
|
||||
}
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
void HdiSession::DoHotPlugCallback(uint32_t devId, bool connect)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
for (const auto &callback : mHotPlugCallBacks) {
|
||||
callback.first(devId, connect, callback.second);
|
||||
}
|
||||
}
|
||||
} // OHOS
|
||||
} // HDI
|
||||
} // DISPLAY
|
||||
|
||||
using namespace OHOS::HDI::DISPLAY;
|
||||
static int32_t RegHotPlugCallback(HotPlugCallback callback, void *data)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
HdiSession::GetInstance().RegHotPlugCallback(callback, data);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetDisplayCapability(uint32_t devId, DisplayCapability *info)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN(info == nullptr, DISPLAY_NULL_PTR, DISPLAY_LOGE("info is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::GetDisplayCapability, info);
|
||||
}
|
||||
|
||||
static int32_t GetDisplaySupportedModes(uint32_t devId, uint32_t *num, DisplayModeInfo *modes)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN(num == nullptr, DISPLAY_NULL_PTR, DISPLAY_LOGE("num is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::GetDisplaySuppportedModes, num, modes);
|
||||
}
|
||||
|
||||
static int32_t GetDisplayMode(uint32_t devId, uint32_t *mode)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((mode == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("mode is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::GetDisplayMode, mode);
|
||||
}
|
||||
|
||||
static int32_t SetDisplayMode(uint32_t devId, uint32_t mode)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::SetDisplayMode, mode);
|
||||
}
|
||||
|
||||
static int32_t GetDisplayPowerStatus(uint32_t devId, DispPowerStatus *status)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((status == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("status is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::GetDisplayPowerStatus, status);
|
||||
}
|
||||
|
||||
static int32_t SetDisplayPowerStatus(uint32_t devId, DispPowerStatus status)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::SetDisplayPowerStatus, status);
|
||||
}
|
||||
|
||||
static int32_t GetDisplayBacklight(uint32_t devId, uint32_t *value)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((value == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("value is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::GetDisplayBacklight, value);
|
||||
}
|
||||
|
||||
static int32_t SetDisplayBacklight(uint32_t devId, uint32_t value)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::SetDisplayBacklight, value);
|
||||
}
|
||||
|
||||
static int32_t GetDisplayProperty(uint32_t devId, uint32_t id, uint64_t *value)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
(void)id;
|
||||
DISPLAY_CHK_RETURN((value == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("value is nullptr"));
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
static int32_t SetDisplayProperty(uint32_t devId, uint32_t id, uint64_t value)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
(void)id;
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
static int32_t PrepareDisplayLayers(uint32_t devId, bool *needFlushFb)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((needFlushFb == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("needFlushFb is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::PrepareDisplayLayers, needFlushFb);
|
||||
}
|
||||
|
||||
static int32_t GetDisplayCompChange(uint32_t devId, uint32_t *num, uint32_t *layers, int32_t *type)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((num == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("num is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::GetDisplayCompChange, num, layers, type);
|
||||
}
|
||||
|
||||
static int32_t SetDisplayClientCrop(uint32_t devId, IRect *rect)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((rect == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("rect is nullptr"));
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
static int32_t SetDisplayClientDestRect(uint32_t devId, IRect *rect)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((rect == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("rect is nullptr"));
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
static int32_t SetDisplayClientBuffer(uint32_t devId, const BufferHandle *buffer, int32_t fence)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::SetDisplayClientBuffer, buffer, fence);
|
||||
}
|
||||
|
||||
static int32_t SetDisplayClientDamage(uint32_t devId, uint32_t num, IRect *rect)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
(void)num;
|
||||
DISPLAY_CHK_RETURN((rect == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("rect is nullptr"));
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
static int32_t SetDisplayVsyncEnabled(uint32_t devId, bool enabled)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::SetDisplayVsyncEnabled, enabled);
|
||||
}
|
||||
|
||||
static int32_t RegDisplayVBlankCallback(uint32_t devId, VBlankCallback callback, void *data)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::RegDisplayVBlankCallback, callback, data);
|
||||
}
|
||||
|
||||
static int32_t GetDisplayReleaseFence(uint32_t devId, uint32_t *num, uint32_t *layers, int32_t *fences)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::GetDisplayReleaseFence, num, layers,
|
||||
fences);
|
||||
}
|
||||
|
||||
static int32_t Commit(uint32_t devId, int32_t *fence)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((fence == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("fence is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::Commit, fence);
|
||||
}
|
||||
|
||||
static int32_t CreateVirtualDisplay(uint32_t width, uint32_t height, int32_t *format, uint32_t *devId)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
static int32_t DestroyVirtualDisplay(uint32_t devId)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
static int32_t SetVirtualDisplayBuffer(uint32_t devId, BufferHandle *buffer, int32_t releaseFence)
|
||||
{
|
||||
// DISPLAY_LOGD();
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
|
||||
// Layer function
|
||||
static int32_t CreateLayer(uint32_t devId, const LayerInfo *layerInfo, uint32_t *layerId)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((layerId == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("layerId is nullptr"));
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::CreateLayer, layerInfo, layerId);
|
||||
}
|
||||
|
||||
static int32_t CloseLayer(uint32_t devId, uint32_t layerId)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::CloseLayer, layerId);
|
||||
}
|
||||
|
||||
static int32_t SetLayerSize(uint32_t devId, uint32_t layerId, IRect *rect)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((rect == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("rect is nullptr"));
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerSize, rect);
|
||||
}
|
||||
|
||||
static int32_t SetLayerCrop(uint32_t devId, uint32_t layerId, IRect *rect)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((rect == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("rect is nullptr"));
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerCrop, rect);
|
||||
}
|
||||
|
||||
static int32_t SetLayerZorder(uint32_t devId, uint32_t layerId, uint32_t zorder)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallDisplayFunction(devId, &HdiDisplay::SetLayerZorder, layerId, zorder);
|
||||
}
|
||||
|
||||
static int32_t SetLayerPreMulti(uint32_t devId, uint32_t layerId, bool preMul)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerPreMulti, preMul);
|
||||
}
|
||||
|
||||
static int32_t SetLayerAlpha(uint32_t devId, uint32_t layerId, LayerAlpha *alpha)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((alpha == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("alpha is nullptr"));
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerAlpha, alpha);
|
||||
}
|
||||
|
||||
static int32_t SetTransformMode(uint32_t devId, uint32_t layerId, TransformType type)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetTransformMode, type);
|
||||
}
|
||||
|
||||
static int32_t SetLayerDirtyRegion(uint32_t devId, uint32_t layerId, IRect *region)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((region == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("region is nullptr"));
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerDirtyRegion, region);
|
||||
}
|
||||
|
||||
static int32_t SetLayerVisibleRegion(uint32_t devId, uint32_t layerId, uint32_t num, IRect *rect)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((rect == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("rect is nullptr"));
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerVisibleRegion, num, rect);
|
||||
}
|
||||
|
||||
static int32_t SetLayerBuffer(uint32_t devId, uint32_t layerId, const BufferHandle *buffer, int32_t fence)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerBuffer, buffer, fence);
|
||||
}
|
||||
|
||||
static int32_t SetLayerCompositionType(uint32_t devId, uint32_t layerId, CompositionType type)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerCompositionType, type);
|
||||
}
|
||||
|
||||
static int32_t SetLayerBlendType(uint32_t devId, uint32_t layerId, BlendType type)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerBlendType, type);
|
||||
}
|
||||
|
||||
static int32_t SetLayerVisible(uint32_t devId, uint32_t layerId, bool visible)
|
||||
{
|
||||
//DISPLAY_LOGD();
|
||||
return HdiSession::GetInstance().CallLayerFunction(devId, layerId, &HdiLayer::SetLayerVisible, visible);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
int32_t DeviceInitialize(DeviceFuncs **funcs)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((funcs == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("in funcs is null"));
|
||||
DeviceFuncs *dFuncs = (DeviceFuncs *)calloc(1, sizeof(DeviceFuncs));
|
||||
DISPLAY_CHK_RETURN((dFuncs == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("can not calloc"));
|
||||
|
||||
dFuncs->RegHotPlugCallback = RegHotPlugCallback;
|
||||
dFuncs->GetDisplayCapability = GetDisplayCapability;
|
||||
dFuncs->GetDisplaySupportedModes = GetDisplaySupportedModes;
|
||||
dFuncs->GetDisplayMode = GetDisplayMode;
|
||||
dFuncs->SetDisplayMode = SetDisplayMode;
|
||||
dFuncs->GetDisplayPowerStatus = GetDisplayPowerStatus;
|
||||
dFuncs->SetDisplayPowerStatus = SetDisplayPowerStatus;
|
||||
dFuncs->PrepareDisplayLayers = PrepareDisplayLayers;
|
||||
dFuncs->GetDisplayBacklight = GetDisplayBacklight;
|
||||
dFuncs->SetDisplayBacklight = SetDisplayBacklight;
|
||||
dFuncs->GetDisplayProperty = GetDisplayProperty;
|
||||
dFuncs->GetDisplayCompChange = GetDisplayCompChange;
|
||||
dFuncs->SetDisplayClientCrop = SetDisplayClientCrop;
|
||||
dFuncs->SetDisplayClientDestRect = SetDisplayClientDestRect;
|
||||
dFuncs->SetDisplayClientBuffer = SetDisplayClientBuffer;
|
||||
dFuncs->SetDisplayClientDamage = SetDisplayClientDamage;
|
||||
dFuncs->SetDisplayVsyncEnabled = SetDisplayVsyncEnabled;
|
||||
dFuncs->RegDisplayVBlankCallback = RegDisplayVBlankCallback;
|
||||
dFuncs->GetDisplayReleaseFence = GetDisplayReleaseFence;
|
||||
dFuncs->CreateVirtualDisplay = CreateVirtualDisplay;
|
||||
dFuncs->DestroyVirtualDisplay = DestroyVirtualDisplay;
|
||||
dFuncs->SetVirtualDisplayBuffer = SetVirtualDisplayBuffer;
|
||||
dFuncs->SetDisplayProperty = SetDisplayProperty;
|
||||
dFuncs->Commit = Commit;
|
||||
*funcs = dFuncs;
|
||||
|
||||
HdiSession::GetInstance();
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DeviceUninitialize(DeviceFuncs *funcs)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((funcs == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("in funcs is null"));
|
||||
free(funcs);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t LayerInitialize(LayerFuncs **funcs)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((funcs == nullptr), DISPLAY_NULL_PTR, DISPLAY_LOGE("the in funcs is nullptr"));
|
||||
LayerFuncs *lFuncs = (LayerFuncs *)calloc(1, sizeof(LayerFuncs));
|
||||
DISPLAY_CHK_RETURN((lFuncs == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("can not calloc errno: %{public}d", errno));
|
||||
lFuncs->SetLayerAlpha = SetLayerAlpha;
|
||||
lFuncs->CreateLayer = CreateLayer;
|
||||
lFuncs->CloseLayer = CloseLayer;
|
||||
lFuncs->SetLayerSize = SetLayerSize;
|
||||
lFuncs->SetLayerCrop = SetLayerCrop;
|
||||
lFuncs->SetLayerZorder = SetLayerZorder;
|
||||
lFuncs->SetLayerPreMulti = SetLayerPreMulti;
|
||||
lFuncs->SetTransformMode = SetTransformMode;
|
||||
lFuncs->SetLayerDirtyRegion = SetLayerDirtyRegion;
|
||||
lFuncs->SetLayerVisibleRegion = SetLayerVisibleRegion;
|
||||
lFuncs->SetLayerBuffer = SetLayerBuffer;
|
||||
lFuncs->SetLayerCompositionType = SetLayerCompositionType;
|
||||
lFuncs->SetLayerBlendType = SetLayerBlendType;
|
||||
lFuncs->SetLayerVisible = SetLayerVisible;
|
||||
|
||||
*funcs = lFuncs;
|
||||
DISPLAY_LOGD("layer initialize success");
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t LayerUninitialize(LayerFuncs *funcs)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((funcs == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("the funcs is nullptr"));
|
||||
free(funcs);
|
||||
DISPLAY_LOGD(" layer uninitialize success");
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_SESSION_H
|
||||
#define HDI_SESSION_H
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "display_device.h"
|
||||
#include "hdi_device_interface.h"
|
||||
#include "hdi_display.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class HdiSession {
|
||||
public:
|
||||
void Init();
|
||||
static HdiSession &GetInstance();
|
||||
|
||||
template<typename... Args>
|
||||
int32_t CallDisplayFunction(uint32_t devId, int32_t (HdiDisplay::*member)(Args...), Args... args)
|
||||
{
|
||||
DISPLAY_LOGD("device Id : %{public}d", devId);
|
||||
DISPLAY_CHK_RETURN((devId == INVALIDE_DISPLAY_ID), DISPLAY_FAILURE, DISPLAY_LOGE("invalide device id"));
|
||||
auto iter = mHdiDisplays.find(devId);
|
||||
DISPLAY_CHK_RETURN((iter == mHdiDisplays.end()), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not find display %{public}d", devId));
|
||||
auto display = iter->second.get();
|
||||
return (display->*member)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
int32_t CallLayerFunction(uint32_t devId, uint32_t layerId, int32_t (HdiLayer::*member)(Args...), Args... args)
|
||||
{
|
||||
DISPLAY_LOGD("device Id : %{public}d", devId);
|
||||
DISPLAY_CHK_RETURN((devId == INVALIDE_DISPLAY_ID), DISPLAY_FAILURE, DISPLAY_LOGE("invalide device id"));
|
||||
auto iter = mHdiDisplays.find(devId);
|
||||
DISPLAY_CHK_RETURN((iter == mHdiDisplays.end()), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not find display %{public}d", devId));
|
||||
auto display = iter->second.get();
|
||||
auto layer = display->GetHdiLayer(layerId);
|
||||
DISPLAY_CHK_RETURN((layer == nullptr), DISPLAY_FAILURE,
|
||||
DISPLAY_LOGE("can not find the layer %{public}d", layerId));
|
||||
return (layer->*member)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
int32_t RegHotPlugCallback(HotPlugCallback callback, void *data);
|
||||
void DoHotPlugCallback(uint32_t devId, bool connect);
|
||||
|
||||
private:
|
||||
std::unordered_map<uint32_t, std::shared_ptr<HdiDisplay>> mHdiDisplays;
|
||||
std::vector<std::shared_ptr<HdiDeviceInterface>> mHdiDevices;
|
||||
std::unordered_map<HotPlugCallback, void *> mHotPlugCallBacks;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace HDI
|
||||
} // namespace DISPLAY
|
||||
|
||||
#endif // HDI_SESSION_H
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HDI_SHARED_FD
|
||||
#define HDI_SHARED_FD
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include "display_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace DISPLAY {
|
||||
class HdiFd {
|
||||
public:
|
||||
HdiFd()
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
}
|
||||
explicit HdiFd(int fd) : mFd(fd)
|
||||
{
|
||||
DISPLAY_LOGD("mFd %{public}d", mFd);
|
||||
}
|
||||
int GetFd() const
|
||||
{
|
||||
return mFd;
|
||||
};
|
||||
|
||||
HdiFd &operator = (int fd)
|
||||
{
|
||||
if (mFd >= 0) {
|
||||
close(mFd);
|
||||
}
|
||||
mFd = fd;
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~HdiFd()
|
||||
{
|
||||
if (mFd >= 0) {
|
||||
close(mFd);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int mFd = -1;
|
||||
};
|
||||
|
||||
using FdPtr = std::shared_ptr<HdiFd>;
|
||||
} // OHOS
|
||||
} // HDIO
|
||||
} // DISPLAY
|
||||
|
||||
#endif // HDI_SHARED_FD
|
||||
+515
@@ -0,0 +1,515 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Rockchip Electronics 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "im2d.h"
|
||||
#include "rga.h"
|
||||
#include "display_common.h"
|
||||
#include "display_gralloc.h"
|
||||
#include "securec.h"
|
||||
#include "display_gfx.h"
|
||||
|
||||
#define ALIGN_UP(x, a) ((((x) + ((a)-1)) / (a)) * (a))
|
||||
GrallocFuncs *grallocFucs = NULL;
|
||||
int32_t rkInitGfx()
|
||||
{
|
||||
DISPLAY_LOGE("%s\n", querystring(RGA_ALL));
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t rkDeinitGfx()
|
||||
{
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
RgaSURF_FORMAT colorSpaceModeChange(PixelFormat color, uint8_t *isYuv)
|
||||
{
|
||||
RgaSURF_FORMAT rkFormat;
|
||||
switch(color) {
|
||||
case PIXEL_FMT_RGB_565: /**< RGB565 format */
|
||||
rkFormat = RK_FORMAT_RGB_565;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_RGBA_4444: /**< RGBA4444 format */
|
||||
rkFormat = RK_FORMAT_RGBA_4444;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_RGBA_5551: /**< RGBA5551 format */
|
||||
rkFormat = RK_FORMAT_RGBA_5551;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_RGBX_8888: /**< RGBX8888 format */
|
||||
rkFormat = RK_FORMAT_RGBX_8888;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_RGBA_8888: /**< RGBA8888 format */
|
||||
rkFormat = RK_FORMAT_RGBA_8888;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_RGB_888: /**< RGB888 format */
|
||||
rkFormat = RK_FORMAT_RGB_888;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_BGR_565: /**< BGR565 format */
|
||||
rkFormat = RK_FORMAT_BGR_565;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_BGRA_4444: /**< BGRA4444 format */
|
||||
rkFormat = RK_FORMAT_BGRA_4444;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_BGRA_5551: /**< BGRA5551 format */
|
||||
rkFormat = RK_FORMAT_BGRA_5551;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_BGRX_8888: /**< BGRX8888 format */
|
||||
rkFormat = RK_FORMAT_BGRX_8888;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_BGRA_8888: /**< BGRA8888 format */
|
||||
rkFormat = RK_FORMAT_BGRA_8888;
|
||||
*isYuv = 0;
|
||||
break;
|
||||
case PIXEL_FMT_YCBCR_422_SP: /**< YCBCR422 semi-planar format */
|
||||
rkFormat = RK_FORMAT_YCbCr_420_SP;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YCRCB_422_SP: /**< YCRCB422 semi-planar format */
|
||||
rkFormat = RK_FORMAT_YCrCb_422_SP;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YCBCR_420_SP: /**< YCBCR420 semi-planar format */
|
||||
rkFormat = RK_FORMAT_YCbCr_420_SP;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YCRCB_420_SP: /**< YCRCB420 semi-planar format */
|
||||
rkFormat = RK_FORMAT_YCrCb_420_SP;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YCBCR_422_P: /**< YCBCR422 planar format */
|
||||
rkFormat = RK_FORMAT_YCbCr_422_P;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YCRCB_422_P: /**< YCRCB422 planar format */
|
||||
rkFormat = RK_FORMAT_YCrCb_422_P;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YCBCR_420_P: /**< YCBCR420 planar format */
|
||||
rkFormat = RK_FORMAT_YCbCr_420_P;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YCRCB_420_P: /**< YCRCB420 planar format */
|
||||
rkFormat = RK_FORMAT_YCrCb_420_P;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YUYV_422_PKG: /**< YUYV422 packed format */
|
||||
rkFormat = RK_FORMAT_YUYV_422;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_UYVY_422_PKG: /**< UYVY422 packed format */
|
||||
rkFormat = RK_FORMAT_UYVY_422;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_YVYU_422_PKG: /**< YVYU422 packed format */
|
||||
rkFormat = RK_FORMAT_YUYV_422;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
case PIXEL_FMT_VYUY_422_PKG: /**< VYUY422 packed format */
|
||||
rkFormat = RK_FORMAT_VYUY_422;
|
||||
*isYuv = 1;
|
||||
break;
|
||||
default:
|
||||
// PIXEL_FMT_CLUT8: /**< CLUT8 format */
|
||||
// PIXEL_FMT_CLUT1, /**< CLUT1 format */
|
||||
// PIXEL_FMT_CLUT4, /**< CLUT4 format */
|
||||
// PIXEL_FMT_RGBA_5658, /**< RGBA5658 format */
|
||||
// PIXEL_FMT_RGBX_4444, /**< RGBX4444 format */
|
||||
// PIXEL_FMT_RGB_444, /**< RGB444 format */
|
||||
// PIXEL_FMT_RGBX_5551, /**< RGBX5551 format */
|
||||
// PIXEL_FMT_RGB_555, /**< RGB555 format */
|
||||
// PIXEL_FMT_BGRX_4444, /**< BGRX4444 format */
|
||||
// PIXEL_FMT_BGRX_5551, /**< BGRX5551 format */
|
||||
// PIXEL_FMT_YUV_422_I, /**< YUV422 interleaved format */
|
||||
rkFormat = RK_FORMAT_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
return rkFormat;
|
||||
}
|
||||
|
||||
int32_t rkFillRect(ISurface *iSurface, IRect *rect, uint32_t color, GfxOpt *opt)
|
||||
{
|
||||
rga_buffer_t dst;
|
||||
im_rect imRect;
|
||||
IM_STATUS ret;
|
||||
uint8_t isYuv;
|
||||
|
||||
errno_t eok = memset_s((void *)&imRect, sizeof(imRect), 0, sizeof(imRect));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
imRect.x = rect->x;
|
||||
imRect.y = rect->y;
|
||||
imRect.width = rect->w;
|
||||
imRect.height = rect->h;
|
||||
|
||||
eok = memset_s((void *)&dst, sizeof(dst), 0, sizeof(dst));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
dst.phy_addr = 0; // (void*)iSurface->phyAddr;
|
||||
dst.vir_addr = 0; // iSurface->virAddr;
|
||||
dst.fd = (int32_t)iSurface->phyAddr;
|
||||
if ((int)dst.phy_addr == 0 && dst.fd == 0 && dst.vir_addr == NULL) {
|
||||
DISPLAY_LOGE("source iSurface address error");
|
||||
return DISPLAY_PARAM_ERR;
|
||||
}
|
||||
DISPLAY_LOGE("gfx vir %{public}p phy 0x%{public}x fd %{public}d",dst.vir_addr, (int32_t)dst.phy_addr, dst.fd);
|
||||
dst.width = iSurface->width;
|
||||
dst.height = iSurface->height;
|
||||
dst.wstride = ALIGN_UP(iSurface->width, 16);
|
||||
dst.hstride = ALIGN_UP(iSurface->height, 16);
|
||||
dst.format = colorSpaceModeChange(iSurface->enColorFmt, &isYuv);
|
||||
dst.color_space_mode = IM_COLOR_SPACE_DEFAULT;
|
||||
dst.color = color;
|
||||
if (opt->enGlobalAlpha)
|
||||
dst.global_alpha = opt->globalAlpha;
|
||||
ret = imfill(dst, imRect, color);
|
||||
|
||||
if (ret != IM_STATUS_SUCCESS)
|
||||
return DISPLAY_FAILURE;
|
||||
else
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t blendTypeChange(BlendType blendType)
|
||||
{
|
||||
int32_t rkBlendType;
|
||||
switch(blendType) {
|
||||
case BLEND_SRC: /**< SRC blending */
|
||||
rkBlendType = IM_ALPHA_BLEND_SRC;
|
||||
break;
|
||||
case BLEND_DST: /**< SRC blending */
|
||||
rkBlendType = IM_ALPHA_BLEND_DST;
|
||||
break;
|
||||
case BLEND_SRCOVER: /**< SRC_OVER blending */
|
||||
rkBlendType = IM_ALPHA_BLEND_SRC_OVER;
|
||||
break;
|
||||
case BLEND_DSTOVER: /**< DST_OVER blending */
|
||||
rkBlendType = IM_ALPHA_BLEND_DST_OVER;
|
||||
break;
|
||||
default:
|
||||
/* Fix up later */
|
||||
// BLEND_NONE /**< No blending */
|
||||
// BLEND_CLEAR: /**< CLEAR blending */
|
||||
// BLEND_SRCIN: /**< SRC_IN blending */
|
||||
// BLEND_DSTIN: /**< DST_IN blending */
|
||||
// BLEND_SRCOUT: /**< SRC_OUT blending */
|
||||
// BLEND_DSTOUT: /**< DST_OUT blending */
|
||||
// BLEND_SRCATOP: /**< SRC_ATOP blending */
|
||||
// BLEND_DSTATOP: /**< DST_ATOP blending */
|
||||
// BLEND_ADD: /**< ADD blending */
|
||||
// BLEND_XOR: /**< XOR blending */
|
||||
// BLEND_DST: /**< DST blending */
|
||||
// BLEND_AKS: /**< AKS blending */
|
||||
// BLEND_AKD: /**< AKD blending */
|
||||
// BLEND_BUTT: /**< Null operation */
|
||||
rkBlendType = IM_STATUS_NOT_SUPPORTED;
|
||||
break;
|
||||
}
|
||||
return rkBlendType;
|
||||
}
|
||||
|
||||
int32_t TransformTypeChange(TransformType type)
|
||||
{
|
||||
int32_t rkRotateType;
|
||||
switch(type) {
|
||||
case ROTATE_90: /**< Rotation by 90 degrees */
|
||||
rkRotateType = IM_HAL_TRANSFORM_ROT_90;
|
||||
break;
|
||||
case ROTATE_180: /**< Rotation by 180 degrees */
|
||||
rkRotateType = IM_HAL_TRANSFORM_ROT_180;
|
||||
break;
|
||||
case ROTATE_270: /**< Rotation by 270 degrees */
|
||||
rkRotateType = IM_HAL_TRANSFORM_ROT_270;
|
||||
break;
|
||||
default:
|
||||
rkRotateType = 0; /**< No rotation */
|
||||
break;
|
||||
}
|
||||
return rkRotateType;
|
||||
}
|
||||
|
||||
int32_t mirrorTypeChange(MirrorType type)
|
||||
{
|
||||
int32_t rkMirrorType;
|
||||
switch(type) {
|
||||
case MIRROR_LR: /**< Left and right mirrors */
|
||||
rkMirrorType = IM_HAL_TRANSFORM_FLIP_H;
|
||||
break;
|
||||
case MIRROR_TB: /**< Top and bottom mirrors */
|
||||
rkMirrorType = IM_HAL_TRANSFORM_FLIP_V;
|
||||
break;
|
||||
default:
|
||||
rkMirrorType = 0;
|
||||
break;
|
||||
}
|
||||
return rkMirrorType;
|
||||
}
|
||||
|
||||
int32_t doFlit(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt)
|
||||
{
|
||||
int32_t usage = 0;
|
||||
uint8_t isYuv = 0;
|
||||
rga_buffer_t dstRgaBuffer, srcRgaBuffer, bRgbBuffer;
|
||||
IM_STATUS ret = 0;
|
||||
im_rect srect;
|
||||
im_rect drect;
|
||||
im_rect prect;
|
||||
int32_t rkBlendType = 0;
|
||||
int32_t rkRotateType = 0;
|
||||
int32_t rkMirrorType = 0;
|
||||
|
||||
errno_t eok = memset_s(&dstRgaBuffer, sizeof(dstRgaBuffer), 0, sizeof(dstRgaBuffer));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
eok = memset_s(&srcRgaBuffer, sizeof(srcRgaBuffer), 0, sizeof(srcRgaBuffer));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
eok = memset_s(&bRgbBuffer, sizeof(bRgbBuffer), 0, sizeof(bRgbBuffer));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
eok = memset_s(&srect, sizeof(srect), 0, sizeof(srect));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
eok = memset_s(&drect, sizeof(drect), 0, sizeof(drect));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
eok = memset_s(&prect, sizeof(prect), 0, sizeof(prect));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
if (opt->enGlobalAlpha) {
|
||||
dstRgaBuffer.global_alpha = opt->globalAlpha;
|
||||
srcRgaBuffer.global_alpha = opt->globalAlpha;
|
||||
}
|
||||
dstRgaBuffer.width = dstSurface->width;
|
||||
dstRgaBuffer.height = dstSurface->height;
|
||||
dstRgaBuffer.wstride = ALIGN_UP(dstSurface->width, 16);
|
||||
dstRgaBuffer.hstride = ALIGN_UP(dstSurface->height, 16);
|
||||
dstRgaBuffer.format = colorSpaceModeChange(dstSurface->enColorFmt, &isYuv);
|
||||
dstRgaBuffer.phy_addr = 0; // (void *)dstSurface->phyAddr;
|
||||
dstRgaBuffer.vir_addr = 0; // dstSurface->virAddr;
|
||||
dstRgaBuffer.color_space_mode = IM_COLOR_SPACE_DEFAULT;
|
||||
dstRgaBuffer.fd = (int32_t)dstSurface->phyAddr;
|
||||
if (isYuv == 1) {
|
||||
DISPLAY_LOGE("rk gfx do not support dst buffer is yuv format");
|
||||
return DISPLAY_PARAM_ERR;
|
||||
}
|
||||
|
||||
srcRgaBuffer.width = srcSurface->width;
|
||||
srcRgaBuffer.height = srcSurface->height;
|
||||
srcRgaBuffer.wstride = ALIGN_UP(srcSurface->width, 16);
|
||||
srcRgaBuffer.hstride = ALIGN_UP(srcSurface->height, 16);
|
||||
srcRgaBuffer.phy_addr = 0; // (void *)srcSurface->phyAddr;
|
||||
srcRgaBuffer.vir_addr = 0; // srcSurface->virAddr;
|
||||
srcRgaBuffer.format = colorSpaceModeChange(srcSurface->enColorFmt, &isYuv);
|
||||
srcRgaBuffer.color_space_mode = IM_COLOR_SPACE_DEFAULT;
|
||||
srcRgaBuffer.fd = (int32_t)srcSurface->phyAddr;
|
||||
|
||||
if ((int)srcRgaBuffer.phy_addr == 0 && srcRgaBuffer.fd == 0 && srcRgaBuffer.vir_addr == NULL) {
|
||||
DISPLAY_LOGE("source iSurface address error");
|
||||
return DISPLAY_PARAM_ERR;
|
||||
}
|
||||
|
||||
DISPLAY_LOGE("gfx src fd %{public}d, w %{public}d, h %{publuc}d, sw %{public}d sh %{public}d vir %{public}p",
|
||||
(int32_t)srcSurface->phyAddr, srcSurface->width, srcSurface->height, ALIGN_UP(srcSurface->width, 16),
|
||||
ALIGN_UP(srcSurface->height, 16), srcRgaBuffer.vir_addr);
|
||||
DISPLAY_LOGE("gfx dst fd %{public}d, w %{public}d, h %{public}d, sw %{public}d sh %{public}d vir %{public}p",
|
||||
(int32_t)dstSurface->phyAddr, dstSurface->width, dstSurface->height, ALIGN_UP(dstSurface->width, 16),
|
||||
ALIGN_UP(dstSurface->height, 16), dstRgaBuffer.vir_addr);
|
||||
|
||||
srect.x = srcRect->x;
|
||||
srect.y = srcRect->y;
|
||||
srect.height = srcRect->h;
|
||||
srect.width = srcRect->w;
|
||||
drect.x = dstRect->x;
|
||||
drect.y = dstRect->y;
|
||||
drect.height = dstRect->h;
|
||||
drect.width = dstRect->w;
|
||||
|
||||
if (opt->blendType) {
|
||||
rkBlendType = blendTypeChange(opt->blendType);
|
||||
if (rkBlendType > 0) {
|
||||
usage |= rkBlendType;
|
||||
if (rkBlendType == IM_ALPHA_BLEND_DST_OVER || rkBlendType == IM_ALPHA_BLEND_SRC_OVER)
|
||||
usage |= IM_ALPHA_BLEND_PRE_MUL;
|
||||
} else if (rkBlendType == IM_STATUS_NOT_SUPPORTED) {
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
}
|
||||
if (opt->rotateType) {
|
||||
rkRotateType = TransformTypeChange(opt->rotateType);
|
||||
if (rkRotateType != 0)
|
||||
usage |= rkRotateType;
|
||||
}
|
||||
if (opt->mirrorType == MIRROR_LR || opt->mirrorType == MIRROR_TB) {
|
||||
rkMirrorType = mirrorTypeChange(opt->mirrorType);
|
||||
if (rkMirrorType != 0)
|
||||
usage |= rkMirrorType;
|
||||
}
|
||||
if (opt->enableScale) {
|
||||
DISPLAY_LOGE("gfx scale from (%{puhblic}d, %{public}d) to (%{public}d, %{public}d)", srcRgaBuffer.width, srcRgaBuffer.height, dstRgaBuffer.width,
|
||||
dstRgaBuffer.height);
|
||||
}
|
||||
usage |= IM_SYNC;
|
||||
if (isYuv == 1) {
|
||||
if (rkBlendType == IM_ALPHA_BLEND_SRC_OVER || rkBlendType == IM_ALPHA_BLEND_SRC) {
|
||||
usage = 0;
|
||||
if (opt->enableScale == 0) {
|
||||
eok = memset_s(&srect, sizeof(srect), 0, sizeof(srect));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
srect.width = srcRgaBuffer.width;
|
||||
srect.height = srcRgaBuffer.height;
|
||||
|
||||
eok = memset_s(&drect, sizeof(drect), 0, sizeof(drect));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
return false;
|
||||
}
|
||||
drect.x = dstRgaBuffer.width - srcRgaBuffer.width;
|
||||
drect.y = dstRgaBuffer.height - srcRgaBuffer.height;
|
||||
drect.width = srcRgaBuffer.width;
|
||||
drect.height = srcRgaBuffer.height;
|
||||
}
|
||||
usage = rkRotateType | rkMirrorType | IM_SYNC;
|
||||
ret = improcess(srcRgaBuffer, dstRgaBuffer, bRgbBuffer, srect, drect, prect, usage);
|
||||
if (ret != IM_STATUS_SUCCESS) {
|
||||
DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
|
||||
}
|
||||
} else if (rkBlendType == IM_ALPHA_BLEND_DST_OVER) {
|
||||
if (grallocFucs == NULL) {
|
||||
ret = GrallocInitialize(&grallocFucs);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("Gralloc init failed"));
|
||||
}
|
||||
AllocInfo info = {
|
||||
.width = dstRgaBuffer.width,
|
||||
.height = dstRgaBuffer.height,
|
||||
.usage = HBM_USE_MEM_DMA | HBM_USE_CPU_READ | HBM_USE_CPU_WRITE,
|
||||
.format = PIXEL_FMT_RGBA_8888, // srcSurface->enColorFmt,
|
||||
};
|
||||
BufferHandle *buffer = NULL;
|
||||
|
||||
ret = grallocFucs->AllocMem(&info, &buffer);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not alloc memory"));
|
||||
|
||||
bRgbBuffer.width = dstRgaBuffer.width;
|
||||
bRgbBuffer.height = dstRgaBuffer.height;
|
||||
bRgbBuffer.wstride = dstRgaBuffer.wstride;
|
||||
bRgbBuffer.hstride = dstRgaBuffer.hstride;
|
||||
bRgbBuffer.format = RK_FORMAT_RGBA_8888; // srcRgaBuffer.format;
|
||||
bRgbBuffer.phy_addr = 0; // (void *) buffer->phyAddr;
|
||||
bRgbBuffer.vir_addr = 0; // buffer->virAddr;
|
||||
bRgbBuffer.color_space_mode = dstRgaBuffer.color_space_mode;
|
||||
bRgbBuffer.fd = (int32_t)buffer->phyAddr;
|
||||
int ret = memcpy_s(&prect, sizeof(drect), &drect, sizeof(drect));
|
||||
if (!ret) {
|
||||
printf("memcpy_s failed!\n");
|
||||
}
|
||||
ret = improcess(srcRgaBuffer, bRgbBuffer, dstRgaBuffer, srect, prect, drect, usage);
|
||||
if (ret != IM_STATUS_SUCCESS) {
|
||||
DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
|
||||
} else {
|
||||
ret = imcopy(bRgbBuffer, dstRgaBuffer);
|
||||
if (ret != IM_STATUS_SUCCESS) {
|
||||
DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
|
||||
}
|
||||
}
|
||||
grallocFucs->FreeMem(buffer);
|
||||
}
|
||||
} else {
|
||||
ret = improcess(srcRgaBuffer, dstRgaBuffer, bRgbBuffer, srect, drect, prect, usage);
|
||||
if (ret != IM_STATUS_SUCCESS) {
|
||||
DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
|
||||
}
|
||||
}
|
||||
if (ret != IM_STATUS_SUCCESS)
|
||||
return DISPLAY_FAILURE;
|
||||
else
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t rkBlit(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt)
|
||||
{
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(srcSurface, DISPLAY_NULL_PTR);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(srcRect, DISPLAY_NULL_PTR);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(dstSurface, DISPLAY_NULL_PTR);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(dstRect, DISPLAY_NULL_PTR);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(opt, DISPLAY_NULL_PTR);
|
||||
|
||||
if (doFlit(srcSurface, srcRect, dstSurface, dstRect, opt) < 0)
|
||||
return DISPLAY_FAILURE;
|
||||
else
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t rkSync(int32_t timeOut)
|
||||
{
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t GfxInitialize(GfxFuncs **funcs)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((funcs == NULL), DISPLAY_PARAM_ERR, DISPLAY_LOGE("info is null"));
|
||||
GfxFuncs *gfxFuncs = (GfxFuncs *)malloc(sizeof(GfxFuncs));
|
||||
errno_t eok = memset_s((void *)gfxFuncs, sizeof(GfxFuncs), 0, sizeof(GfxFuncs));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
free(gfxFuncs);
|
||||
return false;
|
||||
}
|
||||
gfxFuncs->InitGfx = rkInitGfx;
|
||||
gfxFuncs->DeinitGfx = rkDeinitGfx;
|
||||
gfxFuncs->FillRect = rkFillRect;
|
||||
gfxFuncs->Blit = rkBlit;
|
||||
gfxFuncs->Sync = rkSync;
|
||||
*funcs = gfxFuncs;
|
||||
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t GfxUninitialize(GfxFuncs *funcs)
|
||||
{
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(funcs, DISPLAY_NULL_PTR);
|
||||
free(funcs);
|
||||
DISPLAY_LOGI("%s: gfx uninitialize success", __func__);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "display_gralloc.h"
|
||||
#include <inttypes.h>
|
||||
#include <securec.h>
|
||||
#include "display_common.h"
|
||||
#include "display_gralloc_gbm.h"
|
||||
|
||||
int32_t AllocMem(const AllocInfo *info, BufferHandle **handle)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((info == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("info is null"));
|
||||
DISPLAY_CHK_RETURN((handle == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("handle is null"));
|
||||
#ifdef GRALLOC_GBM_SUPPORT
|
||||
if (info->usage & HBM_USE_MEM_DMA) {
|
||||
return GbmAllocMem(info, handle);
|
||||
}
|
||||
#endif
|
||||
DISPLAY_LOGE("the usage is not support 0x%{public}" PRIx64 "", info->usage);
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
void FreeMem(BufferHandle *handle)
|
||||
{
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((handle == NULL), DISPLAY_LOGE("handle is null"));
|
||||
#ifdef GRALLOC_GBM_SUPPORT
|
||||
if (handle->usage & HBM_USE_MEM_DMA) {
|
||||
GbmFreeMem(handle);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void *Mmap(BufferHandle *handle)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((handle == NULL), NULL, DISPLAY_LOGE("handle is null"));
|
||||
#ifdef GRALLOC_GBM_SUPPORT
|
||||
if (handle->usage & HBM_USE_MEM_DMA) {
|
||||
return GbmMmap(handle);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t Unmap(BufferHandle *handle)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((handle == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("handle is null"));
|
||||
#ifdef GRALLOC_GBM_SUPPORT
|
||||
if (handle->usage & HBM_USE_MEM_DMA) {
|
||||
return GbmUnmap(handle);
|
||||
}
|
||||
#endif
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t FlushCache(BufferHandle *handle)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((handle == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("handle is null"));
|
||||
#ifdef GRALLOC_GBM_SUPPORT
|
||||
if (handle->usage & HBM_USE_MEM_DMA) {
|
||||
return GbmFlushCache(handle);
|
||||
}
|
||||
#endif
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t InvalidateCache(BufferHandle *handle)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((handle == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("handle is null"));
|
||||
#ifdef GRALLOC_GBM_SUPPORT
|
||||
if (handle->usage & HBM_USE_MEM_DMA) {
|
||||
return GbmInvalidateCache(handle);
|
||||
}
|
||||
#endif
|
||||
return DISPLAY_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t GrallocUninitialize(GrallocFuncs *funcs)
|
||||
{
|
||||
DISPLAY_CHK_RETURN(funcs == NULL, DISPLAY_PARAM_ERR, DISPLAY_LOGE("funcs is null"));
|
||||
DISPLAY_LOGD();
|
||||
#ifdef GRALLOC_GBM_SUPPORT
|
||||
if (GbmGrallocUninitialize() != DISPLAY_SUCCESS) {
|
||||
DISPLAY_LOGE("gbm uninit failed");
|
||||
}
|
||||
#endif
|
||||
free(funcs);
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t GrallocInitialize(GrallocFuncs **funcs)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN((funcs == NULL), DISPLAY_PARAM_ERR, DISPLAY_LOGE("funcs is null"));
|
||||
GrallocFuncs *grallocFuncs = (GrallocFuncs *)malloc(sizeof(GrallocFuncs));
|
||||
DISPLAY_CHK_RETURN((grallocFuncs == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("memset_s failed"));
|
||||
errno_t eok = memset_s(grallocFuncs, sizeof(GrallocFuncs), 0, sizeof(GrallocFuncs));
|
||||
DISPLAY_CHK_RETURN((eok != EOK), DISPLAY_FAILURE, DISPLAY_LOGE("memset_s failed"));
|
||||
// initialize gbm gralloc
|
||||
#ifdef GRALLOC_GBM_SUPPORT
|
||||
int ret = GbmGrallocInitialize();
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), ret, DISPLAY_LOGE("gbm initial"); free(grallocFuncs));
|
||||
#endif
|
||||
grallocFuncs->AllocMem = AllocMem;
|
||||
grallocFuncs->FreeMem = FreeMem;
|
||||
grallocFuncs->Mmap = Mmap;
|
||||
grallocFuncs->Unmap = Unmap;
|
||||
grallocFuncs->InvalidateCache = InvalidateCache;
|
||||
grallocFuncs->FlushCache = FlushCache;
|
||||
*funcs = grallocFuncs;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "display_gralloc_gbm.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <linux/dma-buf.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/mman.h>
|
||||
#include <xf86drm.h>
|
||||
#include <securec.h>
|
||||
#include "drm_fourcc.h"
|
||||
#include "seed_gbm.h"
|
||||
#include "hdf_dlist.h"
|
||||
#include "display_gralloc_private.h"
|
||||
#include "display_common.h"
|
||||
|
||||
const char *g_drmFileNode = "/dev/dri/card1";
|
||||
static GrallocManager *g_grallocManager = NULL;
|
||||
static pthread_mutex_t g_lock;
|
||||
static uint64_t global_id = 0;
|
||||
|
||||
typedef struct {
|
||||
uint32_t drmFormat;
|
||||
PixelFormat pixFormat;
|
||||
} PixelFormatConvertTbl;
|
||||
|
||||
typedef struct {
|
||||
uint32_t value;
|
||||
const char *str;
|
||||
} ValueStrMap;
|
||||
|
||||
static GrallocManager *GetGrallocManager()
|
||||
{
|
||||
if (g_grallocManager == NULL) {
|
||||
g_grallocManager = (GrallocManager *)malloc(sizeof(GrallocManager));
|
||||
errno_t eok = memset_s(g_grallocManager, sizeof(GrallocManager), 0, sizeof(GrallocManager));
|
||||
if (eok != EOK) {
|
||||
DISPLAY_LOGE("memset_s failed");
|
||||
}
|
||||
if (g_grallocManager == NULL) {
|
||||
DISPLAY_LOGE("gralloc manager malloc failed");
|
||||
}
|
||||
}
|
||||
return g_grallocManager;
|
||||
}
|
||||
|
||||
const char *GetPixelFmtStr(PixelFormat format)
|
||||
{
|
||||
static const ValueStrMap pixelStrMaps[] = {
|
||||
{PIXEL_FMT_CLUT8, "PIXEL_FMT_CLUT8"}, {PIXEL_FMT_CLUT1, "PIXEL_FMT_CLUT1"},
|
||||
{PIXEL_FMT_CLUT4, "PIXEL_FMT_CLUT4"}, {PIXEL_FMT_RGB_565, "PIXEL_FMT_RGB_565"},
|
||||
{PIXEL_FMT_RGBA_5658, "IXEL_FMT_RGBA_5658"}, {PIXEL_FMT_RGBX_4444, "PIXEL_FMT_RGBX_4444"},
|
||||
{PIXEL_FMT_RGBA_4444, "PIXEL_FMT_RGBA_4444"}, {PIXEL_FMT_RGB_444, "PIXEL_FMT_RGB_444"},
|
||||
{PIXEL_FMT_RGBX_5551, "PIXEL_FMT_RGBX_5551"}, {PIXEL_FMT_RGBA_5551, "PIXEL_FMT_RGBA_5551"},
|
||||
{PIXEL_FMT_RGB_555, "PIXEL_FMT_RGB_555"}, {PIXEL_FMT_RGBX_8888, "PIXEL_FMT_RGBX_8888"},
|
||||
{PIXEL_FMT_RGBA_8888, "PIXEL_FMT_RGBA_8888"}, {PIXEL_FMT_RGB_888, "PIXEL_FMT_RGB_888"},
|
||||
{PIXEL_FMT_BGR_565, "PIXEL_FMT_BGR_565"}, {PIXEL_FMT_BGRX_4444, "PIXEL_FMT_BGRX_4444"},
|
||||
{PIXEL_FMT_BGRA_4444, "PIXEL_FMT_BGRA_4444"}, {PIXEL_FMT_BGRX_5551, "PIXEL_FMT_BGRX_5551"},
|
||||
{PIXEL_FMT_BGRA_5551, "PIXEL_FMT_BGRA_5551"}, {PIXEL_FMT_BGRX_8888, "PIXEL_FMT_BGRX_8888"},
|
||||
{PIXEL_FMT_BGRA_8888, "PIXEL_FMT_BGRA_8888"}, {PIXEL_FMT_YUV_422_I, "PIXEL_FMT_YUV_422_I"},
|
||||
{PIXEL_FMT_YUV_422_I, "PIXEL_FMT_YUV_422_I"}, {PIXEL_FMT_YCBCR_422_SP, "PIXEL_FMT_YCBCR_422_SP"},
|
||||
{PIXEL_FMT_YCRCB_422_SP, "PIXEL_FMT_YCRCB_422_SP"}, {PIXEL_FMT_YCBCR_420_SP, "PIXEL_FMT_YCBCR_420_SP"},
|
||||
{PIXEL_FMT_YCRCB_420_SP, "PIXEL_FMT_YCRCB_420_SP"}, {PIXEL_FMT_YCBCR_422_P, "PIXEL_FMT_YCBCR_422_P"},
|
||||
{PIXEL_FMT_YCRCB_422_P, "PIXEL_FMT_YCRCB_422_P"}, {PIXEL_FMT_YCBCR_420_P, "PIXEL_FMT_YCBCR_420_P"},
|
||||
{PIXEL_FMT_YCRCB_420_P, "PIXEL_FMT_YCRCB_420_P"}, {PIXEL_FMT_YUYV_422_PKG, "PIXEL_FMT_YUYV_422_PKG"},
|
||||
{PIXEL_FMT_UYVY_422_PKG, "PIXEL_FMT_UYVY_422_PKG"}, {PIXEL_FMT_YVYU_422_PKG, "PIXEL_FMT_YVYU_422_PKG"},
|
||||
{PIXEL_FMT_VYUY_422_PKG, "PIXEL_FMT_VYUY_422_PKG"}, {PIXEL_FMT_BUTT, "PIXEL_FMT_BUTT"},
|
||||
};
|
||||
static const char *unknown = "unknown format";
|
||||
for (uint32_t i = 0; i < sizeof(pixelStrMaps) / sizeof(pixelStrMaps[0]); i++) {
|
||||
if (pixelStrMaps[i].value == format) {
|
||||
return pixelStrMaps[i].str;
|
||||
}
|
||||
}
|
||||
DISPLAY_LOGE("GetPixelFmtStr unknown format %{public}d", format);
|
||||
return unknown;
|
||||
}
|
||||
|
||||
const char *GetDrmFmtStr(uint32_t format)
|
||||
{
|
||||
static const ValueStrMap formatStrMaps[] = {
|
||||
{DRM_FORMAT_C8, "DRM_FORMAT_C8" }, {DRM_FORMAT_R8, "DRM_FORMAT_R8" },
|
||||
{DRM_FORMAT_R16, "DRM_FORMAT_R16"}, {DRM_FORMAT_RG88, "DRM_FORMAT_RG88"},
|
||||
{DRM_FORMAT_GR88, "DRM_FORMAT_GR88"}, {DRM_FORMAT_RG1616, "DRM_FORMAT_RG1616"},
|
||||
{DRM_FORMAT_GR1616, "DRM_FORMAT_GR1616"}, {DRM_FORMAT_RGB332, "DRM_FORMAT_RGB332"},
|
||||
{DRM_FORMAT_BGR233, "DRM_FORMAT_BGR233"}, {DRM_FORMAT_XRGB4444, "DRM_FORMAT_XRGB4444"},
|
||||
{DRM_FORMAT_XBGR4444, "DRM_FORMAT_XBGR4444"}, {DRM_FORMAT_RGBX4444, "DRM_FORMAT_RGBX4444"},
|
||||
{DRM_FORMAT_BGRX4444, "DRM_FORMAT_BGRX4444"}, {DRM_FORMAT_ARGB4444, "DRM_FORMAT_ARGB4444"},
|
||||
{DRM_FORMAT_ABGR4444, "DRM_FORMAT_ABGR4444"}, {DRM_FORMAT_RGBA4444, "DRM_FORMAT_RGBA4444"},
|
||||
{DRM_FORMAT_BGRA4444, "DRM_FORMAT_BGRA4444"}, {DRM_FORMAT_XRGB1555, "DRM_FORMAT_XRGB1555"},
|
||||
{DRM_FORMAT_XBGR1555, "DRM_FORMAT_XBGR1555"}, {DRM_FORMAT_RGBX5551, "DRM_FORMAT_RGBX5551"},
|
||||
{DRM_FORMAT_BGRX5551, "DRM_FORMAT_BGRX5551"}, {DRM_FORMAT_ARGB1555, "DRM_FORMAT_ARGB1555"},
|
||||
{DRM_FORMAT_ABGR1555, "DRM_FORMAT_ABGR1555"}, {DRM_FORMAT_RGBA5551, "DRM_FORMAT_RGBA5551"},
|
||||
{DRM_FORMAT_BGRA5551, "DRM_FORMAT_BGRA5551"}, {DRM_FORMAT_RGB565, "DRM_FORMAT_RGB565"},
|
||||
{DRM_FORMAT_BGR565, "DRM_FORMAT_BGR565"}, {DRM_FORMAT_RGB888, "DRM_FORMAT_RGB888"},
|
||||
{DRM_FORMAT_BGR888, "DRM_FORMAT_BGR888"}, {DRM_FORMAT_XRGB8888, "DRM_FORMAT_XRGB8888"},
|
||||
{DRM_FORMAT_XBGR8888, "DRM_FORMAT_XBGR8888"}, {DRM_FORMAT_RGBX8888, "DRM_FORMAT_RGBX8888"},
|
||||
{DRM_FORMAT_BGRX8888, "DRM_FORMAT_BGRX8888"}, {DRM_FORMAT_ARGB8888, "DRM_FORMAT_ARGB8888"},
|
||||
{DRM_FORMAT_ABGR8888, "DRM_FORMAT_ABGR8888"}, {DRM_FORMAT_RGBA8888, "DRM_FORMAT_RGBA8888"},
|
||||
{DRM_FORMAT_BGRA8888, "DRM_FORMAT_BGRA8888"}, {DRM_FORMAT_XRGB2101010, "DRM_FORMAT_XRGB2101010"},
|
||||
{DRM_FORMAT_BGRX1010102, "DRM_FORMAT_BGRX1010102"}, {DRM_FORMAT_ARGB2101010, "DRM_FORMAT_ARGB2101010"},
|
||||
{DRM_FORMAT_ABGR2101010, "DRM_FORMAT_ABGR2101010"}, {DRM_FORMAT_RGBA1010102, "DRM_FORMAT_RGBA1010102"},
|
||||
{DRM_FORMAT_YVYU, "DRM_FORMAT_YVYU"}, {DRM_FORMAT_UYVY, "DRM_FORMAT_UYVY"},
|
||||
{DRM_FORMAT_VYUY, "DRM_FORMAT_VYUY"}, {DRM_FORMAT_AYUV, "DRM_FORMAT_AYUV"},
|
||||
{DRM_FORMAT_NV12, "DRM_FORMAT_NV12"}, {DRM_FORMAT_NV21, "DRM_FORMAT_NV21"},
|
||||
{DRM_FORMAT_NV16, "DRM_FORMAT_NV16"}, {DRM_FORMAT_NV61, "DRM_FORMAT_NV61"},
|
||||
{DRM_FORMAT_NV24, "DRM_FORMAT_NV24"}, {DRM_FORMAT_NV42, "DRM_FORMAT_NV42"},
|
||||
{DRM_FORMAT_YUV410, "DRM_FORMAT_YUV410"}, {DRM_FORMAT_YVU410, "DRM_FORMAT_YVU410"},
|
||||
{DRM_FORMAT_YUV411, "DRM_FORMAT_YUV411"}, {DRM_FORMAT_YVU411, "DRM_FORMAT_YVU411"},
|
||||
{DRM_FORMAT_YUV420, "DRM_FORMAT_YUV420"}, {DRM_FORMAT_YVU420, "DRM_FORMAT_YVU420"},
|
||||
{DRM_FORMAT_YUV422, "DRM_FORMAT_YUV422"}, {DRM_FORMAT_YVU422, "DRM_FORMAT_YVU422"},
|
||||
{DRM_FORMAT_YUV444, "DRM_FORMAT_YUV444"}, {DRM_FORMAT_YVU444, "DRM_FORMAT_YVU444"},
|
||||
};
|
||||
|
||||
static const char *unknown = "unknown drm format";
|
||||
for (uint32_t i = 0; i < sizeof(formatStrMaps) / sizeof(formatStrMaps[0]); i++) {
|
||||
if (formatStrMaps[i].value == format) {
|
||||
return formatStrMaps[i].str;
|
||||
}
|
||||
}
|
||||
DISPLAY_LOGE("GetDrmFmtStr unknown format %{public}d", format);
|
||||
return unknown;
|
||||
}
|
||||
|
||||
static uint32_t ConvertFormatToDrm(PixelFormat fmtIn)
|
||||
{
|
||||
static const PixelFormatConvertTbl convertTable[] = {
|
||||
{DRM_FORMAT_RGBX8888, PIXEL_FMT_RGBX_8888}, {DRM_FORMAT_RGBA8888, PIXEL_FMT_RGBA_8888},
|
||||
{DRM_FORMAT_RGB888, PIXEL_FMT_RGB_888}, {DRM_FORMAT_RGB565, PIXEL_FMT_BGR_565},
|
||||
{DRM_FORMAT_BGRX4444, PIXEL_FMT_BGRX_4444}, {DRM_FORMAT_BGRA4444, PIXEL_FMT_BGRA_4444},
|
||||
{DRM_FORMAT_RGBA4444, PIXEL_FMT_RGBA_4444}, {DRM_FORMAT_RGBX4444, PIXEL_FMT_RGBX_4444},
|
||||
{DRM_FORMAT_BGRX5551, PIXEL_FMT_BGRX_5551}, {DRM_FORMAT_BGRA5551, PIXEL_FMT_BGRA_5551},
|
||||
{DRM_FORMAT_BGRX8888, PIXEL_FMT_BGRX_8888}, {DRM_FORMAT_BGRA8888, PIXEL_FMT_BGRA_8888},
|
||||
{DRM_FORMAT_NV12, PIXEL_FMT_YCBCR_420_SP}, {DRM_FORMAT_NV21, PIXEL_FMT_YCRCB_420_SP},
|
||||
{DRM_FORMAT_YUV420, PIXEL_FMT_YCBCR_420_P}, {DRM_FORMAT_YVU420, PIXEL_FMT_YCRCB_420_P},
|
||||
{DRM_FORMAT_NV16, PIXEL_FMT_YCBCR_422_SP}, {DRM_FORMAT_NV61, PIXEL_FMT_YCRCB_422_SP},
|
||||
{DRM_FORMAT_YUV422, PIXEL_FMT_YCBCR_422_P}, {DRM_FORMAT_YVU422, PIXEL_FMT_YCRCB_422_P},
|
||||
};
|
||||
uint32_t fmtOut = 0;
|
||||
for (uint32_t i = 0; i < sizeof(convertTable) / sizeof(convertTable[0]); i++) {
|
||||
if (convertTable[i].pixFormat == fmtIn) {
|
||||
fmtOut = convertTable[i].drmFormat;
|
||||
}
|
||||
}
|
||||
DISPLAY_LOGD("fmtIn %{public}d : %{public}s, outFmt %{public}d : %{public}s", fmtIn, GetPixelFmtStr(fmtIn), fmtOut,
|
||||
GetDrmFmtStr(fmtOut));
|
||||
return fmtOut;
|
||||
}
|
||||
|
||||
static uint64_t ConvertUsageToGbm(uint64_t inUsage)
|
||||
{
|
||||
uint64_t outUsage = GBM_BO_USE_TEXTURING;
|
||||
if (inUsage & HBM_USE_CPU_READ) {
|
||||
outUsage |= GBM_BO_USE_SW_READ_OFTEN;
|
||||
}
|
||||
if (inUsage & HBM_USE_CPU_WRITE) {
|
||||
outUsage |= GBM_BO_USE_SW_WRITE_OFTEN;
|
||||
}
|
||||
DISPLAY_LOGD("outUsage 0x%{public}" PRIx64 "", outUsage);
|
||||
return outUsage;
|
||||
}
|
||||
|
||||
static int32_t InitGbmDevice(const char *drmFile, GrallocManager *grallocManager)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
if (grallocManager->gbmDevice == NULL) {
|
||||
char path[PATH_MAX] = {0};
|
||||
if (realpath(drmFile, path) == NULL) {
|
||||
DISPLAY_LOGE(" drm File : %{public}s is not a realpath, errno: %{public}s", drmFile, strerror(errno));
|
||||
return DISPLAY_PARAM_ERR;
|
||||
}
|
||||
int drmFd = open(path, O_RDWR);
|
||||
if (drmFd < 0) {
|
||||
DISPLAY_LOGE("drm file:%{public}s open failed %{public}s", drmFile, strerror(errno));
|
||||
return DISPLAY_FD_ERR;
|
||||
}
|
||||
drmDropMaster(drmFd);
|
||||
struct gbm_device *gbmDevice = hdi_gbm_create_device(drmFd);
|
||||
grallocManager->drmFd = drmFd;
|
||||
if (gbmDevice == NULL) {
|
||||
close(drmFd);
|
||||
grallocManager->drmFd = -1;
|
||||
DISPLAY_LOGE("gbm device create failed");
|
||||
return DISPLAY_FAILURE;
|
||||
}
|
||||
grallocManager->gbmDevice = gbmDevice;
|
||||
grallocManager->drmFd = drmFd;
|
||||
DListHeadInit(&grallocManager->gbmBoHead);
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
static void DeInitGbmDevice(GrallocManager *grallocManager)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
hdi_gbm_device_destroy(grallocManager->gbmDevice);
|
||||
if (grallocManager->drmFd > 0) {
|
||||
close(grallocManager->drmFd);
|
||||
grallocManager->drmFd = -1;
|
||||
}
|
||||
grallocManager->gbmDevice = NULL;
|
||||
}
|
||||
|
||||
static int32_t DmaBufferSync(const BufferHandle *handle, bool start)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
struct dma_buf_sync syncPrm;
|
||||
errno_t eok = memset_s(&syncPrm, sizeof(syncPrm), 0, sizeof(syncPrm));
|
||||
DISPLAY_CHK_RETURN((eok != EOK), DISPLAY_PARAM_ERR, DISPLAY_LOGE("dma buffer sync memset_s failed"));
|
||||
|
||||
if (handle->usage & HBM_USE_CPU_WRITE) {
|
||||
syncPrm.flags |= DMA_BUF_SYNC_WRITE;
|
||||
}
|
||||
|
||||
if (handle->usage & HBM_USE_CPU_READ) {
|
||||
syncPrm.flags |= DMA_BUF_SYNC_READ;
|
||||
}
|
||||
|
||||
if (start) {
|
||||
syncPrm.flags |= DMA_BUF_SYNC_START;
|
||||
} else {
|
||||
syncPrm.flags |= DMA_BUF_SYNC_END;
|
||||
}
|
||||
int retry = 6;
|
||||
int ret;
|
||||
do {
|
||||
ret = ioctl(handle->fd, DMA_BUF_IOCTL_SYNC, &syncPrm);
|
||||
} while ((retry--) && (ret != -EAGAIN) && (ret != -EINTR));
|
||||
|
||||
if (ret < 0) {
|
||||
DISPLAY_LOGE("DISPLAY_SUCCESS sync failed");
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
static void InitBufferHandle(struct gbm_bo *bo, int fd, const AllocInfo *info, PriBufferHandle *buffer)
|
||||
{
|
||||
BufferHandle *bufferHandle = &(buffer->hdl);
|
||||
bufferHandle->fd = fd;
|
||||
bufferHandle->reserveFds = GRALLOC_PRIV_NUM_FDS;
|
||||
bufferHandle->reserveInts = GRALLOC_PRIV_NUM_INTS;
|
||||
bufferHandle->stride = hdi_gbm_bo_get_stride(bo);
|
||||
bufferHandle->width = info->width;
|
||||
bufferHandle->height = info->height;
|
||||
bufferHandle->usage = info->usage;
|
||||
bufferHandle->format = info->format;
|
||||
bufferHandle->virAddr = NULL;
|
||||
bufferHandle->size = hdi_gbm_bo_get_stride(bo) * hdi_gbm_bo_get_height(bo);
|
||||
switch(info->format)
|
||||
{
|
||||
case PIXEL_FMT_YCBCR_420_SP:
|
||||
case PIXEL_FMT_YCRCB_420_SP:
|
||||
buffer->plan_num = 2;
|
||||
buffer->yuv_info = AW_YUV_NO_INFO;
|
||||
buffer->plane_info[0].alloc_height = hdi_gbm_bo_get_height(bo);
|
||||
buffer->plane_info[0].alloc_width = hdi_gbm_bo_get_width(bo);
|
||||
buffer->plane_info[0].byte_stride = hdi_gbm_bo_get_width(bo);
|
||||
buffer->plane_info[0].offset = 0;
|
||||
buffer->plane_info[1].alloc_height = buffer->plane_info[0].alloc_height/2;
|
||||
buffer->plane_info[1].alloc_width = buffer->plane_info[0].alloc_width/2;
|
||||
buffer->plane_info[1].byte_stride = buffer->plane_info[0].byte_stride;
|
||||
buffer->plane_info[1].offset = buffer->plane_info[0].byte_stride * buffer->plane_info[0].alloc_height;
|
||||
|
||||
break;
|
||||
case PIXEL_FMT_YCBCR_422_SP:
|
||||
case PIXEL_FMT_YCRCB_422_SP:
|
||||
|
||||
break;
|
||||
case PIXEL_FMT_YCBCR_420_P:
|
||||
case PIXEL_FMT_YCRCB_420_P:
|
||||
buffer->plan_num = 3;
|
||||
buffer->yuv_info = AW_YUV_NO_INFO;
|
||||
buffer->plane_info[0].alloc_height = hdi_gbm_bo_get_height(bo);
|
||||
buffer->plane_info[0].alloc_width = hdi_gbm_bo_get_width(bo);
|
||||
buffer->plane_info[0].byte_stride = hdi_gbm_bo_get_width(bo);
|
||||
buffer->plane_info[0].offset = 0;
|
||||
buffer->plane_info[1].alloc_height = buffer->plane_info[0].alloc_height/2;
|
||||
buffer->plane_info[1].alloc_width = buffer->plane_info[0].alloc_width/2;
|
||||
buffer->plane_info[1].byte_stride = buffer->plane_info[0].byte_stride/2;
|
||||
buffer->plane_info[1].offset = buffer->plane_info[0].byte_stride * buffer->plane_info[0].alloc_height;
|
||||
buffer->plane_info[2].alloc_height = buffer->plane_info[0].alloc_height/2;
|
||||
buffer->plane_info[2].alloc_width = buffer->plane_info[0].alloc_width/2;
|
||||
buffer->plane_info[2].byte_stride = buffer->plane_info[0].byte_stride/2;
|
||||
buffer->plane_info[2].offset = buffer->plane_info[1].offset
|
||||
+ buffer->plane_info[1].byte_stride * buffer->plane_info[1].alloc_height;
|
||||
|
||||
break;
|
||||
case PIXEL_FMT_YCBCR_422_P:
|
||||
case PIXEL_FMT_YCRCB_422_P:
|
||||
|
||||
break;
|
||||
default:
|
||||
buffer->plan_num = 1;
|
||||
buffer->yuv_info = AW_YUV_NO_INFO;
|
||||
buffer->plane_info[0].alloc_height = hdi_gbm_bo_get_height(bo);
|
||||
buffer->plane_info[0].alloc_width = hdi_gbm_bo_get_width(bo);
|
||||
buffer->plane_info[0].byte_stride = hdi_gbm_bo_get_stride(bo);
|
||||
buffer->plane_info[0].offset = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int32_t GbmAllocMem(const AllocInfo *info, BufferHandle **buffer)
|
||||
{
|
||||
|
||||
DISPLAY_CHK_RETURN((info == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("info is null"));
|
||||
DISPLAY_CHK_RETURN((buffer == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("buffer is null"));
|
||||
PriBufferHandle *priBuffer = NULL;
|
||||
uint32_t drmFmt = ConvertFormatToDrm(info->format);
|
||||
DISPLAY_CHK_RETURN((drmFmt == INVALID_PIXEL_FMT), DISPLAY_NOT_SUPPORT,
|
||||
DISPLAY_LOGE("format %{public}d can not support", info->format));
|
||||
|
||||
GRALLOC_LOCK();
|
||||
GrallocManager *grallocManager = GetGrallocManager();
|
||||
DISPLAY_CHK_RETURN((grallocManager == NULL), DISPLAY_PARAM_ERR, DISPLAY_LOGE("gralloc manager failed");
|
||||
GRALLOC_UNLOCK());
|
||||
struct gbm_bo *bo =
|
||||
hdi_gbm_bo_create(grallocManager->gbmDevice, info->width, info->height, drmFmt, ConvertUsageToGbm(info->usage));
|
||||
DISPLAY_CHK_RETURN((bo == NULL), DISPLAY_NOMEM, DISPLAY_LOGE("gbm create bo failed"); GRALLOC_UNLOCK());
|
||||
|
||||
int fd = hdi_gbm_bo_get_fd(bo);
|
||||
DISPLAY_CHK_RETURN((fd < 0), DISPLAY_FD_ERR, DISPLAY_LOGE("gbm can not get fd"); hdi_gbm_bo_destroy(bo);
|
||||
GRALLOC_UNLOCK());
|
||||
|
||||
priBuffer = (PriBufferHandle *)malloc(sizeof(PriBufferHandle));
|
||||
DISPLAY_CHK_RETURN((priBuffer == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("bufferhandle malloc failed"); goto error);
|
||||
errno_t eok = memset_s(priBuffer, sizeof(PriBufferHandle), 0, sizeof(PriBufferHandle));
|
||||
DISPLAY_CHK_RETURN((eok != EOK), DISPLAY_PARAM_ERR, DISPLAY_LOGE("memset_s failed"); goto error);
|
||||
|
||||
InitBufferHandle(bo, fd, info, priBuffer);
|
||||
priBuffer->id = global_id++;
|
||||
DISPLAY_LOGD("alloc mem width %{public}d, heigt %{public}d, drmformat %{public}d, format %{public}d buffer id:%{public}llu",
|
||||
info->width, info->height, drmFmt, info->format, priBuffer->id);
|
||||
|
||||
priBuffer->hdl.phyAddr = 0;
|
||||
*buffer = &priBuffer->hdl;
|
||||
hdi_gbm_bo_destroy(bo);
|
||||
GRALLOC_UNLOCK();
|
||||
return DISPLAY_SUCCESS;
|
||||
error:
|
||||
close(fd);
|
||||
hdi_gbm_bo_destroy(bo);
|
||||
if (priBuffer != NULL) {
|
||||
free(priBuffer);
|
||||
}
|
||||
GRALLOC_UNLOCK();
|
||||
return DISPLAY_FAILURE;
|
||||
}
|
||||
|
||||
static void CloseBufferHandle(BufferHandle *handle)
|
||||
{
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((handle == NULL), DISPLAY_LOGE("buffer is null"));
|
||||
if (handle->fd >= 0) {
|
||||
close(handle->fd);
|
||||
handle->fd = -1;
|
||||
}
|
||||
const uint32_t reserveFds = handle->reserveFds;
|
||||
for (uint32_t i = 0; i < reserveFds; i++) {
|
||||
if (handle->reserve[i] >= 0) {
|
||||
close(handle->reserve[i]);
|
||||
handle->reserve[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GbmFreeMem(BufferHandle *buffer)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((buffer == NULL), DISPLAY_LOGE("buffer is null"));
|
||||
if ((buffer->virAddr != NULL) && (GbmUnmap(buffer) != DISPLAY_SUCCESS)) {
|
||||
DISPLAY_LOGE("freeMem unmap buffer failed");
|
||||
}
|
||||
CloseBufferHandle(buffer);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
void *GbmMmap(BufferHandle *buffer)
|
||||
{
|
||||
void *virAddr = NULL;
|
||||
DISPLAY_LOGD();
|
||||
if (buffer == NULL) {
|
||||
DISPLAY_LOGE("gbmmap the buffer handle is NULL");
|
||||
return NULL;
|
||||
}
|
||||
if (buffer->virAddr != NULL) {
|
||||
DISPLAY_LOGD("the buffer has virtual addr");
|
||||
return buffer->virAddr;
|
||||
}
|
||||
virAddr = mmap(NULL, buffer->size, PROT_READ | PROT_WRITE, MAP_SHARED, buffer->fd, 0);
|
||||
if (virAddr == MAP_FAILED) {
|
||||
DISPLAY_LOGE("mmap failed errno %{public}s, fd : %{public}d", strerror(errno), buffer->fd);
|
||||
}
|
||||
buffer->virAddr = virAddr;
|
||||
return virAddr;
|
||||
}
|
||||
|
||||
int32_t GbmUnmap(BufferHandle *buffer)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
if (buffer == NULL) {
|
||||
DISPLAY_LOGE("gbmumap the buffer handle is null");
|
||||
return DISPLAY_NULL_PTR;
|
||||
}
|
||||
|
||||
if (buffer->virAddr == NULL) {
|
||||
DISPLAY_LOGE("virAddr is NULL , has not map the buffer");
|
||||
return DISPLAY_PARAM_ERR;
|
||||
}
|
||||
int ret = munmap(buffer->virAddr, buffer->size);
|
||||
if (ret != 0) {
|
||||
DISPLAY_LOGE("munmap failed err: %{public}s", strerror(errno));
|
||||
return DISPLAY_FAILURE;
|
||||
}
|
||||
buffer->virAddr = NULL;
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t GbmInvalidateCache(BufferHandle *buffer)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
return DmaBufferSync(buffer, true);
|
||||
}
|
||||
|
||||
int32_t GbmFlushCache(BufferHandle *buffer)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
return DmaBufferSync(buffer, false);
|
||||
}
|
||||
|
||||
int32_t GbmGrallocUninitialize(void)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
GRALLOC_LOCK();
|
||||
GrallocManager *grallocManager = GetGrallocManager();
|
||||
DISPLAY_CHK_RETURN((grallocManager == NULL), DISPLAY_PARAM_ERR, DISPLAY_LOGE("gralloc manager failed");
|
||||
GRALLOC_UNLOCK());
|
||||
grallocManager->referCount--;
|
||||
if (grallocManager->referCount < 0) {
|
||||
DeInitGbmDevice(grallocManager);
|
||||
free(g_grallocManager);
|
||||
g_grallocManager = NULL;
|
||||
}
|
||||
GRALLOC_UNLOCK();
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t GbmGrallocInitialize(void)
|
||||
{
|
||||
DISPLAY_LOGD();
|
||||
GRALLOC_LOCK();
|
||||
GrallocManager *grallocManager = GetGrallocManager();
|
||||
DISPLAY_CHK_RETURN((grallocManager == NULL), DISPLAY_PARAM_ERR, DISPLAY_LOGE("gralloc manager failed");
|
||||
GRALLOC_UNLOCK());
|
||||
int ret = InitGbmDevice(g_drmFileNode, grallocManager);
|
||||
DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), ret, DISPLAY_LOGE("gralloc manager failed"); GRALLOC_UNLOCK());
|
||||
grallocManager->referCount++;
|
||||
int32_t pid = getpid();
|
||||
global_id = ((uint64_t)(pid))<<32;
|
||||
GRALLOC_UNLOCK();
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef DISPLAY_GRALLOC_GBM_H
|
||||
#define DISPLAY_GRALLOC_GBM_H
|
||||
#include "display_type.h"
|
||||
#include "hdf_dlist.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum{
|
||||
AW_YUV_NO_INFO,
|
||||
AW_YUV_BT601_NARROW,
|
||||
AW_YUV_BT601_WIDE,
|
||||
AW_YUV_BT709_NARROW,
|
||||
AW_YUV_BT709_WIDE
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct gbm_device *gbmDevice;
|
||||
int drmFd;
|
||||
struct DListHead gbmBoHead;
|
||||
int32_t referCount;
|
||||
} GrallocManager;
|
||||
|
||||
typedef struct {
|
||||
struct DListHead entry;
|
||||
struct gbm_bo *bo;
|
||||
int fd;
|
||||
} GbmBoList;
|
||||
|
||||
int32_t GbmAllocMem(const AllocInfo *info, BufferHandle **buffer);
|
||||
void GbmFreeMem(BufferHandle *buffer);
|
||||
void *GbmMmap(BufferHandle *buffer);
|
||||
int32_t GbmUnmap(BufferHandle *buffer);
|
||||
int32_t GbmInvalidateCache(BufferHandle *buffer);
|
||||
int32_t GbmFlushCache(BufferHandle *buffer);
|
||||
int32_t GbmGrallocUninitialize();
|
||||
int32_t GbmGrallocInitialize();
|
||||
|
||||
#ifdef GRALLOC_LOCK_DEBUG
|
||||
#define GRALLOC_LOCK(format, ...) \
|
||||
do { \
|
||||
HDF_LOGD("[%{public}s@%{public}s:%{public}d]" format "\n", __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
|
||||
pthread_mutex_lock(&g_lock); \
|
||||
} while (0)
|
||||
|
||||
#define GRALLOC_UNLOCK(format, ...) \
|
||||
do { \
|
||||
HDF_LOGD("[%{public}s@%{public}s:%{public}d]" format "\n", __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
|
||||
pthread_mutex_unlock(&g_lock); \
|
||||
} while (0)
|
||||
#else
|
||||
#define GRALLOC_LOCK(format, ...) \
|
||||
do { \
|
||||
pthread_mutex_lock(&g_lock); \
|
||||
} while (0)
|
||||
|
||||
#define GRALLOC_UNLOCK(format, ...) \
|
||||
do { \
|
||||
pthread_mutex_unlock(&g_lock); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DISPLAY_GRALLOC_GBM_H
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#include "seed_gbm.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <securec.h>
|
||||
#include "display_common.h"
|
||||
#include "seed_gbm_internal.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t wPixelAlign;
|
||||
uint32_t hPixelAlign;
|
||||
} PlaneLayoutInfo;
|
||||
|
||||
typedef struct {
|
||||
uint32_t format;
|
||||
uint32_t bitsPerPixel;
|
||||
uint32_t numPlanes;
|
||||
const PlaneLayoutInfo *planes;
|
||||
} FormatInfo;
|
||||
|
||||
static const PlaneLayoutInfo g_defaultLayout = {
|
||||
32,1
|
||||
};
|
||||
|
||||
static const PlaneLayoutInfo g_yuvLayout = {
|
||||
16,1
|
||||
};
|
||||
|
||||
static const FormatInfo *GetFormatInfo(uint32_t format)
|
||||
{
|
||||
static const FormatInfo fmtInfos[] = {
|
||||
{DRM_FORMAT_RGBX8888, 32, 1, &g_defaultLayout}, {DRM_FORMAT_RGBA8888, 32, 1, &g_defaultLayout},
|
||||
{DRM_FORMAT_BGRX8888, 32, 1, &g_defaultLayout}, {DRM_FORMAT_BGRA8888, 32, 1, &g_defaultLayout},
|
||||
{DRM_FORMAT_RGB888, 24, 1, &g_defaultLayout}, {DRM_FORMAT_RGB565, 16, 1, &g_defaultLayout},
|
||||
{DRM_FORMAT_BGRX4444, 16, 1, &g_defaultLayout}, {DRM_FORMAT_BGRA4444, 16, 1, &g_defaultLayout},
|
||||
{DRM_FORMAT_RGBA4444, 16, 1, &g_defaultLayout}, {DRM_FORMAT_RGBX4444, 16, 1, &g_defaultLayout},
|
||||
{DRM_FORMAT_BGRX5551, 16, 1, &g_defaultLayout}, {DRM_FORMAT_BGRA5551, 16, 1, &g_defaultLayout},
|
||||
{DRM_FORMAT_NV12, 12, 2, &g_yuvLayout}, {DRM_FORMAT_NV21, 12, 2, &g_yuvLayout},
|
||||
{DRM_FORMAT_NV16, 16, 2, &g_yuvLayout}, {DRM_FORMAT_NV61, 16, 2, &g_yuvLayout},
|
||||
{DRM_FORMAT_YUV420, 12, 3, &g_yuvLayout}, {DRM_FORMAT_YVU420, 12, 3, &g_yuvLayout},
|
||||
{DRM_FORMAT_YUV422, 16, 3, &g_yuvLayout}, {DRM_FORMAT_YVU422, 16, 3, &g_yuvLayout},
|
||||
};
|
||||
|
||||
for (uint32_t i = 0; i < sizeof(fmtInfos) / sizeof(FormatInfo); i++) {
|
||||
if (fmtInfos[i].format == format) {
|
||||
return &fmtInfos[i];
|
||||
}
|
||||
}
|
||||
DISPLAY_LOGE("the format can not support");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void InitGbmBo(struct gbm_bo *bo, const struct drm_mode_create_dumb *dumb)
|
||||
{
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((dumb == NULL), DISPLAY_LOGE("dumb is null"));
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((bo == NULL), DISPLAY_LOGE("bo is null"));
|
||||
bo->stride = dumb->pitch;
|
||||
bo->size = dumb->size;
|
||||
bo->handle = dumb->handle;
|
||||
}
|
||||
|
||||
static bool AdjustStrideFromFormat(const FormatInfo *fmtInfo, uint32_t *heightStride, uint32_t *widthStride)
|
||||
{
|
||||
if (fmtInfo != NULL) {
|
||||
*heightStride = ALIGN_UP((*heightStride), fmtInfo->planes->hPixelAlign);
|
||||
*widthStride = ALIGN_UP((*widthStride), fmtInfo->planes->wPixelAlign);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct gbm_bo *hdi_gbm_bo_create(struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint32_t usage)
|
||||
{
|
||||
DISPLAY_UNUSED(usage);
|
||||
int ret;
|
||||
struct drm_mode_create_dumb dumb = { 0 };
|
||||
const FormatInfo *fmtInfo = GetFormatInfo(format);
|
||||
DISPLAY_CHK_RETURN((fmtInfo == NULL), NULL, DISPLAY_LOGE("formt: 0x%{public}x can not get layout info", format));
|
||||
struct gbm_bo *bo = (struct gbm_bo *)calloc(1, sizeof(struct gbm_bo));
|
||||
DISPLAY_CHK_RETURN((bo == NULL), NULL, DISPLAY_LOGE("gbm bo create fialed no memery"));
|
||||
(void)memset_s(bo, sizeof(struct gbm_bo), 0, sizeof(struct gbm_bo));
|
||||
AdjustStrideFromFormat(fmtInfo,&height, &width);
|
||||
bo->width = width;
|
||||
bo->height = height;
|
||||
bo->gbm = gbm;
|
||||
bo->format = format;
|
||||
dumb.height = height;
|
||||
dumb.width = width;
|
||||
dumb.flags = 0;
|
||||
dumb.bpp = fmtInfo->bitsPerPixel;
|
||||
ret = drmIoctl(gbm->fd, DRM_IOCTL_MODE_CREATE_DUMB, &dumb);
|
||||
DISPLAY_LOGI("fmt 0x%{public}x create dumb width: %{public}d height: %{public}d bpp: %{public}u pitch %{public}d "
|
||||
"size %{public}llu",
|
||||
format, dumb.width, dumb.height, dumb.bpp, dumb.pitch, dumb.size);
|
||||
DISPLAY_CHK_RETURN((ret != 0), NULL, DISPLAY_LOGE("DRM_IOCTL_MODE_CREATE_DUMB failed errno %{public}d", errno));
|
||||
InitGbmBo(bo, &dumb);
|
||||
DISPLAY_LOGI(
|
||||
"fmt 0x%{public}x create dumb width: %{public}d height: %{public}d stride %{public}d size %{public}u", format,
|
||||
bo->width, bo->height, bo->stride, bo->size);
|
||||
return bo;
|
||||
}
|
||||
|
||||
struct gbm_device *hdi_gbm_create_device(int fd)
|
||||
{
|
||||
struct gbm_device *gbm;
|
||||
gbm = (struct gbm_device *)calloc(1, sizeof(struct gbm_device));
|
||||
DISPLAY_CHK_RETURN((gbm == NULL), NULL, DISPLAY_LOGE("memory calloc failed"));
|
||||
gbm->fd = fd;
|
||||
return gbm;
|
||||
}
|
||||
|
||||
void hdi_gbm_device_destroy(struct gbm_device *gbm)
|
||||
{
|
||||
free(gbm);
|
||||
}
|
||||
|
||||
uint32_t hdi_gbm_bo_get_stride(struct gbm_bo *bo)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((bo == NULL), 0, DISPLAY_LOGE("the bo is null"));
|
||||
return bo->stride;
|
||||
}
|
||||
|
||||
uint32_t hdi_gbm_bo_get_width(struct gbm_bo *bo)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((bo == NULL), 0, DISPLAY_LOGE("the bo is null"));
|
||||
return bo->width;
|
||||
}
|
||||
|
||||
uint32_t hdi_gbm_bo_get_height(struct gbm_bo *bo)
|
||||
{
|
||||
DISPLAY_CHK_RETURN((bo == NULL), 0, DISPLAY_LOGE("the bo is null"));
|
||||
return bo->height;
|
||||
}
|
||||
|
||||
void hdi_gbm_bo_destroy(struct gbm_bo *bo)
|
||||
{
|
||||
int ret;
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((bo == NULL), DISPLAY_LOGE("the bo is null"));
|
||||
struct drm_mode_destroy_dumb dumb = { 0 };
|
||||
dumb.handle = bo->handle;
|
||||
ret = drmIoctl(bo->gbm->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dumb);
|
||||
DISPLAY_CHK_RETURN_NOT_VALUE((ret), DISPLAY_LOGE("dumb buffer destroy failed errno %{public}d", errno));
|
||||
free(bo);
|
||||
}
|
||||
|
||||
int hdi_gbm_bo_get_fd(struct gbm_bo *bo)
|
||||
{
|
||||
int fd, ret;
|
||||
ret = drmPrimeHandleToFD(bo->gbm->fd, bo->handle, DRM_CLOEXEC | DRM_RDWR, &fd);
|
||||
DISPLAY_CHK_RETURN((ret), -1,
|
||||
DISPLAY_LOGE("drmPrimeHandleToFD failed ret: %{public}d errno: %{public}d", ret, errno));
|
||||
return fd;
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HI_GBM_H
|
||||
#define HI_GBM_H
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct gbm_device;
|
||||
struct gbm_bo;
|
||||
|
||||
enum gbm_bo_flags {
|
||||
/* *
|
||||
* Buffer is going to be presented to the screen using an API such as KMS
|
||||
*/
|
||||
GBM_BO_USE_SCANOUT = (1 << 0),
|
||||
/* *
|
||||
* Buffer is going to be used as cursor
|
||||
*/
|
||||
GBM_BO_USE_CURSOR = (1 << 1),
|
||||
/* *
|
||||
* Deprecated
|
||||
*/
|
||||
GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR,
|
||||
/* *
|
||||
* Buffer is to be used for rendering - for example it is going to be used
|
||||
* as the storage for a color buffer
|
||||
*/
|
||||
GBM_BO_USE_RENDERING = (1 << 2),
|
||||
/* *
|
||||
* Deprecated
|
||||
*/
|
||||
GBM_BO_USE_WRITE = (1 << 3),
|
||||
/* *
|
||||
* Buffer is guaranteed to be laid out linearly in memory. That is, the
|
||||
* buffer is laid out as an array with 'height' blocks, each block with
|
||||
* length 'stride'. Each stride is in the same order as the rows of the
|
||||
* buffer. This is intended to be used with buffers that will be accessed
|
||||
* via dma-buf mmap().
|
||||
*/
|
||||
GBM_BO_USE_LINEAR = (1 << 4),
|
||||
/* *
|
||||
* The buffer will be used as a texture that will be sampled from.
|
||||
*/
|
||||
GBM_BO_USE_TEXTURING = (1 << 5),
|
||||
/* *
|
||||
* The buffer will be written to by a camera subsystem.
|
||||
*/
|
||||
GBM_BO_USE_CAMERA_WRITE = (1 << 6),
|
||||
/* *
|
||||
* The buffer will be read from by a camera subsystem.
|
||||
*/
|
||||
GBM_BO_USE_CAMERA_READ = (1 << 7),
|
||||
/* *
|
||||
* Buffer inaccessible to unprivileged users.
|
||||
*/
|
||||
GBM_BO_USE_PROTECTED = (1 << 8),
|
||||
/* *
|
||||
* These flags specify the frequency of software access. These flags do not
|
||||
* guarantee the buffer is linear, but do guarantee gbm_bo_map(..) will
|
||||
* present a linear view.
|
||||
*/
|
||||
GBM_BO_USE_SW_READ_OFTEN = (1 << 9),
|
||||
GBM_BO_USE_SW_READ_RARELY = (1 << 10),
|
||||
GBM_BO_USE_SW_WRITE_OFTEN = (1 << 11),
|
||||
GBM_BO_USE_SW_WRITE_RARELY = (1 << 12),
|
||||
/* *
|
||||
* The buffer will be written by a video decode accelerator.
|
||||
*/
|
||||
GBM_BO_USE_HW_VIDEO_DECODER = (1 << 13),
|
||||
};
|
||||
|
||||
struct gbm_device *hdi_gbm_create_device(int fd);
|
||||
void hdi_gbm_device_destroy(struct gbm_device *gbm);
|
||||
struct gbm_bo *hdi_gbm_bo_create(struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
|
||||
uint32_t hdi_gbm_bo_get_stride(struct gbm_bo *bo);
|
||||
uint32_t hdi_gbm_bo_get_width(struct gbm_bo *bo);
|
||||
uint32_t hdi_gbm_bo_get_height(struct gbm_bo *bo);
|
||||
void hdi_gbm_bo_destroy(struct gbm_bo *bo);
|
||||
int hdi_gbm_bo_get_fd(struct gbm_bo *bo);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif // HI_GBM_H
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef HI_GBM_INTERNEL_H
|
||||
#define HI_GBM_INTERNEL_H
|
||||
|
||||
#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d))
|
||||
#define ALIGN_UP(x, a) ((((x) + ((a)-1)) / (a)) * (a))
|
||||
#define HEIGHT_ALIGN 2U
|
||||
#define WIDTH_ALIGN 8U
|
||||
|
||||
#define MAX_PLANES 3
|
||||
|
||||
struct gbm_device {
|
||||
int fd;
|
||||
};
|
||||
|
||||
struct gbm_bo {
|
||||
struct gbm_device *gbm;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
uint32_t handle;
|
||||
uint32_t stride;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
#endif // HI_GBM_INTERNEL_H
|
||||
@@ -0,0 +1,102 @@
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
|
||||
ohos_prebuilt_shared_library("mesa_gbm") {
|
||||
source = "lib-mesa/libgbm.so.1.0.0"
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
relative_install_dir = "chipsetsdk"
|
||||
subsystem_name = "allwinner_products"
|
||||
part_name = "allwinner_products"
|
||||
symlink_target_name = [
|
||||
"libgbm.so.1",
|
||||
"libgbm.so",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("mesa_egl") {
|
||||
source = "lib-mesa/libEGL.so.1.0.0"
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
relative_install_dir = "chipsetsdk"
|
||||
subsystem_name = "allwinner_products"
|
||||
part_name = "allwinner_products"
|
||||
symlink_target_name = [
|
||||
"libEGL.so.1",
|
||||
"libEGL.so",
|
||||
"libGLESv1.so",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("mesa_glapi") {
|
||||
source = "lib-mesa/libglapi.so.0.0.0"
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
relative_install_dir = "chipsetsdk"
|
||||
subsystem_name = "allwinner_products"
|
||||
part_name = "allwinner_products"
|
||||
symlink_target_name = [
|
||||
"libglapi.so.0",
|
||||
"libglapi.so",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("mesa_glesv1") {
|
||||
source = "lib-mesa/libGLESv1_CM.so.1.1.0"
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
relative_install_dir = "chipsetsdk"
|
||||
subsystem_name = "allwinner_products"
|
||||
part_name = "allwinner_products"
|
||||
symlink_target_name = [
|
||||
"libGLESv1_CM.so.1",
|
||||
"libGLESv1_CM.so",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("mesa_glesv2") {
|
||||
source = "lib-mesa/libGLESv2.so.2.0.0"
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
relative_install_dir = "chipsetsdk"
|
||||
subsystem_name = "allwinner_products"
|
||||
part_name = "allwinner_products"
|
||||
symlink_target_name = [
|
||||
"libGLESv2.so.2",
|
||||
"libGLESv2.so",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("libgallium_dri") {
|
||||
source = "lib-mesa/libgallium_dri.so"
|
||||
install_enable = true
|
||||
install_images = [ chipset_base_dir ]
|
||||
relative_install_dir = "chipsetsdk"
|
||||
subsystem_name = "allwinner_products"
|
||||
part_name = "allwinner_products"
|
||||
symlink_target_name = [
|
||||
"libgallium_dri.so",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("panfrost_dri") {
|
||||
source = "lib-mesa/panfrost_dri.so"
|
||||
install_enable = true
|
||||
install_images = ["system"]
|
||||
subsystem_name = "allwinner_products"
|
||||
part_name = "allwinner_products"
|
||||
symlink_target_name = [
|
||||
"allwinner_dri.so",
|
||||
]
|
||||
}
|
||||
|
||||
group("mesa-gpu") {
|
||||
public_deps = [
|
||||
":mesa_gbm",
|
||||
":mesa_egl",
|
||||
":mesa_glapi",
|
||||
":mesa_glesv1",
|
||||
":mesa_glesv2",
|
||||
":panfrost_dri",
|
||||
]
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
End User License Agreement
|
||||
|
||||
THIS END USER LICENSE AGREEMENT (“AGREEMENT”) IS A LEGAL AGREEMENT BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND Shenzhen Allwinner Online Co., Ltd. (HERE AFTER REFERRED TO AS"AWOL") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS AGREEMENT. AWOL IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS AGREEMENT. BY DOWNDOADING OR BY INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT,AWOL WILL NOT LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE, AND YOU SHALL PROMPTLY DESTROY, DELETE, OR RETURN THE SOFTWARE TO YOUR SUPPLIER.
|
||||
|
||||
“SOFTWARE” means the software in object code provided under the terms of this Agreement.
|
||||
|
||||
Xiangzhou District,Zhuhai,China is the signing place of this Agreement.
|
||||
|
||||
1. GRANT OF LICENSE
|
||||
In consideration of your agreement to abide by the following terms, and subject to the terms and conditions of this Agreement, AWOL hereby grants YOU, a non-transferable, non-exclusive, royalty-free, revocable, worldwide copyright license (without the right to sublicense) to internally use the SOFTWARE and to manufacture, have manufactured, or sell, supply or distribute any products which use or embody any of the SOFTWARE or any of the intellectual property rights therein.
|
||||
|
||||
All rights to the SOFTWARE and all intellectual property rights contained therein are reserved and shall remain the sole and exclusive property of AWOL . The SOFTWARE is licensed but not sold. Except as expressly licensed in Clause 1, in no event shall the license granted in this Clause 1 be construed as granting YOU expressly or by implication, estoppels or otherwise, licenses to any intellectual property rights, including but not limited to patent rights, copyrights, trademark or trade secret in the SOFTWARE.
|
||||
|
||||
|
||||
2. RESTRICTIONS
|
||||
YOU shall reproduce and not remove or obscure any notice incorporated by AWOL in the SOFTWARE to protect AWOL’s intellectual property rights embodied therein.
|
||||
|
||||
YOU shall not decompile, disassemble, or reverse engineer the SOFTWARE.
|
||||
|
||||
YOU shall not distribute the SOFTWARE under an open source license as listed by the Open Source Initiative (a non-profit corporation whose website is www.opensource.org), or other license which requires the source code or object code of the SOFTWARE to be licensed or otherwise shared with any third party.
|
||||
|
||||
3. CONFLICT WITH OPEN SOURCE SOFTWARE LICENSE
|
||||
The SOFTWARE may contain open source software. If the license applied on such open source software has conflict with this Agreement, the license applied on such open source software will prevail and apply to the open source software.
|
||||
|
||||
4. FEEDBACK
|
||||
YOU may choose to provide suggestions, comments, feedback, ideas, modifications or know-how (whether in oral or written form) relating to the use of the SOFTWARE ("Feedback") to AWOL under the terms of this Agreement. YOU hereby grants to AWOL and its affiliates, under all of you and your affiliates’ (as applicable) intellectual property rights, a perpetual, irrevocable, royalty free, non-exclusive, worldwide license to (i) use, copy and modify the Feedback; (ii) sell, supply, or otherwise distribute the Feedback; (iii) design, have designed, manufacture, have manufactured, use, import, sell, and otherwise distribute and dispose of products that incorporate the Feedback; and (iv) sublicense (together with the rights to further sublicense) the rights granted in this paragraph to any third party.
|
||||
|
||||
5. NO WARRANTY
|
||||
YOU AGREE THAT THE SOFTWARE IS PROVIDED BY AWOL ON AN "AS IS" BASIS. AWOL MAKES NO WARRANTY, EXPRESSED OR IMPLIED OR STATUTORY, WITH RESPECT TO ANY OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.
|
||||
|
||||
YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, SOFTWARE APPLICATIONS DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
6. NO LIABILITY
|
||||
PLEASE NOTE THAT YOU SHOULD USE THE SOFTWARE AT YOUR OWN RISK.
|
||||
|
||||
IN NO EVENT SHALL AWOL BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHER LEGAL THEORY, EVEN IF AWOL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF THE SOFTWARE HAS ANY MATERIAL, VERIFIABLE, AND REPRODUCIBLE PROGRAM ERRORS, AWOL SHALL HAVE NO LIABILITY TO MODIFY SUCH ERRORS.
|
||||
|
||||
NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS AGREEMENT, THE MAXIMUM LIABILITY OF AWOL TO YOU IN AGGREGATE FOR ALL CLAIMS MADE AGAINST AWOL IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH THE SUBJECT MATTER OF THIS AGREEMENT SHALL NOT EXCEED THE TOTAL OF SUMS RECEIVED BY AWOL FROM YOU FOR THIS AGREEMENT. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT ENLARGE OR EXTEND THE LIMIT.
|
||||
|
||||
7. CONFIDENTIALITY
|
||||
YOU acknowledge and agree that the SOFTWARE provided under this Agreement contain trade secrets and confidential material of AWOL and YOU agree to maintain all such information in confidence and apply security measures no less stringent than the measures which YOU apply to protect your own like information, but not less than a reasonable degree of care, to prevent their unauthorized disclosure and use. The period of confidentiality shall be indefinite. YOU agree not to use any such information other than in normal use of the SOFTWARE under the license granted in this Agreement.
|
||||
|
||||
8. TERM AND TERMINATION
|
||||
This Agreement shall remain in force until terminated. AWOL may terminate this Agreement at any time with or without any cause. Upon termination of this Agreement, YOU shall immediately stop using the SOFTWARE and confidential information and destroy all copies of the SOFTWARE and confidential information in your possession, together with all documentation and related materials. The provisions of clauses 2, 3, 4, 5, 6, 7,8 and 9 shall survive termination of this Agreement.
|
||||
|
||||
9. GENERAL
|
||||
Any provision of this Agreement which is prohibited or unenforceable in any jurisdiction shall be ineffective to the extent of such prohibition or unenforceability without affecting, impairing or invalidating the remaining provisions hereof.
|
||||
|
||||
The failure by AWOL to enforce any of the provisions of this Agreement, unless waived in writing, shall not constitute a waiver of AWOL's rights to enforce such provision or any other provision of this Agreement in the future.
|
||||
|
||||
This Agreement shall be governed by and construed in accordance with the laws of People’s Republic of China, without reference to the principles of conflicts of laws. Any dispute arising out of or relating to this Agreement shall be submitted to the jurisdiction of the court of the signing place of this Agreement and the parties waive all objections to that jurisdiction and venue.
|
||||
|
||||
---------------------------------------------------------------------
|
||||
Copyright (C) 2022 VYAGOO TECHNOLOGY Co., Ltd. All rights reserved.
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
+26
@@ -0,0 +1,26 @@
|
||||
# Copyright (C) 2021 HiHope 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")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
|
||||
ohos_prebuilt_shared_library("librga") {
|
||||
if (target_cpu == "arm") {
|
||||
source = "lib/librga.z.so"
|
||||
} else if (target_cpu == "arm64") {
|
||||
source = "lib64/librga.z.so"
|
||||
}
|
||||
subsystem_name = "hdf"
|
||||
part_name = "hdf"
|
||||
install_enable = true
|
||||
}
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* Zhiqin Wei <wzq@rock-chips.com>
|
||||
*
|
||||
* 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 _rk_graphic_buffer_h_
|
||||
#define _rk_graphic_buffer_h_
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <system/graphics.h>
|
||||
|
||||
#include <utils/Thread.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include <utils/Atomic.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <android/log.h>
|
||||
#include <utils/Log.h>
|
||||
#include <log/log_main.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "rga.h"
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
int RkRgaGetHandleFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleAttributes(buffer_handle_t handle,
|
||||
std::vector<int> *attrs);
|
||||
int RkRgaGetHandleMapAddress(buffer_handle_t handle,
|
||||
void **buf);
|
||||
#endif //Android
|
||||
|
||||
#endif //_rk_graphic_buffer_h_
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* Zhiqin Wei <wzq@rock-chips.com>
|
||||
*
|
||||
* 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 _rockchip_rga_c_h_
|
||||
#define _rockchip_rga_c_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "rga.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compatible with the old version of C interface.The new
|
||||
* version of the C interface no longer requires users to
|
||||
* initialize rga, so RgaInit and RgaDeInit are just for
|
||||
* compatibility with the old C interface, so please do
|
||||
* not use ctx, because it is usually a NULL.
|
||||
*/
|
||||
#define RgaInit(ctx) ({ \
|
||||
int ret = 0; \
|
||||
ret = c_RkRgaInit(); \
|
||||
c_RkRgaGetContext(ctx); \
|
||||
ret;\
|
||||
})
|
||||
#define RgaDeInit(ctx) { \
|
||||
(void)ctx; /* unused */ \
|
||||
c_RkRgaDeInit(); \
|
||||
}
|
||||
#define RgaBlit(...) c_RkRgaBlit(__VA_ARGS__)
|
||||
#define RgaCollorFill(...) c_RkRgaColorFill(__VA_ARGS__)
|
||||
#define RgaFlush() c_RkRgaFlush()
|
||||
|
||||
int c_RkRgaInit();
|
||||
void c_RkRgaDeInit();
|
||||
void c_RkRgaGetContext(void **ctx);
|
||||
int c_RkRgaBlit(rga_info_t *src, rga_info_t *dst, rga_info_t *src1);
|
||||
int c_RkRgaColorFill(rga_info_t *dst);
|
||||
int c_RkRgaFlush();
|
||||
|
||||
#ifndef ANDROID /* linux */
|
||||
int c_RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||
int c_RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
|
||||
int c_RkRgaGetMmap(bo_t *bo_info);
|
||||
int c_RkRgaUnmap(bo_t *bo_info);
|
||||
int c_RkRgaFree(bo_t *bo_info);
|
||||
int c_RkRgaGetBufferFd(bo_t *bo_info, int *fd);
|
||||
#endif /* #ifndef ANDROID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _rockchip_rga_c_h_ */
|
||||
Executable
+193
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* PutinLee <putin.lee@rock-chips.com>
|
||||
*
|
||||
* 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 _LIBS_RGA_MUTEX_H
|
||||
#define _LIBS_RGA_MUTEX_H
|
||||
|
||||
#ifndef ANDROID
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
// Enable thread safety attributes only with clang.
|
||||
// The attributes can be safely erased when compiling with other compilers.
|
||||
#if defined(__clang__) && (!defined(SWIG))
|
||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
|
||||
#else
|
||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
|
||||
#endif
|
||||
|
||||
#define CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
|
||||
|
||||
#define SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
|
||||
|
||||
#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
|
||||
|
||||
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
|
||||
|
||||
#define ACQUIRED_BEFORE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRED_AFTER(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
|
||||
|
||||
#define REQUIRES(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
|
||||
|
||||
#define REQUIRES_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRE_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define RELEASE(...) THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
|
||||
|
||||
#define RELEASE_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define TRY_ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
|
||||
|
||||
#define TRY_ACQUIRE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
|
||||
|
||||
#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
|
||||
|
||||
#define ASSERT_SHARED_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
|
||||
|
||||
#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
|
||||
|
||||
#define NO_THREAD_SAFETY_ANALYSIS THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
|
||||
|
||||
class Condition;
|
||||
|
||||
/*
|
||||
* NOTE: This class is for code that builds on Win32. Its usage is
|
||||
* deprecated for code which doesn't build for Win32. New code which
|
||||
* doesn't build for Win32 should use std::mutex and std::lock_guard instead.
|
||||
*
|
||||
* Simple mutex class. The implementation is system-dependent.
|
||||
*
|
||||
* The mutex must be unlocked by the thread that locked it. They are not
|
||||
* recursive, i.e. the same thread can't lock it multiple times.
|
||||
*/
|
||||
class CAPABILITY("mutex") Mutex {
|
||||
public:
|
||||
enum {
|
||||
PRIVATE = 0,
|
||||
SHARED = 1
|
||||
};
|
||||
|
||||
Mutex();
|
||||
explicit Mutex(const char* name);
|
||||
explicit Mutex(int type, const char* name = nullptr);
|
||||
~Mutex();
|
||||
|
||||
// lock or unlock the mutex
|
||||
int32_t lock() ACQUIRE();
|
||||
void unlock() RELEASE();
|
||||
|
||||
// lock if possible; returns 0 on success, error otherwise
|
||||
int32_t tryLock() TRY_ACQUIRE(0);
|
||||
|
||||
int32_t timedLock(int64_t timeoutNs) TRY_ACQUIRE(0);
|
||||
|
||||
// Manages the mutex automatically. It'll be locked when Autolock is
|
||||
// constructed and released when Autolock goes out of scope.
|
||||
class SCOPED_CAPABILITY Autolock {
|
||||
public:
|
||||
inline explicit Autolock(Mutex& mutex) ACQUIRE(mutex) : mLock(mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline explicit Autolock(Mutex* mutex) ACQUIRE(mutex) : mLock(*mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline ~Autolock() RELEASE() {
|
||||
mLock.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
Mutex& mLock;
|
||||
// Cannot be copied or moved - declarations only
|
||||
Autolock(const Autolock&);
|
||||
Autolock& operator=(const Autolock&);
|
||||
};
|
||||
|
||||
private:
|
||||
friend class Condition;
|
||||
|
||||
// A mutex cannot be copied
|
||||
Mutex(const Mutex&);
|
||||
Mutex& operator=(const Mutex&);
|
||||
|
||||
pthread_mutex_t mMutex;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline Mutex::Mutex() {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
inline Mutex::Mutex(__attribute__((unused)) const char* name) {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) {
|
||||
if (type == SHARED) {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||
pthread_mutex_init(&mMutex, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
} else {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
}
|
||||
inline Mutex::~Mutex() {
|
||||
pthread_mutex_destroy(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::lock() {
|
||||
return -pthread_mutex_lock(&mMutex);
|
||||
}
|
||||
inline void Mutex::unlock() {
|
||||
pthread_mutex_unlock(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::tryLock() {
|
||||
return -pthread_mutex_trylock(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::timedLock(int64_t timeoutNs) {
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
timeoutNs += now.tv_sec*1000000000 + now.tv_nsec;
|
||||
const struct timespec ts = {
|
||||
/* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),
|
||||
/* .tv_nsec = */ static_cast<long>(timeoutNs % 1000000000),
|
||||
};
|
||||
return -pthread_mutex_timedlock(&mMutex, &ts);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Automatic mutex. Declare one of these at the top of a function.
|
||||
* When the function returns, it will go out of scope, and release the
|
||||
* mutex.
|
||||
*/
|
||||
|
||||
typedef Mutex::Autolock AutoMutex;
|
||||
#endif // __ANDROID_VNDK__
|
||||
#endif // _LIBS_RGA_MUTEX_H
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* Zhiqin Wei <wzq@rock-chips.com>
|
||||
*
|
||||
* 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 _LIBS_RGA_SINGLETON_H
|
||||
#define _LIBS_RGA_SINGLETON_H
|
||||
|
||||
#ifndef ANDROID
|
||||
#include "RgaMutex.h"
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wundefined-var-template"
|
||||
#endif
|
||||
|
||||
template <typename TYPE>
|
||||
class Singleton {
|
||||
public:
|
||||
static TYPE& getInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
TYPE* instance = sInstance;
|
||||
if (instance == nullptr) {
|
||||
instance = new TYPE();
|
||||
sInstance = instance;
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
|
||||
static bool hasInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
return sInstance != nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
~Singleton() { }
|
||||
Singleton() { }
|
||||
|
||||
private:
|
||||
Singleton(const Singleton&);
|
||||
Singleton& operator = (const Singleton&);
|
||||
static Mutex sLock;
|
||||
static TYPE* sInstance;
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#define RGA_SINGLETON_STATIC_INSTANCE(TYPE) \
|
||||
template<> ::Mutex \
|
||||
(::Singleton< TYPE >::sLock)(::Mutex::PRIVATE); \
|
||||
template<> TYPE* ::Singleton< TYPE >::sInstance(nullptr); /* NOLINT */ \
|
||||
template class ::Singleton< TYPE >;
|
||||
|
||||
#endif //ANDROID
|
||||
#endif //_LIBS_RGA_SINGLETON_H
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* Zhiqin Wei <wzq@rock-chips.com>
|
||||
*
|
||||
* 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 _rga_utils_h_
|
||||
#define _rga_utils_h_
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
float get_bpp_from_format(int format);
|
||||
int get_buf_from_file(void *buf, int f, int sw, int sh, int index);
|
||||
int output_buf_data_to_file(void *buf, int f, int sw, int sh, int index);
|
||||
const char *translate_format_str(int format);
|
||||
#endif
|
||||
|
||||
Executable
+110
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* Zhiqin Wei <wzq@rock-chips.com>
|
||||
*
|
||||
* 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 _rockchip_rga_h_
|
||||
#define _rockchip_rga_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "GrallocOps.h"
|
||||
#include "RgaUtils.h"
|
||||
#include "rga.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef ANDROID
|
||||
#include "RgaSingleton.h"
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <utils/Singleton.h>
|
||||
#include <utils/Thread.h>
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
namespace android {
|
||||
#endif
|
||||
|
||||
class RockchipRga :public Singleton<RockchipRga> {
|
||||
public:
|
||||
|
||||
static inline RockchipRga& get() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
int RkRgaInit();
|
||||
void RkRgaDeInit();
|
||||
void RkRgaGetContext(void **ctx);
|
||||
#ifndef ANDROID /* LINUX */
|
||||
int RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
|
||||
int width, int height, int bpp, int flags);
|
||||
int RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
|
||||
int RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
|
||||
int RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetMmap(bo_t *bo_info);
|
||||
int RkRgaUnmap(bo_t *bo_info);
|
||||
int RkRgaFree(bo_t *bo_info);
|
||||
int RkRgaGetBufferFd(bo_t *bo_info, int *fd);
|
||||
#else
|
||||
int RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
|
||||
#endif
|
||||
int RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
|
||||
int RkRgaCollorFill(rga_info *dst);
|
||||
int RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
|
||||
int RkRgaFlush();
|
||||
|
||||
|
||||
void RkRgaSetLogOnceFlag(int log) {
|
||||
mLogOnce = log;
|
||||
}
|
||||
void RkRgaSetAlwaysLogFlag(bool log) {
|
||||
mLogAlways = log;
|
||||
}
|
||||
void RkRgaLogOutRgaReq(struct rga_req rgaReg);
|
||||
int RkRgaLogOutUserPara(rga_info *rgaInfo);
|
||||
inline bool RkRgaIsReady() {
|
||||
return mSupportRga;
|
||||
}
|
||||
|
||||
RockchipRga();
|
||||
~RockchipRga();
|
||||
private:
|
||||
bool mSupportRga;
|
||||
int mLogOnce;
|
||||
int mLogAlways;
|
||||
void * mContext;
|
||||
|
||||
friend class Singleton<RockchipRga>;
|
||||
};
|
||||
|
||||
#ifdef ANDROID
|
||||
}; // namespace android
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+211
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* Zhiqin Wei <wzq@rock-chips.com>
|
||||
*
|
||||
* 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 _rk_drm_rga_
|
||||
#define _rk_drm_rga_
|
||||
|
||||
#include <stdint.h>
|
||||
//#include <sys/cdefs.h>
|
||||
|
||||
#ifdef ANDROID
|
||||
#define DRMRGA_HARDWARE_MODULE_ID "librga"
|
||||
|
||||
#include <hardware/gralloc.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <system/graphics.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#endif
|
||||
|
||||
#ifndef ANDROID /* LINUX */
|
||||
/* flip source image horizontally (around the vertical axis) */
|
||||
#define HAL_TRANSFORM_FLIP_H 0x01
|
||||
/* flip source image vertically (around the horizontal axis)*/
|
||||
#define HAL_TRANSFORM_FLIP_V 0x02
|
||||
/* rotate source image 90 degrees clockwise */
|
||||
#define HAL_TRANSFORM_ROT_90 0x04
|
||||
/* rotate source image 180 degrees */
|
||||
#define HAL_TRANSFORM_ROT_180 0x03
|
||||
/* rotate source image 270 degrees clockwise */
|
||||
#define HAL_TRANSFORM_ROT_270 0x07
|
||||
#endif
|
||||
|
||||
#define HAL_TRANSFORM_FLIP_H_V 0x08
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* for compatibility */
|
||||
#define DRM_RGA_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1
|
||||
#define DRM_RGA_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1
|
||||
#define DRM_RGA_API_VERSION HWC_DEVICE_API_VERSION
|
||||
|
||||
#define DRM_RGA_TRANSFORM_ROT_MASK 0x0000000F
|
||||
#define DRM_RGA_TRANSFORM_ROT_0 0x00000000
|
||||
#define DRM_RGA_TRANSFORM_ROT_90 HAL_TRANSFORM_ROT_90
|
||||
#define DRM_RGA_TRANSFORM_ROT_180 HAL_TRANSFORM_ROT_180
|
||||
#define DRM_RGA_TRANSFORM_ROT_270 HAL_TRANSFORM_ROT_270
|
||||
|
||||
#define DRM_RGA_TRANSFORM_FLIP_MASK 0x00000003
|
||||
#define DRM_RGA_TRANSFORM_FLIP_H HAL_TRANSFORM_FLIP_H
|
||||
#define DRM_RGA_TRANSFORM_FLIP_V HAL_TRANSFORM_FLIP_V
|
||||
|
||||
enum {
|
||||
AWIDTH = 0,
|
||||
AHEIGHT,
|
||||
ASTRIDE,
|
||||
AFORMAT,
|
||||
ASIZE,
|
||||
ATYPE,
|
||||
};
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef ANDROID
|
||||
/* memory type definitions. */
|
||||
enum drm_rockchip_gem_mem_type {
|
||||
/* Physically Continuous memory and used as default. */
|
||||
ROCKCHIP_BO_CONTIG = 1 << 0,
|
||||
/* cachable mapping. */
|
||||
ROCKCHIP_BO_CACHABLE = 1 << 1,
|
||||
/* write-combine mapping. */
|
||||
ROCKCHIP_BO_WC = 1 << 2,
|
||||
ROCKCHIP_BO_SECURE = 1 << 3,
|
||||
ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE |
|
||||
ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE
|
||||
};
|
||||
|
||||
typedef struct bo {
|
||||
int fd;
|
||||
void *ptr;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
size_t pitch;
|
||||
unsigned handle;
|
||||
} bo_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@value size: user not need care about.For avoid read/write out of memory
|
||||
*/
|
||||
typedef struct rga_rect {
|
||||
int xoffset;
|
||||
int yoffset;
|
||||
int width;
|
||||
int height;
|
||||
int wstride;
|
||||
int hstride;
|
||||
int format;
|
||||
int size;
|
||||
} rga_rect_t;
|
||||
|
||||
typedef struct rga_nn {
|
||||
int nn_flag;
|
||||
int scale_r;
|
||||
int scale_g;
|
||||
int scale_b;
|
||||
int offset_r;
|
||||
int offset_g;
|
||||
int offset_b;
|
||||
} rga_nn_t;
|
||||
|
||||
typedef struct rga_dither {
|
||||
int enable;
|
||||
int mode;
|
||||
int lut0_l;
|
||||
int lut0_h;
|
||||
int lut1_l;
|
||||
int lut1_h;
|
||||
} rga_dither_t;
|
||||
|
||||
/*
|
||||
@value fd: use fd to share memory, it can be ion shard fd,and dma fd.
|
||||
@value virAddr:userspace address
|
||||
@value phyAddr:use phy address
|
||||
@value hnd: use buffer_handle_t
|
||||
*/
|
||||
typedef struct rga_info {
|
||||
int fd;
|
||||
void *virAddr;
|
||||
void *phyAddr;
|
||||
#ifndef ANDROID /* LINUX */
|
||||
unsigned hnd;
|
||||
#else /* Android */
|
||||
buffer_handle_t hnd;
|
||||
#endif
|
||||
int format;
|
||||
rga_rect_t rect;
|
||||
unsigned int blend;
|
||||
int bufferSize;
|
||||
int rotation;
|
||||
int color;
|
||||
int testLog;
|
||||
int mmuFlag;
|
||||
int colorkey_en;
|
||||
int colorkey_mode;
|
||||
int colorkey_max;
|
||||
int colorkey_min;
|
||||
int scale_mode;
|
||||
int color_space_mode;
|
||||
int sync_mode;
|
||||
rga_nn_t nn;
|
||||
rga_dither_t dither;
|
||||
int rop_code;
|
||||
int reserve[127];
|
||||
} rga_info_t;
|
||||
|
||||
|
||||
typedef struct drm_rga {
|
||||
rga_rect_t src;
|
||||
rga_rect_t dst;
|
||||
} drm_rga_t;
|
||||
|
||||
/*
|
||||
@fun rga_set_rect:For use to set the rects esayly
|
||||
|
||||
@param rect:The rect user want to set,like setting the src rect:
|
||||
drm_rga_t rects;
|
||||
rga_set_rect(rects.src,0,0,1920,1080,1920,NV12);
|
||||
mean to set the src rect to the value.
|
||||
*/
|
||||
static inline int rga_set_rect(rga_rect_t *rect,
|
||||
int x, int y, int w, int h, int sw, int sh, int f) {
|
||||
if (!rect)
|
||||
return -EINVAL;
|
||||
|
||||
rect->xoffset = x;
|
||||
rect->yoffset = y;
|
||||
rect->width = w;
|
||||
rect->height = h;
|
||||
rect->wstride = sw;
|
||||
rect->hstride = sh;
|
||||
rect->format = f;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef ANDROID /* LINUX */
|
||||
static inline void rga_set_rotation(rga_info_t *info, int angle) {
|
||||
if (angle == 90)
|
||||
info->rotation = HAL_TRANSFORM_ROT_90;
|
||||
else if (angle == 180)
|
||||
info->rotation = HAL_TRANSFORM_ROT_180;
|
||||
else if (angle == 270)
|
||||
info->rotation = HAL_TRANSFORM_ROT_270;
|
||||
}
|
||||
#endif
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
Executable
+892
@@ -0,0 +1,892 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* PutinLee <putin.lee@rock-chips.com>
|
||||
* Cerf Yu <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* 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 _im2d_h_
|
||||
#define _im2d_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef IM_API
|
||||
#define IM_API /* define API export as needed */
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* Rotation */
|
||||
IM_HAL_TRANSFORM_ROT_90 = 1 << 0,
|
||||
IM_HAL_TRANSFORM_ROT_180 = 1 << 1,
|
||||
IM_HAL_TRANSFORM_ROT_270 = 1 << 2,
|
||||
IM_HAL_TRANSFORM_FLIP_H = 1 << 3,
|
||||
IM_HAL_TRANSFORM_FLIP_V = 1 << 4,
|
||||
IM_HAL_TRANSFORM_FLIP_H_V = 1 << 5,
|
||||
IM_HAL_TRANSFORM_MASK = 0x3f,
|
||||
|
||||
/*
|
||||
* Blend
|
||||
* Additional blend usage, can be used with both source and target configs.
|
||||
* If none of the below is set, the default "SRC over DST" is applied.
|
||||
*/
|
||||
IM_ALPHA_BLEND_SRC_OVER = 1 << 6, /* Default, Porter-Duff "SRC over DST" */
|
||||
IM_ALPHA_BLEND_SRC = 1 << 7, /* Porter-Duff "SRC" */
|
||||
IM_ALPHA_BLEND_DST = 1 << 8, /* Porter-Duff "DST" */
|
||||
IM_ALPHA_BLEND_SRC_IN = 1 << 9, /* Porter-Duff "SRC in DST" */
|
||||
IM_ALPHA_BLEND_DST_IN = 1 << 10, /* Porter-Duff "DST in SRC" */
|
||||
IM_ALPHA_BLEND_SRC_OUT = 1 << 11, /* Porter-Duff "SRC out DST" */
|
||||
IM_ALPHA_BLEND_DST_OUT = 1 << 12, /* Porter-Duff "DST out SRC" */
|
||||
IM_ALPHA_BLEND_DST_OVER = 1 << 13, /* Porter-Duff "DST over SRC" */
|
||||
IM_ALPHA_BLEND_SRC_ATOP = 1 << 14, /* Porter-Duff "SRC ATOP" */
|
||||
IM_ALPHA_BLEND_DST_ATOP = 1 << 15, /* Porter-Duff "DST ATOP" */
|
||||
IM_ALPHA_BLEND_XOR = 1 << 16, /* Xor */
|
||||
IM_ALPHA_BLEND_MASK = 0x1ffc0,
|
||||
|
||||
IM_ALPHA_COLORKEY_NORMAL = 1 << 17,
|
||||
IM_ALPHA_COLORKEY_INVERTED = 1 << 18,
|
||||
IM_ALPHA_COLORKEY_MASK = 0x60000,
|
||||
|
||||
IM_SYNC = 1 << 19,
|
||||
IM_ASYNC = 1 << 26,
|
||||
IM_CROP = 1 << 20, /* Unused */
|
||||
IM_COLOR_FILL = 1 << 21,
|
||||
IM_COLOR_PALETTE = 1 << 22,
|
||||
IM_NN_QUANTIZE = 1 << 23,
|
||||
IM_ROP = 1 << 24,
|
||||
IM_ALPHA_BLEND_PRE_MUL = 1 << 25,
|
||||
|
||||
} IM_USAGE;
|
||||
|
||||
typedef enum {
|
||||
IM_ROP_AND = 0x88,
|
||||
IM_ROP_OR = 0xee,
|
||||
IM_ROP_NOT_DST = 0x55,
|
||||
IM_ROP_NOT_SRC = 0x33,
|
||||
IM_ROP_XOR = 0xf6,
|
||||
IM_ROP_NOT_XOR = 0xf9,
|
||||
} IM_ROP_CODE;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_SUPPORT_FORMAT_ERROR_INDEX = 0,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_8_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_10_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_420_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_400_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_Y4_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_MASK_INDEX,
|
||||
} IM_RGA_SUPPORT_FORMAT_INDEX;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_SUPPORT_FORMAT_ERROR = 1 << IM_RGA_SUPPORT_FORMAT_ERROR_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB = 1 << IM_RGA_SUPPORT_FORMAT_RGB_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER = 1 << IM_RGA_SUPPORT_FORMAT_RGB_OTHER_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_BPP = 1 << IM_RGA_SUPPORT_FORMAT_BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_8 = 1 << IM_RGA_SUPPORT_FORMAT_YUV_8_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_10 = 1 << IM_RGA_SUPPORT_FORMAT_YUV_10_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_420 = 1 << IM_RGA_SUPPORT_FORMAT_YUYV_420_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422 = 1 << IM_RGA_SUPPORT_FORMAT_YUYV_422_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_400 = 1 << IM_RGA_SUPPORT_FORMAT_YUV_400_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_Y4 = 1 << IM_RGA_SUPPORT_FORMAT_Y4_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_MASK = ~((~(unsigned int)0x0 << IM_RGA_SUPPORT_FORMAT_MASK_INDEX) | 1),
|
||||
} IM_RGA_SUPPORT_FORMAT;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_SUPPORT_FEATURE_ERROR_INDEX = 0,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_ROP_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_QUANTIZE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MASK_INDEX,
|
||||
} IM_RGA_SUPPORT_FEATURE_INDEX;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_SUPPORT_FEATURE_ERROR = 1 << IM_RGA_SUPPORT_FEATURE_ERROR_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL = 1 << IM_RGA_SUPPORT_FEATURE_COLOR_FILL_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE = 1 << IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_ROP = 1 << IM_RGA_SUPPORT_FEATURE_ROP_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_QUANTIZE = 1 << IM_RGA_SUPPORT_FEATURE_QUANTIZE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC = 1 << IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC = 1 << IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MASK = ~((~(unsigned int)0x0 << IM_RGA_SUPPORT_FEATURE_MASK_INDEX) | 1),
|
||||
} IM_RGA_SUPPORT_FEATURE;
|
||||
|
||||
/* Status codes, returned by any blit function */
|
||||
typedef enum {
|
||||
IM_STATUS_NOERROR = 2,
|
||||
IM_STATUS_SUCCESS = 1,
|
||||
IM_STATUS_NOT_SUPPORTED = -1,
|
||||
IM_STATUS_OUT_OF_MEMORY = -2,
|
||||
IM_STATUS_INVALID_PARAM = -3,
|
||||
IM_STATUS_ILLEGAL_PARAM = -4,
|
||||
IM_STATUS_FAILED = 0,
|
||||
} IM_STATUS;
|
||||
|
||||
/* Status codes, returned by any blit function */
|
||||
typedef enum {
|
||||
IM_YUV_TO_RGB_BT601_LIMIT = 1 << 0,
|
||||
IM_YUV_TO_RGB_BT601_FULL = 2 << 0,
|
||||
IM_YUV_TO_RGB_BT709_LIMIT = 3 << 0,
|
||||
IM_YUV_TO_RGB_MASK = 3 << 0,
|
||||
IM_RGB_TO_YUV_BT601_FULL = 1 << 2,
|
||||
IM_RGB_TO_YUV_BT601_LIMIT = 2 << 2,
|
||||
IM_RGB_TO_YUV_BT709_LIMIT = 3 << 2,
|
||||
IM_RGB_TO_YUV_MASK = 3 << 2,
|
||||
IM_RGB_TO_Y4 = 1 << 4,
|
||||
IM_RGB_TO_Y4_DITHER = 2 << 4,
|
||||
IM_RGB_TO_Y1_DITHER = 3 << 4,
|
||||
IM_Y4_MASK = 3 << 4,
|
||||
IM_RGB_FULL = 1 << 8,
|
||||
IM_RGB_CLIP = 2 << 8,
|
||||
IM_YUV_BT601_LIMIT_RANGE = 3 << 8,
|
||||
IM_YUV_BT601_FULL_RANGE = 4 << 8,
|
||||
IM_YUV_BT709_LIMIT_RANGE = 5 << 8,
|
||||
IM_YUV_BT709_FULL_RANGE = 6 << 8,
|
||||
IM_FULL_CSC_MASK = 0xf << 8,
|
||||
IM_COLOR_SPACE_DEFAULT = 0,
|
||||
} IM_COLOR_SPACE_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_UP_SCALE,
|
||||
IM_DOWN_SCALE,
|
||||
} IM_SCALE;
|
||||
|
||||
typedef enum {
|
||||
INTER_NEAREST,
|
||||
INTER_LINEAR,
|
||||
INTER_CUBIC,
|
||||
} IM_SCALE_MODE;
|
||||
|
||||
/* Get RGA basic information index */
|
||||
typedef enum {
|
||||
RGA_VENDOR = 0,
|
||||
RGA_VERSION,
|
||||
RGA_MAX_INPUT,
|
||||
RGA_MAX_OUTPUT,
|
||||
RGA_SCALE_LIMIT,
|
||||
RGA_INPUT_FORMAT,
|
||||
RGA_OUTPUT_FORMAT,
|
||||
RGA_FEATURE,
|
||||
RGA_EXPECTED,
|
||||
RGA_ALL,
|
||||
} IM_INFORMATION;
|
||||
|
||||
/*rga version index*/
|
||||
typedef enum {
|
||||
RGA_V_ERR = 0x0,
|
||||
RGA_1 = 0x1,
|
||||
RGA_1_PLUS = 0x2,
|
||||
RGA_2 = 0x3,
|
||||
RGA_2_LITE0 = 0x4,
|
||||
RGA_2_LITE1 = 0x5,
|
||||
RGA_2_ENHANCE = 0x6,
|
||||
} RGA_VERSION_NUM;
|
||||
|
||||
//struct AHardwareBuffer AHardwareBuffer;
|
||||
|
||||
typedef struct {
|
||||
RGA_VERSION_NUM version;
|
||||
unsigned int input_resolution;
|
||||
unsigned int output_resolution;
|
||||
unsigned int scale_limit;
|
||||
unsigned int performance;
|
||||
unsigned int input_format;
|
||||
unsigned int output_format;
|
||||
unsigned int feature;
|
||||
char reserved[28];
|
||||
} rga_info_table_entry;
|
||||
|
||||
/* Rectangle definition */
|
||||
typedef struct {
|
||||
int x; /* upper-left x */
|
||||
int y; /* upper-left y */
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
} im_rect;
|
||||
|
||||
typedef struct {
|
||||
int max; /* The Maximum value of the color key */
|
||||
int min; /* The minimum value of the color key */
|
||||
} im_colorkey_range;
|
||||
|
||||
|
||||
typedef struct im_nn {
|
||||
int scale_r; /* scaling factor on R channal */
|
||||
int scale_g; /* scaling factor on G channal */
|
||||
int scale_b; /* scaling factor on B channal */
|
||||
int offset_r; /* offset on R channal */
|
||||
int offset_g; /* offset on G channal */
|
||||
int offset_b; /* offset on B channal */
|
||||
} im_nn_t;
|
||||
|
||||
/* im_info definition */
|
||||
typedef struct {
|
||||
void* vir_addr; /* virtual address */
|
||||
void* phy_addr; /* physical address */
|
||||
int fd; /* shared fd */
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
int wstride; /* wstride */
|
||||
int hstride; /* hstride */
|
||||
int format; /* format */
|
||||
int color_space_mode; /* color_space_mode */
|
||||
int color; /* color, used by color fill */
|
||||
int global_alpha; /* global_alpha */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
} rga_buffer_t;
|
||||
|
||||
/*
|
||||
* @return error message string
|
||||
*/
|
||||
#define imStrError(...) \
|
||||
({ \
|
||||
const char* err; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
err = imStrError_t(IM_STATUS_INVALID_PARAM); \
|
||||
} else if (argc == 1){ \
|
||||
err = imStrError_t((IM_STATUS)args[0]); \
|
||||
} else { \
|
||||
err = ("Fatal error, imStrError() too many parameters\n"); \
|
||||
printf("Fatal error, imStrError() too many parameters\n"); \
|
||||
} \
|
||||
err; \
|
||||
})
|
||||
IM_API const char* imStrError_t(IM_STATUS status);
|
||||
|
||||
/*
|
||||
* @return rga_buffer_t
|
||||
*/
|
||||
#define wrapbuffer_virtualaddr(vir_addr, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t buffer; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
buffer = wrapbuffer_virtualaddr_t(vir_addr, width, height, width, height, format); \
|
||||
} else if (argc == 2){ \
|
||||
buffer = wrapbuffer_virtualaddr_t(vir_addr, width, height, args[0], args[1], format); \
|
||||
} else { \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
buffer; \
|
||||
})
|
||||
|
||||
#define wrapbuffer_physicaladdr(phy_addr, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t buffer; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
buffer = wrapbuffer_physicaladdr_t(phy_addr, width, height, width, height, format); \
|
||||
} else if (argc == 2){ \
|
||||
buffer = wrapbuffer_physicaladdr_t(phy_addr, width, height, args[0], args[1], format); \
|
||||
} else { \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
buffer; \
|
||||
})
|
||||
|
||||
#define wrapbuffer_fd(fd, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t buffer; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
buffer = wrapbuffer_fd_t(fd, width, height, width, height, format); \
|
||||
} else if (argc == 2){ \
|
||||
buffer = wrapbuffer_fd_t(fd, width, height, args[0], args[1], format); \
|
||||
} else { \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
buffer; \
|
||||
})
|
||||
|
||||
IM_API rga_buffer_t wrapbuffer_virtualaddr_t(void* vir_addr, int width, int height, int wstride, int hstride, int format);
|
||||
IM_API rga_buffer_t wrapbuffer_physicaladdr_t(void* phy_addr, int width, int height, int wstride, int hstride, int format);
|
||||
IM_API rga_buffer_t wrapbuffer_fd_t(int fd, int width, int height, int wstride, int hstride, int format);
|
||||
|
||||
/*
|
||||
* Get RGA basic information, supported resolution, supported format, etc.
|
||||
*
|
||||
* @param name
|
||||
* RGA_VENDOR
|
||||
* RGA_VERSION
|
||||
* RGA_MAX_INPUT
|
||||
* RGA_MAX_OUTPUT
|
||||
* RGA_INPUT_FORMAT
|
||||
* RGA_OUTPUT_FORMAT
|
||||
* RGA_EXPECTED
|
||||
* RGA_ALL
|
||||
*
|
||||
* @returns a usage describing properties of RGA.
|
||||
*/
|
||||
//IM_API int rga_get_info(rga_info_table_entry *);
|
||||
IM_API IM_STATUS rga_get_info(rga_info_table_entry *return_table);
|
||||
|
||||
/*
|
||||
* Query RGA basic information, supported resolution, supported format, etc.
|
||||
*
|
||||
* @param name
|
||||
* RGA_VENDOR
|
||||
* RGA_VERSION
|
||||
* RGA_MAX_INPUT
|
||||
* RGA_MAX_OUTPUT
|
||||
* RGA_INPUT_FORMAT
|
||||
* RGA_OUTPUT_FORMAT
|
||||
* RGA_EXPECTED
|
||||
* RGA_ALL
|
||||
*
|
||||
* @returns a string describing properties of RGA.
|
||||
*/
|
||||
IM_API const char* querystring(int name);
|
||||
|
||||
/*
|
||||
* check RGA basic information, supported resolution, supported format, etc.
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param src_rect
|
||||
* @param dst_rect
|
||||
* @param mode_usage
|
||||
*
|
||||
* @returns no error or else negative error code.
|
||||
*/
|
||||
#define imcheck(src, dst, src_rect, dst_rect, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_NOERROR; \
|
||||
rga_buffer_t pat; \
|
||||
im_rect pat_rect; \
|
||||
memset(&pat, 0, sizeof(rga_buffer_t)); \
|
||||
memset(&pat_rect, 0, sizeof(im_rect)); \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, 0); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, args[0]); \
|
||||
} else { \
|
||||
ret = IM_STATUS_FAILED; \
|
||||
printf("check failed\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
#define imcheck_composite(src, dst, pat, src_rect, dst_rect, pat_rect, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_NOERROR; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, 0); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, args[0]); \
|
||||
} else { \
|
||||
ret = IM_STATUS_FAILED; \
|
||||
printf("check failed\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
IM_API IM_STATUS imcheck_t(const rga_buffer_t src, const rga_buffer_t dst, const rga_buffer_t pat,
|
||||
const im_rect src_rect, const im_rect dst_rect, const im_rect pat_rect, const int mdoe_usage);
|
||||
|
||||
/*
|
||||
* Resize
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param fx
|
||||
* @param fy
|
||||
* @param interpolation
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imresize(src, dst, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
double args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(double); \
|
||||
if (argc == 0) { \
|
||||
ret = imresize_t(src, dst, 0, 0, INTER_LINEAR, 1); \
|
||||
} else if (argc == 2){ \
|
||||
ret = imresize_t(src, dst, args[0], args[1], INTER_LINEAR, 1); \
|
||||
} else if (argc == 3){ \
|
||||
ret = imresize_t(src, dst, args[0], args[1], (int)args[2], 1); \
|
||||
} else if (argc == 4){ \
|
||||
ret = imresize_t(src, dst, args[0], args[1], (int)args[2], (int)args[3]); \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
#define impyramid(src, dst, direction) \
|
||||
imresize_t(src, \
|
||||
dst, \
|
||||
direction == IM_UP_SCALE ? 0.5 : 2, \
|
||||
direction == IM_UP_SCALE ? 0.5 : 2, \
|
||||
INTER_LINEAR, 1)
|
||||
|
||||
IM_API IM_STATUS imresize_t(const rga_buffer_t src, rga_buffer_t dst, double fx, double fy, int interpolation, int sync);
|
||||
|
||||
/*
|
||||
* Crop
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param rect
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imcrop(src, dst, rect, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imcrop_t(src, dst, rect, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imcrop_t(src, dst, rect, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
IM_API IM_STATUS imcrop_t(const rga_buffer_t src, rga_buffer_t dst, im_rect rect, int sync);
|
||||
|
||||
/*
|
||||
* rotation
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param rotation
|
||||
* IM_HAL_TRANSFORM_ROT_90
|
||||
* IM_HAL_TRANSFORM_ROT_180
|
||||
* IM_HAL_TRANSFORM_ROT_270
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imrotate(src, dst, rotation, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imrotate_t(src, dst, rotation, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imrotate_t(src, dst, rotation, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
IM_API IM_STATUS imrotate_t(const rga_buffer_t src, rga_buffer_t dst, int rotation, int sync);
|
||||
|
||||
/*
|
||||
* flip
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param mode
|
||||
* IM_HAL_TRANSFORM_FLIP_H
|
||||
* IM_HAL_TRANSFORM_FLIP_V
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imflip(src, dst, mode, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imflip_t(src, dst, mode, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imflip_t(src, dst, mode, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
IM_API IM_STATUS imflip_t (const rga_buffer_t src, rga_buffer_t dst, int mode, int sync);
|
||||
|
||||
/*
|
||||
* fill/reset/draw
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param rect
|
||||
* @param color
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imfill(buf, rect, color, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imfill_t(buf, rect, color, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imfill_t(buf, rect, color, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
#define imreset(buf, rect, color, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imfill_t(buf, rect, color, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imfill_t(buf, rect, color, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
#define imdraw(buf, rect, color, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imfill_t(buf, rect, color, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imfill_t(buf, rect, color, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
IM_API IM_STATUS imfill_t(rga_buffer_t dst, im_rect rect, int color, int sync);
|
||||
|
||||
/*
|
||||
* palette
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param lut
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define impalette(src, dst, lut, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = impalette_t(src, dst, lut, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = impalette_t(src, dst, lut, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
IM_API IM_STATUS impalette_t(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t lut, int sync);
|
||||
|
||||
/*
|
||||
* translate
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param x
|
||||
* @param y
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imtranslate(src, dst, x, y, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imtranslate_t(src, dst, x, y, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imtranslate_t(src, dst, x, y, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
IM_API IM_STATUS imtranslate_t(const rga_buffer_t src, rga_buffer_t dst, int x, int y, int sync);
|
||||
|
||||
/*
|
||||
* copy
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imcopy(src, dst, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imcopy_t(src, dst, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imcopy_t(src, dst, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
IM_API IM_STATUS imcopy_t(const rga_buffer_t src, rga_buffer_t dst, int sync);
|
||||
|
||||
/*
|
||||
* blend (SRC + DST -> DST or SRCA + SRCB -> DST)
|
||||
*
|
||||
* @param srcA
|
||||
* @param srcB can be NULL.
|
||||
* @param dst
|
||||
* @param mode
|
||||
* IM_ALPHA_BLEND_MODE
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imblend(srcA, dst, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
rga_buffer_t srcB; \
|
||||
memset(&srcB, 0x00, sizeof(rga_buffer_t)); \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imblend_t(srcA, srcB, dst, IM_ALPHA_BLEND_SRC_OVER, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imblend_t(srcA, srcB, dst, args[0], 1); \
|
||||
} else if (argc == 2){ \
|
||||
ret = imblend_t(srcA, srcB, dst, args[0], args[1]); \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
#define imcomposite(srcA, srcB, dst, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imblend_t(srcA, srcB, dst, IM_ALPHA_BLEND_SRC_OVER, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imblend_t(srcA, srcB, dst, args[0], 1); \
|
||||
} else if (argc == 2){ \
|
||||
ret = imblend_t(srcA, srcB, dst, args[0], args[1]); \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
IM_API IM_STATUS imblend_t(const rga_buffer_t srcA, const rga_buffer_t srcB, rga_buffer_t dst, int mode, int sync);
|
||||
|
||||
/*
|
||||
* color key
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param colorkey_range
|
||||
* max color
|
||||
* min color
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imcolorkey(src, dst, range, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imcolorkey_t(src, dst, range, IM_ALPHA_COLORKEY_NORMAL, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imcolorkey_t(src, dst, range, args[0], 1); \
|
||||
} else if (argc == 2){ \
|
||||
ret = imcolorkey_t(src, dst, range, args[0], args[1]); \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
IM_API IM_STATUS imcolorkey_t(const rga_buffer_t src, rga_buffer_t dst, im_colorkey_range range, int mode, int sync);
|
||||
|
||||
/*
|
||||
* format convert
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param sfmt
|
||||
* @param dfmt
|
||||
* @param mode
|
||||
* color space mode: IM_COLOR_SPACE_MODE
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imcvtcolor(src, dst, sfmt, dfmt, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imcvtcolor_t(src, dst, sfmt, dfmt, IM_COLOR_SPACE_DEFAULT, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imcvtcolor_t(src, dst, sfmt, dfmt, args[0], 1); \
|
||||
} else if (argc == 2){ \
|
||||
ret = imcvtcolor_t(src, dst, sfmt, dfmt, args[0], args[1]); \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
IM_API IM_STATUS imcvtcolor_t(rga_buffer_t src, rga_buffer_t dst, int sfmt, int dfmt, int mode, int sync);
|
||||
|
||||
/*
|
||||
* nn quantize
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param nninfo
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imquantize(src, dst, nn_info, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imquantize_t(src, dst, nn_info, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imquantize_t(src, dst, nn_info, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
|
||||
IM_API IM_STATUS imquantize_t(const rga_buffer_t src, rga_buffer_t dst, im_nn_t nn_info, int sync);
|
||||
|
||||
/*
|
||||
* ROP
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param rop_code
|
||||
* @param sync
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
#define imrop(src, dst, rop_code, ...) \
|
||||
({ \
|
||||
IM_STATUS ret = IM_STATUS_SUCCESS; \
|
||||
int args[] = {__VA_ARGS__}; \
|
||||
int argc = sizeof(args)/sizeof(int); \
|
||||
if (argc == 0) { \
|
||||
ret = imrop_t(src, dst, rop_code, 1); \
|
||||
} else if (argc == 1){ \
|
||||
ret = imrop_t(src, dst, rop_code, args[0]);; \
|
||||
} else { \
|
||||
ret = IM_STATUS_INVALID_PARAM; \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
IM_API IM_STATUS imrop_t(const rga_buffer_t src, rga_buffer_t dst, int rop_code, int sync);
|
||||
|
||||
/*
|
||||
* process
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @param usage
|
||||
* @param ...
|
||||
* wait until operation complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS improcess(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat, im_rect srect, im_rect drect, im_rect prect, int usage);
|
||||
|
||||
/*
|
||||
* block until all execution is complete
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imsync(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _im2d_h_ */
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2018 RockChip Limited. 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.
|
||||
*/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------
|
||||
* File: platform_gralloc4.h
|
||||
*
|
||||
* Desc: 声明对 buffer_handle_t 实例的 get metadata, import_buffer/free_buffer, lock_buffer/unlock_buffer 等接口.
|
||||
* 这些接口都将基于 IMapper 4.0 (gralloc 4.0) 实现.
|
||||
*
|
||||
* -----------------------------------------------------------------------------------
|
||||
* < 习语 和 缩略语 > :
|
||||
*
|
||||
* -----------------------------------------------------------------------------------
|
||||
* Usage:
|
||||
*
|
||||
* Note:
|
||||
*
|
||||
* Author: ChenZhen
|
||||
*
|
||||
* Log:
|
||||
* init.
|
||||
----Fri Aug 28 10:10:14 2020
|
||||
*
|
||||
* --------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __PLATFORM_GRALLOC4_H__
|
||||
#define __PLATFORM_GRALLOC4_H__
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Include Files
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
// #include <linux/kernel.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#include <ui/PixelFormat.h>
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Macros Definition
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
namespace gralloc4 {
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Types and Structures Definition
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Global Functions' Prototype
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* 获取 'handle' 引用的 graphic_buffer 的 internal_format.
|
||||
*/
|
||||
uint64_t get_internal_format(buffer_handle_t handle);
|
||||
|
||||
int get_width(buffer_handle_t handle, uint64_t* width);
|
||||
|
||||
int get_height(buffer_handle_t handle, uint64_t* height);
|
||||
|
||||
int get_pixel_stride(buffer_handle_t handle, int* pixel_stride);
|
||||
|
||||
int get_byte_stride(buffer_handle_t handle, int* byte_stride);
|
||||
|
||||
int get_format_requested(buffer_handle_t handle, int* format_requested);
|
||||
|
||||
int get_usage(buffer_handle_t handle, uint64_t* usage);
|
||||
|
||||
int get_allocation_size(buffer_handle_t handle, uint64_t* usage);
|
||||
|
||||
int get_share_fd(buffer_handle_t handle, int* share_fd);
|
||||
|
||||
using android::status_t;
|
||||
|
||||
status_t importBuffer(buffer_handle_t rawHandle, buffer_handle_t* outHandle);
|
||||
|
||||
void freeBuffer(buffer_handle_t handle);
|
||||
|
||||
status_t lock(buffer_handle_t bufferHandle,
|
||||
uint64_t usage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
void** outData);
|
||||
|
||||
void unlock(buffer_handle_t bufferHandle);
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Inline Functions Implementation
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
#endif /* __PLATFORM_GRALLOC4_H__ */
|
||||
|
||||
Executable
+795
@@ -0,0 +1,795 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* Zhiqin Wei <wzq@rock-chips.com>
|
||||
*
|
||||
* 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 _RGA_DRIVER_H_
|
||||
#define _RGA_DRIVER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define RGA_BLIT_SYNC 0x5017
|
||||
#define RGA_BLIT_ASYNC 0x5018
|
||||
#define RGA_FLUSH 0x5019
|
||||
#define RGA_GET_RESULT 0x501a
|
||||
#define RGA_GET_VERSION 0x501b
|
||||
|
||||
#define RGA2_BLIT_SYNC 0x6017
|
||||
#define RGA2_BLIT_ASYNC 0x6018
|
||||
#define RGA2_FLUSH 0x6019
|
||||
#define RGA2_GET_RESULT 0x601a
|
||||
#define RGA2_GET_VERSION 0x601b
|
||||
#define RGA2_GET_VERSION 0x601b
|
||||
|
||||
#define RGA_REG_CTRL_LEN 0x8 /* 8 */
|
||||
#define RGA_REG_CMD_LEN 0x1c /* 28 */
|
||||
#define RGA_CMD_BUF_SIZE 0x700 /* 16*28*4 */
|
||||
|
||||
|
||||
|
||||
#ifndef ENABLE
|
||||
#define ENABLE 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef DISABLE
|
||||
#define DISABLE 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* RGA process mode enum */
|
||||
enum {
|
||||
bitblt_mode = 0x0,
|
||||
color_palette_mode = 0x1,
|
||||
color_fill_mode = 0x2,
|
||||
line_point_drawing_mode = 0x3,
|
||||
blur_sharp_filter_mode = 0x4,
|
||||
pre_scaling_mode = 0x5,
|
||||
update_palette_table_mode = 0x6,
|
||||
update_patten_buff_mode = 0x7,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
rop_enable_mask = 0x2,
|
||||
dither_enable_mask = 0x8,
|
||||
fading_enable_mask = 0x10,
|
||||
PD_enbale_mask = 0x20,
|
||||
};
|
||||
|
||||
enum {
|
||||
yuv2rgb_mode0 = 0x0, /* BT.601 MPEG */
|
||||
yuv2rgb_mode1 = 0x1, /* BT.601 JPEG */
|
||||
yuv2rgb_mode2 = 0x2, /* BT.709 */
|
||||
|
||||
rgb2yuv_601_full = 0x1 << 8,
|
||||
rgb2yuv_709_full = 0x2 << 8,
|
||||
yuv2yuv_601_limit_2_709_limit = 0x3 << 8,
|
||||
yuv2yuv_601_limit_2_709_full = 0x4 << 8,
|
||||
yuv2yuv_709_limit_2_601_limit = 0x5 << 8,
|
||||
yuv2yuv_709_limit_2_601_full = 0x6 << 8, //not support
|
||||
yuv2yuv_601_full_2_709_limit = 0x7 << 8,
|
||||
yuv2yuv_601_full_2_709_full = 0x8 << 8, //not support
|
||||
yuv2yuv_709_full_2_601_limit = 0x9 << 8, //not support
|
||||
yuv2yuv_709_full_2_601_full = 0xa << 8, //not support
|
||||
full_csc_mask = 0xf00,
|
||||
};
|
||||
|
||||
/* RGA rotate mode */
|
||||
enum {
|
||||
rotate_mode0 = 0x0, /* no rotate */
|
||||
rotate_mode1 = 0x1, /* rotate */
|
||||
rotate_mode2 = 0x2, /* x_mirror */
|
||||
rotate_mode3 = 0x3, /* y_mirror */
|
||||
};
|
||||
|
||||
enum {
|
||||
color_palette_mode0 = 0x0, /* 1K */
|
||||
color_palette_mode1 = 0x1, /* 2K */
|
||||
color_palette_mode2 = 0x2, /* 4K */
|
||||
color_palette_mode3 = 0x3, /* 8K */
|
||||
};
|
||||
|
||||
enum {
|
||||
BB_BYPASS = 0x0, /* no rotate */
|
||||
BB_ROTATE = 0x1, /* rotate */
|
||||
BB_X_MIRROR = 0x2, /* x_mirror */
|
||||
BB_Y_MIRROR = 0x3 /* y_mirror */
|
||||
};
|
||||
|
||||
enum {
|
||||
nearby = 0x0, /* no rotate */
|
||||
bilinear = 0x1, /* rotate */
|
||||
bicubic = 0x2, /* x_mirror */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// Alpha Red Green Blue
|
||||
{ 4, 32, {{32,24, 8, 0, 16, 8, 24,16 }}, GGL_RGBA }, // RK_FORMAT_RGBA_8888
|
||||
{ 4, 24, {{ 0, 0, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, // RK_FORMAT_RGBX_8888
|
||||
{ 3, 24, {{ 0, 0, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, // RK_FORMAT_RGB_888
|
||||
{ 4, 32, {{32,24, 24,16, 16, 8, 8, 0 }}, GGL_BGRA }, // RK_FORMAT_BGRA_8888
|
||||
{ 2, 16, {{ 0, 0, 16,11, 11, 5, 5, 0 }}, GGL_RGB }, // RK_FORMAT_RGB_565
|
||||
{ 2, 16, {{ 1, 0, 16,11, 11, 6, 6, 1 }}, GGL_RGBA }, // RK_FORMAT_RGBA_5551
|
||||
{ 2, 16, {{ 4, 0, 16,12, 12, 8, 8, 4 }}, GGL_RGBA }, // RK_FORMAT_RGBA_4444
|
||||
{ 3, 24, {{ 0, 0, 24,16, 16, 8, 8, 0 }}, GGL_BGR }, // RK_FORMAT_BGB_888
|
||||
|
||||
*/
|
||||
/* In order to be compatible with RK_FORMAT_XX and HAL_PIXEL_FORMAT_XX,
|
||||
* RK_FORMAT_XX is shifted to the left by 8 bits to distinguish. */
|
||||
typedef enum _Rga_SURF_FORMAT {
|
||||
RK_FORMAT_RGBA_8888 = 0x0 << 8,
|
||||
RK_FORMAT_RGBX_8888 = 0x1 << 8,
|
||||
RK_FORMAT_RGB_888 = 0x2 << 8,
|
||||
RK_FORMAT_BGRA_8888 = 0x3 << 8,
|
||||
RK_FORMAT_RGB_565 = 0x4 << 8,
|
||||
RK_FORMAT_RGBA_5551 = 0x5 << 8,
|
||||
RK_FORMAT_RGBA_4444 = 0x6 << 8,
|
||||
RK_FORMAT_BGR_888 = 0x7 << 8,
|
||||
|
||||
RK_FORMAT_YCbCr_422_SP = 0x8 << 8,
|
||||
RK_FORMAT_YCbCr_422_P = 0x9 << 8,
|
||||
RK_FORMAT_YCbCr_420_SP = 0xa << 8,
|
||||
RK_FORMAT_YCbCr_420_P = 0xb << 8,
|
||||
|
||||
RK_FORMAT_YCrCb_422_SP = 0xc << 8,
|
||||
RK_FORMAT_YCrCb_422_P = 0xd << 8,
|
||||
RK_FORMAT_YCrCb_420_SP = 0xe << 8,
|
||||
RK_FORMAT_YCrCb_420_P = 0xf << 8,
|
||||
|
||||
RK_FORMAT_BPP1 = 0x10 << 8,
|
||||
RK_FORMAT_BPP2 = 0x11 << 8,
|
||||
RK_FORMAT_BPP4 = 0x12 << 8,
|
||||
RK_FORMAT_BPP8 = 0x13 << 8,
|
||||
|
||||
RK_FORMAT_Y4 = 0x14 << 8,
|
||||
RK_FORMAT_YCbCr_400 = 0x15 << 8,
|
||||
|
||||
RK_FORMAT_BGRX_8888 = 0x16 << 8,
|
||||
|
||||
RK_FORMAT_YVYU_422 = 0x18 << 8,
|
||||
RK_FORMAT_YVYU_420 = 0x19 << 8,
|
||||
RK_FORMAT_VYUY_422 = 0x1a << 8,
|
||||
RK_FORMAT_VYUY_420 = 0x1b << 8,
|
||||
RK_FORMAT_YUYV_422 = 0x1c << 8,
|
||||
RK_FORMAT_YUYV_420 = 0x1d << 8,
|
||||
RK_FORMAT_UYVY_422 = 0x1e << 8,
|
||||
RK_FORMAT_UYVY_420 = 0x1f << 8,
|
||||
|
||||
RK_FORMAT_YCbCr_420_SP_10B = 0x20 << 8,
|
||||
RK_FORMAT_YCrCb_420_SP_10B = 0x21 << 8,
|
||||
RK_FORMAT_YCbCr_422_10b_SP = 0x22 << 8,
|
||||
RK_FORMAT_YCrCb_422_10b_SP = 0x23 << 8,
|
||||
|
||||
RK_FORMAT_BGR_565 = 0x24 << 8,
|
||||
RK_FORMAT_BGRA_5551 = 0x25 << 8,
|
||||
RK_FORMAT_BGRA_4444 = 0x26 << 8,
|
||||
RK_FORMAT_UNKNOWN = 0x100 << 8,
|
||||
} RgaSURF_FORMAT;
|
||||
|
||||
|
||||
typedef struct rga_img_info_t {
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
unsigned long yrgb_addr; /* yrgb mem addr */
|
||||
unsigned long uv_addr; /* cb/cr mem addr */
|
||||
unsigned long v_addr; /* cr mem addr */
|
||||
#else
|
||||
unsigned int yrgb_addr; /* yrgb mem addr */
|
||||
unsigned int uv_addr; /* cb/cr mem addr */
|
||||
unsigned int v_addr; /* cr mem addr */
|
||||
#endif
|
||||
unsigned int format; //definition by RK_FORMAT
|
||||
unsigned short act_w;
|
||||
unsigned short act_h;
|
||||
unsigned short x_offset;
|
||||
unsigned short y_offset;
|
||||
|
||||
unsigned short vir_w;
|
||||
unsigned short vir_h;
|
||||
|
||||
unsigned short endian_mode; //for BPP
|
||||
unsigned short alpha_swap;
|
||||
}
|
||||
rga_img_info_t;
|
||||
|
||||
|
||||
typedef struct mdp_img_act {
|
||||
unsigned short w; // width
|
||||
unsigned short h; // height
|
||||
short x_off; // x offset for the vir
|
||||
short y_off; // y offset for the vir
|
||||
}
|
||||
mdp_img_act;
|
||||
|
||||
|
||||
|
||||
typedef struct RANGE {
|
||||
unsigned short min;
|
||||
unsigned short max;
|
||||
}
|
||||
RANGE;
|
||||
|
||||
typedef struct POINT {
|
||||
unsigned short x;
|
||||
unsigned short y;
|
||||
}
|
||||
POINT;
|
||||
|
||||
typedef struct RECT {
|
||||
unsigned short xmin;
|
||||
unsigned short xmax; // width - 1
|
||||
unsigned short ymin;
|
||||
unsigned short ymax; // height - 1
|
||||
} RECT;
|
||||
|
||||
typedef struct RGB {
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
unsigned char res;
|
||||
}RGB;
|
||||
|
||||
|
||||
typedef struct MMU {
|
||||
unsigned char mmu_en;
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
unsigned long base_addr;
|
||||
#else
|
||||
unsigned int base_addr;
|
||||
#endif
|
||||
unsigned int mmu_flag; /* [0] mmu enable [1] src_flush [2] dst_flush [3] CMD_flush [4~5] page size*/
|
||||
} MMU;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct COLOR_FILL {
|
||||
short gr_x_a;
|
||||
short gr_y_a;
|
||||
short gr_x_b;
|
||||
short gr_y_b;
|
||||
short gr_x_g;
|
||||
short gr_y_g;
|
||||
short gr_x_r;
|
||||
short gr_y_r;
|
||||
|
||||
//u8 cp_gr_saturation;
|
||||
}
|
||||
COLOR_FILL;
|
||||
|
||||
typedef struct FADING {
|
||||
unsigned char b;
|
||||
unsigned char g;
|
||||
unsigned char r;
|
||||
unsigned char res;
|
||||
}
|
||||
FADING;
|
||||
|
||||
|
||||
typedef struct line_draw_t {
|
||||
POINT start_point; /* LineDraw_start_point */
|
||||
POINT end_point; /* LineDraw_end_point */
|
||||
unsigned int color; /* LineDraw_color */
|
||||
unsigned int flag; /* (enum) LineDrawing mode sel */
|
||||
unsigned int line_width; /* range 1~16 */
|
||||
}
|
||||
line_draw_t;
|
||||
|
||||
/* color space convert coefficient. */
|
||||
typedef struct csc_coe_t {
|
||||
int16_t r_v;
|
||||
int16_t g_y;
|
||||
int16_t b_u;
|
||||
int32_t off;
|
||||
} csc_coe_t;
|
||||
|
||||
typedef struct full_csc_t {
|
||||
unsigned char flag;
|
||||
csc_coe_t coe_y;
|
||||
csc_coe_t coe_u;
|
||||
csc_coe_t coe_v;
|
||||
} full_csc_t;
|
||||
|
||||
struct rga_req {
|
||||
unsigned char render_mode; /* (enum) process mode sel */
|
||||
|
||||
rga_img_info_t src; /* src image info */
|
||||
rga_img_info_t dst; /* dst image info */
|
||||
rga_img_info_t pat; /* patten image info */
|
||||
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
unsigned long rop_mask_addr; /* rop4 mask addr */
|
||||
unsigned long LUT_addr; /* LUT addr */
|
||||
#else
|
||||
unsigned int rop_mask_addr; /* rop4 mask addr */
|
||||
unsigned int LUT_addr; /* LUT addr */
|
||||
#endif
|
||||
|
||||
RECT clip; /* dst clip window default value is dst_vir */
|
||||
/* value from [0, w-1] / [0, h-1]*/
|
||||
|
||||
int sina; /* dst angle default value 0 16.16 scan from table */
|
||||
int cosa; /* dst angle default value 0 16.16 scan from table */
|
||||
|
||||
unsigned short alpha_rop_flag; /* alpha rop process flag */
|
||||
/* ([0] = 1 alpha_rop_enable) */
|
||||
/* ([1] = 1 rop enable) */
|
||||
/* ([2] = 1 fading_enable) */
|
||||
/* ([3] = 1 PD_enable) */
|
||||
/* ([4] = 1 alpha cal_mode_sel) */
|
||||
/* ([5] = 1 dither_enable) */
|
||||
/* ([6] = 1 gradient fill mode sel) */
|
||||
/* ([7] = 1 AA_enable) */
|
||||
/* ([8] = 1 nn_quantize) */
|
||||
/* ([9] = 1 Real color mode) */
|
||||
|
||||
unsigned char scale_mode; /* 0 nearst / 1 bilnear / 2 bicubic */
|
||||
|
||||
unsigned int color_key_max; /* color key max */
|
||||
unsigned int color_key_min; /* color key min */
|
||||
|
||||
unsigned int fg_color; /* foreground color */
|
||||
unsigned int bg_color; /* background color */
|
||||
|
||||
COLOR_FILL gr_color; /* color fill use gradient */
|
||||
|
||||
line_draw_t line_draw_info;
|
||||
|
||||
FADING fading;
|
||||
|
||||
unsigned char PD_mode; /* porter duff alpha mode sel */
|
||||
|
||||
unsigned char alpha_global_value; /* global alpha value */
|
||||
|
||||
unsigned short rop_code; /* rop2/3/4 code scan from rop code table*/
|
||||
|
||||
unsigned char bsfilter_flag; /* [2] 0 blur 1 sharp / [1:0] filter_type*/
|
||||
|
||||
unsigned char palette_mode; /* (enum) color palatte 0/1bpp, 1/2bpp 2/4bpp 3/8bpp*/
|
||||
|
||||
unsigned char yuv2rgb_mode; /* (enum) BT.601 MPEG / BT.601 JPEG / BT.709 */
|
||||
|
||||
unsigned char endian_mode; /* 0/big endian 1/little endian*/
|
||||
|
||||
unsigned char rotate_mode; /* (enum) rotate mode */
|
||||
/* 0x0, no rotate */
|
||||
/* 0x1, rotate */
|
||||
/* 0x2, x_mirror */
|
||||
/* 0x3, y_mirror */
|
||||
|
||||
unsigned char color_fill_mode; /* 0 solid color / 1 patten color */
|
||||
|
||||
MMU mmu_info; /* mmu information */
|
||||
|
||||
unsigned char alpha_rop_mode; /* ([0~1] alpha mode) */
|
||||
/* ([2~3] rop mode) */
|
||||
/* ([4] zero mode en) */
|
||||
/* ([5] dst alpha mode) (RGA1) */
|
||||
|
||||
unsigned char src_trans_mode;
|
||||
|
||||
unsigned char dither_mode;
|
||||
|
||||
full_csc_t full_csc; /* full color space convert */
|
||||
|
||||
unsigned char CMD_fin_int_enable;
|
||||
|
||||
/* completion is reported through a callback */
|
||||
void (*complete)(int retval);
|
||||
};
|
||||
|
||||
#if 0
|
||||
typedef struct TILE_INFO {
|
||||
int64_t matrix[4];
|
||||
|
||||
uint16_t tile_x_num; /* x axis tile num / tile size is 8x8 pixel */
|
||||
uint16_t tile_y_num; /* y axis tile num */
|
||||
|
||||
int16_t dst_x_tmp; /* dst pos x = (xstart - xoff) default value 0 */
|
||||
int16_t dst_y_tmp; /* dst pos y = (ystart - yoff) default value 0 */
|
||||
|
||||
uint16_t tile_w;
|
||||
uint16_t tile_h;
|
||||
int16_t tile_start_x_coor;
|
||||
int16_t tile_start_y_coor;
|
||||
int32_t tile_xoff;
|
||||
int32_t tile_yoff;
|
||||
|
||||
int32_t tile_temp_xstart;
|
||||
int32_t tile_temp_ystart;
|
||||
|
||||
/* src tile incr */
|
||||
int32_t x_dx;
|
||||
int32_t x_dy;
|
||||
int32_t y_dx;
|
||||
int32_t y_dy;
|
||||
|
||||
mdp_img_act dst_ctrl;
|
||||
|
||||
}
|
||||
TILE_INFO;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
#define RGA_BASE 0x10114000
|
||||
|
||||
//General Registers
|
||||
#define RGA_SYS_CTRL 0x000
|
||||
#define RGA_CMD_CTRL 0x004
|
||||
#define RGA_CMD_ADDR 0x008
|
||||
#define RGA_STATUS 0x00c
|
||||
#define RGA_INT 0x010
|
||||
#define RGA_AXI_ID 0x014
|
||||
#define RGA_MMU_STA_CTRL 0x018
|
||||
#define RGA_MMU_STA 0x01c
|
||||
|
||||
//Command code start
|
||||
#define RGA_MODE_CTRL 0x100
|
||||
|
||||
//Source Image Registers
|
||||
#define RGA_SRC_Y_MST 0x104
|
||||
#define RGA_SRC_CB_MST 0x108
|
||||
#define RGA_MASK_READ_MST 0x108 //repeat
|
||||
#define RGA_SRC_CR_MST 0x10c
|
||||
#define RGA_SRC_VIR_INFO 0x110
|
||||
#define RGA_SRC_ACT_INFO 0x114
|
||||
#define RGA_SRC_X_PARA 0x118
|
||||
#define RGA_SRC_Y_PARA 0x11c
|
||||
#define RGA_SRC_TILE_XINFO 0x120
|
||||
#define RGA_SRC_TILE_YINFO 0x124
|
||||
#define RGA_SRC_TILE_H_INCR 0x128
|
||||
#define RGA_SRC_TILE_V_INCR 0x12c
|
||||
#define RGA_SRC_TILE_OFFSETX 0x130
|
||||
#define RGA_SRC_TILE_OFFSETY 0x134
|
||||
#define RGA_SRC_BG_COLOR 0x138
|
||||
#define RGA_SRC_FG_COLOR 0x13c
|
||||
#define RGA_LINE_DRAWING_COLOR 0x13c //repeat
|
||||
#define RGA_SRC_TR_COLOR0 0x140
|
||||
#define RGA_CP_GR_A 0x140 //repeat
|
||||
#define RGA_SRC_TR_COLOR1 0x144
|
||||
#define RGA_CP_GR_B 0x144 //repeat
|
||||
|
||||
#define RGA_LINE_DRAW 0x148
|
||||
#define RGA_PAT_START_POINT 0x148 //repeat
|
||||
|
||||
//Destination Image Registers
|
||||
#define RGA_DST_MST 0x14c
|
||||
#define RGA_LUT_MST 0x14c //repeat
|
||||
#define RGA_PAT_MST 0x14c //repeat
|
||||
#define RGA_LINE_DRAWING_MST 0x14c //repeat
|
||||
|
||||
#define RGA_DST_VIR_INFO 0x150
|
||||
|
||||
#define RGA_DST_CTR_INFO 0x154
|
||||
#define RGA_LINE_DRAW_XY_INFO 0x154 //repeat
|
||||
|
||||
//Alpha/ROP Registers
|
||||
#define RGA_ALPHA_CON 0x158
|
||||
|
||||
#define RGA_PAT_CON 0x15c
|
||||
#define RGA_DST_VIR_WIDTH_PIX 0x15c //repeat
|
||||
|
||||
#define RGA_ROP_CON0 0x160
|
||||
#define RGA_CP_GR_G 0x160 //repeat
|
||||
#define RGA_PRESCL_CB_MST 0x160 //repeat
|
||||
|
||||
#define RGA_ROP_CON1 0x164
|
||||
#define RGA_CP_GR_R 0x164 //repeat
|
||||
#define RGA_PRESCL_CR_MST 0x164 //repeat
|
||||
|
||||
//MMU Register
|
||||
#define RGA_FADING_CON 0x168
|
||||
#define RGA_MMU_CTRL 0x168 //repeat
|
||||
|
||||
#define RGA_MMU_TBL 0x16c //repeat
|
||||
|
||||
|
||||
#define RGA_BLIT_COMPLETE_EVENT 1
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
RGA_set_src_act_info(
|
||||
struct rga_req *req,
|
||||
unsigned int width, /* act width */
|
||||
unsigned int height, /* act height */
|
||||
unsigned int x_off, /* x_off */
|
||||
unsigned int y_off /* y_off */
|
||||
);
|
||||
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
int
|
||||
RGA_set_src_vir_info(
|
||||
struct rga_req *req,
|
||||
unsigned long yrgb_addr, /* yrgb_addr */
|
||||
unsigned long uv_addr, /* uv_addr */
|
||||
unsigned long v_addr, /* v_addr */
|
||||
unsigned int vir_w, /* vir width */
|
||||
unsigned int vir_h, /* vir height */
|
||||
unsigned char format, /* format */
|
||||
unsigned char a_swap_en /* only for 32bit RGB888 format */
|
||||
);
|
||||
#else
|
||||
int
|
||||
RGA_set_src_vir_info(
|
||||
struct rga_req *req,
|
||||
unsigned int yrgb_addr, /* yrgb_addr */
|
||||
unsigned int uv_addr, /* uv_addr */
|
||||
unsigned int v_addr, /* v_addr */
|
||||
unsigned int vir_w, /* vir width */
|
||||
unsigned int vir_h, /* vir height */
|
||||
unsigned char format, /* format */
|
||||
unsigned char a_swap_en /* only for 32bit RGB888 format */
|
||||
);
|
||||
#endif
|
||||
|
||||
int
|
||||
RGA_set_dst_act_info(
|
||||
struct rga_req *req,
|
||||
unsigned int width, /* act width */
|
||||
unsigned int height, /* act height */
|
||||
unsigned int x_off, /* x_off */
|
||||
unsigned int y_off /* y_off */
|
||||
);
|
||||
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
int
|
||||
RGA_set_dst_vir_info(
|
||||
struct rga_req *msg,
|
||||
unsigned long yrgb_addr, /* yrgb_addr */
|
||||
unsigned long uv_addr, /* uv_addr */
|
||||
unsigned long v_addr, /* v_addr */
|
||||
unsigned int vir_w, /* vir width */
|
||||
unsigned int vir_h, /* vir height */
|
||||
RECT *clip, /* clip window */
|
||||
unsigned char format, /* format */
|
||||
unsigned char a_swap_en
|
||||
);
|
||||
#else
|
||||
int
|
||||
RGA_set_dst_vir_info(
|
||||
struct rga_req *msg,
|
||||
unsigned int yrgb_addr, /* yrgb_addr */
|
||||
unsigned int uv_addr, /* uv_addr */
|
||||
unsigned int v_addr, /* v_addr */
|
||||
unsigned int vir_w, /* vir width */
|
||||
unsigned int vir_h, /* vir height */
|
||||
RECT *clip, /* clip window */
|
||||
unsigned char format, /* format */
|
||||
unsigned char a_swap_en
|
||||
);
|
||||
#endif
|
||||
|
||||
int
|
||||
RGA_set_pat_info(
|
||||
struct rga_req *msg,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
unsigned int x_off,
|
||||
unsigned int y_off,
|
||||
unsigned int pat_format
|
||||
);
|
||||
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
int
|
||||
RGA_set_rop_mask_info(
|
||||
struct rga_req *msg,
|
||||
unsigned long rop_mask_addr,
|
||||
unsigned int rop_mask_endian_mode
|
||||
);
|
||||
#else
|
||||
int
|
||||
RGA_set_rop_mask_info(
|
||||
struct rga_req *msg,
|
||||
unsigned int rop_mask_addr,
|
||||
unsigned int rop_mask_endian_mode
|
||||
);
|
||||
#endif
|
||||
|
||||
int RGA_set_alpha_en_info(
|
||||
struct rga_req *msg,
|
||||
unsigned int alpha_cal_mode, /* 0:alpha' = alpha + (alpha>>7) | alpha' = alpha */
|
||||
unsigned int alpha_mode, /* 0 global alpha / 1 per pixel alpha / 2 mix mode */
|
||||
unsigned int global_a_value,
|
||||
unsigned int PD_en, /* porter duff alpha mode en */
|
||||
unsigned int PD_mode,
|
||||
unsigned int dst_alpha_en ); /* use dst alpha */
|
||||
|
||||
int
|
||||
RGA_set_rop_en_info(
|
||||
struct rga_req *msg,
|
||||
unsigned int ROP_mode,
|
||||
unsigned int ROP_code,
|
||||
unsigned int color_mode,
|
||||
unsigned int solid_color
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
RGA_set_fading_en_info(
|
||||
struct rga_req *msg,
|
||||
unsigned char r,
|
||||
unsigned char g,
|
||||
unsigned char b
|
||||
);
|
||||
|
||||
int
|
||||
RGA_set_src_trans_mode_info(
|
||||
struct rga_req *msg,
|
||||
unsigned char trans_mode,
|
||||
unsigned char a_en,
|
||||
unsigned char b_en,
|
||||
unsigned char g_en,
|
||||
unsigned char r_en,
|
||||
unsigned char color_key_min,
|
||||
unsigned char color_key_max,
|
||||
unsigned char zero_mode_en
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
RGA_set_bitblt_mode(
|
||||
struct rga_req *msg,
|
||||
unsigned char scale_mode, // 0/near 1/bilnear 2/bicubic
|
||||
unsigned char rotate_mode, // 0/copy 1/rotate_scale 2/x_mirror 3/y_mirror
|
||||
unsigned int angle, // rotate angle
|
||||
unsigned int dither_en, // dither en flag
|
||||
unsigned int AA_en, // AA flag
|
||||
unsigned int yuv2rgb_mode
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
RGA_set_color_palette_mode(
|
||||
struct rga_req *msg,
|
||||
unsigned char palette_mode, /* 1bpp/2bpp/4bpp/8bpp */
|
||||
unsigned char endian_mode, /* src endian mode sel */
|
||||
unsigned int bpp1_0_color, /* BPP1 = 0 */
|
||||
unsigned int bpp1_1_color /* BPP1 = 1 */
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
RGA_set_color_fill_mode(
|
||||
struct rga_req *msg,
|
||||
COLOR_FILL *gr_color, /* gradient color part */
|
||||
unsigned char gr_satur_mode, /* saturation mode */
|
||||
unsigned char cf_mode, /* patten fill or solid fill */
|
||||
unsigned int color, /* solid color */
|
||||
unsigned short pat_width, /* pattern width */
|
||||
unsigned short pat_height, /* pattern height */
|
||||
unsigned char pat_x_off, /* pattern x offset */
|
||||
unsigned char pat_y_off, /* pattern y offset */
|
||||
unsigned char aa_en /* alpha en */
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
RGA_set_line_point_drawing_mode(
|
||||
struct rga_req *msg,
|
||||
POINT sp, /* start point */
|
||||
POINT ep, /* end point */
|
||||
unsigned int color, /* line point drawing color */
|
||||
unsigned int line_width, /* line width */
|
||||
unsigned char AA_en, /* AA en */
|
||||
unsigned char last_point_en /* last point en */
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
RGA_set_blur_sharp_filter_mode(
|
||||
struct rga_req *msg,
|
||||
unsigned char filter_mode, /* blur/sharpness */
|
||||
unsigned char filter_type, /* filter intensity */
|
||||
unsigned char dither_en /* dither_en flag */
|
||||
);
|
||||
|
||||
int
|
||||
RGA_set_pre_scaling_mode(
|
||||
struct rga_req *msg,
|
||||
unsigned char dither_en
|
||||
);
|
||||
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
int
|
||||
RGA_update_palette_table_mode(
|
||||
struct rga_req *msg,
|
||||
unsigned long LUT_addr, /* LUT table addr */
|
||||
unsigned int palette_mode /* 1bpp/2bpp/4bpp/8bpp */
|
||||
);
|
||||
#else
|
||||
int
|
||||
RGA_update_palette_table_mode(
|
||||
struct rga_req *msg,
|
||||
unsigned int LUT_addr, /* LUT table addr */
|
||||
unsigned int palette_mode /* 1bpp/2bpp/4bpp/8bpp */
|
||||
);
|
||||
#endif
|
||||
|
||||
int
|
||||
RGA_set_update_patten_buff_mode(
|
||||
struct rga_req *msg,
|
||||
unsigned int pat_addr, /* patten addr */
|
||||
unsigned int w, /* patten width */
|
||||
unsigned int h, /* patten height */
|
||||
unsigned int format /* patten format */
|
||||
);
|
||||
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
int
|
||||
RGA_set_mmu_info(
|
||||
struct rga_req *msg,
|
||||
unsigned char mmu_en,
|
||||
unsigned char src_flush,
|
||||
unsigned char dst_flush,
|
||||
unsigned char cmd_flush,
|
||||
unsigned long base_addr,
|
||||
unsigned char page_size
|
||||
);
|
||||
#else
|
||||
int
|
||||
RGA_set_mmu_info(
|
||||
struct rga_req *msg,
|
||||
unsigned char mmu_en,
|
||||
unsigned char src_flush,
|
||||
unsigned char dst_flush,
|
||||
unsigned char cmd_flush,
|
||||
unsigned int base_addr,
|
||||
unsigned char page_size
|
||||
);
|
||||
#endif
|
||||
|
||||
void rga_set_fds_offsets(
|
||||
struct rga_req *rga_request,
|
||||
unsigned short src_fd,
|
||||
unsigned short dst_fd,
|
||||
unsigned int src_offset,
|
||||
unsigned int dst_offset);
|
||||
|
||||
int
|
||||
RGA_set_src_fence_flag(
|
||||
struct rga_req *msg,
|
||||
int acq_fence,
|
||||
int src_flag
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
RGA_set_dst_fence_flag(
|
||||
struct rga_req *msg,
|
||||
int dst_flag
|
||||
);
|
||||
|
||||
int
|
||||
RGA_get_dst_fence(
|
||||
struct rga_req *msg
|
||||
);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_RK29_IPP_DRIVER_H_*/
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
+100
@@ -0,0 +1,100 @@
|
||||
# Copyright (C) 2022 VYAGOO 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.
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/kernel/kernel.gni")
|
||||
|
||||
XR829_ETC_DIR="//device/soc/allwinner/t507/hardware/wifi/xr829/etc"
|
||||
XR829_BIN_DIR="//device/soc/allwinner/t507/hardware/wifi/xr829/bin"
|
||||
|
||||
if (linux_kernel_version == "linux-4.19") {
|
||||
ohos_prebuilt_etc("boot_xr829_bin") {
|
||||
source = "$XR829_BIN_DIR/boot_xr829.bin"
|
||||
module_install_dir = "etc/firmware"
|
||||
install_images = [ "vendor" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("etf_xr829_bin") {
|
||||
source = "$XR829_BIN_DIR/etf_xr829.bin"
|
||||
module_install_dir = "etc/firmware"
|
||||
install_images = [ "vendor" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("fw_xr829_bin") {
|
||||
source = "$XR829_BIN_DIR/fw_xr829.bin"
|
||||
module_install_dir = "etc/firmware"
|
||||
install_images = [ "vendor" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("sdd_xr829_bin") {
|
||||
source = "$XR829_BIN_DIR/sdd_xr829.bin"
|
||||
module_install_dir = "etc/firmware"
|
||||
install_images = [ "vendor" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
} else if (linux_kernel_version == "linux-5.10") {
|
||||
ohos_prebuilt_etc("boot_xr829_bin") {
|
||||
source = "$XR829_BIN_DIR/boot_xr829.bin"
|
||||
module_install_dir = "lib/firmware"
|
||||
install_images = [ "system" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("etf_xr829_bin") {
|
||||
source = "$XR829_BIN_DIR/etf_xr829.bin"
|
||||
module_install_dir = "lib/firmware"
|
||||
install_images = [ "system" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("fw_xr829_bin") {
|
||||
source = "$XR829_BIN_DIR/fw_xr829.bin"
|
||||
module_install_dir = "lib/firmware"
|
||||
install_images = [ "system" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("sdd_xr829_bin") {
|
||||
source = "$XR829_BIN_DIR/sdd_xr829.bin"
|
||||
module_install_dir = "lib/firmware"
|
||||
install_images = [ "system" ]
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("wpa_supplicant.conf") {
|
||||
source = "$XR829_ETC_DIR/wpa_supplicant.conf"
|
||||
install_images = [ "vendor" ]
|
||||
module_install_dir = "misc/wifi/wpa_supplicant"
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("p2p_supplicant.conf") {
|
||||
source = "$XR829_ETC_DIR/p2p_supplicant.conf"
|
||||
install_images = [ "vendor" ]
|
||||
module_install_dir = "misc/wifi/wpa_supplicant"
|
||||
part_name = "allwinner_products"
|
||||
}
|
||||
|
||||
group("xr829") {
|
||||
deps = [
|
||||
":wpa_supplicant.conf",
|
||||
":p2p_supplicant.conf",
|
||||
":boot_xr829_bin",
|
||||
":etf_xr829_bin",
|
||||
":fw_xr829_bin",
|
||||
":sdd_xr829_bin",
|
||||
]
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
End User License Agreement
|
||||
|
||||
THIS END USER LICENSE AGREEMENT (“AGREEMENT”) IS A LEGAL AGREEMENT BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND Shenzhen Allwinner Online Co., Ltd. (HERE AFTER REFERRED TO AS"AWOL") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS AGREEMENT. AWOL IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS AGREEMENT. BY DOWNDOADING OR BY INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT,AWOL WILL NOT LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE, AND YOU SHALL PROMPTLY DESTROY, DELETE, OR RETURN THE SOFTWARE TO YOUR SUPPLIER.
|
||||
|
||||
“SOFTWARE” means the software in object code provided under the terms of this Agreement.
|
||||
|
||||
Xiangzhou District,Zhuhai,China is the signing place of this Agreement.
|
||||
|
||||
1. GRANT OF LICENSE
|
||||
In consideration of your agreement to abide by the following terms, and subject to the terms and conditions of this Agreement, AWOL hereby grants YOU, a non-transferable, non-exclusive, royalty-free, revocable, worldwide copyright license (without the right to sublicense) to internally use the SOFTWARE and to manufacture, have manufactured, or sell, supply or distribute any products which use or embody any of the SOFTWARE or any of the intellectual property rights therein.
|
||||
|
||||
All rights to the SOFTWARE and all intellectual property rights contained therein are reserved and shall remain the sole and exclusive property of AWOL . The SOFTWARE is licensed but not sold. Except as expressly licensed in Clause 1, in no event shall the license granted in this Clause 1 be construed as granting YOU expressly or by implication, estoppels or otherwise, licenses to any intellectual property rights, including but not limited to patent rights, copyrights, trademark or trade secret in the SOFTWARE.
|
||||
|
||||
|
||||
2. RESTRICTIONS
|
||||
YOU shall reproduce and not remove or obscure any notice incorporated by AWOL in the SOFTWARE to protect AWOL’s intellectual property rights embodied therein.
|
||||
|
||||
YOU shall not decompile, disassemble, or reverse engineer the SOFTWARE.
|
||||
|
||||
YOU shall not distribute the SOFTWARE under an open source license as listed by the Open Source Initiative (a non-profit corporation whose website is www.opensource.org), or other license which requires the source code or object code of the SOFTWARE to be licensed or otherwise shared with any third party.
|
||||
|
||||
3. CONFLICT WITH OPEN SOURCE SOFTWARE LICENSE
|
||||
The SOFTWARE may contain open source software. If the license applied on such open source software has conflict with this Agreement, the license applied on such open source software will prevail and apply to the open source software.
|
||||
|
||||
4. FEEDBACK
|
||||
YOU may choose to provide suggestions, comments, feedback, ideas, modifications or know-how (whether in oral or written form) relating to the use of the SOFTWARE ("Feedback") to AWOL under the terms of this Agreement. YOU hereby grants to AWOL and its affiliates, under all of you and your affiliates’ (as applicable) intellectual property rights, a perpetual, irrevocable, royalty free, non-exclusive, worldwide license to (i) use, copy and modify the Feedback; (ii) sell, supply, or otherwise distribute the Feedback; (iii) design, have designed, manufacture, have manufactured, use, import, sell, and otherwise distribute and dispose of products that incorporate the Feedback; and (iv) sublicense (together with the rights to further sublicense) the rights granted in this paragraph to any third party.
|
||||
|
||||
5. NO WARRANTY
|
||||
YOU AGREE THAT THE SOFTWARE IS PROVIDED BY AWOL ON AN "AS IS" BASIS. AWOL MAKES NO WARRANTY, EXPRESSED OR IMPLIED OR STATUTORY, WITH RESPECT TO ANY OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.
|
||||
|
||||
YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, SOFTWARE APPLICATIONS DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
6. NO LIABILITY
|
||||
PLEASE NOTE THAT YOU SHOULD USE THE SOFTWARE AT YOUR OWN RISK.
|
||||
|
||||
IN NO EVENT SHALL AWOL BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHER LEGAL THEORY, EVEN IF AWOL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF THE SOFTWARE HAS ANY MATERIAL, VERIFIABLE, AND REPRODUCIBLE PROGRAM ERRORS, AWOL SHALL HAVE NO LIABILITY TO MODIFY SUCH ERRORS.
|
||||
|
||||
NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS AGREEMENT, THE MAXIMUM LIABILITY OF AWOL TO YOU IN AGGREGATE FOR ALL CLAIMS MADE AGAINST AWOL IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH THE SUBJECT MATTER OF THIS AGREEMENT SHALL NOT EXCEED THE TOTAL OF SUMS RECEIVED BY AWOL FROM YOU FOR THIS AGREEMENT. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT ENLARGE OR EXTEND THE LIMIT.
|
||||
|
||||
7. CONFIDENTIALITY
|
||||
YOU acknowledge and agree that the SOFTWARE provided under this Agreement contain trade secrets and confidential material of AWOL and YOU agree to maintain all such information in confidence and apply security measures no less stringent than the measures which YOU apply to protect your own like information, but not less than a reasonable degree of care, to prevent their unauthorized disclosure and use. The period of confidentiality shall be indefinite. YOU agree not to use any such information other than in normal use of the SOFTWARE under the license granted in this Agreement.
|
||||
|
||||
8. TERM AND TERMINATION
|
||||
This Agreement shall remain in force until terminated. AWOL may terminate this Agreement at any time with or without any cause. Upon termination of this Agreement, YOU shall immediately stop using the SOFTWARE and confidential information and destroy all copies of the SOFTWARE and confidential information in your possession, together with all documentation and related materials. The provisions of clauses 2, 3, 4, 5, 6, 7,8 and 9 shall survive termination of this Agreement.
|
||||
|
||||
9. GENERAL
|
||||
Any provision of this Agreement which is prohibited or unenforceable in any jurisdiction shall be ineffective to the extent of such prohibition or unenforceability without affecting, impairing or invalidating the remaining provisions hereof.
|
||||
|
||||
The failure by AWOL to enforce any of the provisions of this Agreement, unless waived in writing, shall not constitute a waiver of AWOL's rights to enforce such provision or any other provision of this Agreement in the future.
|
||||
|
||||
This Agreement shall be governed by and construed in accordance with the laws of People’s Republic of China, without reference to the principles of conflicts of laws. Any dispute arising out of or relating to this Agreement shall be submitted to the jurisdiction of the court of the signing place of this Agreement and the parties waive all objections to that jurisdiction and venue.
|
||||
|
||||
---------------------------------------------------------------------
|
||||
Copyright (C) 2022 VYAGOO TECHNOLOGY Co., Ltd. All rights reserved.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+28
@@ -0,0 +1,28 @@
|
||||
# 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.
|
||||
|
||||
ctrl_interface=udp
|
||||
device_name=p2p_ohos
|
||||
manufacturer=ohos
|
||||
device_type=10-0050F204-5
|
||||
config_methods=virtual_push_button physical_display keypad
|
||||
p2p_listen_reg_class=81
|
||||
p2p_listen_channel=1
|
||||
p2p_oper_reg_class=81
|
||||
p2p_oper_channel=1
|
||||
p2p_go_intent=0
|
||||
persistent_reconnect=1
|
||||
serial_number=0123456789ABCDEF
|
||||
p2p_ssid_postfix=-ohos
|
||||
p2p_go_ht40=1
|
||||
p2p_go_vht=1
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
country=GB
|
||||
ctrl_interface=udp
|
||||
network={
|
||||
ssid="AW-GZSW1-TEST"
|
||||
psk="Test321456987"
|
||||
key_mgmt=WPA-PSK
|
||||
auth_alg=OPEN
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user