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