DBoxlcd: cosmetic whitespace
authorMirakels <mirakels@openpli.org>
Fri, 4 Dec 2015 10:34:02 +0000 (11:34 +0100)
committerMirakels <mirakels@openpli.org>
Fri, 4 Dec 2015 10:34:02 +0000 (11:34 +0100)
lib/gdi/lcd.cpp

index 3714670..865fa39 100644 (file)
@@ -17,7 +17,7 @@ eLCD *eLCD::instance;
 eLCD::eLCD()
 {
        lcdfd = -1;
-       locked=0;
+       locked = 0;
        instance = this;
 }
 
@@ -29,10 +29,10 @@ eLCD *eLCD::getInstance()
 void eLCD::setSize(int xres, int yres, int bpp)
 {
        res = eSize(xres, yres);
-       _buffer=new unsigned char[xres * yres * bpp/8];
-       memset(_buffer, 0, res.height()*res.width()*bpp/8);
-       _stride=res.width()*bpp/8;
-       eDebug("[eLCD] (%dx%dx%d) buffer %p %d bytes, stride %d", xres, yres, bpp, _buffer, xres*yres*bpp/8, _stride);
+       _buffer = new unsigned char[xres * yres * bpp/8];
+       memset(_buffer, 0, res.height() * res.width() * bpp / 8);
+       _stride = res.width() * bpp / 8;
+       eDebug("[eLCD] (%dx%dx%d) buffer %p %d bytes, stride %d", xres, yres, bpp, _buffer, xres * yres * bpp / 8, _stride);
 }
 
 eLCD::~eLCD()
@@ -46,13 +46,13 @@ int eLCD::lock()
        if (locked)
                return -1;
 
-       locked=1;
+       locked = 1;
        return lcdfd;
 }
 
 void eLCD::unlock()
 {
-       locked=0;
+       locked = 0;
 }
 
 #ifdef HAVE_TEXTLCD
@@ -69,7 +69,7 @@ void eLCD::renderText(ePoint start, const char *text)
 
 eDBoxLCD::eDBoxLCD()
 {
-       int xres=132, yres=64, bpp=8;
+       int xres = 132, yres = 64, bpp = 8;
        flipped = false;
        inverted = 0;
        lcd_type = 0;
@@ -81,10 +81,9 @@ eDBoxLCD::eDBoxLCD()
                    !access("/proc/stb/fp/oled_brightness", W_OK) )
                        lcd_type = 2;
                lcdfd = open("/dev/dbox/lcd0", O_RDWR);
-       } else
-       {
-               lcd_type = 1;
        }
+       else
+               lcd_type = 1;
 
        if (lcdfd < 0)
                eDebug("[eDboxLCD] No oled0 or lcd0 device found!");
@@ -98,7 +97,7 @@ eDBoxLCD::eDBoxLCD()
 #define        LCD_MODE_BIN            1
 #endif
 
-               int i=LCD_MODE_BIN;
+               int i = LCD_MODE_BIN;
                ioctl(lcdfd, LCD_IOCTL_ASC_MODE, &i);
                FILE *f = fopen("/proc/stb/lcd/xres", "r");
                if (f)
@@ -156,13 +155,13 @@ int eDBoxLCD::setLCDContrast(int contrast)
        eDebug("[eDboxLCD] setLCDContrast %d", contrast);
 
        int fp;
-       if((fp=open("/dev/dbox/fp0", O_RDWR))<0)
+       if((fp = open("/dev/dbox/fp0", O_RDWR)) < 0)
        {
                eDebug("[eDboxLCD] can't open /dev/dbox/fp0: %m");
                return(-1);
        }
 
-       if(ioctl(lcdfd, LCD_IOCTL_SRV, &contrast)<0)
+       if(ioctl(lcdfd, LCD_IOCTL_SRV, &contrast) < 0)
                eDebug("[eDboxLCD] can't set lcd contrast: %m");
        close(fp);
 #endif
@@ -176,19 +175,19 @@ int eDBoxLCD::setLCDBrightness(int brightness)
                return(0);
 
        eDebug("[eDboxLCD] setLCDBrightness %d", brightness);
