Mail_Android_Video_SW_DDK_Intergration_Guide_And_Codec_User_Manual中文翻译【chapter3】

Chapter 3 Kernel Driver Configuration
第3章 内核驱动配置

This chapter describes how to configure the Linux kernel device driver
for your target platform. It contains the following sections:
3.1 Kernel driver configuration on page 3-27
3.2 Device tree configuration on page 3-28
3.3 Board file configuration on page 3-29
3.4 Platform configuration on page 3-30
3.5 Integration with Gralloc on page 3-32
3.6 Integrating JPEG functionality on page 3-33

本章介绍如何为目标平台配置Linux内核设备驱动程序。 它包含以下部分:
3.1 内核驱动程序配置 第3-27页
3.2 设备树配置 第3-28页
3.3 主板文件配置 第3-29页
3.4 平台配置 第3-30页
3.5 与Gralloc集成 第3-32页
3.6 集成JPEG功能 第3-33页

3.1 kernel driver configuration
Before you can build the kernel driver,you must create the driver configuration.
The configuration tells the driver:
1.The physical address of the hardware registers.
2.how to enable power to the hardware.
You can choose to hard code the configuration into the operating system,or to use the device tree.You select this by setting a build-time flag.

Table 3-1 Kernel driver configuration build flag

Flag nameConfiguration
device_tree = 0Hard coded
device_tree=1Device tree

3.1内核驱动程序配置
必须先创建驱动程序配置,然后才能构建内核驱动程序。 该配置告诉驱动程序:
1.硬件寄存器的物理地址。
2.如何启用硬件电源。
您可以选择将配置硬编码到操作系统中,也可以使用设备树。您可以通过设置构建时间标记来选择。

表 3-1 内核驱动程序配置构建标志:

Flag nameConfiguration
device_tree = 0Hard coded
device_tree=1Device tree

3.2 Device tree configuration
The device driver device tree configuration consists of a set of entries. The following entries must be present:
compatible
Set to arm,mali-v500
reg
Specifies the physical address of the core scheduler registers and the size of the register bank.
interrupts
Specifies the interrupt category,interrupt line,and interrupt type.
interrupt-parent
Specifies a reference to the interrupt controller.
3.2设备树配置
设备驱动程序设备树配置由一组条目组成。 必须存在以下条目:
compatible
设置为Arm,MALI-V500
reg
指定核心调度程序寄存器的物理地址和寄存器组的大小。
interrupts
指定中断类别,中断行和中断类型。
interrupt-parent
指定对中断控制器的引用。

3.2.1 Device tree entries
These are examples of device tree entries:
mali-v500@0xFC030000 {
compatible = “arm, mali-v500”;
reg = <“0xFC030000 0xFFFF”>;
interrupts = <“0 38 4”>;
interrupt-parent = <&gic>;
};

mali-v500@6FC030000 {
compatible = “arm, mali-v500”;
reg = <“0x00 0x6FC030000 0xFFFF”>;
interrupts = <“0 168 4”>;
interrupt-parent = <&gic>;
};

----Note----
64-bit systems usually expect 64-bit aligned data for the reg members.That is why it contains four entries and not two.

3.2.1设备树条目
这些是设备树条目的示例:
mali-v500@0xFC030000 {
compatible = “arm, mali-v500”;
reg = <“0xFC030000 0xFFFF”>;
interrupts = <“0 38 4”>;
interrupt-parent = <&gic>;
};

mali-v500@6FC030000 {
compatible = “arm, mali-v500”;
reg = <“0x00 0x6FC030000 0xFFFF”>;
interrupts = <“0 168 4”>;
interrupt-parent = <&gic>; };
注意:
64位系统通常期望reg成员使用64位对齐的数据,这就是为什么它包含四个条目而不是两个的原因。

3.3 Board file configuration
Board file configuration compiles the driver confituration data into the Linux kernel.Configuration details are in the form of an array of struct resourceelemenets.
The kernel uses the name associated with the configuration data to match it with the driver after the driver is loaded.The struct resource elements provide the kernel device driver information about the interrupt number and the location of the memory mapped registers in the physical address space. This source code is an example of what the configuration can look like.

static struct resource mve_resources[] =
{
[0]={
.start = MVE_CORE_BASE,
.end=MVE_CORE_BASE + MVE_CORE_BASE_SIZE,
.flags=IORESOURCE_MEM,
},
[1]={
.start = MVE_IRQ,
.end=MVE_IRQ,
.flags=IORESOURCE_IRQ,
},
};
The configuration data must be registered with the kernel or the driver will not gain access to the settings. This is done by creating a platform_device struct and registering it with the kernel by calling platform_device_register().
This source code is an example of what the platform_device structure can look like.The name must be mali-v500-rsrc.This name is used to match the platform device with the actual device driver.

