Skip to content

Commit

Permalink
default scanvideo to support 125mhz system clock for 640x480 - also m…
Browse files Browse the repository at this point in the history
…eans better compatibility as 25Mhz is better than 24Mhz when compared to 25.175Mhz
  • Loading branch information
kilograham committed Feb 13, 2021
1 parent 97ef906 commit ef3bdfa
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 24 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ Name|Description
## Networking
Name|Description
---|---
[usb_host_webserver](net/usb_host_webserver)| A simple web server implemented as

[usb_host_webserver](net/usb_host_webserver)| A simple web server
2 changes: 2 additions & 0 deletions apps/popcorn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ if (PICO_ON_DEVICE)
VIDEO_DBI

PICO_SCANVIDEO_LINKED_SCANLINE_BUFFERS=1 # we do two rows at a time

#PICO_SCANVIDEO_48MHZ # still uses this for now
)

target_link_libraries(popcorn
Expand Down
4 changes: 4 additions & 0 deletions apps/popcorn/popcorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,11 @@ void setup_audio() {
}

int main(void) {
#if PICO_SCANVIDEO_48MHZ
set_sys_clock_48mhz();
#else
set_sys_clock_khz(50000, true);
#endif

#if USE_RGB_LOW_FOR_DEBUG_PINS
gpio_dir_out_mask(0x421);
Expand Down
1 change: 1 addition & 0 deletions scanvideo/demo1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if (TARGET pico_scanvideo_dpi)

target_compile_definitions(demo1
PRIVATE
#PICO_SCANVIDEO_48MHZ
# video overlay is distracting
# PICO_SCANVIDEO_PLANE_COUNT=3
)
Expand Down
13 changes: 2 additions & 11 deletions scanvideo/demo1/demo1.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ bool render_scanline_test_pattern(struct scanvideo_scanline_buffer *dest, int co
bool render_scanline_pi(struct scanvideo_scanline_buffer *dest, int core);

extern const struct scanvideo_pio_program video_24mhz_composable;
const struct scanvideo_mode vga_mode_320x256_60 =
{
.default_timing = &vga_timing_640x480_60_default,
.pio_program = &video_24mhz_composable,
.width = 320,
.height = 256,
.xscale = 2,
.yscale = 480,
.yscale_denominator = 256
};


//#define vga_mode vga_mode_1080p
//#define vga_mode vga_mode_720p
Expand Down Expand Up @@ -612,7 +601,9 @@ int main(void) {

gpio_put(27, 0);
#if PICO_ON_DEVICE && !PICO_ON_FPGA
#if PICO_SCANVIDEO_48MHz
set_sys_clock_khz(96000, true);
#endif
// set_sys_clock_48();
#endif

Expand Down
2 changes: 1 addition & 1 deletion scanvideo/flash_stream/flash_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void __time_critical_func(render_scanline)(struct scanvideo_scanline_buffer *des
}

int main(void) {
set_sys_clock_khz(192000, true);
set_sys_clock_khz(200000, true);
setup_default_uart();

#ifdef PICO_SMPS_MODE_PIN
Expand Down
2 changes: 1 addition & 1 deletion scanvideo/flash_stream/img/pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ rm -f *.bin pack.uf2
./packtiles -sdf bgar5515 Stone_Mountain_by_Brad_Huchteman.png stone_mountain.bin
./packtiles -sdf bgar5515 Voss_by_fortuneblues.png voss.bin
cat *.bin > pack.bin
uf2conv -f pico -b 0x1003c000 pack.bin -o pack.uf2
uf2conv -f pico -b 0x1003c000 pack.bin -o pack.uf2
2 changes: 2 additions & 0 deletions scanvideo/hscroll_dma_tiles/hscroll_dma_tiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,9 @@ void go_core1(void (*execute)()) {
}

int main(void) {
#if PICO_SCANVIDEO_48MHz
set_sys_clock_48mhz();
#endif
setup_default_uart();

#if PICO_NO_HARDWARE
Expand Down
13 changes: 9 additions & 4 deletions scanvideo/mandelbrot/mandelbrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,19 +239,24 @@ void __time_critical_func(frame_update_logic)() {
}

int main(void) {
uint base_freq;
#if PICO_SCANVIDEO_48MHZ
base_freq = 48000;
#else
base_freq = 50000;
#endif
#if PICO_ON_DEVICE
#ifdef TURBO_BOOST
hw_set_bits(&mm_vreg_and_chip_reset->vreg, VREG_AND_CHIP_RESET_VREG_VSEL_BITS);
sleep_ms(10);
set_sys_clock_khz(48000*6, true);
set_sys_clock_khz(base_freq*6, true);
#else
//set_sys_clock(1536*MHZ, 4, 2);
set_sys_clock_khz(48000 * 4, true);
set_sys_clock_khz(base_freq * 3, true);
#endif
#endif
// Re init uart now that clk_peri has changed
setup_default_uart();
gpio_debug_pins_init();
// gpio_debug_pins_init();

return vga_main();
}
2 changes: 2 additions & 0 deletions scanvideo/mario_tiles/mario_tiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,9 @@ void go_core1(void (*execute)()) {
}

int main(void) {
#if PICO_SCANVIDEO_48MHz
set_sys_clock_48mhz();
#endif
setup_default_uart();

#if PICO_NO_HARDWARE
Expand Down
2 changes: 2 additions & 0 deletions scanvideo/scanvideo_minimal/scanvideo_minimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ void render_scanline(struct scanvideo_scanline_buffer *dest, int core) {


int main(void) {
#if PICO_SCANVIDEO_48MHz
set_sys_clock_48mhz();
#endif
// Re init uart now that clk_peri has changed
setup_default_uart();

Expand Down
4 changes: 4 additions & 0 deletions scanvideo/sprite_demo/sprite_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ int main(void) {
sleep_ms(10);
set_sys_clock(1536*MHZ, 4, 1);
#else
#if PICO_SCANVIDEO_48MHz
set_sys_clock_48mhz();
#endif

set_sys_clock_pll(1536 * MHZ, 4, 2);
#endif
// Re init uart now that clk_peri has changed
Expand Down
1 change: 0 additions & 1 deletion scanvideo/test_pattern/test_pattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ static semaphore_t video_initted;
static bool invert;

int main(void) {
set_sys_clock_48mhz();
stdio_init_all();

// create a semaphore to be posted when video init is complete
Expand Down
11 changes: 7 additions & 4 deletions scanvideo/textmode/textmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "pico/sync.h"
#include "font.h"

// set this to 3, 4 or 5 for smallest to biggest font
#define FRAGMENT_WORDS 4

#if PICO_ON_DEVICE

#include "hardware/structs/bus_ctrl.h"
Expand Down Expand Up @@ -168,8 +171,6 @@ uint32_t *font_raw_pixels;
#else
uint32_t font_raw_pixels[16384];
#endif
#define FRAGMENT_WORDS 4
//#define FRAGMENT_WORDS 5
#define FONT_WIDTH_WORDS FRAGMENT_WORDS
#if FRAGMENT_WORDS == 5
const lv_font_t *font = &ubuntu_mono10;
Expand Down Expand Up @@ -406,8 +407,8 @@ bool render_scanline_bg(struct scanvideo_scanline_buffer *dest, int core) {
// todo for SOME REASON, 80 is the max we can do without starting to really get bus delays (even with priority)... not sure how this could be
// todo actually it seems it can work, it just mostly starts incorrectly synced!?
#define COUNT MIN(vga_mode.width/(FRAGMENT_WORDS*2)-1, 80)//MAX_SCANLINE_BUFFER_WORDS / 2 - 2)
#undef COUNT
#define COUNT 79
//#undef COUNT
//#define COUNT 79
// we need to take up 5 words, since we have fixed width
#if PICO_SCANVIDEO_PLANE1_FIXED_FRAGMENT_DMA
dest->fragment_words = FRAGMENT_WORDS;
Expand Down Expand Up @@ -507,7 +508,9 @@ void go_core1(void (*execute)()) {
}

int main(void) {
#if PICO_SCANVIDEO_48MHZ
set_sys_clock_48mhz();
#endif
gpio_put(27, 0);

setup_default_uart();
Expand Down

0 comments on commit ef3bdfa

Please sign in to comment.