Skip to content

Commit

Permalink
Merge pull request #87 from sundermann/force-hdr-quirk
Browse files Browse the repository at this point in the history
Add option to disable automatic HDR and powerstate switching
  • Loading branch information
TBSniller authored Oct 2, 2022
2 parents 19eb7ce + 56e29a6 commit 7d88b10
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ static struct option long_options[] = {
{ "no-video", no_argument, 0, 'V' },
{ "no-gui", no_argument, 0, 'G' },
{ "no-vsync", no_argument, 0, 'n' },
{ "no-hdr", no_argument, 0, 'r' },
{ "no-powerstate", no_argument, 0, 's' },
{ "backend", required_argument, 0, 'b' },
{ "ui-backend", required_argument, 0, 'u' },
{ "quirks", required_argument, 0, 'q' },
Expand Down Expand Up @@ -58,6 +60,8 @@ static void print_usage()
printf(" -V, --no-video Video will not be captured\n");
printf(" -G, --no-gui GUI/UI will not be captured\n");
printf(" -n, --no-vsync Disable vsync (may increase framerate at the cost of tearing/artifacts)\n");
printf(" -r, --no-hdr Disable automatic HDR mode switching\n");
printf(" -s, --no-powerstate Disable automatic powerstate switching\n");
printf(" -q, --quirks=QUIRKS Enable certain handling for per-device quirks\n");
printf(" -c, --config=PATH Absolute path for configfile to load settings. Giving additional runtime arguments will overwrite loaded ones.\n");
printf(" -d, --dump-frames Dump raw video frames to /tmp/.\n");
Expand All @@ -72,7 +76,7 @@ static int parse_options(int argc, char* argv[])
int opt, longindex;
int ret;

while ((opt = getopt_long(argc, argv, "x:y:a:p:f:b:u:q:c:lvnhdVG", long_options, &longindex)) != -1) {
while ((opt = getopt_long(argc, argv, "x:y:a:p:f:b:u:q:c:lvnhdVGrs", long_options, &longindex)) != -1) {
switch (opt) {
case 'x':
settings.width = atoi(optarg);
Expand All @@ -99,6 +103,12 @@ static int parse_options(int argc, char* argv[])
case 'G':
settings.no_gui = 1;
break;
case 's':
settings.no_powerstate = 1;
break;
case 'r':
settings.no_hdr = 1;
break;
case 'n':
settings.vsync = false;
break;
Expand Down
12 changes: 12 additions & 0 deletions src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ static bool power_callback(LSHandle* sh __attribute__((unused)), LSMessage* msg,
jvalue_ref parsed;
service_t* service = (service_t*)data;

if (service->settings->no_powerstate) {
return false;
}

INFO("Power status callback message: %s", LSMessageGetPayload(msg));

jschema_info_init(&schema, jschema_all(), NULL, NULL);
Expand Down Expand Up @@ -363,6 +367,10 @@ static bool videooutput_callback(LSHandle* sh __attribute__((unused)), LSMessage
jvalue_ref parsed;
service_t* service = (service_t*)data;

if (service->settings->no_hdr) {
return false;
}

// INFO("Videooutput status callback message: %s", LSMessageGetPayload(msg));

jschema_info_init(&schema, jschema_all(), NULL, NULL);
Expand Down Expand Up @@ -425,6 +433,10 @@ static bool picture_callback(LSHandle* sh __attribute__((unused)), LSMessage* ms
jvalue_ref parsed;
service_t* service = (service_t*)data;

if (service->settings->no_hdr) {
return false;
}

// INFO("getSystemSettings/picture status callback message: %s", LSMessageGetPayload(msg));

jschema_info_init(&schema, jschema_all(), NULL, NULL);
Expand Down
11 changes: 11 additions & 0 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ void settings_init(settings_t* settings)
settings->autostart = false;
settings->vsync = true;

settings->no_hdr = false;
settings->no_powerstate = false;

settings->dump_frames = false;
}

Expand Down Expand Up @@ -73,6 +76,11 @@ int settings_load_json(settings_t* settings, jvalue_ref source)
if ((value = jobject_get(source, j_cstr_to_buffer("autostart"))) && jis_boolean(value))
jboolean_get(value, &settings->autostart);

if ((value = jobject_get(source, j_cstr_to_buffer("nohdr"))) && jis_boolean(value))
jboolean_get(value, &settings->no_hdr);
if ((value = jobject_get(source, j_cstr_to_buffer("nopowerstate"))) && jis_boolean(value))
jboolean_get(value, &settings->no_powerstate);

return 0;
}

Expand All @@ -96,6 +104,9 @@ int settings_save_json(settings_t* settings, jvalue_ref target)
jobject_set(target, j_cstr_to_buffer("nogui"), jboolean_create(settings->no_gui));
jobject_set(target, j_cstr_to_buffer("autostart"), jboolean_create(settings->autostart));

jobject_set(target, j_cstr_to_buffer("nohdr"), jboolean_create(settings->no_hdr));
jobject_set(target, j_cstr_to_buffer("nopowerstate"), jboolean_create(settings->no_powerstate));

return 0;
}

Expand Down
3 changes: 3 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ typedef struct _settings_t {
bool autostart;

bool dump_frames;

bool no_hdr;
bool no_powerstate;
} settings_t;

void settings_init(settings_t*);
Expand Down

0 comments on commit 7d88b10

Please sign in to comment.