mirror of
https://github.com/marqs85/ossc
synced 2025-12-22 08:53:25 +03:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd79df5167 | ||
|
|
b151be6833 | ||
|
|
8c0a0c181d | ||
|
|
32af38e252 | ||
|
|
e9bfa11fa6 | ||
|
|
906ec6d574 | ||
|
|
1ba635901a | ||
|
|
496e3f68b8 | ||
|
|
4606dc4aba | ||
|
|
3194ec6ed3 | ||
|
|
05a9e351d4 | ||
|
|
e09f3c88b0 | ||
|
|
d6dba1618b | ||
|
|
6198ce7d9e | ||
|
|
30d403f157 | ||
|
|
21f8bc5406 | ||
|
|
41549e0957 | ||
|
|
8ed64b5cba | ||
|
|
933dbbaa75 | ||
|
|
6b554e4088 | ||
|
|
9f0c62c80a | ||
|
|
8f779136fa | ||
|
|
c572fb651a | ||
|
|
3abd3d7ec0 | ||
|
|
e74da07802 | ||
|
|
429b0f7201 | ||
|
|
fe3c6fdfa7 | ||
|
|
2725351039 | ||
|
|
9af171947a | ||
|
|
0c8b85d3f2 | ||
|
|
fae76ac3e4 | ||
|
|
e2f4350ab1 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -23,3 +23,8 @@ software/sys_controller/sys_controller.map
|
|||||||
software/sys_controller/sys_controller.elf
|
software/sys_controller/sys_controller.elf
|
||||||
.qsys_edit/*
|
.qsys_edit/*
|
||||||
PLLJ_PLLSPE_INFO.txt
|
PLLJ_PLLSPE_INFO.txt
|
||||||
|
tools/bin2hex
|
||||||
|
software/sys_controller_bsp/bsp_timestamp
|
||||||
|
*.a
|
||||||
|
software/sys_controller/mem_init/sys_onchip_memory2_0.bin
|
||||||
|
software/sys_controller/mem_init/sys_onchip_memory2_0.hex
|
||||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,3 +1,3 @@
|
|||||||
[submodule "ip/pulpino_qsys"]
|
[submodule "ip/ibex_qsys"]
|
||||||
path = ip/pulpino_qsys
|
path = ip/ibex_qsys
|
||||||
url = https://github.com/marqs85/pulpino_qsys.git
|
url = git@github.com:marqs85/ibex_qsys.git
|
||||||
|
|||||||
54
README.md
54
README.md
@ -13,6 +13,7 @@ Requirements for building and debugging firmware
|
|||||||
* Software
|
* Software
|
||||||
* [Altera Quartus II + Cyclone IV support](http://dl.altera.com/?edition=lite) (v 16.1 or higher - free Lite Edition suffices)
|
* [Altera Quartus II + Cyclone IV support](http://dl.altera.com/?edition=lite) (v 16.1 or higher - free Lite Edition suffices)
|
||||||
* [RISC-V GNU Compiler Toolchain](https://github.com/riscv/riscv-gnu-toolchain)
|
* [RISC-V GNU Compiler Toolchain](https://github.com/riscv/riscv-gnu-toolchain)
|
||||||
|
* [Picolibc library for RISC-V](https://github.com/picolibc/picolibc)
|
||||||
* GCC (or another C compiler) for host architecture (for building a SD card image)
|
* GCC (or another C compiler) for host architecture (for building a SD card image)
|
||||||
* Make
|
* Make
|
||||||
* [iconv](https://en.wikipedia.org/wiki/Iconv) (for building with JP lang menu)
|
* [iconv](https://en.wikipedia.org/wiki/Iconv) (for building with JP lang menu)
|
||||||
@ -20,19 +21,27 @@ Requirements for building and debugging firmware
|
|||||||
|
|
||||||
Architecture
|
Architecture
|
||||||
------------------------------
|
------------------------------
|
||||||
* [Reference board schematics](https://github.com/marqs85/ossc_pcb/raw/v1.6/ossc_board.pdf)
|
* [Reference board schematics](https://github.com/marqs85/ossc_pcb/raw/v1.8/doc/ossc_board.pdf)
|
||||||
* [Reference PCB project](https://github.com/marqs85/ossc_pcb)
|
* [Reference PCB project](https://github.com/marqs85/ossc_pcb)
|
||||||
|
|
||||||
|
|
||||||
SW toolchain build procedure
|
SW toolchain build procedure
|
||||||
--------------------------
|
--------------------------
|
||||||
1. Download, configure, build and install RISC-V toolchain with Newlib + RV32EMC support:
|
1. Download, configure, build and install RISC-V toolchain (with RV32EMC support) and Picolibc.
|
||||||
|
|
||||||
|
From sources:
|
||||||
~~~~
|
~~~~
|
||||||
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
|
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
|
||||||
|
git clone --recursive https://github.com/picolibc/picolibc
|
||||||
cd riscv-gnu-toolchain
|
cd riscv-gnu-toolchain
|
||||||
./configure --prefix=/opt/riscv --with-arch=rv32emc --with-abi=ilp32e
|
./configure --prefix=/opt/riscv --with-arch=rv32emc --with-abi=ilp32e
|
||||||
sudo make # sudo needed if installing under default /opt/riscv location
|
sudo make # sudo needed if installing under default /opt/riscv location
|
||||||
~~~~
|
~~~~
|
||||||
|
On Debian-style Linux distros:
|
||||||
|
~~~~
|
||||||
|
sudo apt install gcc-riscv64-unknown-elf binutils-riscv64-unknown-elf picolibc-riscv64-unknown-elf
|
||||||
|
~~~~
|
||||||
|
|
||||||
2. Compile custom binary to IHEX converter:
|
2. Compile custom binary to IHEX converter:
|
||||||
~~~~
|
~~~~
|
||||||
gcc tools/bin2hex.c -o tools/bin2hex
|
gcc tools/bin2hex.c -o tools/bin2hex
|
||||||
@ -41,9 +50,9 @@ gcc tools/bin2hex.c -o tools/bin2hex
|
|||||||
|
|
||||||
Building RTL (bitstream)
|
Building RTL (bitstream)
|
||||||
--------------------------
|
--------------------------
|
||||||
1. Initialize pulpino submodules (once after cloning ossc project or when submoduled have been updated)
|
1. Initialize project submodules (once after cloning ossc project or when submoduled have been updated)
|
||||||
~~~~
|
~~~~
|
||||||
git submodule update --init --recursive ip/pulpino_qsys
|
git submodule update --init --recursive
|
||||||
~~~~
|
~~~~
|
||||||
2. Load the project (ossc.qpf) in Quartus
|
2. Load the project (ossc.qpf) in Quartus
|
||||||
3. Generate QSYS output files (only needed before first compilation or when QSYS structure has been modified)
|
3. Generate QSYS output files (only needed before first compilation or when QSYS structure has been modified)
|
||||||
@ -51,12 +60,10 @@ git submodule update --init --recursive ip/pulpino_qsys
|
|||||||
* Load platform configuration (sys.qsys)
|
* Load platform configuration (sys.qsys)
|
||||||
* Generate output (Generate -> Generate HDL, Generate)
|
* Generate output (Generate -> Generate HDL, Generate)
|
||||||
* Close Platform Designer
|
* Close Platform Designer
|
||||||
|
* Run "patch -p0 <scripts/qsys.patch" to patch generated files to optimize block RAM usage
|
||||||
* Run "touch software/sys_controller_bsp/bsp_timestamp" to acknowledge QSYS update
|
* Run "touch software/sys_controller_bsp/bsp_timestamp" to acknowledge QSYS update
|
||||||
3. Generate the FPGA bitstream (Processing -> Start Compilation)
|
4. Generate the FPGA bitstream (Processing -> Start Compilation)
|
||||||
4. Ensure that there are no severe timing violations by looking into Timing Analyzer report
|
5. Ensure that there are no timing violations by looking into Timing Analyzer report
|
||||||
|
|
||||||
NOTE: If the software image (software/sys_controller/mem_init/sys_onchip_memory2_0.hex) was not up to date at the time of compilation, bitstream can be quickly rebuilt with updated hex by running "Processing->Update Memory Initialization File" and "Processing->Start->Start Assembler" in Quartus.
|
|
||||||
|
|
||||||
|
|
||||||
Building software image
|
Building software image
|
||||||
--------------------------
|
--------------------------
|
||||||
@ -70,14 +77,12 @@ make [OPTIONS] [TARGET]
|
|||||||
~~~~
|
~~~~
|
||||||
OPTIONS may include following definitions:
|
OPTIONS may include following definitions:
|
||||||
* OSDLANG=JP (Japanese language menu)
|
* OSDLANG=JP (Japanese language menu)
|
||||||
* ENABLE_AUDIO=y (Includes audio setup code for v1.6 PCB / DIY audio add-on board)
|
|
||||||
|
|
||||||
TARGET is typically one of the following:
|
TARGET is typically one of the following:
|
||||||
* all (Default target. Compiles an ELF file)
|
* all (Default target. Compiles an ELF file)
|
||||||
* generate_hex (Generates a memory initialization file required for bitstream and direct download)
|
|
||||||
* clean (cleans ELF and intermediate files. Should be invoked every time OPTIONS are changed between compilations, expect with generate_hex where it is done automatically)
|
* clean (cleans ELF and intermediate files. Should be invoked every time OPTIONS are changed between compilations, expect with generate_hex where it is done automatically)
|
||||||
|
|
||||||
3. Optionally test updated SW by directly downloading memory image to block RAM via JTAG
|
3. Optionally test updated SW by directly downloading SW image to flash via JTAG (requires valid FPGA bitstream to be present):
|
||||||
~~~~
|
~~~~
|
||||||
make rv-reprogram
|
make rv-reprogram
|
||||||
~~~~
|
~~~~
|
||||||
@ -85,16 +90,16 @@ make rv-reprogram
|
|||||||
|
|
||||||
Installing firmware via JTAG
|
Installing firmware via JTAG
|
||||||
--------------------------
|
--------------------------
|
||||||
The bitstream can be either directly programmed into FPGA (volatile method, suitable for quick testing), or into serial flash chip where it is automatically loaded every time FPGA is subsequently powered on (nonvolatile method, suitable for long-term use).
|
The bitstream can be either directly programmed into FPGA (volatile method, suitable for quick testing), or into serial flash chip alongside SW image where it is automatically loaded every time FPGA is subsequently powered on (nonvolatile method, suitable for long-term use).
|
||||||
|
|
||||||
To program FPGA, open Programmer in Quartus, select your USB Blaster device, add configuration file (output_files/ossc.sof) and press Start
|
To directly program FPGA, open Programmer in Quartus, select your USB Blaster device, add configuration file (output_files/ossc.sof) and press Start. Download SW image if it not present / up to date in flash.
|
||||||
|
|
||||||
To program flash, FPGA configuration file must be first converted into JTAG indirect Configuration file (.jic). Open conversion tool ("File->Convert Programming Files") in Quartus, click "Open Conversion Setup Data", select "ossc.cof" and press Generate. Then open Programmer, add generated file (output_files/ossc.jic) and press Start after which flash is programmed. Installed/updated firmware is activated after power-cycling the board.
|
To program flash, a combined FPGA image must be first generated and converted into JTAG indirect Configuration file (.jic). Open conversion tool ("File->Convert Programming Files") in Quartus, click "Open Conversion Setup Data", select "ossc.cof" and press Generate. Then open Programmer and ensure that "Initiate configuration after programming" and "Unprotect EPCS/EPCQ devices selected for Erase/Program operation" are checked in Tools->Options. Then clear file list, add generated file (output_files/ossc.jic) and press Start after which flash is programmed. Installed/updated firmware is activated when programming finishes (or after power-cycling the board in case of a fresh flash chip).
|
||||||
|
|
||||||
|
|
||||||
Generating SD card image
|
Generating SD card image
|
||||||
--------------------------
|
--------------------------
|
||||||
Bitstream file (Altera propiertary format) must be wrapped with custom header structure (including checksums) so that it can be processed reliably on the CPU. This can be done with included helper application which generates a disk image which can written to a SD card and subsequently loaded on OSSC:
|
Bitstream file (Altera propiertary format) must be wrapped with custom header structure (including checksums) so that it can be processed reliably on the CPU. This can be done with included helper application which generates an image file which can written on FAT32/exFAT-formatted SD card and subsequently loaded on OSSC:
|
||||||
|
|
||||||
1. Compile tools/create_fw_img.c
|
1. Compile tools/create_fw_img.c
|
||||||
~~~~
|
~~~~
|
||||||
@ -102,24 +107,31 @@ cd tools && gcc create_fw_img.c -o create_fw_img
|
|||||||
~~~~
|
~~~~
|
||||||
2. Generate the firmware image:
|
2. Generate the firmware image:
|
||||||
~~~~
|
~~~~
|
||||||
./create_fw_img <rbf> <version> [version_suffix]
|
./create_fw_img <rbf> <sw_image> <offset> <version> [version_suffix]
|
||||||
~~~~
|
~~~~
|
||||||
where
|
where
|
||||||
* \<rbf\> is RBF format bitstream file (typically ../output_files/ossc.rbf)
|
* \<rbf\> is RBF format bitstream file (typically ../output_files/ossc.rbf)
|
||||||
* \<version\> is version string (e.g. 0.78)
|
* \<sw_image\> is SW image binary (typically ../output_files/ossc.rbf)
|
||||||
|
* \<offset\> is target offset for the SW image binary (typically 0x50000)
|
||||||
|
* \<version\> is version string (e.g. 1.20)
|
||||||
* \[version_suffix\] is optional max. 8 character suffix name (e.g. "mytest")
|
* \[version_suffix\] is optional max. 8 character suffix name (e.g. "mytest")
|
||||||
|
|
||||||
|
The command creates ossc_\<version\>-\<version_suffix\>.bin which can be copied to fw folder of SD card. A secondary FW (identified by specific key in header) gets automatically installed at flash address 0x00080000.
|
||||||
|
|
||||||
Debugging
|
Debugging
|
||||||
--------------------------
|
--------------------------
|
||||||
1. Rebuild the software in debug mode:
|
1. Rebuild the software in debug mode:
|
||||||
~~~~
|
~~~~
|
||||||
make clean && make APP_CFLAGS_DEBUG_LEVEL="-DDEBUG" generate_hex
|
make clean && make APP_CFLAGS_DEBUG_LEVEL="-DDEBUG"
|
||||||
~~~~
|
~~~~
|
||||||
NOTE: Fw update functionality via SD card is disabled in debug builds due to code space limitations. If audio support is enabled on debug build, other functionality needs to be disabled as well.
|
|
||||||
|
|
||||||
2. Download memory image via JTAG and open terminal for UART
|
2. Flash SW image via JTAG and open terminal for UART
|
||||||
~~~~
|
~~~~
|
||||||
make rv-reprogram && nios2-terminal
|
make rv-reprogram && nios2-terminal
|
||||||
~~~~
|
~~~~
|
||||||
Remember to close nios2-terminal after debug session, otherwise any JTAG transactions will hang/fail.
|
Remember to close nios2-terminal after debug session, otherwise any JTAG transactions will hang/fail.
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
---------------------------------------------------
|
||||||
|
[GPL3](LICENSE)
|
||||||
@ -130,7 +130,7 @@ alt_u32 I2C_read(alt_u32 base,alt_u32 last)
|
|||||||
int I2C_write
|
int I2C_write
|
||||||
assumes that any addressing and start
|
assumes that any addressing and start
|
||||||
has already been done.
|
has already been done.
|
||||||
writes one byte of data from the slave.
|
writes one byte of data from the slave.
|
||||||
If last is set the stop bit set.
|
If last is set the stop bit set.
|
||||||
inputs
|
inputs
|
||||||
base = the base address of the component
|
base = the base address of the component
|
||||||
@ -182,7 +182,7 @@ alt_u32 I2C_write(alt_u32 base,alt_u8 data, alt_u32 last)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPI_read(alt_u32 base, alt_u8 *rdata, int len)
|
void __attribute__((noinline, flatten, __section__(".text_bram"))) SPI_read(alt_u32 base, alt_u8 *rdata, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ void SPI_read(alt_u32 base, alt_u8 *rdata, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPI_write(alt_u32 base, const alt_u8 *wdata, int len)
|
void __attribute__((noinline, flatten, __section__(".text_bram"))) SPI_write(alt_u32 base, const alt_u8 *wdata, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|||||||
1
ip/ibex_qsys
Submodule
1
ip/ibex_qsys
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 79c0da70116a3a10c73a14c91652e81acd3fc9a9
|
||||||
@ -36,8 +36,9 @@ typedef union {
|
|||||||
uint8_t y_offset:3;
|
uint8_t y_offset:3;
|
||||||
uint8_t x_size:2;
|
uint8_t x_size:2;
|
||||||
uint8_t y_size:2;
|
uint8_t y_size:2;
|
||||||
uint8_t border_color:2;
|
uint8_t border_color:3;
|
||||||
uint32_t osd_rsv:15;
|
uint8_t highlight_color:3;
|
||||||
|
uint32_t osd_rsv:11;
|
||||||
} __attribute__((packed, __may_alias__));
|
} __attribute__((packed, __may_alias__));
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
} osd_config_reg;
|
} osd_config_reg;
|
||||||
|
|||||||
@ -153,7 +153,7 @@ set_interface_property osd_if CMSIS_SVD_VARIABLES ""
|
|||||||
set_interface_property osd_if SVD_ADDRESS_GROUP ""
|
set_interface_property osd_if SVD_ADDRESS_GROUP ""
|
||||||
|
|
||||||
add_interface_port osd_if vclk vclk Input 1
|
add_interface_port osd_if vclk vclk Input 1
|
||||||
add_interface_port osd_if xpos xpos Input 11
|
add_interface_port osd_if xpos xpos Input 12
|
||||||
add_interface_port osd_if ypos ypos Input 11
|
add_interface_port osd_if ypos ypos Input 11
|
||||||
add_interface_port osd_if osd_enable osd_enable Output 1
|
add_interface_port osd_if osd_enable osd_enable Output 1
|
||||||
add_interface_port osd_if osd_color osd_color Output 2
|
add_interface_port osd_if osd_color osd_color Output 3
|
||||||
|
|||||||
@ -32,10 +32,10 @@ module osd_generator_top (
|
|||||||
output avalon_s_waitrequest_n,
|
output avalon_s_waitrequest_n,
|
||||||
// OSD interface
|
// OSD interface
|
||||||
input vclk,
|
input vclk,
|
||||||
input [10:0] xpos,
|
input [11:0] xpos,
|
||||||
input [10:0] ypos,
|
input [10:0] ypos,
|
||||||
output reg osd_enable,
|
output reg osd_enable,
|
||||||
output reg [1:0] osd_color
|
output reg [2:0] osd_color
|
||||||
);
|
);
|
||||||
|
|
||||||
localparam CHAR_ROWS = 30;
|
localparam CHAR_ROWS = 30;
|
||||||
@ -43,10 +43,10 @@ localparam CHAR_COLS = 16;
|
|||||||
localparam CHAR_SECTIONS = 2;
|
localparam CHAR_SECTIONS = 2;
|
||||||
localparam CHAR_SEC_SEPARATOR = 2;
|
localparam CHAR_SEC_SEPARATOR = 2;
|
||||||
|
|
||||||
localparam BG_BLACK = 2'h0;
|
localparam BG_BLACK = 3'h0;
|
||||||
localparam BG_BLUE = 2'h1;
|
localparam BG_BLUE = 3'h1;
|
||||||
localparam BG_YELLOW = 2'h2;
|
localparam BG_YELLOW = 3'h6;
|
||||||
localparam BG_WHITE = 2'h3;
|
localparam BG_WHITE = 3'h7;
|
||||||
|
|
||||||
localparam OSD_CONFIG_REGNUM = 8'hf0;
|
localparam OSD_CONFIG_REGNUM = 8'hf0;
|
||||||
localparam OSD_ROW_LSEC_ENABLE_REGNUM = 8'hf1;
|
localparam OSD_ROW_LSEC_ENABLE_REGNUM = 8'hf1;
|
||||||
@ -56,10 +56,12 @@ localparam OSD_ROW_COLOR_REGNUM = 8'hf3;
|
|||||||
reg [31:0] osd_config;
|
reg [31:0] osd_config;
|
||||||
reg [31:0] config_reg[OSD_ROW_LSEC_ENABLE_REGNUM:OSD_ROW_COLOR_REGNUM] /* synthesis ramstyle = "logic" */;
|
reg [31:0] config_reg[OSD_ROW_LSEC_ENABLE_REGNUM:OSD_ROW_COLOR_REGNUM] /* synthesis ramstyle = "logic" */;
|
||||||
|
|
||||||
reg [10:0] xpos_osd_area_scaled, xpos_text_scaled;
|
reg [11:0] xpos_osd_area_scaled, xpos_text_scaled;
|
||||||
reg [10:0] ypos_osd_area_scaled, ypos_text_scaled;
|
reg [10:0] ypos_osd_area_scaled, ypos_text_scaled;
|
||||||
reg [7:0] x_ptr[2:5], y_ptr[2:5] /* synthesis ramstyle = "logic" */;
|
reg [7:0] x_ptr[2:5], y_ptr[2:5] /* synthesis ramstyle = "logic" */;
|
||||||
reg osd_text_act_pp[2:6], osd_act_pp[3:6];
|
reg osd_text_act_lsec_x_hit, osd_text_act_lsec_en, osd_text_act_rsec_x_hit, osd_text_act_rsec_en, osd_text_act_y_hit;
|
||||||
|
reg osd_act_lsec_x_hit, osd_act_lsec_en, osd_act_rsec_x_hit, osd_act_rsec_en, osd_act_y_hit;
|
||||||
|
reg osd_text_act_pp[3:6], osd_act_pp[4:6];
|
||||||
reg [14:0] to_ctr, to_ctr_ms;
|
reg [14:0] to_ctr, to_ctr_ms;
|
||||||
reg char_px;
|
reg char_px;
|
||||||
|
|
||||||
@ -71,9 +73,10 @@ wire [2:0] x_offset = osd_config[7:5];
|
|||||||
wire [2:0] y_offset = osd_config[10:8];
|
wire [2:0] y_offset = osd_config[10:8];
|
||||||
wire [1:0] x_size = osd_config[12:11];
|
wire [1:0] x_size = osd_config[12:11];
|
||||||
wire [1:0] y_size = osd_config[14:13];
|
wire [1:0] y_size = osd_config[14:13];
|
||||||
wire [1:0] border_color = osd_config[16:15];
|
wire [2:0] border_color = osd_config[17:15];
|
||||||
|
wire [2:0] highlight_color = osd_config[20:18];
|
||||||
|
|
||||||
wire [10:0] xpos_scaled_w = (xpos >> x_size)-({3'h0, x_offset} << 3);
|
wire [11:0] xpos_scaled_w = (xpos >> x_size)-({3'h0, x_offset} << 3);
|
||||||
wire [10:0] ypos_scaled_w = (ypos >> y_size)-({3'h0, y_offset} << 3);
|
wire [10:0] ypos_scaled_w = (ypos >> y_size)-({3'h0, y_offset} << 3);
|
||||||
wire [7:0] rom_rdaddr;
|
wire [7:0] rom_rdaddr;
|
||||||
wire [0:7] char_data[7:0];
|
wire [0:7] char_data[7:0];
|
||||||
@ -123,21 +126,27 @@ always @(posedge vclk) begin
|
|||||||
y_ptr[pp_idx] <= y_ptr[pp_idx-1];
|
y_ptr[pp_idx] <= y_ptr[pp_idx-1];
|
||||||
end
|
end
|
||||||
|
|
||||||
osd_text_act_pp[2] <= render_enable &
|
osd_text_act_lsec_x_hit <= (xpos_text_scaled < 8*CHAR_COLS);
|
||||||
|
osd_text_act_lsec_en <= config_reg[OSD_ROW_LSEC_ENABLE_REGNUM][ypos_text_scaled/8];
|
||||||
|
osd_text_act_rsec_x_hit <= (xpos_text_scaled >= 8*(CHAR_COLS+CHAR_SEC_SEPARATOR)) & (xpos_text_scaled < 8*(2*CHAR_COLS+CHAR_SEC_SEPARATOR));
|
||||||
|
osd_text_act_rsec_en <= config_reg[OSD_ROW_RSEC_ENABLE_REGNUM][ypos_text_scaled/8];
|
||||||
|
osd_text_act_y_hit <= (ypos_text_scaled < 8*CHAR_ROWS);
|
||||||
|
osd_text_act_pp[3] <= render_enable &
|
||||||
(menu_active || (to_ctr_ms > 0)) &
|
(menu_active || (to_ctr_ms > 0)) &
|
||||||
(((xpos_text_scaled < 8*CHAR_COLS) & config_reg[OSD_ROW_LSEC_ENABLE_REGNUM][ypos_text_scaled/8]) |
|
((osd_text_act_lsec_x_hit & osd_text_act_lsec_en) | (osd_text_act_rsec_x_hit & osd_text_act_rsec_en)) & osd_text_act_y_hit;
|
||||||
((xpos_text_scaled >= 8*(CHAR_COLS+CHAR_SEC_SEPARATOR)) & (xpos_text_scaled < 8*(2*CHAR_COLS+CHAR_SEC_SEPARATOR)) & config_reg[OSD_ROW_RSEC_ENABLE_REGNUM][ypos_text_scaled/8])) &
|
for(pp_idx = 4; pp_idx <= 6; pp_idx = pp_idx+1) begin
|
||||||
(ypos_text_scaled < 8*CHAR_ROWS);
|
|
||||||
for(pp_idx = 3; pp_idx <= 6; pp_idx = pp_idx+1) begin
|
|
||||||
osd_text_act_pp[pp_idx] <= osd_text_act_pp[pp_idx-1];
|
osd_text_act_pp[pp_idx] <= osd_text_act_pp[pp_idx-1];
|
||||||
end
|
end
|
||||||
|
|
||||||
osd_act_pp[3] <= render_enable &
|
osd_act_lsec_x_hit <= (xpos_osd_area_scaled/8 < (CHAR_COLS+1));
|
||||||
|
osd_act_lsec_en <= config_reg[OSD_ROW_LSEC_ENABLE_REGNUM][(ypos_osd_area_scaled/8) ? ((ypos_osd_area_scaled/8)-1) : 0];
|
||||||
|
osd_act_rsec_x_hit <= (xpos_osd_area_scaled/8 >= (CHAR_COLS+1)) & (xpos_osd_area_scaled/8 < (2*CHAR_COLS+CHAR_SEC_SEPARATOR+1));
|
||||||
|
osd_act_rsec_en <= (config_reg[OSD_ROW_RSEC_ENABLE_REGNUM][(ypos_osd_area_scaled/8)-1] | config_reg[OSD_ROW_RSEC_ENABLE_REGNUM][ypos_osd_area_scaled/8]);
|
||||||
|
osd_act_y_hit <= (ypos_osd_area_scaled < 8*(CHAR_ROWS+1));
|
||||||
|
osd_act_pp[4] <= render_enable &
|
||||||
(menu_active || (to_ctr_ms > 0)) &
|
(menu_active || (to_ctr_ms > 0)) &
|
||||||
(((xpos_osd_area_scaled/8 < (CHAR_COLS+1)) & config_reg[OSD_ROW_LSEC_ENABLE_REGNUM][(ypos_osd_area_scaled/8) ? ((ypos_osd_area_scaled/8)-1) : 0]) |
|
((osd_act_lsec_x_hit & osd_act_lsec_en) | (osd_act_rsec_x_hit & osd_act_rsec_en)) & osd_act_y_hit;
|
||||||
((xpos_osd_area_scaled/8 >= (CHAR_COLS+1)) & (xpos_osd_area_scaled/8 < (2*CHAR_COLS+CHAR_SEC_SEPARATOR+1)) & (config_reg[OSD_ROW_RSEC_ENABLE_REGNUM][(ypos_osd_area_scaled/8)-1] | config_reg[OSD_ROW_RSEC_ENABLE_REGNUM][ypos_osd_area_scaled/8]))) &
|
for(pp_idx = 5; pp_idx <= 6; pp_idx = pp_idx+1) begin
|
||||||
(ypos_osd_area_scaled < 8*(CHAR_ROWS+1));
|
|
||||||
for(pp_idx = 4; pp_idx <= 6; pp_idx = pp_idx+1) begin
|
|
||||||
osd_act_pp[pp_idx] <= osd_act_pp[pp_idx-1];
|
osd_act_pp[pp_idx] <= osd_act_pp[pp_idx-1];
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -147,7 +156,7 @@ always @(posedge vclk) begin
|
|||||||
|
|
||||||
if (osd_text_act_pp[6]) begin
|
if (osd_text_act_pp[6]) begin
|
||||||
if (char_px) begin
|
if (char_px) begin
|
||||||
osd_color <= config_reg[OSD_ROW_COLOR_REGNUM][char_row] ? BG_YELLOW : BG_WHITE;
|
osd_color <= config_reg[OSD_ROW_COLOR_REGNUM][char_row] ? highlight_color : BG_WHITE;
|
||||||
end else begin
|
end else begin
|
||||||
osd_color <= BG_BLUE;
|
osd_color <= BG_BLUE;
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
Subproject commit dfb0af0ed3b4e9e72e444eba2b1c149b5adad2cc
|
|
||||||
@ -107,15 +107,12 @@ typedef union {
|
|||||||
uint8_t mask_br:4;
|
uint8_t mask_br:4;
|
||||||
uint8_t mask_color:3;
|
uint8_t mask_color:3;
|
||||||
uint8_t reverse_lpf:5;
|
uint8_t reverse_lpf:5;
|
||||||
uint8_t lm_deint_mode:1;
|
|
||||||
uint8_t nir_even_offset:1;
|
|
||||||
uint8_t ypbpr_cs:1;
|
|
||||||
uint8_t vip_enable:1;
|
|
||||||
uint8_t bfi_str:4;
|
|
||||||
uint8_t bfi_enable:1;
|
|
||||||
uint8_t shmask_mode:2;
|
|
||||||
uint8_t lumacode_mode:3;
|
uint8_t lumacode_mode:3;
|
||||||
uint32_t misc_rsv:6;
|
uint8_t shmask_enable:1;
|
||||||
|
uint8_t shmask_iv_x:4;
|
||||||
|
uint8_t shmask_iv_y:4;
|
||||||
|
uint8_t panasonic_hack:1;
|
||||||
|
uint32_t misc_rsv:7;
|
||||||
} __attribute__((packed, __may_alias__));
|
} __attribute__((packed, __may_alias__));
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
} misc_config_reg;
|
} misc_config_reg;
|
||||||
@ -149,6 +146,16 @@ typedef union {
|
|||||||
uint32_t data;
|
uint32_t data;
|
||||||
} sl_config3_reg;
|
} sl_config3_reg;
|
||||||
|
|
||||||
|
// shmask regs
|
||||||
|
typedef struct {
|
||||||
|
uint32_t data[16][16];
|
||||||
|
} shmask_array;
|
||||||
|
|
||||||
|
// lumacode palatte ram
|
||||||
|
typedef struct {
|
||||||
|
uint32_t data[512];
|
||||||
|
} lc_pal_ram;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
fe_status_reg fe_status;
|
fe_status_reg fe_status;
|
||||||
fe_status2_reg fe_status2;
|
fe_status2_reg fe_status2;
|
||||||
@ -165,6 +172,8 @@ typedef struct {
|
|||||||
sl_config_reg sl_config;
|
sl_config_reg sl_config;
|
||||||
sl_config2_reg sl_config2;
|
sl_config2_reg sl_config2;
|
||||||
sl_config3_reg sl_config3;
|
sl_config3_reg sl_config3;
|
||||||
|
shmask_array shmask_data_array __attribute__ ((aligned (1024)));
|
||||||
|
lc_pal_ram lumacode_pal_ram __attribute__ ((aligned (2048)));
|
||||||
} sc_regs;
|
} sc_regs;
|
||||||
|
|
||||||
#endif //SC_CONFIG_REGS_H_
|
#endif //SC_CONFIG_REGS_H_
|
||||||
|
|||||||
@ -100,7 +100,7 @@ set_interface_property avalon_s PORT_NAME_MAP ""
|
|||||||
set_interface_property avalon_s CMSIS_SVD_VARIABLES ""
|
set_interface_property avalon_s CMSIS_SVD_VARIABLES ""
|
||||||
set_interface_property avalon_s SVD_ADDRESS_GROUP ""
|
set_interface_property avalon_s SVD_ADDRESS_GROUP ""
|
||||||
|
|
||||||
add_interface_port avalon_s avalon_s_address address Input 4
|
add_interface_port avalon_s avalon_s_address address Input 10
|
||||||
add_interface_port avalon_s avalon_s_writedata writedata Input 32
|
add_interface_port avalon_s avalon_s_writedata writedata Input 32
|
||||||
add_interface_port avalon_s avalon_s_readdata readdata Output 32
|
add_interface_port avalon_s avalon_s_readdata readdata Output 32
|
||||||
add_interface_port avalon_s avalon_s_byteenable byteenable Input 4
|
add_interface_port avalon_s avalon_s_byteenable byteenable Input 4
|
||||||
@ -158,3 +158,39 @@ add_interface_port sc_if misc_config_o misc_config_o Output 32
|
|||||||
add_interface_port sc_if sl_config_o sl_config_o Output 32
|
add_interface_port sc_if sl_config_o sl_config_o Output 32
|
||||||
add_interface_port sc_if sl_config2_o sl_config2_o Output 32
|
add_interface_port sc_if sl_config2_o sl_config2_o Output 32
|
||||||
add_interface_port sc_if sl_config3_o sl_config3_o Output 32
|
add_interface_port sc_if sl_config3_o sl_config3_o Output 32
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# connection point shmask_if
|
||||||
|
#
|
||||||
|
add_interface shmask_if conduit end
|
||||||
|
set_interface_property shmask_if associatedClock ""
|
||||||
|
set_interface_property shmask_if associatedReset ""
|
||||||
|
set_interface_property shmask_if ENABLED true
|
||||||
|
set_interface_property shmask_if EXPORT_OF ""
|
||||||
|
set_interface_property shmask_if PORT_NAME_MAP ""
|
||||||
|
set_interface_property shmask_if CMSIS_SVD_VARIABLES ""
|
||||||
|
set_interface_property shmask_if SVD_ADDRESS_GROUP ""
|
||||||
|
|
||||||
|
add_interface_port shmask_if vclk vclk Input 1
|
||||||
|
add_interface_port shmask_if shmask_xpos shmask_xpos Input 4
|
||||||
|
add_interface_port shmask_if shmask_ypos shmask_ypos Input 4
|
||||||
|
add_interface_port shmask_if shmask_data shmask_data Output 11
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# connection point lumacode_ram_if
|
||||||
|
#
|
||||||
|
add_interface lc_ram_if conduit end
|
||||||
|
set_interface_property lc_ram_if associatedClock ""
|
||||||
|
set_interface_property lc_ram_if associatedReset ""
|
||||||
|
set_interface_property lc_ram_if ENABLED true
|
||||||
|
set_interface_property lc_ram_if EXPORT_OF ""
|
||||||
|
set_interface_property lc_ram_if PORT_NAME_MAP ""
|
||||||
|
set_interface_property lc_ram_if CMSIS_SVD_VARIABLES ""
|
||||||
|
set_interface_property lc_ram_if SVD_ADDRESS_GROUP ""
|
||||||
|
|
||||||
|
add_interface_port lc_ram_if lumacode_clk_i lumacode_clk_i Input 1
|
||||||
|
add_interface_port lc_ram_if lumacode_addr_i lumacode_addr_i Input 9
|
||||||
|
add_interface_port lc_ram_if lumacode_rden_i lumacode_rden_i Input 1
|
||||||
|
add_interface_port lc_ram_if lumacode_data_o lumacode_data_o Output 32
|
||||||
|
|||||||
@ -24,7 +24,7 @@ module sc_config_top(
|
|||||||
// avalon slave
|
// avalon slave
|
||||||
input [31:0] avalon_s_writedata,
|
input [31:0] avalon_s_writedata,
|
||||||
output reg [31:0] avalon_s_readdata,
|
output reg [31:0] avalon_s_readdata,
|
||||||
input [3:0] avalon_s_address,
|
input [9:0] avalon_s_address,
|
||||||
input [3:0] avalon_s_byteenable,
|
input [3:0] avalon_s_byteenable,
|
||||||
input avalon_s_write,
|
input avalon_s_write,
|
||||||
input avalon_s_read,
|
input avalon_s_read,
|
||||||
@ -45,29 +45,134 @@ module sc_config_top(
|
|||||||
output [31:0] misc_config_o,
|
output [31:0] misc_config_o,
|
||||||
output [31:0] sl_config_o,
|
output [31:0] sl_config_o,
|
||||||
output [31:0] sl_config2_o,
|
output [31:0] sl_config2_o,
|
||||||
output [31:0] sl_config3_o
|
output [31:0] sl_config3_o,
|
||||||
|
// Shadow mask read interface
|
||||||
|
input vclk,
|
||||||
|
input [3:0] shmask_xpos,
|
||||||
|
input [3:0] shmask_ypos,
|
||||||
|
output [10:0] shmask_data,
|
||||||
|
// Lumacode interface
|
||||||
|
input lumacode_clk_i,
|
||||||
|
input [8:0] lumacode_addr_i,
|
||||||
|
input lumacode_rden_i,
|
||||||
|
output [31:0] lumacode_data_o
|
||||||
);
|
);
|
||||||
|
|
||||||
localparam FE_STATUS_REGNUM = 4'h0;
|
localparam FE_STATUS_REGNUM = 10'h0;
|
||||||
localparam FE_STATUS2_REGNUM = 4'h1;
|
localparam FE_STATUS2_REGNUM = 10'h1;
|
||||||
localparam LT_STATUS_REGNUM = 4'h2;
|
localparam LT_STATUS_REGNUM = 10'h2;
|
||||||
localparam HV_IN_CONFIG_REGNUM = 4'h3;
|
localparam HV_IN_CONFIG_REGNUM = 10'h3;
|
||||||
localparam HV_IN_CONFIG2_REGNUM = 4'h4;
|
localparam HV_IN_CONFIG2_REGNUM = 10'h4;
|
||||||
localparam HV_IN_CONFIG3_REGNUM = 4'h5;
|
localparam HV_IN_CONFIG3_REGNUM = 10'h5;
|
||||||
localparam HV_OUT_CONFIG_REGNUM = 4'h6;
|
localparam HV_OUT_CONFIG_REGNUM = 10'h6;
|
||||||
localparam HV_OUT_CONFIG2_REGNUM = 4'h7;
|
localparam HV_OUT_CONFIG2_REGNUM = 10'h7;
|
||||||
localparam HV_OUT_CONFIG3_REGNUM = 4'h8;
|
localparam HV_OUT_CONFIG3_REGNUM = 10'h8;
|
||||||
localparam XY_OUT_CONFIG_REGNUM = 4'h9;
|
localparam XY_OUT_CONFIG_REGNUM = 10'h9;
|
||||||
localparam XY_OUT_CONFIG2_REGNUM = 4'ha;
|
localparam XY_OUT_CONFIG2_REGNUM = 10'ha;
|
||||||
localparam MISC_CONFIG_REGNUM = 4'hb;
|
localparam MISC_CONFIG_REGNUM = 10'hb;
|
||||||
localparam SL_CONFIG_REGNUM = 4'hc;
|
localparam SL_CONFIG_REGNUM = 10'hc;
|
||||||
localparam SL_CONFIG2_REGNUM = 4'hd;
|
localparam SL_CONFIG2_REGNUM = 10'hd;
|
||||||
localparam SL_CONFIG3_REGNUM = 4'he;
|
localparam SL_CONFIG3_REGNUM = 10'he;
|
||||||
|
|
||||||
|
localparam SHMASK_DATA_OFFSET = 10'h100;
|
||||||
|
localparam LUMACODE_RAM_OFFSET = 10'h200;
|
||||||
|
|
||||||
reg [31:0] config_reg[HV_IN_CONFIG_REGNUM:SL_CONFIG3_REGNUM] /* synthesis ramstyle = "logic" */;
|
reg [31:0] config_reg[HV_IN_CONFIG_REGNUM:SL_CONFIG3_REGNUM] /* synthesis ramstyle = "logic" */;
|
||||||
|
|
||||||
assign avalon_s_waitrequest_n = 1'b1;
|
assign avalon_s_waitrequest_n = 1'b1;
|
||||||
|
|
||||||
|
// Shadow mask array
|
||||||
|
altsyncram shmask_array_inst (
|
||||||
|
.address_a (avalon_s_address[7:0]),
|
||||||
|
.address_b ({shmask_ypos, shmask_xpos}),
|
||||||
|
.clock0 (clk_i),
|
||||||
|
.clock1 (vclk),
|
||||||
|
.data_a (avalon_s_writedata[10:0]),
|
||||||
|
.wren_a (avalon_s_chipselect && avalon_s_write && (avalon_s_address >= SHMASK_DATA_OFFSET) && (avalon_s_address < LUMACODE_RAM_OFFSET)),
|
||||||
|
.q_b (shmask_data),
|
||||||
|
.aclr0 (1'b0),
|
||||||
|
.aclr1 (1'b0),
|
||||||
|
.addressstall_a (1'b0),
|
||||||
|
.addressstall_b (1'b0),
|
||||||
|
.byteena_a (1'b1),
|
||||||
|
.byteena_b (1'b1),
|
||||||
|
.clocken0 (1'b1),
|
||||||
|
.clocken1 (1'b1),
|
||||||
|
.clocken2 (1'b1),
|
||||||
|
.clocken3 (1'b1),
|
||||||
|
.data_b ({11{1'b1}}),
|
||||||
|
.eccstatus (),
|
||||||
|
.q_a (),
|
||||||
|
.rden_a (1'b1),
|
||||||
|
.rden_b (1'b1),
|
||||||
|
.wren_b (1'b0));
|
||||||
|
defparam
|
||||||
|
shmask_array_inst.address_aclr_b = "NONE",
|
||||||
|
shmask_array_inst.address_reg_b = "CLOCK1",
|
||||||
|
shmask_array_inst.clock_enable_input_a = "BYPASS",
|
||||||
|
shmask_array_inst.clock_enable_input_b = "BYPASS",
|
||||||
|
shmask_array_inst.clock_enable_output_b = "BYPASS",
|
||||||
|
shmask_array_inst.intended_device_family = "Cyclone IV E",
|
||||||
|
shmask_array_inst.lpm_type = "altsyncram",
|
||||||
|
shmask_array_inst.numwords_a = 256,
|
||||||
|
shmask_array_inst.numwords_b = 256,
|
||||||
|
shmask_array_inst.operation_mode = "DUAL_PORT",
|
||||||
|
shmask_array_inst.outdata_aclr_b = "NONE",
|
||||||
|
shmask_array_inst.outdata_reg_b = "CLOCK1",
|
||||||
|
shmask_array_inst.power_up_uninitialized = "FALSE",
|
||||||
|
shmask_array_inst.widthad_a = 8,
|
||||||
|
shmask_array_inst.widthad_b = 8,
|
||||||
|
shmask_array_inst.width_a = 11,
|
||||||
|
shmask_array_inst.width_b = 11,
|
||||||
|
shmask_array_inst.width_byteena_a = 1;
|
||||||
|
|
||||||
|
// Lumacode palette RAM
|
||||||
|
altsyncram lumacode_pal_ram (
|
||||||
|
.address_a (avalon_s_address[8:0]),
|
||||||
|
.address_b (lumacode_addr_i),
|
||||||
|
.clock0 (clk_i),
|
||||||
|
.clock1 (lumacode_clk_i),
|
||||||
|
.data_a (avalon_s_writedata),
|
||||||
|
.rden_b (lumacode_rden_i),
|
||||||
|
.wren_a (avalon_s_chipselect && avalon_s_write && (avalon_s_address >= LUMACODE_RAM_OFFSET)),
|
||||||
|
.q_b (lumacode_data_o),
|
||||||
|
.aclr0 (1'b0),
|
||||||
|
.aclr1 (1'b0),
|
||||||
|
.addressstall_a (1'b0),
|
||||||
|
.addressstall_b (1'b0),
|
||||||
|
.byteena_a (1'b1),
|
||||||
|
.byteena_b (1'b1),
|
||||||
|
.clocken0 (1'b1),
|
||||||
|
.clocken1 (1'b1),
|
||||||
|
.clocken2 (1'b1),
|
||||||
|
.clocken3 (1'b1),
|
||||||
|
.data_b ({32{1'b1}}),
|
||||||
|
.eccstatus (),
|
||||||
|
.q_a (),
|
||||||
|
.rden_a (1'b1),
|
||||||
|
.wren_b (1'b0));
|
||||||
|
defparam
|
||||||
|
lumacode_pal_ram.address_aclr_b = "NONE",
|
||||||
|
lumacode_pal_ram.address_reg_b = "CLOCK1",
|
||||||
|
lumacode_pal_ram.clock_enable_input_a = "BYPASS",
|
||||||
|
lumacode_pal_ram.clock_enable_input_b = "BYPASS",
|
||||||
|
lumacode_pal_ram.clock_enable_output_b = "BYPASS",
|
||||||
|
lumacode_pal_ram.intended_device_family = "Cyclone IV E",
|
||||||
|
lumacode_pal_ram.lpm_type = "altsyncram",
|
||||||
|
lumacode_pal_ram.numwords_a = 512,
|
||||||
|
lumacode_pal_ram.numwords_b = 512,
|
||||||
|
lumacode_pal_ram.operation_mode = "DUAL_PORT",
|
||||||
|
lumacode_pal_ram.outdata_aclr_b = "NONE",
|
||||||
|
lumacode_pal_ram.outdata_reg_b = "UNREGISTERED",
|
||||||
|
lumacode_pal_ram.power_up_uninitialized = "FALSE",
|
||||||
|
lumacode_pal_ram.rdcontrol_reg_b = "CLOCK1",
|
||||||
|
lumacode_pal_ram.widthad_a = 9,
|
||||||
|
lumacode_pal_ram.widthad_b = 9,
|
||||||
|
lumacode_pal_ram.width_a = 32,
|
||||||
|
lumacode_pal_ram.width_b = 32,
|
||||||
|
lumacode_pal_ram.width_byteena_a = 1;
|
||||||
|
|
||||||
|
|
||||||
genvar i;
|
genvar i;
|
||||||
generate
|
generate
|
||||||
for (i=HV_IN_CONFIG_REGNUM; i <= SL_CONFIG3_REGNUM; i++) begin : gen_reg
|
for (i=HV_IN_CONFIG_REGNUM; i <= SL_CONFIG3_REGNUM; i++) begin : gen_reg
|
||||||
|
|||||||
10
ossc.cof
10
ossc.cof
@ -10,9 +10,15 @@
|
|||||||
<user_name>Page_0</user_name>
|
<user_name>Page_0</user_name>
|
||||||
<page_flags>1</page_flags>
|
<page_flags>1</page_flags>
|
||||||
<bit0>
|
<bit0>
|
||||||
<sof_filename>output_files/ossc.sof<compress_bitstream>1</compress_bitstream></sof_filename>
|
<sof_filename>output_files/ossc.sof<compress_bitstream>1</compress_bitstream></sof_filename>
|
||||||
</bit0>
|
</bit0>
|
||||||
</sof_data>
|
</sof_data>
|
||||||
|
<hex_block>
|
||||||
|
<hex_filename>software/sys_controller/mem_init/flash.hex</hex_filename>
|
||||||
|
<hex_addressing>relative</hex_addressing>
|
||||||
|
<hex_offset>327680</hex_offset>
|
||||||
|
<hex_little_endian>0</hex_little_endian>
|
||||||
|
</hex_block>
|
||||||
<version>10</version>
|
<version>10</version>
|
||||||
<create_cvp_file>0</create_cvp_file>
|
<create_cvp_file>0</create_cvp_file>
|
||||||
<create_hps_iocsr>0</create_hps_iocsr>
|
<create_hps_iocsr>0</create_hps_iocsr>
|
||||||
@ -22,7 +28,7 @@
|
|||||||
<map_file>0</map_file>
|
<map_file>0</map_file>
|
||||||
</options>
|
</options>
|
||||||
<advanced_options>
|
<advanced_options>
|
||||||
<ignore_epcs_id_check>0</ignore_epcs_id_check>
|
<ignore_epcs_id_check>1</ignore_epcs_id_check>
|
||||||
<ignore_condone_check>2</ignore_condone_check>
|
<ignore_condone_check>2</ignore_condone_check>
|
||||||
<plc_adjustment>0</plc_adjustment>
|
<plc_adjustment>0</plc_adjustment>
|
||||||
<post_chain_bitstream_pad_bytes>-1</post_chain_bitstream_pad_bytes>
|
<post_chain_bitstream_pad_bytes>-1</post_chain_bitstream_pad_bytes>
|
||||||
|
|||||||
22
ossc.qsf
22
ossc.qsf
@ -41,7 +41,7 @@ set_global_assignment -name DEVICE EP4CE15E22C8
|
|||||||
set_global_assignment -name TOP_LEVEL_ENTITY ossc
|
set_global_assignment -name TOP_LEVEL_ENTITY ossc
|
||||||
set_global_assignment -name ORIGINAL_QUARTUS_VERSION 13.1
|
set_global_assignment -name ORIGINAL_QUARTUS_VERSION 13.1
|
||||||
set_global_assignment -name PROJECT_CREATION_TIME_DATE "17:27:03 MAY 17, 2014"
|
set_global_assignment -name PROJECT_CREATION_TIME_DATE "17:27:03 MAY 17, 2014"
|
||||||
set_global_assignment -name LAST_QUARTUS_VERSION "23.1std.1 Lite Edition"
|
set_global_assignment -name LAST_QUARTUS_VERSION "24.1std.0 Lite Edition"
|
||||||
set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files
|
set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files
|
||||||
set_global_assignment -name MIN_CORE_JUNCTION_TEMP 0
|
set_global_assignment -name MIN_CORE_JUNCTION_TEMP 0
|
||||||
set_global_assignment -name MAX_CORE_JUNCTION_TEMP 85
|
set_global_assignment -name MAX_CORE_JUNCTION_TEMP 85
|
||||||
@ -172,9 +172,8 @@ set_global_assignment -name OUTPUT_IO_TIMING_NEAR_END_VMEAS "HALF VCCIO" -rise
|
|||||||
set_global_assignment -name OUTPUT_IO_TIMING_NEAR_END_VMEAS "HALF VCCIO" -fall
|
set_global_assignment -name OUTPUT_IO_TIMING_NEAR_END_VMEAS "HALF VCCIO" -fall
|
||||||
set_global_assignment -name OUTPUT_IO_TIMING_FAR_END_VMEAS "HALF SIGNAL SWING" -rise
|
set_global_assignment -name OUTPUT_IO_TIMING_FAR_END_VMEAS "HALF SIGNAL SWING" -rise
|
||||||
set_global_assignment -name OUTPUT_IO_TIMING_FAR_END_VMEAS "HALF SIGNAL SWING" -fall
|
set_global_assignment -name OUTPUT_IO_TIMING_FAR_END_VMEAS "HALF SIGNAL SWING" -fall
|
||||||
|
set_global_assignment -name INI_VARS "FIOMGR_ENABLE_SPI_TIMING=ON"
|
||||||
|
|
||||||
|
|
||||||
set_global_assignment -name SEARCH_PATH rtl
|
|
||||||
set_global_assignment -name CYCLONEIII_CONFIGURATION_DEVICE EPCS16
|
set_global_assignment -name CYCLONEIII_CONFIGURATION_DEVICE EPCS16
|
||||||
|
|
||||||
set_global_assignment -name VERILOG_INPUT_VERSION SYSTEMVERILOG_2005
|
set_global_assignment -name VERILOG_INPUT_VERSION SYSTEMVERILOG_2005
|
||||||
@ -231,6 +230,12 @@ set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_GD[7]
|
|||||||
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_RD[1]
|
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_RD[1]
|
||||||
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_RD[5]
|
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_RD[5]
|
||||||
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_RD[7]
|
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_RD[7]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set_global_assignment -name VERILOG_FILE rtl/videogen.v
|
set_global_assignment -name VERILOG_FILE rtl/videogen.v
|
||||||
set_global_assignment -name VERILOG_FILE rtl/ir_rcv.v
|
set_global_assignment -name VERILOG_FILE rtl/ir_rcv.v
|
||||||
set_global_assignment -name VERILOG_FILE rtl/ossc.v
|
set_global_assignment -name VERILOG_FILE rtl/ossc.v
|
||||||
@ -249,10 +254,9 @@ set_global_assignment -name SDC_FILE ossc.sdc
|
|||||||
set_global_assignment -name CDF_FILE output_files/Chain1.cdf
|
set_global_assignment -name CDF_FILE output_files/Chain1.cdf
|
||||||
set_global_assignment -name SIGNALTAP_FILE output_files/ossc_la.stp
|
set_global_assignment -name SIGNALTAP_FILE output_files/ossc_la.stp
|
||||||
set_global_assignment -name QIP_FILE rtl/char_array.qip
|
set_global_assignment -name QIP_FILE rtl/char_array.qip
|
||||||
|
set_global_assignment -name SEARCH_PATH rtl
|
||||||
|
set_global_assignment -name SEARCH_PATH software/sys_controller/mem_init/
|
||||||
|
set_global_assignment -name SEARCH_PATH ip/ibex_qsys/rtl_extra
|
||||||
|
set_global_assignment -name VERILOG_MACRO "SYNTHESIS=<None>"
|
||||||
|
set_global_assignment -name STRATIXIII_UPDATE_MODE REMOTE
|
||||||
|
|
||||||
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
|
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
|
||||||
16
ossc.sdc
16
ossc.sdc
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
create_clock -period 27MHz -name clk27 [get_ports clk27]
|
create_clock -period 27MHz -name clk27 [get_ports clk27]
|
||||||
|
|
||||||
set_input_delay -clock clk27 0 [get_ports {sda scl SD_CMD SD_DAT* *ALTERA_DATA0}]
|
set_input_delay -clock clk27 0 [get_ports {sda scl SD_CMD SD_DAT*}]
|
||||||
set_false_path -from [get_ports {btn* cfg* ir_rx HDMI_TX_INT_N LED_R}]
|
set_false_path -from [get_ports {btn* cfg* ir_rx HDMI_TX_INT_N LED_R}]
|
||||||
set_false_path -to {sys:sys_inst|sys_pio_1:pio_1|readdata*}
|
set_false_path -to {sys:sys_inst|sys_pio_1:pio_1|readdata*}
|
||||||
|
|
||||||
|
create_generated_clock -name flash_clk -divide_by 2 -source clk27 [get_pins sys:sys_inst|sys_intel_generic_serial_flash_interface_top_0:intel_generic_serial_flash_interface_top_0|sys_intel_generic_serial_flash_interface_top_0_qspi_inf_inst:qspi_inf_inst|flash_clk_reg|q]
|
||||||
|
create_generated_clock -name flash_clk_out -master_clock flash_clk -source [get_pins sys:sys_inst|sys_intel_generic_serial_flash_interface_top_0:intel_generic_serial_flash_interface_top_0|sys_intel_generic_serial_flash_interface_top_0_qspi_inf_inst:qspi_inf_inst|flash_clk_reg|q] -multiply_by 1 [get_ports *ALTERA_DCLK]
|
||||||
|
|
||||||
### Scanconverter clock constraints ###
|
### Scanconverter clock constraints ###
|
||||||
|
|
||||||
@ -52,8 +54,16 @@ foreach_in_collection c [get_clocks pclk_*_out] {
|
|||||||
}
|
}
|
||||||
set_false_path -to [remove_from_collection [all_outputs] $critoutputs_hdmi]
|
set_false_path -to [remove_from_collection [all_outputs] $critoutputs_hdmi]
|
||||||
|
|
||||||
# Lumacode
|
# Lumacode (constrained to max. 60MHz sampling)
|
||||||
set_false_path -from [get_clocks pclk_tvp_high] -through [get_cells tvp7002_frontend:u_tvp_frontend|lc_code*]
|
set_max_delay 16.6 -from [get_registers sys:sys_inst|sc_config_top:sc_config_0|altsyncram:lumacode_pal_ram|*]
|
||||||
|
|
||||||
|
# Flash controller (delays from N25Q128A datasheet)
|
||||||
|
set_input_delay -clock flash_clk_out -clock_fall 5 [get_ports *ALTERA_DATA0]
|
||||||
|
set_output_delay -clock flash_clk_out 4 [get_ports *ALTERA_SCE]
|
||||||
|
set_output_delay -clock flash_clk_out 2 [get_ports *ALTERA_SDO]
|
||||||
|
|
||||||
|
# Latency tester
|
||||||
|
set_false_path -from [get_registers lat_tester:lt0|mode_synced*]
|
||||||
|
|
||||||
|
|
||||||
### CPU/scanconverter clock relations ###
|
### CPU/scanconverter clock relations ###
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
set_global_assignment -name IP_TOOL_NAME "RAM: 2-PORT"
|
set_global_assignment -name IP_TOOL_NAME "RAM: 2-PORT"
|
||||||
set_global_assignment -name IP_TOOL_VERSION "23.1"
|
set_global_assignment -name IP_TOOL_VERSION "24.1"
|
||||||
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
||||||
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "char_array.v"]
|
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "char_array.v"]
|
||||||
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "char_array_inst.v"]
|
|
||||||
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "char_array_bb.v"]
|
|
||||||
|
|||||||
@ -14,24 +14,24 @@
|
|||||||
// ************************************************************
|
// ************************************************************
|
||||||
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
||||||
//
|
//
|
||||||
// 23.1std.1 Build 993 05/14/2024 SC Lite Edition
|
// 24.1std.0 Build 1077 03/04/2025 SC Lite Edition
|
||||||
// ************************************************************
|
// ************************************************************
|
||||||
|
|
||||||
|
|
||||||
//Copyright (C) 2024 Intel Corporation. All rights reserved.
|
//Copyright (C) 2025 Altera Corporation. All rights reserved.
|
||||||
//Your use of Intel Corporation's design tools, logic functions
|
//Your use of Altera Corporation's design tools, logic functions
|
||||||
//and other software and tools, and any partner logic
|
//and other software and tools, and any partner logic
|
||||||
//functions, and any output files from any of the foregoing
|
//functions, and any output files from any of the foregoing
|
||||||
//(including device programming or simulation files), and any
|
//(including device programming or simulation files), and any
|
||||||
//associated documentation or information are expressly subject
|
//associated documentation or information are expressly subject
|
||||||
//to the terms and conditions of the Intel Program License
|
//to the terms and conditions of the Altera Program License
|
||||||
//Subscription Agreement, the Intel Quartus Prime License Agreement,
|
//Subscription Agreement, the Altera Quartus Prime License Agreement,
|
||||||
//the Intel FPGA IP License Agreement, or other applicable license
|
//the Altera IP License Agreement, or other applicable license
|
||||||
//agreement, including, without limitation, that your use is for
|
//agreement, including, without limitation, that your use is for
|
||||||
//the sole purpose of programming logic devices manufactured by
|
//the sole purpose of programming logic devices manufactured by
|
||||||
//Intel and sold by Intel or its authorized distributors. Please
|
//Altera and sold by Altera or its authorized distributors. Please
|
||||||
//refer to the applicable agreement for further details, at
|
//refer to the Altera Software License Subscription Agreements
|
||||||
//https://fpgasoftware.intel.com/eula.
|
//on the Quartus Prime software download page.
|
||||||
|
|
||||||
|
|
||||||
// synopsys translate_off
|
// synopsys translate_off
|
||||||
@ -218,6 +218,6 @@ endmodule
|
|||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array.inc FALSE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array.inc FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array.cmp FALSE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array.cmp FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array.bsf FALSE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array.bsf FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array_inst.v TRUE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array_inst.v FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array_bb.v TRUE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_array_bb.v FALSE
|
||||||
// Retrieval info: LIB_FILE: altera_mf
|
// Retrieval info: LIB_FILE: altera_mf
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
set_global_assignment -name IP_TOOL_NAME "ROM: 1-PORT"
|
set_global_assignment -name IP_TOOL_NAME "ROM: 1-PORT"
|
||||||
set_global_assignment -name IP_TOOL_VERSION "23.1"
|
set_global_assignment -name IP_TOOL_VERSION "24.1"
|
||||||
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
||||||
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "char_rom.v"]
|
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "char_rom.v"]
|
||||||
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "char_rom_inst.v"]
|
|
||||||
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "char_rom_bb.v"]
|
|
||||||
|
|||||||
@ -14,24 +14,24 @@
|
|||||||
// ************************************************************
|
// ************************************************************
|
||||||
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
||||||
//
|
//
|
||||||
// 23.1std.1 Build 993 05/14/2024 SC Lite Edition
|
// 24.1std.0 Build 1077 03/04/2025 SC Lite Edition
|
||||||
// ************************************************************
|
// ************************************************************
|
||||||
|
|
||||||
|
|
||||||
//Copyright (C) 2024 Intel Corporation. All rights reserved.
|
//Copyright (C) 2025 Altera Corporation. All rights reserved.
|
||||||
//Your use of Intel Corporation's design tools, logic functions
|
//Your use of Altera Corporation's design tools, logic functions
|
||||||
//and other software and tools, and any partner logic
|
//and other software and tools, and any partner logic
|
||||||
//functions, and any output files from any of the foregoing
|
//functions, and any output files from any of the foregoing
|
||||||
//(including device programming or simulation files), and any
|
//(including device programming or simulation files), and any
|
||||||
//associated documentation or information are expressly subject
|
//associated documentation or information are expressly subject
|
||||||
//to the terms and conditions of the Intel Program License
|
//to the terms and conditions of the Altera Program License
|
||||||
//Subscription Agreement, the Intel Quartus Prime License Agreement,
|
//Subscription Agreement, the Altera Quartus Prime License Agreement,
|
||||||
//the Intel FPGA IP License Agreement, or other applicable license
|
//the Altera IP License Agreement, or other applicable license
|
||||||
//agreement, including, without limitation, that your use is for
|
//agreement, including, without limitation, that your use is for
|
||||||
//the sole purpose of programming logic devices manufactured by
|
//the sole purpose of programming logic devices manufactured by
|
||||||
//Intel and sold by Intel or its authorized distributors. Please
|
//Altera and sold by Altera or its authorized distributors. Please
|
||||||
//refer to the applicable agreement for further details, at
|
//refer to the Altera Software License Subscription Agreements
|
||||||
//https://fpgasoftware.intel.com/eula.
|
//on the Quartus Prime software download page.
|
||||||
|
|
||||||
|
|
||||||
// synopsys translate_off
|
// synopsys translate_off
|
||||||
@ -160,6 +160,6 @@ endmodule
|
|||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom.inc FALSE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom.inc FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom.cmp FALSE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom.cmp FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom.bsf FALSE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom.bsf FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom_inst.v TRUE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom_inst.v FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom_bb.v TRUE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL char_rom_bb.v FALSE
|
||||||
// Retrieval info: LIB_FILE: altera_mf
|
// Retrieval info: LIB_FILE: altera_mf
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
set_global_assignment -name IP_TOOL_NAME "RAM: 2-PORT"
|
set_global_assignment -name IP_TOOL_NAME "RAM: 2-PORT"
|
||||||
set_global_assignment -name IP_TOOL_VERSION "23.1"
|
set_global_assignment -name IP_TOOL_VERSION "24.1"
|
||||||
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
||||||
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "linebuf.v"]
|
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "linebuf.v"]
|
||||||
|
|||||||
@ -14,24 +14,24 @@
|
|||||||
// ************************************************************
|
// ************************************************************
|
||||||
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
||||||
//
|
//
|
||||||
// 23.1std.1 Build 993 05/14/2024 SC Lite Edition
|
// 24.1std.0 Build 1077 03/04/2025 SC Lite Edition
|
||||||
// ************************************************************
|
// ************************************************************
|
||||||
|
|
||||||
|
|
||||||
//Copyright (C) 2024 Intel Corporation. All rights reserved.
|
//Copyright (C) 2025 Altera Corporation. All rights reserved.
|
||||||
//Your use of Intel Corporation's design tools, logic functions
|
//Your use of Altera Corporation's design tools, logic functions
|
||||||
//and other software and tools, and any partner logic
|
//and other software and tools, and any partner logic
|
||||||
//functions, and any output files from any of the foregoing
|
//functions, and any output files from any of the foregoing
|
||||||
//(including device programming or simulation files), and any
|
//(including device programming or simulation files), and any
|
||||||
//associated documentation or information are expressly subject
|
//associated documentation or information are expressly subject
|
||||||
//to the terms and conditions of the Intel Program License
|
//to the terms and conditions of the Altera Program License
|
||||||
//Subscription Agreement, the Intel Quartus Prime License Agreement,
|
//Subscription Agreement, the Altera Quartus Prime License Agreement,
|
||||||
//the Intel FPGA IP License Agreement, or other applicable license
|
//the Altera IP License Agreement, or other applicable license
|
||||||
//agreement, including, without limitation, that your use is for
|
//agreement, including, without limitation, that your use is for
|
||||||
//the sole purpose of programming logic devices manufactured by
|
//the sole purpose of programming logic devices manufactured by
|
||||||
//Intel and sold by Intel or its authorized distributors. Please
|
//Altera and sold by Altera or its authorized distributors. Please
|
||||||
//refer to the applicable agreement for further details, at
|
//refer to the Altera Software License Subscription Agreements
|
||||||
//https://fpgasoftware.intel.com/eula.
|
//on the Quartus Prime software download page.
|
||||||
|
|
||||||
|
|
||||||
// synopsys translate_off
|
// synopsys translate_off
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
set_global_assignment -name IP_TOOL_NAME "LPM_MULT"
|
set_global_assignment -name IP_TOOL_NAME "LPM_MULT"
|
||||||
set_global_assignment -name IP_TOOL_VERSION "23.1"
|
set_global_assignment -name IP_TOOL_VERSION "24.1"
|
||||||
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
||||||
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "lpm_mult_8x5_9.v"]
|
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "lpm_mult_8x5_9.v"]
|
||||||
|
|||||||
@ -14,24 +14,24 @@
|
|||||||
// ************************************************************
|
// ************************************************************
|
||||||
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
||||||
//
|
//
|
||||||
// 23.1std.1 Build 993 05/14/2024 SC Lite Edition
|
// 24.1std.0 Build 1077 03/04/2025 SC Lite Edition
|
||||||
// ************************************************************
|
// ************************************************************
|
||||||
|
|
||||||
|
|
||||||
//Copyright (C) 2024 Intel Corporation. All rights reserved.
|
//Copyright (C) 2025 Altera Corporation. All rights reserved.
|
||||||
//Your use of Intel Corporation's design tools, logic functions
|
//Your use of Altera Corporation's design tools, logic functions
|
||||||
//and other software and tools, and any partner logic
|
//and other software and tools, and any partner logic
|
||||||
//functions, and any output files from any of the foregoing
|
//functions, and any output files from any of the foregoing
|
||||||
//(including device programming or simulation files), and any
|
//(including device programming or simulation files), and any
|
||||||
//associated documentation or information are expressly subject
|
//associated documentation or information are expressly subject
|
||||||
//to the terms and conditions of the Intel Program License
|
//to the terms and conditions of the Altera Program License
|
||||||
//Subscription Agreement, the Intel Quartus Prime License Agreement,
|
//Subscription Agreement, the Altera Quartus Prime License Agreement,
|
||||||
//the Intel FPGA IP License Agreement, or other applicable license
|
//the Altera IP License Agreement, or other applicable license
|
||||||
//agreement, including, without limitation, that your use is for
|
//agreement, including, without limitation, that your use is for
|
||||||
//the sole purpose of programming logic devices manufactured by
|
//the sole purpose of programming logic devices manufactured by
|
||||||
//Intel and sold by Intel or its authorized distributors. Please
|
//Altera and sold by Altera or its authorized distributors. Please
|
||||||
//refer to the applicable agreement for further details, at
|
//refer to the Altera Software License Subscription Agreements
|
||||||
//https://fpgasoftware.intel.com/eula.
|
//on the Quartus Prime software download page.
|
||||||
|
|
||||||
|
|
||||||
// synopsys translate_off
|
// synopsys translate_off
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
set_global_assignment -name IP_TOOL_NAME "LPM_MULT"
|
set_global_assignment -name IP_TOOL_NAME "LPM_MULT"
|
||||||
set_global_assignment -name IP_TOOL_VERSION "23.1"
|
set_global_assignment -name IP_TOOL_VERSION "24.1"
|
||||||
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
||||||
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "lpm_mult_sl.v"]
|
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "lpm_mult_sl.v"]
|
||||||
|
|||||||
@ -14,24 +14,24 @@
|
|||||||
// ************************************************************
|
// ************************************************************
|
||||||
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
||||||
//
|
//
|
||||||
// 23.1std.1 Build 993 05/14/2024 SC Lite Edition
|
// 24.1std.0 Build 1077 03/04/2025 SC Lite Edition
|
||||||
// ************************************************************
|
// ************************************************************
|
||||||
|
|
||||||
|
|
||||||
//Copyright (C) 2024 Intel Corporation. All rights reserved.
|
//Copyright (C) 2025 Altera Corporation. All rights reserved.
|
||||||
//Your use of Intel Corporation's design tools, logic functions
|
//Your use of Altera Corporation's design tools, logic functions
|
||||||
//and other software and tools, and any partner logic
|
//and other software and tools, and any partner logic
|
||||||
//functions, and any output files from any of the foregoing
|
//functions, and any output files from any of the foregoing
|
||||||
//(including device programming or simulation files), and any
|
//(including device programming or simulation files), and any
|
||||||
//associated documentation or information are expressly subject
|
//associated documentation or information are expressly subject
|
||||||
//to the terms and conditions of the Intel Program License
|
//to the terms and conditions of the Altera Program License
|
||||||
//Subscription Agreement, the Intel Quartus Prime License Agreement,
|
//Subscription Agreement, the Altera Quartus Prime License Agreement,
|
||||||
//the Intel FPGA IP License Agreement, or other applicable license
|
//the Altera IP License Agreement, or other applicable license
|
||||||
//agreement, including, without limitation, that your use is for
|
//agreement, including, without limitation, that your use is for
|
||||||
//the sole purpose of programming logic devices manufactured by
|
//the sole purpose of programming logic devices manufactured by
|
||||||
//Intel and sold by Intel or its authorized distributors. Please
|
//Altera and sold by Altera or its authorized distributors. Please
|
||||||
//refer to the applicable agreement for further details, at
|
//refer to the Altera Software License Subscription Agreements
|
||||||
//https://fpgasoftware.intel.com/eula.
|
//on the Quartus Prime software download page.
|
||||||
|
|
||||||
|
|
||||||
// synopsys translate_off
|
// synopsys translate_off
|
||||||
|
|||||||
80
rtl/ossc.v
80
rtl/ossc.v
@ -95,8 +95,9 @@ wire pclk_out = PCLK_sc;
|
|||||||
|
|
||||||
reg [7:0] po_reset_ctr = 0;
|
reg [7:0] po_reset_ctr = 0;
|
||||||
reg po_reset_n = 1'b0;
|
reg po_reset_n = 1'b0;
|
||||||
wire jtagm_reset_req;
|
wire jtagm_reset_req, ndmreset_req;
|
||||||
wire sys_reset_n = (po_reset_n & ~jtagm_reset_req);
|
reg ndmreset_ack, ndmreset_pulse;
|
||||||
|
wire sys_reset_n = (po_reset_n & ~jtagm_reset_req & ~ndmreset_pulse);
|
||||||
|
|
||||||
reg [7:0] TVP_R, TVP_G, TVP_B;
|
reg [7:0] TVP_R, TVP_G, TVP_B;
|
||||||
reg TVP_HS, TVP_VS, TVP_FID;
|
reg TVP_HS, TVP_VS, TVP_FID;
|
||||||
@ -128,15 +129,21 @@ wire [11:0] lt_stb_result;
|
|||||||
wire lt_trig_waiting;
|
wire lt_trig_waiting;
|
||||||
wire lt_finished;
|
wire lt_finished;
|
||||||
|
|
||||||
reg remove_event_prev;
|
wire [31:0] lumacode_data;
|
||||||
|
wire [8:0] lumacode_addr;
|
||||||
|
wire lumacode_rden;
|
||||||
|
|
||||||
|
reg remote_event_prev;
|
||||||
reg [14:0] to_ctr, to_ctr_ms;
|
reg [14:0] to_ctr, to_ctr_ms;
|
||||||
wire lcd_bl_timeout;
|
wire lcd_bl_timeout;
|
||||||
|
|
||||||
wire [1:0] osd_color;
|
wire [2:0] osd_color;
|
||||||
wire osd_enable_pre;
|
wire osd_enable_pre;
|
||||||
wire osd_enable = osd_enable_pre & ~lt_active;
|
wire osd_enable = osd_enable_pre & ~lt_active;
|
||||||
wire [10:0] xpos_sc;
|
wire [11:0] xpos_sc;
|
||||||
wire [10:0] ypos_sc;
|
wire [10:0] ypos_sc;
|
||||||
|
wire [3:0] x_ctr_shmask, y_ctr_shmask;
|
||||||
|
wire [10:0] shmask_data;
|
||||||
|
|
||||||
wire resync_indicator = (warn_pll_lock_lost != 0) | (resync_led_ctr != 0);
|
wire resync_indicator = (warn_pll_lock_lost != 0) | (resync_led_ctr != 0);
|
||||||
wire LED_R_i = lt_active ? lt_trig_waiting : resync_indicator;
|
wire LED_R_i = lt_active ? lt_trig_waiting : resync_indicator;
|
||||||
@ -194,6 +201,7 @@ tvp7002_frontend u_tvp_frontend (
|
|||||||
.hv_in_config2(hv_in_config2),
|
.hv_in_config2(hv_in_config2),
|
||||||
.hv_in_config3(hv_in_config3),
|
.hv_in_config3(hv_in_config3),
|
||||||
.misc_config(misc_config),
|
.misc_config(misc_config),
|
||||||
|
.lumacode_data(lumacode_data),
|
||||||
.R_o(TVP_R_post),
|
.R_o(TVP_R_post),
|
||||||
.G_o(TVP_G_post),
|
.G_o(TVP_G_post),
|
||||||
.B_o(TVP_B_post),
|
.B_o(TVP_B_post),
|
||||||
@ -210,7 +218,9 @@ tvp7002_frontend u_tvp_frontend (
|
|||||||
.sof_scaler(TVP_sof_scaler),
|
.sof_scaler(TVP_sof_scaler),
|
||||||
.pcnt_field(TVP_fe_pcnt_field),
|
.pcnt_field(TVP_fe_pcnt_field),
|
||||||
.hsync_width(TVP_hsync_width),
|
.hsync_width(TVP_hsync_width),
|
||||||
.sync_active(TVP_sync_active)
|
.sync_active(TVP_sync_active),
|
||||||
|
.lumacode_addr(lumacode_addr),
|
||||||
|
.lumacode_rden(lumacode_rden)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Insert synchronizers to async inputs (synchronize to CPU clock)
|
// Insert synchronizers to async inputs (synchronize to CPU clock)
|
||||||
@ -240,6 +250,13 @@ begin
|
|||||||
po_reset_ctr <= po_reset_ctr + 1'b1;
|
po_reset_ctr <= po_reset_ctr + 1'b1;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
// ndmreset pulse & ack for RISC-V DM
|
||||||
|
always @(posedge clk27)
|
||||||
|
begin
|
||||||
|
ndmreset_pulse <= !ndmreset_ack & ndmreset_req;
|
||||||
|
ndmreset_ack <= ndmreset_req;
|
||||||
|
end
|
||||||
|
|
||||||
// Sync vsync flag to CPU clock
|
// Sync vsync flag to CPU clock
|
||||||
always @(posedge clk27) begin
|
always @(posedge clk27) begin
|
||||||
{vsync_flag_sync1_reg, vsync_flag_sync2_reg} <= {~VSYNC_sc, vsync_flag_sync1_reg};
|
{vsync_flag_sync1_reg, vsync_flag_sync2_reg} <= {~VSYNC_sc, vsync_flag_sync1_reg};
|
||||||
@ -248,7 +265,7 @@ end
|
|||||||
// LCD backlight timeout counters
|
// LCD backlight timeout counters
|
||||||
always @(posedge clk27)
|
always @(posedge clk27)
|
||||||
begin
|
begin
|
||||||
if (remote_event != remove_event_prev) begin
|
if (remote_event != remote_event_prev) begin
|
||||||
to_ctr <= 15'd0;
|
to_ctr <= 15'd0;
|
||||||
to_ctr_ms <= 15'd0;
|
to_ctr_ms <= 15'd0;
|
||||||
end else begin
|
end else begin
|
||||||
@ -268,7 +285,7 @@ begin
|
|||||||
2'b11: lcd_bl_timeout <= (to_ctr_ms >= 30000); //30s
|
2'b11: lcd_bl_timeout <= (to_ctr_ms >= 30000); //30s
|
||||||
endcase
|
endcase
|
||||||
|
|
||||||
remove_event_prev <= remote_event;
|
remote_event_prev <= remote_event;
|
||||||
end
|
end
|
||||||
|
|
||||||
// Generate a warning signal from sync lock loss
|
// Generate a warning signal from sync lock loss
|
||||||
@ -308,15 +325,7 @@ end
|
|||||||
// Output registers
|
// Output registers
|
||||||
always @(posedge pclk_out) begin
|
always @(posedge pclk_out) begin
|
||||||
if (osd_enable) begin
|
if (osd_enable) begin
|
||||||
if (osd_color == 2'h0) begin
|
{HDMI_TX_RD, HDMI_TX_GD, HDMI_TX_BD} <= {{8{osd_color[2]}}, {8{osd_color[1]}}, {8{osd_color[0]}}};
|
||||||
{HDMI_TX_RD, HDMI_TX_GD, HDMI_TX_BD} <= 24'h000000;
|
|
||||||
end else if (osd_color == 2'h1) begin
|
|
||||||
{HDMI_TX_RD, HDMI_TX_GD, HDMI_TX_BD} <= 24'h0000ff;
|
|
||||||
end else if (osd_color == 2'h2) begin
|
|
||||||
{HDMI_TX_RD, HDMI_TX_GD, HDMI_TX_BD} <= 24'hffff00;
|
|
||||||
end else begin
|
|
||||||
{HDMI_TX_RD, HDMI_TX_GD, HDMI_TX_BD} <= 24'hffffff;
|
|
||||||
end
|
|
||||||
end else begin
|
end else begin
|
||||||
{HDMI_TX_RD, HDMI_TX_GD, HDMI_TX_BD} <= {R_sc, G_sc, B_sc};
|
{HDMI_TX_RD, HDMI_TX_GD, HDMI_TX_BD} <= {R_sc, G_sc, B_sc};
|
||||||
end
|
end
|
||||||
@ -364,11 +373,12 @@ defparam
|
|||||||
|
|
||||||
sys sys_inst(
|
sys sys_inst(
|
||||||
.clk_clk (clk27),
|
.clk_clk (clk27),
|
||||||
.reset_reset_n (sys_reset_n),
|
.reset_sys_reset_n (sys_reset_n),
|
||||||
.pulpino_0_config_testmode_i (1'b0),
|
.reset_po_reset_n (po_reset_n),
|
||||||
.pulpino_0_config_fetch_enable_i (1'b1),
|
.ibex_0_ndm_ndmreset_o (ndmreset_req),
|
||||||
.pulpino_0_config_clock_gating_i (1'b0),
|
.ibex_0_ndm_ndmreset_ack_i (ndmreset_ack),
|
||||||
.pulpino_0_config_boot_addr_i (32'h00010000),
|
.ibex_0_config_boot_addr_i (32'h02050000),
|
||||||
|
.ibex_0_config_core_sleep_o (),
|
||||||
.master_0_master_reset_reset (jtagm_reset_req),
|
.master_0_master_reset_reset (jtagm_reset_req),
|
||||||
.i2c_opencores_0_export_scl_pad_io (scl),
|
.i2c_opencores_0_export_scl_pad_io (scl),
|
||||||
.i2c_opencores_0_export_sda_pad_io (sda),
|
.i2c_opencores_0_export_sda_pad_io (sda),
|
||||||
@ -380,7 +390,7 @@ sys sys_inst(
|
|||||||
.pio_1_controls_in_export (controls),
|
.pio_1_controls_in_export (controls),
|
||||||
.sc_config_0_sc_if_fe_status_i ({19'h0, TVP_sync_active, TVP_fe_interlace, TVP_fe_vtotal}),
|
.sc_config_0_sc_if_fe_status_i ({19'h0, TVP_sync_active, TVP_fe_interlace, TVP_fe_vtotal}),
|
||||||
.sc_config_0_sc_if_fe_status2_i ({4'h0, TVP_hsync_width, TVP_fe_pcnt_field}),
|
.sc_config_0_sc_if_fe_status2_i ({4'h0, TVP_hsync_width, TVP_fe_pcnt_field}),
|
||||||
.sc_config_0_sc_if_lt_status_i (32'h00000000),
|
.sc_config_0_sc_if_lt_status_i ({lt_finished, 3'h0, lt_stb_result, lt_lat_result}),
|
||||||
.sc_config_0_sc_if_hv_in_config_o (hv_in_config),
|
.sc_config_0_sc_if_hv_in_config_o (hv_in_config),
|
||||||
.sc_config_0_sc_if_hv_in_config2_o (hv_in_config2),
|
.sc_config_0_sc_if_hv_in_config2_o (hv_in_config2),
|
||||||
.sc_config_0_sc_if_hv_in_config3_o (hv_in_config3),
|
.sc_config_0_sc_if_hv_in_config3_o (hv_in_config3),
|
||||||
@ -393,6 +403,14 @@ sys sys_inst(
|
|||||||
.sc_config_0_sc_if_sl_config_o (sl_config),
|
.sc_config_0_sc_if_sl_config_o (sl_config),
|
||||||
.sc_config_0_sc_if_sl_config2_o (sl_config2),
|
.sc_config_0_sc_if_sl_config2_o (sl_config2),
|
||||||
.sc_config_0_sc_if_sl_config3_o (sl_config3),
|
.sc_config_0_sc_if_sl_config3_o (sl_config3),
|
||||||
|
.sc_config_0_shmask_if_vclk (PCLK_sc),
|
||||||
|
.sc_config_0_shmask_if_shmask_xpos (x_ctr_shmask),
|
||||||
|
.sc_config_0_shmask_if_shmask_ypos (y_ctr_shmask),
|
||||||
|
.sc_config_0_shmask_if_shmask_data (shmask_data),
|
||||||
|
.sc_config_0_lc_ram_if_lumacode_clk_i (TVP_PCLK_i),
|
||||||
|
.sc_config_0_lc_ram_if_lumacode_addr_i (lumacode_addr),
|
||||||
|
.sc_config_0_lc_ram_if_lumacode_rden_i (lumacode_rden),
|
||||||
|
.sc_config_0_lc_ram_if_lumacode_data_o (lumacode_data),
|
||||||
.osd_generator_0_osd_if_vclk (PCLK_sc),
|
.osd_generator_0_osd_if_vclk (PCLK_sc),
|
||||||
.osd_generator_0_osd_if_xpos (xpos_sc),
|
.osd_generator_0_osd_if_xpos (xpos_sc),
|
||||||
.osd_generator_0_osd_if_ypos (ypos_sc),
|
.osd_generator_0_osd_if_ypos (ypos_sc),
|
||||||
@ -406,12 +424,9 @@ sys sys_inst(
|
|||||||
.pll_reconfig_0_pll_reconfig_if_scandone (pll_scandone)
|
.pll_reconfig_0_pll_reconfig_if_scandone (pll_scandone)
|
||||||
);
|
);
|
||||||
|
|
||||||
// These do not work in current Quartus version (23.1) and a patch file (scripts/qsys.patch) must be used after Qsys generation instead
|
// These do not work in current Quartus version (24.1) and a patch file (scripts/qsys.patch) must be used after Qsys generation instead
|
||||||
defparam
|
defparam
|
||||||
sys_inst.epcq_controller2_0.asmi2_inst_epcq_ctrl.xip_controller.avst_fifo_inst.USE_MEMORY_BLOCKS = 0,
|
sys_inst.master_0.fifo.FIFO_DEPTH = 1024;
|
||||||
sys_inst.epcq_controller2_0.asmi2_inst_epcq_ctrl.xip_controller.avst_fifo_inst.avst_fifo.USE_MEMORY_BLOCKS = 0,
|
|
||||||
sys_inst.master_0.fifo.USE_MEMORY_BLOCKS = 0,
|
|
||||||
sys_inst.onchip_memory2_0.the_altsyncram.MAXIMUM_DEPTH = 2048;
|
|
||||||
|
|
||||||
scanconverter #(
|
scanconverter #(
|
||||||
.EMIF_ENABLE(0),
|
.EMIF_ENABLE(0),
|
||||||
@ -458,7 +473,12 @@ scanconverter #(
|
|||||||
.DE_o(DE_sc),
|
.DE_o(DE_sc),
|
||||||
.xpos_o(xpos_sc),
|
.xpos_o(xpos_sc),
|
||||||
.ypos_o(ypos_sc),
|
.ypos_o(ypos_sc),
|
||||||
|
.x_ctr_shmask(x_ctr_shmask),
|
||||||
|
.y_ctr_shmask(y_ctr_shmask),
|
||||||
|
.shmask_data(shmask_data),
|
||||||
.resync_strobe(resync_strobe_i),
|
.resync_strobe(resync_strobe_i),
|
||||||
|
.lt_active(lt_active),
|
||||||
|
.lt_mode(lt_mode_synced),
|
||||||
.emif_br_clk(1'b0),
|
.emif_br_clk(1'b0),
|
||||||
.emif_br_reset(1'b0),
|
.emif_br_reset(1'b0),
|
||||||
.emif_rd_addr(),
|
.emif_rd_addr(),
|
||||||
@ -483,7 +503,7 @@ ir_rcv ir0 (
|
|||||||
.ir_code_cnt (ir_code_cnt)
|
.ir_code_cnt (ir_code_cnt)
|
||||||
);
|
);
|
||||||
|
|
||||||
/*lat_tester lt0 (
|
lat_tester lt0 (
|
||||||
.clk27 (clk27),
|
.clk27 (clk27),
|
||||||
.pclk (PCLK_sc),
|
.pclk (PCLK_sc),
|
||||||
.active (lt_active),
|
.active (lt_active),
|
||||||
@ -497,6 +517,6 @@ ir_rcv ir0 (
|
|||||||
.stb_result (lt_stb_result),
|
.stb_result (lt_stb_result),
|
||||||
.trig_waiting (lt_trig_waiting),
|
.trig_waiting (lt_trig_waiting),
|
||||||
.finished (lt_finished)
|
.finished (lt_finished)
|
||||||
);*/
|
);
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
set_global_assignment -name IP_TOOL_NAME "ALTPLL"
|
set_global_assignment -name IP_TOOL_NAME "ALTPLL"
|
||||||
set_global_assignment -name IP_TOOL_VERSION "23.1"
|
set_global_assignment -name IP_TOOL_VERSION "24.1"
|
||||||
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone IV E}"
|
||||||
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "pll_2x.v"]
|
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "pll_2x.v"]
|
||||||
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "pll_2x.ppf"]
|
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "pll_2x.ppf"]
|
||||||
|
|||||||
21
rtl/pll_2x.v
21
rtl/pll_2x.v
@ -9,29 +9,29 @@
|
|||||||
// altpll
|
// altpll
|
||||||
//
|
//
|
||||||
// Simulation Library Files(s):
|
// Simulation Library Files(s):
|
||||||
//
|
// altera_mf
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// ************************************************************
|
// ************************************************************
|
||||||
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
||||||
//
|
//
|
||||||
// 23.1std.1 Build 993 05/14/2024 SC Lite Edition
|
// 24.1std.0 Build 1077 03/04/2025 SC Lite Edition
|
||||||
// ************************************************************
|
// ************************************************************
|
||||||
|
|
||||||
|
|
||||||
//Copyright (C) 2024 Intel Corporation. All rights reserved.
|
//Copyright (C) 2025 Altera Corporation. All rights reserved.
|
||||||
//Your use of Intel Corporation's design tools, logic functions
|
//Your use of Altera Corporation's design tools, logic functions
|
||||||
//and other software and tools, and any partner logic
|
//and other software and tools, and any partner logic
|
||||||
//functions, and any output files from any of the foregoing
|
//functions, and any output files from any of the foregoing
|
||||||
//(including device programming or simulation files), and any
|
//(including device programming or simulation files), and any
|
||||||
//associated documentation or information are expressly subject
|
//associated documentation or information are expressly subject
|
||||||
//to the terms and conditions of the Intel Program License
|
//to the terms and conditions of the Altera Program License
|
||||||
//Subscription Agreement, the Intel Quartus Prime License Agreement,
|
//Subscription Agreement, the Altera Quartus Prime License Agreement,
|
||||||
//the Intel FPGA IP License Agreement, or other applicable license
|
//the Altera IP License Agreement, or other applicable license
|
||||||
//agreement, including, without limitation, that your use is for
|
//agreement, including, without limitation, that your use is for
|
||||||
//the sole purpose of programming logic devices manufactured by
|
//the sole purpose of programming logic devices manufactured by
|
||||||
//Intel and sold by Intel or its authorized distributors. Please
|
//Altera and sold by Altera or its authorized distributors. Please
|
||||||
//refer to the applicable agreement for further details, at
|
//refer to the Altera Software License Subscription Agreements
|
||||||
//https://fpgasoftware.intel.com/eula.
|
//on the Quartus Prime software download page.
|
||||||
|
|
||||||
|
|
||||||
// synopsys translate_off
|
// synopsys translate_off
|
||||||
@ -377,4 +377,5 @@ endmodule
|
|||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL pll_2x_bb.v FALSE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL pll_2x_bb.v FALSE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL pll_2x.mif TRUE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL pll_2x.mif TRUE
|
||||||
// Retrieval info: GEN_FILE: TYPE_NORMAL pll_2x.hex TRUE
|
// Retrieval info: GEN_FILE: TYPE_NORMAL pll_2x.hex TRUE
|
||||||
|
// Retrieval info: LIB_FILE: altera_mf
|
||||||
// Retrieval info: CBX_MODULE_PREFIX: ON
|
// Retrieval info: CBX_MODULE_PREFIX: ON
|
||||||
|
|||||||
@ -17,6 +17,8 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
`include "lat_tester_includes.v"
|
||||||
|
|
||||||
module scanconverter (
|
module scanconverter (
|
||||||
input PCLK_CAP_i,
|
input PCLK_CAP_i,
|
||||||
input PCLK_OUT_i,
|
input PCLK_OUT_i,
|
||||||
@ -59,7 +61,12 @@ module scanconverter (
|
|||||||
output DE_o,
|
output DE_o,
|
||||||
output [11:0] xpos_o,
|
output [11:0] xpos_o,
|
||||||
output [10:0] ypos_o,
|
output [10:0] ypos_o,
|
||||||
|
output reg [3:0] x_ctr_shmask,
|
||||||
|
output reg [3:0] y_ctr_shmask,
|
||||||
|
input [11:0] shmask_data,
|
||||||
output reg resync_strobe,
|
output reg resync_strobe,
|
||||||
|
input lt_active,
|
||||||
|
input [1:0] lt_mode,
|
||||||
input emif_br_clk,
|
input emif_br_clk,
|
||||||
input emif_br_reset,
|
input emif_br_reset,
|
||||||
output [27:0] emif_rd_addr,
|
output [27:0] emif_rd_addr,
|
||||||
@ -147,24 +154,25 @@ wire [4:0] SL_HYBRSTR = sl_config3[29:25];
|
|||||||
|
|
||||||
wire [3:0] MISC_MASK_BR = misc_config[3:0];
|
wire [3:0] MISC_MASK_BR = misc_config[3:0];
|
||||||
wire [2:0] MISC_MASK_COLOR = misc_config[6:4];
|
wire [2:0] MISC_MASK_COLOR = misc_config[6:4];
|
||||||
wire MISC_LM_DEINT_MODE = misc_config[12];
|
wire MISC_LM_DEINT_MODE = 1'b0;
|
||||||
wire MISC_NIR_EVEN_OFFSET = misc_config[13];
|
wire MISC_NIR_EVEN_OFFSET = 1'b0;
|
||||||
wire [3:0] MISC_BFI_STR = misc_config[19:16];
|
wire [3:0] MISC_BFI_STR = 4'h0;
|
||||||
wire MISC_BFI_ENABLE = misc_config[20];
|
wire MISC_BFI_ENABLE = 1'b0;
|
||||||
wire MISC_SHMASK_ENABLE = (misc_config[22:21] != '0);
|
wire MISC_SHMASK_ENABLE = misc_config[15];
|
||||||
wire [1:0] MISC_SHMASK_ID = (misc_config[22:21] - 1'b1);
|
wire [3:0] MISC_SHMASK_IV_X = misc_config[19:16];
|
||||||
|
wire [3:0] MISC_SHMASK_IV_Y = misc_config[23:20];
|
||||||
|
wire MISC_PANASONIC_HACK = misc_config[24];
|
||||||
|
|
||||||
wire [7:0] MASK_R = MISC_MASK_COLOR[2] ? {2{MISC_MASK_BR}} : 8'h00;
|
wire [7:0] MASK_R = MISC_MASK_COLOR[2] ? {2{MISC_MASK_BR}} : 8'h00;
|
||||||
wire [7:0] MASK_G = MISC_MASK_COLOR[1] ? {2{MISC_MASK_BR}} : 8'h00;
|
wire [7:0] MASK_G = MISC_MASK_COLOR[1] ? {2{MISC_MASK_BR}} : 8'h00;
|
||||||
wire [7:0] MASK_B = MISC_MASK_COLOR[0] ? {2{MISC_MASK_BR}} : 8'h00;
|
wire [7:0] MASK_B = MISC_MASK_COLOR[0] ? {2{MISC_MASK_BR}} : 8'h00;
|
||||||
|
|
||||||
|
// Latency tester box bounds
|
||||||
|
wire [11:0] LT_BOX_X_START = (lt_mode == `LT_POS_TOPLEFT) ? 0 : ((lt_mode == `LT_POS_CENTER) ? ((H_ACTIVE/2'h2)-(H_ACTIVE/(`LT_WIDTH_DIV*2'h2))) : (H_ACTIVE-(H_ACTIVE/`LT_WIDTH_DIV)));
|
||||||
|
wire [11:0] LT_BOX_X_STOP = (lt_mode == `LT_POS_TOPLEFT) ? (H_ACTIVE/`LT_WIDTH_DIV) : ((lt_mode == `LT_POS_CENTER) ? ((H_ACTIVE/2'h2)+(H_ACTIVE/(`LT_WIDTH_DIV*2'h2))) : H_ACTIVE);
|
||||||
|
wire [11:0] LT_BOX_Y_START = (lt_mode == `LT_POS_TOPLEFT) ? 0 : ((lt_mode == `LT_POS_CENTER) ? ((V_ACTIVE/2'h2)-(V_ACTIVE/(`LT_HEIGHT_DIV*2'h2))) : (V_ACTIVE-(V_ACTIVE/`LT_HEIGHT_DIV)));
|
||||||
|
wire [11:0] LT_BOX_Y_STOP = (lt_mode == `LT_POS_TOPLEFT) ? (V_ACTIVE/`LT_HEIGHT_DIV) : ((lt_mode == `LT_POS_CENTER) ? ((V_ACTIVE/2'h2)+(V_ACTIVE/(`LT_HEIGHT_DIV*2'h2))) : V_ACTIVE);
|
||||||
|
|
||||||
/* RGB Shadow mask presets: A-Grille, TV, PVM. Data from ShadowMasks_MiSTer */
|
|
||||||
wire [1:0] shmask_iv_x[0:2] = '{2'h3, 2'h3, 2'h2};
|
|
||||||
wire [1:0] shmask_iv_y[0:2] = '{2'h0, 2'h1, 2'h3};
|
|
||||||
wire [10:0] shmask_data[0:2][0:3][0:3] = '{'{ '{11'h44c,11'h24c,11'h14c,11'h04c}, '{11'h0,11'h0,11'h0,11'h0}, '{11'h0,11'h0,11'h0,11'h0}, '{11'h0,11'h0,11'h0,11'h0}},
|
|
||||||
'{ '{11'h708,11'h44c,11'h24c,11'h14c}, '{11'h44c,11'h24c,11'h14c,11'h708}, '{11'h0,11'h0,11'h0,11'h0}, '{11'h0,11'h0,11'h0,11'h0}},
|
|
||||||
'{ '{11'h42a,11'h72a,11'h72a,11'h0}, '{11'h42a,11'h22a,11'h72a,11'h0}, '{11'h72a,11'h22a,11'h12a,11'h0}, '{11'h42a,11'h72a,11'h12a,11'h0}}};
|
|
||||||
|
|
||||||
reg frame_change_sync1_reg, frame_change_sync2_reg, frame_change_prev, frame_change_resync;
|
reg frame_change_sync1_reg, frame_change_sync2_reg, frame_change_prev, frame_change_resync;
|
||||||
wire frame_change = frame_change_sync2_reg;
|
wire frame_change = frame_change_sync2_reg;
|
||||||
@ -173,6 +181,7 @@ reg [11:0] h_cnt;
|
|||||||
reg [10:0] v_cnt;
|
reg [10:0] v_cnt;
|
||||||
reg h_avidstart, v_avidstart;
|
reg h_avidstart, v_avidstart;
|
||||||
reg src_fid, dst_fid;
|
reg src_fid, dst_fid;
|
||||||
|
wire [6:0] panasonic_adjust = (MISC_PANASONIC_HACK & (Y_RPT == 4'h1) & (v_cnt == V_SYNCLEN+V_BACKPORCH+V_ACTIVE-1)) ? 8'd128 : 7'd0;
|
||||||
|
|
||||||
reg [10:0] xpos_lb;
|
reg [10:0] xpos_lb;
|
||||||
wire [10:0] xpos_lb_start = (X_OFFSET < 10'sd0) ? 11'd0 : {1'b0, X_OFFSET};
|
wire [10:0] xpos_lb_start = (X_OFFSET < 10'sd0) ? 11'd0 : {1'b0, X_OFFSET};
|
||||||
@ -209,11 +218,10 @@ reg DE_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
|||||||
reg [11:0] xpos_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
reg [11: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 [10:0] ypos_pp[PP_PL_START:PP_PL_END] /* synthesis ramstyle = "logic" */;
|
||||||
reg mask_enable_pp[PP_MASK_END:PP_TP_START] /* synthesis ramstyle = "logic" */;
|
reg mask_enable_pp[PP_MASK_END:PP_TP_START] /* synthesis ramstyle = "logic" */;
|
||||||
|
reg lt_box_enable_pp[PP_MASK_END:PP_TP_START] /* synthesis ramstyle = "logic" */;
|
||||||
reg draw_sl_pp[(PP_SLGEN_START+1):(PP_SLGEN_END-1)] /* synthesis ramstyle = "logic" */;
|
reg draw_sl_pp[(PP_SLGEN_START+1):(PP_SLGEN_END-1)] /* synthesis ramstyle = "logic" */;
|
||||||
reg [3:0] x_ctr_sl_pp[PP_PL_START:PP_SLGEN_START] /* synthesis ramstyle = "logic" */;
|
reg [3:0] x_ctr_sl_pp[PP_PL_START:PP_SLGEN_START] /* synthesis ramstyle = "logic" */;
|
||||||
reg [2:0] y_ctr_sl_pp[PP_PL_START:PP_SLGEN_START] /* synthesis ramstyle = "logic" */;
|
reg [2:0] y_ctr_sl_pp[PP_PL_START:PP_SLGEN_START] /* synthesis ramstyle = "logic" */;
|
||||||
reg [1:0] x_ctr_shmask_pp[PP_PL_START:PP_SHMASK_START] /* synthesis ramstyle = "logic" */;
|
|
||||||
reg [1:0] y_ctr_shmask_pp[PP_PL_START:PP_SHMASK_START] /* synthesis ramstyle = "logic" */;
|
|
||||||
|
|
||||||
assign PCLK_o = PCLK_OUT_i;
|
assign PCLK_o = PCLK_OUT_i;
|
||||||
|
|
||||||
@ -361,8 +369,6 @@ linebuf_top #(
|
|||||||
|
|
||||||
videogen vg0 (
|
videogen vg0 (
|
||||||
.pclk (PCLK_OUT_i),
|
.pclk (PCLK_OUT_i),
|
||||||
.lt_active (1'b0),
|
|
||||||
.lt_mode (2'h0),
|
|
||||||
.xpos (xpos_pp[PP_TP_START]),
|
.xpos (xpos_pp[PP_TP_START]),
|
||||||
.ypos (ypos_pp[PP_TP_START]),
|
.ypos (ypos_pp[PP_TP_START]),
|
||||||
.R_out (R_vg),
|
.R_out (R_vg),
|
||||||
@ -423,9 +429,10 @@ end
|
|||||||
// | SYNC/DE | | | | | | | | | | | |
|
// | SYNC/DE | | | | | | | | | | | |
|
||||||
// | X/Y POS | | | | | | | | | | | |
|
// | X/Y POS | | | | | | | | | | | |
|
||||||
// | | MASK | | | | | | | | | | |
|
// | | MASK | | | | | | | | | | |
|
||||||
|
// | | LT_BOX | | | | | | | | | | |
|
||||||
// | | LB_SETUP | LINEBUF | | | | | | | | | |
|
// | | LB_SETUP | LINEBUF | | | | | | | | | |
|
||||||
// | | | | SRCSEL | | | | | | | | |
|
// | | | | SRCSEL | | | | | | | | |
|
||||||
// | | | | SHMASK | SHMASK | SHMASK | | | | | | |
|
// | | SHM_BUF | SHM_BUF | SHMASK | SHMASK | SHMASK | | | | | | |
|
||||||
// | | | | | Y | Y | | | | | | |
|
// | | | | | Y | Y | | | | | | |
|
||||||
// | | | | | | | SLGEN | SLGEN | SLGEN | SLGEN | SLGEN | |
|
// | | | | | | | SLGEN | SLGEN | SLGEN | SLGEN | SLGEN | |
|
||||||
// | | | | | | | | | | | | TP |
|
// | | | | | | | | | | | | TP |
|
||||||
@ -438,7 +445,7 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
VSYNC_pp[1] <= ((v_cnt < V_SYNCLEN) | ((v_cnt == V_TOTAL) & (h_cnt >= (H_TOTAL/2)))) ? 1'b0 : 1'b1;
|
VSYNC_pp[1] <= ((v_cnt < V_SYNCLEN) | ((v_cnt == V_TOTAL) & (h_cnt >= (H_TOTAL/2)))) ? 1'b0 : 1'b1;
|
||||||
else
|
else
|
||||||
VSYNC_pp[1] <= ((v_cnt < V_SYNCLEN-1) | ((v_cnt == V_SYNCLEN-1) & (h_cnt < (H_TOTAL/2)))) ? 1'b0 : 1'b1;
|
VSYNC_pp[1] <= ((v_cnt < V_SYNCLEN-1) | ((v_cnt == V_SYNCLEN-1) & (h_cnt < (H_TOTAL/2)))) ? 1'b0 : 1'b1;
|
||||||
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);
|
DE_pp[1] <= (h_cnt >= H_SYNCLEN+H_BACKPORCH) & (h_cnt < H_SYNCLEN+H_BACKPORCH+H_ACTIVE-panasonic_adjust) & (v_cnt >= V_SYNCLEN+V_BACKPORCH) & (v_cnt < V_SYNCLEN+V_BACKPORCH+V_ACTIVE);
|
||||||
|
|
||||||
if (h_avidstart) begin
|
if (h_avidstart) begin
|
||||||
// Start 1 line before active so that linebuffer can be filled from DRAM in time
|
// Start 1 line before active so that linebuffer can be filled from DRAM in time
|
||||||
@ -466,7 +473,7 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
y_ctr_sl_pp[1] <= 0;
|
y_ctr_sl_pp[1] <= 0;
|
||||||
end
|
end
|
||||||
line_id <= ~line_id;
|
line_id <= ~line_id;
|
||||||
y_ctr_shmask_pp[1] <= '0;
|
y_ctr_shmask <= '0;
|
||||||
end else begin
|
end else begin
|
||||||
if (ypos_pp[1] != V_ACTIVE) begin
|
if (ypos_pp[1] != V_ACTIVE) begin
|
||||||
ypos_pp[1] <= ypos_pp[1] + 1'b1;
|
ypos_pp[1] <= ypos_pp[1] + 1'b1;
|
||||||
@ -486,7 +493,7 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
end
|
end
|
||||||
if (!ypos_pp_init) begin
|
if (!ypos_pp_init) begin
|
||||||
y_ctr_sl_pp[1] <= (y_ctr_sl_pp[1] == SL_IV_Y) ? '0 : y_ctr_sl_pp[1] + 1'b1;
|
y_ctr_sl_pp[1] <= (y_ctr_sl_pp[1] == SL_IV_Y) ? '0 : y_ctr_sl_pp[1] + 1'b1;
|
||||||
y_ctr_shmask_pp[1] <= (y_ctr_shmask_pp[1] == shmask_iv_y[MISC_SHMASK_ID]) ? '0 : y_ctr_shmask_pp[1] + 1'b1;
|
y_ctr_shmask <= (y_ctr_shmask == MISC_SHMASK_IV_Y) ? '0 : y_ctr_shmask + 1'b1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -494,7 +501,7 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
xpos_lb <= X_START_LB;
|
xpos_lb <= X_START_LB;
|
||||||
x_ctr <= 0;
|
x_ctr <= 0;
|
||||||
x_ctr_sl_pp[1] <= 0;
|
x_ctr_sl_pp[1] <= 0;
|
||||||
x_ctr_shmask_pp[1] <= 0;
|
x_ctr_shmask <= 0;
|
||||||
end else begin
|
end else begin
|
||||||
if (xpos_pp[1] != H_ACTIVE) begin
|
if (xpos_pp[1] != H_ACTIVE) begin
|
||||||
xpos_pp[1] <= xpos_pp[1] + 1'b1;
|
xpos_pp[1] <= xpos_pp[1] + 1'b1;
|
||||||
@ -508,7 +515,7 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
x_ctr <= x_ctr + 1'b1;
|
x_ctr <= x_ctr + 1'b1;
|
||||||
end
|
end
|
||||||
x_ctr_sl_pp[1] <= (x_ctr_sl_pp[1] == SL_IV_X) ? '0 : x_ctr_sl_pp[1] + 1'b1;
|
x_ctr_sl_pp[1] <= (x_ctr_sl_pp[1] == SL_IV_X) ? '0 : x_ctr_sl_pp[1] + 1'b1;
|
||||||
x_ctr_shmask_pp[1] <= (x_ctr_shmask_pp[1] == shmask_iv_x[MISC_SHMASK_ID]) ? '0 : x_ctr_shmask_pp[1] + 1'b1;
|
x_ctr_shmask <= (x_ctr_shmask == MISC_SHMASK_IV_X) ? '0 : x_ctr_shmask + 1'b1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -527,10 +534,6 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
x_ctr_sl_pp[pp_idx] <= x_ctr_sl_pp[pp_idx-1];
|
x_ctr_sl_pp[pp_idx] <= x_ctr_sl_pp[pp_idx-1];
|
||||||
y_ctr_sl_pp[pp_idx] <= y_ctr_sl_pp[pp_idx-1];
|
y_ctr_sl_pp[pp_idx] <= y_ctr_sl_pp[pp_idx-1];
|
||||||
end
|
end
|
||||||
for(pp_idx = PP_PL_START+1; pp_idx <= PP_SHMASK_START; pp_idx = pp_idx+1) begin
|
|
||||||
x_ctr_shmask_pp[pp_idx] <= x_ctr_shmask_pp[pp_idx-1];
|
|
||||||
y_ctr_shmask_pp[pp_idx] <= y_ctr_shmask_pp[pp_idx-1];
|
|
||||||
end
|
|
||||||
// Overridden later where necessary
|
// Overridden later where necessary
|
||||||
for (pp_idx = PP_SRCSEL_END+1; pp_idx <= PP_PL_END; pp_idx = pp_idx+1) begin
|
for (pp_idx = PP_SRCSEL_END+1; pp_idx <= PP_PL_END; pp_idx = pp_idx+1) begin
|
||||||
R_pp[pp_idx] <= R_pp[pp_idx-1];
|
R_pp[pp_idx] <= R_pp[pp_idx-1];
|
||||||
@ -538,7 +541,7 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
B_pp[pp_idx] <= B_pp[pp_idx-1];
|
B_pp[pp_idx] <= B_pp[pp_idx-1];
|
||||||
end
|
end
|
||||||
|
|
||||||
/* ---------- Mask enable calculation (1 cycle) ---------- */
|
/* ---------- Mask / Latency tester overlay enable calculation (1 cycle) ---------- */
|
||||||
if (($signed({1'b0, xpos_pp[PP_MASK_START]}) >= X_OFFSET) &
|
if (($signed({1'b0, xpos_pp[PP_MASK_START]}) >= X_OFFSET) &
|
||||||
($signed({1'b0, xpos_pp[PP_MASK_START]}) < X_OFFSET+X_SIZE) &
|
($signed({1'b0, xpos_pp[PP_MASK_START]}) < X_OFFSET+X_SIZE) &
|
||||||
($signed({1'b0, ypos_pp[PP_MASK_START]}) >= Y_OFFSET) &
|
($signed({1'b0, ypos_pp[PP_MASK_START]}) >= Y_OFFSET) &
|
||||||
@ -548,8 +551,16 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
end else begin
|
end else begin
|
||||||
mask_enable_pp[PP_MASK_END] <= 1'b1;
|
mask_enable_pp[PP_MASK_END] <= 1'b1;
|
||||||
end
|
end
|
||||||
|
if ((xpos_pp[PP_MASK_START] >= LT_BOX_X_START) & (xpos_pp[PP_MASK_START] < LT_BOX_X_STOP) &
|
||||||
|
(ypos_pp[PP_MASK_START] >= LT_BOX_Y_START) & (ypos_pp[PP_MASK_START] < LT_BOX_Y_STOP))
|
||||||
|
begin
|
||||||
|
lt_box_enable_pp[PP_MASK_END] <= (lt_mode != 0);
|
||||||
|
end else begin
|
||||||
|
lt_box_enable_pp[PP_MASK_END] <= 1'b0;
|
||||||
|
end
|
||||||
for(pp_idx = PP_MASK_END+1; pp_idx <= PP_TP_START; pp_idx = pp_idx+1) begin
|
for(pp_idx = PP_MASK_END+1; pp_idx <= PP_TP_START; pp_idx = pp_idx+1) begin
|
||||||
mask_enable_pp[pp_idx] <= mask_enable_pp[pp_idx-1];
|
mask_enable_pp[pp_idx] <= mask_enable_pp[pp_idx-1];
|
||||||
|
lt_box_enable_pp[pp_idx] <= lt_box_enable_pp[pp_idx-1];
|
||||||
end
|
end
|
||||||
|
|
||||||
/* ---------- Source selection (1 cycle) ---------- */
|
/* ---------- Source selection (1 cycle) ---------- */
|
||||||
@ -562,15 +573,15 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
Y <= {1'b0, Y_rb_tmp} + {1'b0, G_pp[PP_Y_CALC_START+1], 1'b0};
|
Y <= {1'b0, Y_rb_tmp} + {1'b0, G_pp[PP_Y_CALC_START+1], 1'b0};
|
||||||
|
|
||||||
/* ---------- Shadow mask calculation (3 cycles) ---------- */
|
/* ---------- Shadow mask calculation (3 cycles) ---------- */
|
||||||
R_shmask_str <= shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][10] ?
|
R_shmask_str <= shmask_data[10] ?
|
||||||
5'h10 + shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][7:4] :
|
5'h10 + shmask_data[7:4] :
|
||||||
shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][3:0];
|
shmask_data[3:0];
|
||||||
G_shmask_str <= shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][9] ?
|
G_shmask_str <= shmask_data[9] ?
|
||||||
5'h10 + shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][7:4] :
|
5'h10 + shmask_data[7:4] :
|
||||||
shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][3:0];
|
shmask_data[3:0];
|
||||||
B_shmask_str <= shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][8] ?
|
B_shmask_str <= shmask_data[8] ?
|
||||||
5'h10 + shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][7:4] :
|
5'h10 + shmask_data[7:4] :
|
||||||
shmask_data[MISC_SHMASK_ID][y_ctr_shmask_pp[PP_SHMASK_START]][x_ctr_shmask_pp[PP_SHMASK_START]][3:0];
|
shmask_data[3:0];
|
||||||
|
|
||||||
// Cycle 3
|
// Cycle 3
|
||||||
R_pp[PP_SHMASK_END] <= MISC_SHMASK_ENABLE ? (R_shmask_mult[8] ? 8'hff : R_shmask_mult[7:0]) : R_pp[PP_SHMASK_START+2];
|
R_pp[PP_SHMASK_END] <= MISC_SHMASK_ENABLE ? (R_shmask_mult[8] ? 8'hff : R_shmask_mult[7:0]) : R_pp[PP_SHMASK_START+2];
|
||||||
@ -617,10 +628,10 @@ always @(posedge PCLK_OUT_i) begin
|
|||||||
G_pp[PP_SLGEN_END] <= (draw_sl_pp[PP_SLGEN_START+4] & sl_method) ? G_sl_mult : G_pp[PP_SLGEN_START+4];
|
G_pp[PP_SLGEN_END] <= (draw_sl_pp[PP_SLGEN_START+4] & sl_method) ? G_sl_mult : G_pp[PP_SLGEN_START+4];
|
||||||
B_pp[PP_SLGEN_END] <= (draw_sl_pp[PP_SLGEN_START+4] & sl_method) ? B_sl_mult : B_pp[PP_SLGEN_START+4];
|
B_pp[PP_SLGEN_END] <= (draw_sl_pp[PP_SLGEN_START+4] & sl_method) ? B_sl_mult : B_pp[PP_SLGEN_START+4];
|
||||||
|
|
||||||
/* ---------- Testpattern / mask generation ---------- */
|
/* ---------- Testpattern / mask / lt_box generation ---------- */
|
||||||
R_pp[PP_TP_END] <= testpattern_enable ? R_vg : (mask_enable_pp[PP_TP_START] ? MASK_R : R_pp[PP_TP_START]);
|
R_pp[PP_TP_END] <= lt_active ? {8{lt_box_enable_pp[PP_TP_START]}} : (testpattern_enable ? R_vg : (mask_enable_pp[PP_TP_START] ? MASK_R : R_pp[PP_TP_START]));
|
||||||
G_pp[PP_TP_END] <= testpattern_enable ? G_vg : (mask_enable_pp[PP_TP_START] ? MASK_G : G_pp[PP_TP_START]);
|
G_pp[PP_TP_END] <= lt_active ? {8{lt_box_enable_pp[PP_TP_START]}} : (testpattern_enable ? G_vg : (mask_enable_pp[PP_TP_START] ? MASK_G : G_pp[PP_TP_START]));
|
||||||
B_pp[PP_TP_END] <= testpattern_enable ? B_vg : (mask_enable_pp[PP_TP_START] ? MASK_B : B_pp[PP_TP_START]);
|
B_pp[PP_TP_END] <= lt_active ? {8{lt_box_enable_pp[PP_TP_START]}} : (testpattern_enable ? B_vg : (mask_enable_pp[PP_TP_START] ? MASK_B : B_pp[PP_TP_START]));
|
||||||
end
|
end
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
|
|||||||
@ -36,6 +36,7 @@ module tvp7002_frontend (
|
|||||||
input [31:0] hv_in_config2,
|
input [31:0] hv_in_config2,
|
||||||
input [31:0] hv_in_config3,
|
input [31:0] hv_in_config3,
|
||||||
input [31:0] misc_config,
|
input [31:0] misc_config,
|
||||||
|
input [31:0] lumacode_data,
|
||||||
output [7:0] R_o,
|
output [7:0] R_o,
|
||||||
output [7:0] G_o,
|
output [7:0] G_o,
|
||||||
output [7:0] B_o,
|
output [7:0] B_o,
|
||||||
@ -52,7 +53,9 @@ module tvp7002_frontend (
|
|||||||
output reg sof_scaler,
|
output reg sof_scaler,
|
||||||
output reg [19:0] pcnt_field,
|
output reg [19:0] pcnt_field,
|
||||||
output reg [7:0] hsync_width,
|
output reg [7:0] hsync_width,
|
||||||
output reg sync_active
|
output reg sync_active,
|
||||||
|
output [8:0] lumacode_addr,
|
||||||
|
output lumacode_rden
|
||||||
);
|
);
|
||||||
|
|
||||||
localparam FID_EVEN = 1'b0;
|
localparam FID_EVEN = 1'b0;
|
||||||
@ -61,6 +64,15 @@ localparam FID_ODD = 1'b1;
|
|||||||
localparam VSYNC_SEPARATED = 1'b0;
|
localparam VSYNC_SEPARATED = 1'b0;
|
||||||
localparam VSYNC_RAW = 1'b1;
|
localparam VSYNC_RAW = 1'b1;
|
||||||
|
|
||||||
|
localparam LC_DISABLED = 3'd0;
|
||||||
|
localparam LC_C64 = 3'd1;
|
||||||
|
localparam LC_SPECTRUM = 3'd2;
|
||||||
|
localparam LC_MSX = 3'd3;
|
||||||
|
localparam LC_INTV = 3'd4;
|
||||||
|
localparam LC_NES = 3'd5;
|
||||||
|
localparam LC_GTIA = 3'd6;
|
||||||
|
localparam LC_CTIA = 3'd7;
|
||||||
|
|
||||||
localparam PP_PL_START = 1;
|
localparam PP_PL_START = 1;
|
||||||
localparam PP_DE_POS_START = PP_PL_START;
|
localparam PP_DE_POS_START = PP_PL_START;
|
||||||
localparam PP_DE_POS_LENGTH = 1;
|
localparam PP_DE_POS_LENGTH = 1;
|
||||||
@ -100,6 +112,8 @@ reg [1:0] lc_code[1:4];
|
|||||||
reg [2:0] lc_ctr;
|
reg [2:0] lc_ctr;
|
||||||
reg [2:0] lc_cnt;
|
reg [2:0] lc_cnt;
|
||||||
reg [2:0] lc_emp_nes;
|
reg [2:0] lc_emp_nes;
|
||||||
|
reg [3:0] lc_atari_hue, lc_atari_luma;
|
||||||
|
reg lc_atari_ctr;
|
||||||
|
|
||||||
// Measurement registers
|
// Measurement registers
|
||||||
reg [20:0] pcnt_frame_ctr;
|
reg [20:0] pcnt_frame_ctr;
|
||||||
@ -123,7 +137,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 [5:0] MISC_REV_LPF_STR = (misc_config[11:7] + 6'd16);
|
||||||
wire MISC_REV_LPF_ENABLE = (misc_config[11:7] != 5'h0);
|
wire MISC_REV_LPF_ENABLE = (misc_config[11:7] != 5'h0);
|
||||||
wire [2:0] MISC_LUMACODE_MODE = misc_config[25:23];
|
wire [2:0] MISC_LUMACODE_MODE = misc_config[14:12];
|
||||||
|
|
||||||
wire [11:0] h_cnt_ref = (vsync_i_type == VSYNC_SEPARATED) ? h_cnt_sogref : h_cnt;
|
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);
|
wire [11:0] even_min_thold = (H_TOTAL / 12'd4);
|
||||||
@ -145,25 +159,10 @@ wire HSYNC_i_np = (HSYNC_i ^ ~hsync_i_pol);
|
|||||||
wire [3:0] H_SKIP = hv_in_config3[27:24];
|
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 = hv_in_config3[31:28];
|
||||||
|
|
||||||
// Lumacode uses 2 samples for {C64, C128, VIC20, Spectrum, TMS99xxA}, 3 samples for NES, 4 samples for VCS and 6 samples for Atari 8bit
|
// Lumacode
|
||||||
wire [2:0] LC_SAMPLES = (MISC_LUMACODE_MODE <= 3) ? 2 : ((MISC_LUMACODE_MODE <= 4) ? 3 : ((MISC_LUMACODE_MODE <= 5) ? 4 : 6));
|
wire [2:0] LC_SAMPLES;
|
||||||
wire [2:0] LC_H_SKIP = ((H_SKIP+1) / LC_SAMPLES) - 1;
|
wire [2:0] LC_H_SKIP = ((H_SKIP+1) / LC_SAMPLES) - 1;
|
||||||
|
|
||||||
// Lumacode palettes for 2-sample index-based sources (C64, Spectrum, Coleco/MSX)
|
|
||||||
wire [23:0] lumacode_data_2s[0:2][0:15] = '{'{ 24'h000000,24'h2a1b9d,24'h7d202c,24'h84258c,24'h4c2e00,24'h3c3c3c,24'h646464,24'h4fb3a5,24'h7f410d,24'h6351db,24'h939393,24'hbfd04a,24'h339840,24'hb44f5c,24'h7ce587,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'h5455ed,24'hfc5554,24'hff7978,24'h000000,24'hd4524d,24'h7d76fc,24'h42ebf5,24'h21b03b,24'h21c842,24'hff7978,24'hcccccc,24'hc95bba,24'hd4c154,24'he6ce80,24'hffffff}};
|
|
||||||
|
|
||||||
// Lumacode palette for NES
|
|
||||||
wire [23:0] lumacode_data_3s[0:63] = '{ 24'h000000, 24'h000000, 24'h000000, 24'h000000, 24'h000000, 24'h000000, 24'h000000, 24'h000000,
|
|
||||||
24'h626262, 24'h001fb2, 24'h2404c8, 24'h5200b2, 24'h730076, 24'h800024, 24'h730b00, 24'h522800, 24'h244400, 24'h005700, 24'h005c00, 24'h005324, 24'h003c76, 24'h000000,
|
|
||||||
24'hababab, 24'h0d57ff, 24'h4b30ff, 24'h8a13ff, 24'hbc08d6, 24'hd21269, 24'hc72e00, 24'h9d5400, 24'h607b00, 24'h209800, 24'h00a300, 24'h009942, 24'h007db4, 24'h000000,
|
|
||||||
24'hffffff, 24'h53aeff, 24'h9085ff, 24'hd365ff, 24'hff57ff, 24'hff5dcf, 24'hff7757, 24'hfa9e00, 24'hbdc700, 24'h7ae700, 24'h43f611, 24'h26ef7e, 24'h2cd5f6, 24'h4e4e4e,
|
|
||||||
24'hffffff, 24'hb6e1ff, 24'hced1ff, 24'he9c3ff, 24'hffbcff, 24'hffbdf4, 24'hffc6c3, 24'hffd59a, 24'he9e681, 24'hcef481, 24'hb6fb9a, 24'ha9fac3, 24'ha9f0f4, 24'hb8b8b8};
|
|
||||||
wire [7:0] lumacode_data_3s_R = lumacode_data_3s[{lc_code[1], lc_code[2], lc_code[3]}][23:16];
|
|
||||||
wire [7:0] lumacode_data_3s_G = lumacode_data_3s[{lc_code[1], lc_code[2], lc_code[3]}][15:8];
|
|
||||||
wire [7:0] lumacode_data_3s_B = lumacode_data_3s[{lc_code[1], lc_code[2], lc_code[3]}][7:0];
|
|
||||||
|
|
||||||
// SOF position for scaler
|
// SOF position for scaler
|
||||||
wire [10:0] V_SOF_LINE = hv_in_config3[23:13];
|
wire [10:0] V_SOF_LINE = hv_in_config3[23:13];
|
||||||
|
|
||||||
@ -178,6 +177,15 @@ function [7:0] apply_reverse_lpf;
|
|||||||
end
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
// Lumacode number of samples selection
|
||||||
|
always @(*) begin
|
||||||
|
case(MISC_LUMACODE_MODE)
|
||||||
|
LC_C64,LC_SPECTRUM,LC_MSX,LC_CTIA : LC_SAMPLES = 2; // 2 samples for {C64, C128, VIC20, Spectrum, TMS99xxA} / 4 samples for VCS (2 per half-pixel)
|
||||||
|
LC_INTV : LC_SAMPLES = 1; // 2 samples for Intellivision (1 per doubled pixel)
|
||||||
|
LC_NES,LC_GTIA : LC_SAMPLES = 3; // 3 samples for NES / 6 samples for Atari 8bit (3 per pixel)
|
||||||
|
default : LC_SAMPLES = 1;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
|
||||||
// Pipeline stage 1
|
// Pipeline stage 1
|
||||||
always @(posedge PCLK_i) begin
|
always @(posedge PCLK_i) begin
|
||||||
@ -263,6 +271,7 @@ always @(posedge PCLK_i) begin
|
|||||||
lc_code[1] <= G_pp[1][7:6];
|
lc_code[1] <= G_pp[1][7:6];
|
||||||
lc_cnt <= 0;
|
lc_cnt <= 0;
|
||||||
lc_ctr <= 0;
|
lc_ctr <= 0;
|
||||||
|
lc_atari_ctr <= (h_cnt == 0) ? 0 : lc_atari_ctr ^ 1'b1;
|
||||||
end else if (lc_ctr == LC_H_SKIP) begin
|
end else if (lc_ctr == LC_H_SKIP) begin
|
||||||
lc_code[2+lc_cnt] <= G_pp[1][7:6];
|
lc_code[2+lc_cnt] <= G_pp[1][7:6];
|
||||||
lc_cnt <= lc_cnt + 1;
|
lc_cnt <= lc_cnt + 1;
|
||||||
@ -271,45 +280,44 @@ always @(posedge PCLK_i) begin
|
|||||||
lc_ctr <= lc_ctr + 1;
|
lc_ctr <= lc_ctr + 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
// Standard output
|
// Lumacode related source-specific registers (used as part of palette RAM addressing / data processing)
|
||||||
if (MISC_LUMACODE_MODE == '0) begin
|
|
||||||
{R_pp[2], G_pp[2], B_pp[2]} <= {R_pp[1], G_pp[1], B_pp[1]};
|
|
||||||
// Lumacode C64, C128, VIC20, Spectrum, TMS99xxA
|
|
||||||
end else if (MISC_LUMACODE_MODE <= 3) begin
|
|
||||||
{R_pp[2], G_pp[2], B_pp[2]} <= lumacode_data_2s[MISC_LUMACODE_MODE-1'b1][{lc_code[1], lc_code[2]}];
|
|
||||||
// Lumacode NES
|
// Lumacode NES
|
||||||
end else if (MISC_LUMACODE_MODE == 4) begin
|
if (MISC_LUMACODE_MODE == LC_NES) begin
|
||||||
if (lc_emp_nes[1] & lc_emp_nes[0])
|
|
||||||
R_pp[2] <= lumacode_data_3s_R/2;
|
|
||||||
else if (lc_emp_nes[1] | lc_emp_nes[0])
|
|
||||||
R_pp[2] <= lumacode_data_3s_R - lumacode_data_3s_R/4;
|
|
||||||
else
|
|
||||||
R_pp[2] <= lumacode_data_3s_R;
|
|
||||||
|
|
||||||
if (lc_emp_nes[2] & lc_emp_nes[0])
|
|
||||||
G_pp[2] <= lumacode_data_3s_G/2;
|
|
||||||
else if (lc_emp_nes[2] | lc_emp_nes[0])
|
|
||||||
G_pp[2] <= lumacode_data_3s_G - lumacode_data_3s_G/4;
|
|
||||||
else
|
|
||||||
G_pp[2] <= lumacode_data_3s_G;
|
|
||||||
|
|
||||||
if (lc_emp_nes[2] & lc_emp_nes[1])
|
|
||||||
B_pp[2] <= lumacode_data_3s_B/2;
|
|
||||||
else if (lc_emp_nes[2] | lc_emp_nes[1])
|
|
||||||
B_pp[2] <= lumacode_data_3s_B - lumacode_data_3s_B/4;
|
|
||||||
else
|
|
||||||
B_pp[2] <= lumacode_data_3s_B;
|
|
||||||
|
|
||||||
if ((h_ctr == H_SAMPLE_SEL) & ({lc_code[1], lc_code[2], lc_code[3]} < 8))
|
if ((h_ctr == H_SAMPLE_SEL) & ({lc_code[1], lc_code[2], lc_code[3]} < 8))
|
||||||
lc_emp_nes <= {lc_code[2][0], lc_code[3]};
|
lc_emp_nes <= {lc_code[2][0], lc_code[3]};
|
||||||
// TODO: Lumacode VCS
|
// Lumacode Intellivision
|
||||||
end else if (MISC_LUMACODE_MODE == 5) begin
|
end else if (MISC_LUMACODE_MODE == LC_INTV) begin
|
||||||
{R_pp[2], G_pp[2], B_pp[2]} <= '0;
|
if ((h_ctr == H_SAMPLE_SEL) & lc_atari_ctr) begin
|
||||||
// TODO: Lumacode Atari 8-bit
|
lc_atari_luma[1:0] <= lc_code[1];
|
||||||
|
end
|
||||||
|
// Lumacode Atari GTIA
|
||||||
|
end else if (MISC_LUMACODE_MODE == LC_GTIA) begin
|
||||||
|
if (h_ctr == H_SAMPLE_SEL) begin
|
||||||
|
if (lc_atari_ctr) begin
|
||||||
|
// Store hue and luma (high bits) for 1st pixel, and display last pixel of previous pair
|
||||||
|
lc_atari_hue <= {lc_code[1], lc_code[2]};
|
||||||
|
lc_atari_luma[3:2] <= lc_code[3];
|
||||||
|
//{R_pp[2], G_pp[2], B_pp[2]} <= lumacode_data_gtia[{lc_atari_hue, lc_atari_luma}];
|
||||||
|
end else begin
|
||||||
|
// Store luma for 2nd pixel, and display first pixel of current pair
|
||||||
|
lc_atari_luma <= {lc_code[2], lc_code[3]};
|
||||||
|
//{R_pp[2], G_pp[2], B_pp[2]} <= lumacode_data_gtia[{lc_atari_hue, lc_atari_luma[3:2], lc_code[1]}];
|
||||||
|
end
|
||||||
|
end
|
||||||
|
// Lumacode Atari VCS
|
||||||
end else begin
|
end else begin
|
||||||
{R_pp[2], G_pp[2], B_pp[2]} <= '0;
|
if (h_ctr == H_SAMPLE_SEL) begin
|
||||||
|
if (lc_atari_ctr) begin
|
||||||
|
// Store first 2 lumacode samples (hue) from double-sampled input (160col->320col)
|
||||||
|
lc_atari_hue <= {lc_code[1], lc_code[2]};
|
||||||
|
end else begin
|
||||||
|
// Display pixel after receiving remaining 2 lumacode samples (luma)
|
||||||
|
//{R_pp[2], G_pp[2], B_pp[2]} <= lumacode_data_ctia[{lc_atari_hue, lc_code[1], lc_code[2][1]}];
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
{R_pp[2], G_pp[2], B_pp[2]} <= {R_pp[1], G_pp[1], B_pp[1]};
|
||||||
HSYNC_pp[2] <= HSYNC_pp[1];
|
HSYNC_pp[2] <= HSYNC_pp[1];
|
||||||
VSYNC_pp[2] <= VSYNC_pp[1];
|
VSYNC_pp[2] <= VSYNC_pp[1];
|
||||||
FID_pp[2] <= FID_pp[1];
|
FID_pp[2] <= FID_pp[1];
|
||||||
@ -359,13 +367,65 @@ always @(posedge PCLK_i) begin
|
|||||||
B_diff_s15 <= (B_diff_s15_pre * MISC_REV_LPF_STR);
|
B_diff_s15 <= (B_diff_s15_pre * MISC_REV_LPF_STR);
|
||||||
|
|
||||||
// Cycle 3
|
// Cycle 3
|
||||||
if (MISC_REV_LPF_ENABLE) begin
|
if (MISC_REV_LPF_ENABLE & (MISC_LUMACODE_MODE == LC_DISABLED)) begin
|
||||||
R_pp[PP_RLPF_END] <= apply_reverse_lpf(R_pp[PP_RLPF_START+2], R_diff_s15);
|
R_pp[PP_RLPF_END] <= apply_reverse_lpf(R_pp[PP_RLPF_START+2], R_diff_s15);
|
||||||
G_pp[PP_RLPF_END] <= apply_reverse_lpf(G_pp[PP_RLPF_START+2], G_diff_s15);
|
G_pp[PP_RLPF_END] <= apply_reverse_lpf(G_pp[PP_RLPF_START+2], G_diff_s15);
|
||||||
B_pp[PP_RLPF_END] <= apply_reverse_lpf(B_pp[PP_RLPF_START+2], B_diff_s15);
|
B_pp[PP_RLPF_END] <= apply_reverse_lpf(B_pp[PP_RLPF_START+2], B_diff_s15);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
/* --- Lumacode overwrite data from RAM --- */
|
||||||
|
if (MISC_LUMACODE_MODE != LC_DISABLED) begin
|
||||||
|
if (MISC_LUMACODE_MODE == LC_NES) begin
|
||||||
|
// NES
|
||||||
|
R_pp[PP_RLPF_START+1] <= &lc_emp_nes[1:0] ? (lumacode_data[23:16]/2) : (|lc_emp_nes[1:0] ? (lumacode_data[23:16] - lumacode_data[23:16]/4) : lumacode_data[23:16]);
|
||||||
|
G_pp[PP_RLPF_START+1] <= (lc_emp_nes[2] & lc_emp_nes[0]) ? (lumacode_data[15:8]/2) : ((lc_emp_nes[2] | lc_emp_nes[0]) ? (lumacode_data[15:8] - lumacode_data[15:8]/4) : lumacode_data[15:8]);
|
||||||
|
B_pp[PP_RLPF_START+1] <= &lc_emp_nes[2:1] ? (lumacode_data[7:0]/2) : (|lc_emp_nes[2:1] ? (lumacode_data[7:0] - lumacode_data[7:0]/4) : lumacode_data[7:0]);
|
||||||
|
end else begin
|
||||||
|
// With other palette data used as-is
|
||||||
|
R_pp[PP_RLPF_START+1] <= lumacode_data[23:16];
|
||||||
|
G_pp[PP_RLPF_START+1] <= lumacode_data[15:8];
|
||||||
|
B_pp[PP_RLPF_START+1] <= lumacode_data[7:0];
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
// Lumacode palette RAM inputs
|
||||||
|
always @(*)
|
||||||
|
case (MISC_LUMACODE_MODE)
|
||||||
|
LC_C64: begin // C64, C128, VIC20
|
||||||
|
lumacode_addr = {5'h0, lc_code[1], lc_code[2]};
|
||||||
|
lumacode_rden = 1;
|
||||||
|
end
|
||||||
|
LC_SPECTRUM: begin // Spectrum
|
||||||
|
lumacode_addr = {5'h1, lc_code[1], lc_code[2]};
|
||||||
|
lumacode_rden = 1;
|
||||||
|
end
|
||||||
|
LC_MSX: begin // TMS99xxA
|
||||||
|
lumacode_addr = {5'h2, lc_code[1], lc_code[2]};
|
||||||
|
lumacode_rden = 1;
|
||||||
|
end
|
||||||
|
LC_INTV: begin // Intellivision
|
||||||
|
lumacode_addr = {5'h3, lc_atari_luma[1:0], lc_code[1]};
|
||||||
|
lumacode_rden = (h_ctr == H_SAMPLE_SEL) & !lc_atari_ctr;
|
||||||
|
end
|
||||||
|
LC_NES: begin // NES
|
||||||
|
lumacode_addr = {3'h1, lc_code[1], lc_code[2], lc_code[3]};
|
||||||
|
lumacode_rden = 1;
|
||||||
|
end
|
||||||
|
LC_GTIA: begin // Atari GTIA
|
||||||
|
lumacode_addr = lc_atari_ctr ? {1'h1, lc_atari_hue, lc_atari_luma} : {1'h1, lc_atari_hue, lc_atari_luma[3:2], lc_code[1]};
|
||||||
|
lumacode_rden = (h_ctr == H_SAMPLE_SEL);
|
||||||
|
end
|
||||||
|
LC_CTIA: begin // Atari CTIA/TIA
|
||||||
|
lumacode_addr = {2'h1, lc_atari_hue, lc_code[1], lc_code[2][1]};
|
||||||
|
lumacode_rden = (h_ctr == H_SAMPLE_SEL) & !lc_atari_ctr;
|
||||||
|
end
|
||||||
|
default: begin // Standard output
|
||||||
|
lumacode_addr = '0;
|
||||||
|
lumacode_rden = 0;
|
||||||
|
end
|
||||||
|
endcase
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
assign R_o = R_pp[PP_PL_END];
|
assign R_o = R_pp[PP_PL_END];
|
||||||
assign G_o = G_pp[PP_PL_END];
|
assign G_o = G_pp[PP_PL_END];
|
||||||
|
|||||||
@ -17,12 +17,8 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
//
|
//
|
||||||
|
|
||||||
`include "lat_tester_includes.v"
|
|
||||||
|
|
||||||
module videogen (
|
module videogen (
|
||||||
input pclk,
|
input pclk,
|
||||||
input lt_active,
|
|
||||||
input [1:0] lt_mode,
|
|
||||||
input [11:0] xpos,
|
input [11:0] xpos,
|
||||||
input [10:0] ypos,
|
input [10:0] ypos,
|
||||||
output reg [7:0] R_out,
|
output reg [7:0] R_out,
|
||||||
@ -56,31 +52,14 @@ parameter V_BORDER = ((V_AREA-V_GRADIENT)>>1);
|
|||||||
// Pattern gen
|
// Pattern gen
|
||||||
always @(posedge pclk)
|
always @(posedge pclk)
|
||||||
begin
|
begin
|
||||||
if (lt_active) begin
|
if ((xpos < H_OVERSCAN) || (xpos >= H_OVERSCAN+H_AREA) || (ypos < V_OVERSCAN) || (ypos >= V_OVERSCAN+V_AREA))
|
||||||
case (lt_mode)
|
{R_out, G_out, B_out} <= {3{(xpos[0] ^ ypos[0]) ? 8'hff : 8'h00}};
|
||||||
default: begin
|
else if ((xpos < H_OVERSCAN+H_BORDER) || (xpos >= H_OVERSCAN+H_AREA-H_BORDER) || (ypos < V_OVERSCAN+V_BORDER) || (ypos >= V_OVERSCAN+V_AREA-V_BORDER))
|
||||||
{R_out, G_out, B_out} <= {3{8'h00}};
|
{R_out, G_out, B_out} <= {3{8'h50}};
|
||||||
end
|
else if (ypos >= V_OVERSCAN+V_BORDER+V_GRADIENT-V_GRAYRAMP)
|
||||||
`LT_POS_TOPLEFT: begin
|
{R_out, G_out, B_out} <= {3{8'((((xpos - (H_OVERSCAN+H_BORDER)) >> 4) << 3) + (xpos - (H_OVERSCAN+H_BORDER) >> 6))}};
|
||||||
{R_out, G_out, B_out} <= {3{((xpos < (H_ACTIVE/`LT_WIDTH_DIV)) && (ypos < (V_ACTIVE/`LT_HEIGHT_DIV))) ? 8'hff : 8'h00}};
|
else
|
||||||
end
|
{R_out, G_out, B_out} <= {3{8'((xpos - (H_OVERSCAN+H_BORDER)) >> 1)}};
|
||||||
`LT_POS_CENTER: begin
|
|
||||||
{R_out, G_out, B_out} <= {3{((xpos >= ((H_ACTIVE/2)-(H_ACTIVE/(`LT_WIDTH_DIV*2)))) && (xpos < ((H_ACTIVE/2)+(H_ACTIVE/(`LT_WIDTH_DIV*2)))) && (ypos >= ((V_ACTIVE/2)-(V_ACTIVE/(`LT_HEIGHT_DIV*2)))) && (ypos < ((V_ACTIVE/2)+(V_ACTIVE/(`LT_HEIGHT_DIV*2))))) ? 8'hff : 8'h00}};
|
|
||||||
end
|
|
||||||
`LT_POS_BOTTOMRIGHT: begin
|
|
||||||
{R_out, G_out, B_out} <= {3{((xpos >= (H_ACTIVE-(H_ACTIVE/`LT_WIDTH_DIV))) && (ypos >= (V_ACTIVE-(V_ACTIVE/`LT_HEIGHT_DIV)))) ? 8'hff : 8'h00}};
|
|
||||||
end
|
|
||||||
endcase
|
|
||||||
end else begin
|
|
||||||
if ((xpos < H_OVERSCAN) || (xpos >= H_OVERSCAN+H_AREA) || (ypos < V_OVERSCAN) || (ypos >= V_OVERSCAN+V_AREA))
|
|
||||||
{R_out, G_out, B_out} <= {3{(xpos[0] ^ ypos[0]) ? 8'hff : 8'h00}};
|
|
||||||
else if ((xpos < H_OVERSCAN+H_BORDER) || (xpos >= H_OVERSCAN+H_AREA-H_BORDER) || (ypos < V_OVERSCAN+V_BORDER) || (ypos >= V_OVERSCAN+V_AREA-V_BORDER))
|
|
||||||
{R_out, G_out, B_out} <= {3{8'h50}};
|
|
||||||
else if (ypos >= V_OVERSCAN+V_BORDER+V_GRADIENT-V_GRAYRAMP)
|
|
||||||
{R_out, G_out, B_out} <= {3{8'((((xpos - (H_OVERSCAN+H_BORDER)) >> 4) << 3) + (xpos - (H_OVERSCAN+H_BORDER) >> 6))}};
|
|
||||||
else
|
|
||||||
{R_out, G_out, B_out} <= {3{8'((xpos - (H_OVERSCAN+H_BORDER)) >> 1)}};
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
58
scripts/dump_flash_regs.tcl
Normal file
58
scripts/dump_flash_regs.tcl
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# flash details
|
||||||
|
set flash_base 0x02000000
|
||||||
|
set flash_imem_offset 0x00100000
|
||||||
|
set flash_imem_base [format 0x%.8x [expr $flash_base + $flash_imem_offset]]
|
||||||
|
set flash_secsize 65536
|
||||||
|
|
||||||
|
# flash controller register addresses
|
||||||
|
set control_register 0x00020100
|
||||||
|
set operating_protocols_setting 0x00020110
|
||||||
|
set read_instr 0x00020114
|
||||||
|
set write_instr 0x00020118
|
||||||
|
set flash_cmd_setting 0x0002011c
|
||||||
|
set flash_cmd_ctrl 0x00020120
|
||||||
|
set flash_cmd_addr_register 0x00020124
|
||||||
|
set flash_cmd_write_data_0 0x00020128
|
||||||
|
set flash_cmd_read_data_0 0x00020130
|
||||||
|
|
||||||
|
#Select the master service type and check for available service paths.
|
||||||
|
set service_paths [get_service_paths master]
|
||||||
|
|
||||||
|
#Set the master service path.
|
||||||
|
set master_service_path [lindex $service_paths 0]
|
||||||
|
|
||||||
|
#Open the master service.
|
||||||
|
set claim_path [claim_service master $master_service_path mylib]
|
||||||
|
|
||||||
|
puts "Halting CPU"
|
||||||
|
master_write_32 $claim_path 0x40 0x00000001
|
||||||
|
master_write_32 $claim_path 0x40 0x80000001
|
||||||
|
|
||||||
|
#read status reg
|
||||||
|
master_write_32 $claim_path $flash_cmd_setting 0x00001805
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
set st [master_read_8 $claim_path $flash_cmd_read_data_0 1]
|
||||||
|
puts "\nSTATUS: $st"
|
||||||
|
|
||||||
|
#read flag reg
|
||||||
|
master_write_32 $claim_path $flash_cmd_setting 0x00001848
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
set flags [master_read_8 $claim_path $flash_cmd_read_data_0 1]
|
||||||
|
puts "FLAGS: $flags"
|
||||||
|
|
||||||
|
#read vcr reg
|
||||||
|
master_write_32 $claim_path $flash_cmd_setting 0x00001861
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
set vcr [master_read_8 $claim_path $flash_cmd_read_data_0 1]
|
||||||
|
puts "VCR: $vcr"
|
||||||
|
|
||||||
|
#read evcr reg
|
||||||
|
master_write_32 $claim_path $flash_cmd_setting 0x00001881
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
set evcr [master_read_8 $claim_path $flash_cmd_read_data_0 1]
|
||||||
|
puts "EVCR: $evcr"
|
||||||
|
|
||||||
|
#clear flag register
|
||||||
|
master_write_32 $claim_path $flash_cmd_setting 0x00000050
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
|
||||||
@ -1,35 +1,13 @@
|
|||||||
--- sys/synthesis/submodules/altera_asmi2_xip_controller.sv 2024-07-15 02:34:49.476724296 +0300
|
--- sys/synthesis/submodules/sys_master_0.v 2025-07-25 10:15:46.708247405 +0300
|
||||||
+++ sys/synthesis/submodules/altera_asmi2_xip_controller.sv 2024-07-15 02:50:24.750038794 +0300
|
+++ sys/synthesis/submodules/sys_master_0.v 2025-07-25 10:15:54.937804924 +0300
|
||||||
@@ -611,7 +611,7 @@
|
@@ -156,9 +156,9 @@
|
||||||
.USE_PACKETS (1),
|
|
||||||
.USE_FILL_LEVEL (0),
|
altera_avalon_sc_fifo #(
|
||||||
.EMPTY_LATENCY (3),
|
.SYMBOLS_PER_BEAT (1),
|
||||||
- .USE_MEMORY_BLOCKS (1),
|
.BITS_PER_SYMBOL (8),
|
||||||
+ .USE_MEMORY_BLOCKS (0),
|
- .FIFO_DEPTH (64),
|
||||||
.USE_STORE_FORWARD (0),
|
+ .FIFO_DEPTH (1024),
|
||||||
.USE_ALMOST_FULL_IF (0),
|
.CHANNEL_WIDTH (0),
|
||||||
.USE_ALMOST_EMPTY_IF (0)
|
.ERROR_WIDTH (0),
|
||||||
|
|
||||||
--- sys/synthesis/submodules/sys_master_0.v 2024-07-15 02:34:47.396703537 +0300
|
|
||||||
+++ sys/synthesis/submodules/sys_master_0.v 2024-07-15 02:50:14.617938092 +0300
|
|
||||||
@@ -163,7 +163,7 @@
|
|
||||||
.USE_PACKETS (0),
|
.USE_PACKETS (0),
|
||||||
.USE_FILL_LEVEL (0),
|
.USE_FILL_LEVEL (0),
|
||||||
.EMPTY_LATENCY (3),
|
|
||||||
- .USE_MEMORY_BLOCKS (1),
|
|
||||||
+ .USE_MEMORY_BLOCKS (0),
|
|
||||||
.USE_STORE_FORWARD (0),
|
|
||||||
.USE_ALMOST_FULL_IF (0),
|
|
||||||
.USE_ALMOST_EMPTY_IF (0)
|
|
||||||
|
|
||||||
--- sys/synthesis/submodules/sys_onchip_memory2_0.v 2024-07-15 02:34:47.540704974 +0300
|
|
||||||
+++ sys/synthesis/submodules/sys_onchip_memory2_0.v 2024-07-15 02:49:59.685789671 +0300
|
|
||||||
@@ -71,7 +71,7 @@
|
|
||||||
defparam the_altsyncram.byte_size = 8,
|
|
||||||
the_altsyncram.init_file = INIT_FILE,
|
|
||||||
the_altsyncram.lpm_type = "altsyncram",
|
|
||||||
- the_altsyncram.maximum_depth = 10496,
|
|
||||||
+ the_altsyncram.maximum_depth = 2048,
|
|
||||||
the_altsyncram.numwords_a = 10496,
|
|
||||||
the_altsyncram.operation_mode = "SINGLE_PORT",
|
|
||||||
the_altsyncram.outdata_reg_a = "UNREGISTERED",
|
|
||||||
|
|||||||
36
scripts/rv-bt.tcl
Normal file
36
scripts/rv-bt.tcl
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#Select the master service type and check for available service paths.
|
||||||
|
while 1 {
|
||||||
|
set service_paths [get_service_paths master]
|
||||||
|
if {[llength $service_paths] > 0} {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
puts "Refreshing connections..."
|
||||||
|
refresh_connections
|
||||||
|
after 100
|
||||||
|
}
|
||||||
|
|
||||||
|
#Set the master service path.
|
||||||
|
set master_service_path [lindex $service_paths 0]
|
||||||
|
|
||||||
|
#Open the master service.
|
||||||
|
set claim_path [claim_service master $master_service_path mylib]
|
||||||
|
|
||||||
|
puts "Halting CPU"
|
||||||
|
master_write_32 $claim_path 0x40 0x00000001
|
||||||
|
master_write_32 $claim_path 0x40 0x80000001
|
||||||
|
|
||||||
|
master_write_32 $claim_path 0x5c [expr 0x2207b1]
|
||||||
|
puts "DPC: [master_read_32 $claim_path 0x10 1]"
|
||||||
|
master_write_32 $claim_path 0x5c [expr 0x220341]
|
||||||
|
puts "MEPC: [master_read_32 $claim_path 0x10 1]"
|
||||||
|
master_write_32 $claim_path 0x5c [expr 0x220342]
|
||||||
|
puts "MCAUSE: [master_read_32 $claim_path 0x10 1]"
|
||||||
|
|
||||||
|
set offset 0x1001
|
||||||
|
foreach i {ra sp gp tp t0 t1 t2 s0 s1 a0 a1 a2 a3 a4 a5} {
|
||||||
|
master_write_32 $claim_path 0x5c [expr 0x220000 + $offset]
|
||||||
|
puts "$i: [master_read_32 $claim_path 0x10 1]"
|
||||||
|
set offset [expr $offset + 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
master_write_32 $claim_path 0x40 0x40000000
|
||||||
29
scripts/rv-ndmreset.tcl
Normal file
29
scripts/rv-ndmreset.tcl
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#Select the master service type and check for available service paths.
|
||||||
|
while 1 {
|
||||||
|
set service_paths [get_service_paths master]
|
||||||
|
if {[llength $service_paths] > 0} {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
puts "Refreshing connections..."
|
||||||
|
refresh_connections
|
||||||
|
after 100
|
||||||
|
}
|
||||||
|
|
||||||
|
#Set the master service path.
|
||||||
|
set master_service_path [lindex $service_paths 0]
|
||||||
|
|
||||||
|
#Open the master service.
|
||||||
|
set claim_path [claim_service master $master_service_path mylib]
|
||||||
|
|
||||||
|
puts "Halting CPU"
|
||||||
|
master_write_32 $claim_path 0x40 0x00000001
|
||||||
|
master_write_32 $claim_path 0x40 0x80000001
|
||||||
|
|
||||||
|
puts "Resetting system"
|
||||||
|
master_write_32 $claim_path 0x40 0x00000003
|
||||||
|
after 1
|
||||||
|
master_write_32 $claim_path 0x40 0x00000001
|
||||||
|
master_write_32 $claim_path 0x40 0x00000000
|
||||||
|
|
||||||
|
close_service master $claim_path
|
||||||
|
puts "Done"
|
||||||
30
scripts/rv-reboot.tcl
Normal file
30
scripts/rv-reboot.tcl
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#Select the master service type and check for available service paths.
|
||||||
|
while 1 {
|
||||||
|
set service_paths [get_service_paths master]
|
||||||
|
if {[llength $service_paths] > 0} {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
puts "Refreshing connections..."
|
||||||
|
refresh_connections
|
||||||
|
after 100
|
||||||
|
}
|
||||||
|
|
||||||
|
#Set the master service path.
|
||||||
|
set master_service_path [lindex $service_paths 0]
|
||||||
|
|
||||||
|
#Open the master service.
|
||||||
|
set claim_path [claim_service master $master_service_path mylib]
|
||||||
|
|
||||||
|
puts "Halting CPU via sleep"
|
||||||
|
master_write_32 $claim_path 0x200 0x00000002
|
||||||
|
|
||||||
|
close_service master $claim_path
|
||||||
|
|
||||||
|
|
||||||
|
set jtag_debug_list [get_service_paths jtag_debug]
|
||||||
|
set jd [ lindex $jtag_debug_list 0 ]
|
||||||
|
open_service jtag_debug $jd
|
||||||
|
puts "Resetting system"
|
||||||
|
jtag_debug_reset_system $jd
|
||||||
|
close_service jtag_debug $jd
|
||||||
|
puts "Done"
|
||||||
@ -1,3 +1,25 @@
|
|||||||
|
# flash details
|
||||||
|
set flash_base 0x02000000
|
||||||
|
set flash_imem_offset 0x00050000
|
||||||
|
set flash_imem_base [format 0x%.8x [expr $flash_base + $flash_imem_offset]]
|
||||||
|
set flash_secsize 65536
|
||||||
|
|
||||||
|
# flash controller register addresses
|
||||||
|
set control_register 0x00020100
|
||||||
|
set operating_protocols_setting 0x00020110
|
||||||
|
set read_instr 0x00020114
|
||||||
|
set write_instr 0x00020118
|
||||||
|
set flash_cmd_setting 0x0002011c
|
||||||
|
set flash_cmd_ctrl 0x00020120
|
||||||
|
set flash_cmd_addr_register 0x00020124
|
||||||
|
set flash_cmd_write_data_0 0x00020128
|
||||||
|
set flash_cmd_read_data_0 0x00020130
|
||||||
|
|
||||||
|
# target file details
|
||||||
|
set bin_file mem_init/flash.bin
|
||||||
|
set bin_size [file size $bin_file]
|
||||||
|
set num_sectors [expr ($bin_size / $flash_secsize) + (($bin_size % $flash_secsize) ne 0)]
|
||||||
|
|
||||||
#Select the master service type and check for available service paths.
|
#Select the master service type and check for available service paths.
|
||||||
while 1 {
|
while 1 {
|
||||||
set service_paths [get_service_paths master]
|
set service_paths [get_service_paths master]
|
||||||
@ -16,18 +38,55 @@ set master_service_path [lindex $service_paths 0]
|
|||||||
set claim_path [claim_service master $master_service_path mylib]
|
set claim_path [claim_service master $master_service_path mylib]
|
||||||
|
|
||||||
puts "Halting CPU"
|
puts "Halting CPU"
|
||||||
master_write_32 $claim_path 0x0 0x10000
|
master_write_32 $claim_path 0x40 0x00000001
|
||||||
|
master_write_32 $claim_path 0x40 0x80000001
|
||||||
|
|
||||||
puts "Writing block RAM"
|
#write enable
|
||||||
master_write_from_file $claim_path mem_init/sys_onchip_memory2_0.bin 0x10000
|
master_write_32 $claim_path $flash_cmd_setting 0x00000006
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
|
||||||
|
#write status register (clear BP)
|
||||||
|
master_write_32 $claim_path $flash_cmd_setting 0x00001001
|
||||||
|
#master_write_32 $claim_path $flash_cmd_write_data_0 0x0000005c
|
||||||
|
master_write_32 $claim_path $flash_cmd_write_data_0 0x00000000
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
|
||||||
|
puts "Erasing $num_sectors flash sectors"
|
||||||
|
set addr $flash_imem_offset
|
||||||
|
for {set i 0} {$i<$num_sectors} {incr i} {
|
||||||
|
master_write_32 $claim_path $flash_cmd_setting 0x00000006
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
master_write_32 $claim_path $flash_cmd_setting 0x000003D8
|
||||||
|
master_write_32 $claim_path $flash_cmd_addr_register $addr
|
||||||
|
master_write_32 $claim_path $flash_cmd_ctrl 0x1
|
||||||
|
set addr [expr $addr + $flash_secsize]
|
||||||
|
after 500
|
||||||
|
}
|
||||||
|
|
||||||
|
puts "Writing flash"
|
||||||
|
# JTAG to Avalon master does not support sink backpressure
|
||||||
|
#master_write_from_file $claim_path mem_init/flash.bin $flash_imem_base
|
||||||
|
|
||||||
|
# work around lack of backpressure support by writing chunks of master FIFO size
|
||||||
|
set chunks [llength [glob mem_init/chunks/*]]
|
||||||
|
puts "Programming $chunks chunks"
|
||||||
|
set addr $flash_imem_base
|
||||||
|
for {set i 0} {$i<$chunks} {incr i} {
|
||||||
|
set file [format "flash.%04d" $i]
|
||||||
|
master_write_from_file $claim_path mem_init/chunks/$file $addr
|
||||||
|
set addr [expr $addr + 1024]
|
||||||
|
}
|
||||||
|
#master_read_to_file $claim_path mem_init/flash_readback.bin $flash_imem_base $bin_size
|
||||||
|
#master_read_to_file $claim_path mem_init/ram_readback.bin 0x010000 65536
|
||||||
|
|
||||||
|
# flush flashctrl cmd fifo to ensure writes have finished
|
||||||
|
master_read_32 $claim_path $flash_base 1
|
||||||
|
|
||||||
|
puts "Resetting system"
|
||||||
|
master_write_32 $claim_path 0x40 0x00000003
|
||||||
|
after 1
|
||||||
|
master_write_32 $claim_path 0x40 0x00000001
|
||||||
|
master_write_32 $claim_path 0x40 0x00000000
|
||||||
|
|
||||||
close_service master $claim_path
|
close_service master $claim_path
|
||||||
|
|
||||||
|
|
||||||
set jtag_debug_list [get_service_paths jtag_debug]
|
|
||||||
set jd [ lindex $jtag_debug_list 0 ]
|
|
||||||
open_service jtag_debug $jd
|
|
||||||
puts "Resetting system"
|
|
||||||
jtag_debug_reset_system $jd
|
|
||||||
close_service jtag_debug $jd
|
|
||||||
puts "Done"
|
puts "Done"
|
||||||
|
|||||||
@ -26,6 +26,103 @@
|
|||||||
}]]]>
|
}]]]>
|
||||||
</Plugin>
|
</Plugin>
|
||||||
</Plugins>
|
</Plugins>
|
||||||
|
<VirtualDirectory Name="sys_controller">
|
||||||
|
<VirtualDirectory Name="fatfs">
|
||||||
|
<VirtualDirectory Name="source">
|
||||||
|
<File Name="sys_controller/fatfs/source/ffsystem.c"/>
|
||||||
|
<File Name="sys_controller/fatfs/source/ff.h"/>
|
||||||
|
<File Name="sys_controller/fatfs/source/ff.c"/>
|
||||||
|
<File Name="sys_controller/fatfs/source/diskio.h"/>
|
||||||
|
<File Name="sys_controller/fatfs/source/diskio.c"/>
|
||||||
|
<File Name="sys_controller/fatfs/source/ffunicode.c"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<File Name="sys_controller/av_controller.c"/>
|
||||||
|
<VirtualDirectory Name="src">
|
||||||
|
<File Name="sys_controller/src/file.c"/>
|
||||||
|
<File Name="sys_controller/src/sdcard.c"/>
|
||||||
|
<File Name="sys_controller/src/firmware.c"/>
|
||||||
|
<File Name="sys_controller/src/controls.c"/>
|
||||||
|
<File Name="sys_controller/src/avconfig.c"/>
|
||||||
|
<File Name="sys_controller/src/userdata.c"/>
|
||||||
|
<File Name="sys_controller/src/flash.c"/>
|
||||||
|
<File Name="sys_controller/src/menu.c"/>
|
||||||
|
<File Name="sys_controller/src/utils.c"/>
|
||||||
|
<File Name="sys_controller/src/video_modes_list.c"/>
|
||||||
|
<File Name="sys_controller/src/video_modes.c"/>
|
||||||
|
<File Name="sys_controller/src/fat16_export.c"/>
|
||||||
|
<File Name="sys_controller/src/lcd.c"/>
|
||||||
|
<File Name="sys_controller/src/lumacode_palettes.c"/>
|
||||||
|
<File Name="sys_controller/src/shmask_arrays.c"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="ic_drivers">
|
||||||
|
<VirtualDirectory Name="pcm1862">
|
||||||
|
<File Name="sys_controller/ic_drivers/pcm1862/pcm1862_regs.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/pcm1862/pcm1862.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/pcm1862/pcm1862.h"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="st7032">
|
||||||
|
<File Name="sys_controller/ic_drivers/st7032/st7032.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/st7032/st7032.h"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="tvp7002">
|
||||||
|
<File Name="sys_controller/ic_drivers/tvp7002/tvp7002.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/tvp7002/tvp7002.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/tvp7002/tvp7002_regs.h"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="it6613">
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/typedef.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/edid.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/it6613_sys.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/it6613.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/hdmitx.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/HDMI_COMMON.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/it6613_sys.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/EDID.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/hdmitx_nios2.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/it6613_drv.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/it6613.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/HDMI_TX.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/HDMI_TX.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/it6613/it6613_drv.c"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="sh1107">
|
||||||
|
<File Name="sys_controller/ic_drivers/sh1107/font12.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/sh1107/sh1107.h"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/sh1107/sh1107.c"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="ths7353">
|
||||||
|
<File Name="sys_controller/ic_drivers/ths7353/ths7353.c"/>
|
||||||
|
<File Name="sys_controller/ic_drivers/ths7353/ths7353.h"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="ulibSD">
|
||||||
|
<File Name="sys_controller/ulibSD/sd_io.c"/>
|
||||||
|
<File Name="sys_controller/ulibSD/integer.h"/>
|
||||||
|
<File Name="sys_controller/ulibSD/spi_io.c"/>
|
||||||
|
<File Name="sys_controller/ulibSD/sd_io.h"/>
|
||||||
|
<File Name="sys_controller/ulibSD/spi_io.h"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="inc">
|
||||||
|
<File Name="sys_controller/inc/file.h"/>
|
||||||
|
<File Name="sys_controller/inc/firmware.h"/>
|
||||||
|
<File Name="sys_controller/inc/controls.h"/>
|
||||||
|
<File Name="sys_controller/inc/av_controller.h"/>
|
||||||
|
<File Name="sys_controller/inc/menu.h"/>
|
||||||
|
<File Name="sys_controller/inc/sdcard.h"/>
|
||||||
|
<File Name="sys_controller/inc/utils.h"/>
|
||||||
|
<File Name="sys_controller/inc/avconfig.h"/>
|
||||||
|
<File Name="sys_controller/inc/video_modes.h"/>
|
||||||
|
<File Name="sys_controller/inc/fat16_export.h"/>
|
||||||
|
<File Name="sys_controller/inc/flash.h"/>
|
||||||
|
<File Name="sys_controller/inc/userdata.h"/>
|
||||||
|
<File Name="sys_controller/inc/lcd.h"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
<VirtualDirectory Name="config">
|
||||||
|
<File Name="sys_controller/config/ffconf.h"/>
|
||||||
|
<File Name="sys_controller/config/sysconfig.h"/>
|
||||||
|
</VirtualDirectory>
|
||||||
|
</VirtualDirectory>
|
||||||
<Reconciliation>
|
<Reconciliation>
|
||||||
<Regexes/>
|
<Regexes/>
|
||||||
<Excludepaths/>
|
<Excludepaths/>
|
||||||
@ -33,77 +130,8 @@
|
|||||||
<Extensions>
|
<Extensions>
|
||||||
<![CDATA[*.cpp;*.c;*.h;*.hpp;*.xrc;*.wxcp;*.fbp]]>
|
<![CDATA[*.cpp;*.c;*.h;*.hpp;*.xrc;*.wxcp;*.fbp]]>
|
||||||
</Extensions>
|
</Extensions>
|
||||||
<Topleveldir>./</Topleveldir>
|
<Topleveldir>/home/markus/Code/ossc/software/</Topleveldir>
|
||||||
</Reconciliation>
|
</Reconciliation>
|
||||||
<VirtualDirectory Name="sys_controller">
|
|
||||||
<VirtualDirectory Name="ths7353">
|
|
||||||
<File Name="sys_controller/ths7353/ths7353.h"/>
|
|
||||||
<File Name="sys_controller/ths7353/ths7353.c"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<VirtualDirectory Name="it6613">
|
|
||||||
<File Name="sys_controller/it6613/it6613_drv.c"/>
|
|
||||||
<File Name="sys_controller/it6613/HDMI_TX.c"/>
|
|
||||||
<File Name="sys_controller/it6613/HDMI_TX.h"/>
|
|
||||||
<File Name="sys_controller/it6613/it6613.c"/>
|
|
||||||
<File Name="sys_controller/it6613/it6613_drv.h"/>
|
|
||||||
<File Name="sys_controller/it6613/hdmitx_nios2.c"/>
|
|
||||||
<File Name="sys_controller/it6613/EDID.c"/>
|
|
||||||
<File Name="sys_controller/it6613/it6613_sys.h"/>
|
|
||||||
<File Name="sys_controller/it6613/HDMI_COMMON.h"/>
|
|
||||||
<File Name="sys_controller/it6613/hdmitx.h"/>
|
|
||||||
<File Name="sys_controller/it6613/it6613.h"/>
|
|
||||||
<File Name="sys_controller/it6613/it6613_sys.c"/>
|
|
||||||
<File Name="sys_controller/it6613/edid.h"/>
|
|
||||||
<File Name="sys_controller/it6613/typedef.h"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<VirtualDirectory Name="spi_charlcd">
|
|
||||||
<File Name="sys_controller/spi_charlcd/lcd.c"/>
|
|
||||||
<File Name="sys_controller/spi_charlcd/lcd.h"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<VirtualDirectory Name="tvp7002">
|
|
||||||
<File Name="sys_controller/tvp7002/tvp7002_regs.h"/>
|
|
||||||
<File Name="sys_controller/tvp7002/tvp7002.h"/>
|
|
||||||
<File Name="sys_controller/tvp7002/tvp7002.c"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<VirtualDirectory Name="memory">
|
|
||||||
<File Name="sys_controller/memory/flash.h"/>
|
|
||||||
<File Name="sys_controller/memory/flash.c"/>
|
|
||||||
<File Name="sys_controller/memory/sdcard.h"/>
|
|
||||||
<File Name="sys_controller/memory/sdcard.c"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<VirtualDirectory Name="ossc">
|
|
||||||
<File Name="sys_controller/ossc/utils.h"/>
|
|
||||||
<File Name="sys_controller/ossc/utils.c"/>
|
|
||||||
<File Name="sys_controller/ossc/menu.c"/>
|
|
||||||
<File Name="sys_controller/ossc/menu.h"/>
|
|
||||||
<File Name="sys_controller/ossc/sysconfig.h"/>
|
|
||||||
<File Name="sys_controller/ossc/controls.h"/>
|
|
||||||
<File Name="sys_controller/ossc/controls.c"/>
|
|
||||||
<File Name="sys_controller/ossc/avconfig.h"/>
|
|
||||||
<File Name="sys_controller/ossc/avconfig.c"/>
|
|
||||||
<File Name="sys_controller/ossc/av_controller.c"/>
|
|
||||||
<File Name="sys_controller/ossc/av_controller.h"/>
|
|
||||||
<File Name="sys_controller/ossc/firmware.h"/>
|
|
||||||
<File Name="sys_controller/ossc/firmware.c"/>
|
|
||||||
<File Name="sys_controller/ossc/userdata.h"/>
|
|
||||||
<File Name="sys_controller/ossc/userdata.c"/>
|
|
||||||
<File Name="sys_controller/ossc/video_modes.h"/>
|
|
||||||
<File Name="sys_controller/ossc/video_modes.c"/>
|
|
||||||
<File Name="sys_controller/ossc/video_modes_list.c"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<VirtualDirectory Name="ulibSD">
|
|
||||||
<File Name="sys_controller/ulibSD/integer.h"/>
|
|
||||||
<File Name="sys_controller/ulibSD/sd_io.c"/>
|
|
||||||
<File Name="sys_controller/ulibSD/sd_io.h"/>
|
|
||||||
<File Name="sys_controller/ulibSD/spi_io.h"/>
|
|
||||||
<File Name="sys_controller/ulibSD/spi_io.c"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<VirtualDirectory Name="pcm1862">
|
|
||||||
<File Name="sys_controller/pcm1862/pcm1862.c"/>
|
|
||||||
<File Name="sys_controller/pcm1862/pcm1862.h"/>
|
|
||||||
<File Name="sys_controller/pcm1862/pcm1862_regs.h"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<Description/>
|
<Description/>
|
||||||
<Dependencies/>
|
<Dependencies/>
|
||||||
<Dependencies Name="Debug"/>
|
<Dependencies Name="Debug"/>
|
||||||
@ -142,7 +170,7 @@
|
|||||||
<Target Name="Ack BSP update">cd ../sys_controller_bsp && touch bsp_timestamp</Target>
|
<Target Name="Ack BSP update">cd ../sys_controller_bsp && touch bsp_timestamp</Target>
|
||||||
<RebuildCommand/>
|
<RebuildCommand/>
|
||||||
<CleanCommand>make clean</CleanCommand>
|
<CleanCommand>make clean</CleanCommand>
|
||||||
<BuildCommand>make ENABLE_AUDIO=y APP_CFLAGS_DEBUG_LEVEL="-DDEBUG" generate_hex</BuildCommand>
|
<BuildCommand>make ENABLE_AUDIO=y APP_CFLAGS_DEBUG_LEVEL="-DDEBUG"</BuildCommand>
|
||||||
<PreprocessFileCommand/>
|
<PreprocessFileCommand/>
|
||||||
<SingleFileCommand/>
|
<SingleFileCommand/>
|
||||||
<MakefileGenerationCommand/>
|
<MakefileGenerationCommand/>
|
||||||
@ -188,7 +216,7 @@
|
|||||||
<Target Name="Ack BSP update">cd ../sys_controller_bsp && touch bsp_timestamp</Target>
|
<Target Name="Ack BSP update">cd ../sys_controller_bsp && touch bsp_timestamp</Target>
|
||||||
<RebuildCommand/>
|
<RebuildCommand/>
|
||||||
<CleanCommand>make clean</CleanCommand>
|
<CleanCommand>make clean</CleanCommand>
|
||||||
<BuildCommand>make ENABLE_AUDIO=y generate_hex</BuildCommand>
|
<BuildCommand>make ENABLE_AUDIO=y</BuildCommand>
|
||||||
<PreprocessFileCommand/>
|
<PreprocessFileCommand/>
|
||||||
<SingleFileCommand/>
|
<SingleFileCommand/>
|
||||||
<MakefileGenerationCommand/>
|
<MakefileGenerationCommand/>
|
||||||
|
|||||||
@ -142,37 +142,44 @@ ACDS_VERSION := 14.1
|
|||||||
ELF := sys_controller.elf
|
ELF := sys_controller.elf
|
||||||
|
|
||||||
# Paths to C, C++, and assembly source files.
|
# Paths to C, C++, and assembly source files.
|
||||||
C_SRCS += it6613/EDID.c
|
C_SRCS += av_controller.c
|
||||||
C_SRCS += it6613/HDMI_TX.c
|
C_SRCS += src/avconfig.c
|
||||||
C_SRCS += it6613/hdmitx_nios2.c
|
C_SRCS += src/utils.c
|
||||||
C_SRCS += it6613/it6613.c
|
C_SRCS += src/controls.c
|
||||||
C_SRCS += it6613/it6613_drv.c
|
|
||||||
C_SRCS += it6613/it6613_sys.c
|
|
||||||
C_SRCS += tvp7002/tvp7002.c
|
|
||||||
C_SRCS += ths7353/ths7353.c
|
|
||||||
C_SRCS += pcm1862/pcm1862.c
|
|
||||||
C_SRCS += spi_charlcd/lcd.c
|
|
||||||
C_SRCS += memory/flash.c
|
|
||||||
C_SRCS += memory/sdcard.c
|
|
||||||
C_SRCS += ossc/av_controller.c
|
|
||||||
C_SRCS += ossc/avconfig.c
|
|
||||||
C_SRCS += ossc/controls.c
|
|
||||||
C_SRCS += ossc/firmware.c
|
|
||||||
C_SRCS += ossc/fat16_export.c
|
|
||||||
ifeq ($(OSDLANG),JP)
|
ifeq ($(OSDLANG),JP)
|
||||||
C_SRCS += ossc/menu_sjis.c
|
C_SRCS += src/menu_sjis.c
|
||||||
else
|
else
|
||||||
C_SRCS += ossc/menu.c
|
C_SRCS += src/menu.c
|
||||||
endif
|
endif
|
||||||
|
C_SRCS += src/video_modes.c
|
||||||
|
C_SRCS += src/flash.c
|
||||||
|
C_SRCS += src/firmware.c
|
||||||
ifeq ($(OSDLANG),JP)
|
ifeq ($(OSDLANG),JP)
|
||||||
C_SRCS += ossc/userdata_sjis.c
|
C_SRCS += src/userdata_sjis.c
|
||||||
else
|
else
|
||||||
C_SRCS += ossc/userdata.c
|
C_SRCS += src/userdata.c
|
||||||
endif
|
endif
|
||||||
C_SRCS += ossc/utils.c
|
C_SRCS += src/sdcard.c
|
||||||
C_SRCS += ossc/video_modes.c
|
C_SRCS += src/fat16_export.c
|
||||||
|
C_SRCS += src/lcd.c
|
||||||
|
C_SRCS += src/file.c
|
||||||
|
C_SRCS += ic_drivers/it6613/EDID.c
|
||||||
|
C_SRCS += ic_drivers/it6613/HDMI_TX.c
|
||||||
|
C_SRCS += ic_drivers/it6613/hdmitx_nios2.c
|
||||||
|
C_SRCS += ic_drivers/it6613/it6613.c
|
||||||
|
C_SRCS += ic_drivers/it6613/it6613_drv.c
|
||||||
|
C_SRCS += ic_drivers/it6613/it6613_sys.c
|
||||||
|
C_SRCS += ic_drivers/tvp7002/tvp7002.c
|
||||||
|
C_SRCS += ic_drivers/ths7353/ths7353.c
|
||||||
|
C_SRCS += ic_drivers/pcm1862/pcm1862.c
|
||||||
|
C_SRCS += ic_drivers/st7032/st7032.c
|
||||||
|
C_SRCS += ic_drivers/sh1107/sh1107.c
|
||||||
C_SRCS += ulibSD/sd_io.c
|
C_SRCS += ulibSD/sd_io.c
|
||||||
C_SRCS += ulibSD/spi_io.c
|
C_SRCS += ulibSD/spi_io.c
|
||||||
|
C_SRCS += fatfs/source/diskio.c
|
||||||
|
C_SRCS += fatfs/source/ff.c
|
||||||
|
C_SRCS += fatfs/source/ffsystem.c
|
||||||
|
C_SRCS += fatfs/source/ffunicode.c
|
||||||
CXX_SRCS :=
|
CXX_SRCS :=
|
||||||
ASM_SRCS := crt0.boot_E.S
|
ASM_SRCS := crt0.boot_E.S
|
||||||
|
|
||||||
@ -190,18 +197,18 @@ CREATE_ELF_DERIVED_FILES := 0
|
|||||||
CREATE_LINKER_MAP := 1
|
CREATE_LINKER_MAP := 1
|
||||||
|
|
||||||
# Common arguments for ALT_CFLAGSs
|
# Common arguments for ALT_CFLAGSs
|
||||||
APP_CFLAGS_DEFINED_SYMBOLS :=
|
APP_CFLAGS_DEFINED_SYMBOLS := -DPICOLIBC_INTEGER_PRINTF_SCANF
|
||||||
ifeq ($(ENABLE_AUDIO),y)
|
|
||||||
APP_CFLAGS_DEFINED_SYMBOLS += -DENABLE_AUDIO
|
|
||||||
endif
|
|
||||||
ifeq ($(OSDLANG),JP)
|
ifeq ($(OSDLANG),JP)
|
||||||
APP_CFLAGS_DEFINED_SYMBOLS += -DOSDLANG_JP
|
APP_CFLAGS_DEFINED_SYMBOLS += -DOSDLANG_JP
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(HAS_SH1107),y)
|
||||||
|
APP_CFLAGS_DEFINED_SYMBOLS += -DHAS_SH1107
|
||||||
|
endif
|
||||||
APP_CFLAGS_UNDEFINED_SYMBOLS :=
|
APP_CFLAGS_UNDEFINED_SYMBOLS :=
|
||||||
APP_CFLAGS_OPTIMIZATION := -Os
|
APP_CFLAGS_OPTIMIZATION := -Os
|
||||||
APP_CFLAGS_DEBUG_LEVEL :=
|
APP_CFLAGS_DEBUG_LEVEL :=
|
||||||
APP_CFLAGS_WARNINGS := -Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -Wno-packed-bitfield-compat
|
APP_CFLAGS_WARNINGS := -Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -Wno-packed-bitfield-compat
|
||||||
APP_CFLAGS_USER_FLAGS := -fdata-sections -ffunction-sections -fshort-enums -fgnu89-inline -flto
|
APP_CFLAGS_USER_FLAGS := -fdata-sections -ffunction-sections -fshort-enums -fgnu89-inline -flto -msmall-data-limit=0
|
||||||
|
|
||||||
APP_ASFLAGS_USER :=
|
APP_ASFLAGS_USER :=
|
||||||
APP_LDFLAGS_USER := -Wl,--gc-sections
|
APP_LDFLAGS_USER := -Wl,--gc-sections
|
||||||
@ -216,14 +223,18 @@ SYS_LIB :=
|
|||||||
BSP_ROOT_DIR := ../sys_controller_bsp/
|
BSP_ROOT_DIR := ../sys_controller_bsp/
|
||||||
|
|
||||||
# List of application specific include directories, library directories and library names
|
# List of application specific include directories, library directories and library names
|
||||||
APP_INCLUDE_DIRS += it6613
|
APP_INCLUDE_DIRS += /usr/lib/picolibc/riscv64-unknown-elf/include
|
||||||
APP_INCLUDE_DIRS += tvp7002
|
APP_INCLUDE_DIRS += config
|
||||||
APP_INCLUDE_DIRS += ths7353
|
APP_INCLUDE_DIRS += inc
|
||||||
APP_INCLUDE_DIRS += pcm1862
|
APP_INCLUDE_DIRS += ic_drivers/it6613
|
||||||
APP_INCLUDE_DIRS += spi_charlcd
|
APP_INCLUDE_DIRS += ic_drivers/tvp7002
|
||||||
|
APP_INCLUDE_DIRS += ic_drivers/ths7353
|
||||||
|
APP_INCLUDE_DIRS += ic_drivers/pcm1862
|
||||||
|
APP_INCLUDE_DIRS += ic_drivers/st7032
|
||||||
|
APP_INCLUDE_DIRS += ic_drivers/sh1107
|
||||||
APP_INCLUDE_DIRS += memory
|
APP_INCLUDE_DIRS += memory
|
||||||
APP_INCLUDE_DIRS += ulibSD
|
APP_INCLUDE_DIRS += ulibSD
|
||||||
APP_INCLUDE_DIRS += ossc
|
APP_INCLUDE_DIRS += fatfs/source
|
||||||
APP_LIBRARY_DIRS :=
|
APP_LIBRARY_DIRS :=
|
||||||
APP_LIBRARY_NAMES :=
|
APP_LIBRARY_NAMES :=
|
||||||
|
|
||||||
@ -257,7 +268,7 @@ endif
|
|||||||
all:
|
all:
|
||||||
@$(ECHO) [$(APP_NAME) build complete]
|
@$(ECHO) [$(APP_NAME) build complete]
|
||||||
|
|
||||||
all : build_pre_process libs app build_post_process
|
all : build_pre_process libs app mem_init_generate_new build_post_process
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@ -396,7 +407,7 @@ APP_ASFLAGS := $(APP_ASM_INC_DIRS) \
|
|||||||
$(ASFLAGS)
|
$(ASFLAGS)
|
||||||
|
|
||||||
# Arguments only for the linker.
|
# Arguments only for the linker.
|
||||||
APP_LDFLAGS := $(APP_LDFLAGS_USER) --specs=nano.specs -nostartfiles
|
APP_LDFLAGS := $(APP_LDFLAGS_USER) --specs=picolibc.specs -nostartfiles
|
||||||
|
|
||||||
ifneq ($(LINKER_SCRIPT),)
|
ifneq ($(LINKER_SCRIPT),)
|
||||||
APP_LDFLAGS += -T'$(LINKER_SCRIPT)'
|
APP_LDFLAGS += -T'$(LINKER_SCRIPT)'
|
||||||
@ -657,11 +668,11 @@ build_post_process :
|
|||||||
# included makefile fragment.
|
# included makefile fragment.
|
||||||
#
|
#
|
||||||
ifeq ($(DEFAULT_CROSS_COMPILE),)
|
ifeq ($(DEFAULT_CROSS_COMPILE),)
|
||||||
DEFAULT_CROSS_COMPILE := riscv32-unknown-elf-
|
DEFAULT_CROSS_COMPILE := riscv64-unknown-elf-
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(DEFAULT_STACKREPORT),)
|
ifeq ($(DEFAULT_STACKREPORT),)
|
||||||
DEFAULT_STACKREPORT := riscv32-unknown-elf-size
|
DEFAULT_STACKREPORT := riscv64-unknown-elf-size
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(DEFAULT_DOWNLOAD),)
|
ifeq ($(DEFAULT_DOWNLOAD),)
|
||||||
@ -715,7 +726,7 @@ AR := $(CROSS_COMPILE)ar
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(origin LD),default)
|
ifeq ($(origin LD),default)
|
||||||
LD := $(CROSS_COMPILE)g++
|
LD := $(CROSS_COMPILE)gcc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(origin RM),default)
|
ifeq ($(origin RM),default)
|
||||||
@ -760,7 +771,7 @@ ifeq ($(MKDIR),)
|
|||||||
MKDIR := $(DEFAULT_MKDIR)
|
MKDIR := $(DEFAULT_MKDIR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
RV_OBJCOPY = riscv32-unknown-elf-objcopy
|
RV_OBJCOPY = riscv64-unknown-elf-objcopy
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# PATTERN RULES TO BUILD OBJECTS
|
# PATTERN RULES TO BUILD OBJECTS
|
||||||
@ -975,7 +986,7 @@ clean : clean_elf_derived_files
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
@$(RM) -r $(ELF) $(OBJDUMP_NAME) $(LINKER_MAP_NAME) $(OBJ_ROOT_DIR) $(RUNTIME_ROOT_DIR) $(FORCE_REBUILD_DEP_LIST) ossc/menu_sjis.c ossc/userdata_sjis.c
|
@$(RM) -r $(ELF) $(OBJDUMP_NAME) $(LINKER_MAP_NAME) $(OBJ_ROOT_DIR) $(RUNTIME_ROOT_DIR) $(FORCE_REBUILD_DEP_LIST) src/menu_sjis.c src/userdata_sjis.c
|
||||||
@$(ECHO) [$(APP_NAME) clean complete]
|
@$(ECHO) [$(APP_NAME) clean complete]
|
||||||
|
|
||||||
# Clean just the BSP.
|
# Clean just the BSP.
|
||||||
@ -1132,22 +1143,38 @@ print-elf-name:
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# CUSTOM TARGETS
|
# CUSTOM TARGETS
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
ossc/menu_sjis.c: ossc/menu.c
|
src/menu_sjis.c: src/menu.c
|
||||||
iconv -f UTF-8 -t SHIFT-JIS ossc/menu.c > ossc/menu_sjis.c
|
iconv -f UTF-8 -t SHIFT-JIS src/menu.c > src/menu_sjis.c
|
||||||
|
|
||||||
ossc/userdata_sjis.c: ossc/userdata.c
|
src/userdata_sjis.c: src/userdata.c
|
||||||
iconv -f UTF-8 -t SHIFT-JIS ossc/userdata.c > ossc/userdata_sjis.c
|
iconv -f UTF-8 -t SHIFT-JIS src/userdata.c > src/userdata_sjis.c
|
||||||
|
|
||||||
mem_init/sys_onchip_memory2_0.hex: sys_controller.elf
|
mem_init/flash.hex: sys_controller.elf
|
||||||
$(RV_OBJCOPY) --change-addresses -0x10000 -O binary --gap-fill 0 $< mem_init/sys_onchip_memory2_0.bin
|
$(RV_OBJCOPY) --change-addresses -0x02050000 -O binary --gap-fill 0 $< mem_init/flash.bin
|
||||||
../../tools/bin2hex 4 mem_init/sys_onchip_memory2_0.bin mem_init/sys_onchip_memory2_0.hex
|
$(RV_OBJCOPY) --change-addresses -0x02050000 -O ihex --gap-fill 0 $< mem_init/flash.hex
|
||||||
|
mkdir -p mem_init/chunks
|
||||||
|
rm -f mem_init/chunks/*
|
||||||
|
split -d -b 1024 -a 4 mem_init/flash.bin mem_init/chunks/flash.
|
||||||
|
|
||||||
.PHONY: mem_init_generate_new
|
.PHONY: mem_init_generate_new
|
||||||
mem_init_generate_new: mem_init/sys_onchip_memory2_0.hex
|
mem_init_generate_new: mem_init/flash.hex
|
||||||
|
|
||||||
.PHONY: generate_hex
|
.PHONY: regenerate_hex
|
||||||
generate_hex: clean mem_init_generate_new
|
regenerate_hex: clean mem_init_generate_new
|
||||||
|
|
||||||
.PHONY: rv-reprogram
|
.PHONY: rv-reprogram
|
||||||
rv-reprogram: mem_init_generate_new
|
rv-reprogram: mem_init_generate_new
|
||||||
|
jtagconfig
|
||||||
system-console -cli --script ../../scripts/rv-reprogram.tcl
|
system-console -cli --script ../../scripts/rv-reprogram.tcl
|
||||||
|
|
||||||
|
rv-bt:
|
||||||
|
jtagconfig
|
||||||
|
system-console -cli --script ../../scripts/rv-bt.tcl
|
||||||
|
|
||||||
|
rv-reboot:
|
||||||
|
jtagconfig
|
||||||
|
system-console -cli --script ../../scripts/rv-reboot.tcl
|
||||||
|
|
||||||
|
rv-ndmreset:
|
||||||
|
jtagconfig
|
||||||
|
system-console -cli --script ../../scripts/rv-ndmreset.tcl
|
||||||
|
|||||||
@ -42,6 +42,9 @@
|
|||||||
#include "sd_io.h"
|
#include "sd_io.h"
|
||||||
#include "sys/alt_timestamp.h"
|
#include "sys/alt_timestamp.h"
|
||||||
|
|
||||||
|
#include "src/shmask_arrays.c"
|
||||||
|
#include "src/lumacode_palettes.c"
|
||||||
|
|
||||||
#define MIN_LINES_PROGRESSIVE 200
|
#define MIN_LINES_PROGRESSIVE 200
|
||||||
#define MIN_LINES_INTERLACED 400
|
#define MIN_LINES_INTERLACED 400
|
||||||
#define STATUS_TIMEOUT_US 25000
|
#define STATUS_TIMEOUT_US 25000
|
||||||
@ -62,18 +65,24 @@ extern alt_u16 rc_keymap_default[REMOTE_MAX_KEYS];
|
|||||||
extern alt_u32 remote_code;
|
extern alt_u32 remote_code;
|
||||||
extern alt_u32 btn_code, btn_code_prev;
|
extern alt_u32 btn_code, btn_code_prev;
|
||||||
extern alt_u8 remote_rpt, remote_rpt_prev;
|
extern alt_u8 remote_rpt, remote_rpt_prev;
|
||||||
extern avconfig_t tc, tc_default;
|
extern avconfig_t tc;
|
||||||
extern alt_u8 vm_sel;
|
extern alt_u8 vm_sel;
|
||||||
extern char target_profile_name[PROFILE_NAME_LEN+1];
|
extern char target_profile_name[USERDATA_NAME_LEN+1];
|
||||||
|
|
||||||
tvp_input_t target_tvp;
|
tvp_input_t target_tvp;
|
||||||
tvp_sync_input_t target_tvp_sync;
|
tvp_sync_input_t target_tvp_sync;
|
||||||
alt_u8 target_type;
|
alt_u8 target_type;
|
||||||
alt_u8 update_cur_vm;
|
alt_u8 update_cur_vm;
|
||||||
|
|
||||||
alt_u8 profile_sel, profile_sel_menu, input_profiles[AV_LAST], lt_sel, def_input, profile_link, lcd_bl_timeout;
|
// Default settings
|
||||||
alt_u8 osd_enable=1, osd_status_timeout=1;
|
const settings_t ts_default = {
|
||||||
alt_u8 auto_input, auto_av1_ypbpr, auto_av2_ypbpr = 1, auto_av3_ypbpr;
|
.osd_enable = 1,
|
||||||
|
.osd_status_timeout = 1,
|
||||||
|
.osd_highlight_color = 4,
|
||||||
|
.auto_av2_ypbpr = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
alt_u8 profile_sel, profile_sel_menu, sd_profile_sel_menu, input_profiles[AV_LAST], lt_sel;
|
||||||
|
|
||||||
char row1[LCD_ROW_LEN+1], row2[LCD_ROW_LEN+1], menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
char row1[LCD_ROW_LEN+1], row2[LCD_ROW_LEN+1], menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
||||||
|
|
||||||
@ -82,6 +91,11 @@ avinput_t target_input;
|
|||||||
|
|
||||||
alt_u8 pcm1862_active;
|
alt_u8 pcm1862_active;
|
||||||
|
|
||||||
|
flash_ctrl_dev flashctrl_dev = {.regs = (volatile gen_flash_if_regs*)INTEL_GENERIC_SERIAL_FLASH_INTERFACE_TOP_0_AVL_CSR_BASE,
|
||||||
|
.flash_size = 0x0200000};
|
||||||
|
|
||||||
|
rem_update_dev rem_reconfig_dev = {.regs = (volatile rem_update_regs*)0x0002a000};
|
||||||
|
|
||||||
uint8_t sl_def_iv_x, sl_def_iv_y;
|
uint8_t sl_def_iv_x, sl_def_iv_y;
|
||||||
|
|
||||||
alt_u32 read_it2(alt_u32 regaddr);
|
alt_u32 read_it2(alt_u32 regaddr);
|
||||||
@ -89,6 +103,8 @@ alt_u32 read_it2(alt_u32 regaddr);
|
|||||||
mode_data_t vmode_in, vmode_out;
|
mode_data_t vmode_in, vmode_out;
|
||||||
vm_proc_config_t vm_conf;
|
vm_proc_config_t vm_conf;
|
||||||
|
|
||||||
|
settings_t cs, ts;
|
||||||
|
|
||||||
// Manually (see cyiv-51005.pdf) or automatically (MIF/HEX from PLL megafunction) generated config may not
|
// Manually (see cyiv-51005.pdf) or automatically (MIF/HEX from PLL megafunction) generated config may not
|
||||||
// provide fully correct scan chain data (e.g. mismatches in C3) and lead to incorrect PLL configuration.
|
// provide fully correct scan chain data (e.g. mismatches in C3) and lead to incorrect PLL configuration.
|
||||||
// To get correct scan chain data, do the following:
|
// To get correct scan chain data, do the following:
|
||||||
@ -121,11 +137,21 @@ volatile sc_regs *sc = (volatile sc_regs*)SC_CONFIG_0_BASE;
|
|||||||
volatile osd_regs *osd = (volatile osd_regs*)OSD_GENERATOR_0_BASE;
|
volatile osd_regs *osd = (volatile osd_regs*)OSD_GENERATOR_0_BASE;
|
||||||
volatile pll_reconfig_regs *pll_reconfig = (volatile pll_reconfig_regs*)PLL_RECONFIG_0_BASE;
|
volatile pll_reconfig_regs *pll_reconfig = (volatile pll_reconfig_regs*)PLL_RECONFIG_0_BASE;
|
||||||
|
|
||||||
|
c_shmask_t c_shmask;
|
||||||
|
const shmask_data_arr* shmask_data_arr_list[] = {NULL, &shmask_agrille, &shmask_tv, &shmask_pvm, &shmask_pvm_2530, &shmask_xc_3315c, &shmask_c_1084, &shmask_jvc, &shmask_vga, &c_shmask.arr};
|
||||||
|
int shmask_loaded_array = 0;
|
||||||
|
int shmask_loaded_str = -1;
|
||||||
|
#define SHMASKS_SIZE (sizeof(shmask_data_arr_list) / sizeof((shmask_data_arr_list)[0]))
|
||||||
|
|
||||||
|
c_lc_palette_set_t c_lc_palette_set;
|
||||||
|
const lc_palette_set* lc_palette_set_list[] = {&lc_palette_pal, &c_lc_palette_set.pal};
|
||||||
|
int loaded_lc_palette = -1;
|
||||||
|
|
||||||
void ui_disp_menu(alt_u8 osd_mode)
|
void ui_disp_menu(alt_u8 osd_mode)
|
||||||
{
|
{
|
||||||
alt_u8 menu_page;
|
uint8_t menu_page;
|
||||||
|
|
||||||
if ((osd_mode == 1) || (osd_enable == 2)) {
|
if ((osd_mode == 1) || (ts.osd_enable == 2)) {
|
||||||
strncpy((char*)osd->osd_array.data[0][0], menu_row1, OSD_CHAR_COLS);
|
strncpy((char*)osd->osd_array.data[0][0], menu_row1, OSD_CHAR_COLS);
|
||||||
strncpy((char*)osd->osd_array.data[1][0], menu_row2, OSD_CHAR_COLS);
|
strncpy((char*)osd->osd_array.data[1][0], menu_row2, OSD_CHAR_COLS);
|
||||||
osd->osd_row_color.mask = 0;
|
osd->osd_row_color.mask = 0;
|
||||||
@ -155,7 +181,6 @@ void ui_disp_status(alt_u8 refresh_osd_timer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_AUDIO
|
|
||||||
inline void SetupAudio(tx_mode_t mode)
|
inline void SetupAudio(tx_mode_t mode)
|
||||||
{
|
{
|
||||||
// shut down audio-tx before setting new config (recommended for changing audio-tx config)
|
// shut down audio-tx before setting new config (recommended for changing audio-tx config)
|
||||||
@ -177,7 +202,6 @@ inline void SetupAudio(tx_mode_t mode)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
inline void TX_enable(tx_mode_t mode)
|
inline void TX_enable(tx_mode_t mode)
|
||||||
{
|
{
|
||||||
@ -185,6 +209,7 @@ inline void TX_enable(tx_mode_t mode)
|
|||||||
SetAVMute(TRUE);
|
SetAVMute(TRUE);
|
||||||
DisableVideoOutput();
|
DisableVideoOutput();
|
||||||
EnableAVIInfoFrame(FALSE, NULL);
|
EnableAVIInfoFrame(FALSE, NULL);
|
||||||
|
EnableGPInfoFrame(FALSE, NULL);
|
||||||
|
|
||||||
//Setup TX configuration
|
//Setup TX configuration
|
||||||
//TODO: set pclk target and VIC dynamically
|
//TODO: set pclk target and VIC dynamically
|
||||||
@ -192,16 +217,16 @@ inline void TX_enable(tx_mode_t mode)
|
|||||||
|
|
||||||
if (mode != TX_DVI) {
|
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_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);
|
if (tc.hdmi_vrr)
|
||||||
HDMITX_SetVRRInfoFrame(tc.hdmi_vrr);
|
HDMITX_SetVRRInfoFrame(tc.hdmi_vrr);
|
||||||
|
if (tc.hdmi_hdr)
|
||||||
|
HDMITX_SetHDRInfoFrame(tc.hdmi_hdr ? 3 : 0);
|
||||||
cm.cc.hdmi_itc = tc.hdmi_itc;
|
cm.cc.hdmi_itc = tc.hdmi_itc;
|
||||||
cm.cc.hdmi_hdr = tc.hdmi_hdr;
|
cm.cc.hdmi_hdr = tc.hdmi_hdr;
|
||||||
cm.cc.hdmi_vrr = tc.hdmi_vrr;
|
cm.cc.hdmi_vrr = tc.hdmi_vrr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_AUDIO
|
|
||||||
SetupAudio(mode);
|
SetupAudio(mode);
|
||||||
#endif
|
|
||||||
|
|
||||||
// start TX
|
// start TX
|
||||||
SetAVMute(FALSE);
|
SetAVMute(FALSE);
|
||||||
@ -412,7 +437,9 @@ status_t get_status(tvp_sync_input_t syncinput)
|
|||||||
if (memcmp(&tc.col, &cm.cc.col, sizeof(color_setup_t)))
|
if (memcmp(&tc.col, &cm.cc.col, sizeof(color_setup_t)))
|
||||||
tvp_set_gain_offset(&tc.col);
|
tvp_set_gain_offset(&tc.col);
|
||||||
|
|
||||||
#ifdef ENABLE_AUDIO
|
if (tc.full_vs_bypass != cm.cc.full_vs_bypass)
|
||||||
|
tvp_set_full_vs_bypass(tc.full_vs_bypass);
|
||||||
|
|
||||||
if ((tc.audio_dw_sampl != cm.cc.audio_dw_sampl) ||
|
if ((tc.audio_dw_sampl != cm.cc.audio_dw_sampl) ||
|
||||||
#ifdef MANUAL_CTS
|
#ifdef MANUAL_CTS
|
||||||
update_cur_vm ||
|
update_cur_vm ||
|
||||||
@ -428,7 +455,6 @@ status_t get_status(tvp_sync_input_t syncinput)
|
|||||||
pcm_set_stereo_mode(tc.audio_mono);
|
pcm_set_stereo_mode(tc.audio_mono);
|
||||||
SetupAudio(cm.cc.tx_mode);
|
SetupAudio(cm.cc.tx_mode);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
cm.cc = tc;
|
cm.cc = tc;
|
||||||
update_cur_vm = 0;
|
update_cur_vm = 0;
|
||||||
@ -436,9 +462,14 @@ status_t get_status(tvp_sync_input_t syncinput)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_sc_config(mode_data_t *vm_in, mode_data_t *vm_out, vm_proc_config_t *vm_conf, avconfig_t *avconfig)
|
void update_sc_config()
|
||||||
{
|
{
|
||||||
int i;
|
int i, p, t;
|
||||||
|
shmask_data_arr *shmask_data_arr_ptr;
|
||||||
|
|
||||||
|
mode_data_t *vm_in = &vmode_in;
|
||||||
|
mode_data_t *vm_out = &vmode_out;
|
||||||
|
avconfig_t *avconfig = &cm.cc;
|
||||||
|
|
||||||
hv_config_reg hv_in_config = {.data=0x00000000};
|
hv_config_reg hv_in_config = {.data=0x00000000};
|
||||||
hv_config2_reg hv_in_config2 = {.data=0x00000000};
|
hv_config2_reg hv_in_config2 = {.data=0x00000000};
|
||||||
@ -453,6 +484,28 @@ void update_sc_config(mode_data_t *vm_in, mode_data_t *vm_out, vm_proc_config_t
|
|||||||
sl_config2_reg sl_config2 = {.data=0x00000000};
|
sl_config2_reg sl_config2 = {.data=0x00000000};
|
||||||
sl_config3_reg sl_config3 = {.data=0x00000000};
|
sl_config3_reg sl_config3 = {.data=0x00000000};
|
||||||
|
|
||||||
|
if (avconfig->shmask_mode && ((avconfig->shmask_mode != shmask_loaded_array) || (avconfig->shmask_str != shmask_loaded_str))) {
|
||||||
|
shmask_data_arr_ptr = (shmask_data_arr*)shmask_data_arr_list[avconfig->shmask_mode];
|
||||||
|
|
||||||
|
for (p=0; p<=shmask_data_arr_ptr->iv_y; p++) {
|
||||||
|
for (t=0; t<=shmask_data_arr_ptr->iv_x; t++)
|
||||||
|
sc->shmask_data_array.data[p][t] = (avconfig->shmask_str == 15) ? shmask_data_arr_ptr->v[p][t] : (shmask_data_arr_ptr->v[p][t]&0x700) |
|
||||||
|
((((avconfig->shmask_str+1)*((shmask_data_arr_ptr->v[p][t]&0x0f0) >> 4))/16)<<4) |
|
||||||
|
(15-(((avconfig->shmask_str+1)*(15-(shmask_data_arr_ptr->v[p][t]&0x00f))) / 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
shmask_loaded_array = avconfig->shmask_mode;
|
||||||
|
shmask_loaded_str = avconfig->shmask_str;
|
||||||
|
} else {
|
||||||
|
shmask_data_arr_ptr = shmask_loaded_array ? (shmask_data_arr*)shmask_data_arr_list[shmask_loaded_array] : (shmask_data_arr*)shmask_data_arr_list[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (avconfig->lumacode_mode && (avconfig->lumacode_pal != loaded_lc_palette)) {
|
||||||
|
for (i=0; i<(sizeof(lc_palette_set)/4); i++)
|
||||||
|
sc->lumacode_pal_ram.data[i] = lc_palette_set_list[avconfig->lumacode_pal]->data[i];
|
||||||
|
loaded_lc_palette = avconfig->lumacode_pal;
|
||||||
|
}
|
||||||
|
|
||||||
// Set input params
|
// Set input params
|
||||||
hv_in_config.h_total = vm_in->timings.h_total;
|
hv_in_config.h_total = vm_in->timings.h_total;
|
||||||
hv_in_config.h_active = vm_in->timings.h_active;
|
hv_in_config.h_active = vm_in->timings.h_active;
|
||||||
@ -463,8 +516,8 @@ void update_sc_config(mode_data_t *vm_in, mode_data_t *vm_out, vm_proc_config_t
|
|||||||
hv_in_config3.v_backporch = vm_in->timings.v_backporch;
|
hv_in_config3.v_backporch = vm_in->timings.v_backporch;
|
||||||
hv_in_config2.interlaced = vm_in->timings.interlaced;
|
hv_in_config2.interlaced = vm_in->timings.interlaced;
|
||||||
hv_in_config3.v_startline = vm_in->timings.v_synclen+vm_in->timings.v_backporch+12;
|
hv_in_config3.v_startline = vm_in->timings.v_synclen+vm_in->timings.v_backporch+12;
|
||||||
hv_in_config3.h_skip = vm_conf->h_skip;
|
hv_in_config3.h_skip = vm_conf.h_skip;
|
||||||
hv_in_config3.h_sample_sel = vm_conf->h_sample_sel;
|
hv_in_config3.h_sample_sel = vm_conf.h_sample_sel;
|
||||||
|
|
||||||
// Set output params
|
// Set output params
|
||||||
hv_out_config.h_total = vm_out->timings.h_total;
|
hv_out_config.h_total = vm_out->timings.h_total;
|
||||||
@ -476,32 +529,31 @@ void update_sc_config(mode_data_t *vm_in, mode_data_t *vm_out, vm_proc_config_t
|
|||||||
hv_out_config3.v_synclen = vm_out->timings.v_synclen;
|
hv_out_config3.v_synclen = vm_out->timings.v_synclen;
|
||||||
hv_out_config3.v_backporch = vm_out->timings.v_backporch;
|
hv_out_config3.v_backporch = vm_out->timings.v_backporch;
|
||||||
hv_out_config2.interlaced = vm_out->timings.interlaced;
|
hv_out_config2.interlaced = vm_out->timings.interlaced;
|
||||||
hv_out_config3.v_startline = vm_conf->framesync_line;
|
hv_out_config3.v_startline = vm_conf.framesync_line;
|
||||||
|
|
||||||
xy_out_config.x_size = vm_conf->x_size;
|
xy_out_config.x_size = vm_conf.x_size;
|
||||||
xy_out_config.y_size = vm_conf->y_size;
|
xy_out_config.y_size = vm_conf.y_size;
|
||||||
xy_out_config.y_offset = vm_conf->y_offset;
|
xy_out_config.y_offset = vm_conf.y_offset;
|
||||||
xy_out_config2.x_offset = vm_conf->x_offset;
|
xy_out_config2.x_offset = vm_conf.x_offset;
|
||||||
xy_out_config2.x_start_lb = vm_conf->x_start_lb;
|
xy_out_config2.x_start_lb = vm_conf.x_start_lb;
|
||||||
xy_out_config2.y_start_lb = vm_conf->y_start_lb;
|
xy_out_config2.y_start_lb = vm_conf.y_start_lb;
|
||||||
xy_out_config2.x_rpt = vm_conf->x_rpt;
|
xy_out_config2.x_rpt = vm_conf.x_rpt;
|
||||||
xy_out_config2.y_rpt = vm_conf->y_rpt;
|
xy_out_config2.y_rpt = vm_conf.y_rpt;
|
||||||
|
|
||||||
misc_config.mask_br = avconfig->mask_br;
|
misc_config.mask_br = avconfig->mask_br;
|
||||||
misc_config.mask_color = avconfig->mask_color;
|
misc_config.mask_color = avconfig->mask_color;
|
||||||
misc_config.reverse_lpf = avconfig->reverse_lpf;
|
misc_config.reverse_lpf = avconfig->reverse_lpf;
|
||||||
misc_config.shmask_mode = avconfig->shmask_mode;
|
misc_config.shmask_enable = (avconfig->shmask_mode != 0);
|
||||||
|
misc_config.shmask_iv_x = shmask_data_arr_ptr->iv_x;
|
||||||
|
misc_config.shmask_iv_y = shmask_data_arr_ptr->iv_y;
|
||||||
misc_config.lumacode_mode = avconfig->lumacode_mode;
|
misc_config.lumacode_mode = avconfig->lumacode_mode;
|
||||||
|
misc_config.panasonic_hack = avconfig->panasonic_hack;
|
||||||
/*misc_config.lm_deint_mode = 0;
|
/*misc_config.lm_deint_mode = 0;
|
||||||
misc_config.nir_even_offset = 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;
|
|
||||||
misc_config.vip_enable = 0;
|
|
||||||
misc_config.bfi_enable = 0;
|
|
||||||
misc_config.bfi_str = 0;*/
|
|
||||||
|
|
||||||
// set default/custom scanline interval
|
// set default/custom scanline interval
|
||||||
sl_def_iv_y = (vm_conf->y_rpt > 0) ? vm_conf->y_rpt : 1;
|
sl_def_iv_y = (vm_conf.y_rpt > 0) ? vm_conf.y_rpt : 1;
|
||||||
sl_def_iv_x = (vm_conf->x_rpt > 0) ? vm_conf->x_rpt : sl_def_iv_y;
|
sl_def_iv_x = (vm_conf.x_rpt > 0) ? vm_conf.x_rpt : sl_def_iv_y;
|
||||||
sl_config3.sl_iv_x = ((avconfig->sl_type == 3) && (avconfig->sl_cust_iv_x)) ? avconfig->sl_cust_iv_x : sl_def_iv_x;
|
sl_config3.sl_iv_x = ((avconfig->sl_type == 3) && (avconfig->sl_cust_iv_x)) ? avconfig->sl_cust_iv_x : sl_def_iv_x;
|
||||||
sl_config3.sl_iv_y = ((avconfig->sl_type == 3) && (avconfig->sl_cust_iv_y)) ? avconfig->sl_cust_iv_y : sl_def_iv_y;
|
sl_config3.sl_iv_y = ((avconfig->sl_type == 3) && (avconfig->sl_cust_iv_y)) ? avconfig->sl_cust_iv_y : sl_def_iv_y;
|
||||||
|
|
||||||
@ -542,7 +594,7 @@ void update_sc_config(mode_data_t *vm_in, mode_data_t *vm_out, vm_proc_config_t
|
|||||||
sl_config3.sl_hybr_str = avconfig->sl_hybr_str;
|
sl_config3.sl_hybr_str = avconfig->sl_hybr_str;
|
||||||
|
|
||||||
// disable scanlines if configured so
|
// disable scanlines if configured so
|
||||||
if (((avconfig->sl_mode == 1) && (!vm_conf->y_rpt)) || (avconfig->sl_mode == 0)) {
|
if (((avconfig->sl_mode == 1) && (!vm_conf.y_rpt)) || (avconfig->sl_mode == 0)) {
|
||||||
sl_config.sl_l_overlay = 0;
|
sl_config.sl_l_overlay = 0;
|
||||||
sl_config3.sl_c_overlay = 0;
|
sl_config3.sl_c_overlay = 0;
|
||||||
}
|
}
|
||||||
@ -660,7 +712,7 @@ void program_mode()
|
|||||||
|
|
||||||
update_osd_size(&vmode_out);
|
update_osd_size(&vmode_out);
|
||||||
|
|
||||||
update_sc_config(&vmode_in, &vmode_out, &vm_conf, &cm.cc);
|
update_sc_config();
|
||||||
|
|
||||||
TX_SetPixelRepetition(vm_conf.tx_pixelrep, ((cm.cc.tx_mode!=TX_DVI) && (vm_conf.tx_pixelrep == vm_conf.hdmitx_pixr_ifr)) ? 1 : 0);
|
TX_SetPixelRepetition(vm_conf.tx_pixelrep, ((cm.cc.tx_mode!=TX_DVI) && (vm_conf.tx_pixelrep == vm_conf.hdmitx_pixr_ifr)) ? 1 : 0);
|
||||||
|
|
||||||
@ -679,10 +731,8 @@ void program_mode()
|
|||||||
TX_enable(cm.cc.tx_mode);
|
TX_enable(cm.cc.tx_mode);
|
||||||
} else if (cm.cc.tx_mode!=TX_DVI) {
|
} else if (cm.cc.tx_mode!=TX_DVI) {
|
||||||
HDMITX_SetAVIInfoFrame(vmode_out.vic, (cm.cc.tx_mode == TX_HDMI_RGB) ? F_MODE_RGB444 : F_MODE_YUV444, 0, 0, cm.cc.hdmi_itc, vm_conf.hdmitx_pixr_ifr);
|
HDMITX_SetAVIInfoFrame(vmode_out.vic, (cm.cc.tx_mode == TX_HDMI_RGB) ? F_MODE_RGB444 : F_MODE_YUV444, 0, 0, cm.cc.hdmi_itc, vm_conf.hdmitx_pixr_ifr);
|
||||||
#ifdef ENABLE_AUDIO
|
|
||||||
#ifdef MANUAL_CTS
|
#ifdef MANUAL_CTS
|
||||||
SetupAudio(cm.cc.tx_mode);
|
SetupAudio(cm.cc.tx_mode);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -708,7 +758,7 @@ void set_sampler_phase(uint8_t sampler_phase, uint8_t update_sc) {
|
|||||||
tvp_set_hpll_phase(tvp_phase);
|
tvp_set_hpll_phase(tvp_phase);
|
||||||
|
|
||||||
if (update_sc)
|
if (update_sc)
|
||||||
update_sc_config(&vmode_in, &vmode_out, &vm_conf, &cm.cc);
|
update_sc_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_profile() {
|
int load_profile() {
|
||||||
@ -723,7 +773,7 @@ int load_profile() {
|
|||||||
target_input = tc.link_av;
|
target_input = tc.link_av;
|
||||||
|
|
||||||
// Update profile link (also prevents the change of input from inducing a profile load).
|
// Update profile link (also prevents the change of input from inducing a profile load).
|
||||||
input_profiles[profile_link ? target_input : AV_TESTPAT] = profile_sel;
|
input_profiles[ts.profile_link ? target_input : AV_TESTPAT] = profile_sel;
|
||||||
write_userdata(INIT_CONFIG_SLOT);
|
write_userdata(INIT_CONFIG_SLOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,13 +787,28 @@ int save_profile() {
|
|||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
profile_sel = profile_sel_menu;
|
profile_sel = profile_sel_menu;
|
||||||
|
|
||||||
input_profiles[profile_link ? cm.avinput : AV_TESTPAT] = profile_sel;
|
input_profiles[ts.profile_link ? cm.avinput : AV_TESTPAT] = profile_sel;
|
||||||
write_userdata(INIT_CONFIG_SLOT);
|
write_userdata(INIT_CONFIG_SLOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_default_settings() {
|
||||||
|
memcpy(&ts, &ts_default, sizeof(settings_t));
|
||||||
|
set_default_keymap();
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_default_c_shmask() {
|
||||||
|
memset(&c_shmask, 0, sizeof(c_shmask));
|
||||||
|
strncpy(c_shmask.name, "Custom: <none>", 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_default_c_lc_palette_set() {
|
||||||
|
memset(&c_lc_palette_set, 0, sizeof(c_lc_palette_set));
|
||||||
|
strncpy(c_lc_palette_set.name, "Custom: <none>", 20);
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize hardware
|
// Initialize hardware
|
||||||
int init_hw()
|
int init_hw()
|
||||||
{
|
{
|
||||||
@ -801,33 +866,35 @@ int init_hw()
|
|||||||
|
|
||||||
InitIT6613();
|
InitIT6613();
|
||||||
|
|
||||||
#ifdef ENABLE_AUDIO
|
|
||||||
if (pcm1862_init()) {
|
if (pcm1862_init()) {
|
||||||
printf("PCM1862 found\n");
|
printf("PCM1862 found\n");
|
||||||
pcm1862_active = 1;
|
pcm1862_active = 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (init_flash() != 0) {
|
/*if (init_flash() != 0) {
|
||||||
printf("Error: could not find flash\n");
|
printf("Error: could not find flash\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
set_default_avconfig();
|
set_default_profile(1);
|
||||||
memcpy(&cm.cc, &tc_default, sizeof(avconfig_t));
|
set_default_c_shmask();
|
||||||
memcpy(rc_keymap, rc_keymap_default, sizeof(rc_keymap));
|
set_default_c_lc_palette_set();
|
||||||
|
set_default_settings();
|
||||||
|
|
||||||
// Init menu
|
// Init menu
|
||||||
init_menu();
|
init_menu();
|
||||||
|
|
||||||
// Load initconfig and profile
|
// Load initconfig and profile
|
||||||
read_userdata(INIT_CONFIG_SLOT, 0);
|
read_userdata(INIT_CONFIG_SLOT, 0);
|
||||||
|
profile_sel = input_profiles[AV_TESTPAT]; // Global profile
|
||||||
read_userdata(profile_sel, 0);
|
read_userdata(profile_sel, 0);
|
||||||
|
|
||||||
|
update_settings(1);
|
||||||
|
|
||||||
// Setup test pattern
|
// Setup test pattern
|
||||||
get_vmode(VMODE_480p, &vmode_in, &vmode_out, &vm_conf);
|
get_vmode(VMODE_480p, &vmode_in, &vmode_out, &vm_conf);
|
||||||
update_sc_config(&vmode_in, &vmode_out, &vm_conf, &cm.cc);
|
update_sc_config();
|
||||||
|
|
||||||
// init always in HDMI mode (fixes yellow screen bug)
|
// init always in HDMI mode (fixes yellow screen bug)
|
||||||
TX_enable(TX_HDMI_RGB);
|
TX_enable(TX_HDMI_RGB);
|
||||||
@ -863,7 +930,9 @@ void print_vm_stats() {
|
|||||||
sniprintf((char*)osd->osd_array.data[++row][0], OSD_CHAR_COLS, "Profile:");
|
sniprintf((char*)osd->osd_array.data[++row][0], OSD_CHAR_COLS, "Profile:");
|
||||||
sniprintf((char*)osd->osd_array.data[row][1], OSD_CHAR_COLS, "%u: %s", profile_sel, (target_profile_name[0] == 0) ? "<empty>" : target_profile_name);
|
sniprintf((char*)osd->osd_array.data[row][1], OSD_CHAR_COLS, "%u: %s", profile_sel, (target_profile_name[0] == 0) ? "<empty>" : target_profile_name);
|
||||||
sniprintf((char*)osd->osd_array.data[++row][0], OSD_CHAR_COLS, "FW:");
|
sniprintf((char*)osd->osd_array.data[++row][0], OSD_CHAR_COLS, "FW:");
|
||||||
sniprintf((char*)osd->osd_array.data[row][1], OSD_CHAR_COLS, "%u.%.2u" FW_SUFFIX1 FW_SUFFIX2 " @ " __DATE__, FW_VER_MAJOR, FW_VER_MINOR);
|
sniprintf((char*)osd->osd_array.data[row][1], OSD_CHAR_COLS, "%u.%.2u" FW_SUFFIX, FW_VER_MAJOR, FW_VER_MINOR);
|
||||||
|
sniprintf((char*)osd->osd_array.data[++row][0], OSD_CHAR_COLS, "FW date:");
|
||||||
|
sniprintf((char*)osd->osd_array.data[row][1], OSD_CHAR_COLS, __DATE__);
|
||||||
|
|
||||||
osd->osd_config.status_refresh = 1;
|
osd->osd_config.status_refresh = 1;
|
||||||
osd->osd_row_color.mask = 0;
|
osd->osd_row_color.mask = 0;
|
||||||
@ -933,6 +1002,24 @@ int latency_test() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void invalidate_loaded_arrays() {
|
||||||
|
shmask_loaded_array = -1;
|
||||||
|
loaded_lc_palette = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_settings(int init_setup) {
|
||||||
|
if (init_setup || (ts.osd_enable != cs.osd_enable) || (ts.osd_status_timeout != cs.osd_status_timeout) || (ts.osd_highlight_color != cs.osd_highlight_color)) {
|
||||||
|
osd->osd_config.enable = !!ts.osd_enable;
|
||||||
|
osd->osd_config.status_timeout = ts.osd_status_timeout;
|
||||||
|
osd->osd_config.highlight_color = 2+ts.osd_highlight_color;
|
||||||
|
refresh_osd();
|
||||||
|
}
|
||||||
|
if (init_setup)
|
||||||
|
target_input = ts.def_input;
|
||||||
|
|
||||||
|
memcpy(&cs, &ts, sizeof(settings_t));
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
ths_input_t target_ths = 0;
|
ths_input_t target_ths = 0;
|
||||||
@ -955,13 +1042,16 @@ int main()
|
|||||||
// Start system timer
|
// Start system timer
|
||||||
alt_timestamp_start();
|
alt_timestamp_start();
|
||||||
|
|
||||||
|
// Write-protect flash
|
||||||
|
flash_write_protect(&flashctrl_dev, 1);
|
||||||
|
|
||||||
init_stat = init_hw();
|
init_stat = init_hw();
|
||||||
|
|
||||||
if (init_stat >= 0) {
|
if (init_stat >= 0) {
|
||||||
printf("### DIY VIDEO DIGITIZER / SCANCONVERTER INIT OK ###\n\n");
|
printf("### DIY VIDEO DIGITIZER / SCANCONVERTER INIT OK ###\n\n");
|
||||||
sniprintf(row1, LCD_ROW_LEN+1, "OSSC fw. %u.%.2u" FW_SUFFIX1 FW_SUFFIX2, FW_VER_MAJOR, FW_VER_MINOR);
|
sniprintf(row1, LCD_ROW_LEN+1, " OSSC fw. %u.%.2u" FW_SUFFIX, FW_VER_MAJOR, FW_VER_MINOR);
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
strncpy(row2, "2014-2024 marqs", LCD_ROW_LEN+1);
|
strncpy(row2, "2014-2025 marqs", LCD_ROW_LEN+1);
|
||||||
#else
|
#else
|
||||||
strncpy(row2, "** DEBUG BUILD *", LCD_ROW_LEN+1);
|
strncpy(row2, "** DEBUG BUILD *", LCD_ROW_LEN+1);
|
||||||
#endif
|
#endif
|
||||||
@ -997,19 +1087,19 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Auto input switching
|
// Auto input switching
|
||||||
if ((auto_input != AUTO_OFF) && (cm.avinput != AV_TESTPAT) && !cm.sync_active && !menu_active
|
if ((cs.auto_input != AUTO_OFF) && (cm.avinput != AV_TESTPAT) && !cm.sync_active && !menu_active
|
||||||
&& (alt_timestamp() >= auto_input_timestamp + 300 * (alt_timestamp_freq() >> 10)) && (auto_input_ctr < AUTO_MAX_COUNT)) {
|
&& (alt_timestamp() >= auto_input_timestamp + 300 * (alt_timestamp_freq() >> 10)) && (auto_input_ctr < AUTO_MAX_COUNT)) {
|
||||||
|
|
||||||
// Keep switching on the same physical input when set to Current input or a short time after losing sync.
|
// Keep switching on the same physical input when set to Current input or a short time after losing sync.
|
||||||
auto_input_keep_current = (auto_input == AUTO_CURRENT_INPUT || auto_input_current_ctr < AUTO_CURRENT_MAX_COUNT);
|
auto_input_keep_current = (cs.auto_input == AUTO_CURRENT_INPUT || auto_input_current_ctr < AUTO_CURRENT_MAX_COUNT);
|
||||||
|
|
||||||
switch(cm.avinput) {
|
switch(cm.avinput) {
|
||||||
case AV1_RGBs:
|
case AV1_RGBs:
|
||||||
target_input = auto_av1_ypbpr ? AV1_YPBPR : AV1_RGsB;
|
target_input = cs.auto_av1_ypbpr ? AV1_YPBPR : AV1_RGsB;
|
||||||
break;
|
break;
|
||||||
case AV1_RGsB:
|
case AV1_RGsB:
|
||||||
case AV1_YPBPR:
|
case AV1_YPBPR:
|
||||||
target_input = auto_input_keep_current ? AV1_RGBs : (auto_av2_ypbpr ? AV2_YPBPR : AV2_RGsB);
|
target_input = auto_input_keep_current ? AV1_RGBs : (cs.auto_av2_ypbpr ? AV2_YPBPR : AV2_RGsB);
|
||||||
break;
|
break;
|
||||||
case AV2_YPBPR:
|
case AV2_YPBPR:
|
||||||
case AV2_RGsB:
|
case AV2_RGsB:
|
||||||
@ -1019,7 +1109,7 @@ int main()
|
|||||||
target_input = AV3_RGBs;
|
target_input = AV3_RGBs;
|
||||||
break;
|
break;
|
||||||
case AV3_RGBs:
|
case AV3_RGBs:
|
||||||
target_input = auto_av3_ypbpr ? AV3_YPBPR : AV3_RGsB;
|
target_input = cs.auto_av3_ypbpr ? AV3_YPBPR : AV3_RGsB;
|
||||||
break;
|
break;
|
||||||
case AV3_RGsB:
|
case AV3_RGsB:
|
||||||
case AV3_YPBPR:
|
case AV3_YPBPR:
|
||||||
@ -1050,7 +1140,7 @@ int main()
|
|||||||
if ((target_input != cm.avinput && man_input_change) || (auto_input_changed && cm.sync_active)) {
|
if ((target_input != cm.avinput && man_input_change) || (auto_input_changed && cm.sync_active)) {
|
||||||
// The input changed, so load the appropriate profile if
|
// The input changed, so load the appropriate profile if
|
||||||
// input->profile link is enabled
|
// input->profile link is enabled
|
||||||
if (profile_link && (profile_sel != input_profiles[target_input])) {
|
if (cs.profile_link && (profile_sel != input_profiles[target_input])) {
|
||||||
profile_sel = input_profiles[target_input];
|
profile_sel = input_profiles[target_input];
|
||||||
read_userdata(profile_sel, 0);
|
read_userdata(profile_sel, 0);
|
||||||
}
|
}
|
||||||
@ -1121,11 +1211,9 @@ int main()
|
|||||||
cm.sync_active = 0;
|
cm.sync_active = 0;
|
||||||
ths_source_sel(target_ths, (cm.cc.video_lpf > 1) ? (VIDEO_LPF_MAX-cm.cc.video_lpf) : THS_LPF_BYPASS);
|
ths_source_sel(target_ths, (cm.cc.video_lpf > 1) ? (VIDEO_LPF_MAX-cm.cc.video_lpf) : THS_LPF_BYPASS);
|
||||||
tvp_powerdown();
|
tvp_powerdown();
|
||||||
#ifdef ENABLE_AUDIO
|
|
||||||
DisableAudioOutput();
|
DisableAudioOutput();
|
||||||
if (pcm1862_active)
|
if (pcm1862_active)
|
||||||
pcm_source_sel(target_pcm);
|
pcm_source_sel(target_pcm);
|
||||||
#endif
|
|
||||||
tvp_source_sel(target_tvp, target_tvp_sync, target_format);
|
tvp_source_sel(target_tvp, target_tvp_sync, target_format);
|
||||||
cm.clkcnt = 0; //TODO: proper invalidate
|
cm.clkcnt = 0; //TODO: proper invalidate
|
||||||
sys_ctrl &= ~VSYNC_I_TYPE;
|
sys_ctrl &= ~VSYNC_I_TYPE;
|
||||||
@ -1137,7 +1225,7 @@ int main()
|
|||||||
ui_disp_status(1);
|
ui_disp_status(1);
|
||||||
if (man_input_change) {
|
if (man_input_change) {
|
||||||
// record last input if it was selected manually
|
// record last input if it was selected manually
|
||||||
if (def_input == AV_LAST)
|
if (cs.def_input == AV_LAST)
|
||||||
write_userdata(INIT_CONFIG_SLOT);
|
write_userdata(INIT_CONFIG_SLOT);
|
||||||
// Set auto_input_timestamp when input is manually changed
|
// Set auto_input_timestamp when input is manually changed
|
||||||
auto_input_ctr = 0;
|
auto_input_ctr = 0;
|
||||||
@ -1162,30 +1250,23 @@ int main()
|
|||||||
HDMITX_SetAVIInfoFrame(vmode_out.vic, (tc.tx_mode == TX_HDMI_RGB) ? F_MODE_RGB444 : F_MODE_YUV444, 0, 0, tc.hdmi_itc, vm_conf.hdmitx_pixr_ifr);
|
HDMITX_SetAVIInfoFrame(vmode_out.vic, (tc.tx_mode == TX_HDMI_RGB) ? F_MODE_RGB444 : F_MODE_YUV444, 0, 0, tc.hdmi_itc, vm_conf.hdmitx_pixr_ifr);
|
||||||
cm.cc.hdmi_itc = tc.hdmi_itc;
|
cm.cc.hdmi_itc = tc.hdmi_itc;
|
||||||
}
|
}
|
||||||
if (tc.hdmi_hdr != cm.cc.hdmi_hdr) {
|
|
||||||
printf("setting HDR flag to %d\n", tc.hdmi_hdr);
|
|
||||||
HDMITX_SetHDRInfoFrame(tc.hdmi_hdr ? 3 : 0);
|
|
||||||
cm.cc.hdmi_hdr = tc.hdmi_hdr;
|
|
||||||
}
|
|
||||||
if (tc.hdmi_vrr != cm.cc.hdmi_vrr) {
|
if (tc.hdmi_vrr != cm.cc.hdmi_vrr) {
|
||||||
printf("setting VRR flag to %d\n", tc.hdmi_vrr);
|
printf("setting VRR flag to %d\n", tc.hdmi_vrr);
|
||||||
HDMITX_SetVRRInfoFrame(tc.hdmi_vrr);
|
HDMITX_SetVRRInfoFrame(tc.hdmi_vrr);
|
||||||
cm.cc.hdmi_vrr = tc.hdmi_vrr;
|
cm.cc.hdmi_vrr = tc.hdmi_vrr;
|
||||||
}
|
}
|
||||||
|
if (tc.hdmi_hdr != cm.cc.hdmi_hdr) {
|
||||||
|
printf("setting HDR flag to %d\n", tc.hdmi_hdr);
|
||||||
|
HDMITX_SetHDRInfoFrame(tc.hdmi_hdr ? 3 : 0);
|
||||||
|
cm.cc.hdmi_hdr = tc.hdmi_hdr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (tc.av3_alt_rgb != cm.cc.av3_alt_rgb) {
|
if (tc.av3_alt_rgb != cm.cc.av3_alt_rgb) {
|
||||||
printf("Changing AV3 RGB source\n");
|
printf("Changing AV3 RGB source\n");
|
||||||
cm.cc.av3_alt_rgb = tc.av3_alt_rgb;
|
cm.cc.av3_alt_rgb = tc.av3_alt_rgb;
|
||||||
}
|
}
|
||||||
if ((!!osd_enable != osd->osd_config.enable) || (osd_status_timeout != osd->osd_config.status_timeout)) {
|
|
||||||
osd->osd_config.enable = !!osd_enable;
|
update_settings(0);
|
||||||
osd->osd_config.status_timeout = osd_status_timeout;
|
|
||||||
if (menu_active) {
|
|
||||||
remote_code = 0;
|
|
||||||
render_osd_page();
|
|
||||||
display_menu(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cm.avinput != AV_TESTPAT) {
|
if (cm.avinput != AV_TESTPAT) {
|
||||||
status = get_status(target_tvp_sync);
|
status = get_status(target_tvp_sync);
|
||||||
@ -1198,9 +1279,7 @@ int main()
|
|||||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
tvp_powerup();
|
tvp_powerup();
|
||||||
program_mode();
|
program_mode();
|
||||||
#ifdef ENABLE_AUDIO
|
|
||||||
SetupAudio(cm.cc.tx_mode);
|
SetupAudio(cm.cc.tx_mode);
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
printf("Sync lost\n");
|
printf("Sync lost\n");
|
||||||
cm.clkcnt = 0; //TODO: proper invalidate
|
cm.clkcnt = 0; //TODO: proper invalidate
|
||||||
@ -1224,7 +1303,7 @@ int main()
|
|||||||
case SC_CONFIG_CHANGE:
|
case SC_CONFIG_CHANGE:
|
||||||
if (cm.sync_active) {
|
if (cm.sync_active) {
|
||||||
printf("Scanconverter config change\n");
|
printf("Scanconverter config change\n");
|
||||||
update_sc_config(&vmode_in, &vmode_out, &vm_conf, &cm.cc);
|
update_sc_config();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
296
software/sys_controller/config/ffconf.h
Normal file
296
software/sys_controller/config/ffconf.h
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
/*---------------------------------------------------------------------------/
|
||||||
|
/ Configurations of FatFs Module
|
||||||
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define FFCONF_DEF 5380 /* Revision ID */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------/
|
||||||
|
/ Function Configurations
|
||||||
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define FF_FS_READONLY 0
|
||||||
|
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||||
|
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||||
|
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||||
|
/ and optional writing functions as well. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_FS_MINIMIZE 0
|
||||||
|
/* This option defines minimization level to remove some basic API functions.
|
||||||
|
/
|
||||||
|
/ 0: Basic functions are fully enabled.
|
||||||
|
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
|
||||||
|
/ are removed.
|
||||||
|
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||||
|
/ 3: f_lseek() function is removed in addition to 2. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_FIND 1
|
||||||
|
/* This option switches filtered directory read functions, f_findfirst() and
|
||||||
|
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_MKFS 0
|
||||||
|
/* This option switches f_mkfs(). (0:Disable or 1:Enable) */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_FASTSEEK 0
|
||||||
|
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_EXPAND 0
|
||||||
|
/* This option switches f_expand(). (0:Disable or 1:Enable) */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_CHMOD 0
|
||||||
|
/* This option switches attribute control API functions, f_chmod() and f_utime().
|
||||||
|
/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_LABEL 0
|
||||||
|
/* This option switches volume label API functions, f_getlabel() and f_setlabel().
|
||||||
|
/ (0:Disable or 1:Enable) */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_FORWARD 0
|
||||||
|
/* This option switches f_forward(). (0:Disable or 1:Enable) */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_STRFUNC 1
|
||||||
|
#define FF_PRINT_LLI 0
|
||||||
|
#define FF_PRINT_FLOAT 0
|
||||||
|
#define FF_STRF_ENCODE 3
|
||||||
|
/* FF_USE_STRFUNC switches the string API functions, f_gets(), f_putc(), f_puts()
|
||||||
|
/ and f_printf().
|
||||||
|
/
|
||||||
|
/ 0: Disable. FF_PRINT_LLI, FF_PRINT_FLOAT and FF_STRF_ENCODE have no effect.
|
||||||
|
/ 1: Enable without LF - CRLF conversion.
|
||||||
|
/ 2: Enable with LF - CRLF conversion.
|
||||||
|
/
|
||||||
|
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
||||||
|
/ makes f_printf() support floating point argument. These features want C99 or later.
|
||||||
|
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string API functions convert the character
|
||||||
|
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
||||||
|
/ to be read/written via those functions.
|
||||||
|
/
|
||||||
|
/ 0: ANSI/OEM in current CP
|
||||||
|
/ 1: Unicode in UTF-16LE
|
||||||
|
/ 2: Unicode in UTF-16BE
|
||||||
|
/ 3: Unicode in UTF-8
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------/
|
||||||
|
/ Locale and Namespace Configurations
|
||||||
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define FF_CODE_PAGE 437
|
||||||
|
/* This option specifies the OEM code page to be used on the target system.
|
||||||
|
/ Incorrect code page setting can cause a file open failure.
|
||||||
|
/
|
||||||
|
/ 437 - U.S.
|
||||||
|
/ 720 - Arabic
|
||||||
|
/ 737 - Greek
|
||||||
|
/ 771 - KBL
|
||||||
|
/ 775 - Baltic
|
||||||
|
/ 850 - Latin 1
|
||||||
|
/ 852 - Latin 2
|
||||||
|
/ 855 - Cyrillic
|
||||||
|
/ 857 - Turkish
|
||||||
|
/ 860 - Portuguese
|
||||||
|
/ 861 - Icelandic
|
||||||
|
/ 862 - Hebrew
|
||||||
|
/ 863 - Canadian French
|
||||||
|
/ 864 - Arabic
|
||||||
|
/ 865 - Nordic
|
||||||
|
/ 866 - Russian
|
||||||
|
/ 869 - Greek 2
|
||||||
|
/ 932 - Japanese (DBCS)
|
||||||
|
/ 936 - Simplified Chinese (DBCS)
|
||||||
|
/ 949 - Korean (DBCS)
|
||||||
|
/ 950 - Traditional Chinese (DBCS)
|
||||||
|
/ 0 - Include all code pages above and configured by f_setcp()
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_LFN 1
|
||||||
|
#define FF_MAX_LFN 255
|
||||||
|
/* The FF_USE_LFN switches the support for LFN (long file name).
|
||||||
|
/
|
||||||
|
/ 0: Disable LFN. FF_MAX_LFN has no effect.
|
||||||
|
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||||
|
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||||
|
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||||
|
/
|
||||||
|
/ To enable the LFN, ffunicode.c needs to be added to the project. The LFN feature
|
||||||
|
/ requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
|
||||||
|
/ additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
|
||||||
|
/ The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
|
||||||
|
/ be in range of 12 to 255. It is recommended to be set 255 to fully support the LFN
|
||||||
|
/ specification.
|
||||||
|
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||||
|
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||||
|
/ ff_memfree() exemplified in ffsystem.c, need to be added to the project. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_LFN_UNICODE 0
|
||||||
|
/* This option switches the character encoding on the API when LFN is enabled.
|
||||||
|
/
|
||||||
|
/ 0: ANSI/OEM in current CP (TCHAR = char)
|
||||||
|
/ 1: Unicode in UTF-16 (TCHAR = WCHAR)
|
||||||
|
/ 2: Unicode in UTF-8 (TCHAR = char)
|
||||||
|
/ 3: Unicode in UTF-32 (TCHAR = DWORD)
|
||||||
|
/
|
||||||
|
/ Also behavior of string I/O functions will be affected by this option.
|
||||||
|
/ When LFN is not enabled, this option has no effect. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_LFN_BUF 255
|
||||||
|
#define FF_SFN_BUF 12
|
||||||
|
/* This set of options defines size of file name members in the FILINFO structure
|
||||||
|
/ which is used to read out directory items. These values should be suffcient for
|
||||||
|
/ the file names to read. The maximum possible length of the read file name depends
|
||||||
|
/ on character encoding. When LFN is not enabled, these options have no effect. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_FS_RPATH 1
|
||||||
|
/* This option configures support for relative path.
|
||||||
|
/
|
||||||
|
/ 0: Disable relative path and remove related API functions.
|
||||||
|
/ 1: Enable relative path. f_chdir() and f_chdrive() are available.
|
||||||
|
/ 2: f_getcwd() is available in addition to 1.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------/
|
||||||
|
/ Drive/Volume Configurations
|
||||||
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define FF_VOLUMES 1
|
||||||
|
/* Number of volumes (logical drives) to be used. (1-10) */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_STR_VOLUME_ID 0
|
||||||
|
#define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
|
||||||
|
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
|
||||||
|
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
|
||||||
|
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
|
||||||
|
/ logical drive. Number of items must not be less than FF_VOLUMES. Valid
|
||||||
|
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
|
||||||
|
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
|
||||||
|
/ not defined, a user defined volume string table is needed as:
|
||||||
|
/
|
||||||
|
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_MULTI_PARTITION 0
|
||||||
|
/* This option switches support for multiple volumes on the physical drive.
|
||||||
|
/ By default (0), each logical drive number is bound to the same physical drive
|
||||||
|
/ number and only an FAT volume found on the physical drive will be mounted.
|
||||||
|
/ When this feature is enabled (1), each logical drive number can be bound to
|
||||||
|
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
||||||
|
/ will be available. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_MIN_SS 512
|
||||||
|
#define FF_MAX_SS 512
|
||||||
|
/* This set of options configures the range of sector size to be supported. (512,
|
||||||
|
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
|
||||||
|
/ harddisk, but a larger value may be required for on-board flash memory and some
|
||||||
|
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is
|
||||||
|
/ configured for variable sector size mode and disk_ioctl() needs to implement
|
||||||
|
/ GET_SECTOR_SIZE command. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_LBA64 0
|
||||||
|
/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)
|
||||||
|
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_MIN_GPT 0x10000000
|
||||||
|
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs() and
|
||||||
|
/ f_fdisk(). 2^32 sectors maximum. This option has no effect when FF_LBA64 == 0. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_TRIM 0
|
||||||
|
/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
|
||||||
|
/ To enable this feature, also CTRL_TRIM command should be implemented to
|
||||||
|
/ the disk_ioctl(). */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------/
|
||||||
|
/ System Configurations
|
||||||
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define FF_FS_TINY 0
|
||||||
|
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||||
|
/ At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
|
||||||
|
/ Instead of private sector buffer eliminated from the file object, common sector
|
||||||
|
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_FS_EXFAT 1
|
||||||
|
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
|
||||||
|
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
|
||||||
|
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_FS_NORTC 1
|
||||||
|
#define FF_NORTC_MON 11
|
||||||
|
#define FF_NORTC_MDAY 1
|
||||||
|
#define FF_NORTC_YEAR 2024
|
||||||
|
/* The option FF_FS_NORTC switches timestamp feature. If the system does not have
|
||||||
|
/ an RTC or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable the
|
||||||
|
/ timestamp feature. Every object modified by FatFs will have a fixed timestamp
|
||||||
|
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
|
||||||
|
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() need to be added
|
||||||
|
/ to the project to read current time form real-time clock. FF_NORTC_MON,
|
||||||
|
/ FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
|
||||||
|
/ These options have no effect in read-only configuration (FF_FS_READONLY = 1). */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_FS_NOFSINFO 0
|
||||||
|
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||||
|
/ option, and f_getfree() at the first time after volume mount will force
|
||||||
|
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||||
|
/
|
||||||
|
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||||
|
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||||
|
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||||
|
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_FS_LOCK 0
|
||||||
|
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
|
||||||
|
/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
|
||||||
|
/ is 1.
|
||||||
|
/
|
||||||
|
/ 0: Disable file lock function. To avoid volume corruption, application program
|
||||||
|
/ should avoid illegal open, remove and rename to the open objects.
|
||||||
|
/ >0: Enable file lock function. The value defines how many files/sub-directories
|
||||||
|
/ can be opened simultaneously under file lock control. Note that the file
|
||||||
|
/ lock control is independent of re-entrancy. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_FS_REENTRANT 0
|
||||||
|
#define FF_FS_TIMEOUT 1000
|
||||||
|
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
||||||
|
/ module itself. Note that regardless of this option, file access to different
|
||||||
|
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||||
|
/ and f_fdisk(), are always not re-entrant. Only file/directory access to
|
||||||
|
/ the same volume is under control of this featuer.
|
||||||
|
/
|
||||||
|
/ 0: Disable re-entrancy. FF_FS_TIMEOUT have no effect.
|
||||||
|
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||||
|
/ ff_mutex_create(), ff_mutex_delete(), ff_mutex_take() and ff_mutex_give(),
|
||||||
|
/ must be added to the project. Samples are available in ffsystem.c.
|
||||||
|
/
|
||||||
|
/ The FF_FS_TIMEOUT defines timeout period in unit of O/S time tick.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--- End of configuration options ---*/
|
||||||
@ -25,6 +25,7 @@
|
|||||||
#define SD_SPI_BASE I2C_OPENCORES_1_BASE
|
#define SD_SPI_BASE I2C_OPENCORES_1_BASE
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
|
#include <stdio.h>
|
||||||
#define OS_PRINTF(...)
|
#define OS_PRINTF(...)
|
||||||
#define ErrorF(...)
|
#define ErrorF(...)
|
||||||
#define printf(...)
|
#define printf(...)
|
||||||
@ -38,6 +39,8 @@
|
|||||||
#define printf dd_printf
|
#define printf dd_printf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define sniprintf snprintf
|
||||||
|
|
||||||
#define WAITLOOP_SLEEP_US 10000
|
#define WAITLOOP_SLEEP_US 10000
|
||||||
|
|
||||||
#endif /* SYSCONFIG_H_ */
|
#endif /* SYSCONFIG_H_ */
|
||||||
@ -71,6 +71,14 @@ zero_loop:
|
|||||||
ble x26, x27, zero_loop
|
ble x26, x27, zero_loop
|
||||||
zero_loop_end:
|
zero_loop_end:
|
||||||
|
|
||||||
|
copy_sections:
|
||||||
|
jal alt_load
|
||||||
|
|
||||||
|
cache_setup:
|
||||||
|
fence.i
|
||||||
|
csrwi 0x7C0, 1
|
||||||
|
cache_setup_end:
|
||||||
|
|
||||||
|
|
||||||
main_entry:
|
main_entry:
|
||||||
/* jump to alt_main program entry point */
|
/* jump to alt_main program entry point */
|
||||||
|
|||||||
@ -55,6 +55,15 @@ zero_loop:
|
|||||||
ble x14, x15, zero_loop
|
ble x14, x15, zero_loop
|
||||||
zero_loop_end:
|
zero_loop_end:
|
||||||
|
|
||||||
|
copy_sections:
|
||||||
|
jal alt_load
|
||||||
|
copy_sections_end:
|
||||||
|
|
||||||
|
cache_setup:
|
||||||
|
fence.i
|
||||||
|
csrwi 0x7C0, 1
|
||||||
|
cache_setup_end:
|
||||||
|
|
||||||
|
|
||||||
main_entry:
|
main_entry:
|
||||||
/* jump to alt_main program entry point */
|
/* jump to alt_main program entry point */
|
||||||
|
|||||||
377
software/sys_controller/fatfs/source/00history.txt
Normal file
377
software/sys_controller/fatfs/source/00history.txt
Normal file
@ -0,0 +1,377 @@
|
|||||||
|
----------------------------------------------------------------------------
|
||||||
|
Revision history of FatFs module
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
R0.00 (February 26, 2006)
|
||||||
|
|
||||||
|
Prototype.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.01 (April 29, 2006)
|
||||||
|
|
||||||
|
The first release.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.02 (June 01, 2006)
|
||||||
|
|
||||||
|
Added FAT12 support.
|
||||||
|
Removed unbuffered mode.
|
||||||
|
Fixed a problem on small (<32M) partition.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.02a (June 10, 2006)
|
||||||
|
|
||||||
|
Added a configuration option (_FS_MINIMUM).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.03 (September 22, 2006)
|
||||||
|
|
||||||
|
Added f_rename().
|
||||||
|
Changed option _FS_MINIMUM to _FS_MINIMIZE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.03a (December 11, 2006)
|
||||||
|
|
||||||
|
Improved cluster scan algorithm to write files fast.
|
||||||
|
Fixed f_mkdir() creates incorrect directory on FAT32.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.04 (February 04, 2007)
|
||||||
|
|
||||||
|
Added f_mkfs().
|
||||||
|
Supported multiple drive system.
|
||||||
|
Changed some interfaces for multiple drive system.
|
||||||
|
Changed f_mountdrv() to f_mount().
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.04a (April 01, 2007)
|
||||||
|
|
||||||
|
Supported multiple partitions on a physical drive.
|
||||||
|
Added a capability of extending file size to f_lseek().
|
||||||
|
Added minimization level 3.
|
||||||
|
Fixed an endian sensitive code in f_mkfs().
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.04b (May 05, 2007)
|
||||||
|
|
||||||
|
Added a configuration option _USE_NTFLAG.
|
||||||
|
Added FSINFO support.
|
||||||
|
Fixed DBCS name can result FR_INVALID_NAME.
|
||||||
|
Fixed short seek (<= csize) collapses the file object.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.05 (August 25, 2007)
|
||||||
|
|
||||||
|
Changed arguments of f_read(), f_write() and f_mkfs().
|
||||||
|
Fixed f_mkfs() on FAT32 creates incorrect FSINFO.
|
||||||
|
Fixed f_mkdir() on FAT32 creates incorrect directory.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.05a (February 03, 2008)
|
||||||
|
|
||||||
|
Added f_truncate() and f_utime().
|
||||||
|
Fixed off by one error at FAT sub-type determination.
|
||||||
|
Fixed btr in f_read() can be mistruncated.
|
||||||
|
Fixed cached sector is not flushed when create and close without write.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.06 (April 01, 2008)
|
||||||
|
|
||||||
|
Added fputc(), fputs(), fprintf() and fgets().
|
||||||
|
Improved performance of f_lseek() on moving to the same or following cluster.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.07 (April 01, 2009)
|
||||||
|
|
||||||
|
Merged Tiny-FatFs as a configuration option. (_FS_TINY)
|
||||||
|
Added long file name feature. (_USE_LFN)
|
||||||
|
Added multiple code page feature. (_CODE_PAGE)
|
||||||
|
Added re-entrancy for multitask operation. (_FS_REENTRANT)
|
||||||
|
Added auto cluster size selection to f_mkfs().
|
||||||
|
Added rewind option to f_readdir().
|
||||||
|
Changed result code of critical errors.
|
||||||
|
Renamed string functions to avoid name collision.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.07a (April 14, 2009)
|
||||||
|
|
||||||
|
Septemberarated out OS dependent code on reentrant cfg.
|
||||||
|
Added multiple sector size feature.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.07c (June 21, 2009)
|
||||||
|
|
||||||
|
Fixed f_unlink() can return FR_OK on error.
|
||||||
|
Fixed wrong cache control in f_lseek().
|
||||||
|
Added relative path feature.
|
||||||
|
Added f_chdir() and f_chdrive().
|
||||||
|
Added proper case conversion to extended character.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.07e (November 03, 2009)
|
||||||
|
|
||||||
|
Septemberarated out configuration options from ff.h to ffconf.h.
|
||||||
|
Fixed f_unlink() fails to remove a sub-directory on _FS_RPATH.
|
||||||
|
Fixed name matching error on the 13 character boundary.
|
||||||
|
Added a configuration option, _LFN_UNICODE.
|
||||||
|
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.08 (May 15, 2010)
|
||||||
|
|
||||||
|
Added a memory configuration option. (_USE_LFN = 3)
|
||||||
|
Added file lock feature. (_FS_SHARE)
|
||||||
|
Added fast seek feature. (_USE_FASTSEEK)
|
||||||
|
Changed some types on the API, XCHAR->TCHAR.
|
||||||
|
Changed .fname in the FILINFO structure on Unicode cfg.
|
||||||
|
String functions support UTF-8 encoding files on Unicode cfg.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.08a (August 16, 2010)
|
||||||
|
|
||||||
|
Added f_getcwd(). (_FS_RPATH = 2)
|
||||||
|
Added sector erase feature. (_USE_ERASE)
|
||||||
|
Moved file lock semaphore table from fs object to the bss.
|
||||||
|
Fixed f_mkfs() creates wrong FAT32 volume.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.08b (January 15, 2011)
|
||||||
|
|
||||||
|
Fast seek feature is also applied to f_read() and f_write().
|
||||||
|
f_lseek() reports required table size on creating CLMP.
|
||||||
|
Extended format syntax of f_printf().
|
||||||
|
Ignores duplicated directory separators in given path name.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.09 (September 06, 2011)
|
||||||
|
|
||||||
|
f_mkfs() supports multiple partition to complete the multiple partition feature.
|
||||||
|
Added f_fdisk().
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.09a (August 27, 2012)
|
||||||
|
|
||||||
|
Changed f_open() and f_opendir() reject null object pointer to avoid crash.
|
||||||
|
Changed option name _FS_SHARE to _FS_LOCK.
|
||||||
|
Fixed assertion failure due to OS/2 EA on FAT12/16 volume.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.09b (January 24, 2013)
|
||||||
|
|
||||||
|
Added f_setlabel() and f_getlabel().
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.10 (October 02, 2013)
|
||||||
|
|
||||||
|
Added selection of character encoding on the file. (_STRF_ENCODE)
|
||||||
|
Added f_closedir().
|
||||||
|
Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO)
|
||||||
|
Added forced mount feature with changes of f_mount().
|
||||||
|
Improved behavior of volume auto detection.
|
||||||
|
Improved write throughput of f_puts() and f_printf().
|
||||||
|
Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
|
||||||
|
Fixed f_write() can be truncated when the file size is close to 4GB.
|
||||||
|
Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect value on error.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.10a (January 15, 2014)
|
||||||
|
|
||||||
|
Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
|
||||||
|
Added a configuration option of minimum sector size. (_MIN_SS)
|
||||||
|
2nd argument of f_rename() can have a drive number and it will be ignored.
|
||||||
|
Fixed f_mount() with forced mount fails when drive number is >= 1. (appeared at R0.10)
|
||||||
|
Fixed f_close() invalidates the file object without volume lock.
|
||||||
|
Fixed f_closedir() returns but the volume lock is left acquired. (appeared at R0.10)
|
||||||
|
Fixed creation of an entry with LFN fails on too many SFN collisions. (appeared at R0.07)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.10b (May 19, 2014)
|
||||||
|
|
||||||
|
Fixed a hard error in the disk I/O layer can collapse the directory entry.
|
||||||
|
Fixed LFN entry is not deleted when delete/rename an object with lossy converted SFN. (appeared at R0.07)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.10c (November 09, 2014)
|
||||||
|
|
||||||
|
Added a configuration option for the platforms without RTC. (_FS_NORTC)
|
||||||
|
Changed option name _USE_ERASE to _USE_TRIM.
|
||||||
|
Fixed volume label created by Mac OS X cannot be retrieved with f_getlabel(). (appeared at R0.09b)
|
||||||
|
Fixed a potential problem of FAT access that can appear on disk error.
|
||||||
|
Fixed null pointer dereference on attempting to delete the root direcotry. (appeared at R0.08)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.11 (February 09, 2015)
|
||||||
|
|
||||||
|
Added f_findfirst(), f_findnext() and f_findclose(). (_USE_FIND)
|
||||||
|
Fixed f_unlink() does not remove cluster chain of the file. (appeared at R0.10c)
|
||||||
|
Fixed _FS_NORTC option does not work properly. (appeared at R0.10c)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.11a (September 05, 2015)
|
||||||
|
|
||||||
|
Fixed wrong media change can lead a deadlock at thread-safe configuration.
|
||||||
|
Added code page 771, 860, 861, 863, 864, 865 and 869. (_CODE_PAGE)
|
||||||
|
Removed some code pages actually not exist on the standard systems. (_CODE_PAGE)
|
||||||
|
Fixed errors in the case conversion teble of code page 437 and 850 (ff.c).
|
||||||
|
Fixed errors in the case conversion teble of Unicode (cc*.c).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.12 (April 12, 2016)
|
||||||
|
|
||||||
|
Added support for exFAT file system. (_FS_EXFAT)
|
||||||
|
Added f_expand(). (_USE_EXPAND)
|
||||||
|
Changed some members in FINFO structure and behavior of f_readdir().
|
||||||
|
Added an option _USE_CHMOD.
|
||||||
|
Removed an option _WORD_ACCESS.
|
||||||
|
Fixed errors in the case conversion table of Unicode (cc*.c).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.12a (July 10, 2016)
|
||||||
|
|
||||||
|
Added support for creating exFAT volume with some changes of f_mkfs().
|
||||||
|
Added a file open method FA_OPEN_APPEND. An f_lseek() following f_open() is no longer needed.
|
||||||
|
f_forward() is available regardless of _FS_TINY.
|
||||||
|
Fixed f_mkfs() creates wrong volume. (appeared at R0.12)
|
||||||
|
Fixed wrong memory read in create_name(). (appeared at R0.12)
|
||||||
|
Fixed compilation fails at some configurations, _USE_FASTSEEK and _USE_FORWARD.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.12b (September 04, 2016)
|
||||||
|
|
||||||
|
Made f_rename() be able to rename objects with the same name but case.
|
||||||
|
Fixed an error in the case conversion teble of code page 866. (ff.c)
|
||||||
|
Fixed writing data is truncated at the file offset 4GiB on the exFAT volume. (appeared at R0.12)
|
||||||
|
Fixed creating a file in the root directory of exFAT volume can fail. (appeared at R0.12)
|
||||||
|
Fixed f_mkfs() creating exFAT volume with too small cluster size can collapse unallocated memory. (appeared at R0.12)
|
||||||
|
Fixed wrong object name can be returned when read directory at Unicode cfg. (appeared at R0.12)
|
||||||
|
Fixed large file allocation/removing on the exFAT volume collapses allocation bitmap. (appeared at R0.12)
|
||||||
|
Fixed some internal errors in f_expand() and f_lseek(). (appeared at R0.12)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.12c (March 04, 2017)
|
||||||
|
|
||||||
|
Improved write throughput at the fragmented file on the exFAT volume.
|
||||||
|
Made memory usage for exFAT be able to be reduced as decreasing _MAX_LFN.
|
||||||
|
Fixed successive f_getfree() can return wrong count on the FAT12/16 volume. (appeared at R0.12)
|
||||||
|
Fixed configuration option _VOLUMES cannot be set 10. (appeared at R0.10c)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.13 (May 21, 2017)
|
||||||
|
|
||||||
|
Changed heading character of configuration keywords "_" to "FF_".
|
||||||
|
Removed ASCII-only configuration, FF_CODE_PAGE = 1. Use FF_CODE_PAGE = 437 instead.
|
||||||
|
Added f_setcp(), run-time code page configuration. (FF_CODE_PAGE = 0)
|
||||||
|
Improved cluster allocation time on stretch a deep buried cluster chain.
|
||||||
|
Improved processing time of f_mkdir() with large cluster size by using FF_USE_LFN = 3.
|
||||||
|
Improved NoFatChain flag of the fragmented file to be set after it is truncated and got contiguous.
|
||||||
|
Fixed archive attribute is left not set when a file on the exFAT volume is renamed. (appeared at R0.12)
|
||||||
|
Fixed exFAT FAT entry can be collapsed when write or lseek operation to the existing file is done. (appeared at R0.12c)
|
||||||
|
Fixed creating a file can fail when a new cluster allocation to the exFAT directory occures. (appeared at R0.12c)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.13a (October 14, 2017)
|
||||||
|
|
||||||
|
Added support for UTF-8 encoding on the API. (FF_LFN_UNICODE = 2)
|
||||||
|
Added options for file name output buffer. (FF_LFN_BUF, FF_SFN_BUF).
|
||||||
|
Added dynamic memory allocation option for working buffer of f_mkfs() and f_fdisk().
|
||||||
|
Fixed f_fdisk() and f_mkfs() create the partition table with wrong CHS parameters. (appeared at R0.09)
|
||||||
|
Fixed f_unlink() can cause lost clusters at fragmented file on the exFAT volume. (appeared at R0.12c)
|
||||||
|
Fixed f_setlabel() rejects some valid characters for exFAT volume. (appeared at R0.12)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.13b (April 07, 2018)
|
||||||
|
|
||||||
|
Added support for UTF-32 encoding on the API. (FF_LFN_UNICODE = 3)
|
||||||
|
Added support for Unix style volume ID. (FF_STR_VOLUME_ID = 2)
|
||||||
|
Fixed accesing any object on the exFAT root directory beyond the cluster boundary can fail. (appeared at R0.12c)
|
||||||
|
Fixed f_setlabel() does not reject some invalid characters. (appeared at R0.09b)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.13c (October 14, 2018)
|
||||||
|
Supported stdint.h for C99 and later. (integer.h was included in ff.h)
|
||||||
|
Fixed reading a directory gets infinite loop when the last directory entry is not empty. (appeared at R0.12)
|
||||||
|
Fixed creating a sub-directory in the fragmented sub-directory on the exFAT volume collapses FAT chain of the parent directory. (appeared at R0.12)
|
||||||
|
Fixed f_getcwd() cause output buffer overrun when the buffer has a valid drive number. (appeared at R0.13b)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.14 (October 14, 2019)
|
||||||
|
Added support for 64-bit LBA and GUID partition table (FF_LBA64 = 1)
|
||||||
|
Changed some API functions, f_mkfs() and f_fdisk().
|
||||||
|
Fixed f_open() function cannot find the file with file name in length of FF_MAX_LFN characters.
|
||||||
|
Fixed f_readdir() function cannot retrieve long file names in length of FF_MAX_LFN - 1 characters.
|
||||||
|
Fixed f_readdir() function returns file names with wrong case conversion. (appeared at R0.12)
|
||||||
|
Fixed f_mkfs() function can fail to create exFAT volume in the second partition. (appeared at R0.12)
|
||||||
|
|
||||||
|
|
||||||
|
R0.14a (December 5, 2020)
|
||||||
|
Limited number of recursive calls in f_findnext().
|
||||||
|
Fixed old floppy disks formatted with MS-DOS 2.x and 3.x cannot be mounted.
|
||||||
|
Fixed some compiler warnings.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.14b (April 17, 2021)
|
||||||
|
Made FatFs uses standard library <string.h> for copy, compare and search instead of built-in string functions.
|
||||||
|
Added support for long long integer and floating point to f_printf(). (FF_STRF_LLI and FF_STRF_FP)
|
||||||
|
Made path name parser ignore the terminating separator to allow "dir/".
|
||||||
|
Improved the compatibility in Unix style path name feature.
|
||||||
|
Fixed the file gets dead-locked when f_open() failed with some conditions. (appeared at R0.12a)
|
||||||
|
Fixed f_mkfs() can create wrong exFAT volume due to a timing dependent error. (appeared at R0.12)
|
||||||
|
Fixed code page 855 cannot be set by f_setcp().
|
||||||
|
Fixed some compiler warnings.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.15 (November 6, 2022)
|
||||||
|
Changed user provided synchronization functions in order to completely eliminate the platform dependency from FatFs code.
|
||||||
|
FF_SYNC_t is removed from the configuration options.
|
||||||
|
Fixed a potential error in f_mount when FF_FS_REENTRANT.
|
||||||
|
Fixed file lock control FF_FS_LOCK is not mutal excluded when FF_FS_REENTRANT && FF_VOLUMES > 1 is true.
|
||||||
|
Fixed f_mkfs() creates broken exFAT volume when the size of volume is >= 2^32 sectors.
|
||||||
|
Fixed string functions cannot write the unicode characters not in BMP when FF_LFN_UNICODE == 2 (UTF-8).
|
||||||
|
Fixed a compatibility issue in identification of GPT header.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.15a (November 22, 2024)
|
||||||
|
Fixed a complie error when FF_FS_LOCK != 0.
|
||||||
|
Fixed a potential issue when work FatFs concurrency with FF_FS_REENTRANT, FF_VOLUMES >= 2 and FF_FS_LOCK > 0.
|
||||||
|
Made f_setlabel() accept a volume label in Unix style volume ID when FF_STR_VOLUME_ID == 2.
|
||||||
|
Made FatFs update PercInUse field in exFAT VBR. (A preceding f_getfree() is needed for the accuracy)
|
||||||
|
|
||||||
21
software/sys_controller/fatfs/source/00readme.txt
Normal file
21
software/sys_controller/fatfs/source/00readme.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
FatFs Module Source Files R0.15
|
||||||
|
|
||||||
|
|
||||||
|
FILES
|
||||||
|
|
||||||
|
00readme.txt This file.
|
||||||
|
00history.txt Revision history.
|
||||||
|
ff.c FatFs module.
|
||||||
|
ffconf.h Configuration file of FatFs module.
|
||||||
|
ff.h Common include file for FatFs and application module.
|
||||||
|
diskio.h Common include file for FatFs and disk I/O module.
|
||||||
|
diskio.c An example of glue function to attach existing disk I/O module to FatFs.
|
||||||
|
ffunicode.c Optional Unicode utility functions.
|
||||||
|
ffsystem.c An example of optional O/S related functions.
|
||||||
|
|
||||||
|
|
||||||
|
Low level disk I/O module is not included in this archive because the FatFs
|
||||||
|
module is only a generic file system layer and it does not depend on any specific
|
||||||
|
storage device. You need to provide a low level disk I/O module written to
|
||||||
|
control the storage device that attached to the target system.
|
||||||
|
|
||||||
128
software/sys_controller/fatfs/source/diskio.c
Normal file
128
software/sys_controller/fatfs/source/diskio.c
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Low level disk I/O module SKELETON for FatFs (C)ChaN, 2019 */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* If a working storage control module is available, it should be */
|
||||||
|
/* attached to the FatFs via a glue function rather than modifying it. */
|
||||||
|
/* This is an example of glue functions to attach various exsisting */
|
||||||
|
/* storage control modules to the FatFs module with a defined API. */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "ff.h" /* Obtains integer types */
|
||||||
|
#include "diskio.h" /* Declarations of disk functions */
|
||||||
|
#include "sd_io.h"
|
||||||
|
#include "sysconfig.h"
|
||||||
|
|
||||||
|
extern SD_DEV sdcard_dev;
|
||||||
|
|
||||||
|
/* Definitions of physical drive number for each drive */
|
||||||
|
#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */
|
||||||
|
#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */
|
||||||
|
#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Get Drive Status */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
DSTATUS disk_status (
|
||||||
|
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//res = SD_Status(&sdcard_dev);
|
||||||
|
|
||||||
|
return sdcard_dev.mount ? RES_OK : STA_NODISK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Inidialize a Drive */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
DSTATUS disk_initialize (
|
||||||
|
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DSTATUS stat;
|
||||||
|
SDRESULTS res;
|
||||||
|
|
||||||
|
if (sdcard_dev.mount)
|
||||||
|
return SD_OK;
|
||||||
|
|
||||||
|
res = SD_Init(&sdcard_dev);
|
||||||
|
|
||||||
|
return (res == SD_OK) ? RES_OK : STA_NOINIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Read Sector(s) */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
DRESULT disk_read (
|
||||||
|
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||||
|
BYTE *buff, /* Data buffer to store read data */
|
||||||
|
LBA_t sector, /* Start sector in LBA */
|
||||||
|
UINT count /* Number of sectors to read */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SDRESULTS res;
|
||||||
|
|
||||||
|
if (!sdcard_dev.mount)
|
||||||
|
return STA_NOINIT;
|
||||||
|
|
||||||
|
res = SD_Read(&sdcard_dev, buff, sector, 0, count*SD_BLK_SIZE);
|
||||||
|
|
||||||
|
return (res == SD_OK) ? RES_OK : RES_PARERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Write Sector(s) */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if FF_FS_READONLY == 0
|
||||||
|
|
||||||
|
DRESULT disk_write (
|
||||||
|
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||||
|
const BYTE *buff, /* Data to be written */
|
||||||
|
LBA_t sector, /* Start sector in LBA */
|
||||||
|
UINT count /* Number of sectors to write */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SDRESULTS res;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!sdcard_dev.mount)
|
||||||
|
return STA_NOINIT;
|
||||||
|
|
||||||
|
for (i=0; i<count; i++) {
|
||||||
|
res = SD_Write(&sdcard_dev, (void*)&buff[i*SD_BLK_SIZE], sector);
|
||||||
|
if (res != SD_OK)
|
||||||
|
return RES_PARERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RES_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Miscellaneous Functions */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
DRESULT disk_ioctl (
|
||||||
|
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||||
|
BYTE cmd, /* Control code */
|
||||||
|
void *buff /* Buffer to send/receive control data */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DRESULT res;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
return RES_PARERR;
|
||||||
|
}
|
||||||
|
|
||||||
77
software/sys_controller/fatfs/source/diskio.h
Normal file
77
software/sys_controller/fatfs/source/diskio.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*-----------------------------------------------------------------------/
|
||||||
|
/ Low level disk interface modlue include file (C)ChaN, 2019 /
|
||||||
|
/-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef _DISKIO_DEFINED
|
||||||
|
#define _DISKIO_DEFINED
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Status of Disk Functions */
|
||||||
|
typedef BYTE DSTATUS;
|
||||||
|
|
||||||
|
/* Results of Disk Functions */
|
||||||
|
typedef enum {
|
||||||
|
RES_OK = 0, /* 0: Successful */
|
||||||
|
RES_ERROR, /* 1: R/W Error */
|
||||||
|
RES_WRPRT, /* 2: Write Protected */
|
||||||
|
RES_NOTRDY, /* 3: Not Ready */
|
||||||
|
RES_PARERR /* 4: Invalid Parameter */
|
||||||
|
} DRESULT;
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------*/
|
||||||
|
/* Prototypes for disk control functions */
|
||||||
|
|
||||||
|
|
||||||
|
DSTATUS disk_initialize (BYTE pdrv);
|
||||||
|
DSTATUS disk_status (BYTE pdrv);
|
||||||
|
DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
|
||||||
|
DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
|
||||||
|
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||||
|
|
||||||
|
|
||||||
|
/* Disk Status Bits (DSTATUS) */
|
||||||
|
|
||||||
|
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||||
|
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||||
|
#define STA_PROTECT 0x04 /* Write protected */
|
||||||
|
|
||||||
|
|
||||||
|
/* Command code for disk_ioctrl fucntion */
|
||||||
|
|
||||||
|
/* Generic command (Used by FatFs) */
|
||||||
|
#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
|
||||||
|
#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
|
||||||
|
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
|
||||||
|
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
|
||||||
|
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
|
||||||
|
|
||||||
|
/* Generic command (Not used by FatFs) */
|
||||||
|
#define CTRL_POWER 5 /* Get/Set power status */
|
||||||
|
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
|
||||||
|
#define CTRL_EJECT 7 /* Eject media */
|
||||||
|
#define CTRL_FORMAT 8 /* Create physical format on the media */
|
||||||
|
|
||||||
|
/* MMC/SDC specific ioctl command */
|
||||||
|
#define MMC_GET_TYPE 10 /* Get card type */
|
||||||
|
#define MMC_GET_CSD 11 /* Get CSD */
|
||||||
|
#define MMC_GET_CID 12 /* Get CID */
|
||||||
|
#define MMC_GET_OCR 13 /* Get OCR */
|
||||||
|
#define MMC_GET_SDSTAT 14 /* Get SD status */
|
||||||
|
#define ISDIO_READ 55 /* Read data form SD iSDIO register */
|
||||||
|
#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
|
||||||
|
#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
|
||||||
|
|
||||||
|
/* ATA/CF specific ioctl command */
|
||||||
|
#define ATA_GET_REV 20 /* Get F/W revision */
|
||||||
|
#define ATA_GET_MODEL 21 /* Get model name */
|
||||||
|
#define ATA_GET_SN 22 /* Get serial number */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
7181
software/sys_controller/fatfs/source/ff.c
Normal file
7181
software/sys_controller/fatfs/source/ff.c
Normal file
File diff suppressed because it is too large
Load Diff
431
software/sys_controller/fatfs/source/ff.h
Normal file
431
software/sys_controller/fatfs/source/ff.h
Normal file
@ -0,0 +1,431 @@
|
|||||||
|
/*----------------------------------------------------------------------------/
|
||||||
|
/ FatFs - Generic FAT Filesystem module R0.15a /
|
||||||
|
/-----------------------------------------------------------------------------/
|
||||||
|
/
|
||||||
|
/ Copyright (C) 2024, ChaN, all right reserved.
|
||||||
|
/
|
||||||
|
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||||
|
/ source and binary forms, with or without modification, are permitted provided
|
||||||
|
/ that the following condition is met:
|
||||||
|
|
||||||
|
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
/ this condition and the following disclaimer.
|
||||||
|
/
|
||||||
|
/ This software is provided by the copyright holder and contributors "AS IS"
|
||||||
|
/ and any warranties related to this software are DISCLAIMED.
|
||||||
|
/ The copyright owner or contributors be NOT LIABLE for any damages caused
|
||||||
|
/ by use of this software.
|
||||||
|
/
|
||||||
|
/----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FF_DEFINED
|
||||||
|
#define FF_DEFINED 5380 /* Revision ID */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(FFCONF_DEF)
|
||||||
|
#include "ffconf.h" /* FatFs configuration options */
|
||||||
|
#endif
|
||||||
|
#if FF_DEFINED != FFCONF_DEF
|
||||||
|
#error Wrong configuration file (ffconf.h).
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Integer types used for FatFs API */
|
||||||
|
|
||||||
|
#if defined(_WIN32) /* Windows VC++ (for development only) */
|
||||||
|
#define FF_INTDEF 2
|
||||||
|
#include <windows.h>
|
||||||
|
typedef unsigned __int64 QWORD;
|
||||||
|
#include <float.h>
|
||||||
|
#define isnan(v) _isnan(v)
|
||||||
|
#define isinf(v) (!_finite(v))
|
||||||
|
|
||||||
|
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
||||||
|
#define FF_INTDEF 2
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||||
|
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||||
|
typedef uint16_t WORD; /* 16-bit unsigned */
|
||||||
|
typedef uint32_t DWORD; /* 32-bit unsigned */
|
||||||
|
typedef uint64_t QWORD; /* 64-bit unsigned */
|
||||||
|
typedef WORD WCHAR; /* UTF-16 code unit */
|
||||||
|
|
||||||
|
#else /* Earlier than C99 */
|
||||||
|
#define FF_INTDEF 1
|
||||||
|
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||||
|
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||||
|
typedef unsigned short WORD; /* short must be 16-bit */
|
||||||
|
typedef unsigned long DWORD; /* long must be 32-bit */
|
||||||
|
typedef WORD WCHAR; /* UTF-16 code unit */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Type of file size and LBA variables */
|
||||||
|
|
||||||
|
#if FF_FS_EXFAT
|
||||||
|
#if FF_INTDEF != 2
|
||||||
|
#error exFAT feature wants C99 or later
|
||||||
|
#endif
|
||||||
|
typedef QWORD FSIZE_t;
|
||||||
|
#if FF_LBA64
|
||||||
|
typedef QWORD LBA_t;
|
||||||
|
#else
|
||||||
|
typedef DWORD LBA_t;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if FF_LBA64
|
||||||
|
#error exFAT needs to be enabled when enable 64-bit LBA
|
||||||
|
#endif
|
||||||
|
typedef DWORD FSIZE_t;
|
||||||
|
typedef DWORD LBA_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Type of path name strings on FatFs API (TCHAR) */
|
||||||
|
|
||||||
|
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
|
||||||
|
typedef WCHAR TCHAR;
|
||||||
|
#define _T(x) L ## x
|
||||||
|
#define _TEXT(x) L ## x
|
||||||
|
#elif FF_USE_LFN && FF_LFN_UNICODE == 2 /* Unicode in UTF-8 encoding */
|
||||||
|
typedef char TCHAR;
|
||||||
|
#define _T(x) u8 ## x
|
||||||
|
#define _TEXT(x) u8 ## x
|
||||||
|
#elif FF_USE_LFN && FF_LFN_UNICODE == 3 /* Unicode in UTF-32 encoding */
|
||||||
|
typedef DWORD TCHAR;
|
||||||
|
#define _T(x) U ## x
|
||||||
|
#define _TEXT(x) U ## x
|
||||||
|
#elif FF_USE_LFN && (FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 3)
|
||||||
|
#error Wrong FF_LFN_UNICODE setting
|
||||||
|
#else /* ANSI/OEM code in SBCS/DBCS */
|
||||||
|
typedef char TCHAR;
|
||||||
|
#define _T(x) x
|
||||||
|
#define _TEXT(x) x
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Definitions of volume management */
|
||||||
|
|
||||||
|
#if FF_MULTI_PARTITION /* Multiple partition configuration */
|
||||||
|
typedef struct {
|
||||||
|
BYTE pd; /* Associated physical drive */
|
||||||
|
BYTE pt; /* Associated partition (0:Auto detect, 1-4:Forced partition) */
|
||||||
|
} PARTITION;
|
||||||
|
extern PARTITION VolToPart[]; /* Volume to partition mapping table */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if FF_STR_VOLUME_ID
|
||||||
|
#ifndef FF_VOLUME_STRS
|
||||||
|
extern const char* VolumeStr[FF_VOLUMES]; /* User defined volume ID table */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Filesystem object structure (FATFS) */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BYTE fs_type; /* Filesystem type (0:blank filesystem object) */
|
||||||
|
BYTE pdrv; /* Volume hosting physical drive */
|
||||||
|
BYTE ldrv; /* Logical drive number (used only when FF_FS_REENTRANT) */
|
||||||
|
BYTE n_fats; /* Number of FATs (1 or 2) */
|
||||||
|
BYTE wflag; /* win[] status (1:dirty) */
|
||||||
|
BYTE fsi_flag; /* Allocation information control (b7:disabled, b0:dirty) */
|
||||||
|
WORD id; /* Volume mount ID */
|
||||||
|
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||||
|
WORD csize; /* Cluster size [sectors] */
|
||||||
|
#if FF_MAX_SS != FF_MIN_SS
|
||||||
|
WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */
|
||||||
|
#endif
|
||||||
|
#if FF_USE_LFN
|
||||||
|
WCHAR* lfnbuf; /* LFN working buffer */
|
||||||
|
#endif
|
||||||
|
#if FF_FS_EXFAT
|
||||||
|
BYTE* dirbuf; /* Directory entry block scratch pad buffer for exFAT */
|
||||||
|
#endif
|
||||||
|
#if !FF_FS_READONLY
|
||||||
|
DWORD last_clst; /* Last allocated cluster (Unknown if >= n_fatent) */
|
||||||
|
DWORD free_clst; /* Number of free clusters (Unknown if >= n_fatent-2) */
|
||||||
|
#endif
|
||||||
|
#if FF_FS_RPATH
|
||||||
|
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||||
|
#if FF_FS_EXFAT
|
||||||
|
DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */
|
||||||
|
DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */
|
||||||
|
DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
||||||
|
DWORD fsize; /* Number of sectors per FAT */
|
||||||
|
LBA_t volbase; /* Volume base sector */
|
||||||
|
LBA_t fatbase; /* FAT base sector */
|
||||||
|
LBA_t dirbase; /* Root directory base sector (FAT12/16) or cluster (FAT32/exFAT) */
|
||||||
|
LBA_t database; /* Data base sector */
|
||||||
|
#if FF_FS_EXFAT
|
||||||
|
LBA_t bitbase; /* Allocation bitmap base sector */
|
||||||
|
#endif
|
||||||
|
LBA_t winsect; /* Current sector appearing in the win[] */
|
||||||
|
BYTE win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||||
|
} FATFS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Object ID and allocation information (FFOBJID) */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FATFS* fs; /* Pointer to the hosting volume of this object */
|
||||||
|
WORD id; /* Hosting volume's mount ID */
|
||||||
|
BYTE attr; /* Object attribute */
|
||||||
|
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
||||||
|
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
||||||
|
FSIZE_t objsize; /* Object size (valid when sclust != 0) */
|
||||||
|
#if FF_FS_EXFAT
|
||||||
|
DWORD n_cont; /* Size of first fragment - 1 (valid when stat == 3) */
|
||||||
|
DWORD n_frag; /* Size of last fragment needs to be written to FAT (valid when not zero) */
|
||||||
|
DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */
|
||||||
|
DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
|
||||||
|
DWORD c_ofs; /* Offset in the containing directory (valid when file object and sclust != 0) */
|
||||||
|
#endif
|
||||||
|
#if FF_FS_LOCK
|
||||||
|
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||||
|
#endif
|
||||||
|
} FFOBJID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* File object structure (FIL) */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FFOBJID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */
|
||||||
|
BYTE flag; /* File status flags */
|
||||||
|
BYTE err; /* Abort flag (error code) */
|
||||||
|
FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
|
||||||
|
DWORD clust; /* Current cluster of fpter (invalid when fptr is 0) */
|
||||||
|
LBA_t sect; /* Sector number appearing in buf[] (0:invalid) */
|
||||||
|
#if !FF_FS_READONLY
|
||||||
|
LBA_t dir_sect; /* Sector number containing the directory entry (not used at exFAT) */
|
||||||
|
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] (not used at exFAT) */
|
||||||
|
#endif
|
||||||
|
#if FF_USE_FASTSEEK
|
||||||
|
DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */
|
||||||
|
#endif
|
||||||
|
#if !FF_FS_TINY
|
||||||
|
BYTE buf[FF_MAX_SS]; /* File private data read/write window */
|
||||||
|
#endif
|
||||||
|
} FIL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Directory object structure (DIR) */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FFOBJID obj; /* Object identifier */
|
||||||
|
DWORD dptr; /* Current read/write offset */
|
||||||
|
DWORD clust; /* Current cluster */
|
||||||
|
LBA_t sect; /* Current sector (0:Read operation has terminated) */
|
||||||
|
BYTE* dir; /* Pointer to the directory item in the win[] */
|
||||||
|
BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */
|
||||||
|
#if FF_USE_LFN
|
||||||
|
DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
|
||||||
|
#endif
|
||||||
|
#if FF_USE_FIND
|
||||||
|
const TCHAR* pat; /* Pointer to the name matching pattern */
|
||||||
|
#endif
|
||||||
|
} DIR;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* File information structure (FILINFO) */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FSIZE_t fsize; /* File size */
|
||||||
|
WORD fdate; /* Modified date */
|
||||||
|
WORD ftime; /* Modified time */
|
||||||
|
BYTE fattrib; /* File attribute */
|
||||||
|
#if FF_USE_LFN
|
||||||
|
TCHAR altname[FF_SFN_BUF + 1];/* Alternative file name */
|
||||||
|
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
|
||||||
|
#else
|
||||||
|
TCHAR fname[12 + 1]; /* File name */
|
||||||
|
#endif
|
||||||
|
} FILINFO;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Format parameter structure (MKFS_PARM) */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BYTE fmt; /* Format option (FM_FAT, FM_FAT32, FM_EXFAT and FM_SFD) */
|
||||||
|
BYTE n_fat; /* Number of FATs */
|
||||||
|
UINT align; /* Data area alignment (sector) */
|
||||||
|
UINT n_root; /* Number of root directory entries */
|
||||||
|
DWORD au_size; /* Cluster size (byte) */
|
||||||
|
} MKFS_PARM;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* File function return code (FRESULT) */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FR_OK = 0, /* (0) Function succeeded */
|
||||||
|
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
|
||||||
|
FR_INT_ERR, /* (2) Assertion failed */
|
||||||
|
FR_NOT_READY, /* (3) The physical drive does not work */
|
||||||
|
FR_NO_FILE, /* (4) Could not find the file */
|
||||||
|
FR_NO_PATH, /* (5) Could not find the path */
|
||||||
|
FR_INVALID_NAME, /* (6) The path name format is invalid */
|
||||||
|
FR_DENIED, /* (7) Access denied due to a prohibited access or directory full */
|
||||||
|
FR_EXIST, /* (8) Access denied due to a prohibited access */
|
||||||
|
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
|
||||||
|
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
|
||||||
|
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
||||||
|
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
||||||
|
FR_NO_FILESYSTEM, /* (13) Could not find a valid FAT volume */
|
||||||
|
FR_MKFS_ABORTED, /* (14) The f_mkfs function aborted due to some problem */
|
||||||
|
FR_TIMEOUT, /* (15) Could not take control of the volume within defined period */
|
||||||
|
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
|
||||||
|
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated or given buffer is insufficient in size */
|
||||||
|
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */
|
||||||
|
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
||||||
|
} FRESULT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
/* FatFs Module Application Interface */
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
|
||||||
|
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||||
|
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||||
|
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */
|
||||||
|
FRESULT f_read_cc (FIL* fp, uint32_t* buff, UINT btr, UINT* br, UINT max_clusters); /* Collect cluster# */
|
||||||
|
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */
|
||||||
|
FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */
|
||||||
|
FRESULT f_truncate (FIL* fp); /* Truncate the file */
|
||||||
|
FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */
|
||||||
|
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||||
|
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||||
|
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||||
|
FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
|
||||||
|
FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */
|
||||||
|
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||||
|
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||||
|
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||||
|
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||||
|
FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
|
||||||
|
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */
|
||||||
|
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||||
|
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||||
|
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||||
|
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||||
|
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||||
|
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||||
|
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||||
|
FRESULT f_expand (FIL* fp, FSIZE_t fsz, BYTE opt); /* Allocate a contiguous block to the file */
|
||||||
|
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||||
|
FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */
|
||||||
|
FRESULT f_fdisk (BYTE pdrv, const LBA_t ptbl[], void* work); /* Divide a physical drive into some partitions */
|
||||||
|
FRESULT f_setcp (WORD cp); /* Set current code page */
|
||||||
|
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||||
|
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||||
|
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||||
|
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||||
|
|
||||||
|
/* Some API fucntions are implemented as macro */
|
||||||
|
|
||||||
|
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
||||||
|
#define f_error(fp) ((fp)->err)
|
||||||
|
#define f_tell(fp) ((fp)->fptr)
|
||||||
|
#define f_size(fp) ((fp)->obj.objsize)
|
||||||
|
#define f_rewind(fp) f_lseek((fp), 0)
|
||||||
|
#define f_rewinddir(dp) f_readdir((dp), 0)
|
||||||
|
#define f_rmdir(path) f_unlink(path)
|
||||||
|
#define f_unmount(path) f_mount(0, path, 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
/* Additional Functions */
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* RTC function (provided by user) */
|
||||||
|
#if !FF_FS_READONLY && !FF_FS_NORTC
|
||||||
|
DWORD get_fattime (void); /* Get current time */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* LFN support functions (defined in ffunicode.c) */
|
||||||
|
|
||||||
|
#if FF_USE_LFN >= 1
|
||||||
|
WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
|
||||||
|
WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
|
||||||
|
DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* O/S dependent functions (samples available in ffsystem.c) */
|
||||||
|
|
||||||
|
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||||
|
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||||
|
void ff_memfree (void* mblock); /* Free memory block */
|
||||||
|
#endif
|
||||||
|
#if FF_FS_REENTRANT /* Sync functions */
|
||||||
|
int ff_mutex_create (int vol); /* Create a sync object */
|
||||||
|
void ff_mutex_delete (int vol); /* Delete a sync object */
|
||||||
|
int ff_mutex_take (int vol); /* Lock sync object */
|
||||||
|
void ff_mutex_give (int vol); /* Unlock sync object */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
/* Flags and Offset Address */
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* File access mode and open method flags (3rd argument of f_open function) */
|
||||||
|
#define FA_READ 0x01
|
||||||
|
#define FA_WRITE 0x02
|
||||||
|
#define FA_OPEN_EXISTING 0x00
|
||||||
|
#define FA_CREATE_NEW 0x04
|
||||||
|
#define FA_CREATE_ALWAYS 0x08
|
||||||
|
#define FA_OPEN_ALWAYS 0x10
|
||||||
|
#define FA_OPEN_APPEND 0x30
|
||||||
|
|
||||||
|
/* Fast seek controls (2nd argument of f_lseek function) */
|
||||||
|
#define CREATE_LINKMAP ((FSIZE_t)0 - 1)
|
||||||
|
|
||||||
|
/* Format options (2nd argument of f_mkfs function) */
|
||||||
|
#define FM_FAT 0x01
|
||||||
|
#define FM_FAT32 0x02
|
||||||
|
#define FM_EXFAT 0x04
|
||||||
|
#define FM_ANY 0x07
|
||||||
|
#define FM_SFD 0x08
|
||||||
|
|
||||||
|
/* Filesystem type (FATFS.fs_type) */
|
||||||
|
#define FS_FAT12 1
|
||||||
|
#define FS_FAT16 2
|
||||||
|
#define FS_FAT32 3
|
||||||
|
#define FS_EXFAT 4
|
||||||
|
|
||||||
|
/* File attribute bits for directory entry (FILINFO.fattrib) */
|
||||||
|
#define AM_RDO 0x01 /* Read only */
|
||||||
|
#define AM_HID 0x02 /* Hidden */
|
||||||
|
#define AM_SYS 0x04 /* System */
|
||||||
|
#define AM_DIR 0x10 /* Directory */
|
||||||
|
#define AM_ARC 0x20 /* Archive */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* FF_DEFINED */
|
||||||
208
software/sys_controller/fatfs/source/ffsystem.c
Normal file
208
software/sys_controller/fatfs/source/ffsystem.c
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* A Sample Code of User Provided OS Dependent Functions for FatFs */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "ff.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if FF_USE_LFN == 3 /* Use dynamic memory allocation */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Allocate/Free a Memory Block */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <stdlib.h> /* with POSIX API */
|
||||||
|
|
||||||
|
|
||||||
|
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
||||||
|
UINT msize /* Number of bytes to allocate */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return malloc((size_t)msize); /* Allocate a new memory block */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ff_memfree (
|
||||||
|
void* mblock /* Pointer to the memory block to free (no effect if null) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
free(mblock); /* Free the memory block */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if FF_FS_REENTRANT /* Mutal exclusion */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Definitions of Mutex */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define OS_TYPE 0 /* 0:Win32, 1:uITRON4.0, 2:uC/OS-II, 3:FreeRTOS, 4:CMSIS-RTOS */
|
||||||
|
|
||||||
|
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
#include <windows.h>
|
||||||
|
static HANDLE Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
#include "itron.h"
|
||||||
|
#include "kernel.h"
|
||||||
|
static mtxid Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uc/OS-II */
|
||||||
|
#include "includes.h"
|
||||||
|
static OS_EVENT *Mutex[FF_VOLUMES + 1]; /* Table of mutex pinter */
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
static SemaphoreHandle_t Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
#include "cmsis_os.h"
|
||||||
|
static osMutexId Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Create a Mutex */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called in f_mount function to create a new mutex
|
||||||
|
/ or semaphore for the volume. When a 0 is returned, the f_mount function
|
||||||
|
/ fails with FR_INT_ERR.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ff_mutex_create ( /* Returns 1:Function succeeded or 0:Could not create the mutex */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
Mutex[vol] = CreateMutex(NULL, FALSE, NULL);
|
||||||
|
return (int)(Mutex[vol] != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
T_CMTX cmtx = {TA_TPRI,1};
|
||||||
|
|
||||||
|
Mutex[vol] = acre_mtx(&cmtx);
|
||||||
|
return (int)(Mutex[vol] > 0);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
Mutex[vol] = OSMutexCreate(0, &err);
|
||||||
|
return (int)(err == OS_NO_ERR);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
Mutex[vol] = xSemaphoreCreateMutex();
|
||||||
|
return (int)(Mutex[vol] != NULL);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexDef(cmsis_os_mutex);
|
||||||
|
|
||||||
|
Mutex[vol] = osMutexCreate(osMutex(cmsis_os_mutex));
|
||||||
|
return (int)(Mutex[vol] != NULL);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Delete a Mutex */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called in f_mount function to delete a mutex or
|
||||||
|
/ semaphore of the volume created with ff_mutex_create function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ff_mutex_delete ( /* Returns 1:Function succeeded or 0:Could not delete due to an error */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
CloseHandle(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
del_mtx(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
OSMutexDel(Mutex[vol], OS_DEL_ALWAYS, &err);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
vSemaphoreDelete(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexDelete(Mutex[vol]);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Request a Grant to Access the Volume */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called on enter file functions to lock the volume.
|
||||||
|
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ff_mutex_take ( /* Returns 1:Succeeded or 0:Timeout */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
return (int)(WaitForSingleObject(Mutex[vol], FF_FS_TIMEOUT) == WAIT_OBJECT_0);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
return (int)(tloc_mtx(Mutex[vol], FF_FS_TIMEOUT) == E_OK);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
OSMutexPend(Mutex[vol], FF_FS_TIMEOUT, &err));
|
||||||
|
return (int)(err == OS_NO_ERR);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
return (int)(xSemaphoreTake(Mutex[vol], FF_FS_TIMEOUT) == pdTRUE);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
return (int)(osMutexWait(Mutex[vol], FF_FS_TIMEOUT) == osOK);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Release a Grant to Access the Volume */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called on leave file functions to unlock the volume.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ff_mutex_give (
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
ReleaseMutex(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
unl_mtx(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OSMutexPost(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
xSemaphoreGive(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexRelease(Mutex[vol]);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FF_FS_REENTRANT */
|
||||||
|
|
||||||
15593
software/sys_controller/fatfs/source/ffunicode.c
Normal file
15593
software/sys_controller/fatfs/source/ffunicode.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -3401,6 +3401,8 @@ SetGPInfoFrame(BYTE *pInfoFrameData)
|
|||||||
return ER_FAIL ;
|
return ER_FAIL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DISABLE_NULL_PKT();
|
||||||
|
|
||||||
Switch_HDMITX_Bank(1) ;
|
Switch_HDMITX_Bank(1) ;
|
||||||
|
|
||||||
HDMITX_WriteI2C_Byte(REG_TX_PKT_HB00, (0x80+pInfoFrame->info.Type));
|
HDMITX_WriteI2C_Byte(REG_TX_PKT_HB00, (0x80+pInfoFrame->info.Type));
|
||||||
@ -18,6 +18,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "i2c_opencores.h"
|
#include "i2c_opencores.h"
|
||||||
1337
software/sys_controller/ic_drivers/sh1107/font12.h
Normal file
1337
software/sys_controller/ic_drivers/sh1107/font12.h
Normal file
File diff suppressed because it is too large
Load Diff
139
software/sys_controller/ic_drivers/sh1107/sh1107.c
Normal file
139
software/sys_controller/ic_drivers/sh1107/sh1107.c
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
//
|
||||||
|
// Copyright (C) 2025 Balázs Triszka <info@balika011.hu>
|
||||||
|
//
|
||||||
|
// This file is part of Open Source Scan Converter project.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "sh1107.h"
|
||||||
|
#include "alt_types.h"
|
||||||
|
#include "altera_avalon_pio_regs.h"
|
||||||
|
#include "i2c_opencores.h"
|
||||||
|
#include "av_controller.h"
|
||||||
|
#include "font12.h"
|
||||||
|
|
||||||
|
#define OLED_WIDTH 128
|
||||||
|
#define OLED_HEIGHT 64
|
||||||
|
|
||||||
|
extern alt_u32 sys_ctrl;
|
||||||
|
|
||||||
|
static void OLED_Write(uint8_t value)
|
||||||
|
{
|
||||||
|
SPI_write(I2CA_BASE, &value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sh1107_init()
|
||||||
|
{
|
||||||
|
sys_ctrl &= ~(LCD_CS_N | LCD_RS);
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
|
||||||
|
alt_u8 init[] = {
|
||||||
|
0xae, /*turn off OLED display*/
|
||||||
|
0x00, /*set lower column address*/
|
||||||
|
0x10, /*set higher column address*/
|
||||||
|
0xb0, /*set page address*/
|
||||||
|
0xdc, 0x00, /*set display start line*/
|
||||||
|
0x81, /*contract control*/
|
||||||
|
0x6f, /*128*/
|
||||||
|
0x21, /* Set Memory addressing mode (0x20/0x21) */
|
||||||
|
0xa1, /*set segment remap*/
|
||||||
|
0xc0, /*Com scan direction*/
|
||||||
|
0xa4, /*Disable Entire Display On (0xA4/0xA5)*/
|
||||||
|
0xa6, /*normal / reverse*/
|
||||||
|
0xa8, /*multiplex ratio*/
|
||||||
|
0x3f, /*duty = 1/64*/
|
||||||
|
0xd3, 0x60, /*set display offset*/
|
||||||
|
0xd5, 0x41, /*set osc division*/
|
||||||
|
0xd9, 0x22, /*set pre-charge period*/
|
||||||
|
0xdb, 0x35, /*set vcomh*/
|
||||||
|
0xad, /*set charge pump enable*/
|
||||||
|
0x8a /*Set DC-DC enable (a=0:disable; a=1:enable) */
|
||||||
|
};
|
||||||
|
SPI_write(I2CA_BASE, init, sizeof(init));
|
||||||
|
|
||||||
|
// Clear the screen
|
||||||
|
OLED_Write(0xb0);
|
||||||
|
for (alt_u8 i = 0; i < OLED_HEIGHT; i++)
|
||||||
|
{
|
||||||
|
sys_ctrl &= ~LCD_RS;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
OLED_Write(0x00 + (i & 0x0f));
|
||||||
|
OLED_Write(0x10 + (i >> 4));
|
||||||
|
|
||||||
|
sys_ctrl |= LCD_RS;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
for (alt_u8 i = 0; i < OLED_WIDTH / 8; i++)
|
||||||
|
OLED_Write(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_ctrl &= ~LCD_RS;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
|
||||||
|
// Turn on
|
||||||
|
OLED_Write(0xaf);
|
||||||
|
|
||||||
|
sys_ctrl |= LCD_CS_N;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sh1107_write(char *row1, char *row2)
|
||||||
|
{
|
||||||
|
sys_ctrl &= ~(LCD_CS_N | LCD_RS);
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
|
||||||
|
alt_u8 row1len = strnlen(row1, LCD_ROW_LEN);
|
||||||
|
|
||||||
|
for (alt_u8 i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
sys_ctrl &= ~LCD_RS;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
OLED_Write(0xb0);
|
||||||
|
OLED_Write(0x00 + ((i + 13) & 0x0f));
|
||||||
|
OLED_Write(0x10 + ((i + 13) >> 4));
|
||||||
|
|
||||||
|
sys_ctrl |= LCD_RS;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
for (alt_u8 j = 0; j < row1len; j++)
|
||||||
|
OLED_Write(Font12_Table[(row1[j] - 0x20) * 12 + i]);
|
||||||
|
|
||||||
|
for (alt_u8 j = row1len; j < LCD_ROW_LEN; j++)
|
||||||
|
OLED_Write(Font12_Table[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
alt_u8 row2len = strnlen(row2, LCD_ROW_LEN);
|
||||||
|
|
||||||
|
for (alt_u8 i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
sys_ctrl &= ~LCD_RS;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
OLED_Write(0xb0);
|
||||||
|
OLED_Write(0x00 + ((i + 39) & 0x0f));
|
||||||
|
OLED_Write(0x10 + ((i + 39) >> 4));
|
||||||
|
|
||||||
|
sys_ctrl |= LCD_RS;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
for (alt_u8 j = 0; j < row2len; j++)
|
||||||
|
OLED_Write(Font12_Table[(row2[j] - 0x20) * 12 + i]);
|
||||||
|
|
||||||
|
for (alt_u8 j = row2len; j < LCD_ROW_LEN; j++)
|
||||||
|
OLED_Write(Font12_Table[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_ctrl |= LCD_CS_N;
|
||||||
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
}
|
||||||
31
software/sys_controller/ic_drivers/sh1107/sh1107.h
Normal file
31
software/sys_controller/ic_drivers/sh1107/sh1107.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// Copyright (C) 2025 Balázs Triszka <info@balika011.hu>
|
||||||
|
//
|
||||||
|
// This file is part of Open Source Scan Converter project.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef SH1107_H_
|
||||||
|
#define SH1107_H_
|
||||||
|
|
||||||
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "sysconfig.h"
|
||||||
|
|
||||||
|
void sh1107_init();
|
||||||
|
|
||||||
|
void sh1107_write(char *row1, char *row2);
|
||||||
|
|
||||||
|
#endif /* sh1107_H_ */
|
||||||
@ -1,5 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2015-2016 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
// Copyright (C) 2015-2016 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
||||||
|
// Copyright (C) 2025 Balázs Triszka <info@balika011.hu>
|
||||||
//
|
//
|
||||||
// This file is part of Open Source Scan Converter project.
|
// This file is part of Open Source Scan Converter project.
|
||||||
//
|
//
|
||||||
@ -20,14 +21,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
#include "st7032.h"
|
||||||
#include "alt_types.h"
|
#include "alt_types.h"
|
||||||
#include "altera_avalon_pio_regs.h"
|
#include "altera_avalon_pio_regs.h"
|
||||||
#include "i2c_opencores.h"
|
#include "i2c_opencores.h"
|
||||||
#include "av_controller.h"
|
#include "av_controller.h"
|
||||||
|
|
||||||
#define LCD_CMD 0x00
|
|
||||||
#define LCD_DATA 0x40
|
|
||||||
|
|
||||||
#define WRDELAY 20
|
#define WRDELAY 20
|
||||||
#define CLEARDELAY 800
|
#define CLEARDELAY 800
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ static void lcd_cmd(alt_u8 cmd, alt_u16 postdelay) {
|
|||||||
usleep(postdelay);
|
usleep(postdelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_init()
|
void st7032_init()
|
||||||
{
|
{
|
||||||
sys_ctrl &= ~(LCD_CS_N|LCD_RS);
|
sys_ctrl &= ~(LCD_CS_N|LCD_RS);
|
||||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
@ -59,7 +58,7 @@ void lcd_init()
|
|||||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_write(char *row1, char *row2)
|
void st7032_write(char *row1, char *row2)
|
||||||
{
|
{
|
||||||
alt_u8 i, rowlen;
|
alt_u8 i, rowlen;
|
||||||
|
|
||||||
32
software/sys_controller/ic_drivers/st7032/st7032.h
Normal file
32
software/sys_controller/ic_drivers/st7032/st7032.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// Copyright (C) 2015-2016 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
||||||
|
// Copyright (C) 2025 Balázs Triszka <info@balika011.hu>
|
||||||
|
//
|
||||||
|
// This file is part of Open Source Scan Converter project.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef ST7032_H_
|
||||||
|
#define ST7032_H_
|
||||||
|
|
||||||
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "sysconfig.h"
|
||||||
|
|
||||||
|
void st7032_init();
|
||||||
|
|
||||||
|
void st7032_write(char *row1, char *row2);
|
||||||
|
|
||||||
|
#endif /* st7032_H_ */
|
||||||
@ -38,7 +38,8 @@ const ypbpr_to_rgb_csc_t csc_coeffs[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const alt_u8 Kvco[] = {75, 85, 150, 200};
|
static const alt_u8 Kvco[] = {75, 85, 150, 200};
|
||||||
static const char *Kvco_str[] = { "Ultra low", "Low", "Medium", "High" };
|
static const char* const Kvco_str[] = { "Ultra low", "Low", "Medium", "High" };
|
||||||
|
static alt_u8 full_vs_bypass;
|
||||||
|
|
||||||
static void tvp_set_clamp_type(video_format fmt)
|
static void tvp_set_clamp_type(video_format fmt)
|
||||||
{
|
{
|
||||||
@ -201,6 +202,7 @@ void tvp_init()
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Set default configuration (skip those which match register reset values)
|
// Set default configuration (skip those which match register reset values)
|
||||||
|
full_vs_bypass = 0;
|
||||||
|
|
||||||
// Configure external refclk, HPLL generated pclk
|
// Configure external refclk, HPLL generated pclk
|
||||||
tvp_sel_clk(REFCLK_EXT27, 0);
|
tvp_sel_clk(REFCLK_EXT27, 0);
|
||||||
@ -267,6 +269,10 @@ void tvp_set_gain_offset(color_setup_t *col) {
|
|||||||
tvp_writereg(TVP_B_FOFFSET_MSB, col->b_f_off);
|
tvp_writereg(TVP_B_FOFFSET_MSB, col->b_f_off);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tvp_set_full_vs_bypass(alt_u8 enable) {
|
||||||
|
full_vs_bypass = enable;
|
||||||
|
}
|
||||||
|
|
||||||
// Configure H-PLL (sampling rate, VCO gain and charge pump current)
|
// Configure H-PLL (sampling rate, VCO gain and charge pump current)
|
||||||
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks_per_line, alt_u8 plldivby2)
|
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks_per_line, alt_u8 plldivby2)
|
||||||
{
|
{
|
||||||
@ -447,11 +453,10 @@ void tvp_source_sel(tvp_input_t input, tvp_sync_input_t syncinput, video_format
|
|||||||
else
|
else
|
||||||
tvp_writereg(TVP_MISCCTRL3, 0x00);
|
tvp_writereg(TVP_MISCCTRL3, 0x00);
|
||||||
|
|
||||||
#ifdef SYNCBYPASS
|
if ((syncinput > TVP_SOG3) && (syncinput < TVP_CS_A))
|
||||||
tvp_writereg(TVP_SYNCBYPASS, 0x03);
|
tvp_writereg(TVP_SYNCBYPASS, full_vs_bypass ? 0x02 : 0x00);
|
||||||
#else
|
else
|
||||||
tvp_writereg(TVP_SYNCBYPASS, 0x00);
|
tvp_writereg(TVP_SYNCBYPASS, 0x00);
|
||||||
#endif
|
|
||||||
|
|
||||||
//TODO:
|
//TODO:
|
||||||
//TVP_ADCSETUP
|
//TVP_ADCSETUP
|
||||||
@ -98,6 +98,8 @@ void tvp_init();
|
|||||||
|
|
||||||
void tvp_set_gain_offset(color_setup_t *col);
|
void tvp_set_gain_offset(color_setup_t *col);
|
||||||
|
|
||||||
|
void tvp_set_full_vs_bypass(alt_u8 enable);
|
||||||
|
|
||||||
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks_per_line, alt_u8 plldivby2);
|
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks_per_line, alt_u8 plldivby2);
|
||||||
|
|
||||||
void tvp_sel_csc(const ypbpr_to_rgb_csc_t *csc);
|
void tvp_sel_csc(const ypbpr_to_rgb_csc_t *csc);
|
||||||
@ -89,15 +89,63 @@ typedef struct {
|
|||||||
avconfig_t cc;
|
avconfig_t cc;
|
||||||
} avmode_t;
|
} avmode_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t profile_link;
|
||||||
|
avinput_t def_input;
|
||||||
|
uint8_t auto_input;
|
||||||
|
uint8_t auto_av1_ypbpr;
|
||||||
|
uint8_t auto_av2_ypbpr;
|
||||||
|
uint8_t auto_av3_ypbpr;
|
||||||
|
uint8_t lcd_bl_timeout;
|
||||||
|
uint8_t osd_enable;
|
||||||
|
uint8_t osd_status_timeout;
|
||||||
|
uint8_t osd_highlight_color;
|
||||||
|
uint8_t phase_hotkey_enable;
|
||||||
|
} settings_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t iv_x;
|
||||||
|
uint8_t iv_y;
|
||||||
|
uint16_t v[16][16];
|
||||||
|
} shmask_data_arr;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[20];
|
||||||
|
shmask_data_arr arr;
|
||||||
|
} c_shmask_t;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
struct {
|
||||||
|
uint32_t c64_pal[16];
|
||||||
|
uint32_t zx_pal[16];
|
||||||
|
uint32_t msx_pal[16];
|
||||||
|
uint32_t intv_pal[16];
|
||||||
|
uint32_t nes_pal[64];
|
||||||
|
uint32_t tia_pal[128];
|
||||||
|
uint32_t gtia_pal[256];
|
||||||
|
} __attribute__((packed, __may_alias__));
|
||||||
|
uint32_t data[512];
|
||||||
|
} lc_palette_set;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[20];
|
||||||
|
lc_palette_set pal;
|
||||||
|
} c_lc_palette_set_t;
|
||||||
|
|
||||||
void ui_disp_menu(alt_u8 osd_mode);
|
void ui_disp_menu(alt_u8 osd_mode);
|
||||||
void ui_disp_status(alt_u8 refresh_osd_timer);
|
void ui_disp_status(alt_u8 refresh_osd_timer);
|
||||||
|
|
||||||
void set_sampler_phase(uint8_t sampler_phase, uint8_t update_sc);
|
void set_sampler_phase(uint8_t sampler_phase, uint8_t update_sc);
|
||||||
|
|
||||||
int load_profile();
|
void set_default_c_shmask();
|
||||||
int save_profile();
|
void set_default_c_lc_palette_set();
|
||||||
|
|
||||||
void print_vm_stats();
|
void print_vm_stats();
|
||||||
int latency_test();
|
int latency_test();
|
||||||
|
|
||||||
|
void update_sc_config();
|
||||||
|
|
||||||
|
void invalidate_loaded_arrays();
|
||||||
|
void update_settings(int init_setup);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -105,6 +105,8 @@ typedef struct {
|
|||||||
alt_u8 tvp_hpll2x;
|
alt_u8 tvp_hpll2x;
|
||||||
alt_u8 adc_pll_bw;
|
alt_u8 adc_pll_bw;
|
||||||
alt_u8 fpga_pll_bw;
|
alt_u8 fpga_pll_bw;
|
||||||
|
alt_u8 panasonic_hack;
|
||||||
|
alt_u8 o480p_pbox;
|
||||||
|
|
||||||
/* Postprocessing settings */
|
/* Postprocessing settings */
|
||||||
alt_u8 sl_mode;
|
alt_u8 sl_mode;
|
||||||
@ -122,7 +124,9 @@ typedef struct {
|
|||||||
alt_u8 mask_color;
|
alt_u8 mask_color;
|
||||||
alt_u8 reverse_lpf;
|
alt_u8 reverse_lpf;
|
||||||
alt_u8 shmask_mode;
|
alt_u8 shmask_mode;
|
||||||
|
alt_u8 shmask_str;
|
||||||
alt_u8 lumacode_mode;
|
alt_u8 lumacode_mode;
|
||||||
|
alt_u8 lumacode_pal;
|
||||||
|
|
||||||
/* AFE settings */
|
/* AFE settings */
|
||||||
alt_u8 sync_vth;
|
alt_u8 sync_vth;
|
||||||
@ -137,6 +141,7 @@ typedef struct {
|
|||||||
alt_u8 alc_h_filter;
|
alt_u8 alc_h_filter;
|
||||||
alt_u8 alc_v_filter;
|
alt_u8 alc_v_filter;
|
||||||
color_setup_t col;
|
color_setup_t col;
|
||||||
|
alt_u8 full_vs_bypass;
|
||||||
|
|
||||||
/* Audio settings */
|
/* Audio settings */
|
||||||
alt_u8 audio_dw_sampl;
|
alt_u8 audio_dw_sampl;
|
||||||
@ -154,6 +159,11 @@ typedef struct {
|
|||||||
avinput_t link_av;
|
avinput_t link_av;
|
||||||
} __attribute__((packed)) avconfig_t;
|
} __attribute__((packed)) avconfig_t;
|
||||||
|
|
||||||
int set_default_avconfig();
|
int set_default_profile(int update_cc);
|
||||||
|
int reset_profile();
|
||||||
|
int load_profile();
|
||||||
|
int save_profile();
|
||||||
|
int load_profile_sd();
|
||||||
|
int save_profile_sd();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -51,6 +51,10 @@ typedef enum {
|
|||||||
RC_SL_TYPE,
|
RC_SL_TYPE,
|
||||||
RC_SL_PLUS,
|
RC_SL_PLUS,
|
||||||
RC_SL_MINUS,
|
RC_SL_MINUS,
|
||||||
|
RC_SHMMODE_PLUS,
|
||||||
|
RC_SHMMODE_MINUS,
|
||||||
|
RC_SHMINT_PLUS,
|
||||||
|
RC_SHMINT_MINUS,
|
||||||
RC_LM_MODE,
|
RC_LM_MODE,
|
||||||
RC_PHASE_PLUS,
|
RC_PHASE_PLUS,
|
||||||
RC_PHASE_MINUS,
|
RC_PHASE_MINUS,
|
||||||
@ -60,6 +64,7 @@ typedef enum {
|
|||||||
#define REMOTE_MAX_KEYS (RC_PROF_HOTKEY-RC_BTN1+1)
|
#define REMOTE_MAX_KEYS (RC_PROF_HOTKEY-RC_BTN1+1)
|
||||||
|
|
||||||
void setup_rc();
|
void setup_rc();
|
||||||
|
void set_default_keymap();
|
||||||
int parse_control();
|
int parse_control();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
14
software/sys_controller/inc/file.h
Normal file
14
software/sys_controller/inc/file.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef FILE_H_
|
||||||
|
#define FILE_H_
|
||||||
|
|
||||||
|
#include "ff.h"
|
||||||
|
#include "sysconfig.h"
|
||||||
|
|
||||||
|
FRESULT file_mount();
|
||||||
|
FRESULT file_open(FIL* fil, char* path);
|
||||||
|
FRESULT file_close(FIL* fil);
|
||||||
|
TCHAR* file_get_string(FIL* fil, char* buff, int len);
|
||||||
|
FRESULT scan_files (char* path);
|
||||||
|
int find_files_exec(char* path, char* pat, FILINFO *fno, int efirst, int elast, void (*func)(FILINFO *fno));
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -20,49 +20,48 @@
|
|||||||
#ifndef FIRMWARE_H_
|
#ifndef FIRMWARE_H_
|
||||||
#define FIRMWARE_H_
|
#define FIRMWARE_H_
|
||||||
|
|
||||||
#include "alt_types.h"
|
#include <stdint.h>
|
||||||
#include "sysconfig.h"
|
#include "sysconfig.h"
|
||||||
|
|
||||||
#define FW_VER_MAJOR 1
|
#define FW_VER_MAJOR 1
|
||||||
#define FW_VER_MINOR 11
|
#define FW_VER_MINOR 20
|
||||||
|
|
||||||
#define PROFILE_VER_MAJOR 1
|
|
||||||
#define PROFILE_VER_MINOR 11
|
|
||||||
|
|
||||||
#define INITCFG_VER_MAJOR 1
|
|
||||||
#define INITCFG_VER_MINOR 0
|
|
||||||
|
|
||||||
#ifdef ENABLE_AUDIO
|
|
||||||
#define FW_SUFFIX1 "a"
|
|
||||||
#else
|
|
||||||
#define FW_SUFFIX1 ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef OSDLANG_JP
|
#ifdef OSDLANG_JP
|
||||||
#define FW_SUFFIX2 "j"
|
#define FW_SUFFIX "j"
|
||||||
#else
|
#else
|
||||||
#define FW_SUFFIX2 ""
|
#define FW_SUFFIX ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FW_UPDATE_RETRIES 3
|
|
||||||
|
|
||||||
#define FW_IMAGE_ERROR 100
|
|
||||||
#define FW_HDR_ERROR 101
|
|
||||||
#define FW_HDR_CRC_ERROR 102
|
|
||||||
#define FW_DATA_CRC_ERROR 103
|
|
||||||
#define FW_UPD_CANCELLED 104
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char fw_key[4];
|
char fw_key[4];
|
||||||
alt_u8 version_major;
|
uint8_t version_major;
|
||||||
alt_u8 version_minor;
|
uint8_t version_minor;
|
||||||
char version_suffix[8];
|
char version_suffix[8];
|
||||||
alt_u32 hdr_len;
|
uint32_t hdr_len;
|
||||||
alt_u32 data_len;
|
uint32_t data_len;
|
||||||
alt_u32 data_crc;
|
uint32_t data_crc;
|
||||||
alt_u32 hdr_crc;
|
char padding[482];
|
||||||
} fw_hdr;
|
uint32_t hdr_crc;
|
||||||
|
} __attribute__((packed)) fw_hdr;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t sm_cur_state[4];
|
||||||
|
uint32_t force_early_confdone[4];
|
||||||
|
uint32_t wdog_timeout[4];
|
||||||
|
uint32_t wdog_enable[4];
|
||||||
|
uint32_t image_addr[4];
|
||||||
|
uint32_t force_int_osc[4];
|
||||||
|
uint32_t reg_trig_cnd[4];
|
||||||
|
uint32_t reset_timer;
|
||||||
|
uint32_t reconfig_start;
|
||||||
|
} rem_update_regs;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
volatile rem_update_regs *regs;
|
||||||
|
} rem_update_dev;
|
||||||
|
|
||||||
|
int fw_init_secondary();
|
||||||
int fw_update();
|
int fw_update();
|
||||||
|
void fw_update_commit(uint32_t* cluster_idx, uint32_t bytes_to_copy, uint16_t fs_csize, uint16_t fs_startsec, uint32_t flash_addr);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -20,22 +20,32 @@
|
|||||||
#ifndef FLASH_H_
|
#ifndef FLASH_H_
|
||||||
#define FLASH_H_
|
#define FLASH_H_
|
||||||
|
|
||||||
#include "alt_types.h"
|
#include <stdint.h>
|
||||||
#include "sysconfig.h"
|
#include "sysconfig.h"
|
||||||
#include "altera_epcq_controller2.h"
|
|
||||||
|
|
||||||
// EPCS16 pagesize is 256 bytes
|
#define FLASH_SECTOR_SIZE 65536
|
||||||
// Flash is split 50-50 to FW and userdata, 1MB each
|
|
||||||
#define PAGESIZE 256
|
|
||||||
#define PAGES_PER_SECTOR 256 //EPCS "sector" corresponds to "block" on Spansion flash
|
|
||||||
#define SECTORSIZE (PAGESIZE*PAGES_PER_SECTOR)
|
|
||||||
#define USERDATA_OFFSET 0x100000
|
|
||||||
#define MAX_USERDATA_ENTRY 15 // 16 sectors for userdata
|
|
||||||
|
|
||||||
#define FLASH_VERIFY_ERROR 204
|
typedef struct {
|
||||||
|
uint32_t ctrl;
|
||||||
|
uint32_t baud_rate;
|
||||||
|
uint32_t cs_delay;
|
||||||
|
uint32_t read_capture;
|
||||||
|
uint32_t oper_mode;
|
||||||
|
uint32_t read_instr;
|
||||||
|
uint32_t write_instr;
|
||||||
|
uint32_t flash_cmd_cfg;
|
||||||
|
uint32_t flash_cmd_ctrl;
|
||||||
|
uint32_t flash_cmd_addr;
|
||||||
|
uint32_t flash_cmd_wrdata[2];
|
||||||
|
uint32_t flash_cmd_rddata[2];
|
||||||
|
} gen_flash_if_regs;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
volatile gen_flash_if_regs *regs;
|
||||||
|
uint32_t flash_size;
|
||||||
|
} flash_ctrl_dev;
|
||||||
|
|
||||||
int init_flash();
|
void flash_write_protect(flash_ctrl_dev *dev, int enable);
|
||||||
int verify_flash(alt_u32 offset, alt_u32 length, alt_u32 golden_crc, alt_u8 *tmpbuf);
|
void flash_sector_erase(flash_ctrl_dev *dev, uint32_t addr);
|
||||||
|
|
||||||
#endif /* FLASH_H_ */
|
#endif /* FLASH_H_ */
|
||||||
@ -1,5 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2015-2016 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
// Copyright (C) 2015-2016 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
||||||
|
// Copyright (C) 2025 Balázs Triszka <info@balika011.hu>
|
||||||
//
|
//
|
||||||
// This file is part of Open Source Scan Converter project.
|
// This file is part of Open Source Scan Converter project.
|
||||||
//
|
//
|
||||||
@ -20,14 +21,10 @@
|
|||||||
#ifndef LCD_H_
|
#ifndef LCD_H_
|
||||||
#define LCD_H_
|
#define LCD_H_
|
||||||
|
|
||||||
#include "system.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "sysconfig.h"
|
|
||||||
|
|
||||||
#define LCD_ROW_LEN 16
|
#define LCD_ROW_LEN 16
|
||||||
|
|
||||||
void lcd_init();
|
void lcd_init();
|
||||||
|
|
||||||
void lcd_write(char *row1, char *row2);
|
void lcd_write(char *row1, char *row2);
|
||||||
|
|
||||||
#endif /* LCD_H_ */
|
#endif /* LCD_H_ */
|
||||||
@ -31,11 +31,22 @@
|
|||||||
#define LNG(e, j) e
|
#define LNG(e, j) e
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NO_ACTION = 0,
|
||||||
|
OPT_SELECT = RC_OK,
|
||||||
|
PREV_MENU = RC_BACK,
|
||||||
|
PREV_PAGE = RC_UP,
|
||||||
|
NEXT_PAGE = RC_DOWN,
|
||||||
|
VAL_MINUS = RC_LEFT,
|
||||||
|
VAL_PLUS = RC_RIGHT,
|
||||||
|
} menucode_id; // order must be consequential with rc_code_t
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OPT_AVCONFIG_SELECTION,
|
OPT_AVCONFIG_SELECTION,
|
||||||
OPT_AVCONFIG_NUMVALUE,
|
OPT_AVCONFIG_NUMVALUE,
|
||||||
OPT_AVCONFIG_NUMVAL_U16,
|
OPT_AVCONFIG_NUMVAL_U16,
|
||||||
OPT_SUBMENU,
|
OPT_SUBMENU,
|
||||||
|
OPT_CUSTOMMENU,
|
||||||
OPT_FUNC_CALL,
|
OPT_FUNC_CALL,
|
||||||
} menuitem_type;
|
} menuitem_type;
|
||||||
|
|
||||||
@ -43,6 +54,7 @@ typedef int (*func_call)(void);
|
|||||||
typedef void (*arg_func)(void);
|
typedef void (*arg_func)(void);
|
||||||
typedef void (*disp_func)(alt_u8);
|
typedef void (*disp_func)(alt_u8);
|
||||||
typedef void (*disp_func_u16)(alt_u16*);
|
typedef void (*disp_func_u16)(alt_u16*);
|
||||||
|
typedef void (*cstm_disp_func)(menucode_id, int);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
alt_u8 *data;
|
alt_u8 *data;
|
||||||
@ -55,7 +67,7 @@ typedef struct {
|
|||||||
alt_u8 wrap_cfg;
|
alt_u8 wrap_cfg;
|
||||||
alt_u8 min;
|
alt_u8 min;
|
||||||
alt_u8 max;
|
alt_u8 max;
|
||||||
const char **setting_str;
|
const char *const *const setting_str;
|
||||||
} opt_avconfig_selection;
|
} opt_avconfig_selection;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -86,6 +98,10 @@ typedef struct {
|
|||||||
arg_func arg_f;
|
arg_func arg_f;
|
||||||
} opt_submenu;
|
} opt_submenu;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
cstm_disp_func cstm_f;
|
||||||
|
} opt_custommenu;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
menuitem_type type;
|
menuitem_type type;
|
||||||
@ -94,40 +110,39 @@ typedef struct {
|
|||||||
opt_avconfig_numvalue num;
|
opt_avconfig_numvalue num;
|
||||||
opt_avconfig_numvalue_u16 num_u16;
|
opt_avconfig_numvalue_u16 num_u16;
|
||||||
opt_submenu sub;
|
opt_submenu sub;
|
||||||
|
opt_custommenu cstm;
|
||||||
opt_func_call fun;
|
opt_func_call fun;
|
||||||
};
|
};
|
||||||
} menuitem_t;
|
} menuitem_t;
|
||||||
|
|
||||||
struct menustruct {
|
struct menustruct {
|
||||||
alt_u8 num_items;
|
alt_u8 num_items;
|
||||||
menuitem_t *items;
|
const menuitem_t *items;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SETTING_ITEM(x) 0, sizeof(x)/sizeof(char*)-1, x
|
#define SETTING_ITEM(x) 0, sizeof(x)/sizeof(char*)-1, x
|
||||||
#define MENU(X, Y) menuitem_t X##_items[] = Y; const menu_t X = { sizeof(X##_items)/sizeof(menuitem_t), X##_items };
|
#define MENU(X, Y) const menuitem_t X##_items[] = Y; const menu_t X = { sizeof(X##_items)/sizeof(menuitem_t), X##_items };
|
||||||
#define P99_PROTECT(...) __VA_ARGS__
|
#define P99_PROTECT(...) __VA_ARGS__
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
NO_ACTION = 0,
|
|
||||||
OPT_SELECT = RC_OK,
|
|
||||||
PREV_MENU = RC_BACK,
|
|
||||||
PREV_PAGE = RC_UP,
|
|
||||||
NEXT_PAGE = RC_DOWN,
|
|
||||||
VAL_MINUS = RC_LEFT,
|
|
||||||
VAL_PLUS = RC_RIGHT,
|
|
||||||
} menucode_id; // order must be consequential with rc_code_t
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const menu_t *m;
|
const menu_t *m;
|
||||||
alt_u8 mp;
|
alt_u8 mp;
|
||||||
} menunavi;
|
} menunavi;
|
||||||
|
|
||||||
|
typedef int (*load_func)(char*, char*);
|
||||||
|
|
||||||
menunavi* get_current_menunavi();
|
menunavi* get_current_menunavi();
|
||||||
void init_menu();
|
void init_menu();
|
||||||
void render_osd_page();
|
void render_osd_page();
|
||||||
void display_menu(alt_u8 forcedisp);
|
void display_menu(alt_u8 forcedisp);
|
||||||
void sampler_phase_disp(alt_u8 v);
|
void sampler_phase_disp(alt_u8 v);
|
||||||
|
void set_func_ret_msg(char *msg);
|
||||||
void update_osd_size(mode_data_t *vm_out);
|
void update_osd_size(mode_data_t *vm_out);
|
||||||
|
void refresh_osd();
|
||||||
|
void cstm_shmask_load(menucode_id code, int setup_disp);
|
||||||
|
void cstm_lc_palette_set_load(menucode_id code, int setup_disp);
|
||||||
|
void cstm_fw_update(menucode_id code, int setup_disp);
|
||||||
|
void enter_cstm(const menuitem_t *item, int detached_mode);
|
||||||
static void vm_select();
|
static void vm_select();
|
||||||
static void vm_tweak(alt_u16 *v);
|
static void vm_tweak(alt_u16 *v);
|
||||||
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2015-2023 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
// Copyright (C) 2015-2025 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
||||||
//
|
//
|
||||||
// This file is part of Open Source Scan Converter project.
|
// This file is part of Open Source Scan Converter project.
|
||||||
//
|
//
|
||||||
@ -20,21 +20,17 @@
|
|||||||
#ifndef USERDATA_H_
|
#ifndef USERDATA_H_
|
||||||
#define USERDATA_H_
|
#define USERDATA_H_
|
||||||
|
|
||||||
#include "alt_types.h"
|
#include <stdint.h>
|
||||||
#include "sysconfig.h"
|
#include "sysconfig.h"
|
||||||
#include "controls.h"
|
|
||||||
#include "av_controller.h"
|
|
||||||
#include "avconfig.h"
|
|
||||||
#include "video_modes.h"
|
|
||||||
#include "flash.h"
|
|
||||||
|
|
||||||
#define PROFILE_NAME_LEN 12
|
#define USERDATA_NAME_LEN 13
|
||||||
|
#define MAX_USERDATA_ENTRY 15
|
||||||
|
#define MAX_SD_USERDATA_ENTRY 100
|
||||||
|
|
||||||
#define MAX_PROFILE (MAX_USERDATA_ENTRY-1)
|
#define MAX_PROFILE (MAX_USERDATA_ENTRY-1)
|
||||||
|
#define MAX_SD_PROFILE (MAX_SD_USERDATA_ENTRY-1)
|
||||||
#define INIT_CONFIG_SLOT MAX_USERDATA_ENTRY
|
#define INIT_CONFIG_SLOT MAX_USERDATA_ENTRY
|
||||||
|
#define SD_INIT_CONFIG_SLOT MAX_SD_USERDATA_ENTRY
|
||||||
#define UDATA_IMPT_CANCELLED 104
|
|
||||||
#define UDATA_EXPT_CANCELLED 105
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UDE_INITCFG = 0,
|
UDE_INITCFG = 0,
|
||||||
@ -43,40 +39,26 @@ typedef enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char userdata_key[8];
|
char userdata_key[8];
|
||||||
alt_u8 version_major;
|
char name[USERDATA_NAME_LEN+1];
|
||||||
alt_u8 version_minor;
|
|
||||||
ude_type type;
|
ude_type type;
|
||||||
|
uint8_t num_items;
|
||||||
} __attribute__((packed, __may_alias__)) ude_hdr;
|
} __attribute__((packed, __may_alias__)) ude_hdr;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ude_hdr hdr;
|
uint16_t id;
|
||||||
alt_u16 data_len;
|
uint16_t version;
|
||||||
alt_u8 last_profile[AV_LAST];
|
uint16_t data_size;
|
||||||
alt_u8 profile_link;
|
} __attribute__((packed, __may_alias__)) ude_item_hdr;
|
||||||
avinput_t last_input;
|
|
||||||
avinput_t def_input;
|
|
||||||
alt_u8 lcd_bl_timeout;
|
|
||||||
alt_u8 auto_input;
|
|
||||||
alt_u8 auto_av1_ypbpr;
|
|
||||||
alt_u8 auto_av2_ypbpr;
|
|
||||||
alt_u8 auto_av3_ypbpr;
|
|
||||||
alt_u8 osd_enable;
|
|
||||||
alt_u8 osd_status_timeout;
|
|
||||||
alt_u8 phase_hotkey_enable;
|
|
||||||
alt_u16 keys[REMOTE_MAX_KEYS];
|
|
||||||
} __attribute__((packed, __may_alias__)) ude_initcfg;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ude_hdr hdr;
|
ude_item_hdr hdr;
|
||||||
char name[PROFILE_NAME_LEN+1];
|
void *data;
|
||||||
alt_u16 avc_data_len;
|
} ude_item_map;
|
||||||
alt_u16 vm_data_len;
|
|
||||||
avconfig_t avc;
|
|
||||||
//mode_data_t vm[VIDEO_MODES_CNT];
|
|
||||||
} __attribute__((packed, __may_alias__)) ude_profile;
|
|
||||||
|
|
||||||
int write_userdata(alt_u8 entry);
|
int write_userdata(uint8_t entry);
|
||||||
int read_userdata(alt_u8 entry, int dry_run);
|
int read_userdata(uint8_t entry, int dry_run);
|
||||||
|
int write_userdata_sd(uint8_t entry);
|
||||||
|
int read_userdata_sd(uint8_t entry, int dry_run);
|
||||||
int import_userdata();
|
int import_userdata();
|
||||||
int export_userdata();
|
int export_userdata();
|
||||||
|
|
||||||
@ -28,14 +28,14 @@
|
|||||||
#define DEF_PHASE 0x10
|
#define DEF_PHASE 0x10
|
||||||
|
|
||||||
#define H_TOTAL_MIN 300
|
#define H_TOTAL_MIN 300
|
||||||
#define H_TOTAL_MAX 2800
|
#define H_TOTAL_MAX 3200
|
||||||
#define H_TOTAL_ADJ_MAX 19
|
#define H_TOTAL_ADJ_MAX 19
|
||||||
#define H_SYNCLEN_MIN 10
|
#define H_SYNCLEN_MIN 10
|
||||||
#define H_SYNCLEN_MAX 255
|
#define H_SYNCLEN_MAX 255
|
||||||
#define H_BPORCH_MIN 0
|
#define H_BPORCH_MIN 0
|
||||||
#define H_BPORCH_MAX 511
|
#define H_BPORCH_MAX 511
|
||||||
#define H_ACTIVE_MIN 200
|
#define H_ACTIVE_MIN 200
|
||||||
#define H_ACTIVE_MAX 2560
|
#define H_ACTIVE_MAX 3000
|
||||||
#define H_ACTIVE_SMP_MAX 2048
|
#define H_ACTIVE_SMP_MAX 2048
|
||||||
#define V_SYNCLEN_MIN 1
|
#define V_SYNCLEN_MIN 1
|
||||||
#define V_SYNCLEN_MAX 15
|
#define V_SYNCLEN_MAX 15
|
||||||
@ -1,13 +1,19 @@
|
|||||||
SEARCH_DIR(.)
|
SEARCH_DIR(.)
|
||||||
__DYNAMIC = 0;
|
__DYNAMIC = 0;
|
||||||
|
|
||||||
|
/* First 16 flash sectors reserved for 2 firmware images (2x 0.5MB).
|
||||||
|
In typical configuration a firmware image consists of
|
||||||
|
* compressed bitstream (5 sectors / 0.3MB)
|
||||||
|
* flash_imem (3 sectors / 0.2MB)
|
||||||
|
Last 16 flash sectors reserved for userdata (16x 64KB). */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
dataram : ORIGIN = 0x00010000, LENGTH = 0xa400
|
flash_imem : ORIGIN = 0x02050000, LENGTH = 196608
|
||||||
|
dataram : ORIGIN = 0x00010000, LENGTH = 16384
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stack information variables */
|
/* Stack information variables */
|
||||||
_min_stack = 0x4B0; /* 1200 - minimum stack space to reserve */
|
_min_stack = 0x1000; /* 4KB - minimum stack space to reserve */
|
||||||
_stack_start = ORIGIN(dataram) + LENGTH(dataram);
|
_stack_start = ORIGIN(dataram) + LENGTH(dataram);
|
||||||
|
|
||||||
/* We have to align each sector to word boundaries as our current s19->slm
|
/* We have to align each sector to word boundaries as our current s19->slm
|
||||||
@ -19,7 +25,7 @@ SECTIONS
|
|||||||
{
|
{
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
KEEP(*(.vectors))
|
KEEP(*(.vectors))
|
||||||
} > dataram
|
} > flash_imem
|
||||||
|
|
||||||
.text : {
|
.text : {
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
@ -40,7 +46,16 @@ SECTIONS
|
|||||||
*(.lit)
|
*(.lit)
|
||||||
*(.shdata)
|
*(.shdata)
|
||||||
_endtext = .;
|
_endtext = .;
|
||||||
} > dataram
|
} > flash_imem
|
||||||
|
|
||||||
|
.rodata : {
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.rodata);
|
||||||
|
*(.rodata.*)
|
||||||
|
*(.srodata);
|
||||||
|
*(.srodata.*)
|
||||||
|
. = ALIGN(4);
|
||||||
|
} > flash_imem
|
||||||
|
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
/* Global constructor/destructor segement */
|
/* Global constructor/destructor segement */
|
||||||
@ -69,20 +84,19 @@ SECTIONS
|
|||||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
} > dataram
|
} > dataram
|
||||||
|
|
||||||
.rodata : {
|
.text_bram : AT ( LOADADDR (.rodata) + SIZEOF (.rodata) ) {
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
*(.rodata);
|
PROVIDE (__ram_text_start = ABSOLUTE(.));
|
||||||
*(.rodata.*)
|
*(.text_bram);
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE (__ram_text_end = ABSOLUTE(.));
|
||||||
} > dataram
|
} > dataram
|
||||||
|
|
||||||
.shbss :
|
PROVIDE (__flash_text_bram_start = LOADADDR(.text_bram));
|
||||||
{
|
|
||||||
. = ALIGN(4);
|
|
||||||
*(.shbss)
|
|
||||||
} > dataram
|
|
||||||
|
|
||||||
.data : {
|
.data : AT ( LOADADDR (.text_bram) + SIZEOF (.text_bram) ) {
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
|
PROVIDE (__ram_rwdata_start = ABSOLUTE(.));
|
||||||
sdata = .;
|
sdata = .;
|
||||||
_sdata = .;
|
_sdata = .;
|
||||||
*(.data);
|
*(.data);
|
||||||
@ -93,6 +107,16 @@ SECTIONS
|
|||||||
*(.sdata2.*)
|
*(.sdata2.*)
|
||||||
edata = .;
|
edata = .;
|
||||||
_edata = .;
|
_edata = .;
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE (__ram_rwdata_end = ABSOLUTE(.));
|
||||||
|
} > dataram
|
||||||
|
|
||||||
|
PROVIDE (__flash_rwdata_start = LOADADDR(.data));
|
||||||
|
|
||||||
|
.shbss :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.shbss)
|
||||||
} > dataram
|
} > dataram
|
||||||
|
|
||||||
.bss :
|
.bss :
|
||||||
|
|||||||
@ -2,6 +2,6 @@
|
|||||||
OUTPUT_ARCH(riscv)
|
OUTPUT_ARCH(riscv)
|
||||||
|
|
||||||
/* required to correctly link newlib */
|
/* required to correctly link newlib */
|
||||||
GROUP( -lc -lgloss -lgcc -lsupc++ )
|
GROUP( -lc -lgcc )
|
||||||
|
|
||||||
INCLUDE link.common.ld
|
INCLUDE link.common.ld
|
||||||
|
|||||||
@ -1,69 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (C) 2015-2016 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
|
||||||
//
|
|
||||||
// This file is part of Open Source Scan Converter project.
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "system.h"
|
|
||||||
#include "flash.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
// save some code space
|
|
||||||
#define SINGLE_FLASH_INSTANCE
|
|
||||||
|
|
||||||
alt_flash_dev *epcq_dev;
|
|
||||||
|
|
||||||
|
|
||||||
int init_flash()
|
|
||||||
{
|
|
||||||
#ifdef SINGLE_FLASH_INSTANCE
|
|
||||||
extern alt_llist alt_flash_dev_list;
|
|
||||||
epcq_dev = (alt_flash_dev*)alt_flash_dev_list.next;
|
|
||||||
#else
|
|
||||||
epcq_dev = alt_flash_open_dev(EPCQ_CONTROLLER2_0_AVL_MEM_NAME);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (epcq_dev == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int verify_flash(alt_u32 offset, alt_u32 length, alt_u32 golden_crc, alt_u8 *tmpbuf)
|
|
||||||
{
|
|
||||||
alt_u32 crcval=0, i, j, bytes_to_read;
|
|
||||||
int retval;
|
|
||||||
|
|
||||||
for (i=0; i<length; i=i+PAGESIZE) {
|
|
||||||
bytes_to_read = ((length-i < PAGESIZE) ? (length-i) : PAGESIZE);
|
|
||||||
|
|
||||||
//retval = read_flash(i, bytes_to_read, tmpbuf);
|
|
||||||
retval = alt_epcq_controller2_read(epcq_dev, offset+i, tmpbuf, bytes_to_read);
|
|
||||||
for (j=0; j<bytes_to_read; j++)
|
|
||||||
tmpbuf[j] = bitswap8(tmpbuf[j]);
|
|
||||||
if (retval != 0)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
crcval = crc32(tmpbuf, bytes_to_read, (i==0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crcval != golden_crc)
|
|
||||||
return -FLASH_VERIFY_ERROR;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@ -1,220 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (C) 2015-2023 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
|
||||||
//
|
|
||||||
// This file is part of Open Source Scan Converter project.
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "firmware.h"
|
|
||||||
#include "sdcard.h"
|
|
||||||
#include "flash.h"
|
|
||||||
#include "controls.h"
|
|
||||||
#include "tvp7002.h"
|
|
||||||
#include "av_controller.h"
|
|
||||||
#include "lcd.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "menu.h"
|
|
||||||
#include "altera_avalon_pio_regs.h"
|
|
||||||
|
|
||||||
extern char menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
|
||||||
extern alt_u16 rc_keymap[REMOTE_MAX_KEYS];
|
|
||||||
extern SD_DEV sdcard_dev;
|
|
||||||
extern alt_u32 sys_ctrl;
|
|
||||||
|
|
||||||
static int check_fw_header(alt_u8 *databuf, fw_hdr *hdr)
|
|
||||||
{
|
|
||||||
alt_u32 crcval, tmp;
|
|
||||||
|
|
||||||
strncpy(hdr->fw_key, (char*)databuf, 4);
|
|
||||||
if (strncmp(hdr->fw_key, "OSSC", 4))
|
|
||||||
return FW_IMAGE_ERROR;
|
|
||||||
|
|
||||||
hdr->version_major = databuf[4];
|
|
||||||
hdr->version_minor = databuf[5];
|
|
||||||
strncpy(hdr->version_suffix, (char*)(databuf+6), 8);
|
|
||||||
hdr->version_suffix[7] = 0;
|
|
||||||
|
|
||||||
memcpy(&tmp, databuf+14, 4);
|
|
||||||
hdr->hdr_len = bswap32(tmp);
|
|
||||||
memcpy(&tmp, databuf+18, 4);
|
|
||||||
hdr->data_len = bswap32(tmp);
|
|
||||||
memcpy(&tmp, databuf+22, 4);
|
|
||||||
hdr->data_crc = bswap32(tmp);
|
|
||||||
// Always at bytes [508-511]
|
|
||||||
memcpy(&tmp, databuf+508, 4);
|
|
||||||
hdr->hdr_crc = bswap32(tmp);
|
|
||||||
|
|
||||||
if (hdr->hdr_len < 26 || hdr->hdr_len > 508)
|
|
||||||
return FW_HDR_ERROR;
|
|
||||||
|
|
||||||
crcval = crc32(databuf, hdr->hdr_len, 1);
|
|
||||||
|
|
||||||
if (crcval != hdr->hdr_crc)
|
|
||||||
return FW_HDR_CRC_ERROR;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int check_fw_image(alt_u32 offset, alt_u32 size, alt_u32 golden_crc, alt_u8 *tmpbuf)
|
|
||||||
{
|
|
||||||
alt_u32 crcval=0, i, bytes_to_read;
|
|
||||||
SDRESULTS res;
|
|
||||||
|
|
||||||
for (i=0; i<size; i=i+SD_BLK_SIZE) {
|
|
||||||
bytes_to_read = ((size-i < SD_BLK_SIZE) ? (size-i) : SD_BLK_SIZE);
|
|
||||||
res = SD_Read(&sdcard_dev, tmpbuf, (offset+i)/SD_BLK_SIZE, 0, bytes_to_read);
|
|
||||||
|
|
||||||
if (res != SD_OK)
|
|
||||||
return -res;
|
|
||||||
|
|
||||||
crcval = crc32(tmpbuf, bytes_to_read, (i==0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crcval != golden_crc)
|
|
||||||
return FW_DATA_CRC_ERROR;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fw_update()
|
|
||||||
{
|
|
||||||
int retval, i;
|
|
||||||
int retries = FW_UPDATE_RETRIES;
|
|
||||||
char *errmsg;
|
|
||||||
alt_u8 databuf[SD_BLK_SIZE];
|
|
||||||
alt_u32 btn_vec;
|
|
||||||
alt_u32 bytes_to_rw;
|
|
||||||
fw_hdr fw_header;
|
|
||||||
|
|
||||||
#ifdef CHECK_STACK_USE
|
|
||||||
// estimate stack usage, assuming around here is the worst case (due to 512B databuf)
|
|
||||||
alt_u32 sp;
|
|
||||||
asm volatile("mv %0, sp" : "=r"(sp));
|
|
||||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "Stack size:");
|
|
||||||
sniprintf(menu_row2, LCD_ROW_LEN+1, "%lu bytes", (ONCHIP_MEMORY2_0_BASE+ONCHIP_MEMORY2_0_SIZE_VALUE)-sp);
|
|
||||||
ui_disp_menu(1);
|
|
||||||
usleep(1000000);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
retval = check_sdcard(databuf);
|
|
||||||
SPI_CS_High();
|
|
||||||
if (retval != 0) {
|
|
||||||
retval = -retval;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = check_fw_header(databuf, &fw_header);
|
|
||||||
if (retval != 0)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "Validating data");
|
|
||||||
sniprintf(menu_row2, LCD_ROW_LEN+1, "%u bytes", (unsigned)fw_header.data_len);
|
|
||||||
ui_disp_menu(1);
|
|
||||||
retval = check_fw_image(512, fw_header.data_len, fw_header.data_crc, databuf);
|
|
||||||
if (retval != 0)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "%u.%.2u%s%s", fw_header.version_major, fw_header.version_minor, (fw_header.version_suffix[0] == 0) ? "" : "-", fw_header.version_suffix);
|
|
||||||
strncpy(menu_row2, "Update? 1=Y, 2=N", LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(1);
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
btn_vec = IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & RC_MASK;
|
|
||||||
|
|
||||||
if (btn_vec == rc_keymap[RC_BTN1]) {
|
|
||||||
break;
|
|
||||||
} else if (btn_vec == rc_keymap[RC_BTN2]) {
|
|
||||||
retval = FW_UPD_CANCELLED;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(WAITLOOP_SLEEP_US);
|
|
||||||
}
|
|
||||||
|
|
||||||
//disable video output
|
|
||||||
tvp_powerdown();
|
|
||||||
sys_ctrl |= VIDGEN_OFF;
|
|
||||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
|
||||||
usleep(10000);
|
|
||||||
|
|
||||||
strncpy(menu_row1, "Updating FW", LCD_ROW_LEN+1);
|
|
||||||
update_init:
|
|
||||||
strncpy(menu_row2, "please wait...", LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(1);
|
|
||||||
|
|
||||||
retval = copy_sd_to_flash(512/SD_BLK_SIZE, 0, fw_header.data_len, databuf);
|
|
||||||
if (retval != 0)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
strncpy(menu_row1, "Verifying flash", LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(1);
|
|
||||||
retval = verify_flash(0, fw_header.data_len, fw_header.data_crc, databuf);
|
|
||||||
if (retval != 0)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
SPI_CS_High();
|
|
||||||
|
|
||||||
strncpy(menu_row1, "Firmware updated", LCD_ROW_LEN+1);
|
|
||||||
strncpy(menu_row2, "please restart", LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(1);
|
|
||||||
while (1) {}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
failure:
|
|
||||||
SPI_CS_High();
|
|
||||||
|
|
||||||
switch (retval) {
|
|
||||||
case SD_NOINIT:
|
|
||||||
errmsg = "No SD card det.";
|
|
||||||
break;
|
|
||||||
case FW_IMAGE_ERROR:
|
|
||||||
errmsg = "Invalid image";
|
|
||||||
break;
|
|
||||||
case FW_HDR_ERROR:
|
|
||||||
errmsg = "Invalid header";
|
|
||||||
break;
|
|
||||||
case FW_HDR_CRC_ERROR:
|
|
||||||
errmsg = "Invalid hdr CRC";
|
|
||||||
break;
|
|
||||||
case FW_DATA_CRC_ERROR:
|
|
||||||
errmsg = "Invalid data CRC";
|
|
||||||
break;
|
|
||||||
case FW_UPD_CANCELLED:
|
|
||||||
errmsg = "Update cancelled";
|
|
||||||
break;
|
|
||||||
case -FLASH_VERIFY_ERROR:
|
|
||||||
errmsg = "Flash verif fail";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
errmsg = "SD/Flash error";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strncpy(menu_row2, errmsg, LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(1);
|
|
||||||
usleep(1000000);
|
|
||||||
|
|
||||||
// Critical error, retry update
|
|
||||||
if ((retval < 0) && (retries > 0)) {
|
|
||||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "Retrying update");
|
|
||||||
retries--;
|
|
||||||
goto update_init;
|
|
||||||
}
|
|
||||||
|
|
||||||
render_osd_page();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
@ -1,537 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (C) 2015-2023 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
|
||||||
//
|
|
||||||
// This file is part of Open Source Scan Converter project.
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "userdata.h"
|
|
||||||
#include "fat16_export.h"
|
|
||||||
#include "flash.h"
|
|
||||||
#include "sdcard.h"
|
|
||||||
#include "firmware.h"
|
|
||||||
#include "lcd.h"
|
|
||||||
#include "controls.h"
|
|
||||||
#include "av_controller.h"
|
|
||||||
#include "menu.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "altera_avalon_pio_regs.h"
|
|
||||||
|
|
||||||
// include mode array definitions so that sizeof() can be used
|
|
||||||
#define VM_STATIC_INCLUDE
|
|
||||||
#include "video_modes_list.c"
|
|
||||||
#undef VM_STATIC_INCLUDE
|
|
||||||
|
|
||||||
extern alt_u16 rc_keymap[REMOTE_MAX_KEYS];
|
|
||||||
extern avmode_t cm;
|
|
||||||
extern avconfig_t tc;
|
|
||||||
extern mode_data_t video_modes_plm[];
|
|
||||||
extern avinput_t target_input;
|
|
||||||
extern alt_u8 update_cur_vm;
|
|
||||||
extern alt_u8 input_profiles[AV_LAST];
|
|
||||||
extern alt_u8 profile_sel;
|
|
||||||
extern alt_u8 def_input, profile_link;
|
|
||||||
extern alt_u8 lcd_bl_timeout;
|
|
||||||
extern alt_u8 auto_input, auto_av1_ypbpr, auto_av2_ypbpr, auto_av3_ypbpr;
|
|
||||||
extern alt_u8 osd_enable, osd_status_timeout, phase_hotkey_enable;
|
|
||||||
extern SD_DEV sdcard_dev;
|
|
||||||
extern alt_flash_dev *epcq_dev;
|
|
||||||
extern char menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
|
||||||
|
|
||||||
char target_profile_name[PROFILE_NAME_LEN+1];
|
|
||||||
|
|
||||||
int write_userdata(alt_u8 entry)
|
|
||||||
{
|
|
||||||
alt_u8 databuf[PAGESIZE];
|
|
||||||
alt_u16 vm_to_write;
|
|
||||||
alt_u16 pageoffset, srcoffset;
|
|
||||||
alt_u8 pageno;
|
|
||||||
alt_u32 bytes_to_w;
|
|
||||||
int retval, i;
|
|
||||||
|
|
||||||
if (entry > MAX_USERDATA_ENTRY) {
|
|
||||||
printf("invalid entry\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(((ude_hdr*)databuf)->userdata_key, "USRDATA", 8);
|
|
||||||
((ude_hdr*)databuf)->type = (entry > MAX_PROFILE) ? UDE_INITCFG : UDE_PROFILE;
|
|
||||||
|
|
||||||
switch (((ude_hdr*)databuf)->type) {
|
|
||||||
case UDE_INITCFG:
|
|
||||||
((ude_hdr*)databuf)->version_major = INITCFG_VER_MAJOR;
|
|
||||||
((ude_hdr*)databuf)->version_minor = INITCFG_VER_MINOR;
|
|
||||||
((ude_initcfg*)databuf)->data_len = sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile);
|
|
||||||
memcpy(((ude_initcfg*)databuf)->last_profile, input_profiles, sizeof(input_profiles));
|
|
||||||
((ude_initcfg*)databuf)->last_input = target_input;
|
|
||||||
((ude_initcfg*)databuf)->def_input = def_input;
|
|
||||||
((ude_initcfg*)databuf)->profile_link = profile_link;
|
|
||||||
((ude_initcfg*)databuf)->lcd_bl_timeout = lcd_bl_timeout;
|
|
||||||
((ude_initcfg*)databuf)->auto_input = auto_input;
|
|
||||||
((ude_initcfg*)databuf)->auto_av1_ypbpr = auto_av1_ypbpr;
|
|
||||||
((ude_initcfg*)databuf)->auto_av2_ypbpr = auto_av2_ypbpr;
|
|
||||||
((ude_initcfg*)databuf)->auto_av3_ypbpr = auto_av3_ypbpr;
|
|
||||||
((ude_initcfg*)databuf)->osd_enable = osd_enable;
|
|
||||||
((ude_initcfg*)databuf)->osd_status_timeout = osd_status_timeout;
|
|
||||||
((ude_initcfg*)databuf)->phase_hotkey_enable = phase_hotkey_enable;
|
|
||||||
memcpy(((ude_initcfg*)databuf)->keys, rc_keymap, sizeof(rc_keymap));
|
|
||||||
for (i=0; i<sizeof(ude_initcfg); i++)
|
|
||||||
databuf[i] = bitswap8(databuf[i]);
|
|
||||||
retval = alt_epcq_controller2_write(epcq_dev, (USERDATA_OFFSET+entry*SECTORSIZE), databuf, sizeof(ude_initcfg));
|
|
||||||
if (retval != 0)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
printf("Initconfig data written (%u bytes)\n", sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile));
|
|
||||||
break;
|
|
||||||
case UDE_PROFILE:
|
|
||||||
((ude_hdr*)databuf)->version_major = PROFILE_VER_MAJOR;
|
|
||||||
((ude_hdr*)databuf)->version_minor = PROFILE_VER_MINOR;
|
|
||||||
vm_to_write = sizeof(video_modes_plm_default);
|
|
||||||
((ude_profile*)databuf)->avc_data_len = sizeof(avconfig_t);
|
|
||||||
((ude_profile*)databuf)->vm_data_len = vm_to_write;
|
|
||||||
|
|
||||||
if (target_profile_name[0] == 0)
|
|
||||||
sniprintf(target_profile_name, PROFILE_NAME_LEN+1, "<used>");
|
|
||||||
|
|
||||||
strncpy(((ude_profile*)databuf)->name, target_profile_name, PROFILE_NAME_LEN+1);
|
|
||||||
|
|
||||||
pageoffset = offsetof(ude_profile, avc);
|
|
||||||
|
|
||||||
// assume that sizeof(avconfig_t) << PAGESIZE
|
|
||||||
memcpy(databuf+pageoffset, &tc, sizeof(avconfig_t));
|
|
||||||
pageoffset += sizeof(avconfig_t);
|
|
||||||
|
|
||||||
// erase sector and write a full page first, assume sizeof(video_modes_plm) >> PAGESIZE
|
|
||||||
memcpy(databuf+pageoffset, (char*)video_modes_plm, PAGESIZE-pageoffset);
|
|
||||||
srcoffset = PAGESIZE-pageoffset;
|
|
||||||
vm_to_write -= PAGESIZE-pageoffset;
|
|
||||||
for (i=0; i<PAGESIZE; i++)
|
|
||||||
databuf[i] = bitswap8(databuf[i]);
|
|
||||||
retval = alt_epcq_controller2_write(epcq_dev, (USERDATA_OFFSET+entry*SECTORSIZE), databuf, PAGESIZE);
|
|
||||||
if (retval != 0)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
// then write the rest page by page
|
|
||||||
pageno = 1;
|
|
||||||
while (vm_to_write > 0) {
|
|
||||||
memcpy(databuf, (char*)video_modes_plm+srcoffset, (vm_to_write > PAGESIZE) ? PAGESIZE : vm_to_write);
|
|
||||||
for (i=0; i<PAGESIZE; i++)
|
|
||||||
databuf[i] = bitswap8(databuf[i]);
|
|
||||||
retval = alt_epcq_controller2_write_block(epcq_dev, (USERDATA_OFFSET+entry*SECTORSIZE), (USERDATA_OFFSET+entry*SECTORSIZE+pageno*PAGESIZE), databuf, (vm_to_write > PAGESIZE) ? PAGESIZE : vm_to_write);
|
|
||||||
if (retval != 0)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
srcoffset += PAGESIZE;
|
|
||||||
vm_to_write = (vm_to_write < PAGESIZE) ? 0 : (vm_to_write - PAGESIZE);
|
|
||||||
pageno++;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Profile %u data written (%u bytes)\n", entry, sizeof(avconfig_t)+sizeof(video_modes_plm_default));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int read_userdata(alt_u8 entry, int dry_run)
|
|
||||||
{
|
|
||||||
int retval, i;
|
|
||||||
alt_u8 databuf[PAGESIZE];
|
|
||||||
alt_u16 vm_to_read;
|
|
||||||
alt_u16 pageoffset, dstoffset;
|
|
||||||
alt_u8 pageno;
|
|
||||||
|
|
||||||
target_profile_name[0] = 0;
|
|
||||||
|
|
||||||
if (entry > MAX_USERDATA_ENTRY) {
|
|
||||||
printf("invalid entry\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = alt_epcq_controller2_read(epcq_dev, (USERDATA_OFFSET+entry*SECTORSIZE), databuf, PAGESIZE);
|
|
||||||
for (i=0; i<PAGESIZE; i++)
|
|
||||||
databuf[i] = bitswap8(databuf[i]);
|
|
||||||
if (retval != 0)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
if (strncmp(((ude_hdr*)databuf)->userdata_key, "USRDATA", 8)) {
|
|
||||||
printf("No userdata found on entry %u\n", entry);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (((ude_hdr*)databuf)->type) {
|
|
||||||
case UDE_INITCFG:
|
|
||||||
if ((((ude_hdr*)databuf)->version_major != INITCFG_VER_MAJOR) || (((ude_hdr*)databuf)->version_minor != INITCFG_VER_MINOR)) {
|
|
||||||
printf("Initconfig version %u.%.2u does not match current one\n", ((ude_hdr*)databuf)->version_major, ((ude_hdr*)databuf)->version_minor);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if (((ude_initcfg*)databuf)->data_len == sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile)) {
|
|
||||||
if (dry_run)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(input_profiles)/sizeof(*input_profiles); ++i)
|
|
||||||
if (((ude_initcfg*)databuf)->last_profile[i] <= MAX_PROFILE)
|
|
||||||
input_profiles[i] = ((ude_initcfg*)databuf)->last_profile[i];
|
|
||||||
def_input = ((ude_initcfg*)databuf)->def_input;
|
|
||||||
if (def_input < AV_LAST)
|
|
||||||
target_input = def_input;
|
|
||||||
else if (((ude_initcfg*)databuf)->last_input < AV_LAST)
|
|
||||||
target_input = ((ude_initcfg*)databuf)->last_input;
|
|
||||||
auto_input = ((ude_initcfg*)databuf)->auto_input;
|
|
||||||
auto_av1_ypbpr = ((ude_initcfg*)databuf)->auto_av1_ypbpr;
|
|
||||||
auto_av2_ypbpr = ((ude_initcfg*)databuf)->auto_av2_ypbpr;
|
|
||||||
auto_av3_ypbpr = ((ude_initcfg*)databuf)->auto_av3_ypbpr;
|
|
||||||
osd_enable = ((ude_initcfg*)databuf)->osd_enable;
|
|
||||||
osd_status_timeout = ((ude_initcfg*)databuf)->osd_status_timeout;
|
|
||||||
profile_link = ((ude_initcfg*)databuf)->profile_link;
|
|
||||||
profile_sel = input_profiles[AV_TESTPAT]; // Global profile
|
|
||||||
lcd_bl_timeout = ((ude_initcfg*)databuf)->lcd_bl_timeout;
|
|
||||||
phase_hotkey_enable = ((ude_initcfg*)databuf)->phase_hotkey_enable;
|
|
||||||
memcpy(rc_keymap, ((ude_initcfg*)databuf)->keys, sizeof(rc_keymap));
|
|
||||||
printf("RC data read (%u bytes)\n", sizeof(rc_keymap));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UDE_PROFILE:
|
|
||||||
if ((((ude_hdr*)databuf)->version_major != PROFILE_VER_MAJOR) || (((ude_hdr*)databuf)->version_minor != PROFILE_VER_MINOR)) {
|
|
||||||
printf("Profile version %u.%.2u does not match current one\n", ((ude_hdr*)databuf)->version_major, ((ude_hdr*)databuf)->version_minor);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if ((((ude_profile*)databuf)->avc_data_len == sizeof(avconfig_t)) && (((ude_profile*)databuf)->vm_data_len == sizeof(video_modes_plm_default))) {
|
|
||||||
strncpy(target_profile_name, ((ude_profile*)databuf)->name, PROFILE_NAME_LEN+1);
|
|
||||||
if (dry_run)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
vm_to_read = ((ude_profile*)databuf)->vm_data_len;
|
|
||||||
|
|
||||||
pageno = 0;
|
|
||||||
pageoffset = offsetof(ude_profile, avc);
|
|
||||||
|
|
||||||
// assume that sizeof(avconfig_t) << PAGESIZE
|
|
||||||
memcpy(&tc, databuf+pageoffset, sizeof(avconfig_t));
|
|
||||||
pageoffset += sizeof(avconfig_t);
|
|
||||||
|
|
||||||
dstoffset = 0;
|
|
||||||
while (vm_to_read > 0) {
|
|
||||||
if (vm_to_read >= PAGESIZE-pageoffset) {
|
|
||||||
memcpy((char*)video_modes_plm+dstoffset, databuf+pageoffset, PAGESIZE-pageoffset);
|
|
||||||
dstoffset += PAGESIZE-pageoffset;
|
|
||||||
vm_to_read -= PAGESIZE-pageoffset;
|
|
||||||
pageoffset = 0;
|
|
||||||
pageno++;
|
|
||||||
// check
|
|
||||||
retval = alt_epcq_controller2_read(epcq_dev, (USERDATA_OFFSET+entry*SECTORSIZE+pageno*PAGESIZE), databuf, PAGESIZE);
|
|
||||||
for (i=0; i<PAGESIZE; i++)
|
|
||||||
databuf[i] = bitswap8(databuf[i]);
|
|
||||||
if (retval != 0)
|
|
||||||
return retval;
|
|
||||||
} else {
|
|
||||||
memcpy((char*)video_modes_plm+dstoffset, databuf+pageoffset, vm_to_read);
|
|
||||||
pageoffset += vm_to_read;
|
|
||||||
vm_to_read = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
update_cur_vm = 1;
|
|
||||||
|
|
||||||
printf("Profile %u data read (%u bytes)\n", entry, sizeof(avconfig_t)+sizeof(video_modes_plm_default));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("Unknown userdata entry\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int import_userdata()
|
|
||||||
{
|
|
||||||
SDRESULTS res;
|
|
||||||
int retval;
|
|
||||||
int n, entries_imported=0;
|
|
||||||
char *errmsg;
|
|
||||||
alt_u8 databuf[SD_BLK_SIZE];
|
|
||||||
ude_hdr header;
|
|
||||||
alt_u32 btn_vec;
|
|
||||||
|
|
||||||
retval = check_sdcard(databuf);
|
|
||||||
SPI_CS_High();
|
|
||||||
if (retval != 0)
|
|
||||||
goto sd_disable;
|
|
||||||
|
|
||||||
strncpy(menu_row2, "Import? 1=Y, 2=N", LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(2);
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
btn_vec = IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & RC_MASK;
|
|
||||||
|
|
||||||
if (btn_vec == rc_keymap[RC_BTN1]) {
|
|
||||||
break;
|
|
||||||
} else if (btn_vec == rc_keymap[RC_BTN2]) {
|
|
||||||
retval = UDATA_IMPT_CANCELLED;
|
|
||||||
strncpy(menu_row2, "Cancelled", LCD_ROW_LEN+1);
|
|
||||||
goto sd_disable;
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(WAITLOOP_SLEEP_US);
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(menu_row2, "Loading...", LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(2);
|
|
||||||
|
|
||||||
// Import the userdata
|
|
||||||
for (n=0; n<=MAX_USERDATA_ENTRY; ++n) {
|
|
||||||
res = SD_Read(&sdcard_dev, &header, (512+n*SECTORSIZE)/SD_BLK_SIZE, 0, sizeof(header));
|
|
||||||
if (res != SD_OK) {
|
|
||||||
printf("Failed to read SD card\n");
|
|
||||||
retval = -res;
|
|
||||||
goto sd_disable;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp(header.userdata_key, "USRDATA", 8)) {
|
|
||||||
printf("Not an userdata entry at 0x%x\n", 512+n*SECTORSIZE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((header.type == UDE_PROFILE) && ((header.version_major != PROFILE_VER_MAJOR) || (header.version_minor != PROFILE_VER_MINOR))) {
|
|
||||||
printf("Profile version %u.%.2u does not match current one\n", header.version_major, header.version_minor);
|
|
||||||
continue;
|
|
||||||
} else if ((header.type == UDE_INITCFG) && ((header.version_major != INITCFG_VER_MAJOR) || (header.version_minor != INITCFG_VER_MINOR))) {
|
|
||||||
printf("Initconfig version %u.%.2u does not match current one\n", header.version_major, header.version_minor);
|
|
||||||
continue;
|
|
||||||
} else if (header.type > UDE_PROFILE) {
|
|
||||||
printf("Unknown userdata entry type %u\n", header.type);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Just blindly write the entry to flash
|
|
||||||
retval = copy_sd_to_flash((512+n*SECTORSIZE)/SD_BLK_SIZE, (n*PAGES_PER_SECTOR)+(USERDATA_OFFSET/PAGESIZE),
|
|
||||||
(header.type == UDE_PROFILE) ? (sizeof(ude_profile)+sizeof(video_modes_plm_default)) : sizeof(ude_initcfg), databuf);
|
|
||||||
if (retval != 0) {
|
|
||||||
printf("Copy from SD to flash failed (error %d)\n", retval);
|
|
||||||
goto sd_disable;
|
|
||||||
}
|
|
||||||
|
|
||||||
entries_imported++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// flash read immediately after write might fail, add some delay
|
|
||||||
usleep(1000);
|
|
||||||
|
|
||||||
read_userdata(INIT_CONFIG_SLOT, 0);
|
|
||||||
profile_sel = input_profiles[target_input];
|
|
||||||
read_userdata(profile_sel, 0);
|
|
||||||
|
|
||||||
sniprintf(menu_row2, LCD_ROW_LEN+1, "%d slots loaded", entries_imported);
|
|
||||||
retval = 1;
|
|
||||||
|
|
||||||
sd_disable:
|
|
||||||
SPI_CS_High();
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static alt_u8 poll_yesno(const useconds_t useconds, alt_u32 *const btn_vec_out)
|
|
||||||
{
|
|
||||||
alt_u32 btn_vec;
|
|
||||||
alt_u8 ret = 0U;
|
|
||||||
|
|
||||||
for (alt_u32 i = 0; i < (useconds/WAITLOOP_SLEEP_US); ++i) {
|
|
||||||
btn_vec = IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & RC_MASK;
|
|
||||||
|
|
||||||
for (alt_u32 j = RC_BTN1; j < (REMOTE_MAX_KEYS - 1); ++j) {
|
|
||||||
if (btn_vec == rc_keymap[j]) {
|
|
||||||
ret = 1U;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
|
|
||||||
usleep(WAITLOOP_SLEEP_US);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
*btn_vec_out = btn_vec;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int export_userdata()
|
|
||||||
{
|
|
||||||
int retval;
|
|
||||||
const char *msg;
|
|
||||||
alt_u8 databuf[SD_BLK_SIZE];
|
|
||||||
alt_u8 prompt_state = 0;
|
|
||||||
useconds_t prompt_delay;
|
|
||||||
const alt_u8 prompt_transitions[] = { 1, 2, 0, 0, };
|
|
||||||
const alt_u8 prompt_ofs[] = { 0, 16, 31, LNG(48, 47), };
|
|
||||||
const char *prompt_msgs =
|
|
||||||
LNG(
|
|
||||||
"SD CARD WILL BE" "\0" // [ 0..15]
|
|
||||||
"OVERWRITTEN!!!" "\0" // [16..30]
|
|
||||||
"Export? 1=Y, 2=N""\0" // [31..47]
|
|
||||||
"Press 1 or 2", // [48..60]
|
|
||||||
"SDカードヲウワガキシマス" "\0" // [ 0..15]
|
|
||||||
"ゴチュウイクダサイ!!!" "\0" // [16..30]
|
|
||||||
"1=ジッコウスル 2=ヤメル" "\0" // [31..46]
|
|
||||||
"ドチラカエランデクダサイ" // [47..60]
|
|
||||||
);
|
|
||||||
alt_u32 btn_vec, sd_block_offset;
|
|
||||||
|
|
||||||
_Static_assert(SD_BLK_SIZE == FAT16_SECTOR_SIZE, "Sector size mismatch");
|
|
||||||
|
|
||||||
retval = check_sdcard(databuf);
|
|
||||||
SPI_CS_High();
|
|
||||||
if (retval != 0) {
|
|
||||||
retval = -retval;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(100000U);
|
|
||||||
while (1) {
|
|
||||||
msg = &prompt_msgs[prompt_ofs[prompt_state]];
|
|
||||||
prompt_delay = (prompt_state == 2) ? 2000000U
|
|
||||||
: ((prompt_state == 3) ? 300000U : 1000000U);
|
|
||||||
prompt_state = prompt_transitions[prompt_state];
|
|
||||||
|
|
||||||
strncpy(menu_row2, msg, LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(2);
|
|
||||||
if (poll_yesno(prompt_delay, &btn_vec))
|
|
||||||
goto eval_button;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
eval_button:
|
|
||||||
if (btn_vec == rc_keymap[RC_BTN1]) {
|
|
||||||
break;
|
|
||||||
} else if (btn_vec == rc_keymap[RC_BTN2] ||
|
|
||||||
btn_vec == rc_keymap[RC_BACK])
|
|
||||||
{
|
|
||||||
retval = UDATA_EXPT_CANCELLED;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
prompt_state = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(100000U);
|
|
||||||
strncpy(menu_row1,"SD Format", LCD_ROW_LEN+1);
|
|
||||||
strncpy(menu_row2,"1=FAT16, 2=RAW", LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(2);
|
|
||||||
if ((!poll_yesno(5000000U, &btn_vec)) || ((btn_vec != rc_keymap[RC_BTN1]) && (btn_vec != rc_keymap[RC_BTN2]))) {
|
|
||||||
retval = UDATA_EXPT_CANCELLED;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
sd_block_offset = (btn_vec == rc_keymap[RC_BTN1]) ? (PROF_16_DATA_OFS/SD_BLK_SIZE) : 0;
|
|
||||||
|
|
||||||
strncpy(menu_row2, LNG("Exporting...", "オマチクダサイ"), LCD_ROW_LEN+1);
|
|
||||||
ui_disp_menu(2);
|
|
||||||
|
|
||||||
// RAW copy
|
|
||||||
if (btn_vec == rc_keymap[RC_BTN2])
|
|
||||||
goto copy_start;
|
|
||||||
|
|
||||||
/* Zero out the boot sector, FATs and root directory. */
|
|
||||||
memset(databuf, 0, SD_BLK_SIZE);
|
|
||||||
for (alt_u32 sector = 0;
|
|
||||||
sector < (FAT16_ROOT_DIR_FIRST_SECTOR + FAT16_ROOT_DIR_SECTORS);
|
|
||||||
++sector)
|
|
||||||
{
|
|
||||||
retval = SD_Write(&sdcard_dev, databuf, sector);
|
|
||||||
if (retval)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Generate and write the boot sector. */
|
|
||||||
generate_boot_sector_16(databuf);
|
|
||||||
retval = SD_Write(&sdcard_dev, databuf, 0);
|
|
||||||
if (retval)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/* Generate and write the file allocation tables. */
|
|
||||||
for (alt_u16 clusters_written = 0, sd_blk_idx = 0;
|
|
||||||
clusters_written < (PROF_16_DATA_SIZE/FAT16_CLUSTER_SIZE);)
|
|
||||||
{
|
|
||||||
memset(databuf, 0, SD_BLK_SIZE);
|
|
||||||
clusters_written = generate_fat16(databuf, clusters_written);
|
|
||||||
retval = SD_Write(&sdcard_dev, databuf,
|
|
||||||
(FAT16_1_OFS/SD_BLK_SIZE) + sd_blk_idx);
|
|
||||||
if (retval)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
retval = SD_Write(&sdcard_dev, databuf,
|
|
||||||
(FAT16_2_OFS/SD_BLK_SIZE) + sd_blk_idx);
|
|
||||||
if (retval)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
++sd_blk_idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write the directory entry of the settings file. */
|
|
||||||
memset(databuf, 0, SD_BLK_SIZE);
|
|
||||||
memcpy(databuf, prof_dirent_16, PROF_DIRENT_16_SIZE);
|
|
||||||
retval = SD_Write(&sdcard_dev, databuf, PROF_DIRENT_16_OFS/SD_BLK_SIZE);
|
|
||||||
if (retval)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
copy_start:
|
|
||||||
// Zero out first 512 bytes (1 SD block) of the file
|
|
||||||
memset(databuf, 0, SD_BLK_SIZE);
|
|
||||||
retval = SD_Write(&sdcard_dev, databuf, sd_block_offset++);
|
|
||||||
if (retval)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/* This may wear the SD card a bit more than necessary... */
|
|
||||||
retval = copy_flash_to_sd(USERDATA_OFFSET/PAGESIZE,
|
|
||||||
sd_block_offset,
|
|
||||||
(MAX_USERDATA_ENTRY + 1) * SECTORSIZE,
|
|
||||||
databuf);
|
|
||||||
|
|
||||||
out:
|
|
||||||
SPI_CS_High();
|
|
||||||
|
|
||||||
switch (retval) {
|
|
||||||
case 0:
|
|
||||||
msg = LNG("Success", "カンリョウシマシタ"); // Alternative: "カンリョウイタシマシタ"
|
|
||||||
break;
|
|
||||||
case SD_NOINIT:
|
|
||||||
msg = LNG("No SD card det.", "SDカードガミツカリマセン");
|
|
||||||
break;
|
|
||||||
case -EINVAL:
|
|
||||||
msg = LNG("Invalid params.", "パラメータガムコウデス");
|
|
||||||
break;
|
|
||||||
case UDATA_EXPT_CANCELLED:
|
|
||||||
msg = LNG("Cancelled", "キャンセルサレマシタ"); // Alternative: "キャンセルサセテイタダキマス"
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
msg = LNG("SD/Flash error", "SDカFLASHノエラー"); // フラッシュ would be NG.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strncpy(menu_row2, msg, LCD_ROW_LEN+1);
|
|
||||||
|
|
||||||
if (!retval) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* We want the message above to remain on screen, so return a
|
|
||||||
* positive value which nevertheless stands out when debugging.
|
|
||||||
*/
|
|
||||||
return 0x0dead;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -21,12 +21,15 @@
|
|||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "avconfig.h"
|
#include "avconfig.h"
|
||||||
#include "av_controller.h"
|
#include "av_controller.h"
|
||||||
|
#include "userdata.h"
|
||||||
#include "altera_avalon_pio_regs.h"
|
#include "altera_avalon_pio_regs.h"
|
||||||
#include "tvp7002.h"
|
#include "tvp7002.h"
|
||||||
|
|
||||||
#define DEFAULT_ON 1
|
#define DEFAULT_ON 1
|
||||||
|
|
||||||
|
extern avmode_t cm;
|
||||||
extern alt_u8 update_cur_vm;
|
extern alt_u8 update_cur_vm;
|
||||||
|
extern uint8_t sd_profile_sel_menu;
|
||||||
|
|
||||||
// Target configuration
|
// Target configuration
|
||||||
avconfig_t tc;
|
avconfig_t tc;
|
||||||
@ -45,6 +48,7 @@ const avconfig_t tc_default = {
|
|||||||
.vsync_thold = DEFAULT_VSYNC_THOLD,
|
.vsync_thold = DEFAULT_VSYNC_THOLD,
|
||||||
.pre_coast = DEFAULT_PRE_COAST,
|
.pre_coast = DEFAULT_PRE_COAST,
|
||||||
.post_coast = DEFAULT_POST_COAST,
|
.post_coast = DEFAULT_POST_COAST,
|
||||||
|
.adc_pll_bw = 1,
|
||||||
.sync_lpf = DEFAULT_SYNC_LPF,
|
.sync_lpf = DEFAULT_SYNC_LPF,
|
||||||
.alc_h_filter = DEFAULT_ALC_H_FILTER,
|
.alc_h_filter = DEFAULT_ALC_H_FILTER,
|
||||||
.alc_v_filter = DEFAULT_ALC_V_FILTER,
|
.alc_v_filter = DEFAULT_ALC_V_FILTER,
|
||||||
@ -58,21 +62,45 @@ const avconfig_t tc_default = {
|
|||||||
.c_gain = DEFAULT_COARSE_GAIN,
|
.c_gain = DEFAULT_COARSE_GAIN,
|
||||||
},
|
},
|
||||||
.mask_br = 8,
|
.mask_br = 8,
|
||||||
#ifdef ENABLE_AUDIO
|
.shmask_str = 15,
|
||||||
.audio_dw_sampl = DEFAULT_ON,
|
.audio_dw_sampl = DEFAULT_ON,
|
||||||
.audio_gain = AUDIO_GAIN_0DB,
|
.audio_gain = AUDIO_GAIN_0DB,
|
||||||
#endif
|
|
||||||
.link_av = AV_LAST,
|
.link_av = AV_LAST,
|
||||||
};
|
};
|
||||||
|
|
||||||
int set_default_avconfig()
|
int set_default_profile(int update_cc)
|
||||||
{
|
{
|
||||||
memcpy(&tc, &tc_default, sizeof(avconfig_t));
|
memcpy(&tc, &tc_default, sizeof(avconfig_t));
|
||||||
|
|
||||||
tc.tx_mode = (IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & HDMITX_MODE_MASK) ? TX_DVI : TX_HDMI_RGB;
|
tc.tx_mode = (IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & HDMITX_MODE_MASK) ? TX_DVI : TX_HDMI_RGB;
|
||||||
|
|
||||||
|
if (update_cc)
|
||||||
|
memcpy(&cm.cc, &tc, sizeof(avconfig_t));
|
||||||
|
|
||||||
|
set_default_c_shmask();
|
||||||
|
set_default_c_lc_palette_set();
|
||||||
set_default_vm_table();
|
set_default_vm_table();
|
||||||
update_cur_vm = 1;
|
update_cur_vm = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int reset_profile() {
|
||||||
|
set_default_profile(0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_profile_sd() {
|
||||||
|
return read_userdata_sd(sd_profile_sel_menu, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int save_profile_sd() {
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
retval = write_userdata_sd(sd_profile_sel_menu);
|
||||||
|
if (retval == 0)
|
||||||
|
write_userdata_sd(SD_INIT_CONFIG_SLOT);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "system.h"
|
||||||
#include "alt_types.h"
|
#include "alt_types.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
@ -31,31 +33,32 @@
|
|||||||
|
|
||||||
static const char *rc_keydesc[REMOTE_MAX_KEYS] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", \
|
static const char *rc_keydesc[REMOTE_MAX_KEYS] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", \
|
||||||
"MENU", "OK", "BACK", "UP", "DOWN", "LEFT", "RIGHT", "INFO", "LCD_BACKLIGHT", "SCANLINE_MODE", \
|
"MENU", "OK", "BACK", "UP", "DOWN", "LEFT", "RIGHT", "INFO", "LCD_BACKLIGHT", "SCANLINE_MODE", \
|
||||||
"SCANLINE_TYPE", "SCANLINE_INT+", "SCANLINE_INT-", "LINEMULT_MODE", "PHASE+", "PHASE-", "PROFILE_HOTKEY"};
|
"SCANLINE_TYPE", "SCANLINE_INT+", "SCANLINE_INT-", "SHMASK_MODE+", "SHMASK_MODE-", "SHMASK_INT+", "SHMASK_INT-", "LINEMULT_MODE", "PHASE+", "PHASE-",
|
||||||
|
"PROFILE_HOTKEY"};
|
||||||
const alt_u16 rc_keymap_default[REMOTE_MAX_KEYS] = {0x3E29, 0x3EA9, 0x3E69, 0x3EE9, 0x3E19, 0x3E99, 0x3E59, 0x3ED9, 0x3E39, 0x3EC9, \
|
const alt_u16 rc_keymap_default[REMOTE_MAX_KEYS] = {0x3E29, 0x3EA9, 0x3E69, 0x3EE9, 0x3E19, 0x3E99, 0x3E59, 0x3ED9, 0x3E39, 0x3EC9, \
|
||||||
0x3E4D, 0x3E1D, 0x3EED, 0x3E2D, 0x3ECD, 0x3EAD, 0x3E6D, 0x3E65, 0x3E01, 0x1C48, \
|
0x3E4D, 0x3E1D, 0x3EED, 0x3E2D, 0x3ECD, 0x3EAD, 0x3E6D, 0x3E65, 0x3E01, 0x1C48, \
|
||||||
0x1C18, 0x1C50, 0x1CD0, 0x1CC8, 0x5E58, 0x5ED8, 0x3EB9};
|
0x1C18, 0x1C50, 0x1CD0, 0x3E5D, 0x3E9D, 0x1C70, 0x1CF0, 0x1CC8, 0x5E58, 0x5ED8,
|
||||||
|
0x3EB9};
|
||||||
alt_u16 rc_keymap[REMOTE_MAX_KEYS];
|
alt_u16 rc_keymap[REMOTE_MAX_KEYS];
|
||||||
|
|
||||||
extern char menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
extern char menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
||||||
extern mode_data_t video_modes_plm[];
|
extern mode_data_t video_modes_plm[];
|
||||||
extern avmode_t cm;
|
extern avmode_t cm;
|
||||||
extern avconfig_t tc;
|
extern avconfig_t tc;
|
||||||
|
extern settings_t ts;
|
||||||
extern avinput_t target_input;
|
extern avinput_t target_input;
|
||||||
extern alt_u8 menu_active;
|
extern alt_u8 menu_active;
|
||||||
extern alt_u32 sys_ctrl;
|
extern alt_u32 sys_ctrl;
|
||||||
extern alt_u16 tc_sampler_phase;
|
extern alt_u16 tc_sampler_phase;
|
||||||
extern alt_u8 profile_sel, profile_sel_menu;
|
extern alt_u8 profile_sel, profile_sel_menu;
|
||||||
extern alt_u8 lcd_bl_timeout;
|
|
||||||
extern alt_u8 vm_edit;
|
extern alt_u8 vm_edit;
|
||||||
extern volatile osd_regs *osd;
|
extern volatile osd_regs *osd;
|
||||||
|
|
||||||
extern menu_t menu_scanlines, menu_advtiming;
|
extern menu_t menu_scanlines, menu_advtiming, menu_postproc;
|
||||||
|
|
||||||
alt_u32 remote_code;
|
alt_u32 remote_code;
|
||||||
alt_u8 remote_rpt, remote_rpt_prev;
|
alt_u8 remote_rpt, remote_rpt_prev;
|
||||||
alt_u32 btn_code, btn_code_prev;
|
alt_u32 btn_code, btn_code_prev;
|
||||||
alt_u8 phase_hotkey_enable;
|
|
||||||
|
|
||||||
void setup_rc()
|
void setup_rc()
|
||||||
{
|
{
|
||||||
@ -92,7 +95,7 @@ void setup_rc()
|
|||||||
|
|
||||||
if ((btn_code_prev == 0) && (btn_code == PB0_BIT)) {
|
if ((btn_code_prev == 0) && (btn_code == PB0_BIT)) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
memcpy(rc_keymap, rc_keymap_default, sizeof(rc_keymap));
|
set_default_keymap();
|
||||||
i=REMOTE_MAX_KEYS;
|
i=REMOTE_MAX_KEYS;
|
||||||
} else {
|
} else {
|
||||||
i-=2;
|
i-=2;
|
||||||
@ -114,6 +117,10 @@ void setup_rc()
|
|||||||
osd->osd_config.menu_active = 0;
|
osd->osd_config.menu_active = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_default_keymap() {
|
||||||
|
memcpy(rc_keymap, rc_keymap_default, sizeof(rc_keymap));
|
||||||
|
}
|
||||||
|
|
||||||
int parse_control()
|
int parse_control()
|
||||||
{
|
{
|
||||||
int i, prof_x10=0, ret=0, retval;
|
int i, prof_x10=0, ret=0, retval;
|
||||||
@ -214,6 +221,43 @@ int parse_control()
|
|||||||
render_osd_page();
|
render_osd_page();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case RC_SHMMODE_MINUS:
|
||||||
|
case RC_SHMMODE_PLUS:
|
||||||
|
if (i == RC_SHMMODE_MINUS)
|
||||||
|
tc.shmask_mode = tc.shmask_mode ? (tc.shmask_mode - 1) : menu_postproc.items[0].sel.max;
|
||||||
|
else
|
||||||
|
tc.shmask_mode = (tc.shmask_mode < menu_postproc.items[0].sel.max) ? (tc.shmask_mode + 1) : 0;
|
||||||
|
|
||||||
|
if (!menu_active) {
|
||||||
|
strncpy((char*)osd->osd_array.data[0][0], menu_postproc.items[0].name, OSD_CHAR_COLS);
|
||||||
|
strncpy((char*)osd->osd_array.data[1][0], menu_postproc.items[0].sel.setting_str[tc.shmask_mode], OSD_CHAR_COLS);
|
||||||
|
osd->osd_config.status_refresh = 1;
|
||||||
|
osd->osd_row_color.mask = 0;
|
||||||
|
osd->osd_sec_enable[0].mask = 3;
|
||||||
|
osd->osd_sec_enable[1].mask = 0;
|
||||||
|
} else if (get_current_menunavi()->m == &menu_postproc) {
|
||||||
|
render_osd_page();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RC_SHMINT_MINUS:
|
||||||
|
case RC_SHMINT_PLUS:
|
||||||
|
if (i == RC_SHMINT_MINUS)
|
||||||
|
tc.shmask_str = tc.shmask_str ? (tc.shmask_str - 1) : 0;
|
||||||
|
else
|
||||||
|
tc.shmask_str = (tc.shmask_str < SCANLINESTR_MAX) ? (tc.shmask_str + 1) : SCANLINESTR_MAX;
|
||||||
|
|
||||||
|
if (!menu_active) {
|
||||||
|
strncpy((char*)osd->osd_array.data[0][0], menu_postproc.items[2].name, OSD_CHAR_COLS);
|
||||||
|
menu_postproc.items[2].num.df(tc.shmask_str);
|
||||||
|
strncpy((char*)osd->osd_array.data[1][0], menu_row2, OSD_CHAR_COLS);
|
||||||
|
osd->osd_config.status_refresh = 1;
|
||||||
|
osd->osd_row_color.mask = 0;
|
||||||
|
osd->osd_sec_enable[0].mask = 3;
|
||||||
|
osd->osd_sec_enable[1].mask = 0;
|
||||||
|
} else if (get_current_menunavi()->m == &menu_postproc) {
|
||||||
|
render_osd_page();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case RC_LM_MODE:
|
case RC_LM_MODE:
|
||||||
strncpy(menu_row1, "Linemult mode:", LCD_ROW_LEN+1);
|
strncpy(menu_row1, "Linemult mode:", LCD_ROW_LEN+1);
|
||||||
strncpy(menu_row2, "press 1-6", LCD_ROW_LEN+1);
|
strncpy(menu_row2, "press 1-6", LCD_ROW_LEN+1);
|
||||||
@ -253,7 +297,7 @@ int parse_control()
|
|||||||
break;
|
break;
|
||||||
case RC_PHASE_MINUS:
|
case RC_PHASE_MINUS:
|
||||||
case RC_PHASE_PLUS:
|
case RC_PHASE_PLUS:
|
||||||
if (phase_hotkey_enable) {
|
if (ts.phase_hotkey_enable) {
|
||||||
if (i == RC_PHASE_MINUS)
|
if (i == RC_PHASE_MINUS)
|
||||||
video_modes_plm[cm.id].sampler_phase = video_modes_plm[cm.id].sampler_phase ? (video_modes_plm[cm.id].sampler_phase - 1) : SAMPLER_PHASE_MAX;
|
video_modes_plm[cm.id].sampler_phase = video_modes_plm[cm.id].sampler_phase ? (video_modes_plm[cm.id].sampler_phase - 1) : SAMPLER_PHASE_MAX;
|
||||||
else
|
else
|
||||||
@ -339,7 +383,7 @@ Button_Check:
|
|||||||
|
|
||||||
sys_ctrl &= ~(3<<LCD_BL_TIMEOUT_OFFS);
|
sys_ctrl &= ~(3<<LCD_BL_TIMEOUT_OFFS);
|
||||||
if (!menu_active)
|
if (!menu_active)
|
||||||
sys_ctrl |= (lcd_bl_timeout << LCD_BL_TIMEOUT_OFFS);
|
sys_ctrl |= (ts.lcd_bl_timeout << LCD_BL_TIMEOUT_OFFS);
|
||||||
|
|
||||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user