kopia lustrzana https://github.com/hoglet67/RGBtoHDMI
Merge remote-tracking branch 'upstream/dev' into dev
commit
2f6bb5d855
|
@ -10,6 +10,10 @@
|
|||
// This is the default core clock, used when things got wrong
|
||||
#define DEFAULT_CORE_CLOCK 384000000
|
||||
|
||||
// Define the legal range of HDMI pixel clocks
|
||||
#define MIN_PIXEL_CLOCK 25.0 // 25MHz
|
||||
#define MAX_PIXEL_CLOCK 165.0 // 165MHz
|
||||
|
||||
// Define how the Pi Framebuffer is initialized
|
||||
// - if defined, use the property interface (Channel 8)
|
||||
// - if not defined, use to the the framebuffer interface (Channel 1)
|
||||
|
@ -155,7 +159,7 @@ typedef struct {
|
|||
|
||||
// LED1 is left LED, driven by the Pi
|
||||
// LED2 is the right LED, driven by the CPLD, as a copy of mode 7
|
||||
// both LEDs are active low
|
||||
// both LEDs are active high
|
||||
#define LED1_PIN (27)
|
||||
|
||||
#define SW1_MASK (1 << SW1_PIN)
|
||||
|
@ -163,6 +167,7 @@ typedef struct {
|
|||
#define SW3_MASK (1 << SW3_PIN)
|
||||
#define PSYNC_MASK (1 << PSYNC_PIN)
|
||||
#define CSYNC_MASK (1 << CSYNC_PIN)
|
||||
#define LED1_MASK (1 << LED1_PIN)
|
||||
|
||||
#define INTERLACED_FLAG (1 << 31)
|
||||
|
||||
|
|
23
src/osd.c
23
src/osd.c
|
@ -15,6 +15,7 @@
|
|||
#include "rpi-mailbox-interface.h"
|
||||
#include "saa5050_font.h"
|
||||
#include "rgb_to_fb.h"
|
||||
#include "rgb_to_hdmi.h"
|
||||
|
||||
// =============================================================
|
||||
// Definitions for the size of the OSD
|
||||
|
@ -861,7 +862,6 @@ void osd_clear() {
|
|||
memset(buffer, 0, sizeof(buffer));
|
||||
osd_update((uint32_t *)capinfo->fb, capinfo->pitch);
|
||||
active = 0;
|
||||
RPI_SetGpioValue(LED1_PIN, active);
|
||||
osd_update_palette();
|
||||
}
|
||||
}
|
||||
|
@ -869,7 +869,6 @@ void osd_clear() {
|
|||
void osd_set(int line, int attr, char *text) {
|
||||
if (!active) {
|
||||
active = 1;
|
||||
RPI_SetGpioValue(LED1_PIN, active);
|
||||
osd_update_palette();
|
||||
}
|
||||
attributes[line] = attr;
|
||||
|
@ -900,6 +899,7 @@ int osd_key(int key) {
|
|||
param_menu_item_t *param_item = (param_menu_item_t *)item;
|
||||
int val;
|
||||
int ret = -1;
|
||||
static int cal_count;
|
||||
static int last_vsync;
|
||||
|
||||
switch (osd_state) {
|
||||
|
@ -918,6 +918,10 @@ int osd_key(int key) {
|
|||
last_vsync = get_vsync();
|
||||
// Enable vsync
|
||||
set_vsync(1);
|
||||
// Do the actual clock calibration
|
||||
action_calibrate_clocks();
|
||||
// Initialize the counter used to limit the calibration time
|
||||
cal_count = 0;
|
||||
// Fire OSD_EXPIRED in 50 frames time
|
||||
ret = 50;
|
||||
// come back to CLOCK_CAL0
|
||||
|
@ -934,12 +938,21 @@ int osd_key(int key) {
|
|||
break;
|
||||
|
||||
case CLOCK_CAL0:
|
||||
// Do the actual clock calibration
|
||||
action_calibrate_clocks();
|
||||
// Fire OSD_EXPIRED in 50 frames time
|
||||
ret = 50;
|
||||
// come back to CLOCK_CAL1
|
||||
if (is_genlocked()) {
|
||||
// move on when locked
|
||||
osd_set(0, ATTR_DOUBLE_SIZE, "Genlock Succeeded");
|
||||
osd_state = CLOCK_CAL1;
|
||||
} else if (cal_count == 10) {
|
||||
// give up after 10 seconds
|
||||
osd_set(0, ATTR_DOUBLE_SIZE, "Genlock Failed");
|
||||
osd_state = CLOCK_CAL1;
|
||||
// restore the original HDMI clock
|
||||
set_vlockmode(HDMI_ORIGINAL);
|
||||
} else {
|
||||
cal_count++;
|
||||
}
|
||||
break;
|
||||
|
||||
case CLOCK_CAL1:
|
||||
|
|
24
src/osd.h
24
src/osd.h
|
@ -59,28 +59,4 @@ int osd_active();
|
|||
int osd_key(int key);
|
||||
void osd_update_palette();
|
||||
|
||||
void action_calibrate_clocks();
|
||||
void action_calibrate_auto();
|
||||
|
||||
void set_deinterlace(int value);
|
||||
int get_deinterlace();
|
||||
void set_scanlines(int on);
|
||||
int get_scanlines();
|
||||
void set_elk(int on);
|
||||
int get_elk();
|
||||
void set_vsync(int on);
|
||||
int get_vsync();
|
||||
void set_vlockmode(int val);
|
||||
int get_vlockmode();
|
||||
void set_vlockline(int val);
|
||||
int get_vlockline();
|
||||
#ifdef MULTI_BUFFER
|
||||
void set_nbuffers(int val);
|
||||
int get_nbuffers();
|
||||
#endif
|
||||
void set_m7disable(int on);
|
||||
int get_m7disable();
|
||||
void set_debug(int on);
|
||||
int get_debug();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -492,6 +492,22 @@ skip_osd_update:
|
|||
|
||||
push {r0-r12, lr}
|
||||
bl recalculate_hdmi_clock_line_locked_update
|
||||
|
||||
// Returns:
|
||||
// r0=0 genlock disabled - LED off
|
||||
// r0=1 genlock enabled (unlocked) - LED flash
|
||||
// r0=2 genlock enabled (locked) - LED on
|
||||
|
||||
READ_CYCLE_COUNTER r1
|
||||
|
||||
mov r2, #LED1_MASK
|
||||
tst r0, #1 // should LED flash?
|
||||
tstne r1, #(1 << 26) // flash rate ~ 8Hz
|
||||
tsteq r0, #2 // should LED be on?
|
||||
ldrne r1, =GPSET0 // LED on
|
||||
ldreq r1, =GPCLR0 // LED off
|
||||
str r2, [r1]
|
||||
|
||||
pop {r0-r12, lr}
|
||||
|
||||
ldr r0, lock_fail
|
||||
|
|
|
@ -33,6 +33,6 @@ extern int default_vsync_line;
|
|||
|
||||
extern int lock_fail;
|
||||
|
||||
void recalculate_hdmi_clock_line_locked_update();
|
||||
int recalculate_hdmi_clock_line_locked_update();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -460,6 +460,17 @@ static void recalculate_hdmi_clock(int vlockmode) { // use local vsyncmode, not
|
|||
f2 /= error;
|
||||
f2 /= 1.0 + ((double) (HDMI_EXACT - vlockmode)) / 1000.0;
|
||||
}
|
||||
|
||||
// Sanity check HDMI pixel clock
|
||||
pixel_clock = f2 / ((double) fixed_divider) / ((double) additional_divider);
|
||||
if (pixel_clock < MIN_PIXEL_CLOCK) {
|
||||
log_warn("Pixel clock of %.2lf MHz is too low; leaving unchanged", pixel_clock);
|
||||
f2 = pllh_clock;
|
||||
} else if (pixel_clock > MAX_PIXEL_CLOCK) {
|
||||
log_warn("Pixel clock of %.2lf MHz is too high; leaving unchanged", pixel_clock);
|
||||
f2 = pllh_clock;
|
||||
}
|
||||
|
||||
log_debug(" Source vsync freq: %lf Hz (measured)", source_vsync_freq);
|
||||
log_debug("Display vsync freq: %lf Hz", display_vsync_freq);
|
||||
log_debug(" Vsync error: %lf ppm", error_ppm);
|
||||
|
@ -525,7 +536,7 @@ static void recalculate_hdmi_clock_once(int vlockmode) {
|
|||
}
|
||||
}
|
||||
|
||||
void recalculate_hdmi_clock_line_locked_update() {
|
||||
int recalculate_hdmi_clock_line_locked_update() {
|
||||
lock_fail = 0;
|
||||
if (vlockmode != HDMI_EXACT) {
|
||||
genlocked = 0;
|
||||
|
@ -576,6 +587,14 @@ void recalculate_hdmi_clock_line_locked_update() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (vlockmode != HDMI_EXACT) {
|
||||
// Return 0 if genlock disabled
|
||||
return 0;
|
||||
} else {
|
||||
// Return 1 if genlock enabled but not yet locked
|
||||
// Return 2 if genlock enabled and locked
|
||||
return 1 + genlocked;
|
||||
}
|
||||
}
|
||||
|
||||
static void init_hardware() {
|
||||
|
@ -1179,6 +1198,10 @@ void action_calibrate_auto() {
|
|||
}
|
||||
}
|
||||
|
||||
int is_genlocked() {
|
||||
return genlocked;
|
||||
}
|
||||
|
||||
void rgb_to_hdmi_main() {
|
||||
|
||||
int result;
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef RGB_TO_HDMI_H
|
||||
#define RGB_TO_HDMI_H
|
||||
|
||||
// Property setters/getters
|
||||
void set_deinterlace(int value);
|
||||
int get_deinterlace();
|
||||
void set_scanlines(int on);
|
||||
int get_scanlines();
|
||||
void set_elk(int on);
|
||||
int get_elk();
|
||||
void set_vsync(int on);
|
||||
int get_vsync();
|
||||
void set_vlockmode(int val);
|
||||
int get_vlockmode();
|
||||
void set_vlockline(int val);
|
||||
int get_vlockline();
|
||||
#ifdef MULTI_BUFFER
|
||||
void set_nbuffers(int val);
|
||||
int get_nbuffers();
|
||||
#endif
|
||||
void set_m7disable(int on);
|
||||
int get_m7disable();
|
||||
void set_debug(int on);
|
||||
int get_debug();
|
||||
|
||||
// Actions
|
||||
void action_calibrate_clocks();
|
||||
void action_calibrate_auto();
|
||||
|
||||
// Status
|
||||
int is_genlocked();
|
||||
|
||||
#endif
|
Ładowanie…
Reference in New Issue