Subversion Repositories Kolibri OS

Rev

Rev 1404 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #include <stdint.h>
  3. #include <drm/drmP.h>
  4. #include <drm.h>
  5. #include <drm_mm.h>
  6. #include "radeon_drm.h"
  7. #include "radeon.h"
  8. #include "radeon_object.h"
  9.  
  10. static int my_atoi(char **cmd)
  11. {
  12.     char* p = *cmd;
  13.     int val = 0;
  14.  
  15.     for (;; *p++) {
  16.         switch (*p) {
  17.         case '0' ... '9':
  18.             val = 10*val+(*p-'0');
  19.             break;
  20.         default:
  21.             *cmd = p;
  22.             return val;
  23.         }
  24.     }
  25. }
  26.  
  27. char* parse_mode(char *p, mode_t *mode)
  28. {
  29.     char c;
  30.  
  31.     while( (c = *p++) == ' ');
  32.  
  33.     if( c )
  34.     {
  35.         p--;
  36.  
  37.         mode->width = my_atoi(&p);
  38.         if(*p == 'x') p++;
  39.  
  40.         mode->height = my_atoi(&p);
  41.         if(*p == 'x') p++;
  42.  
  43.         mode->bpp = 32;
  44.  
  45.         mode->freq = my_atoi(&p);
  46.  
  47.         if( mode->freq == 0 )
  48.             mode->freq = 60;
  49.     }
  50.  
  51.     return p;
  52. };
  53.  
  54. char* parse_path(char *p, char *log)
  55. {
  56.     char  c;
  57.  
  58.     while( (c = *p++) == ' ');
  59.     p--;
  60.     while( (c = *log++ = *p++) && (c != ' '));
  61.     *log = 0;
  62.  
  63.     return p;
  64. };
  65.  
  66. void parse_cmdline(char *cmdline, mode_t *mode, char *log, int *kms)
  67. {
  68.     char *p = cmdline;
  69.  
  70.     char c = *p++;
  71.  
  72.     while( c )
  73.     {
  74.         if( c == '-')
  75.         {
  76.             switch(*p++)
  77.             {
  78.                 case 'm':
  79.                     p = parse_mode(p, mode);
  80.                     break;
  81.  
  82.                 case 'l':
  83.                     p = parse_path(p, log);
  84.                     break;
  85.  
  86.                 case 'n':
  87.                     *kms = 0;
  88.             };
  89.         };
  90.         c = *p++;
  91.     };
  92. };
  93.