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 /* DMA transfer properties. */ 37 38 int line_channels, initiating_int_num; 39 40 /* Horizontal and vertical sync peripherals. */ 41 42 int timer, hsync_unit, vsync_unit; 43 44 /* Current scanline. */ 45 46 uint32_t line; 47 48 /* Pointers to pixel lines. */ 49 50 uint8_t *linedata; 51 52 /* General display configuration. */ 53 54 display_config_t *display_config; 55 56 } vga_display_t; 57 58 59 60 /* Initialisation. */ 61 62 void init_vga(display_config_t *display_config, int line_channels, 63 int initiating_int_num); 64 65 void vga_configure_sync(int hsync_unit, int vsync_unit, int timer); 66 67 void vga_configure_transfer(int transfer_int_num, uint32_t output); 68 69 void vga_configure_line_channel(int channel, int int_num, enum dma_chain chain, 70 uint32_t output); 71 72 void vga_configure_zero_channel(int channel, int int_num, int initiating, 73 uint32_t output); 74 75 /* Interrupt handlers. */ 76 77 void vga_interrupt_handler(void); 78 79 /* Display state handlers. */ 80 81 void vbp_active(void); 82 void visible_active(void); 83 void vfp_active(void); 84 void vsync_active(void); 85 86 /* Display operations. */ 87 88 void start_visible(void); 89 void update_visible(void); 90 void stop_visible(void); 91 void update_transfers(int enable); 92 93 /* Vertical sync operations. */ 94 95 void vsync_high(void); 96 void vsync_low(void); 97 98 #endif /* __VGA_DISPLAY_H__ */