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"?
migrated from stackoverflow.com Apr 5 '11 at 8:25
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.
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.