kopia lustrzana https://github.com/Wren6991/PicoDVI
Merge branch 'ikjordan:audio' into audio
commit
fbad2a7be4
|
@ -11,6 +11,7 @@ target_compile_definitions(moon PRIVATE
|
|||
DVI_VERTICAL_REPEAT=1
|
||||
DVI_N_TMDS_BUFFERS=3
|
||||
DVI_MONOCHROME_TMDS
|
||||
DVI_1BPP_BUFFER
|
||||
)
|
||||
|
||||
target_link_libraries(moon
|
||||
|
@ -34,6 +35,7 @@ target_compile_definitions(moon_pio_encode PRIVATE
|
|||
DVI_VERTICAL_REPEAT=1
|
||||
DVI_N_TMDS_BUFFERS=3
|
||||
DVI_MONOCHROME_TMDS
|
||||
DVI_1BPP_BUFFER
|
||||
USE_PIO_TMDS_ENCODE
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
add_executable(moon_double_audio
|
||||
main.c
|
||||
tmds_double.S
|
||||
tmds_double.h
|
||||
)
|
||||
|
||||
target_compile_options(moon_double_audio PRIVATE -Wall)
|
||||
|
|
|
@ -41,9 +41,9 @@ static void core1_main();
|
|||
// but playback set to 32kHz
|
||||
|
||||
// Pick one:
|
||||
#define MODE_640x480_60Hz
|
||||
//#define MODE_640x480_60Hz
|
||||
//#define MODE_720x540_50Hz
|
||||
//#define MODE_720x576_50Hz
|
||||
#define MODE_720x576_50Hz
|
||||
|
||||
#if defined(MODE_640x480_60Hz)
|
||||
#define FRAME_WIDTH 640
|
||||
|
@ -129,7 +129,7 @@ int main()
|
|||
|
||||
dvi_set_audio_freq(&dvi0, AUDIO_RATE, dvi0.timing->bit_clk_khz*HDMI_N/(AUDIO_RATE/100)/128, HDMI_N);
|
||||
|
||||
printf("FReq %i Set CTS %i\n", dvi0.timing->bit_clk_khz, dvi0.timing->bit_clk_khz*HDMI_N/(AUDIO_RATE/100)/128);
|
||||
printf("Freq %i Set CTS %i\n", dvi0.timing->bit_clk_khz, dvi0.timing->bit_clk_khz*HDMI_N/(AUDIO_RATE/100)/128);
|
||||
|
||||
|
||||
sem_init(&fifty_hz, 0, 1);
|
||||
|
@ -154,16 +154,9 @@ static void __not_in_flash_func(render_loop)()
|
|||
{
|
||||
for (uint y = 0; y < FRAME_HEIGHT/2; ++y)
|
||||
{
|
||||
const uint32_t *colourbuf = &((const uint32_t*)moon_img)[(y + (FRAME_HEIGHT >> 3))* IMAGE_WIDTH / 32];
|
||||
const uint8_t *colourbuf = (const uint8_t*)&moon_img[(y + (FRAME_HEIGHT >> 3))* IMAGE_WIDTH / 8];
|
||||
queue_remove_blocking_u32(&dvi0.q_tmds_free, &tmdsbuf);
|
||||
|
||||
// 32 pixels create 8 * 2 32 bit words
|
||||
// tmds_double_1bpp requires multiple of 32 pixels
|
||||
// For input of 360 to generate 720 pixels:
|
||||
// 360 pixels -> 11.25 32 bit words
|
||||
// Will therefore generate 12 * 32 * 2 pixels = 768
|
||||
// tmdsbuf size must be rounded up to multiple of 64
|
||||
// in dvi.c
|
||||
tmds_double_1bpp(colourbuf, tmdsbuf, FRAME_WIDTH);
|
||||
queue_add_blocking_u32(&dvi0.q_tmds_valid, &tmdsbuf);
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
// Fast Half res 1bpp black/white encoder
|
||||
|
||||
// Taking the encoder from DVI spec, with initial balance 0:
|
||||
//
|
||||
//
|
||||
// - Encoding either 0x00 or 0xff will produce a running balance of -8, with
|
||||
// output symbol of 0x100 or 0x200
|
||||
//
|
||||
//
|
||||
// - Subsequently encoding either 0x01 or 0xfe will return the balance to 0, with
|
||||
// output symbol of 0x1ff or 0x2ff
|
||||
//
|
||||
//
|
||||
// So we can do 1bpp encode with a lookup of x coordinate LSB, and input
|
||||
// colour bit. If we process pixels in even-sized blocks, only the colour
|
||||
// lookup is needed.
|
||||
|
@ -56,14 +56,14 @@
|
|||
|
||||
.endm
|
||||
|
||||
// r0: input buffer (word-aligned)
|
||||
// r0: input buffer (byte-aligned)
|
||||
// r1: output buffer (word-aligned)
|
||||
// r2: output pixel count
|
||||
decl_func tmds_double_1bpp
|
||||
push {r4-r7, lr} // Store scratch registers
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
lsls r2, #1 // Double the output pixel count - initially set to 640
|
||||
lsls r2, #1 // Double the output pixel count
|
||||
add r2, r1 // Now points to end of output buffer
|
||||
mov ip, r2 // ip is r12 - store end of output buffer
|
||||
adr r4, tmds_d1bpp_table // r4 contains pointer to look up table
|
||||
|
@ -71,30 +71,21 @@ decl_func tmds_double_1bpp
|
|||
// Mask: 2 bit index, 8 bytes per entry
|
||||
movs r3, #0x18 // bits 4 to 5 checked
|
||||
b 2f // Jump over for the first pass
|
||||
|
||||
1:
|
||||
ldmia r0!, {r2} // Loads r2 with contents pointed by r0 then inc r0
|
||||
ldrb r2, [r0]
|
||||
adds r0, #1
|
||||
#if !DVI_1BPP_BIT_REVERSE
|
||||
tmds_double_1bpp_body lsls 3 lsls 1
|
||||
tmds_double_1bpp_body lsrs 1 lsrs 3
|
||||
tmds_double_1bpp_body lsrs 5 lsrs 7
|
||||
tmds_double_1bpp_body lsrs 9 lsrs 11
|
||||
tmds_double_1bpp_body lsrs 13 lsrs 15
|
||||
tmds_double_1bpp_body lsrs 17 lsrs 19
|
||||
tmds_double_1bpp_body lsrs 21 lsrs 23
|
||||
tmds_double_1bpp_body lsrs 25 lsrs 27
|
||||
#else
|
||||
tmds_double_1bpp_body lsrs 3 lsrs 1
|
||||
tmds_double_1bpp_body lsls 1 lsls 3
|
||||
tmds_double_1bpp_body lsrs 11 lsrs 9
|
||||
tmds_double_1bpp_body lsrs 7 lsrs 5
|
||||
tmds_double_1bpp_body lsrs 19 lsrs 17
|
||||
tmds_double_1bpp_body lsrs 15 lsrs 13
|
||||
tmds_double_1bpp_body lsrs 27 lsrs 25
|
||||
tmds_double_1bpp_body lsrs 23 lsrs 21
|
||||
#endif
|
||||
|
||||
2:
|
||||
cmp r1, ip // Has all of the output data been generated
|
||||
blo 1b // If not, back to generate more
|
||||
blo 1b // If not, back to generate more
|
||||
|
||||
pop {r7} // Restore registers and return
|
||||
mov r8, r7
|
||||
|
@ -143,7 +134,7 @@ tmds_d1bpp_table:
|
|||
ldr \rd, [r0, \rd]
|
||||
.endm
|
||||
|
||||
// r0: input buffer (word-aligned)
|
||||
// r0: input buffer (byte-aligned)
|
||||
// r1: output buffer (word-aligned)
|
||||
// r2: output pixel count
|
||||
decl_func tmds_double_2bpp
|
||||
|
@ -161,28 +152,14 @@ decl_func tmds_double_2bpp
|
|||
b 2f
|
||||
1:
|
||||
mov r4, r8
|
||||
ldmia r4!, {r2}
|
||||
ldrb r2, [r4]
|
||||
adds r4, #1
|
||||
mov r8, r4
|
||||
tmds_double_2bpp_body lsls 2 r7
|
||||
tmds_double_2bpp_body lsrs 0 r6
|
||||
tmds_double_2bpp_body lsrs 2 r5
|
||||
tmds_double_2bpp_body lsrs 4 r4
|
||||
stmia r1!, {r4-r7}
|
||||
tmds_double_2bpp_body lsrs 6 r7
|
||||
tmds_double_2bpp_body lsrs 8 r6
|
||||
tmds_double_2bpp_body lsrs 10 r5
|
||||
tmds_double_2bpp_body lsrs 12 r4
|
||||
stmia r1!, {r4-r7}
|
||||
tmds_double_2bpp_body lsrs 14 r7
|
||||
tmds_double_2bpp_body lsrs 16 r6
|
||||
tmds_double_2bpp_body lsrs 18 r5
|
||||
tmds_double_2bpp_body lsrs 20 r4
|
||||
stmia r1!, {r4-r7}
|
||||
tmds_double_2bpp_body lsrs 22 r7
|
||||
tmds_double_2bpp_body lsrs 24 r6
|
||||
tmds_double_2bpp_body lsrs 26 r5
|
||||
tmds_double_2bpp_body lsrs 28 r4
|
||||
stmia r1!, {r4-r7}
|
||||
2:
|
||||
cmp r1, ip
|
||||
blo 1b
|
||||
|
@ -196,3 +173,23 @@ tmds_d2bpp_table:
|
|||
.word 0xb3e30 // 10, 10
|
||||
.word 0x73d30 // 01, 01
|
||||
.word 0x7f103 // 00, 00
|
||||
|
||||
// r0: start of tdms buffer for plane 1
|
||||
// r1: pixel count to copy
|
||||
decl_func tmds_clone
|
||||
push {lr}
|
||||
lsls r1, #2 // convert to 32 bit words
|
||||
adds r2, r0, r1 // Start of plane 2
|
||||
mov ip, r2 // End when get to plane 2
|
||||
adds r3, r2, r1 // Start of plane 3
|
||||
b 2f
|
||||
|
||||
1:
|
||||
ldm r0!, {r1}
|
||||
stm r2!, {r1}
|
||||
stm r3!, {r1}
|
||||
|
||||
2:
|
||||
cmp r0, ip
|
||||
blo 1b
|
||||
pop {pc}
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include "dvi_config_defs.h"
|
||||
|
||||
// Functions from tmds_double.S
|
||||
void tmds_double_1bpp(const uint32_t *pixbuf, uint32_t *symbuf, size_t n_pix);
|
||||
void tmds_double_2bpp(const uint32_t *pixbuf, uint32_t *symbuf, size_t n_pix);
|
||||
void tmds_double_1bpp(const uint8_t *pixbuf, uint32_t *symbuf, size_t n_pix);
|
||||
void tmds_double_2bpp(const uint8_t *pixbuf, uint32_t *symbuf, size_t n_pix);
|
||||
|
||||
void tmds_clone(const uint32_t *symbuf, size_t n_pix);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,11 @@ void dvi_init(struct dvi_inst *inst, uint spinlock_tmds_queue, uint spinlock_col
|
|||
dvi_setup_scanline_for_active(inst->timing, inst->dma_cfg, NULL, &inst->dma_list_error, false);
|
||||
dvi_setup_scanline_for_active(inst->timing, inst->dma_cfg, NULL, &inst->dma_list_active_blank, true);
|
||||
|
||||
uint16_t mask = 0x3f; // To account for worst case of monochrome horizontal pixel doubling
|
||||
uint16_t mask = 0;
|
||||
|
||||
#ifdef DVI_1BPP_BUFFER
|
||||
mask = 0x1f; // To account for worst case of 1bpp horizontal pixels generated 32 bits at a time (e.g. 720x568)
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < DVI_N_TMDS_BUFFERS; ++i) {
|
||||
#if DVI_MONOCHROME_TMDS
|
||||
|
|
Ładowanie…
Reference in New Issue