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;
17 eLCD::eLCD(eSize size): res(size)
21 _buffer=new unsigned char[res.height()*res.width()];
22 memset(_buffer, 0, res.height()*res.width());
45 eDBoxLCD::eDBoxLCD(): eLCD(eSize(132, 64))
49 lcdfd = open("/dev/dbox/oled0", O_RDWR);
52 FILE *f=fopen("/proc/stb/lcd/oled_brightness", "w");
54 f = fopen("/proc/stb/fp/oled_brightness", "w");
60 lcdfd = open("/dev/dbox/lcd0", O_RDWR);
63 eDebug("found OLED display!");
72 eDebug("couldn't open LCD - load lcd.o!");
76 ioctl(lcdfd, LCD_IOCTL_ASC_MODE, &i);
81 void eDBoxLCD::setInverted(unsigned char inv)
87 int eDBoxLCD::setLCDContrast(int contrast)
90 if((fp=open("/dev/dbox/fp0", O_RDWR))<=0)
92 eDebug("[LCD] can't open /dev/dbox/fp0");
96 if(ioctl(lcdfd, LCD_IOCTL_SRV, &contrast))
98 eDebug("[LCD] can't set lcd contrast");
104 int eDBoxLCD::setLCDBrightness(int brightness)
106 eDebug("setLCDBrightness %d", brightness);
107 FILE *f=fopen("/proc/stb/lcd/oled_brightness", "w");
109 f = fopen("/proc/stb/fp/oled_brightness", "w");
112 if (fprintf(f, "%d", brightness) == 0)
113 eDebug("write /proc/stb/lcd/oled_brightness failed!! (%m)");
119 if((fp=open("/dev/dbox/fp0", O_RDWR))<=0)
121 eDebug("[LCD] can't open /dev/dbox/fp0");
125 if(ioctl(fp, FP_IOCTL_LCD_DIMM, &brightness)<=0)
126 eDebug("[LCD] can't set lcd brightness (%m)");
132 eDBoxLCD::~eDBoxLCD()
141 eDBoxLCD *eDBoxLCD::getInstance()
146 void eDBoxLCD::update()
148 if (!is_oled || is_oled == 2)
150 unsigned char raw[132*8];
154 for (x=0; x<132; x++)
157 for (yy=0; yy<8; yy++)
159 pix|=(_buffer[(y*8+yy)*132+x]>=108)<<yy;
161 raw[y*132+x]=(pix^inverted);
165 write(lcdfd, raw, 132*8);
168 unsigned char raw[64*64];
170 memset(raw, 0, 64*64);
174 for (x=0; x<128 / 2; x++)
176 pix = (_buffer[y*132 + x * 2 + 2] & 0xF0) |(_buffer[y*132 + x * 2 + 1 + 2] >> 4);
183 write(lcdfd, raw, 64*64);