1 #include <lib/gdi/lcd.h>
7 #if defined(HAVE_DBOX_FP_H) && defined(HAVE_DBOX_LCD_KS0713_H)
9 #include <dbox/lcd-ks0713.h>
14 #include <lib/gdi/esize.h>
15 #include <lib/base/init.h>
16 #include <lib/base/init_num.h>
17 #include <lib/gdi/glcddc.h>
19 eDBoxLCD *eDBoxLCD::instance;
27 void eLCD::setSize(int xres, int yres, int bpp)
29 res = eSize(xres, yres);
30 _buffer=new unsigned char[xres * yres * bpp/8];
31 memset(_buffer, 0, res.height()*res.width()*bpp/8);
32 _stride=res.width()*bpp/8;
33 eDebug("lcd buffer %p %d bytes, stride %d", _buffer, xres*yres*bpp/8, _stride);
57 int xres=132, yres=64, bpp=8;
60 lcdfd = open("/dev/dbox/oled0", O_RDWR);
63 FILE *f=fopen("/proc/stb/lcd/oled_brightness", "w");
65 f = fopen("/proc/stb/fp/oled_brightness", "w");
71 lcdfd = open("/dev/dbox/lcd0", O_RDWR);
74 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)
112 setSize(xres, yres, bpp);
115 void eDBoxLCD::setInverted(unsigned char inv)
121 int eDBoxLCD::setLCDContrast(int contrast)
125 if((fp=open("/dev/dbox/fp0", O_RDWR))<=0)
127 eDebug("[LCD] can't open /dev/dbox/fp0");
131 if(ioctl(lcdfd, LCD_IOCTL_SRV, &contrast))
133 eDebug("[LCD] can't set lcd contrast");
140 int eDBoxLCD::setLCDBrightness(int brightness)
143 eDebug("setLCDBrightness %d", brightness);
144 FILE *f=fopen("/proc/stb/lcd/oled_brightness", "w");
146 f = fopen("/proc/stb/fp/oled_brightness", "w");
149 if (fprintf(f, "%d", brightness) == 0)
150 eDebug("write /proc/stb/lcd/oled_brightness failed!! (%m)");
156 if((fp=open("/dev/dbox/fp0", O_RDWR))<=0)
158 eDebug("[LCD] can't open /dev/dbox/fp0");
162 if(ioctl(fp, FP_IOCTL_LCD_DIMM, &brightness)<=0)
163 eDebug("[LCD] can't set lcd brightness (%m)");
170 eDBoxLCD::~eDBoxLCD()
179 eDBoxLCD *eDBoxLCD::getInstance()
184 void eDBoxLCD::update()
188 if (!is_oled || is_oled == 2)
190 unsigned char raw[132*8];
194 for (x=0; x<132; x++)
197 for (yy=0; yy<8; yy++)
199 pix|=(_buffer[(y*8+yy)*132+x]>=108)<<yy;
201 raw[y*132+x]=(pix^inverted);
204 write(lcdfd, raw, 132*8);
206 else if (is_oled == 3)
207 write(lcdfd, _buffer, _stride * res.height());
210 unsigned char raw[64*64];
212 memset(raw, 0, 64*64);
216 for (x=0; x<128 / 2; x++)
218 pix = (_buffer[y*132 + x * 2 + 2] & 0xF0) |(_buffer[y*132 + x * 2 + 1 + 2] >> 4);
224 write(lcdfd, raw, 64*64);