/Mali-V500 can handle 40 bits wide physical address/
static uint64_t mv500_dma_mask=DMA_BIT_MASK(40);
static struct platform_device mve_device=
{ .name = “mali-v500-rsrc”, .id=0,
.num_resources=ARRAY_SIZE(mve_resources),
.resource=mve_resources,
.dev={
.platform_data=NULL,
.release = mve_device_release,
.dma_mask=&mv500_dma_mask,
.coherent_dma_mask=DMA_BIT_MASK(40),
},
};
The video processor MMU can handle up to 40-bit wide physical address.See the dma_mask and coherent_dma_mask attributes.

3.3单板文件配置
板文件配置将驱动程序配置数据编译到Linux内核中。配置详细信息以结构资源元素数组的形式出现。
加载驱动程序后,内核使用与配置数据关联的名称与驱动程序进行匹配。struct资源元素提供内核设备驱动程序有关中断号和物理地址空间中内存映射寄存器位置的信息。
此源代码是配置外观的示例。

static struct resource mve_resources[] =
{
[0]={
.start = MVE_CORE_BASE,
.end=MVE_CORE_BASE + MVE_CORE_BASE_SIZE,
.flags=IORESOURCE_MEM,
},
[1]={
.start = MVE_IRQ,
.end=MVE_IRQ,
.flags=IORESOURCE_IRQ,
},
};

配置数据必须在内核中注册,否则驱动程序将无法访问设置。
这是通过创建platform_device结构并通过调用platform_device_register()在内核中注册它来完成的。
该源代码是platform_device结构的示例,名称必须为mali-v500-rsrc,该名称用于将平台设备与实际设备驱动程序进行匹配。
/Mali-V500 can handle 40 bits wide physical address/
static uint64_t mv500_dma_mask=DMA_BIT_MASK(40);
static struct platform_device mve_device=
{ .name = “mali-v500-rsrc”, .id=0,
.num_resources=ARRAY_SIZE(mve_resources),
.resource=mve_resources,
.dev={
.platform_data=NULL,
.release = mve_device_release,
.dma_mask=&mv500_dma_mask,
.coherent_dma_mask=DMA_BIT_MASK(40),
},
};
视频处理器MMU最多可以处理40位宽的物理地址。请参阅dma_mask和coherent_dma_mask属性。

3.4 Platform configuration
The driver requires configuration details, such as the DVFS callbacks, to be able to operate correctly.The driver cannot get this information from device trees or resource structs. The driver must use an internal API,based on key-value pairs.Configuration details are stored in structures which are registered with a key. The driver uses the key to fetch the configuration.
This section contains the following subsections:
3.4.1 Configuration key-value pairs on page 3-30.·
3.4.2 Power management on page 3-30.
3.4.3 DVFS on page 3-30.
3.4.4 Memory bus attributes on page 3-31.
3.4.5 End marker on page 3-31.

3.4平台配置
该驱动程序需要配置详细信息(例如DVFS回调)才能正常运行。 驱动程序无法从设备树或资源结构中获取此信息。 驱动程序必须使用基于键值对的内部API。配置详细信息存储在通过键注册的结构中。 驱动程序使用密钥来获取配置。 本节包含以下小节:
3.4.1配置键值对 第3-30页。·
3.4.2电源管理 第3-30页。
3.4.3 DVFS 第3-30页。
3.4.4内存总线属性 第3-31页。
3.4.5结束标记 第3-31页的。

3.4.1 Configuration key-value pairs
All configuration information, except for the interrupt line number and the location of the memory mapped registers in physical address space, are stored in an array of key-value pairs.
The key-value pairs structure is defined by:
struct mve_config_attribute {
enum mve_config_key key; //The key of the
element mve_config_attribute_válue value; //The value corresponding to the key above
};
The driver retrieves this array by calling mve_device_get_config The platform configuration must provide an implementation of this function. The function prototype is:
struct mve_config_attribute *mve_device_get_config(void);
You can configure:
1.Power management callbacks.
2.DVFS callbacks.
3.AXI bus memory access settings.

The list of key-value pairs is stored in an array of mve_config_attributiastances. The last key-value pair indicates the end of the list using a special key.

