DRM全解析 —— CRTC详解(1)

本文参考以下博文:

Linux内核4.14版本——drm框架分析(4)——crtc分析

特此致谢!

1. 简介

CRTC实际上可以拆分为CRT+C。CRT的中文意思是阴极摄像管,就是当初老电视上普遍使用的显像管(老电视之所以都很厚,就是因为它的缘故)。而后边那个C,代表Controller即控制器(一说是Context即上下文)。

CRTC主要用于显示控制,如对于显示时序、分辨率、刷新率等的控制,还要承担将framebuffer(帧缓冲)内容送显、更新framebuffer等任务。

CRTC对内连接framebuffer地址,对外连接encoder。扫描framebuffer上的内容,叠加上 planes的内容,最后传给encoder。

CRTC在系统中的位置和作用如下所示:

2. 核心结构

在Linux内核的DRM中,CRTC对应的核心结构体为:struct drm_crtc。该结构体在include/drm/drm_crtc.h中定义,代码如下(Linux内核版本:6.1):

/*** struct drm_crtc - central CRTC control structure** Each CRTC may have one or more connectors associated with it.  This structure* allows the CRTC to be controlled.*/
struct drm_crtc {/** @dev: parent DRM device */struct drm_device *dev;/** @port: OF node used by drm_of_find_possible_crtcs(). */struct device_node *port;/*** @head:** List of all CRTCs on @dev, linked from &drm_mode_config.crtc_list.* Invariant over the lifetime of @dev and therefore does not need* locking.*/struct list_head head;/** @name: human readable name, can be overwritten by the driver */char *name;/*** @mutex:** This provides a read lock for the overall CRTC state (mode, dpms* state, ...) and a write lock for everything which can be update* without a full modeset (fb, cursor data, CRTC properties ...). A full* modeset also need to grab &drm_mode_config.connection_mutex.** For atomic drivers specifically this protects @state.*/struct drm_modeset_lock mutex;/** @base: base KMS object for ID tracking etc. */struct drm_mode_object base;/*** @primary:* Primary plane for this CRTC. Note that this is only* relevant for legacy IOCTL, it specifies the plane implicitly used by* the SETCRTC and PAGE_FLIP IOCTLs. It does not have any significance* beyond that.*/struct drm_plane *primary;/*** @cursor:* Cursor plane for this CRTC. Note that this is only relevant for* legacy IOCTL, it specifies the plane implicitly used by the SETCURSOR* and SETCURSOR2 IOCTLs. It does not have any significance* beyond that.*/struct drm_plane *cursor;/*** @index: Position inside the mode_config.list, can be used as an array* index. It is invariant over the lifetime of the CRTC.*/unsigned index;/*** @cursor_x: Current x position of the cursor, used for universal* cursor planes because the SETCURSOR IOCTL only can update the* framebuffer without supplying the coordinates. Drivers should not use* this directly, atomic drivers should look at &drm_plane_state.crtc_x* of the cursor plane instead.*/int cursor_x;/*** @cursor_y: Current y position of the cursor, used for universal* cursor planes because the SETCURSOR IOCTL only can update the* framebuffer without supplying the coordinates. Drivers should not use* this directly, atomic drivers should look at &drm_plane_state.crtc_y* of the cursor plane instead.*/int cursor_y;/*** @enabled:** Is this CRTC enabled? Should only be used by legacy drivers, atomic* drivers should instead consult &drm_crtc_state.enable and* &drm_crtc_state.active. Atomic drivers can update this by calling* drm_atomic_helper_update_legacy_modeset_state().*/bool enabled;/*** @mode:** Current mode timings. Should only be used by legacy drivers, atomic* drivers should instead consult &drm_crtc_state.mode. Atomic drivers* can update this by calling* drm_atomic_helper_update_legacy_modeset_state().*/struct drm_display_mode mode;/*** @hwmode:** Programmed mode in hw, after adjustments for encoders, crtc, panel* scaling etc. Should only be used by legacy drivers, for high* precision vblank timestamps in* drm_crtc_vblank_helper_get_vblank_timestamp().** Note that atomic drivers should not use this, but instead use* &drm_crtc_state.adjusted_mode. And for high-precision timestamps* drm_crtc_vblank_helper_get_vblank_timestamp() used* &drm_vblank_crtc.hwmode,* which is filled out by calling drm_calc_timestamping_constants().*/struct drm_display_mode hwmode;/*** @x:* x position on screen. Should only be used by legacy drivers, atomic* drivers should look at &drm_plane_state.crtc_x of the primary plane* instead. Updated by calling* drm_atomic_helper_update_legacy_modeset_state().*/int x;/*** @y:* y position on screen. Should only be used by legacy drivers, atomic* drivers should look at &drm_plane_state.crtc_y of the primary plane* instead. Updated by calling* drm_atomic_helper_update_legacy_modeset_state().*/int y;/** @funcs: CRTC control functions */const struct drm_crtc_funcs *funcs;/*** @gamma_size: Size of legacy gamma ramp reported to userspace. Set up* by calling drm_mode_crtc_set_gamma_size().** Note that atomic drivers need to instead use* &drm_crtc_state.gamma_lut. See drm_crtc_enable_color_mgmt().*/uint32_t gamma_size;/*** @gamma_store: Gamma ramp values used by the legacy SETGAMMA and* GETGAMMA IOCTls. Set up by calling drm_mode_crtc_set_gamma_size().** Note that atomic drivers need to instead use* &drm_crtc_state.gamma_lut. See drm_crtc_enable_color_mgmt().*/uint16_t *gamma_store;/** @helper_private: mid-layer private data */const struct drm_crtc_helper_funcs *helper_private;/** @properties: property tracking for this CRTC */struct drm_object_properties properties;/*** @scaling_filter_property: property to apply a particular filter while* scaling.*/struct drm_property *scaling_filter_property;/*** @state:** Current atomic state for this CRTC.** This is protected by @mutex. Note that nonblocking atomic commits* access the current CRTC state without taking locks. Either by going* through the &struct drm_atomic_state pointers, see* for_each_oldnew_crtc_in_state(), for_each_old_crtc_in_state() and* for_each_new_crtc_in_state(). Or through careful ordering of atomic* commit operations as implemented in the atomic helpers, see* &struct drm_crtc_commit.*/struct drm_crtc_state *state;/*** @commit_list:** List of &drm_crtc_commit structures tracking pending commits.* Protected by @commit_lock. This list holds its own full reference,* as does the ongoing commit.** "Note that the commit for a state change is also tracked in* &drm_crtc_state.commit. For accessing the immediately preceding* commit in an atomic update it is recommended to just use that* pointer in the old CRTC state, since accessing that doesn't need* any locking or list-walking. @commit_list should only be used to* stall for framebuffer cleanup that's signalled through* &drm_crtc_commit.cleanup_done."*/struct list_head commit_list;/*** @commit_lock:** Spinlock to protect @commit_list.*/spinlock_t commit_lock;/*** @debugfs_entry:** Debugfs directory for this CRTC.*/struct dentry *debugfs_entry;/*** @crc:** Configuration settings of CRC capture.*/struct drm_crtc_crc crc;/*** @fence_context:** timeline context used for fence operations.*/unsigned int fence_context;/*** @fence_lock:** spinlock to protect the fences in the fence_context.*/spinlock_t fence_lock;/*** @fence_seqno:** Seqno variable used as monotonic counter for the fences* created on the CRTC's timeline.*/unsigned long fence_seqno;/*** @timeline_name:** The name of the CRTC's fence timeline.*/char timeline_name[32];/*** @self_refresh_data: Holds the state for the self refresh helpers** Initialized via drm_self_refresh_helper_init().*/struct drm_self_refresh_data *self_refresh_data;
};

