Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

Enabling the Linux Framebuffer

This is only a short guide. See /usr/src/linux/README and /usr/src/linux/Documentation/fb/ for detailed information. There is also a detailed explanation at http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html.

  1. Make sure that you have the Linux kernel source code in /usr/src/linux/.

  2. Log in as root and cd /usr/src/linux

  3. Configure the kernel:

    Run:

        make menuconfig
    

    Select "Code maturity level options" and set "Prompt for development and/or incomplete code/drivers".

    Then select "Console drivers" and set "Support for frame buffer devices" to built-in (even if it says EXPERIMENTAL). Then configure the driver. Most modern graphics cards can use the "VESA VGA graphics console"; use that or a driver that specifically matches your video card. Finally, enable "Advanced low level driver options" and make sure that 16 and 32 bpp packed pixel support are enabled.

    When you are finished, chose exit and save.

  4. Compile the kernel

    First do:

        make dep
    
    then:
        make bzImage
    

    The new kernel should now be in arch/i386/boot/bzImage.

  5. Copy the kernel to the boot directory:
        cp arch/i386/boot/bzImage /boot/linux.vesafb
    

  6. Edit /etc/lilo.conf.

    Warning: Keep a backup of /etc/lilo.conf, and have a rescue disk available. If you make a mistake, the machine may not boot.

    The file /etc/lilo.conf specifies how the system boots. The precise contents of the file varies from system to system. Here is an example:

    # LILO configuration file
    boot = /dev/hda3
    delay = 30 
    image = /boot/vmlinuz
      root = /dev/hda3
      label = Linux
      read-only # Non-UMSDOS filesystems should be mounted read-only for checking
    other=/dev/hda1
            label=nt
            table=/dev/hda
    

    Make a new "image" section that is a copy of the first one, but with

      image = /boot/linux.vesafb 
    
    and
      label = Linux-vesafb
    
    Place it just above the first image section.

    Add a line before the image section saying vga = 791. (Meaning 1024x768, 16 bpp.)

    With the above example, lilo.conf would now be:

    # LILO configuration file
    boot = /dev/hda3
    delay = 30 
    vga = 791
    image = /boot/linux.vesafb
      root = /dev/hda3
      label = Linux-vesafb
      read-only # Non-UMSDOS filesystems should be mounted read-only for checking
    image = /boot/vmlinuz
      root = /dev/hda3
      label = Linux
      read-only # Non-UMSDOS filesystems should be mounted read-only for checking
    other=/dev/hda1
            label=nt
            table=/dev/hda
    

    Do not change any existing lines in the file; just add new ones.

  7. To make the new changes take effect, run the lilo program:
        lilo
    

  8. Reboot the system. You should now see a penguin logo while the system is booting. (Or more than one on a multi-processor machine.)

  9. If it does not boot properly with the new kernel, you can boot with the old kernel by entering the label of the old image section at the LILO prompt. (with the example lilo.conf file, the old label is Linux.)

    If that does not work (probably because of an error in lilo.conf), boot the machine using your rescue disk, restore /etc/lilo.conf from backup and re-run lilo.

  10. Testing: Here's a short program that opens the frame buffer and draws a gradient-filled red square.

    #include <unistd.h>
    #include <stdio.h>
    #include <fcntl.h>
    #include <linux/fb.h>
    #include <sys/mman.h>
    
    int main()
    {
        int fbfd = 0;
        struct fb_var_screeninfo vinfo;
        struct fb_fix_screeninfo finfo;
        long int screensize = 0;
        char *fbp = 0;
        int x = 0, y = 0;
        long int location = 0;
    
        // Open the file for reading and writing
        fbfd = open("/dev/fb0", O_RDWR);
        if (!fbfd) {
            printf("Error: cannot open framebuffer device.\n");
            exit(1);
        }
        printf("The framebuffer device was opened successfully.\n");
    
        // Get fixed screen information
        if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
            printf("Error reading fixed information.\n");
            exit(2);
        }
    
        // Get variable screen information
        if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
            printf("Error reading variable information.\n");
            exit(3);
        }
    
        printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel );
    
        // Figure out the size of the screen in bytes
        screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
    
        // Map the device to memory
        fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
                           fbfd, 0);
        if ((int)fbp == -1) {
            printf("Error: failed to map framebuffer device to memory.\n");
            exit(4);
        }
        printf("The framebuffer device was mapped to memory successfully.\n");
    
        x = 100; y = 100;       // Where we are going to put the pixel
    
        // Figure out where in memory to put the pixel
        for ( y = 100; y < 300; y++ )
            for ( x = 100; x < 300; x++ ) {
    
                location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
                           (y+vinfo.yoffset) * finfo.line_length;
    
                if ( vinfo.bits_per_pixel == 32 ) {
                    *(fbp + location) = 100;        // Some blue
                    *(fbp + location + 1) = 15+(x-100)/2;     // A little green
                    *(fbp + location + 2) = 200-(y-100)/5;    // A lot of red
                    *(fbp + location + 3) = 0;      // No transparency
                } else  { //assume 16bpp
                    int b = 10;
                    int g = (x-100)/6;     // A little green
                    int r = 31-(y-100)/16;    // A lot of red
                    unsigned short int t = r<<11 | g << 5 | b;
                    *((unsigned short int*)(fbp + location)) = t;
                }
    
            }
        munmap(fbp, screensize);
        close(fbfd);
        return 0;
    }
    

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 44
  2. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
Page suivante

Le Qt Quarterly au hasard

Logo

Les développeurs viennent de Mars, les designers de Vénus

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 3.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web