LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-31-2011, 07:54 AM   #1
Nickew
LQ Newbie
 
Registered: May 2011
Posts: 15

Rep: Reputation: Disabled
Graphics kernel files


Hello everyone,
I would like to study the low level graphic drivers of the kernel, where the cursor is controlled and where it puts each and every character on the screen and moves the cursor one character forward.
Kernel doesn't have graphics and windows, but it shows a screen and command line. where does it control all this. which fonts does it use? what are font size limitations? where are the font files?

I am not into programming new graphics. I want to hack around with the linux kernel a bit. I found many articles about programming high level graphics.

If you can send me some links to related tutorials and how tos would be great.

Thanks in advance.
Nickew

Last edited by Nickew; 05-31-2011 at 07:30 PM. Reason: I learned more about kernel and I corrected my question.
 
Old 05-31-2011, 02:01 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Graphics of the sort you are referring to is generally done in the X server. The X server is a layer between the graphic kernel driver, which doesn't know about characters and cursors, and userspace applications. The lowest level drivers are the glue layer between the X server and the graphics hardware. Usually, as I understand it, the driver exposes a block of memory which maps to screen pixels according to the spacial and color resolution in use. There is also the framebuffer interface supported by most drivers, which has a VESA standardized interface to which you can interface with userspace applications. There is also an X server driver which can use the framebuffer as its access to the video hardware.

As I understand it, there is precious little for hacking in graphics drivers, as the driver are not always open source. The Xorg sources should be fully open for your perusal and scrutiny.

--- rod.
 
1 members found this post helpful.
Old 05-31-2011, 07:33 PM   #3
Nickew
LQ Newbie
 
Registered: May 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
I have changed my questions a bit.

Thanks Rod, I understand a bit more and I have changed my questions !
Can you give me more tips, thanks again.

Quote:
Originally Posted by theNbomr View Post
Graphics of the sort you are referring to is generally done in the X server. The X server is a layer between the graphic kernel driver, which doesn't know about characters and cursors, and userspace applications. The lowest level drivers are the glue layer between the X server and the graphics hardware. Usually, as I understand it, the driver exposes a block of memory which maps to screen pixels according to the spacial and color resolution in use. There is also the framebuffer interface supported by most drivers, which has a VESA standardized interface to which you can interface with userspace applications. There is also an X server driver which can use the framebuffer as its access to the video hardware.

As I understand it, there is precious little for hacking in graphics drivers, as the driver are not always open source. The Xorg sources should be fully open for your perusal and scrutiny.

--- rod.
 
Old 06-01-2011, 10:03 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Do you mean that you are interested in non-graphical video; ie. text-mode? That is mostly done in the video hardware. The video hardware has a standard text mode that is the default on boot, and is used by the BIOS and other low-level code to put text and text-mode attributes such as foreground and background color & emphasis to a matrix of character cells on the screen. It can be accessed through standard BIOS calls, and also by writing directly to an area of real-mode memory that maps character cells in the row/column arrangement. The font used is built into the video BIOS of the video card, and is referred to as a character generator. In text-mode, the graphics card also controls the cursor position, as well as providing some control over the shape, color and blinking attributes.
Manipulating the text-mode screen was a very common practice in the days of MS-DOS when full access to the machine hardware was possible, and was required to achieve the best performance of application software. In Linux, there is very very little purpose for using such direct access to the hardware.
--- rod.
 
1 members found this post helpful.
Old 06-01-2011, 10:36 AM   #5
Nickew
LQ Newbie
 
Registered: May 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Changing the graphic driver

Thanks for the explanations. Now, if I make changes to the graphic driver or the BIOS, like changing the direction, will that also effect the Xwindows graphics.
There are programs for MS-Windows which flip the screen upside down (how can I do the same in Linux)?

Quote:
Originally Posted by theNbomr View Post
Do you mean that you are interested in non-graphical video; ie. text-mode? That is mostly done in the video hardware. The video hardware has a standard text mode that is the default on boot, and is used by the BIOS and other low-level code to put text and text-mode attributes such as foreground and background color & emphasis to a matrix of character cells on the screen. It can be accessed through standard BIOS calls, and also by writing directly to an area of real-mode memory that maps character cells in the row/column arrangement. The font used is built into the video BIOS of the video card, and is referred to as a character generator. In text-mode, the graphics card also controls the cursor position, as well as providing some control over the shape, color and blinking attributes.
Manipulating the text-mode screen was a very common practice in the days of MS-DOS when full access to the machine hardware was possible, and was required to achieve the best performance of application software. In Linux, there is very very little purpose for using such direct access to the hardware.
--- rod.
 
Old 06-01-2011, 12:30 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
The BIOS will not affect the X server, and is mostly immutable, anyway. I'm not sure what you mean by 'changing the direction' (change orientation?). There is an X module 'randr' which is used to do resize and rotate operations. I don't know if it can be used to flip the server on either horizontal or vertical planes.

--- rod.
 
Old 06-01-2011, 11:43 PM   #7
Nickew
LQ Newbie
 
Registered: May 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
I know that graphics all work based on a memory map. so there is a memory section either shared on the RAM or the dedicated RAM of the graphic card which has all the pixels on the screen.
How can access that RAM to change the directions?
I need to modify either the way it writes to the mamory or when it reads it to the screen. If I can access and control that memory then I got half of what I want.
The other half is where are the fonts (on BIOS, on Graphic BIOS, ...), I need add and make changes there as well.
Thanks a million for your help.

PS: If you show me data sheets, tutorials or similars, I will gladly read them.

Last edited by Nickew; 06-01-2011 at 11:50 PM.
 
