# HG changeset patch # User Paul Boddie # Date 1541881809 -3600 # Node ID 6934a0847aed083294463c715537a47863e6bf7a # Parent ed2641a2294d143c80e20878d939fdad6ce16cc7 Simplified display configuration initialisation. diff -r ed2641a2294d -r 6934a0847aed examples/vga/main.c --- a/examples/vga/main.c Sat Nov 10 19:20:13 2018 +0100 +++ b/examples/vga/main.c Sat Nov 10 21:30:09 2018 +0100 @@ -31,8 +31,8 @@ /* Specific functionality. */ #include "devconfig.h" -#include "display_config.h" #include "main.h" +#include "vga.h" @@ -87,13 +87,9 @@ -/* Framebuffer memory. */ - -static uint8_t framebuffer[FRAME_SIZE * FRAME_COUNT]; +/* Initialise memory for a multi-frame display. */ -/* Screen start values for each frame. */ - -uint8_t *screen_starts[FRAME_COUNT]; +static Display(display_config, LINE_LENGTH, LINE_COUNT, FRAME_COUNT); @@ -347,10 +343,9 @@ uart_init(1, FPB, 115200); uart_on(1); - /* Initialise memory for a double-buffered display. */ + /* Set the display to a well-defined state. */ - init_display(&display_config, framebuffer, LINE_LENGTH, LINE_COUNT, - FRAME_COUNT, screen_starts); + init_display(&display_config); /* Initialise VGA output with one or two line channels, configuring a line timer and any transfer timer, with an initiating channel being introduced diff -r ed2641a2294d -r 6934a0847aed include/display.h --- a/include/display.h Sat Nov 10 19:20:13 2018 +0100 +++ b/include/display.h Sat Nov 10 21:30:09 2018 +0100 @@ -94,11 +94,39 @@ +/* Initialise a display. */ + +#define Display(NAME, WIDTH, HEIGHT, FRAMES) \ + uint8_t __##NAME##_framebuffer[(WIDTH) * (HEIGHT + 1) * (FRAMES)]; \ + uint8_t *__##NAME##_screen_starts[FRAMES]; \ + display_config_t NAME = { \ + .framebuffer=__##NAME##_framebuffer, \ + .screen_starts=__##NAME##_screen_starts, \ + \ + .line_length=WIDTH, \ + .line_count=HEIGHT, \ + .screen_size=(WIDTH) * (HEIGHT), \ + .total_lines=(HEIGHT + 1) * (FRAMES), \ + .frame=0, \ + .frames=FRAMES, \ + .max_frames=FRAMES, \ + \ + .scanlines = SCANLINES, \ + .line_channels = LINE_CHANNELS, \ + .cell_size = CELL_SIZE, \ + .transfer_cell_size = TRANSFER_CELL_SIZE, \ + \ + .hfreq_limit = HFREQ_LIMIT, \ + .hsync_start = HSYNC_START, \ + .hsync_end = HSYNC_END, \ + .visible_start = VISIBLE_START, \ + .vfp_start = VFP_START, \ + .vsync_start = VSYNC_START, \ + .vsync_end = VSYNC_END}; + /* Configuration functions. */ -void init_display(display_config_t *cfg, uint8_t *framebuffer, - uint32_t line_length, uint32_t line_count, - int frames, uint8_t **screen_starts); +void init_display(display_config_t *cfg); void init_display_properties(display_config_t *cfg); diff -r ed2641a2294d -r 6934a0847aed include/vga_common.h --- a/include/vga_common.h Sat Nov 10 19:20:13 2018 +0100 +++ b/include/vga_common.h Sat Nov 10 21:30:09 2018 +0100 @@ -40,4 +40,21 @@ #define VSYNC_END 622 +/* Define DMA channels if not indicated in the build configuration. */ + +/* CPU-based transfers: no channels. */ + +#ifdef TRANSFER_CPU +#define LINE_CHANNELS 0 + +/* DMA-based transfers: single channel by default. */ + +#else + +#ifndef LINE_CHANNELS +#define LINE_CHANNELS 1 +#endif + +#endif /* TRANSFER_CPU */ + #endif /* __VGA_COMMON_H__ */ diff -r ed2641a2294d -r 6934a0847aed lib/display.c --- a/lib/display.c Sat Nov 10 19:20:13 2018 +0100 +++ b/lib/display.c Sat Nov 10 21:30:09 2018 +0100 @@ -24,35 +24,8 @@ /* Initialise a display configuration. */ -void init_display(display_config_t *cfg, uint8_t *framebuffer, - uint32_t line_length, uint32_t line_count, - int frames, uint8_t **screen_starts) +void init_display(display_config_t *cfg) { - /* Framebuffer address. */ - - cfg->framebuffer = framebuffer; - - /* Frame allocation limits. */ - - cfg->total_lines = (line_count + 1) * frames; - cfg->max_frames = frames; - - /* Screen size and dimensions. */ - - cfg->screen_size = line_length * line_count; - cfg->line_length = line_length; - cfg->line_count = line_count; - - /* Set the number of frames and the current frame. */ - - cfg->frames = frames; - cfg->frame = 0; - - /* Set the pointer to a collection of screen start pointers, one per - frame. */ - - cfg->screen_starts = screen_starts; - init_frames(cfg); init_display_properties(cfg); }