1.1 --- a/examples/vga/main.c Wed Nov 07 00:12:44 2018 +0100
1.2 +++ b/examples/vga/main.c Thu Nov 08 18:32:07 2018 +0100
1.3 @@ -39,17 +39,11 @@
1.4 /* CPU-based transfers: no channels. */
1.5
1.6 #ifdef TRANSFER_CPU
1.7 -#define LINE_CHANNELS 0
1.8 #define SCROLL_XSTEP 1
1.9
1.10 /* DMA-based transfers: single channel by default. */
1.11
1.12 #else
1.13 -
1.14 -#ifndef LINE_CHANNELS
1.15 -#define LINE_CHANNELS 1
1.16 -#endif
1.17 -
1.18 #define SCROLL_XSTEP LINE_CHANNELS
1.19 #endif
1.20
2.1 --- a/include/display.h Wed Nov 07 00:12:44 2018 +0100
2.2 +++ b/include/display.h Thu Nov 08 18:32:07 2018 +0100
2.3 @@ -66,6 +66,10 @@
2.4
2.5 int line_multiplier; /* = scanlines / line_count */
2.6
2.7 + /* Number of line channels used for pixel data transfers. */
2.8 +
2.9 + int line_channels;
2.10 +
2.11 /* Number of consecutive pixels provided by a framebuffer region. */
2.12
2.13 uint32_t cell_size;
3.1 --- a/include/display_config.h Wed Nov 07 00:12:44 2018 +0100
3.2 +++ b/include/display_config.h Thu Nov 08 18:32:07 2018 +0100
3.3 @@ -24,6 +24,23 @@
3.4 #include "display.h"
3.5 #include "vga.h"
3.6
3.7 +/* Define DMA channels if not indicated in the build configuration. */
3.8 +
3.9 +/* CPU-based transfers: no channels. */
3.10 +
3.11 +#ifdef TRANSFER_CPU
3.12 +#define LINE_CHANNELS 0
3.13 +
3.14 +/* DMA-based transfers: single channel by default. */
3.15 +
3.16 +#else
3.17 +
3.18 +#ifndef LINE_CHANNELS
3.19 +#define LINE_CHANNELS 1
3.20 +#endif
3.21 +
3.22 +#endif
3.23 +
3.24 /* Define a structure containing the display parameters. */
3.25
3.26 display_config_t display_config = {
3.27 @@ -31,6 +48,7 @@
3.28 /* Define display properties. */
3.29
3.30 .scanlines = SCANLINES,
3.31 + .line_channels = LINE_CHANNELS,
3.32 .cell_size = CELL_SIZE,
3.33 .transfer_cell_size = TRANSFER_CELL_SIZE,
3.34
4.1 --- a/lib/display.c Wed Nov 07 00:12:44 2018 +0100
4.2 +++ b/lib/display.c Thu Nov 08 18:32:07 2018 +0100
4.3 @@ -121,8 +121,24 @@
4.4
4.5 int get_position(display_config_t *cfg, int x)
4.6 {
4.7 - int cell = x / cfg->cell_size, offset = x % cfg->cell_size;
4.8 - int pos = (cell / 2) * cfg->cell_size + offset;
4.9 + int cell, offset, pos;
4.10 +
4.11 + if (cfg->line_channels < 2)
4.12 + return x;
4.13 +
4.14 + /* Determine which cell is providing the position and the offset of the
4.15 + pixel within the cell. */
4.16 +
4.17 + cell = x / cfg->cell_size;
4.18 + offset = x % cfg->cell_size;
4.19 +
4.20 + /* Determine the resulting position within the divided-up data. */
4.21 +
4.22 + pos = (cell / 2) * cfg->cell_size + offset;
4.23 +
4.24 + /* Return the final position within the entire data. All cells in
4.25 + odd-numbered positions occur in the first half, all even-numbered cells
4.26 + in the second half. */
4.27
4.28 return cell % 2 ? pos + cfg->line_length / 2 : pos;
4.29 }