Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 01 Sep 2014, 04:22
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
improve Xfbdev with kernel patch
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Wed 13 Jun 2012, 14:42    Post subject:  improve Xfbdev with kernel patch  

With Xvesa being deprecated (actually completely gone in xorg), the last remaining small Xserver is Xfbdev, but it has one big hurdle.
One of the things that makes Xorg a necessity is all of the manual kernel command line interaction by the user that is needed to set the resolution of the frame buffer. let's see if we can automate that

AFAIK, all of the code is in arch/x86/boot/video.c
Code:
void set_video(void)
{...
   for (;;) {
      if (mode == ASK_VGA)
         mode = mode_menu();
/* TODO:   if (mode == MAX_VGA) mode = mode_max(); */
      if (!set_mode(mode))
         break;
...}


which would need a function:
static unsigned int mode_max(); /* based on mode_menu()*/
here is my best guess:

Code:
static void modemax(void)
{
   struct card_info *card;
   struct mode_info *mi;
   int i;
   int nmodes;
   int visible;
   u16 mode_max;
   u16 res_max = 0;

   nmodes = 0;
   for (card = video_cards; card < video_cards_end; card++)
      nmodes += card->nmodes;

   for (card = video_cards; card < video_cards_end; card++) {
      mi = card->modes;
      for (i = 0; i < card->nmodes; i++, mi++) {
         visible = mi->x && mi->y;
         if (!visible)
            continue; /* Hidden mode */
         if (!mi->depth)
            continue; /* I _think_ we need depth */
         if ((mi->x * mi->y * mi->depth) > res_max){
            res_max=(mi->x * mi->y * mi->depth);
            mode_max = mi->mode ? mi->mode : (mi->y << 8)+mi->x;
         }
      }
   }
return (mode_max)
}


assuming we can get the above to work, we'd need to wedge in a vga=max parameter (but for testing we can just use the vga=ask code by replacing mode_menu with the modemax code)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Wed 13 Jun 2012, 19:06    Post subject:  

ok, here is the quick hack that I am going to _try_ to build and test it by using vga=ask
Code:
static unsigned int mode_menu(void)
{
   struct card_info *card;
   struct mode_info *mi;
   int i;
   int visible;
   u16 mode_max;
   u16 res_max = 0;

   for (card = video_cards; card < video_cards_end; card++) {
      mi = card->modes;
      for (i = 0; i < card->nmodes; i++, mi++) {
         visible = mi->x && mi->y;
         if (!visible)
            continue; /* Hidden mode */
         if (!mi->depth)
            continue; /* I _think_ we need depth */
         if ((mi->x * mi->y * mi->depth) > res_max){
            res_max=(mi->x * mi->y * mi->depth);
            mode_max = mi->mode ? mi->mode : (mi->y << 8)+mi->x;
         }
      }
   }
return (mode_max)
}

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Thu 14 Jun 2012, 03:42    Post subject:  

I think the code should first try to guess the maximum resolution rather than asking the user. If that doesn't work, then ask the user.

I think set_mode() returns nonzero in case of failure.

Here's the function that finds maximum resolution available. If multiple modes with same resolution exist, one with maximum depth is selected.
Code:
u16 guess_max_resolution(void)
{
   struct card_info *card;
   struct mode_info *mi;
   
   unsigned long long max_pixels = 0;
   unsigned int max_depth = 0;
   u16 sel_mode = 0;
   
   //Iterate for each mode
   for (card = video_cards; card < video_cards_end; card++)
   {
      int i;
      mi = card->modes;
      for (i = 0; i < card->nmodes; i++, mi++)
      {
         //Avoid 'hidden modes'
         int visible = mi->x && mi->y;
         if (!visible) continue;
         
         //Uncomment this if depth is required
         //if (! mi->depth) continue;
         
         unsigned long long one_pixels = mi->x * mi->y;
         u16 onemode = mi->mode ? mi->mode : (mi->y << 8) + mi->x;
         //Check whether this one is higher
         if (one_pixels > max_pixels)
         {
            //Select this one
            sel_mode = onemode;
            max_pixels = one_pixels;
            max_depth = mi->depth;
         }
         else if (one_pixels == max_pixels)
         {
            //Check for maximum depth
            if (mi->depth)
            {
               if (mi->depth > max_depth)
               {
                  //Select this one
                  sel_mode = onemode;
                  max_depth = mi->depth;
               }
            }
         }
      }
   }
   
   return sel_mode;
}

It could be integrated like this:
Code:

void set_video(void)
{
   ...
   int not_guessed = 1;
   for (;;)
   {
      if (mode == ASK_VGA)
      {
         //If guessing maximum resolution hasn't been tried yet try it now
         if (not_guessed)
         {
            mode = guess_max_resolution();
            not_guessed = 0;
         }
         else
            mode = mode_menu();
      }
      
      if (!set_mode(mode))
         break;
      
      printf("Undefined video mode number: %x\n", mode);
      mode = ASK_VGA;
   }
   ...
}
Back to top
View user's profile Send private message 
PANZERKOPF

Joined: 16 Dec 2009
Posts: 280
Location: Earth

PostPosted: Fri 15 Jun 2012, 15:53    Post subject: Re: improve Xfbdev with kernel patch  

technosaurus wrote:

One of the things that makes Xorg a necessity is all of the manual kernel command line interaction by the user that is needed to set the resolution of the frame buffer.

It seems there is another way to get a working framebuffer. Kernel has several framebuffer modules for particular videocards (nvidiafb, radeonfb etc.). We can
boot in usual text mode, load a module, tune framebuffer with fbset utility then load Xfbdev server. I guess that framebuffer should be faster than VESA one.

_________________
SUUM CUIQUE.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1009s ][ Queries: 12 (0.0358s) ][ GZIP on ]