3.4.1配置键值对
除中断行号和物理地址空间中存储器映射寄存器的位置以外的所有配置信息都存储在键-值对数组中。 键值对结构的定义如下:
struct mve_config_attribute { enum mve_config_key key; //The key of the element
mve_config_attribute_válue value; //The value corresponding to the key above
};

驱动程序通过调用mve_device_get_config检索此数组。平台配置必须提供此功能的实现。 函数原型为: struct
mve_config_attribute * mve_device_get_config(void); 您可以配置:
1.电源管理回调。
2.DVFS回调。
3.AXI总线内存访问设置。 键值对列表存储在mve_config_attributiastances数组中。 最后一个键值对使用特殊键指示列表的末尾。

3.4.2 Power management
The device driver uses callback functions to control the power supply of the hardware block.
You must supply the device driver with an instance of the struct mve_power_control defined in:
vendor/arm/v5xx/kernel/drivers/video/arm/v5xx/resource/machine/mve_power_management.h
Each member is a function pointer that must point to a function that performs the requested functionality when called.You can implement the functions using the Linux kernel regulator framework, or any other framework that is suitable for your platform. The driver gets the instance of the struct mve_power_contrqby using the key-value pairs array. You must register a reference to the structure using the key
MVE_DEVICE_ATTR_POWER_CALLBACKS

3.4.2电源管理
设备驱动程序使用回调函数来控制硬件模块的电源。
您必须为设备驱动程序提供以下结构中定义的struct mve_power_control实例:
vendor/arm/v5xx/kernel/drivers/video/arm/v5xx/resource/machine/mve_power_management.h
每个成员都是一个函数指针,该函数指针必须指向在调用时执行所请求功能的函数。您可以使用Linux内核调节器框架或任何其他函数来实现这些功能。 适用于您平台的框架。 驱动程序使用键值对数组获取结构mve_power_contrq的实例。
您必须使用键MVE_DEVICE_ATTR_POWER_CALLBACKS注册对结构的引用

3.4.3 DVFS
The device driver supports frequency scaling,based on the current work load. If the clock frequency is deemed too high or low, the driver calls a callback function with the new clock frequency as a parameter. The DVFS interface enables the driver to control when the hardware clock is enabled. The driver disables the clock when the hardware idles, and enables the clock again when needed. To support DVFS and clock control,you must supply the device driver with an instance of the struct mve_dvfs_callback_conf defined in
vendor/arm/v5xx/kernel/drivers/video/arm/v5xx/resource/machine/mve_dvfs.h.
Each member is a function pointer that must point to a function that performs the requested functionality when called. The driver uses the
instance of the struct mve_dvfs_callback_conf. identified by the key-value pairs array.You must register a reference to the structure using the keyMVE_DEVICE_ATTR_DVFS_CALLBACKS

3.4.3 DVFS
设备驱动程序支持基于当前工作负载的频率缩放。 如果认为时钟频率太高或太低,驱动程序将使用新的时钟频率作为参数调用回调函数。 DVFS接口使驱动程序可以控制何时启用硬件时钟。 当硬件空闲时,驱动程序将禁用时钟,并在需要时再次启用时钟。 要支持DVFS和时钟控制,您必须为设备驱动程序提供在vendor/arm/v5xx/kernel/drivers/video/arm/v5xx/resource/machine/mve_dvfs.h中定义的struct mve_dvfs_callback_conf实例。 必须指向一个函数的函数指针 调用时执行请求的功能。 驱动程序使用结构mve_dvfs_callback_conf的实例。 由键值对标识 数组。您必须使用keyMVE_DEVICE_ATTR_DVFS_CALLBACKS注册对结构的引用

3.4.4 Memory bus attributes
Each entry in the video processor MMU has a 2-bit attribute specifier,ATTR You must register a callback function in the key-value pairs list that enables the driver to query the memory bus settings for each attribute.
You must register the callback function using the key MVE_DEVICE_ATTR_BUS_ATTRIBUTES The attribute
argument can take the values 0-3:

Table 3-2 Memory bus attribute values

AttributeNameUsage
0PrivateData private to the hardware,such as firmware pages and intermediate buffers
1PublicOnly used for memory regions mapped by the firmware
2Shared read-onlyBuffers are used for communication with secure and protected components.For protected sessions,these pages must reside in protected memory,not accessible by the Rich Execution Environment(REE) Memory accesses are not cached within the cores.An outer level cache can cache the data as long as it is coherent with the application processor and other media components using the buffer
3Shared read-onlyBuffers for communication between the rich execution environment and the video processor

