paul@50 | 1 | /* |
paul@50 | 2 | * VGA display-related functions. |
paul@50 | 3 | * |
paul@50 | 4 | * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@50 | 5 | * |
paul@50 | 6 | * This program is free software: you can redistribute it and/or modify |
paul@50 | 7 | * it under the terms of the GNU General Public License as published by |
paul@50 | 8 | * the Free Software Foundation, either version 3 of the License, or |
paul@50 | 9 | * (at your option) any later version. |
paul@50 | 10 | * |
paul@50 | 11 | * This program is distributed in the hope that it will be useful, |
paul@50 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@50 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@50 | 14 | * GNU General Public License for more details. |
paul@50 | 15 | * |
paul@50 | 16 | * You should have received a copy of the GNU General Public License |
paul@50 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@50 | 18 | */ |
paul@50 | 19 | |
paul@50 | 20 | #ifndef __VGA_DISPLAY_H__ |
paul@50 | 21 | #define __VGA_DISPLAY_H__ |
paul@50 | 22 | |
paul@56 | 23 | #include "pic32_c.h" |
paul@50 | 24 | #include "display.h" |
paul@50 | 25 | |
paul@50 | 26 | |
paul@50 | 27 | |
paul@50 | 28 | /* Display configuration type. */ |
paul@50 | 29 | |
paul@50 | 30 | typedef struct |
paul@50 | 31 | { |
paul@50 | 32 | /* Current display state handler. */ |
paul@50 | 33 | |
paul@50 | 34 | void (*state_handler)(); |
paul@50 | 35 | |
paul@88 | 36 | /* Common transfer properties. */ |
paul@88 | 37 | |
paul@88 | 38 | int line_timer; |
paul@88 | 39 | uint32_t output; |
paul@88 | 40 | |
paul@56 | 41 | /* DMA transfer properties. */ |
paul@50 | 42 | |
paul@88 | 43 | int line_channels, transfer_int_num; |
paul@50 | 44 | |
paul@54 | 45 | /* Horizontal and vertical sync peripherals. */ |
paul@50 | 46 | |
paul@59 | 47 | int hsync_unit, vsync_unit; |
paul@50 | 48 | |
paul@50 | 49 | /* Current scanline. */ |
paul@50 | 50 | |
paul@50 | 51 | uint32_t line; |
paul@50 | 52 | |
paul@92 | 53 | /* Screen start address, frame limit, current pixel line. */ |
paul@92 | 54 | |
paul@92 | 55 | uint8_t *screen_start, *screen_limit, *linedata; |
paul@50 | 56 | |
paul@92 | 57 | /* Screen size, used to wrap the current line pointer. */ |
paul@92 | 58 | |
paul@92 | 59 | uint32_t screen_size; |
paul@50 | 60 | |
paul@50 | 61 | /* General display configuration. */ |
paul@50 | 62 | |
paul@50 | 63 | display_config_t *display_config; |
paul@50 | 64 | |
paul@50 | 65 | } vga_display_t; |
paul@50 | 66 | |
paul@50 | 67 | |
paul@50 | 68 | |
paul@50 | 69 | /* Initialisation. */ |
paul@50 | 70 | |
paul@56 | 71 | void init_vga(display_config_t *display_config, int line_channels, |
paul@124 | 72 | int line_timer, int transfer_int_num); |
paul@59 | 73 | |
paul@59 | 74 | void init_vga_with_timers(display_config_t *display_config, int line_channels, |
paul@59 | 75 | int line_timer, int transfer_timer); |
paul@50 | 76 | |
paul@59 | 77 | void vga_configure_sync(int hsync_unit, int vsync_unit); |
paul@53 | 78 | |
paul@59 | 79 | void vga_configure_transfer(uint32_t output); |
paul@59 | 80 | |
paul@88 | 81 | void vga_configure_dma_transfer(uint32_t output); |
paul@88 | 82 | |
paul@59 | 83 | /* Initialisation helpers. */ |
paul@56 | 84 | |
paul@56 | 85 | void vga_configure_line_channel(int channel, int int_num, enum dma_chain chain, |
paul@56 | 86 | uint32_t output); |
paul@56 | 87 | |
paul@56 | 88 | void vga_configure_zero_channel(int channel, int int_num, int initiating, |
paul@56 | 89 | uint32_t output); |
paul@56 | 90 | |
paul@96 | 91 | /* Access-related operations. */ |
paul@96 | 92 | |
paul@92 | 93 | void vga_set_frame(display_config_t *display_config); |
paul@96 | 94 | void vga_wait_visible(void); |
paul@96 | 95 | |
paul@50 | 96 | /* Interrupt handlers. */ |
paul@50 | 97 | |
paul@50 | 98 | void vga_interrupt_handler(void); |
paul@88 | 99 | void vga_hsync_interrupt_handler(void); |
paul@88 | 100 | void vga_transfer_interrupt_handler(void); |
paul@50 | 101 | |
paul@50 | 102 | /* Display state handlers. */ |
paul@50 | 103 | |
paul@50 | 104 | void vbp_active(void); |
paul@50 | 105 | void visible_active(void); |
paul@50 | 106 | void vfp_active(void); |
paul@50 | 107 | void vsync_active(void); |
paul@50 | 108 | |
paul@88 | 109 | /* DMA transfer operations. */ |
paul@56 | 110 | |
paul@56 | 111 | void start_visible(void); |
paul@56 | 112 | void update_visible(void); |
paul@56 | 113 | void stop_visible(void); |
paul@56 | 114 | void update_transfers(int enable); |
paul@56 | 115 | |
paul@54 | 116 | /* Vertical sync operations. */ |
paul@54 | 117 | |
paul@54 | 118 | void vsync_high(void); |
paul@54 | 119 | void vsync_low(void); |
paul@54 | 120 | |
paul@50 | 121 | #endif /* __VGA_DISPLAY_H__ */ |