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/fp/oled_brightness", "w");
65 lcdfd = open("/dev/dbox/lcd0", O_RDWR);
68 eDebug("found OLED display!");
77 eDebug("couldn't open LCD - load lcd.o!");
81 ioctl(lcdfd, LCD_IOCTL_ASC_MODE, &i);
83 FILE *f = fopen("/proc/stb/lcd/xres", "r");
87 if (fscanf(f, "%x", &tmp) == 1)
90 f = fopen("/proc/stb/lcd/yres", "r");
93 if (fscanf(f, "%x", &tmp) == 1)
96 f = fopen("/proc/stb/lcd/bpp", "r");
99 if (fscanf(f, "%x", &tmp) == 1)
107 setSize(xres, yres, bpp);
110 void eDBoxLCD::setInverted(unsigned char inv)
116 int eDBoxLCD::setLCDContrast(int contrast)
119 if((fp=open("/dev/dbox/fp0", O_RDWR))<=0)
121 eDebug("[LCD] can't open /dev/dbox/fp0");
125 if(ioctl(lcdfd, LCD_IOCTL_SRV, &contrast))
127 eDebug("[LCD] can't set lcd contrast");
133 int eDBoxLCD::setLCDBrightness(int brightness)
135 eDebug("setLCDBrightness %d", brightness);
136 FILE *f=fopen("/proc/stb/fp/oled_brightness", "w");
139 if (fprintf(f, "%d", brightness) == 0)
140 eDebug("write /proc/stb/fp/oled_brightness failed!! (%m)");
146 if((fp=open("/dev/dbox/fp0", O_RDWR))<=0)
148 eDebug("[LCD] can't open /dev/dbox/fp0");
152 if(ioctl(fp, FP_IOCTL_LCD_DIMM, &brightness)<=0)
153 eDebug("[LCD] can't set lcd brightness (%m)");
159 eDBoxLCD::~eDBoxLCD()
168 eDBoxLCD *eDBoxLCD::getInstance()
173 void eDBoxLCD::update()
177 if (!is_oled || is_oled == 2)
179 unsigned char raw[132*8];
183 for (x=0; x<132; x++)
186 for (yy=0; yy<8; yy++)
188 pix|=(_buffer[(y*8+yy)*132+x]>=108)<<yy;
190 raw[y*132+x]=(pix^inverted);
193 write(lcdfd, raw, 132*8);
195 else if (is_oled == 3) {
196 FILE *f = fopen("/tmp/bla", "w+");
198 fwrite(_buffer, _stride * res.height(), 1, f);
201 write(lcdfd, _buffer, _stride * res.height());
205 unsigned char raw[64*64];
207 memset(raw, 0, 64*64);
211 for (x=0; x<128 / 2; x++)
213 pix = (_buffer[y*132 + x * 2 + 2] & 0xF0) |(_buffer[y*132 + x * 2 + 1 + 2] >> 4);
219 write(lcdfd, raw, 64*64);