kopia lustrzana https://github.com/hoglet67/RGBtoHDMI
Pi Firmware: Moved offset/fb size params into cpld config, as this is mode specific
Change-Id: I36cf67fa71678595ff2598b3216dd3462792ccaepull/11/head
rodzic
c1a346ba95
commit
cc76f2542d
|
@ -26,6 +26,8 @@ typedef struct {
|
|||
param_t *(*get_params)();
|
||||
int (*get_value)(int num);
|
||||
void (*set_value)(int num, int value);
|
||||
// Support for filling in framebuffer params
|
||||
int (*get_fb_params)(capture_info_t *capinfo);
|
||||
// Support for info page
|
||||
void (*show_cal_summary)(int line);
|
||||
void (*show_cal_details)(int line);
|
||||
|
|
|
@ -307,6 +307,14 @@ static void cpld_set_mode(int mode) {
|
|||
write_config(config);
|
||||
}
|
||||
|
||||
static int cpld_get_fb_params(capture_info_t *capinfo) {
|
||||
capinfo->h_offset = 0;
|
||||
capinfo->v_offset = 21;
|
||||
capinfo->width = mode7 ? 504 : 672;
|
||||
capinfo->height = 540;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static param_t *cpld_get_params() {
|
||||
if (mode7) {
|
||||
return mode7_params;
|
||||
|
@ -400,6 +408,7 @@ cpld_t cpld_alternative = {
|
|||
.get_version = cpld_get_version,
|
||||
.calibrate = cpld_calibrate,
|
||||
.set_mode = cpld_set_mode,
|
||||
.get_fb_params = cpld_get_fb_params,
|
||||
.get_params = cpld_get_params,
|
||||
.get_value = cpld_get_value,
|
||||
.set_value = cpld_set_value
|
||||
|
|
|
@ -16,6 +16,10 @@ typedef struct {
|
|||
int sp_offset[NUM_OFFSETS];
|
||||
int half_px_delay; // 0 = off, 1 = on, all modes
|
||||
int full_px_delay; // 0..15, mode 7 only
|
||||
int h_offset; // horizontal offset (in psync clocks)
|
||||
int v_offset; // vertical offset (in lines)
|
||||
int fb_width; // framebuffer width in pixels
|
||||
int fb_height; // framebuffer height in pixels
|
||||
} config_t;
|
||||
|
||||
// Current calibration state for mode 0..6
|
||||
|
@ -68,32 +72,45 @@ enum {
|
|||
E_OFFSET,
|
||||
F_OFFSET,
|
||||
HALF,
|
||||
H_OFFSET,
|
||||
V_OFFSET,
|
||||
FB_WIDTH,
|
||||
FB_HEIGHT,
|
||||
DELAY
|
||||
};
|
||||
|
||||
static param_t default_params[] = {
|
||||
{ "All offsets", 0, 5 },
|
||||
{ "A offset", 0, 5 },
|
||||
{ "B offset", 0, 5 },
|
||||
{ "C offset", 0, 5 },
|
||||
{ "D offset", 0, 5 },
|
||||
{ "E offset", 0, 5 },
|
||||
{ "F offset", 0, 5 },
|
||||
{ "Half", 0, 1 },
|
||||
{ NULL, 0, 0 },
|
||||
{ "All offsets", 0, 5 },
|
||||
{ "A offset", 0, 5 },
|
||||
{ "B offset", 0, 5 },
|
||||
{ "C offset", 0, 5 },
|
||||
{ "D offset", 0, 5 },
|
||||
{ "E offset", 0, 5 },
|
||||
{ "F offset", 0, 5 },
|
||||
{ "Half", 0, 1 },
|
||||
{ "H offset", 0, 59 },
|
||||
{ "V offset", 0, 39 },
|
||||
{ "FB width", 400, 800 },
|
||||
{ "FB height", 540, 540 },
|
||||
{ "Delay", 0, 15 },
|
||||
{ NULL, 0, 0 },
|
||||
};
|
||||
|
||||
static param_t mode7_params[] = {
|
||||
{ "All offsets", 0, 7 },
|
||||
{ "A offset", 0, 7 },
|
||||
{ "B offset", 0, 7 },
|
||||
{ "C offset", 0, 7 },
|
||||
{ "D offset", 0, 7 },
|
||||
{ "E offset", 0, 7 },
|
||||
{ "F offset", 0, 7 },
|
||||
{ "Half", 0, 1 },
|
||||
{ "Delay", 0, 15 },
|
||||
{ NULL, 0, 0 },
|
||||
{ "All offsets", 0, 7 },
|
||||
{ "A offset", 0, 7 },
|
||||
{ "B offset", 0, 7 },
|
||||
{ "C offset", 0, 7 },
|
||||
{ "D offset", 0, 7 },
|
||||
{ "E offset", 0, 7 },
|
||||
{ "F offset", 0, 7 },
|
||||
{ "Half", 0, 1 },
|
||||
{ "H offset", 0, 39 },
|
||||
{ "V offset", 0, 39 },
|
||||
{ "FB width", 400, 800 },
|
||||
{ "FB height", 540, 540 },
|
||||
{ "Delay", 0, 15 },
|
||||
{ NULL, 0, 0 },
|
||||
};
|
||||
|
||||
// =============================================================
|
||||
|
@ -189,10 +206,22 @@ static void log_sp(config_t *config) {
|
|||
|
||||
static void cpld_init(int version) {
|
||||
cpld_version = version;
|
||||
// Version 2 CPLD supports the delay parameter
|
||||
// Setup default frame buffer params
|
||||
mode7_config.h_offset = 24;
|
||||
mode7_config.v_offset = 21;
|
||||
mode7_config.fb_width = 504;
|
||||
mode7_config.fb_height = 540;
|
||||
default_config.h_offset = 32;
|
||||
default_config.v_offset = 21;
|
||||
default_config.fb_width = 672;
|
||||
default_config.fb_height = 540;
|
||||
// Version 2 CPLD supports the delay parameter, and starts sampling earlier
|
||||
supports_delay = ((cpld_version >> VERSION_MAJOR_BIT) & 0x0F) >= 2;
|
||||
if (!supports_delay) {
|
||||
mode7_params[DELAY].name = NULL;
|
||||
default_params[DELAY].name = NULL;
|
||||
mode7_config.h_offset = 0;
|
||||
default_config.h_offset = 0;
|
||||
}
|
||||
for (int i = 0; i < NUM_OFFSETS; i++) {
|
||||
default_config.sp_offset[i] = 0;
|
||||
|
@ -200,7 +229,8 @@ static void cpld_init(int version) {
|
|||
}
|
||||
default_config.half_px_delay = 0;
|
||||
mode7_config.half_px_delay = 0;
|
||||
mode7_config.full_px_delay = 4; // Correct for the master
|
||||
default_config.full_px_delay = 0;
|
||||
mode7_config.full_px_delay = 4; // Correct for the master
|
||||
config = &default_config;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
sum_metrics_default[i] = -1;
|
||||
|
@ -372,6 +402,16 @@ static void cpld_set_mode(int mode) {
|
|||
write_config(config);
|
||||
}
|
||||
|
||||
static int cpld_get_fb_params(capture_info_t *capinfo) {
|
||||
int old_fb_width = capinfo->width;
|
||||
int old_fb_height = capinfo->height;
|
||||
capinfo->h_offset = config->h_offset;
|
||||
capinfo->v_offset = config->v_offset;
|
||||
capinfo->width = config->fb_width;
|
||||
capinfo->height = config->fb_height;
|
||||
return (old_fb_width != config->fb_width) || (old_fb_height != config->fb_height);
|
||||
}
|
||||
|
||||
static param_t *cpld_get_params() {
|
||||
if (mode7) {
|
||||
return mode7_params;
|
||||
|
@ -398,6 +438,14 @@ static int cpld_get_value(int num) {
|
|||
return config->sp_offset[5];
|
||||
case HALF:
|
||||
return config->half_px_delay;
|
||||
case H_OFFSET:
|
||||
return config->h_offset;
|
||||
case V_OFFSET:
|
||||
return config->v_offset;
|
||||
case FB_WIDTH:
|
||||
return config->fb_width;
|
||||
case FB_HEIGHT:
|
||||
return config->fb_height;
|
||||
case DELAY:
|
||||
return config->full_px_delay;
|
||||
}
|
||||
|
@ -435,6 +483,18 @@ static void cpld_set_value(int num, int value) {
|
|||
case HALF:
|
||||
config->half_px_delay = value;
|
||||
break;
|
||||
case H_OFFSET:
|
||||
config->h_offset = value;
|
||||
break;
|
||||
case V_OFFSET:
|
||||
config->v_offset = value;
|
||||
break;
|
||||
case FB_WIDTH:
|
||||
config->fb_width = value;
|
||||
break;
|
||||
case FB_HEIGHT:
|
||||
config->fb_height = value;
|
||||
break;
|
||||
case DELAY:
|
||||
config->full_px_delay = value;
|
||||
break;
|
||||
|
@ -484,6 +544,7 @@ cpld_t cpld_normal = {
|
|||
.get_version = cpld_get_version,
|
||||
.calibrate = cpld_calibrate,
|
||||
.set_mode = cpld_set_mode,
|
||||
.get_fb_params = cpld_get_fb_params,
|
||||
.get_params = cpld_get_params,
|
||||
.get_value = cpld_get_value,
|
||||
.set_value = cpld_set_value,
|
||||
|
|
31
src/osd.c
31
src/osd.c
|
@ -125,8 +125,6 @@ enum {
|
|||
F_INFO,
|
||||
F_PALETTE,
|
||||
F_DEINTERLACE,
|
||||
F_H_OFFSET,
|
||||
F_V_OFFSET,
|
||||
F_SCANLINES,
|
||||
F_MUX,
|
||||
F_ELK,
|
||||
|
@ -142,8 +140,6 @@ static param_t features[] = {
|
|||
{ "Info", 0, NUM_INFOS - 1 },
|
||||
{ "Color Palette", 0, NUM_PALETTES - 1 },
|
||||
{ "Deinterlace", 0, NUM_DEINTERLACES - 1 },
|
||||
{ "Hor Offset", 0, 39 },
|
||||
{ "Ver Offset", 0, 39 },
|
||||
{ "Scanlines", 0, 1 },
|
||||
{ "Input Mux", 0, 1 },
|
||||
{ "Elk", 0, 1 },
|
||||
|
@ -283,10 +279,6 @@ static int get_feature(int num) {
|
|||
return palette;
|
||||
case F_DEINTERLACE:
|
||||
return get_deinterlace();
|
||||
case F_H_OFFSET:
|
||||
return get_h_offset();
|
||||
case F_V_OFFSET:
|
||||
return get_v_offset();
|
||||
case F_SCANLINES:
|
||||
return get_scanlines();
|
||||
case F_MUX:
|
||||
|
@ -319,12 +311,6 @@ static void set_feature(int num, int value) {
|
|||
case F_DEINTERLACE:
|
||||
set_deinterlace(value);
|
||||
break;
|
||||
case F_H_OFFSET:
|
||||
set_h_offset(value);
|
||||
break;
|
||||
case F_V_OFFSET:
|
||||
set_v_offset(value);
|
||||
break;
|
||||
case F_SCANLINES:
|
||||
set_scanlines(value);
|
||||
break;
|
||||
|
@ -354,7 +340,6 @@ static void set_feature(int num, int value) {
|
|||
}
|
||||
|
||||
static const char *get_value_string(int num) {
|
||||
static char buffer[100];
|
||||
// Read the current value of the specified feature
|
||||
int value = get_feature(num);
|
||||
// Convert that to a human readable string
|
||||
|
@ -371,10 +356,6 @@ static const char *get_value_string(int num) {
|
|||
case F_NBUFFERS:
|
||||
return nbuffer_names[value];
|
||||
#endif
|
||||
case F_H_OFFSET:
|
||||
case F_V_OFFSET:
|
||||
sprintf(buffer, "%d", value);
|
||||
return buffer;
|
||||
default:
|
||||
return value ? "On" : "Off";
|
||||
}
|
||||
|
@ -632,18 +613,6 @@ void osd_init() {
|
|||
set_feature(F_DEINTERLACE, val);
|
||||
log_info("config.txt: deinterlace = %d", val);
|
||||
}
|
||||
prop = get_cmdline_prop("h_offset");
|
||||
if (prop) {
|
||||
int val = atoi(prop);
|
||||
set_feature(F_H_OFFSET, val);
|
||||
log_info("config.txt: h_offset = %d", val);
|
||||
}
|
||||
prop = get_cmdline_prop("v_offset");
|
||||
if (prop) {
|
||||
int val = atoi(prop);
|
||||
set_feature(F_V_OFFSET, val);
|
||||
log_info("config.txt: v_offset = %d", val);
|
||||
}
|
||||
prop = get_cmdline_prop("scanlines");
|
||||
if (prop) {
|
||||
int val = atoi(prop);
|
||||
|
|
|
@ -49,7 +49,6 @@ static capture_info_t default_capinfo __attribute__((aligned(32)));
|
|||
static capture_info_t mode7_capinfo __attribute__((aligned(32)));
|
||||
static uint32_t cpld_version_id;
|
||||
static int mode7;
|
||||
static int last_mode7;
|
||||
static int clear;
|
||||
static volatile int delay;
|
||||
static double pllh_clock = 0;
|
||||
|
@ -962,6 +961,8 @@ void action_calibrate() {
|
|||
void rgb_to_hdmi_main() {
|
||||
|
||||
int result;
|
||||
int last_mode7;
|
||||
int size_changed;
|
||||
|
||||
capinfo = &default_capinfo;
|
||||
|
||||
|
@ -1009,14 +1010,15 @@ void rgb_to_hdmi_main() {
|
|||
log_debug("Setting mode7 = %d", mode7);
|
||||
RPI_SetGpioValue(MODE7_PIN, mode7);
|
||||
|
||||
log_debug("Loading sample points");
|
||||
cpld->set_mode(mode7);
|
||||
cpld->get_fb_params(capinfo);
|
||||
log_debug("Done loading sample points");
|
||||
|
||||
log_debug("Setting up frame buffer");
|
||||
init_framebuffer(capinfo);
|
||||
log_debug("Done setting up frame buffer");
|
||||
|
||||
log_debug("Loading sample points");
|
||||
cpld->set_mode(mode7);
|
||||
log_debug("Done loading sample points");
|
||||
|
||||
clear = BIT_CLEAR;
|
||||
|
||||
osd_refresh();
|
||||
|
@ -1065,10 +1067,13 @@ void rgb_to_hdmi_main() {
|
|||
osd_key(OSD_SW3);
|
||||
}
|
||||
|
||||
// Possibly the size or offset has been adjusted, so update these
|
||||
size_changed = cpld->get_fb_params(capinfo);
|
||||
|
||||
last_mode7 = mode7;
|
||||
mode7 = result & BIT_MODE7;
|
||||
|
||||
} while (mode7 == last_mode7);
|
||||
} while (mode7 == last_mode7 && !size_changed);
|
||||
|
||||
osd_clear();
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue