DRM全称是Direct Rendering Manager,管理进行显示输出的, buffer分配, 帧缓冲. libdrm库提供了一系列友好的控制封装, 使
用户可以方便的进行显示的控制, 但并不是 只能通过libdrm库来 控制drm, 用户可以直接操作drm的ioctl或者是使用framebuffer的 接口实现显示操作. 后面重点介绍
kernel态 drm的机制. 以下为drm显示大致框架:
设备节点
DRM 的设备节点为 "/dev/dri/cardX", X为0-15的数值.
默认使用的是/dev/dri/card0
用户空间内存操作
为了便于说明, 额外定义一个外部内存结构:
// drm相关操作需要引用该头文件
#
include <drm.h>
struct bo {
int fd;
void *ptr;
size_t size;
size_t offset;
size_t pitch;
unsigned handle;
};
获取设备节点:
bo->fd = open("/dev/dri/card0", O_RDWR, 0);
......
Drm 模式设置时序图
框架代码:
drivers/base/component.c
功能:
component
Framework作者Russell King对该机制的描述:
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However,
firmware tends to describe the individual devices and the connections between them. Therefore, we need a way to gather up the individual component devices together, and indicate when we have all the component devices. We do this in DT by providing a "superdevice" node which
SPECifies the components, eg: imx-drm {compatible = "fsl,drm"; crtcs = <&ipu1>; connectors = <&
HDMI>; }; The superdevice is declared into the component
support, along with the subcomponents. The superdevice receives
callbacks to locate the subcomponents, and identify when all components are present. At this point, we bind the superdevice, which causes the
APPropriate subsystem to be initiali
SED in the conventional way. When any of the components or superdevice are re
MOVed from the system, we unbind the superdevice, thereby taking the subsystem down.
在dts中, 有一个总的设备节点, 所有的子设备信息都通过dts描述关联起来, 这样系统 开机后, 就能统一的管 理各个设备.
更多详细内容请下载附件查看