-       FILE *f=fopen("/proc/stb/lcd/oled_brightness", "w");
+       FILE *f = fopen("/proc/stb/lcd/oled_brightness", "w");
        if (!f)
                f = fopen("/proc/stb/fp/oled_brightness", "w");
        if (f)
        {
                if (fprintf(f, "%d", brightness) == 0)
-                       eDebug("[eDboxLCD] write /proc/stb/lcd/oled_brightness failed: %m");
+                       eDebug("[eDboxLCD] write /proc/stb/lcd|fp/oled_brightness failed: %m");
                fclose(f);
        }
        else
        {
                int fp;
-               if((fp=open("/dev/dbox/fp0", O_RDWR)) < 0)
+               if ((fp = open("/dev/dbox/fp0", O_RDWR)) < 0)
                {
                        eDebug("[eDboxLCD] can't open /dev/dbox/fp0: %m");
                        return(-1);
@@ -196,7 +195,7 @@ int eDBoxLCD::setLCDBrightness(int brightness)
 #ifndef FP_IOCTL_LCD_DIMM
 #define FP_IOCTL_LCD_DIMM       3
 #endif
-               if(ioctl(fp, FP_IOCTL_LCD_DIMM, &brightness) < 0)
+               if (ioctl(fp, FP_IOCTL_LCD_DIMM, &brightness) < 0)
                        eDebug("[eDboxLCD] can't set lcd brightness: %m");
                close(fp);
        }
@@ -206,10 +205,10 @@ int eDBoxLCD::setLCDBrightness(int brightness)
 
 eDBoxLCD::~eDBoxLCD()
 {
-       if (lcdfd>=0)
+       if (lcdfd >= 0)
        {
                close(lcdfd);
-               lcdfd=-1;
+               lcdfd = -1;
        }
 }
 
@@ -221,17 +220,15 @@ void eDBoxLCD::update()
 
        if (lcd_type == 0 || lcd_type == 2)
        {
-               unsigned char raw[132*8];
+               unsigned char raw[132 * 8];
                int x, y, yy;
-               for (y=0; y<8; y++)
+               for (y = 0; y < 8; y++)
                {
-                       for (x=0; x<132; x++)
+                       for (x = 0; x < 132; x++)
                        {
-                               int pix=0;
-                               for (yy=0; yy<8; yy++)
-                               {
-                                       pix|=(_buffer[(y*8+yy)*132+x]>=108)<<yy;
-                               }
+                               int pix = 0;
+                               for (yy = 0; yy < 8; yy++)
+                                       pix |= (_buffer[(y * 8 + yy) * 132 + x] >= 108) << yy;
                                if (flipped)
                                {
                                        /* 8 pixels per byte, swap bits */
@@ -239,12 +236,10 @@ void eDBoxLCD::update()
                                        raw[(7 - y) * 132 + (131 - x)] = BIT_SWAP(pix ^ inverted);
                                }
                                else
-                               {
                                        raw[y * 132 + x] = pix ^ inverted;
-                               }
                        }
                }
-               write(lcdfd, raw, 132*8);
+               write(lcdfd, raw, 132 * 8);
        }
        else if (lcd_type == 3)
        {
@@ -259,34 +254,28 @@ void eDBoxLCD::update()
                                for (unsigned int x = 0; x < width; x++)
                                {
                                        if (flipped)
-                                       {
                                                /* 8bpp, no bit swapping */
                                                raw[(height - 1 - y) * width + (width - 1 - x)] = _buffer[y * width + x] ^ inverted;
-                                       }
                                        else
-                                       {
                                                raw[y * width + x] = _buffer[y * width + x] ^ inverted;
-                                       }
                                }
                        }
                        write(lcdfd, raw, _stride * height);
                }
                else
-               {
                        write(lcdfd, _buffer, _stride * res.height());
-               }
        }
        else /* lcd_type == 1 */
        {
-               unsigned char raw[64*64];
+               unsigned char raw[64 * 64];
                int x, y;
-               memset(raw, 0, 64*64);
-               for (y=0; y<64; y++)
+               memset(raw, 0, 64 * 64);
+               for (y = 0; y < 64; y++)
                {
-                       int pix=0;
-                       for (x=0; x<128 / 2; x++)
+                       int pix = 0;
+                       for (x = 0; x < 128 / 2; x++)
                        {
-                               pix = (_buffer[y*132 + x * 2 + 2] & 0xF0) |(_buffer[y*132 + x * 2 + 1 + 2] >> 4);
+                               pix = (_buffer[y * 132 + x * 2 + 2] & 0xF0) | (_buffer[y * 132 + x * 2 + 1 + 2] >> 4);
                                if (inverted)
                                        pix = 0xFF - pix;
                                if (flipped)
@@ -298,12 +287,10 @@ void eDBoxLCD::update()
                                        raw[(63 - y) * 64 + (63 - x)] = byte;
                                }
                                else
-                               {
                                        raw[y * 64 + x] = pix;
-                               }
                        }
                }
-               write(lcdfd, raw, 64*64);
+               write(lcdfd, raw, 64 * 64);
        }
 #endif
 }