Gralloc ION DMABUF in Camera Display

news2024/10/6 6:41:48

目录

Background knowledge

Introduction ia pa va and memory addressing

Memory Addressing

Page Frame Management

Memory area management

DMA

IOVA and IOMMU

Introduce DMABUF

What is DMABUF

DMABUF 关键概念

DMABUF APIS –The Exporter

DMABUF APIS –The Importer

DMABUF APIS

DMABUF usage flow

代码和调试

Introduce ION

What is ION

ION Overview

ION关键概念

ION 配置

ION APIS

ION changes

ION与DMABUF的关联

代码和调试

Introduce Gralloc

What is gralloc

Gralloc 和 ION的关联

代码和调试

Gralloc ion DMABUF in Camera & display

相机架构简述

相机smmu

相机DMABUF调用栈分析

相机驱动内存管理实例分析

Display DMABUF调用栈分析

总结1

总结2


Background knowledge

Introduction ia pa va and memory addressing

ia(Intermediate Address):CPU指令构造的地址空间,指令的演进具有滞后性,分段需求诞生。中间地址,也称为物理中间地址(Physical Intermediate Address),是指 CPU 访问内存时使用的地址。IA 是 CPU 通过地址转换机制将 VA 转换为 PA 的中间步骤。

pa(Physical Address):物理地址总线发出的地址构成的地址空间。物理地址,是指 CPU 访问内存时实际使用的地址。PA 是 CPU 通过地址转换机制将 VA 转换为 PA 的最终结果。

va(Virtual Address):pa的空间过大后,引入页表,经过分页处理ia和pa不再一一对应,ia由此之后可称为va。虚拟地址,是指程序在运行时使用的地址。VA 是程序中使用的地址,与物理内存地址没有直接关系。

Memory Addressing

Page Frame Management

Memory area management

DMA

  1. DMA(Direct Memory Access,直接内存存取) 它允许不同速度的硬件装置来沟通,而不需要依赖于 CPU 的大量中断负载 。
  2. DMA 传输将数据从一个地址空间复制到另外一个地址空间。
  3. Reference : http://www.wowotech.net/memory_management/DMA-Mapping-api.html

IOVA and IOMMU

  1. DMA 最初只接受物理地址,设备地址长度比CPU总线长度短,分配低地址给设备使用
  2. 设备增强后可以自带页表将DMA地址转换为同等长度的物理地址
  3. 设备自带页表转换可以认为在IO上做了mmu转换,硬件上有了IOMMU的概念,arm上称为SMMU
  4. IOMMU 作用是连接DMA-capable I/O总线(Direct Memory Access-capable I/O Bus)和主存(main memory)
  5. DMA地址可以由此可称为IOVA

Introduce DMABUF

What is DMABUF

  1. A generic kernel level framework to share buffers.
  2. Defines a new buffer object, which provides mechanism for exporting and using shared buffers.
  3. Provides uniform APIs that allow various operations related to buffer sharing.

DMABUF 关键概念

  1. The exporter
  2. implements and manages operations in struct dma_buf_ops for the buffer,
  3. allows other users to share the buffer by using dma_buf sharing APIs,
  4. manages the details of buffer allocation, wrapped int a struct dma_buf,
  5. decides about the actual backing storage where this allocation happens,
  6. and takes care of any migration of scatterlist - for all (shared) users of this buffer.

  1. The buffer-user
  2. is one of (many) sharing users of the buffer.
  3. doesn’t need to worry about how the buffer is allocated, or where.
  4. and needs a mechanism to get access to the scatterlist that makes up this buffer in memory, mapped into its own address space, so it can access the same area of memory. This interface is provided by struct dma_buf_attachment.

DMABUF APIS –The Exporter

1、dma_buf_export()  Used to export a buffer,Connects the exporter's private metadata for the buffer, an implementation of buffer operations for this buffer, and flags for the associated file. Returns a handle to the dma_buf object with all the above associated information.  

2、dma_buf_fd() Returns a FD associated with the dma_buf object. Userspace then passes the FD to other devices & sub-systems participating in sharing this dma_buf object.

3、dma_buf_get() Used by importing device to get the dma_buf object associated with the FD

DMABUF APIS –The Importer

4、dma_buf_attach(): The importing device can attach itself with the dma_buf object. Called once at beginning of dma_buf object sharing.

5、dma_buf_map_attachment() Used by importing device to request access to the buffer so it can do DMA. Returns an sg_table, containing the scatterlist mapped in the importing device's address space.

6、dma_buf_unmap_attachment() Once the DMA access is done, the device tells the exporter that the currently requested access is completed by calling this API.

DMABUF APIS

7、dma_buf_detach() At the end of need to access this dma_buf object, the importer device tells the exporter of its intent to 'detach' from the current sharing.

8、dma_buf_put() After dma_buf_detach() is called, the reference count of this buffer is decremented by calling dma_buf_put().

