mirror of
https://github.com/marqs85/ossc
synced 2025-04-09 22:56:34 +03:00
add support for Lumacode and VRR flag
This commit is contained in:
parent
b45e0fb517
commit
e49106b635
@ -114,7 +114,8 @@ typedef union {
|
||||
uint8_t bfi_str:4;
|
||||
uint8_t bfi_enable:1;
|
||||
uint8_t shmask_mode:2;
|
||||
uint32_t misc_rsv:9;
|
||||
uint8_t lumacode_mode:2;
|
||||
uint32_t misc_rsv:7;
|
||||
} __attribute__((packed, __may_alias__));
|
||||
uint32_t data;
|
||||
} misc_config_reg;
|
||||
|
@ -62,7 +62,10 @@ localparam VSYNC_SEPARATED = 1'b0;
|
||||
localparam VSYNC_RAW = 1'b1;
|
||||
|
||||
localparam PP_PL_START = 1;
|
||||
localparam PP_RLPF_START = PP_PL_START;
|
||||
localparam PP_DE_POS_START = PP_PL_START;
|
||||
localparam PP_DE_POS_LENGTH = 1;
|
||||
localparam PP_DE_POS_END = PP_DE_POS_START + PP_DE_POS_LENGTH;
|
||||
localparam PP_RLPF_START = PP_DE_POS_END;
|
||||
localparam PP_RLPF_LENGTH = 3;
|
||||
localparam PP_RLPF_END = PP_RLPF_START + PP_RLPF_LENGTH;
|
||||
localparam PP_PL_END = PP_RLPF_END;
|
||||
@ -82,16 +85,20 @@ reg [7:0] B_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg HSYNC_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg VSYNC_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg FID_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg DE_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg datavalid_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg [10:0] xpos_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg [10:0] ypos_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg DE_pp[PP_DE_POS_END:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg datavalid_pp[PP_DE_POS_END:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg [10:0] xpos_pp[PP_DE_POS_END:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
reg [10:0] ypos_pp[PP_DE_POS_END:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||
|
||||
// Reverse LPF
|
||||
wire rlpf_trigger_act;
|
||||
reg signed [14:0] R_diff_s15_pre, G_diff_s15_pre, B_diff_s15_pre, R_diff_s15, G_diff_s15, B_diff_s15;
|
||||
reg [7:0] R_pp_prev_rlpf, G_pp_prev_rlpf, B_pp_prev_rlpf;
|
||||
|
||||
// Lumacode
|
||||
reg [1:0] lumacode_msbs, lumacode_lsbs;
|
||||
wire [3:0] lumacode = {lumacode_msbs, lumacode_lsbs};
|
||||
|
||||
// Measurement registers
|
||||
reg [20:0] pcnt_frame_ctr;
|
||||
reg [17:0] syncpol_det_ctr, hsync_hpol_ctr, vsync_hpol_ctr;
|
||||
@ -114,6 +121,7 @@ wire [8:0] V_BACKPORCH = hv_in_config3[12:4];
|
||||
|
||||
wire [5:0] MISC_REV_LPF_STR = (misc_config[11:7] + 6'd16);
|
||||
wire MISC_REV_LPF_ENABLE = (misc_config[11:7] != 5'h0);
|
||||
wire [1:0] MISC_LUMACODE_MODE = misc_config[24:23];
|
||||
|
||||
wire [11:0] h_cnt_ref = (vsync_i_type == VSYNC_SEPARATED) ? h_cnt_sogref : h_cnt;
|
||||
wire [11:0] even_min_thold = (H_TOTAL / 12'd4);
|
||||
@ -134,6 +142,12 @@ wire HSYNC_i_np = (HSYNC_i ^ ~hsync_i_pol);
|
||||
// Sample skip for low-res optimized modes
|
||||
wire [3:0] H_SKIP = hv_in_config3[27:24];
|
||||
wire [3:0] H_SAMPLE_SEL = hv_in_config3[31:28];
|
||||
wire [3:0] H_SAMPLE_SEL_ALT = (H_SAMPLE_SEL >= (H_SKIP+1)/2) ? (H_SAMPLE_SEL - ((H_SKIP+1)/2)) : (H_SAMPLE_SEL + ((H_SKIP+1)/2));
|
||||
|
||||
// Lumacode tables (C64, Spectrum, empty)
|
||||
wire [23:0] lumacode_data[0:2][0:15] = '{'{ 24'h000000,24'h483aaa,24'h924a40,24'h9351b6,24'h675200,24'h606060,24'h8a8a8a,24'h84c5cc,24'hc33d00,24'h867ade,24'hb3b3b3,24'hd5df7c,24'h72b14b,24'hc18178,24'hb3ec91,24'hffffff},
|
||||
'{ 24'h000000,24'h000000,24'h0200FD,24'hCF01CE,24'h0100CE,24'hCF0100,24'hFF02FD,24'h01CFCF,24'hFF0201,24'h00CF15,24'h02FFFF,24'hFFFF1D,24'h00FF1C,24'hCFCF15,24'hCFCFCF,24'hFFFFFF},
|
||||
'{ 24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000,24'h000000}};
|
||||
|
||||
// SOF position for scaler
|
||||
wire [10:0] V_SOF_LINE = hv_in_config3[23:13];
|
||||
@ -150,14 +164,11 @@ function [7:0] apply_reverse_lpf;
|
||||
endfunction
|
||||
|
||||
|
||||
// Pipeline stage 1
|
||||
always @(posedge PCLK_i) begin
|
||||
R_pp[1] <= R_i;
|
||||
G_pp[1] <= G_i;
|
||||
B_pp[1] <= B_i;
|
||||
DE_pp[1] <= (h_cnt >= H_SYNCLEN+H_BACKPORCH) & (h_cnt < H_SYNCLEN+H_BACKPORCH+H_ACTIVE) & (v_cnt >= V_SYNCLEN+V_BACKPORCH) & (v_cnt < V_SYNCLEN+V_BACKPORCH+V_ACTIVE);
|
||||
datavalid_pp[1] <= (h_ctr == H_SAMPLE_SEL);
|
||||
xpos_pp[1] <= (h_cnt-H_SYNCLEN-H_BACKPORCH);
|
||||
ypos_pp[1] <= (v_cnt-V_SYNCLEN-V_BACKPORCH);
|
||||
|
||||
HS_i_prev <= HS_i;
|
||||
VS_i_np_prev <= VS_i_np;
|
||||
@ -230,10 +241,34 @@ always @(posedge PCLK_i) begin
|
||||
end
|
||||
end
|
||||
|
||||
// Pipeline stages 2-
|
||||
// Pipeline stage 2
|
||||
always @(posedge PCLK_i) begin
|
||||
// Lumacode
|
||||
if (h_ctr == H_SAMPLE_SEL) begin
|
||||
lumacode_msbs <= G_pp[1][7:6];
|
||||
end else if (h_ctr == H_SAMPLE_SEL_ALT) begin
|
||||
lumacode_lsbs <= G_pp[1][7:6];
|
||||
end
|
||||
|
||||
if (MISC_LUMACODE_MODE == 2'h0) begin
|
||||
{R_pp[2], G_pp[2], B_pp[2]} <= {R_pp[1], G_pp[1], B_pp[1]};
|
||||
end else begin
|
||||
{R_pp[2], G_pp[2], B_pp[2]} <= lumacode_data[MISC_LUMACODE_MODE-1'b1][lumacode];
|
||||
end
|
||||
|
||||
HSYNC_pp[2] <= HSYNC_pp[1];
|
||||
VSYNC_pp[2] <= VSYNC_pp[1];
|
||||
FID_pp[2] <= FID_pp[1];
|
||||
DE_pp[2] <= (h_cnt >= H_SYNCLEN+H_BACKPORCH) & (h_cnt < H_SYNCLEN+H_BACKPORCH+H_ACTIVE) & (v_cnt >= V_SYNCLEN+V_BACKPORCH) & (v_cnt < V_SYNCLEN+V_BACKPORCH+V_ACTIVE);
|
||||
datavalid_pp[2] <= (h_ctr == H_SAMPLE_SEL);
|
||||
xpos_pp[2] <= (h_cnt-H_SYNCLEN-H_BACKPORCH);
|
||||
ypos_pp[2] <= (v_cnt-V_SYNCLEN-V_BACKPORCH);
|
||||
end
|
||||
|
||||
// Pipeline stages 3-
|
||||
integer pp_idx;
|
||||
always @(posedge PCLK_i) begin
|
||||
for(pp_idx = PP_PL_START+1; pp_idx <= PP_PL_END; pp_idx = pp_idx+1) begin
|
||||
for(pp_idx = PP_RLPF_START+1; pp_idx <= PP_PL_END; pp_idx = pp_idx+1) begin
|
||||
R_pp[pp_idx] <= R_pp[pp_idx-1];
|
||||
G_pp[pp_idx] <= G_pp[pp_idx-1];
|
||||
B_pp[pp_idx] <= B_pp[pp_idx-1];
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -185,8 +185,10 @@ inline void TX_enable(tx_mode_t mode)
|
||||
if (mode != TX_DVI) {
|
||||
HDMITX_SetAVIInfoFrame(vmode_out.vic, (mode == TX_HDMI_RGB) ? F_MODE_RGB444 : F_MODE_YUV444, 0, 0, tc.hdmi_itc, vm_conf.hdmitx_pixr_ifr);
|
||||
HDMITX_SetHDRInfoFrame(tc.hdmi_hdr ? 3 : 0);
|
||||
HDMITX_SetVRRInfoFrame(tc.hdmi_vrr);
|
||||
cm.cc.hdmi_itc = tc.hdmi_itc;
|
||||
cm.cc.hdmi_hdr = tc.hdmi_hdr;
|
||||
cm.cc.hdmi_vrr = tc.hdmi_vrr;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AUDIO
|
||||
@ -460,6 +462,7 @@ void update_sc_config(mode_data_t *vm_in, mode_data_t *vm_out, vm_proc_config_t
|
||||
misc_config.mask_color = avconfig->mask_color;
|
||||
misc_config.reverse_lpf = avconfig->reverse_lpf;
|
||||
misc_config.shmask_mode = avconfig->shmask_mode;
|
||||
misc_config.lumacode_mode = avconfig->lumacode_mode;
|
||||
/*misc_config.lm_deint_mode = 0;
|
||||
misc_config.nir_even_offset = 0;
|
||||
misc_config.ypbpr_cs = (avconfig->ypbpr_cs == 0) ? ((vm_in->type & VIDEO_HDTV) ? 1 : 0) : avconfig->ypbpr_cs-1;
|
||||
@ -612,6 +615,7 @@ void program_mode()
|
||||
|
||||
tvp_source_setup(target_type,
|
||||
pll_h_total,
|
||||
vmode_in.timings.h_total,
|
||||
cm.clkcnt,
|
||||
0,
|
||||
(alt_u8)h_synclen_px,
|
||||
@ -1140,6 +1144,11 @@ int main()
|
||||
HDMITX_SetHDRInfoFrame(tc.hdmi_hdr ? 3 : 0);
|
||||
cm.cc.hdmi_hdr = tc.hdmi_hdr;
|
||||
}
|
||||
if (tc.hdmi_vrr != cm.cc.hdmi_vrr) {
|
||||
printf("setting VRR flag to %d\n", tc.hdmi_vrr);
|
||||
HDMITX_SetVRRInfoFrame(tc.hdmi_vrr);
|
||||
cm.cc.hdmi_vrr = tc.hdmi_vrr;
|
||||
}
|
||||
}
|
||||
if (tc.av3_alt_rgb != cm.cc.av3_alt_rgb) {
|
||||
printf("Changing AV3 RGB source\n");
|
||||
|
@ -119,6 +119,7 @@ typedef struct {
|
||||
alt_u8 mask_color;
|
||||
alt_u8 reverse_lpf;
|
||||
alt_u8 shmask_mode;
|
||||
alt_u8 lumacode_mode;
|
||||
|
||||
/* AFE settings */
|
||||
alt_u8 sync_vth;
|
||||
@ -144,6 +145,7 @@ typedef struct {
|
||||
alt_u8 tx_mode;
|
||||
alt_u8 hdmi_itc;
|
||||
alt_u8 hdmi_hdr;
|
||||
alt_u8 hdmi_vrr;
|
||||
alt_u8 full_tx_setup;
|
||||
alt_u8 av3_alt_rgb;
|
||||
avinput_t link_av;
|
||||
|
@ -80,6 +80,7 @@ static const char *auto_input_desc[] = { "Off", "Current input", "All inputs" };
|
||||
static const char *mask_color_desc[] = { "Black", "Blue", "Green", "Cyan", "Red", "Magenta", "Yellow", "White" };
|
||||
static const char *av3_alt_rgb_desc[] = { "Off", "AV1", "AV2" };
|
||||
static const char *shmask_mode_desc[] = { "Off", "A-Grille", "TV", "PVM" };
|
||||
static const char *lumacode_mode_desc[] = { "Off", "C64", "Spectrum", "NES" };
|
||||
|
||||
static void sync_vth_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, "%d mV", (v*1127)/100); }
|
||||
static void intclks_to_time_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, "%u.%.2u us", (unsigned)(((1000000U*v)/(TVP_INTCLK_HZ/1000))/1000), (unsigned)((((1000000U*v)/(TVP_INTCLK_HZ/1000))%1000)/10)); }
|
||||
@ -154,6 +155,7 @@ MENU(menu_vinputproc, P99_PROTECT({ \
|
||||
{ "Clamp/ALC offset", OPT_AVCONFIG_NUMVALUE, { .num = { &tc.clamp_offset, OPT_NOWRAP, CLAMP_OFFSET_MIN, CLAMP_OFFSET_MAX, signed_disp } } },
|
||||
{ "ALC V filter", OPT_AVCONFIG_NUMVALUE, { .num = { &tc.alc_v_filter, OPT_NOWRAP, 0, ALC_V_FILTER_MAX, alc_v_filter_disp } } },
|
||||
{ "ALC H filter", OPT_AVCONFIG_NUMVALUE, { .num = { &tc.alc_h_filter, OPT_NOWRAP, 0, ALC_H_FILTER_MAX, alc_h_filter_disp } } },
|
||||
{ "Lumacode", OPT_AVCONFIG_SELECTION, { .sel = { &tc.lumacode_mode, OPT_WRAP, SETTING_ITEM(lumacode_mode_desc) } } },
|
||||
}))
|
||||
|
||||
MENU(menu_sampling, P99_PROTECT({ \
|
||||
@ -190,6 +192,7 @@ MENU(menu_output, P99_PROTECT({ \
|
||||
{ LNG("TX mode","TXモード"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.tx_mode, OPT_WRAP, SETTING_ITEM(tx_mode_desc) } } },
|
||||
{ "HDMI ITC", OPT_AVCONFIG_SELECTION, { .sel = { &tc.hdmi_itc, OPT_WRAP, SETTING_ITEM(off_on_desc) } } },
|
||||
{ "HDMI HDR flag", OPT_AVCONFIG_SELECTION, { .sel = { &tc.hdmi_hdr, OPT_WRAP, SETTING_ITEM(off_on_desc) } } },
|
||||
{ "HDMI VRR flag", OPT_AVCONFIG_SELECTION, { .sel = { &tc.hdmi_vrr, OPT_WRAP, SETTING_ITEM(off_on_desc) } } },
|
||||
}))
|
||||
|
||||
MENU(menu_scanlines, P99_PROTECT({ \
|
||||
@ -245,7 +248,9 @@ MENU(menu_settings, P99_PROTECT({ \
|
||||
{ LNG("<Reset settings>","<セッテイヲショキカ >"), OPT_FUNC_CALL, { .fun = { set_default_avconfig, NULL } } },
|
||||
#ifndef DEBUG
|
||||
{ LNG("<Import sett. >","<セッテイヨミコミ >"), OPT_FUNC_CALL, { .fun = { import_userdata, NULL } } },
|
||||
#if 0
|
||||
{ LNG("<Export sett. >","<セッテイカキコミ >"), OPT_FUNC_CALL, { .fun = { export_userdata, NULL } } },
|
||||
#endif
|
||||
{ LNG("<Fw. update >","<ファームウェアアップデート>"), OPT_FUNC_CALL, { .fun = { fw_update, NULL } } },
|
||||
#endif
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user