3.4.4内存总线属性
视频处理器MMU中的每个条目都有一个2位的属性说明符,ATTR。您必须在键值对列表中注册一个回调函数,使驱动程序可以查询每个属性的内存总线设置。
您必须使用键MVE_DEVICE_ATTR_BUS_ATTRIBUTES注册回调函数 attribute参数的值可以为0-3:

表3-2 内存总线属性值

AttributeNameUsage
0Private硬件专用的数据,例如固件页面和中间缓冲区
1Public仅用于固件映射的内存区域
2Shared read-only缓冲区用于与安全和受保护的组件进行通信。对于受保护的会话,这些页面必须驻留在受保护的内存中,不能由Rich Execution Environment(REE)访问。内存访问未缓存在内核中。外部级别的缓存可以缓存数据 只要它与使用缓冲区的应用处理器和其他媒体组件保持一致
3Shared read-only丰富执行环境和视频处理器之间的通信缓冲区

3.4.5 End marker
You must end the key-value array with a MVE_DEVICE_ATTR_END key since this is the only way for the driver to know how many items are stored in the arrray.There is need to specify a value for this key since the value field is ignored.
3.4.5结束标记
必须使用MVE_DEVICE_ATTR_END键结束键值数组,因为这是驱动程序知道错误存储了多少项的唯一方法。由于忽略了value字段,因此需要为此键指定一个值。

3.5 Integration with Gralloc
In an Android environment, the driver handles the Gralloc-allocated buffers. Gralloc does not expose an API to query the internal buffer properties, such as dimensions and memory handles. You must implement an interface that enables the driver to retrieve the properties from Gralloc.
You can find the interface description in omx_components/src/mve_omx_gralloc.h .ARM provides an implementation in the source code delivery, tailored to the ARM Gralloc implementation. If you do not use the ARM Gralloc implementation,you must implement this API for your Gralloc implementation.
The video driver assumes that all YUV buffers allocated by Gralloc have plane strides that are 128 bytealigned. You must take this into consideration if you do not use the ARM Gralloc implementation.YUV buffers that are not allocated by Gralloc have no stride alignment requirements.

3.5与Gralloc集成
在Android环境中,驱动程序处理分配给Gralloc的缓冲区。 Gralloc不会公开用于查询内部缓冲区属性(例如维度和内存句柄)的API。您必须实现一个接口,该接口使驱动程序能够从Gralloc检索属性。
您可以在omx_components / src / mve_omx_gralloc.h中找到接口说明。ARM在源代码交付中提供了一个针对ARM Gralloc实现的实现实现。 如果不使用ARM Gralloc实现,则必须为实现Gralloc实施此API。
视频驱动程序假定由Gralloc分配的所有YUV缓冲区的平面步长均为128字节对齐。 如果不使用ARM Gralloc实现,则必须考虑到这一点。Gralloc未分配的YUV缓冲区没有跨步对齐要求。

3.6 Integrating JPEG functionality
The video processor supports JPEG through the dynamic link library libjpeg_hw.so.This library has the same extemal interface as the standard library libjpeg.
To integrate video processor JPEG functionality,you must find the Android libraries and applications that link against libjpeg and link them against libjpeg_hw instead.
There are no further steps required for ntegration if the application supports the video processor JPEG feature set.
3.6集成JPEG功能
视频处理器通过动态链接库libjpeg_hw.so支持JPEG。该库具有与标准库libjpeg相同的外部接口。
要集成视频处理器JPEG功能,必须找到针对libjpeg进行链接并针对其进行链接的Android库和应用程序 。
如果应用程序支持视频处理器JPEG功能集,则集成不需要任何其他步骤。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在给出的引用中,没有提到signal en, en1 : std_logic的具体定义和作用。但是根据引用\[1\]中的示例代码,可以推测signal en和en1是std_logic类型的信号。std_logic是IEEE标准库文件std_logic_1164中定义的一种数据类型,用于表示数字信号的值。它可以取以下几个值:'0'表示逻辑低,'1'表示逻辑高,'Z'表示高阻态,'X'表示未知值。这些信号可能用于控制电路中的某些功能或状态。由于没有提供更多的上下文信息,无法确定en和en1的具体用途。 #### 引用[.reference_title] - *1* [EDA期末复习](https://blog.csdn.net/weixin_60303223/article/details/128375897)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [VHDL中数据类型转换与移位(STD_LOGIC_ARITH与NUMERIC_STD)](https://blog.csdn.net/qq_43445577/article/details/105767241)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [[转]VHDL中数据类型转换与移位(STD_LOGIC_ARITH与NUMERIC_STD)](https://blog.csdn.net/ddk43521/article/details/101226706)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水笙赵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值