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

本文参考以下博文:

Linux内核4.14版本------drm框架分析(3)------encoder分析

特此致谢!

1. 简介

encoder是编码器/输出转换器,负责将CRTC输出的timing时序转换成外部设备所需要的信号,如HDMI转换器或DSI Controller。

具体来讲,encoder的作用就是将内存的pixel像素编码(转换)为显示器所需要的信号(因为画面显示到不同的设备(Display Device)上,需要将画面转化为不同的电信号)。如RGB、LVDS、DSI、eDP、HDMI、CVBS、VGA等显示接口。另外,encoder与CRTC之间的交互就是我们所说的ModeSetting,其中包含了前面提到的色彩模式、还有时序(timing)等。

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

2. 核心结构

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

cpp 复制代码
/**
 * struct drm_encoder - central DRM encoder structure
 * @dev: parent DRM device
 * @head: list management
 * @base: base KMS object
 * @name: human readable name, can be overwritten by the driver
 * @funcs: control functions, can be NULL for simple managed encoders
 * @helper_private: mid-layer private data
 *
 * CRTCs drive pixels to encoders, which convert them into signals
 * appropriate for a given connector or set of connectors.
 */
struct drm_encoder {
	struct drm_device *dev;
	struct list_head head;

	struct drm_mode_object base;
	char *name;
	/**
	 * @encoder_type:
	 *
	 * One of the DRM_MODE_ENCODER_<foo> types in drm_mode.h. The following
	 * encoder types are defined thus far:
	 *
	 * - DRM_MODE_ENCODER_DAC for VGA and analog on DVI-I/DVI-A.
	 *
	 * - DRM_MODE_ENCODER_TMDS for DVI, HDMI and (embedded) DisplayPort.
	 *
	 * - DRM_MODE_ENCODER_LVDS for display panels, or in general any panel
	 *   with a proprietary parallel connector.
	 *
	 * - DRM_MODE_ENCODER_TVDAC for TV output (Composite, S-Video,
	 *   Component, SCART).
	 *
	 * - DRM_MODE_ENCODER_VIRTUAL for virtual machine displays
	 *
	 * - DRM_MODE_ENCODER_DSI for panels connected using the DSI serial bus.
	 *
	 * - DRM_MODE_ENCODER_DPI for panels connected using the DPI parallel
	 *   bus.
	 *
	 * - DRM_MODE_ENCODER_DPMST for special fake encoders used to allow
	 *   mutliple DP MST streams to share one physical encoder.
	 */
	int encoder_type;

	/**
	 * @index: Position inside the mode_config.list, can be used as an array
	 * index. It is invariant over the lifetime of the encoder.
	 */
	unsigned index;

	/**
	 * @possible_crtcs: Bitmask of potential CRTC bindings, using
	 * drm_crtc_index() as the index into the bitfield. The driver must set
	 * the bits for all &drm_crtc objects this encoder can be connected to
	 * before calling drm_dev_register().
	 *
	 * You will get a WARN if you get this wrong in the driver.
	 *
	 * Note that since CRTC objects can't be hotplugged the assigned indices
	 * are stable and hence known before registering all objects.
	 */
	uint32_t possible_crtcs;

	/**
	 * @possible_clones: Bitmask of potential sibling encoders for cloning,
	 * using drm_encoder_index() as the index into the bitfield. The driver
	 * must set the bits for all &drm_encoder objects which can clone a
	 * &drm_crtc together with this encoder before calling
	 * drm_dev_register(). Drivers should set the bit representing the
	 * encoder itself, too. Cloning bits should be set such that when two
	 * encoders can be used in a cloned configuration, they both should have
	 * each another bits set.
	 *
	 * As an exception to the above rule if the driver doesn't implement
	 * any cloning it can leave @possible_clones set to 0. The core will
	 * automagically fix this up by setting the bit for the encoder itself.
	 *
	 * You will get a WARN if you get this wrong in the driver.
	 *
	 * Note that since encoder objects can't be hotplugged the assigned indices
	 * are stable and hence known before registering all objects.
	 */
	uint32_t possible_clones;

	/**
	 * @crtc: Currently bound CRTC, only really meaningful for non-atomic
	 * drivers.  Atomic drivers should instead check
	 * &drm_connector_state.crtc.
	 */
	struct drm_crtc *crtc;

	/**
	 * @bridge_chain: Bridges attached to this encoder. Drivers shall not
	 * access this field directly.
	 */
	struct list_head bridge_chain;

	const struct drm_encoder_funcs *funcs;
	const struct drm_encoder_helper_funcs *helper_private;
};

3. drm_encoder结构释义

(0)总述

cpp 复制代码
/**
 * struct drm_encoder - central DRM encoder structure
......
 * CRTCs drive pixels to encoders, which convert them into signals
 * appropriate for a given connector or set of connectors.
 */

struct drm_encoder ------ 核心DRM encoder结构。

CRTC将像素驱动到encoder,encoder将像素转换为适用于给定连接器或连接器组的信号。

(1)struct drm_device *dev

cpp 复制代码
    /** @dev: parent DRM device */
	struct drm_device *dev;

父DRM设备。

(2)struct list_head head

cpp 复制代码
    /** @head: list management */
    struct list_head head;

链表管理。

(3)struct drm_mode_object base

cpp 复制代码
    /** @base: base KMS object */
    struct drm_mode_object base;

基本KMS对象。

(4)char *name

cpp 复制代码
    /** @name: human readable name, can be overwritten by the driver */
    char *name;

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

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

相关推荐
JasonSJX8 天前
海海软件成为微软 PlayReady DRM 官方合作伙伴
microsoft·drm·视频加密·playready·数字版权保护
DeeplyMind16 天前
linux drm子系统专栏介绍
linux·驱动开发·ai·drm·amdgpu·kfd
DeeplyMind2 个月前
AMD KFD的BO设计分析系列3-4:Linux DRM GEM mmap 与 drm_vma_offset_node 机制详解
linux·drm·opengl驱动·drm_gem_object
林政硕(Cohen0415)8 个月前
Linux驱动开发进阶(七)- DRM驱动程序设计
linux·驱动开发·drm
songze_lee9 个月前
openharmony系统移植之显示驱动框架从framebuffer升级为drm(linux-5.10)
linux·openharmony·drm
AlfredZhao1 年前
永远不要轻易设置Oracle的隐藏参数,哪怕是DRM
oracle·drm·_gc_undo_affinity
芒果黑1 年前
Qt WebEngine播放DRM音视频
drm·qt webengine
炭烤毛蛋2 年前
modetest
drm·framebuffer
wenshizhang2 年前
AMD显卡休眠唤醒流程分析
linux·内核·drm·amdgpu
Android系统攻城狮2 年前
Android12之DRM架构(一)
drm