当前位置: 首页 > news >正文

Gralloc ION DMABUF in Camera Display

目录

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

相关文章:

Gralloc ION DMABUF in Camera Display

目录 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…...

【LVS】lvs的四种模式的区别是什么?

LVS中的DR模式、NAT模式、TUN模式和FANT模式是四种不同的负载均衡模式,它们之间的主要区别在于数据包转发方式和网络地址转换。 DR模式(Direct Routing):此模式通过改写请求报文的目标MAC地址,将请求发给真实服务器&a…...

Android原生实现控件点击弹起效果方案(API28及以上)

之前在实现控件阴影时有提到过,阴影效果的实现采用的是Android原生的View的属性,拔高Z轴。Z轴会让View产生阴影的效果。 Zelevation translationZ 拔高Z轴可以通过控制elevation和translationZ。 我们之前是通过elevation来单纯的控制Z轴;而…...

【数据结构-队列 二】【单调队列】滑动窗口最大值

废话不多说,喊一句号子鼓励自己:程序员永不失业,程序员走向架构!本篇Blog的主题是【单调队列】,使用【队列】这个基本的数据结构来实现,这个高频题的站点是:CodeTop,筛选条件为&…...

如何设置CentOS系统以禁用不必要的网络端口和服务?

要禁用CentOS系统中的不必要的网络端口和服务,可以按照以下步骤进行操作: 1. 查看当前正在运行的服务和端口:使用以下命令可以查看正在运行的服务和对应的端口号。 sudo netstat -tuln 2. 停用不必要的服务:根据netstat命令的输…...

【IDEA项目个别类爆红,但是项目可以正常运行】

打开项目时发现idea个别类爆红,但是项目可以正常运行 问题原因:Idea本身的问题,可能是其缓存问题,导致爆红 解决方案:重置Idea 很多时候排查不出代码问题,就尝试一下此操作。 选择目录:File–>Invalida…...

hive 之select 中文乱码

此处的中文乱码和mysql的库表 编码 latin utf 无关。 直接上案例。 有时候我们需要自定义一列,有时是汉字有时是字母,结果遇到这种情况了。 说实话看到这真是糟心。这谁受得了。 单独select 没有任何问题。 这是怎么回事呢? 经过一番检查&…...

优化|优化处理可再生希尔伯特核空间的非参数回归中的协变量偏移

原文:Optimally tackling covariate shift in RKHS-based nonparametric regression. The Annals of Statistics, 51(2), pp.738-761, 2023.​ 原文作者:Cong Ma, Reese Pathak, Martin J. Wainwright​ 论文解读者:赵进 编者按: …...

Netty深入浅出Java网络编程学习笔记(一) Netty入门篇

目录 一、概述 1、什么是Netty 2、Netty的优势 二、入门案例 1、服务器端代码 2、客户端代码 3、运行流程 组件解释 三、组件 1、EventLoop 处理普通与定时任务 关闭 EventLoopGroup 处理IO任务 服务器代码 客户端代码 分工细化 划分Boss 和Work 增加自定义EventLoopGroup 切换…...

自动化产线集控系统(西门子CNC 840D/840DSL远程控制)

1.1项目背景 RQQ/VF120机组目前为1人操作3台机床,需在机台旁监控。为了改善人员在班中劳动强度非常大的现状,调整好每台机床的节奏,以保证机床的最少的等待时间。本项目旨在通过远程监视设备运行过程关键参数,操作人员人员可远程监…...

MVVM 与 MVC区别和应用场景?

MVVM 和 MVC 1. MVC2. MVVM 1. MVC MVC 是 Model View Controller 的缩写 Model:模型层,是应用程序中用于处理应用程序数据逻辑的部分。通常模型对象负责在数据库中存取数据。View:视图层,用户界面渲染逻辑,通常视图…...

Linux开发-Ubuntu软件源工具

开发&验证环境: 操作系统:ubuntu 20.04 软件源:http://archive.ubuntu.com/ubuntu 开发工具 sudo apt install vim sudo apt install git# gnu工具链 sudo apt install gcc sudo apt install g sudo apt install gdb# llvm工具链 sudo …...

环境下载地址

1. DOTNET环境下载 适用于 Visual Studio 的 .NET SDK 下载 (microsoft.com)https://dotnet.microsoft.com/zh-cn/download/visual-studio-sdks...

E. Block Sequence-Codeforces Round 903 (Div. 3)

E. Block Sequence dp题,设dp[i]表示i~n之间的数&#xff0c;需要最小删除数量 那么每一位数有两种情况&#xff0c;设数a[i]&#xff1a; 1.被删除&#xff1a;dp[i]dp[i1]1,这一位等于上一位的加一。 2.被保留&#xff1a;dp[i]min(dp[i],dp[ia[i]1]); #include<iostream…...

路由router

什么是路由? 一个路由就是一组映射关系&#xff08;key - value&#xff09;key 为路径&#xff0c;value 可能是 function 或 component 2、安装\引入\基础使用 只有vue-router3&#xff0c;才能应用于vue2&#xff1b;vue-router4可以应用于vue3中 这里我们安装vue-router3…...

学习编程-先改变心态

编程失败的天才 林一和我很久以前就认识了——我从五年级就认识他了。他是班上最聪明的孩子。如果每个人在家庭作业或考试准备方面需要帮助&#xff0c;他们都会去那里。 有趣的是&#xff0c;林一不是那种连续学习几个小时的孩子。 他的聪明才智似乎与生俱来&#xff0c;几乎毫…...

