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

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

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

相关文章

上海亚商投顾:沪指探底回升 华为汽车概念股集体大涨

上海亚商投顾前言:无惧大盘涨跌,解密龙虎榜资金,跟踪一线游资和机构资金动向,识别短期热点和强势个股。 一.市场情绪 三大指数昨日探底回升,早盘一度集体跌超1%,随后震荡回暖,深成指、创业板指…

交通物流模型 | 基于多重时空信息融合网络的城市网约车需求预测

交通物流模型 | 基于多重时空信息融合网络的城市网约车需求预测 城市网约车需求预测是网约车系统决策、出租车调度和智能交通建设的一项长期且具有挑战性的任务。准确的城市网约车需求预测可以提升车辆的利用和调度,减少等待时间和交通拥堵。现有的交通流预测方法大部分采用基…

LeetCode二叉树OJ

目录 剑指 Offer 55 - I. 二叉树的深度 - 力扣(LeetCode) 965. 单值二叉树 - 力扣(LeetCode) 100. 相同的树 - 力扣(LeetCode) 101. 对称二叉树 - 力扣(LeetCode) 二叉树遍历_牛客题…

Vue组件化开发步骤

Vue组件化开发的步骤可以简单概括为以下几步: 划分组件:根据页面的布局和功能需求,将页面划分成若干个组件,每个组件具备独立的功能和样式。 编写组件:针对每个组件,编写组件的模板、样式和逻辑代码&#…

uniapp 点击 富文本元素 图片 可以预览(非nvue)

我使用的是uniapp 官方推荐的组件 rich-text,一般我能用官方级用官方,更有保障一些。 一、整体逻辑 1. 定义一段html标签字符串,里面包含图片 2. 将字符串放入rich-text组件中,绑定点击事件itemclick 3. 通过点击事件获取到图片ur…

TensorFlow学习:使用官方模型进行图像分类、使用自己的数据对模型进行微调

前言 上一篇文章 TensorFlow案例学习:对服装图像进行分类 中我们跟随官方文档学习了如何进行预处理数据、构建模型、训练模型等。但是对于像我这样的业余玩家来说训练一个模型是非常困难的。所以为什么我们不站在巨人的肩膀上,使用已经训练好了的成熟模…

VIT(Vision Transformer)学习-模型理解(一)

VIT (Vision Transformer) 模型论文代码(源码)从零详细解读,看不懂来打我_哔哩哔哩_bilibili VIT模型架构图 1.图片切分为patch 2. patch转化为embedding 1)将patch展平为一维长度 2)token embedding:将拉平之后的序列映射…

【ARM AMBA5 CHI 入门 12.1 -- CHI 链路层详细介绍 】

文章目录 CHI 版本介绍1.1 CHI 链路层介绍1.1.1 Flit 切片介绍1.1.2 link layer credit(L-Credit)机制1.1.3 Channel1.1.4 Port1.1. RN Node 接口定义1.1.6 SN Node 接口定义1.2 Channel interface signals1.2.1 Request, REQ, channel1.2.2 Response, RSP, channel1.2.3 Snoop…

如何找到新媒体矩阵中存在的问题?

随着数字媒体的发展,企业的新媒体矩阵已成为品牌推广和营销的重要手段之一。 然而,很多企业在搭建新媒体矩阵的过程中,往往会忽略一些问题,导致矩阵发展存在潜在风险,影响整个矩阵运营效果。 因此,找到目前…

二维离散傅里叶变换的实现

二维离散傅里叶变换的实现 1.使用Python包实现1.1 fftshift在numpy中的实现1.2 平移后的幅度谱 2.使用c实现之12.1 FFTW库安装2.2 结果比较 3.使用c实现之2参考文献 1.使用Python包实现 import numpy as np import matplotlib.pyplot as plt anp.array([0, 2, 4, 1,6, 1, 3, …

快速幂求逆元

思路 题意: 给出两个整数 a , p a,p a,p,其中 p p p 是质数,求出一个整数 b b b,使得 a ∗ b 1 ( m o d p ) a~*~b~~1(mod~p) a ∗ b 1(mod p) 成立(即求 a a a 模 p p p 的乘法逆元)。 首先我们…

澳大利亚教育部宣布ChatGPT将被允许在澳学校使用!

教育部长最近宣布,从 2024 年起,包括 ChatGPT 在内的人工智能将被允许在所有澳大利亚学校使用。 (图片来源:卫报) 而早些时候,澳洲各高校就已经在寻找与Chatgpt之间的平衡了。 之前,悉尼大学就…

leetCode 1035.不相交的线 动态规划 + 滚动数组 (最长公共子序列)

1035. 不相交的线 - 力扣(LeetCode) 在两条独立的水平线上按给定的顺序写下 nums1 和 nums2 中的整数。 现在,可以绘制一些连接两个数字 nums1[i] 和 nums2[j] 的直线,这些直线需要同时满足满足: nums1[i] nums2[j]…

vue3+elementplus+flask 文件夹上传

<div><input class"fileuploadclass" title"请选择文件夹" ref"file" id"submit" type"file"multiple name"" webkitdirectory change"folderModelOn"><el-button type"primary&qu…

冒泡排序/鸡尾酒排序

冒泡排序 冒泡排序&#xff08;Bubble Sort&#xff09;是一种简单的排序算法&#xff0c;它通过多次交换相邻元素的位置来实现排序。它的基本思想是从数组的第一个元素开始&#xff0c;比较相邻的两个元素&#xff0c;如果它们的顺序错误&#xff0c;则交换它们的位置。重复进…

蓝桥杯每日一题20233.10.10

题目描述 回文日期 - 蓝桥云课 (lanqiao.cn) 题目分析 对于此题&#xff0c;我们最先想到的是暴力解法&#xff0c;将每一种情况经行循环查找&#xff0c;在查找的过程中记录下答案&#xff0c;回文日期就是字符串判断回文&#xff0c;ABABBABA型回文日期可以将回文经行特判…

JVM源码剖析之Thread类中sleep方法

版本信息&#xff1a; jdk版本&#xff1a;jdk8u40 写在前面&#xff1a; 大部分的Java程序员知道让线程睡眠的方法是Thread.sleep方法&#xff0c;而这个方法是一个native方法&#xff0c;让很多想知道底层如何让线程睡眠的程序员望而却步。所以笔者特意写在这篇文章&#xf…

openGauss学习笔记-96 openGauss 数据库管理-访问外部数据库-file_fdw

文章目录 openGauss学习笔记-96 openGauss 数据库管理-访问外部数据库-file_fdw96.1 使用file_fdw96.2 注意事项 openGauss学习笔记-96 openGauss 数据库管理-访问外部数据库-file_fdw openGauss的fdw实现的功能是各个openGauss数据库及远程服务器&#xff08;包括数据库、文件…

沪深300期权一个点多少钱?

经中国证监会批准&#xff0c;深圳证券交易所于2019年12月23日上市嘉实沪深300ETF期权合约品种。该产品是以沪深300为标的物的嘉实沪深300ETF交易型指数基金为标的衍生的标准化合约&#xff0c;下文介绍沪深300期权一个点多少钱?本文来自&#xff1a;期权酱 一、沪深300期权涨…

PDF编辑和OCR文字识别工具ABBYY FineReader PDF

ABBYY FineReader PDF是一款专业的OCR文字识别和PDF编辑工具&#xff0c;可以帮助用户更好地处理和管理PDF文档。以下是ABBYY FineReader PDF的一些特点&#xff1a; 1. 文字识别精准&#xff1a;ABBYY FineReader PDF具有强大的OCR文字识别功能&#xff0c;可以将PDF中的文字…