Pi Firmware: Elk detection was broke - fixed now

Change-Id: I3d3f708f7bf6e62dc0e9e6cb8b0db4c0aacda715
issue_1022 20180718_695249b
David Banks 2018-07-18 14:58:32 +01:00
rodzic 228e1b5fac
commit 695249b650
3 zmienionych plików z 34 dodań i 19 usunięć

Wyświetl plik

@ -79,6 +79,11 @@ static const char *info_names[] = {
"Calibration Detail"
};
static const char *machine_names[] = {
"Beeb",
"Elk"
};
// =============================================================
// Feature definitions for OSD
// =============================================================
@ -106,7 +111,6 @@ static int info = INFO_VERSION;
static int palette = PALETTE_DEFAULT;
static int scanlines = 0;
static int mux = 0;
static int elk = 0;
static int debug = 0;
uint32_t *osd_get_palette() {
@ -239,7 +243,7 @@ static int get_feature(int num) {
case F_MUX:
return mux;
case F_ELK:
return elk;
return get_elk();
case F_DEBUG:
return debug;
}
@ -264,8 +268,7 @@ static void set_feature(int num, int value) {
RPI_SetGpioValue(MUX_PIN, mux);
break;
case F_ELK:
elk = value;
action_elk(value);
set_elk(value);
break;
case F_DEBUG:
debug = value;
@ -275,6 +278,7 @@ static void set_feature(int num, int value) {
}
static void show_feature(int num) {
const char *machine;
// Read the current value of the specified feature
int value = get_feature(num);
// Convert that to a human readable string
@ -295,10 +299,11 @@ static void show_feature(int num) {
osd_set(3, 0, message);
break;
case INFO_CAL_SUMMARY:
machine = machine_names[get_elk()];
if (clock_error_ppm > 0) {
sprintf(message, "Clk Err: %d ppm (Beeb slower than Pi)", clock_error_ppm);
sprintf(message, "Clk Err: %d ppm (%s slower than Pi)", clock_error_ppm, machine);
} else if (clock_error_ppm < 0) {
sprintf(message, "Clk Err: %d ppm (Beeb faster than Pi)", -clock_error_ppm);
sprintf(message, "Clk Err: %d ppm (%s faster than Pi)", -clock_error_ppm, machine);
} else {
sprintf(message, "Clk Err: %d ppm (exact match)", clock_error_ppm);
}

Wyświetl plik

@ -21,7 +21,8 @@ void osd_key(int key);
uint32_t *osd_get_palette();
void action_calibrate();
void action_elk(int on);
void action_scanlines(int on);
void set_elk(int on);
int get_elk();
#endif

Wyświetl plik

@ -404,11 +404,12 @@ static void cpld_init() {
cpld->init();
}
static int test_for_elk(int mode7, int chars_per_line) {
static int test_for_elk(int elk, int mode7, int chars_per_line) {
// If mode 7, then assume the Beeb
if (mode7) {
return 0;
// Leave the setting unchanged
return elk;
}
unsigned int ret;
@ -416,15 +417,18 @@ static int test_for_elk(int mode7, int chars_per_line) {
// Grab one field
ret = rgb_to_fb(fb, chars_per_line, pitch, flags);
// Save a copy
memcpy((void *)last, (void *)(fb + ((ret & BIT_LAST_BUFFER) ? SCREEN_HEIGHT * pitch : 0)), SCREEN_HEIGHT * pitch);
unsigned char *fb1 = fb + ((ret & BIT_LAST_BUFFER) ? SCREEN_HEIGHT * pitch : 0);
// Grab second field
ret = rgb_to_fb(fb, chars_per_line, pitch, flags);
unsigned char *fb1 = last;
unsigned char *fb2 = fb + ((ret & BIT_LAST_BUFFER) ? SCREEN_HEIGHT * pitch : 0);
if (fb1 == fb2) {
log_warn("test_for_elk() failed, both buffers the same!");
// Leave the setting unchanged
return elk;
}
unsigned int min_diff = INT_MAX;
unsigned int min_offset = 0;
@ -487,7 +491,7 @@ int *diff_N_frames(int n, int mode7, int elk, int chars_per_line) {
// In mode 0..6, set BIT_CAL_COUNT to 1 (capture 1 field)
// In mode 7, set BIT_CAL_COUNT to 0 (capture two fields, doesn't matter whether odd-even or even-odd)
unsigned int flags = mode7 | BIT_CALIBRATE | (mode7 ? 0 : BIT_CAL_COUNT) | (elk ? BIT_ELK : 0);
unsigned int flags = mode7 | BIT_CALIBRATE | (mode7 ? 0 : BIT_CAL_COUNT) | ((elk & !mode7) ? BIT_ELK : 0);
#ifdef INSTRUMENT_CAL
t = _get_cycle_counter();
@ -627,7 +631,7 @@ int total_N_frames(int n, int mode7, int elk, int chars_per_line) {
// In mode 0..6, set BIT_CAL_COUNT to 1 (capture 1 field)
// In mode 7, set BIT_CAL_COUNT to 0 (capture two fields, doesn't matter whether odd-even or even-odd)
unsigned int flags = mode7 | BIT_CALIBRATE | (mode7 ? 0 : BIT_CAL_COUNT) | (elk ? BIT_ELK : 0);
unsigned int flags = mode7 | BIT_CALIBRATE | (mode7 ? 0 : BIT_CAL_COUNT) | ((elk & !mode7) ? BIT_ELK : 0);
for (int i = 0; i < n; i++) {
int total = 0;
@ -692,11 +696,15 @@ void swapBuffer(int buffer) {
}
#endif
void action_elk(int on) {
void set_elk(int on) {
elk = on;
clear = BIT_CLEAR;
}
int get_elk() {
return elk;
}
void action_scanlines(int on) {
if (on) {
scanlines = BIT_SCANLINES;
@ -707,7 +715,8 @@ void action_scanlines(int on) {
}
void action_calibrate() {
elk = test_for_elk(mode7, chars_per_line);
// During calibration we do our best to auto-delect an Electron
elk = test_for_elk(elk, mode7, chars_per_line);
log_debug("Elk mode = %d", elk);
for (int c = 0; c < NUM_CAL_PASSES; c++) {
cpld->calibrate(elk, chars_per_line);
@ -746,7 +755,7 @@ void rgb_to_hdmi_main() {
do {
log_debug("Entering rgb_to_fb");
result = rgb_to_fb(fb, chars_per_line, pitch, mode7 | BIT_INITIALIZE | (elk ? BIT_ELK : 0) | clear | scanlines);
result = rgb_to_fb(fb, chars_per_line, pitch, mode7 | BIT_INITIALIZE | ((elk & !mode7) ? BIT_ELK : 0) | clear | scanlines);
log_debug("Leaving rgb_to_fb, result=%04x", result);
clear = 0;