3. drm_crtc结构释义

(0)总述

/*** struct drm_crtc - central CRTC control structure** Each CRTC may have one or more connectors associated with it.  This structure* allows the CRTC to be controlled.*/

struct drm_crtc —— 核心的DRM CRTC控制结构。

每个CRTC可以有一个或多个与其相关的连接器。这种结构允许控制CRTC。

(1)struct drm_device *dev

    /** @dev: parent DRM device */struct drm_device *dev;

父DRM设备。

(2)struct device_node *port

    /** @port: OF node used by drm_of_find_possible_crtcs(). */struct device_node *port;

由drm_of_find_possible_crtcs()使用的OF结点。

(3)struct list_head head

    /*** @head:** List of all CRTCs on @dev, linked from &drm_mode_config.crtc_list.* Invariant over the lifetime of @dev and therefore does not need* locking.*/struct list_head head;

@dev上所有crtc的列表,链接自&drm_mode_config.crtc_List。

在@dev的生命周期内保持不变,因此不需要锁定。

(4)char *name

    /** @name: human readable name, can be overwritten by the driver */char *name;

人类可读的名称(名字),可以被驱动程序覆盖。

drm_crtc结构的其余成员将在下一篇文章中继续深入释义。

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

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

相关文章

【状态估计】将变压器和LSTM与卡尔曼滤波器结合到EM算法中进行状态估计(Python代码实现)

💥💥💞💞欢迎来到本博客❤️❤️💥💥 🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。 ⛳️座右铭&a…

并发工具类库使用的常见问题

一、ThreadLocal在多线程环境中没有清理 由于ThreadLocal是和线程绑定的,如果线程被复用了,也即使用了线程池,那么ThreadLocal中的值是可能被复用的,这个特性如果是开发者没有预料到的,那么会产生很大的问题。例如&am…

人机言语交互模型的评估要素

智能客服中的言语交互模型评估要素,主要包括以下几个方面: 有效性:指模型能否准确识别和理解用户的言语意图,以及生成正确和合适的回答。可以通过比较模型生成的回答与人工回答的准确率来评估。流畅性:指模型在回答问…

【单调栈】下一个更大元素 II

文章目录 Tag题目来源题目解读解题思路方法一:单调栈循环数组 写在最后 Tag 【单调栈循环数组】【数组】 题目来源 503. 下一个更大元素 II 题目解读 在循环数组中找下一个更大的元素。循环数组指的是,数组的最后一个元素的下一个元素是数组首元素。 …

C语言之动态内存管理篇(1)

目录 为什么存在动态内存分配 动态内存函数的介绍 malloc free calloc realloc 常见的动态内存错误 今天收假了,抓紧时间写几篇博客。我又来赶进度了。今天我们来讲解动态内存管理。🆗🆗 为什么存在动态内存分配 假设我们去实现一个…

pip永久换源,虚拟环境

1 pip永久换源 2 虚拟环境 pip永久换源 # 自己写一个模块--->传到pypi上 # 安装第三方模块-清华,阿里云 pip install -i 源地址 模块名字# 永久换源 1、文件管理器文件路径地址栏敲:%APPDATA% 回车,快速进入 C:\Users\电脑用户\AppDat…

Excel插件:StatPlus Pro 7.7.0 Crack

Windows 版 StatPlus 借助 StatPlus,人们可以获得一套强大的统计工具和图形分析方法,可以通过简单直观的界面轻松访问。StatPlus 的可能应用范围几乎是无限的 - 社会学、金融分析、生物统计学、经济学、保险业、医疗保健和临床研究 - 仅举几个该程序已被…

SignalIR入门

SignalIR入门 简介教程1.创建项目2.添加 SignalR 客户端库3.创建 SignalR 中心4.配置 SignalR5.添加 SignalR 客户端代码 效果 简介 SignalR 是一个用于构建实时 Web 应用程序的开发工具和库,它可以让服务器端代码与客户端代码之间建立双向通信。SignalR 的中文解释…

05_模板引擎

模板引擎可以让将数据和HTML模板更加友好的结合&#xff0c;省去繁琐的字符串拼接&#xff0c;使代码更加易于维护。 1 EJS 文档地址&#xff1a;https://ejs.bootcss.com/#install 1.1 安装 npm install ejs 1.2 标签语法 <% ‘脚本’ 标签&#xff0c;用于流程控制&…

【思维构造】Circle of Monsters—CF1334C

Circle of Monsters—CF1334C 思路 每一个怪兽都有两种死法&#xff1a; 直接被子弹打死先被上一个怪兽爆炸击伤&#xff0c;剩下的血量再用子弹打死 所以&#xff0c;很容易看出来第二种死法对于所有的怪兽都是最优死法&#xff08;消耗子弹最少的死法&#xff09;。我们需要…

