天天看點

libdrm-----linux顯示卡應用層代碼庫DRMdrm驅動與應用程式接口

DRM

The Direct Rendering Manager (DRM) is a subsystem of the Linux kernel responsible for  
interfacing with GPUs of modern video cards. DRM exposes an API that user space programs  
can use to send commands and data to the GPU, and perform operations such as configuring  
the mode setting of the display. DRM was first developed as the kernel space component of  
the X Server's Direct Rendering Infrastructure,[1] but since then it has been used by other  
graphic stack alternatives such as Wayland.
           

drm驅動

核心的drm主要是為了實作圖形的dri硬體加速而服務的,通過提供一系列ioctls的操作,使得應用層的軟體可以直接對顯示卡硬體操作。驅動實際使用drm是經過libdrm封裝之後的借口。核心drm主要包括:vblank事件處理,記憶體管理,輸出管理,framebuffer管理,指令注冊,fencing,suspend/resume 支援,dma服務等。

核心drm的核心是圍繞structdrm_device結構展開(這個結構的定義見Documents/DocBook/drm.tmpl),每種顯示卡的drm都會聲明一個靜态的structdrm_device變量以radeon驅動為例(見drivers/gpu/drm/radeon/radeon_drv.c)。radeon是一家公司的顯示卡,i915是intel內建顯示卡,驅動位于drivers/gpu/drm/i915/i915_drv.c。

與應用程式接口

雖然應用程式可以直接通過系統調用openioctl等與drm互動,但是實際上在drm使用中為了友善總是在系統中安裝了libdrm對drm的

各個操作進行封裝,這樣更友善使用而不用去記憶那些ioctl的num和與之對應的函數。

libdrm

libdrm的編譯:

(1)apt install libpthread-stubs0-dev

(2)apt install libpciaccess-dev

(3)./configure

(4)make

(5)make install

測試代碼:

下載下傳:https://download.csdn.net/download/xgbing/10338858