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

70 disable vrr #77

Merged
merged 8 commits into from
Apr 1, 2023
Merged
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
5 changes: 4 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TST_CXX = $(wildcard tst/*.cpp)
TST_O = $(TST_C:.c=.o) $(TST_CXX:.cpp=.o)
TST_E = $(patsubst tst/%.c,%,$(wildcard tst/tst-*.c))

all: way-displays
all: way-displays /tmp/vg.supp

$(SRC_O): $(INC_H) $(PRO_H) config.mk GNUmakefile
$(PRO_O): $(PRO_H) config.mk GNUmakefile
Expand All @@ -41,6 +41,9 @@ $(PRO_C): $(PRO_X)
clean:
rm -f way-displays example_client $(SRC_O) $(EXAMPLE_O) $(PRO_O) $(PRO_H) $(PRO_C) $(TST_O) $(TST_E)

/tmp/vg.supp: .vg.supp
cp .vg.supp /tmp/vg.supp

install: way-displays way-displays.1 cfg.yaml
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f way-displays $(DESTDIR)$(PREFIX)/bin
Expand Down
6 changes: 6 additions & 0 deletions cfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ MODE:
#- NAME_DESC: DP-2
# MAX: TRUE

# VRR / adaptive sync is enabled by default. Disable it per display.
VRR_OFF:
# - DP-2
# - '!.*my monitor.*'


# Laptop displays usually start with eDP e.g. eDP-1. This may be overridden if
# your laptop is different.
#LAPTOP_DISPLAY_PREFIX: 'eDP'
Expand Down
11 changes: 11 additions & 0 deletions doc/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ MODE:
- NAME_DESC: HDMI-A-1
MAX: TRUE
```

### VRR_OFF

Adaptive sync is enabled by default. Disable it per display.

```yaml
VRR_OFF:
- DP-2
- '!.*my monitor.*'
```

### LAPTOP_DISPLAY_PREFIX

Laptop displays usually start with `eDP` e.g. `eDP-1`. This may be overridden if your laptop is different e.g.:
Expand Down
2 changes: 2 additions & 0 deletions doc/YAML_SCHEMAS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ MODE: !!seq
- !!map
NAME_DESC: !!str
MAX: !!bool
VRR_OFF: !!seq
- !!str
DISABLED: !!seq
- !!str
LOG_THRESHOLD: !!log_threshold
Expand Down
4 changes: 4 additions & 0 deletions inc/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct Cfg {
enum AutoScale auto_scale;
struct SList *user_scales;
struct SList *user_modes;
struct SList *adaptive_sync_off_name_desc;
struct SList *max_preferred_refresh_name_desc;
struct SList *disabled_name_desc;
enum LogThreshold log_threshold;
Expand All @@ -66,6 +67,7 @@ enum CfgElement {
AUTO_SCALE,
SCALE,
MODE,
VRR_OFF,
LAPTOP_DISPLAY_PREFIX,
MAX_PREFERRED_REFRESH,
LOG_THRESHOLD,
Expand All @@ -75,6 +77,8 @@ enum CfgElement {

void cfg_init(const char *cfg_path);

bool cfg_equal(struct Cfg *a, struct Cfg *b);

struct Cfg *cfg_merge(struct Cfg *to, struct Cfg *from, bool del);

void cfg_file_reload(void);
Expand Down
11 changes: 11 additions & 0 deletions inc/global.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef GLOBAL_H
#define GLOBAL_H

extern struct Displ *displ;
extern struct Cfg *cfg;
extern struct Lid *lid;

extern struct Head *head_changing_mode;
extern struct Head *head_changing_adaptive_sync;

#endif // GLOBAL_H
4 changes: 0 additions & 4 deletions inc/server.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#ifndef SERVER_H
#define SERVER_H

extern struct Displ *displ;
extern struct Cfg *cfg;
extern struct Lid *lid;

int server(char *cfg_path);

#endif // SERVER_H
Expand Down
75 changes: 40 additions & 35 deletions src/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "cfg.h"

#include "convert.h"
#include "global.h"
#include "info.h"
#include "list.h"
#include "log.h"
#include "marshalling.h"
#include "server.h"

bool cfg_equal_user_mode_name(const void *value, const void *data) {
if (!value || !data) {
Expand Down Expand Up @@ -203,6 +203,11 @@ struct Cfg *clone_cfg(struct Cfg *from) {
slist_append(&to->user_modes, to_user_mode);
}

// VRR_OFF
for (i = from->adaptive_sync_off_name_desc; i; i = i->nex) {
slist_append(&to->adaptive_sync_off_name_desc, strdup((char*)i->val));
}

// LAPTOP_DISPLAY_PREFIX
if (from->laptop_display_prefix) {
to->laptop_display_prefix = strdup(from->laptop_display_prefix);
Expand All @@ -226,7 +231,7 @@ struct Cfg *clone_cfg(struct Cfg *from) {
return to;
}

bool equal_cfg(struct Cfg *a, struct Cfg *b) {
bool cfg_equal(struct Cfg *a, struct Cfg *b) {
if (!a || !b) {
return false;
}
Expand Down Expand Up @@ -261,6 +266,11 @@ bool equal_cfg(struct Cfg *a, struct Cfg *b) {
return false;
}

// VRR_OFF
if (!slist_equal(a->adaptive_sync_off_name_desc, b->adaptive_sync_off_name_desc, slist_equal_strcmp)) {
return false;
}

// LAPTOP_DISPLAY_PREFIX
char *al = a->laptop_display_prefix;
char *bl = b->laptop_display_prefix;
Expand Down Expand Up @@ -410,6 +420,11 @@ void validate_warn(struct Cfg *cfg) {
continue;
warn_short_name_desc((const char*)i->val, "ORDER");
}
for (i = cfg->adaptive_sync_off_name_desc; i; i = i->nex) {
if (!i->val)
continue;
warn_short_name_desc((const char*)i->val, "VRR_OFF");
}
for (i = cfg->max_preferred_refresh_name_desc; i; i = i->nex) {
if (!i->val)
continue;
Expand Down Expand Up @@ -484,6 +499,13 @@ struct Cfg *merge_set(struct Cfg *to, struct Cfg *from) {
merged_user_mode->warned_no_mode = set_user_mode->warned_no_mode;
}

// VRR_OFF
for (i = from->adaptive_sync_off_name_desc; i; i = i->nex) {
if (!slist_find_equal(merged->adaptive_sync_off_name_desc, slist_equal_strcmp, i->val)) {
slist_append(&merged->adaptive_sync_off_name_desc, strdup((char*)i->val));
}
}

// DISABLED
for (i = from->disabled_name_desc; i; i = i->nex) {
if (!slist_find_equal(merged->disabled_name_desc, slist_equal_strcmp, i->val)) {
Expand Down Expand Up @@ -513,6 +535,11 @@ struct Cfg *merge_del(struct Cfg *to, struct Cfg *from) {
slist_remove_all_free(&merged->user_modes, cfg_equal_user_mode_name, i->val, cfg_user_mode_free);
}

// VRR_OFF
for (i = from->adaptive_sync_off_name_desc; i; i = i->nex) {
slist_remove_all_free(&merged->adaptive_sync_off_name_desc, slist_equal_strcmp, i->val, NULL);
}

// DISABLED
for (i = from->disabled_name_desc; i; i = i->nex) {
slist_remove_all_free(&merged->disabled_name_desc, slist_equal_strcmp, i->val, NULL);
Expand All @@ -538,7 +565,7 @@ struct Cfg *cfg_merge(struct Cfg *to, struct Cfg *from, bool del) {
validate_fix(merged);
validate_warn(merged);

if (equal_cfg(merged, to)) {
if (cfg_equal(merged, to)) {
cfg_free(merged);
merged = NULL;
}
Expand Down Expand Up @@ -647,44 +674,22 @@ void cfg_free(struct Cfg *cfg) {
if (!cfg)
return;

if (cfg->dir_path) {
free(cfg->dir_path);
}
if (cfg->file_path) {
free(cfg->file_path);
}
if (cfg->file_name) {
free(cfg->file_name);
}
free(cfg->dir_path);
free(cfg->file_path);
free(cfg->file_name);
free(cfg->laptop_display_prefix);

for (struct SList *i = cfg->order_name_desc; i; i = i->nex) {
free(i->val);
}
slist_free(&cfg->order_name_desc);
slist_free_vals(&cfg->order_name_desc, NULL);

for (struct SList *i = cfg->user_scales; i; i = i->nex) {
cfg_user_scale_free((struct UserScale*)i->val);
}
slist_free(&cfg->user_scales);
slist_free_vals(&cfg->user_scales, cfg_user_scale_free);

for (struct SList *i = cfg->user_modes; i; i = i->nex) {
cfg_user_mode_free((struct UserMode*)i->val);
}
slist_free(&cfg->user_modes);
slist_free_vals(&cfg->user_modes, cfg_user_mode_free);

for (struct SList *i = cfg->max_preferred_refresh_name_desc; i; i = i->nex) {
free(i->val);
}
slist_free(&cfg->max_preferred_refresh_name_desc);
slist_free_vals(&cfg->adaptive_sync_off_name_desc, NULL);

for (struct SList *i = cfg->disabled_name_desc; i; i = i->nex) {
free(i->val);
}
slist_free(&cfg->disabled_name_desc);
slist_free_vals(&cfg->max_preferred_refresh_name_desc, NULL);

if (cfg->laptop_display_prefix) {
free(cfg->laptop_display_prefix);
}
slist_free_vals(&cfg->disabled_name_desc, NULL);

free(cfg);
}
Expand Down
7 changes: 7 additions & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ struct Cfg *parse_element(enum IpcRequestOperation op, enum CfgElement element,
break;
}
break;
case VRR_OFF:
for (int i = optind; i < argc; i++) {
slist_append(&cfg->adaptive_sync_off_name_desc, strdup(argv[i]));
}
parsed = true;
break;
case DISABLED:
for (int i = optind; i < argc; i++) {
slist_append(&cfg->disabled_name_desc, strdup(argv[i]));
Expand Down Expand Up @@ -191,6 +197,7 @@ struct IpcRequest *parse_set(int argc, char **argv) {
break;
case AUTO_SCALE:
case DISABLED:
case VRR_OFF:
if (optind + 1 != argc) {
log_error("%s requires one argument", cfg_element_name(element));
wd_exit(EXIT_FAILURE);
Expand Down
1 change: 1 addition & 0 deletions src/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ static struct NameVal cfg_elements[] = {
{ .val = AUTO_SCALE, .name = "AUTO_SCALE", },
{ .val = SCALE, .name = "SCALE", },
{ .val = MODE, .name = "MODE", },
{ .val = VRR_OFF, .name = "VRR_OFF", },
{ .val = LAPTOP_DISPLAY_PREFIX, .name = "LAPTOP_DISPLAY_PREFIX", },
{ .val = MAX_PREFERRED_REFRESH, .name = "MAX_PREFERRED_REFRESH", },
{ .val = LOG_THRESHOLD, .name = "LOG_THRESHOLD", },
Expand Down
2 changes: 1 addition & 1 deletion src/displ.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "displ.h"

#include "global.h"
#include "listeners.h"
#include "log.h"
#include "process.h"
#include "server.h"

void displ_init(void) {

Expand Down
4 changes: 2 additions & 2 deletions src/fds.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#include "fds.h"

#include "cfg.h"
#include "displ.h"
#include "lid.h"
#include "log.h"
#include "displ.h"
#include "global.h"
#include "process.h"
#include "server.h"
#include "sockets.h"

#define PFDS_SIZE 5
Expand Down
9 changes: 9 additions & 0 deletions src/global.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stddef.h>

struct Displ *displ = NULL;
struct Lid *lid = NULL;
struct Cfg *cfg = NULL;

struct Head *head_changing_mode = NULL;
struct Head *head_changing_adaptive_sync = NULL;

2 changes: 1 addition & 1 deletion src/head.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include "head.h"

#include "cfg.h"
#include "global.h"
#include "info.h"
#include "list.h"
#include "log.h"
#include "mode.h"
#include "server.h"

struct SList *heads = NULL;
struct SList *heads_arrived = NULL;
Expand Down
Loading