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