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 /* Pointers to pixel lines. */ 54 55 uint8_t *linedata; 56 57 /* General display configuration. */ 58 59 display_config_t *display_config; 60 61 } vga_display_t; 62 63 64 65 /* Initialisation. */ 66 67 void init_vga(display_config_t *display_config, int line_channels, 68 int line_timer, int initiating_int_num); 69 70 void init_vga_with_timers(display_config_t *display_config, int line_channels, 71 int line_timer, int transfer_timer); 72 73 void vga_configure_sync(int hsync_unit, int vsync_unit); 74 75 void vga_configure_transfer(uint32_t output); 76 77 void vga_configure_dma_transfer(uint32_t output); 78 79 /* Initialisation helpers. */ 80 81 void vga_configure_line_channel(int channel, int int_num, enum dma_chain chain, 82 uint32_t output); 83 84 void vga_configure_zero_channel(int channel, int int_num, int initiating, 85 uint32_t output); 86 87 /* Access-related operations. */ 88 89 void vga_wait_visible(void); 90 91 /* Interrupt handlers. */ 92 93 void vga_interrupt_handler(void); 94 void vga_hsync_interrupt_handler(void); 95 void vga_transfer_interrupt_handler(void); 96 97 /* Display state handlers. */ 98 99 void vbp_active(void); 100 void visible_active(void); 101 void vfp_active(void); 102 void vsync_active(void); 103 104 /* DMA transfer operations. */ 105 106 void start_visible(void); 107 void update_visible(void); 108 void stop_visible(void); 109 void update_transfers(int enable); 110 111 /* Vertical sync operations. */ 112 113 void vsync_high(void); 114 void vsync_low(void); 115 116 #endif /* __VGA_DISPLAY_H__ */