什么测试自动化测试?

什么测试自动化测试&#xff1f; 做测试好几年了&#xff0c;真正学习和实践自动化测试一年&#xff0c;自我感觉这一个年中收获许多。一直想动笔写一篇文章分享自动化测试实践中的一些经验。终于决定花点时间来做这件事儿。 首先理清自动化测试的概念&#xff0c;广义上来讲&a…

如何搭建一个 websocket

环境: NodeJssocket.io 4.7.2 安装依赖 yarn add socket.io创建服务器 引入文件 特别注意: 涉及到 colors 的代码&#xff0c;请采取 console.log() 打印 // 基础老三样 import http from "http"; import fs from "fs"; import { Server } from &quo…

pytorch 数据载入

在PyTorch中&#xff0c;数据载入是训练深度学习模型的重要一环。 本文将介绍三种常用的数据载入方式&#xff1a;Dataset、DataLoader、以及自定义的数据加载器。 使用 Dataset 载入数据 方法&#xff1a; from torch.utils.data import Datasetclass CustomDataset(Dataset…

第九课 排序

文章目录 第九课 排序排序算法lc912.排序数组--中等题目描述代码展示 lc1122.数组的相对排序--简单题目描述代码展示 lc56.合并区间--中等题目描述代码展示 lc215.数组中的第k个最大元素--中等题目描述代码展示 acwing104.货仓选址--简单题目描述代码展示 lc493.翻转树--困难题…

JavaScript系列从入门到精通系列第十五篇:JavaScript中函数的实参介绍返回值介绍以及函数的立即执行

文章目录 一&#xff1a;函数的参数 1&#xff1a;形参如何定义 2&#xff1a;形参的使用规则 二&#xff1a;函数的返回值 1&#xff1a;函数返回值如何定义 2&#xff1a;函数返回值种类 三&#xff1a;实参的任意性 1&#xff1a;方法可以作为实参 2&#xff1a;将匿…

kafka与hbase的区别

Kafka 和 HBase 是两个不同的分布式数据存储系统&#xff0c;它们可以在大数据应用中发挥不同的作用。 Kafka 是一个高吞吐量的分布式发布订阅消息系统&#xff0c;主要用于处理实时数据流。它具有以下特点&#xff1a; 高性能&#xff1a;Kafka 能够以非常高的吞吐量和低延迟…

2023年全球市场数字干膜测量仪总体规模、主要生产商、主要地区、产品和应用细分研究报告

内容摘要 按收入计&#xff0c;2022年全球数字干膜测量仪收入大约149.2百万美元&#xff0c;预计2029年达到191.6百万美元&#xff0c;2023至2029期间&#xff0c;年复合增长率CAGR为 3.6%。同时2022年全球数字干膜测量仪销量大约 &#xff0c;预计2029年将达到 。2022年中国市…

【Spring Boot】创建一个 Spring Boot 项目

创建一个 Spring Boot 项目 1. 安装插件2. 创建 Spring Boot 项目3. 项目目录介绍和运行注意事项 1. 安装插件 IDEA 中安装 Spring Boot Helper / Spring Assistant / Spring Initializr and Assistant插件才能创建 Spring Boot 项⽬ &#xff08;有时候不用安装&#xff0c;直…

分布式事务 —— SpringCloud Alibaba Seata

文章目录 Seata 简介Seata 服务端Seata 客户端 Seata 简介 传统的单体应用中&#xff0c;业务操作使用同一条连接操作不同的数据表&#xff0c;一旦出现异常就可以整体回滚。随着公司的快速发展、业务需求的变化&#xff0c;单体应用被拆分成微服务应用&#xff0c;原来的单体…

【排序算法】冒泡排序

文章目录 一&#xff1a;排序算法1.1 介绍1.2 分类 二&#xff1a;冒泡排序2.1 基本介绍2.2 图解冒泡排序算法2.3 代码实现 三&#xff1a;算法性能分析3.1 时间复杂度3.2 空间复杂度 一&#xff1a;排序算法 1.1 介绍 排序也称排序算法(Sort Algorithm)&#xff0c;排序是将…