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结构的其余成员将在下一篇文章中继续深入释义。

相关推荐
芒果黑3 个月前
Qt WebEngine播放DRM音视频
drm·qt webengine
炭烤毛蛋10 个月前
modetest
drm·framebuffer
wenshizhang1 年前
AMD显卡休眠唤醒流程分析
linux·内核·drm·amdgpu
Android系统攻城狮1 年前
Android12之DRM架构(一)
drm
蓝天居士1 年前
DRM全解析 —— connector详解(1)
drm
蓝天居士1 年前
DRM全解析 —— encoder详解(3)
drm
山东布谷科技官方1 年前
直播系统源码平台内容安全与版权维护技术:DRM
网络安全·drm·直播系统源码·数字版权管理·版权
风雨兼程80231 年前
Linux内核4.14版本——drm框架分析(14)——Atomic KMS 架构(struct drm_atomic_state)
drm
蓝天居士1 年前
DRM全解析 —— CREATE_DUMB(4)
linux内核·libdrm·drm