Skip to content

Commit

Permalink
dm8000/dm7080: fix grautec lcd
Browse files Browse the repository at this point in the history
  • Loading branch information
BPanther committed Jun 8, 2024
1 parent 7baa162 commit 8381507
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions lib/liblcddisplay/lcddisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include <byteswap.h>
#include <string.h>

#if BOXMODEL_DM8000 || BOXMODEL_DM7080
#include <system/helpers.h>
#endif

#ifndef BYTE_ORDER
#error "no BYTE_ORDER defined!"
#endif
Expand Down Expand Up @@ -210,40 +214,46 @@ int CLCDDisplay::setLCDContrast(int contrast)

int CLCDDisplay::setLCDBrightness(int brightness)
{
printf("setLCDBrightness %d\n", brightness);

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)
printf("write /proc/stb/lcd/oled_brightness failed!! (%m)\n");
fclose(f);
}
else
#if BOXMODEL_DM8000 || BOXMODEL_DM7080
if (!file_exists("/tmp/usbtft"))
{
int fp;
if ((fp = open("/dev/dbox/fp0", O_RDWR)) < 0)
#endif
printf("setLCDBrightness %d\n", brightness);

FILE *f = fopen("/proc/stb/lcd/oled_brightness", "w");
if (!f)
f = fopen("/proc/stb/fp/oled_brightness", "w");
if (f)
{
printf("[LCD] can't open /dev/dbox/fp0\n");
return (-1);
if (fprintf(f, "%d", brightness) == 0)
printf("write /proc/stb/lcd/oled_brightness failed!! (%m)\n");
fclose(f);
}
else
{
int fp;
if ((fp = open("/dev/dbox/fp0", O_RDWR)) < 0)
{
printf("[LCD] can't open /dev/dbox/fp0\n");
return (-1);
}

if (ioctl(fp, FP_IOCTL_LCD_DIMM, &brightness) < 0)
printf("[LCD] can't set lcd brightness (%m)\n");
close(fp);
}

if (brightness == 0)
{
memset(_buffer, inverted, raw_buffer_size);
update();
}
if (ioctl(fp, FP_IOCTL_LCD_DIMM, &brightness) < 0)
printf("[LCD] can't set lcd brightness (%m)\n");
close(fp);
}

last_brightness = brightness;
if (brightness == 0)
{
memset(_buffer, inverted, raw_buffer_size);
update();
}

return (0);
last_brightness = brightness;
#if BOXMODEL_DM8000 || BOXMODEL_DM7080
}
#endif
return (0);
}

bool CLCDDisplay::isAvailable()
Expand Down

0 comments on commit 8381507

Please sign in to comment.