Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxqtbacklight: read brightness instead of actual_brightness for raw drivers #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions lxqtbacklight/linux_backend/driver/libbacklight_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,26 @@

static FILE* open_driver_file(const char *file, const char *driver, const char *mode);
static int read_backlight(const char *driver);
static int read_actual_backlight(const char *driver);
static int read_max_backlight(const char *driver);
static int read_bl_power(const char *driver);
static int read_type(const char *driver);
static const char *sysfs_backlight_dir = "/sys/class/backlight";

typedef enum {FIRMWARE, PLATFORM, RAW, OTHER, N_BACKLIGHT} BacklightTypes;

int lxqt_backlight_backend_get()
{
char *driver = lxqt_backlight_backend_get_driver();
if( driver == NULL ) {
return -1;
}
int value = read_backlight(driver);
int value;
if (read_type(driver) == RAW) {
value = read_actual_backlight(driver);
} else {
value = read_backlight(driver);
}
free(driver);
return value;
}
Expand Down Expand Up @@ -151,6 +160,11 @@ static FILE* open_driver_file(const char *file, const char *driver, const char *
}

static int read_backlight(const char *driver)
{
return read_int("brightness", driver);
}

static int read_actual_backlight(const char *driver)
{
return read_int("actual_brightness", driver);
}
Expand All @@ -165,7 +179,27 @@ static int read_bl_power(const char *driver)
return read_int("bl_power", driver);
}

typedef enum {FIRMWARE, PLATFORM, RAW, OTHER, N_BACKLIGHT} BackligthTypes;
static int read_type(const char *driver)
{
FILE *in = open_driver_file("type", driver, "r");
if( in == NULL ) {
return -1;
}
char type[1024];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1024 is probably overkill here, but the same value is used in lxqt_backlight_backend_get_driver() as well.

int result = fscanf(in, "%s", type);
fclose(in);
if( result == EOF ) {
return OTHER;
}
if (!strcmp(type, "firmware"))
return FIRMWARE;
else if (!strcmp(type, "firmware"))
return PLATFORM;
else if (!strcmp(type, "raw"))
return RAW;
else
return OTHER;
}

char *lxqt_backlight_backend_get_driver()
{
Expand Down
2 changes: 1 addition & 1 deletion lxqtbacklight/linux_backend/driver/lxqtbacklight_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void show_blacklight()
return;
}
int max_value = read_max_backlight(driver);
int actual = read_backlight(driver);
int actual = read_actual_backlight(driver);
printf("%s %d %d\n", driver, max_value, actual);
free(driver);
}
Expand Down