src/video/ipod/SDL_ipodvideo.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/ipod/SDL_ipodvideo.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/ipod/SDL_ipodvideo.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -45,19 +45,19 @@
     1.4  
     1.5  #define _THIS SDL_VideoDevice *this
     1.6  
     1.7 -static int iPod_VideoInit (_THIS, SDL_PixelFormat * vformat);
     1.8 -static SDL_Rect **iPod_ListModes (_THIS, SDL_PixelFormat * format,
     1.9 -                                  Uint32 flags);
    1.10 -static SDL_Surface *iPod_SetVideoMode (_THIS, SDL_Surface * current,
    1.11 -                                       int width, int height, int bpp,
    1.12 -                                       Uint32 flags);
    1.13 -static int iPod_SetColors (_THIS, int firstcolor, int ncolors,
    1.14 -                           SDL_Color * colors);
    1.15 -static void iPod_UpdateRects (_THIS, int nrects, SDL_Rect * rects);
    1.16 -static void iPod_VideoQuit (_THIS);
    1.17 -static void iPod_PumpEvents (_THIS);
    1.18 +static int iPod_VideoInit(_THIS, SDL_PixelFormat * vformat);
    1.19 +static SDL_Rect **iPod_ListModes(_THIS, SDL_PixelFormat * format,
    1.20 +                                 Uint32 flags);
    1.21 +static SDL_Surface *iPod_SetVideoMode(_THIS, SDL_Surface * current,
    1.22 +                                      int width, int height, int bpp,
    1.23 +                                      Uint32 flags);
    1.24 +static int iPod_SetColors(_THIS, int firstcolor, int ncolors,
    1.25 +                          SDL_Color * colors);
    1.26 +static void iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects);
    1.27 +static void iPod_VideoQuit(_THIS);
    1.28 +static void iPod_PumpEvents(_THIS);
    1.29  
    1.30 -static long iPod_GetGeneration ();
    1.31 +static long iPod_GetGeneration();
    1.32  
    1.33  static int initd = 0;
    1.34  static int kbfd = -1;
    1.35 @@ -80,64 +80,64 @@
    1.36  static unsigned long lcd_base, lcd_rtc, lcd_width, lcd_height;
    1.37  
    1.38  static long
    1.39 -iPod_GetGeneration ()
    1.40 +iPod_GetGeneration()
    1.41  {
    1.42      int i;
    1.43      char cpuinfo[256];
    1.44      char *ptr;
    1.45      FILE *file;
    1.46  
    1.47 -    if ((file = fopen ("/proc/cpuinfo", "r")) != NULL) {
    1.48 -        while (fgets (cpuinfo, sizeof (cpuinfo), file) != NULL)
    1.49 -            if (SDL_strncmp (cpuinfo, "Revision", 8) == 0)
    1.50 +    if ((file = fopen("/proc/cpuinfo", "r")) != NULL) {
    1.51 +        while (fgets(cpuinfo, sizeof(cpuinfo), file) != NULL)
    1.52 +            if (SDL_strncmp(cpuinfo, "Revision", 8) == 0)
    1.53                  break;
    1.54 -        fclose (file);
    1.55 +        fclose(file);
    1.56      }
    1.57 -    for (i = 0; !isspace (cpuinfo[i]); i++);
    1.58 -    for (; isspace (cpuinfo[i]); i++);
    1.59 +    for (i = 0; !isspace(cpuinfo[i]); i++);
    1.60 +    for (; isspace(cpuinfo[i]); i++);
    1.61      ptr = cpuinfo + i + 2;
    1.62  
    1.63 -    return SDL_strtol (ptr, NULL, 10);
    1.64 +    return SDL_strtol(ptr, NULL, 10);
    1.65  }
    1.66  
    1.67  static int
    1.68 -iPod_Available ()
    1.69 +iPod_Available()
    1.70  {
    1.71      return 1;
    1.72  }
    1.73  
    1.74  static void
    1.75 -iPod_DeleteDevice (SDL_VideoDevice * device)
    1.76 +iPod_DeleteDevice(SDL_VideoDevice * device)
    1.77  {
    1.78 -    free (device->hidden);
    1.79 -    free (device);
    1.80 +    free(device->hidden);
    1.81 +    free(device);
    1.82  }
    1.83  
    1.84  void
    1.85 -iPod_InitOSKeymap (_THIS)
    1.86 +iPod_InitOSKeymap(_THIS)
    1.87  {
    1.88  }
    1.89  
    1.90  static SDL_VideoDevice *
    1.91 -iPod_CreateDevice (int devindex)
    1.92 +iPod_CreateDevice(int devindex)
    1.93  {
    1.94      SDL_VideoDevice *this;
    1.95  
    1.96 -    this = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice));
    1.97 +    this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
    1.98      if (this) {
    1.99 -        memset (this, 0, sizeof *this);
   1.100 +        memset(this, 0, sizeof *this);
   1.101          this->hidden = (struct SDL_PrivateVideoData *)
   1.102 -            SDL_malloc (sizeof (struct SDL_PrivateVideoData));
   1.103 +            SDL_malloc(sizeof(struct SDL_PrivateVideoData));
   1.104      }
   1.105      if (!this || !this->hidden) {
   1.106 -        SDL_OutOfMemory ();
   1.107 +        SDL_OutOfMemory();
   1.108          if (this)
   1.109 -            SDL_free (this);
   1.110 +            SDL_free(this);
   1.111          return 0;
   1.112      }
   1.113 -    memset (this->hidden, 0, sizeof (struct SDL_PrivateVideoData));
   1.114 +    memset(this->hidden, 0, sizeof(struct SDL_PrivateVideoData));
   1.115  
   1.116 -    generation = iPod_GetGeneration ();
   1.117 +    generation = iPod_GetGeneration();
   1.118  
   1.119      this->VideoInit = iPod_VideoInit;
   1.120      this->ListModes = iPod_ListModes;
   1.121 @@ -174,7 +174,7 @@
   1.122  //--//
   1.123  
   1.124  static int
   1.125 -iPod_VideoInit (_THIS, SDL_PixelFormat * vformat)
   1.126 +iPod_VideoInit(_THIS, SDL_PixelFormat * vformat)
   1.127  {
   1.128      if (!initd) {
   1.129          /*** Code adapted/copied from SDL fbcon driver. ***/
   1.130 @@ -184,65 +184,65 @@
   1.131          int i, tty0_fd;
   1.132  
   1.133          dbgout =
   1.134 -            fdopen (open ("/etc/sdlpod.log", O_WRONLY | O_SYNC | O_APPEND),
   1.135 -                    "a");
   1.136 +            fdopen(open("/etc/sdlpod.log", O_WRONLY | O_SYNC | O_APPEND),
   1.137 +                   "a");
   1.138          if (dbgout) {
   1.139 -            setbuf (dbgout, 0);
   1.140 -            fprintf (dbgout, "--> Started SDL <--\n");
   1.141 +            setbuf(dbgout, 0);
   1.142 +            fprintf(dbgout, "--> Started SDL <--\n");
   1.143          }
   1.144          // Try to query for a free VT
   1.145          tty0_fd = -1;
   1.146          for (i = 0; tty0[i] && (tty0_fd < 0); ++i) {
   1.147 -            tty0_fd = open (tty0[i], O_WRONLY, 0);
   1.148 +            tty0_fd = open(tty0[i], O_WRONLY, 0);
   1.149          }
   1.150          if (tty0_fd < 0) {
   1.151 -            tty0_fd = dup (0);  /* Maybe stdin is a VT? */
   1.152 +            tty0_fd = dup(0);   /* Maybe stdin is a VT? */
   1.153          }
   1.154 -        ioctl (tty0_fd, VT_OPENQRY, &curvt);
   1.155 -        close (tty0_fd);
   1.156 +        ioctl(tty0_fd, VT_OPENQRY, &curvt);
   1.157 +        close(tty0_fd);
   1.158  
   1.159 -        tty0_fd = open ("/dev/tty", O_RDWR, 0);
   1.160 +        tty0_fd = open("/dev/tty", O_RDWR, 0);
   1.161          if (tty0_fd >= 0) {
   1.162 -            ioctl (tty0_fd, TIOCNOTTY, 0);
   1.163 -            close (tty0_fd);
   1.164 +            ioctl(tty0_fd, TIOCNOTTY, 0);
   1.165 +            close(tty0_fd);
   1.166          }
   1.167  
   1.168 -        if ((geteuid () == 0) && (curvt > 0)) {
   1.169 +        if ((geteuid() == 0) && (curvt > 0)) {
   1.170              for (i = 0; vcs[i] && (kbfd < 0); ++i) {
   1.171                  char vtpath[12];
   1.172  
   1.173 -                SDL_snprintf (vtpath, SDL_arraysize (vtpath), vcs[i], curvt);
   1.174 -                kbfd = open (vtpath, O_RDWR);
   1.175 +                SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], curvt);
   1.176 +                kbfd = open(vtpath, O_RDWR);
   1.177              }
   1.178          }
   1.179          if (kbfd < 0) {
   1.180              if (dbgout)
   1.181 -                fprintf (dbgout, "Couldn't open any VC\n");
   1.182 +                fprintf(dbgout, "Couldn't open any VC\n");
   1.183              return -1;
   1.184          }
   1.185          if (dbgout)
   1.186 -            fprintf (stderr, "Current VT: %d\n", curvt);
   1.187 +            fprintf(stderr, "Current VT: %d\n", curvt);
   1.188  
   1.189          if (kbfd >= 0) {
   1.190              /* Switch to the correct virtual terminal */
   1.191              if (curvt > 0) {
   1.192                  struct vt_stat vtstate;
   1.193  
   1.194 -                if (ioctl (kbfd, VT_GETSTATE, &vtstate) == 0) {
   1.195 +                if (ioctl(kbfd, VT_GETSTATE, &vtstate) == 0) {
   1.196                      oldvt = vtstate.v_active;
   1.197                  }
   1.198 -                if (ioctl (kbfd, VT_ACTIVATE, curvt) == 0) {
   1.199 +                if (ioctl(kbfd, VT_ACTIVATE, curvt) == 0) {
   1.200                      if (dbgout)
   1.201 -                        fprintf (dbgout, "Waiting for switch to this VT... ");
   1.202 -                    ioctl (kbfd, VT_WAITACTIVE, curvt);
   1.203 +                        fprintf(dbgout, "Waiting for switch to this VT... ");
   1.204 +                    ioctl(kbfd, VT_WAITACTIVE, curvt);
   1.205                      if (dbgout)
   1.206 -                        fprintf (dbgout, "done!\n");
   1.207 +                        fprintf(dbgout, "done!\n");
   1.208                  }
   1.209              }
   1.210              // Set terminal input mode
   1.211 -            if (tcgetattr (kbfd, &old_termios) < 0) {
   1.212 +            if (tcgetattr(kbfd, &old_termios) < 0) {
   1.213                  if (dbgout)
   1.214 -                    fprintf (dbgout, "Can't get termios\n");
   1.215 +                    fprintf(dbgout, "Can't get termios\n");
   1.216                  return -1;
   1.217              }
   1.218              cur_termios = old_termios;
   1.219 @@ -257,32 +257,32 @@
   1.220              cur_termios.c_cc[VMIN] = 0;
   1.221              cur_termios.c_cc[VTIME] = 0;
   1.222  
   1.223 -            if (tcsetattr (kbfd, TCSAFLUSH, &cur_termios) < 0) {
   1.224 +            if (tcsetattr(kbfd, TCSAFLUSH, &cur_termios) < 0) {
   1.225                  if (dbgout)
   1.226 -                    fprintf (dbgout, "Can't set termios\n");
   1.227 +                    fprintf(dbgout, "Can't set termios\n");
   1.228                  return -1;
   1.229              }
   1.230 -            if (ioctl (kbfd, KDSKBMODE, K_MEDIUMRAW) < 0) {
   1.231 +            if (ioctl(kbfd, KDSKBMODE, K_MEDIUMRAW) < 0) {
   1.232                  if (dbgout)
   1.233 -                    fprintf (dbgout, "Can't set medium-raw mode\n");
   1.234 +                    fprintf(dbgout, "Can't set medium-raw mode\n");
   1.235                  return -1;
   1.236              }
   1.237 -            if (ioctl (kbfd, KDSETMODE, KD_GRAPHICS) < 0) {
   1.238 +            if (ioctl(kbfd, KDSETMODE, KD_GRAPHICS) < 0) {
   1.239                  if (dbgout)
   1.240 -                    fprintf (dbgout, "Can't set graphics\n");
   1.241 +                    fprintf(dbgout, "Can't set graphics\n");
   1.242                  return -1;
   1.243              }
   1.244          }
   1.245          // Open the framebuffer
   1.246 -        if ((fbfd = open ("/dev/fb0", O_RDWR)) < 0) {
   1.247 +        if ((fbfd = open("/dev/fb0", O_RDWR)) < 0) {
   1.248              if (dbgout)
   1.249 -                fprintf (dbgout, "Can't open framebuffer\n");
   1.250 +                fprintf(dbgout, "Can't open framebuffer\n");
   1.251              return -1;
   1.252          } else {
   1.253              struct fb_var_screeninfo vinfo;
   1.254  
   1.255              if (dbgout)
   1.256 -                fprintf (dbgout, "Generation: %ld\n", generation);
   1.257 +                fprintf(dbgout, "Generation: %ld\n", generation);
   1.258  
   1.259              if (generation >= 40000) {
   1.260                  lcd_base = IPOD_NEW_LCD_BASE;
   1.261 @@ -290,15 +290,15 @@
   1.262                  lcd_base = IPOD_OLD_LCD_BASE;
   1.263              }
   1.264  
   1.265 -            ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo);
   1.266 -            close (fbfd);
   1.267 +            ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo);
   1.268 +            close(fbfd);
   1.269  
   1.270              if (lcd_base == IPOD_OLD_LCD_BASE)
   1.271                  lcd_rtc = IPOD_OLD_LCD_RTC;
   1.272              else if (lcd_base == IPOD_NEW_LCD_BASE)
   1.273                  lcd_rtc = IPOD_NEW_LCD_RTC;
   1.274              else {
   1.275 -                SDL_SetError ("Unknown iPod version");
   1.276 +                SDL_SetError("Unknown iPod version");
   1.277                  return -1;
   1.278              }
   1.279  
   1.280 @@ -306,10 +306,10 @@
   1.281              lcd_height = vinfo.yres;
   1.282  
   1.283              if (dbgout)
   1.284 -                fprintf (dbgout, "LCD is %dx%d\n", lcd_width, lcd_height);
   1.285 +                fprintf(dbgout, "LCD is %dx%d\n", lcd_width, lcd_height);
   1.286          }
   1.287  
   1.288 -        fcntl (kbfd, F_SETFL, O_RDWR | O_NONBLOCK);
   1.289 +        fcntl(kbfd, F_SETFL, O_RDWR | O_NONBLOCK);
   1.290  
   1.291          /* Determine the current screen size */
   1.292          this->info.current_w = lcd_width;
   1.293 @@ -327,25 +327,25 @@
   1.294  
   1.295          initd = 1;
   1.296          if (dbgout)
   1.297 -            fprintf (dbgout, "Initialized.\n\n");
   1.298 +            fprintf(dbgout, "Initialized.\n\n");
   1.299      }
   1.300      return 0;
   1.301  }
   1.302  
   1.303  static SDL_Rect **
   1.304 -iPod_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.305 +iPod_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.306  {
   1.307      int width, height, fd;
   1.308      static SDL_Rect r;
   1.309      static SDL_Rect *rs[2] = { &r, 0 };
   1.310  
   1.311 -    if ((fd = open ("/dev/fb0", O_RDWR)) < 0) {
   1.312 +    if ((fd = open("/dev/fb0", O_RDWR)) < 0) {
   1.313          return 0;
   1.314      } else {
   1.315          struct fb_var_screeninfo vinfo;
   1.316  
   1.317 -        ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo);
   1.318 -        close (fbfd);
   1.319 +        ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo);
   1.320 +        close(fbfd);
   1.321  
   1.322          width = vinfo.xres;
   1.323          height = vinfo.yres;
   1.324 @@ -358,8 +358,8 @@
   1.325  
   1.326  
   1.327  static SDL_Surface *
   1.328 -iPod_SetVideoMode (_THIS, SDL_Surface * current, int width, int height,
   1.329 -                   int bpp, Uint32 flags)
   1.330 +iPod_SetVideoMode(_THIS, SDL_Surface * current, int width, int height,
   1.331 +                  int bpp, Uint32 flags)
   1.332  {
   1.333      Uint32 Rmask, Gmask, Bmask;
   1.334      if (bpp > 8) {
   1.335 @@ -371,18 +371,18 @@
   1.336      }
   1.337  
   1.338      if (this->hidden->buffer)
   1.339 -        SDL_free (this->hidden->buffer);
   1.340 -    this->hidden->buffer = SDL_malloc (width * height * (bpp / 8));
   1.341 +        SDL_free(this->hidden->buffer);
   1.342 +    this->hidden->buffer = SDL_malloc(width * height * (bpp / 8));
   1.343      if (!this->hidden->buffer) {
   1.344 -        SDL_SetError ("Couldn't allocate buffer for requested mode");
   1.345 +        SDL_SetError("Couldn't allocate buffer for requested mode");
   1.346          return 0;
   1.347      }
   1.348  
   1.349 -    memset (this->hidden->buffer, 0, width * height * (bpp / 8));
   1.350 +    memset(this->hidden->buffer, 0, width * height * (bpp / 8));
   1.351  
   1.352 -    if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) {
   1.353 -        SDL_SetError ("Couldn't allocate new pixel format");
   1.354 -        SDL_free (this->hidden->buffer);
   1.355 +    if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) {
   1.356 +        SDL_SetError("Couldn't allocate new pixel format");
   1.357 +        SDL_free(this->hidden->buffer);
   1.358          this->hidden->buffer = 0;
   1.359          return 0;
   1.360      }
   1.361 @@ -408,7 +408,7 @@
   1.362  }
   1.363  
   1.364  static int
   1.365 -iPod_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors)
   1.366 +iPod_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
   1.367  {
   1.368      if (SDL_VideoSurface && SDL_VideoSurface->format
   1.369          && SDL_VideoSurface->format->palette) {
   1.370 @@ -425,21 +425,21 @@
   1.371  }
   1.372  
   1.373  static void
   1.374 -iPod_VideoQuit (_THIS)
   1.375 +iPod_VideoQuit(_THIS)
   1.376  {
   1.377 -    ioctl (kbfd, KDSETMODE, KD_TEXT);
   1.378 -    tcsetattr (kbfd, TCSAFLUSH, &old_termios);
   1.379 +    ioctl(kbfd, KDSETMODE, KD_TEXT);
   1.380 +    tcsetattr(kbfd, TCSAFLUSH, &old_termios);
   1.381      old_kbmode = -1;
   1.382  
   1.383      if (oldvt > 0)
   1.384 -        ioctl (kbfd, VT_ACTIVATE, oldvt);
   1.385 +        ioctl(kbfd, VT_ACTIVATE, oldvt);
   1.386  
   1.387      if (kbfd > 0)
   1.388 -        close (kbfd);
   1.389 +        close(kbfd);
   1.390  
   1.391      if (dbgout) {
   1.392 -        fprintf (dbgout, "<-- Ended SDL -->\n");
   1.393 -        fclose (dbgout);
   1.394 +        fprintf(dbgout, "<-- Ended SDL -->\n");
   1.395 +        fclose(dbgout);
   1.396      }
   1.397  
   1.398      kbfd = -1;
   1.399 @@ -473,7 +473,7 @@
   1.400  
   1.401  
   1.402  static void
   1.403 -iPod_keyboard ()
   1.404 +iPod_keyboard()
   1.405  {
   1.406      unsigned char keybuf[128];
   1.407      int i, nread;
   1.408 @@ -482,26 +482,26 @@
   1.409  
   1.410      keysym.mod = 0;
   1.411      keysym.scancode = 0xff;
   1.412 -    memset (&ev, 0, sizeof (SDL_Event));
   1.413 +    memset(&ev, 0, sizeof(SDL_Event));
   1.414  
   1.415 -    nread = read (kbfd, keybuf, 128);
   1.416 +    nread = read(kbfd, keybuf, 128);
   1.417      for (i = 0; i < nread; i++) {
   1.418          char ascii = iPod_SC_keymap[keybuf[i] & 0x7f];
   1.419  
   1.420          if (dbgout)
   1.421 -            fprintf (dbgout, "Key! %02x is %c %s", keybuf[i], ascii,
   1.422 -                     (keybuf[i] & 0x80) ? "up" : "down");
   1.423 +            fprintf(dbgout, "Key! %02x is %c %s", keybuf[i], ascii,
   1.424 +                    (keybuf[i] & 0x80) ? "up" : "down");
   1.425  
   1.426          keysym.sym = keysym.unicode = ascii;
   1.427          ev.type = (keybuf[i] & 0x80) ? SDL_KEYUP : SDL_KEYDOWN;
   1.428          ev.key.state = 0;
   1.429          ev.key.keysym = keysym;
   1.430 -        SDL_PushEvent (&ev);
   1.431 +        SDL_PushEvent(&ev);
   1.432      }
   1.433  }
   1.434  
   1.435  static void
   1.436 -iPod_PumpEvents (_THIS)
   1.437 +iPod_PumpEvents(_THIS)
   1.438  {
   1.439      fd_set fdset;
   1.440      int max_fd = 0;
   1.441 @@ -511,21 +511,21 @@
   1.442      do {
   1.443          posted = 0;
   1.444  
   1.445 -        FD_ZERO (&fdset);
   1.446 +        FD_ZERO(&fdset);
   1.447          if (kbfd >= 0) {
   1.448 -            FD_SET (kbfd, &fdset);
   1.449 +            FD_SET(kbfd, &fdset);
   1.450              max_fd = kbfd;
   1.451          }
   1.452          if (dbgout)
   1.453 -            fprintf (dbgout, "Selecting");
   1.454 -        if (select (max_fd + 1, &fdset, 0, 0, &zero) > 0) {
   1.455 +            fprintf(dbgout, "Selecting");
   1.456 +        if (select(max_fd + 1, &fdset, 0, 0, &zero) > 0) {
   1.457              if (dbgout)
   1.458 -                fprintf (dbgout, " -> match!\n");
   1.459 -            iPod_keyboard ();
   1.460 +                fprintf(dbgout, " -> match!\n");
   1.461 +            iPod_keyboard();
   1.462              posted++;
   1.463          }
   1.464          if (dbgout)
   1.465 -            fprintf (dbgout, "\n");
   1.466 +            fprintf(dbgout, "\n");
   1.467      }
   1.468      while (posted);
   1.469  }
   1.470 @@ -541,17 +541,17 @@
   1.471  
   1.472  /* get current usec counter */
   1.473  static int
   1.474 -M_timer_get_current (void)
   1.475 +M_timer_get_current(void)
   1.476  {
   1.477 -    return inl (lcd_rtc);
   1.478 +    return inl(lcd_rtc);
   1.479  }
   1.480  
   1.481  /* check if number of useconds has past */
   1.482  static int
   1.483 -M_timer_check (int clock_start, int usecs)
   1.484 +M_timer_check(int clock_start, int usecs)
   1.485  {
   1.486      unsigned long clock;
   1.487 -    clock = inl (lcd_rtc);
   1.488 +    clock = inl(lcd_rtc);
   1.489  
   1.490      if ((clock - clock_start) >= usecs) {
   1.491          return 1;
   1.492 @@ -562,60 +562,60 @@
   1.493  
   1.494  /* wait for LCD with timeout */
   1.495  static void
   1.496 -M_lcd_wait_write (void)
   1.497 +M_lcd_wait_write(void)
   1.498  {
   1.499 -    if ((inl (lcd_base) & 0x8000) != 0) {
   1.500 -        int start = M_timer_get_current ();
   1.501 +    if ((inl(lcd_base) & 0x8000) != 0) {
   1.502 +        int start = M_timer_get_current();
   1.503  
   1.504          do {
   1.505 -            if ((inl (lcd_base) & (unsigned int) 0x8000) == 0)
   1.506 +            if ((inl(lcd_base) & (unsigned int) 0x8000) == 0)
   1.507                  break;
   1.508          }
   1.509 -        while (M_timer_check (start, 1000) == 0);
   1.510 +        while (M_timer_check(start, 1000) == 0);
   1.511      }
   1.512  }
   1.513  
   1.514  
   1.515  /* send LCD data */
   1.516  static void
   1.517 -M_lcd_send_data (int data_lo, int data_hi)
   1.518 +M_lcd_send_data(int data_lo, int data_hi)
   1.519  {
   1.520 -    M_lcd_wait_write ();
   1.521 +    M_lcd_wait_write();
   1.522  
   1.523 -    outl (data_lo, lcd_base + LCD_DATA);
   1.524 +    outl(data_lo, lcd_base + LCD_DATA);
   1.525  
   1.526 -    M_lcd_wait_write ();
   1.527 +    M_lcd_wait_write();
   1.528  
   1.529 -    outl (data_hi, lcd_base + LCD_DATA);
   1.530 +    outl(data_hi, lcd_base + LCD_DATA);
   1.531  
   1.532  }
   1.533  
   1.534  /* send LCD command */
   1.535  static void
   1.536 -M_lcd_prepare_cmd (int cmd)
   1.537 +M_lcd_prepare_cmd(int cmd)
   1.538  {
   1.539 -    M_lcd_wait_write ();
   1.540 +    M_lcd_wait_write();
   1.541  
   1.542 -    outl (0x0, lcd_base + LCD_CMD);
   1.543 +    outl(0x0, lcd_base + LCD_CMD);
   1.544  
   1.545 -    M_lcd_wait_write ();
   1.546 +    M_lcd_wait_write();
   1.547  
   1.548 -    outl (cmd, lcd_base + LCD_CMD);
   1.549 +    outl(cmd, lcd_base + LCD_CMD);
   1.550  
   1.551  }
   1.552  
   1.553  /* send LCD command and data */
   1.554  static void
   1.555 -M_lcd_cmd_and_data (int cmd, int data_lo, int data_hi)
   1.556 +M_lcd_cmd_and_data(int cmd, int data_lo, int data_hi)
   1.557  {
   1.558 -    M_lcd_prepare_cmd (cmd);
   1.559 +    M_lcd_prepare_cmd(cmd);
   1.560  
   1.561 -    M_lcd_send_data (data_lo, data_hi);
   1.562 +    M_lcd_send_data(data_lo, data_hi);
   1.563  }
   1.564  
   1.565  // Copied from uW
   1.566  static void
   1.567 -M_update_display (int sx, int sy, int mx, int my)
   1.568 +M_update_display(int sx, int sy, int mx, int my)
   1.569  {
   1.570      int y;
   1.571      unsigned short cursor_pos;
   1.572 @@ -630,17 +630,17 @@
   1.573          int x;
   1.574  
   1.575          /* move the cursor */
   1.576 -        M_lcd_cmd_and_data (0x11, cursor_pos >> 8, cursor_pos & 0xff);
   1.577 +        M_lcd_cmd_and_data(0x11, cursor_pos >> 8, cursor_pos & 0xff);
   1.578  
   1.579          /* setup for printing */
   1.580 -        M_lcd_prepare_cmd (0x12);
   1.581 +        M_lcd_prepare_cmd(0x12);
   1.582  
   1.583          img_data = ipod_scr + (sx << 1) + (y * (lcd_width / 4));
   1.584  
   1.585          /* loops up to 160 times */
   1.586          for (x = sx; x <= mx; x++) {
   1.587              /* display eight pixels */
   1.588 -            M_lcd_send_data (*(img_data + 1), *img_data);
   1.589 +            M_lcd_send_data(*(img_data + 1), *img_data);
   1.590  
   1.591              img_data += 2;
   1.592          }
   1.593 @@ -652,17 +652,17 @@
   1.594  
   1.595  /* get current usec counter */
   1.596  static int
   1.597 -C_timer_get_current (void)
   1.598 +C_timer_get_current(void)
   1.599  {
   1.600 -    return inl (0x60005010);
   1.601 +    return inl(0x60005010);
   1.602  }
   1.603  
   1.604  /* check if number of useconds has past */
   1.605  static int
   1.606 -C_timer_check (int clock_start, int usecs)
   1.607 +C_timer_check(int clock_start, int usecs)
   1.608  {
   1.609      unsigned long clock;
   1.610 -    clock = inl (0x60005010);
   1.611 +    clock = inl(0x60005010);
   1.612  
   1.613      if ((clock - clock_start) >= usecs) {
   1.614          return 1;
   1.615 @@ -673,30 +673,30 @@
   1.616  
   1.617  /* wait for LCD with timeout */
   1.618  static void
   1.619 -C_lcd_wait_write (void)
   1.620 +C_lcd_wait_write(void)
   1.621  {
   1.622 -    if ((inl (0x70008A0C) & 0x80000000) != 0) {
   1.623 -        int start = C_timer_get_current ();
   1.624 +    if ((inl(0x70008A0C) & 0x80000000) != 0) {
   1.625 +        int start = C_timer_get_current();
   1.626  
   1.627          do {
   1.628 -            if ((inl (0x70008A0C) & 0x80000000) == 0)
   1.629 +            if ((inl(0x70008A0C) & 0x80000000) == 0)
   1.630                  break;
   1.631          }
   1.632 -        while (C_timer_check (start, 1000) == 0);
   1.633 +        while (C_timer_check(start, 1000) == 0);
   1.634      }
   1.635  }
   1.636  static void
   1.637 -C_lcd_cmd_data (int cmd, int data)
   1.638 +C_lcd_cmd_data(int cmd, int data)
   1.639  {
   1.640 -    C_lcd_wait_write ();
   1.641 -    outl (cmd | 0x80000000, 0x70008A0C);
   1.642 +    C_lcd_wait_write();
   1.643 +    outl(cmd | 0x80000000, 0x70008A0C);
   1.644  
   1.645 -    C_lcd_wait_write ();
   1.646 -    outl (data | 0x80000000, 0x70008A0C);
   1.647 +    C_lcd_wait_write();
   1.648 +    outl(data | 0x80000000, 0x70008A0C);
   1.649  }
   1.650  
   1.651  static void
   1.652 -C_update_display (int sx, int sy, int mx, int my)
   1.653 +C_update_display(int sx, int sy, int mx, int my)
   1.654  {
   1.655      int height = (my - sy) + 1;
   1.656      int width = (mx - sx) + 1;
   1.657 @@ -707,14 +707,13 @@
   1.658          width++;
   1.659  
   1.660      /* start X and Y */
   1.661 -    C_lcd_cmd_data (0x12, (sy & 0xff));
   1.662 -    C_lcd_cmd_data (0x13, (((SDL_VideoSurface->w - 1) - sx) & 0xff));
   1.663 +    C_lcd_cmd_data(0x12, (sy & 0xff));
   1.664 +    C_lcd_cmd_data(0x13, (((SDL_VideoSurface->w - 1) - sx) & 0xff));
   1.665  
   1.666      /* max X and Y */
   1.667 -    C_lcd_cmd_data (0x15, (((sy + height) - 1) & 0xff));
   1.668 -    C_lcd_cmd_data (0x16,
   1.669 -                    (((((SDL_VideoSurface->w - 1) - sx) - width) +
   1.670 -                      1) & 0xff));
   1.671 +    C_lcd_cmd_data(0x15, (((sy + height) - 1) & 0xff));
   1.672 +    C_lcd_cmd_data(0x16,
   1.673 +                   (((((SDL_VideoSurface->w - 1) - sx) - width) + 1) & 0xff));
   1.674  
   1.675      addr += sx + sy * SDL_VideoSurface->pitch;
   1.676  
   1.677 @@ -730,9 +729,9 @@
   1.678              pixels_to_write = (width * h) * 2;
   1.679          }
   1.680  
   1.681 -        outl (0x10000080, 0x70008A20);
   1.682 -        outl ((pixels_to_write - 1) | 0xC0010000, 0x70008A24);
   1.683 -        outl (0x34000000, 0x70008A20);
   1.684 +        outl(0x10000080, 0x70008A20);
   1.685 +        outl((pixels_to_write - 1) | 0xC0010000, 0x70008A24);
   1.686 +        outl(0x34000000, 0x70008A20);
   1.687  
   1.688          /* for each row */
   1.689          for (x = 0; x < h; x++) {
   1.690 @@ -743,18 +742,18 @@
   1.691                  two_pixels = addr[0] | (addr[1] << 16);
   1.692                  addr += 2;
   1.693  
   1.694 -                while ((inl (0x70008A20) & 0x1000000) == 0);
   1.695 +                while ((inl(0x70008A20) & 0x1000000) == 0);
   1.696  
   1.697                  /* output 2 pixels */
   1.698 -                outl (two_pixels, 0x70008B00);
   1.699 +                outl(two_pixels, 0x70008B00);
   1.700              }
   1.701  
   1.702              addr += SDL_VideoSurface->w - width;
   1.703          }
   1.704  
   1.705 -        while ((inl (0x70008A20) & 0x4000000) == 0);
   1.706 +        while ((inl(0x70008A20) & 0x4000000) == 0);
   1.707  
   1.708 -        outl (0x0, 0x70008A24);
   1.709 +        outl(0x0, 0x70008A24);
   1.710  
   1.711          height = height - h;
   1.712      }
   1.713 @@ -762,10 +761,10 @@
   1.714  
   1.715  // Should work with photo. However, I don't have one, so I'm not sure.
   1.716  static void
   1.717 -iPod_UpdateRects (_THIS, int nrects, SDL_Rect * rects)
   1.718 +iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects)
   1.719  {
   1.720      if (SDL_VideoSurface->format->BitsPerPixel == 16) {
   1.721 -        C_update_display (0, 0, lcd_width, lcd_height);
   1.722 +        C_update_display(0, 0, lcd_width, lcd_height);
   1.723      } else {
   1.724          int i, y, x;
   1.725          for (i = 0; i < nrects; i++) {
   1.726 @@ -789,7 +788,7 @@
   1.727              }
   1.728          }
   1.729  
   1.730 -        M_update_display (0, 0, lcd_width, lcd_height);
   1.731 +        M_update_display(0, 0, lcd_width, lcd_height);
   1.732      }
   1.733  }
   1.734