【Node.js】http 模块

1. http 模块 import http from http // 创建本地服务器接收数据 const server http.createServer((req, res) > {console.log(req.url)res.writeHead(200, { Content-Type: application/json // Content-Type: text/html;charsetutf-8 // 将内容以 html 标签和 utf-8 的…...

S/4 HANA 大白话 - 财务会计-2 总账主数据

接下来看看财务模块的一些具体操作。 总账相关主数据 公司每天运转&#xff0c;每天办公室有租金&#xff0c;有水电费&#xff0c;有桌椅板凳损坏&#xff0c;鼠标损坏要换&#xff0c;有产品买卖&#xff0c;有收入。那么所有这些都得记下来。记哪里&#xff1f;记在总账里…...

Redis根据中心点坐标和半径筛选符合的数据

目录 1.启动Redis​编辑 2.导入maven依赖 3.添加redis配置 4.编写RedisService 5.使用 6.验证 1.启动Redis 2.导入maven依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifac…...

springboot 集成 zookeeper 问题记录

springboot 集成 zookeeper 问题记录 环境 springboot - 2.7.8 dubbo - 3.1.11 dubbo-dependencies-zookeeper-curator5 - 3.1.11 模拟真实环境&#xff0c;将 windows 上的 zookeeper 迁移到虚拟机 linux 的 docker 环境 failed to connect to zookeeper server 迁移到…...

Vue记事本应用实现教程

文章目录 1. 项目介绍2. 开发环境准备3. 设计应用界面4. 创建Vue实例和数据模型5. 实现记事本功能5.1 添加新记事项5.2 删除记事项5.3 清空所有记事 6. 添加样式7. 功能扩展&#xff1a;显示创建时间8. 功能扩展&#xff1a;记事项搜索9. 完整代码10. Vue知识点解析10.1 数据绑…...

Qt/C++开发监控GB28181系统/取流协议/同时支持udp/tcp被动/tcp主动

一、前言说明 在2011版本的gb28181协议中&#xff0c;拉取视频流只要求udp方式&#xff0c;从2016开始要求新增支持tcp被动和tcp主动两种方式&#xff0c;udp理论上会丢包的&#xff0c;所以实际使用过程可能会出现画面花屏的情况&#xff0c;而tcp肯定不丢包&#xff0c;起码…...

逻辑回归:给不确定性划界的分类大师

想象你是一名医生。面对患者的检查报告&#xff08;肿瘤大小、血液指标&#xff09;&#xff0c;你需要做出一个**决定性判断**&#xff1a;恶性还是良性&#xff1f;这种“非黑即白”的抉择&#xff0c;正是**逻辑回归&#xff08;Logistic Regression&#xff09;** 的战场&a…...

Java - Mysql数据类型对应

Mysql数据类型java数据类型备注整型INT/INTEGERint / java.lang.Integer–BIGINTlong/java.lang.Long–––浮点型FLOATfloat/java.lang.FloatDOUBLEdouble/java.lang.Double–DECIMAL/NUMERICjava.math.BigDecimal字符串型CHARjava.lang.String固定长度字符串VARCHARjava.lang…...

微信小程序 - 手机震动

一、界面 <button type"primary" bindtap"shortVibrate">短震动</button> <button type"primary" bindtap"longVibrate">长震动</button> 二、js逻辑代码 注&#xff1a;文档 https://developers.weixin.qq…...

vue3 定时器-定义全局方法 vue+ts

1.创建ts文件 路径&#xff1a;src/utils/timer.ts 完整代码&#xff1a; import { onUnmounted } from vuetype TimerCallback (...args: any[]) > voidexport function useGlobalTimer() {const timers: Map<number, NodeJS.Timeout> new Map()// 创建定时器con…...

Axios请求超时重发机制

Axios 超时重新请求实现方案 在 Axios 中实现超时重新请求可以通过以下几种方式&#xff1a; 1. 使用拦截器实现自动重试 import axios from axios;// 创建axios实例 const instance axios.create();// 设置超时时间 instance.defaults.timeout 5000;// 最大重试次数 cons…...

均衡后的SNRSINR

本文主要摘自参考文献中的前两篇&#xff0c;相关文献中经常会出现MIMO检测后的SINR不过一直没有找到相关数学推到过程&#xff0c;其中文献[1]中给出了相关原理在此仅做记录。 1. 系统模型 复信道模型 n t n_t nt​ 根发送天线&#xff0c; n r n_r nr​ 根接收天线的 MIMO 系…...

重启Eureka集群中的节点,对已经注册的服务有什么影响

先看答案&#xff0c;如果正确地操作&#xff0c;重启Eureka集群中的节点&#xff0c;对已经注册的服务影响非常小&#xff0c;甚至可以做到无感知。 但如果操作不当&#xff0c;可能会引发短暂的服务发现问题。 下面我们从Eureka的核心工作原理来详细分析这个问题。 Eureka的…...

现有的 Redis 分布式锁库(如 Redisson)提供了哪些便利?

现有的 Redis 分布式锁库&#xff08;如 Redisson&#xff09;相比于开发者自己基于 Redis 命令&#xff08;如 SETNX, EXPIRE, DEL&#xff09;手动实现分布式锁&#xff0c;提供了巨大的便利性和健壮性。主要体现在以下几个方面&#xff1a; 原子性保证 (Atomicity)&#xff…...