1 #include <lib/gdi/lcd.h>
8 #include <dbox/lcd-ks0713.h>
10 #include <lib/gdi/esize.h>
11 #include <lib/base/init.h>
12 #include <lib/base/init_num.h>
13 #include <lib/gdi/glcddc.h>
15 eDBoxLCD *eDBoxLCD::instance;
23 void eLCD::setSize(int xres, int yres, int bpp)
25 res = eSize(xres, yres);
26 _buffer=new unsigned char[xres * yres * bpp/8];
27 memset(_buffer, 0, res.height()*res.width()*bpp/8);
28 _stride=res.width()*bpp/8;
29 eDebug("lcd buffer %p %d bytes, stride %d", _buffer, xres*yres*bpp/8, _stride);
53 int xres=132, yres=64, bpp=8;
56 lcdfd = open("/dev/dbox/oled0", O_RDWR);
59 FILE *f=fopen("/proc/stb/lcd/oled_brightness", "w");
61 f = fopen("/proc/stb/fp/oled_brightness", "w");
67 lcdfd = open("/dev/dbox/lcd0", O_RDWR);
70 eDebug("found OLED display!");
79 eDebug("couldn't open LCD - load lcd.o!");
83 ioctl(lcdfd, LCD_IOCTL_ASC_MODE, &i);
85 FILE *f = fopen("/proc/stb/lcd/xres", "r");
89 if (fscanf(f, "%x", &tmp) == 1)
92 f = fopen("/proc/stb/lcd/yres", "r");
95 if (fscanf(f, "%x", &tmp) == 1)
98 f = fopen("/proc/stb/lcd/bpp", "r");
101 if (fscanf(f, "%x", &tmp) == 1)
109 setSize(xres, yres, bpp);
112 void eDBoxLCD::setInverted(unsigned char inv)
118 int eDBoxLCD::setLCDContrast(int contrast)
121 if((fp=open("/dev/dbox/fp0", O_RDWR))<=0)
123 eDebug("[LCD] can't open /dev/dbox/fp0");
127 if(ioctl(lcdfd, LCD_IOCTL_SRV, &contrast))
129 eDebug("[LCD] can't set lcd contrast");
135 int eDBoxLCD::setLCDBrightness(int brightness)
137 eDebug("setLCDBrightness %d", brightness);
138 FILE *f=fopen("/proc/stb/lcd/oled_brightness", "w");
140 f = fopen("/proc/stb/fp/oled_brightness", "w");
143 if (fprintf(f, "%d", brightness) == 0)
144 eDebug("write /proc/stb/lcd/oled_brightness failed!! (%m)");
150 if((fp=open("/dev/dbox/fp0", O_RDWR))<=0)
152 eDebug("[LCD] can't open /dev/dbox/fp0");
156 if(ioctl(fp, FP_IOCTL_LCD_DIMM, &brightness)<=0)
157 eDebug("[LCD] can't set lcd brightness (%m)");
163 eDBoxLCD::~eDBoxLCD()
172 eDBoxLCD *eDBoxLCD::getInstance()
177 void eDBoxLCD::update()
181 if (!is_oled || is_oled == 2)
183 unsigned char raw[132*8];
187 for (x=0; x<132; x++)
190 for (yy=0; yy<8; yy++)
192 pix|=(_buffer[(y*8+yy)*132+x]>=108)<<yy;
194 raw[y*132+x]=(pix^inverted);
197 write(lcdfd, raw, 132*8);
199 else if (is_oled == 3)
200 write(lcdfd, _buffer, _stride * res.height());
203 unsigned char raw[64*64];
205 memset(raw, 0, 64*64);
209 for (x=0; x<128 / 2; x++)
211 pix = (_buffer[y*132 + x * 2 + 2] & 0xF0) |(_buffer[y*132 + x * 2 + 1 + 2] >> 4);
217 write(lcdfd, raw, 64*64);