DMABUF usage flow

代码和调试

  1. 代码路径:kernel/msm-4.14/drivers/dma-buf
  2. Debug:/sys/kernel/debug/dma_buf
  3. Reference: https://www.kernel.org/doc/html/latest/driver-api/dma-buf.html

Introduce ION

What is ION

  1. ION is a generalized memory manager that Google introduced in the Android 4.0 ICS (Ice Cream Sandwich) release to address the issue of fragmented memory management interfaces across different Android devices.
  2. 内存池管理器

ION Overview

ION关键概念

  1. ION device : metadata of the ion device node
  2. ION heap ops : ops to operate on a given heap
  3. ION heap : represents a heap in the system
  4. ION page pool: ION memory pool in heap
  5. ION buffer : metadata for a particular buffer

ION 配置

path: msm-4.14/arch/arm/boot/dts/qcom/sm8150-ion.dtsi

msm_ion_probe

        Ion_device_create

        Ion_heap_create

        Ion_device_add_heap

ION APIS

  1. Ion_alloc_fd()
  2. ion_ioctl()
  3. Ion_map()
  4. Ion_free()

ION changes

ION与DMABUF的关联

代码和调试

Code :

  1. system/core/libion/
  2. kernel/msm-4.14/drivers/staging/android/ion/

Debug:

  1. /sys/kernel/debug/dma_buf

Introduce Gralloc

What is gralloc

  1. Gralloc is a vendor-supplied library, at run-time in /system/lib/hw/gralloc.[product name].so
  2. allocates graphic buffers
  3. gralloc allocates all graphic buffers using a kernel memory manager, typically ION  
  4. Selects appropriate ION heap based on the buffer usage flags

Gralloc 和 ION的关联

代码和调试

code

gralloc0 gralloc1

hardware/libhardware/include/hardware/gralloc.h libhardware/modules/gralloc/

gralloc2

hardware/interfaces/graphics/allocator/ hardware/qcom/display/gralloc/​

Gralloc ion DMABUF in Camera & display

相机架构简述

相机smmu

相机DMABUF调用栈分析

相机驱动内存管理实例分析

Display DMABUF调用栈分析

总结1

总结2

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1077083.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

PyTorch模型的多种导出方式提供给其他程序使用

PyTorch模型的多种导出方式提供给其他程序使用 flyfish PyTorch模型的多种导出方式 PyTorch模型的多种导出方式提供给其他程序使用1 模型可视化2 预训练模型3 ONNX模型导出有输入有输出TRAINING导出方式EVAL导出方式 4 自定义输入输出的名字,并可批量推理5 导出JI…

PyG两个data Datsaset v.s. InMemoryDataset

可以看到InMemoryDataset 对CPU更加友好 https://pytorch-geometric.readthedocs.io/en/latest/modules/data.html#pytorch-lightning-wrappers

Linux下C++编程-进度条

引言&#xff1a;本篇主要在linux下的C实现进度条的功能。按照多文件编程&#xff0c;同时使用Makefile文件完成多文件的编译、连接。 首先创建头文件&#xff1a; 1. progress.h #pragma once #include <iostream> #include <cstring> #include <iomanip>…

Navicat定时任务

Navicat定时任务 1、启动Navicat for MySQL工具&#xff0c;连接数据库。 2、查询定时任务选项是否开启 查询命令&#xff1a;SHOW VARIABLES LIKE ‘%event_scheduler%’; ON表示打开&#xff0c;OFF表示关闭。 打开定时任务命令 SET GLOBAL event_scheduler 0; 或者 SET G…

elasticsearch 8.5.3问题记录

一&#xff1a;解决 elasticsearch 高版本 warning: ignoring JAVA_HOMEC:\Program Files\Java\jdk-11&#xff1b; using bundled JDK if defined JAVA_HOME (set JAVA_HOME%JAVA_HOME%; )示例版本Elasticsearch 8.5.3 可以与 JDK 11 兼容&#xff0c;但不支持 JDK 17。确保选…

离散数学 期末复习

离散数学 期末复习 图片过多&#xff0c;若无法显示&#xff0c;请转至 https://chenhaotian.top/study/discrete-mathematics-final-review/ 访问全文 发布于 2023-06-18 第 1 章 命题逻辑 1.2 等值演算 真值表法 等值演算法 题&#xff1a;等值演算 题&#xff1a;等值演…

python 学习随笔 5

函数 在python中&#xff0c;函数也是对象。 def func():""" 这是文档字符串"""print("Hello World")fun带参数函数 函数和变量注解 def calc(a:int, b:int) -> int: # 为函数的形参和返回值标注类型return a b print(calc(1,3…

C语言重点突破(2)指针(三)

