Skip to content

Commit

Permalink
Allow overscan setting in resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSB committed Jan 13, 2021
1 parent 8ae7bd4 commit f29faee
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/osd.c
Expand Up @@ -5260,6 +5260,42 @@ void osd_init() {

int cbytes = file_load("/config.txt", config_buffer, MAX_CONFIG_BUFFER_SIZE);

if (cbytes) {
prop = get_prop_no_space(config_buffer, "overscan_left");
}
if (!prop || !cbytes) {
prop = "0";
}
log_info("overscan_left: %s", prop);
int l = atoi(prop);
if (cbytes) {
prop = get_prop_no_space(config_buffer, "overscan_right");
}
if (!prop || !cbytes) {
prop = "0";
}
log_info("overscan_right: %s", prop);
int r = atoi(prop);

if (cbytes) {
prop = get_prop_no_space(config_buffer, "overscan_top");
}
if (!prop || !cbytes) {
prop = "0";
}
log_info("overscan_top: %s", prop);
int t = atoi(prop);
if (cbytes) {
prop = get_prop_no_space(config_buffer, "overscan_bottom");
}
if (!prop || !cbytes) {
prop = "0";
}
log_info("overscan_bottom: %s", prop);
int b = atoi(prop);

set_config_overscan(l, r, t, b);

if (cbytes) {
prop = get_prop_no_space(config_buffer, "hdmi_drive");
}
Expand Down
17 changes: 17 additions & 0 deletions src/rgb_to_hdmi.c
Expand Up @@ -242,6 +242,10 @@ static int vlock_limited = 0;
static int current_display_buffer = 0;
static int h_overscan = 0;
static int v_overscan = 0;
static int config_overscan_left = 0;
static int config_overscan_right = 0;
static int config_overscan_top = 0;
static int config_overscan_bottom = 0;
static int cpuspeed = 1000;
static int cpld_fail_state = CPLD_NORMAL;
static int helper_flag = 0;
Expand Down Expand Up @@ -435,6 +439,12 @@ static int last_height = -1;

int top_overscan = adj_v_overscan >> 1;
int bottom_overscan = top_overscan + (adj_v_overscan & 1);


left_overscan += config_overscan_left;
right_overscan += config_overscan_right;
top_overscan += config_overscan_top;
bottom_overscan += config_overscan_bottom;

log_info("Overscan L=%d, R=%d, T=%d, B=%d",left_overscan, right_overscan, top_overscan, bottom_overscan);

Expand Down Expand Up @@ -2253,6 +2263,13 @@ int get_current_display_buffer() {
}
}

void set_config_overscan(int l, int r, int t, int b) {
config_overscan_left = l;
config_overscan_right = r;
config_overscan_top = t;
config_overscan_bottom = b;
}

void set_profile(int val) {
log_info("Setting profile to %d", val);
profile = val;
Expand Down
1 change: 1 addition & 0 deletions src/rgb_to_hdmi.h
Expand Up @@ -2,6 +2,7 @@
#define RGB_TO_HDMI_H

// Property setters/getters
void set_config_overscan(int l, int r, int t, int b);
void set_profile(int value);
int get_profile();
void set_subprofile(int value);
Expand Down

0 comments on commit f29faee

Please sign in to comment.