DRM框架(vkms)分析(5)----crtc初始化

本文详细解析了drm_crtc结构体,包括初始化流程、常用属性设置(如DRM_MODE_SETCRTC接口)、crtc控制接口和helper_private函数。介绍了如何通过atomic操作管理和调整CRTC状态,以及关键的gamma设置和power management操作。

drm_crtc结构体类型如下:

/**
 * 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_mode_config.crtc_list*/
	struct list_head head;
	/** crtc名称 */
	char *name;
	/** kms mode对象 */
	struct drm_mode_object base;
	/*primary层*/
	struct drm_plane *primary;
	/*鼠标层*/
	struct drm_plane *cursor;
	/*序号*/
	unsigned index;

	int cursor_x;
	int cursor_y;

	/*使用drm_atomic_helper_update_legacy_modeset_state更新*/
	bool enabled;
	/*显示时序,通过drm_atomic_helper_update_legacy_modeset_state()更新*/
	struct drm_display_mode mode;
	struct drm_display_mode hwmode;
	int x;
	int y;

	/*crtc 的funcs*/
	const struct drm_crtc_funcs *funcs;

    //gamma相关参数
	uint32_t gamma_size;
	uint16_t *gamma_store;

	/*驱动自定义的helper函数*/
	const struct drm_crtc_helper_funcs *helper_private;

	/*crtc的属性 */
	struct drm_object_properties properties;
	struct drm_property *scaling_filter_property;

	/*crtc的state*/
	struct drm_crtc_state *state;

	/*记录commit链表*/
	struct list_head commit_list;

};

一 drm_crtc初始化

drm_crtc_init_with_planes
    __drm_crtc_init_with_planes(dev, crtc, primary, cursor, funcs, ...)
        crtc->funcs = funcs //初始化funcs (如赋值struct drm_crtc_funcs vkms_crtc_funs)
        //创建DRM_MODE_OBJECT_CRTC类型的drm_mode_object对象实例
        ret = drm_mode_object_add(dev, &crtc->base, DRM_MODE_OBJECT_CRTC)
        //将crtc->head添加到config->crtc_list中、
        list_add_tail(&crtc->head, &config->crtc_list)
        crtc->primary = primary //初始化primary plane
        crtc->cursor = cursor //初始化 cursor plane
        //将config中创建的prop_active等属性绑定到crtc->base(drm_mode_object对象);
        drm_object_attach_property(&crtc->base, config->prop_active, 0);
//赋值crtc->helper_private
drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs);
        crtc->helper_private = funcs; //vkms_crtc_helper_funcs

二 常用属性设置

crtc的设置主要有ACTIVE/MODE_ID属性, 其中MODE_ID属性,是设置其显示时序,常用的设置接口如下:

(1)drmModeSetCrtc

该接口设置crtc的显示buf,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值