本章重点 1. 函数指针 2. 函数指针数组3. 指向函数指针数组的指针 4. 回调函数 1.函数指针 首先可以明确的是&#xff0c;函数指针和数组指针的类型都是指针类型&#xff0c;用来存放地址的&#xff0c;数组指针存放数组的地址&#xff0c;而函数指针存放的便是函数的地址。 …

ESPHome 通过http获取设备的状态

substitutions: { desc: 传感器, devicename: sensor }esphome:name: $devicenameplatform: ESP8266board: nodemcuv2arduino_version: latest# Enable logging logger:# Enable Home Assistant API api:encryption:key: "MhXiJqKKyCXTqjZWqtegaP1tQSUpPtbnXP9iV1i2TzE&qu…

SSM - Springboot - MyBatis-Plus 全栈体系(二十四)

第五章 SSM 二、SSM 整合配置实战 1. 依赖整合添加 1.1 数据库准备 依然沿用 mybatis 数据库测试脚本&#xff01; CREATE DATABASE mybatis-example;USE mybatis-example;CREATE TABLE t_emp(emp_id INT AUTO_INCREMENT,emp_name CHAR(100),emp_salary DOUBLE(10,5),PRIM…

视频号双11激励政策,快来看一看

双十一即将来临&#xff0c;不少平台都公布了自己的双十一政策。这篇文章&#xff0c;我们来看看视频号推出的激励政策&#xff0c;看有哪些需要准备的。

var、const、let的区别

目录 一、作用域 二、变量提升&#xff08;Hoisting&#xff09; 三、重复声明 四、 赋值和重新赋值 五、全局对象属性 六、使用场景 七、声明和赋值的数据类型 一、作用域 var 声明的变量在函数作用域内有效&#xff0c;如果在函数外声明&#xff0c;它将成为全局变量…

C++-Mongoose(3)-http-server-https-restful

1.url 结构 2.http和 http-restful区别在于对于mg_tls_opts的赋值 2.1 http和https 区分 a) port地址 static const char *s_http_addr "http://0.0.0.0:8000"; // HTTP port static const char *s_https_addr "https://0.0.0.0:8443"; // HTTP…

Springboot全局异常和自定义异常

目录 依赖 一、全局异常处理 1、系统异常 2、业务异常 &#xff08;1&#xff09;、接口配置 &#xff08;2&#xff09;、服务配置 二、自定义异常 依赖 <!-- validator&#xff0c;用于接口参数校验 --><dependency><groupId>org.hibernate.valida…

淘宝京东拼多多品牌价格监控API接口

淘宝、京东、拼多多品牌价格监控API接口需要从官方平台获取&#xff0c;以下是具体步骤&#xff1a; 登录京东、天猫、淘宝、拼多多、苏宁、国美、唯品会等电商平台&#xff0c;注册并获取开发者账号和API接口权限。通过开发者账号和API接口权限&#xff0c;访问京东、天猫、淘…

linux中单节点安装greenplum数据库

目录 一、安装包准备 二、关闭防火墙 三、安装greenplum依赖包 四、添加配置 五、新建greenplum用户 六、安装greenplum安装包 七、设置环境变量 八、权限互通 九、修改数据库配置文件 十、初始化数据库 十一、配置远程连接文件 十二、说明 一、安装包准备 下载准备…

Windows网络管理及诊断命令整理

目录 traceroute&#xff1a; ping&#xff1a; pathping: netstat: ipconfig&#xff1a; nslookup&#xff1a; route&#xff1a; ARP: FTP: netsh&#xff1a; nbtstat&#xff1a; sniffer(嗅探器)&#xff1a; winipcfg&#xff1a; traceroute&#xff1a; …

【无公网IP内网穿透】基于NATAPP搭建Web站点

&#x1f389;&#x1f389;欢迎来到我的CSDN主页&#xff01;&#x1f389;&#x1f389; &#x1f3c5;我是Java方文山&#xff0c;一个在CSDN分享笔记的博主。&#x1f4da;&#x1f4da; &#x1f31f;推荐给大家我的专栏《.内网穿透》。&#x1f3af;&#x1f3af; &#…

读书笔记:多Transformer的双向编码器表示法(Bert)-4

多Transformer的双向编码器表示法 Bidirectional Encoder Representations from Transformers&#xff0c;即Bert&#xff1b; 第二部分 探索BERT变体 从本章开始的诸多内容&#xff0c;以理解为目标&#xff0c;着重关注对音频相关的支持&#xff08;如果有的话&#xff09;…

Nginx、Git、Gitee的介绍及使用

目录 1、项目启动思路 2、Nginx 一、下载Nginx 1、下载地址 2、选择下载稳定版本 3、解压安装包 二、Nginx的原理 1、原理图 2、流程分析 三、配置Nginx 1、第一步&#xff1a;解决各种js报错 2、第二步&#xff1a;配置Nginx 3、启动/停止/重启Nginx 4、访问网址 …