Old 06-02-2011, 10:32 AM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Do you want to do this using X? If so, you would have to go through some X server API calls (as I mentioned previously, there is the standard randr extension that provides this functionality). The kernel driver for each make/model of video card will probably expose some standard interface that X servers use to gain access to the video card functions. I'm sorry that I can't explain any of the details of this. I don't think you will be able to access video memory in any way that will be coordinated with the X server unless you actually use the X server to do the work.
Fonts are stored in files on disk, and interpreted by the X server at runtime. X client applications tell the X server what fonts they want to use, and the X server uses a font server (xfs) to fetch them. For a normal desktop setting, the font server is built in to the local X server is running. Optionally, you can have a network font server, where fonts are downloaded to the X server from a remote host. You can see what fonts are available to the currently used X server (as indicated by $DISPLAY) with the xlsfonts tool. The font server loads fonts from disk using a somewhat complex system of pre-processing and configuration that includes provision for font-name aliasing, compression and naming conventions. Configuration of X fonts is a tricky subject and is too big to explain in this forum (a cop-out, because I've never been able to fully understand it. :-) ). Google is your friend on this subject.
As I said earlier, there is also a basic bitmap font embedded in the video BIOS ROM which defines a font that is used only in text mode. This is not used by X, and is not normally available in any sense by userspace Linux applications.
--- rod.
 
Old 06-03-2011, 12:08 AM   #9
Nickew
LQ Newbie
 
Registered: May 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Are you telling me that I don't need to learn vedio device driver development to access the memory map and make effects there?
Are you saying that it can be done at Xserver level as well.
Does the Xserver has something similar to memeory map or it writes directly to the memory of the graphic card using some vedio driver functionality?
Thanks
 
Old 06-03-2011, 11:15 AM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I am saying that you can access video memory either through the X server or directly through the interface exposed by the driver. Not both concurrently. It is fairly unusual to program directly at the X level these days (it tends to be wrapped in higher level APIs like Qt, GTK, Motif, etc) but I'm sure there is a way to access the X server using a bitmap oriented paradigm. This will not work well (probably not at all) in the way you seem to want on a system that has an X-based desktop or window manager already running.

To get a better base-level understanding of X, and how it fits into to the picture, you should do a bit of reading. A good starting point would be On-line X programming tutorials.
Your whole line of questions seem to hover around the divisions between the various layers that are involved in rendering graphics on a computer monitor in a typical desktop Linux architecture. One breakdown of this layered approach would be, from lowest level to highest level:
  • Hardware
  • Kernel driver
  • X server
  • Other wrapper (Qt, GTK, GL, Motif, etc)
The upshot of this layered approach is that for the most part, if you use any lower level layer to generate graphics, it will almost certainly be in conflict with the layers above. The flow of control of the video subsystem is intended to start at one top level layer. You cannot have an X server controlling the video subsystem, and then inject your own functionality at some lower level in any coordinated way. Working your way up the stack will provide progressively easier and more standardized ways to accomplish rendering of graphics on the screen. The price that you pay for that is that you surrender exclusive control to the layer providing the service.

--- rod.
 
1 members found this post helpful.
Old 06-03-2011, 10:44 PM   #11
Nickew
LQ Newbie
 
Registered: May 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
I think I go for the kernel driver. The question is, " can I change the orientation and the direction (flipping upside down or even rotating the screen at this level?"
I have the feeling that it should probably using an interface provided by the hardware layer and give the characters' bitmaps and doesn't bother if the screen is upside down, am I right? if yes, then again I have to learn the driver of the hardware? right?

Thanks again, you have been bery helpful.
 
Old 06-04-2011, 12:09 AM   #12
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
If you are going to be using a kernel driver to set the orientation of the screen, your driver will have to be responsible for all of what is on the screen, so your driver can put it in whatever orientation you choose.
Yes, you will need to learn all of the details of operation for each type of hardware you want to create a driver for.
--- rod.
 
1 members found this post helpful.
Old 06-04-2011, 12:40 AM   #13
Nickew
LQ Newbie
 
Registered: May 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
I don't want to write a new kernel driver. I want to use what is availabe and modify very little so that everything stays intact in terms of compatibility with the over all system and to other high level programs.

so, I would like to know, what functionalities kernel uses form the lower level hardware and what does kernel offer to higher levels? and where are the codes related to this in the kernel source code?

Thanks
 
Old 06-04-2011, 10:39 AM   #14
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by Nickew View Post
I don't want to write a new kernel driver. I want to use what is availabe and modify very little so that everything stays intact in terms of compatibility with the over all system and to other high level programs.
Strategically, that makes sense. In practice, I can't see it working without modifying X as well.
Quote:
so, I would like to know, what functionalities kernel uses form the lower level hardware and what does kernel offer to higher levels? and where are the codes related to this in the kernel source code?
The best way to determine how to access the hardware is to dig into the code. It is in
  • linux-x.x.x/drivers/video/...
Drivers are by definition hardware dependent, so there really isn't a single correct answer.

--- rod.
 
1 members found this post helpful.
Old 06-04-2011, 11:35 PM   #15
Nickew
LQ Newbie
 
Registered: May 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
OK. I got the picture. Thanks a lot Rod.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Kernel-2.6.33.2 Blanking Graphics :-O business_kid Linux - Software 6 04-11-2010 11:49 AM
Is there a graphics package that will open CDR files? forcfed Linux - Software 5 07-02-2008 08:03 AM
2.6.11 kernel and nVidia graphics ilikejam Linux - Hardware 2 03-13-2005 12:03 AM
extract all the diagrams in a pdf file to individual graphics files on linux tcma Linux - Software 0 10-22-2004 01:52 PM
Graphics drivers on kernel 2.6/2.5 malcidragon Linux - Hardware 13 12-05-2003 11:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration