Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I set the video mode in Linux the low level way? As far as I know the lowest layer in userspace would be to request KMS via DRM. Is this correct? And if so, how could I achieve a mode switch and access to the associated "video memory"?

share|improve this question

migrated from stackoverflow.com Apr 5 '11 at 8:25

This question came from our site for professional and enthusiast programmers.

    
What is kms? So far I haven't heard of KSM, or mode switching. –  BЈовић Apr 4 '11 at 10:16
    
I mean by KMS: Kernel-Mode-Setting link‌​. –  litro Apr 4 '11 at 12:31
    
Do you mean for the framebuffer/console? Or for X11/Xorg? –  penguin359 Apr 6 '11 at 3:49
    
@penguin359 Either. X and fb if possible as long as I get to use the libdrm directly... (PS: preferably via C++) –  user6349 Apr 6 '11 at 19:12
4  
@litro what are you trying to achieve? and in many distro's kms will activate itself if available and not turned off. –  xenoterracide Jun 3 '11 at 14:18

2 Answers 2

KMS—Kernel Mode Setting, for those who haven't heard of it—is made possible by kernel mode video drivers. These kernel mode video drivers configure a framebuffer display that by default is the native resolution of the attached monitor(s). If there is more than one monitor attached, each monitor will get its native resolution and the virtual console will be constrained to the minimum width and height of both monitors.

Because the use of KMS results in a framebuffer, the framebuffer configuration items should work. I cannot verify this on the system that I am presently on, because it does not have a KMS driver. But I will be at a system later with KMS and I will let you know.

See the kernel documentation on setting modes with the video= boot up parameter for framebuffers for more information.

share|improve this answer

I'm not sure you really know what your asking, otherwise you would have phrased it in a manner which is answerable. ... But to do my best, at answering your question.

You want to set a mode and thunk out some 'video memory'? like the old dos mode X days?? If this is what you want, you need to program with the Framebuffer. With that said, it would be much better working with DirectFB. DirectFB is like a very thin layer, with acceleration, on the Framebuffer. Its low level, and truthfully its as low as you should reasonably ever want to go writing applications. You would be able to set modes, and have control in more low level style. If you want direct direct style control you have to write Framebuffer raw, you basically mmap out some video ram. If you feel Framebuffer performs poorly, I can't stress enough, check out DirectFB. If somebody has a KMS driver loaded, their Framebuffer is set via KMS/libdrm.

Now as for libdrm, it is a userspace lib for working with the kernel DRM. It is not a Framebuffer, it is not an application API, it is a system device library. If you want to create a new device driver, libdrm is the absolute way to go. For example, libdrm-radeon. Linux is not DOS, the only way to directly communicate with hardware is through the kernel. All normal applications never send code directly to hardware, it must get thunked out in some lib/API/call. There are projects that have taken the in-kernel approach, for academic/experimental purposes, such as FBUI.

I hope I could have at least pointed you in the right direction, if not you should comment and also update your question. I have followed this question since its conception, which was at least two migrations ago and no closer to answered. Without more information, There really isn't any more that can be said.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.