dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_video.h
Go to the documentation of this file.
1 
17 /*
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful, but
24  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26  * for more details.
27  *
28  * You should have received a copy of the GNU General Public License along
29  * with this program; if not, see <http://www.gnu.org/licenses/>
30  */
31 
32 #ifndef PIOS_VIDEO_H
33 #define PIOS_VIDEO_H
34 
35 #include <pios_stm32.h>
36 #include <pios_spi_priv.h>
37 
38 // PAL/NTSC specific boundary values
40  uint16_t graphics_right;
41  uint16_t graphics_bottom;
42 };
43 
44 // 3D Mode
48 };
49 
54 };
55 
56 
57 #if defined(PIOS_INCLUDE_VIDEO_QUADSPI)
58 #include <stm32f4xx_qspi.h>
59 
60 // PAL/NTSC specific config values
61 struct pios_video_type_cfg {
62  uint16_t graphics_height_real;
63  uint16_t graphics_column_start;
64  uint8_t graphics_line_start;
65  uint8_t dma_buffer_length;
66 };
67 
68 struct pios_video_cfg {
69  QSPI_InitTypeDef qspi_init;
70  DMA_TypeDef *pixel_dma;
71  struct stm32_dma dma;
72  struct stm32_gpio sclk;
73  struct stm32_gpio bk1_io0;
74  struct stm32_gpio bk1_io1;
75  struct stm32_gpio bk1_io2;
76  struct stm32_gpio bk1_io3;
77  const struct pios_exti_cfg *hsync;
78  const struct pios_exti_cfg *vsync;
79  void (* set_bw_levels)(uint8_t, uint8_t);
80  void (* set_x_offset)(int8_t);
81  void (* set_x_scale)(uint8_t);
82  void (* set_3d_config)(enum pios_video_3d_mode, uint8_t);
83 };
84 #else
85 // PAL/NTSC specific config values
91  uint8_t period;
92  uint8_t dc;
93 };
94 
96  DMA_TypeDef *mask_dma;
97  const struct pios_spi_cfg mask;
98  DMA_TypeDef *level_dma;
99  const struct pios_spi_cfg level;
102  TIM_OCInitTypeDef tim_oc_init;
103  const struct pios_exti_cfg *vsync;
104  void (* set_bw_levels)(uint8_t, uint8_t);
105  void (* set_x_scale)(uint8_t);
106  void (* set_3d_config)(enum pios_video_3d_mode, uint8_t);
107 };
108 #endif /* defined(PIOS_VIDEO_QUADSPI) */
109 
110 extern const struct pios_video_cfg pios_video_cfg;
111 
112 extern bool PIOS_Vsync_ISR();
113 extern bool PIOS_Hsync_ISR();
114 
115 extern void PIOS_Video_Init(const struct pios_video_cfg *cfg);
116 extern void PIOS_Pixel_Init(void);
117 extern void PIOS_Video_SetLevels(uint8_t, uint8_t);
118 extern void PIOS_Video_SetXOffset(int8_t);
119 extern void PIOS_Video_SetYOffset(int8_t);
120 extern void PIOS_Video_SetXScale(uint8_t x_scale);
121 extern void PIOS_Video_Set3DConfig(enum pios_video_3d_mode mode, uint8_t right_eye_x_shift);
122 
123 uint16_t PIOS_Video_GetLines(void);
125 
126 // video boundary values
128 #define GRAPHICS_LEFT 0
129 #define GRAPHICS_TOP 0
130 #define GRAPHICS_RIGHT pios_video_type_boundary_act->graphics_right
131 #define GRAPHICS_BOTTOM pios_video_type_boundary_act->graphics_bottom
132 
133 #define GRAPHICS_X_MIDDLE ((GRAPHICS_RIGHT + 1) / 2)
134 #define GRAPHICS_Y_MIDDLE ((GRAPHICS_BOTTOM + 1) / 2)
135 
136 // for autodetect
137 #define VIDEO_TYPE_PAL_ROWS 300
138 
139 // draw area buffer values, for memory allocation, access and calculations we suppose the larger values for PAL, this also works for NTSC
140 #define GRAPHICS_WIDTH_REAL 376 // max columns
141 #define GRAPHICS_HEIGHT_REAL 266 // max lines
142 #if defined(PIOS_VIDEO_SPLITBUFFER)
143 #define BUFFER_WIDTH (GRAPHICS_WIDTH_REAL / 8 + 1) // Bytes plus one byte for SPI, needs to be multiple of 4 for alignment
144 #define BUFFER_HEIGHT (GRAPHICS_HEIGHT_REAL)
145 #else
146 #define BUFFER_WIDTH_TMP (GRAPHICS_WIDTH_REAL / (8 / PIOS_VIDEO_BITS_PER_PIXEL))
147 #define BUFFER_WIDTH (BUFFER_WIDTH_TMP + BUFFER_WIDTH_TMP % 4)
148 #define BUFFER_HEIGHT (GRAPHICS_HEIGHT_REAL)
149 #endif /* PIOS_INCLUDE_VIDEO_SPLITBUFFER */
150 
151 // Macro to swap buffers given a temporary pointer.
152 #define SWAP_BUFFS(tmp, a, b) { tmp = a; a = b; b = tmp; }
153 
154 #endif /* PIOS_VIDEO_H */
pios_video_system
Definition: pios_video.h:50
Types that are specific to the STM32 peripherals.
const struct pios_video_type_boundary * pios_video_type_boundary_act
const struct pios_exti_cfg * vsync
Definition: pios_video.h:103
void PIOS_Video_SetXScale(uint8_t x_scale)
SPI private definitions.
uint8_t graphics_line_start
Definition: pios_video.h:89
void(* set_3d_config)(enum pios_video_3d_mode, uint8_t)
Definition: pios_video.h:106
uint16_t graphics_height_real
Definition: pios_video.h:87
enum pios_video_system PIOS_Video_GetSystem(void)
void(* set_bw_levels)(uint8_t, uint8_t)
Definition: pios_video.h:104
pios_video_3d_mode
Definition: pios_video.h:45
struct pios_tim_channel pixel_timer
Definition: pios_video.h:101
const struct pios_spi_cfg level
Definition: pios_video.h:99
void PIOS_Video_SetYOffset(int8_t)
static struct flyingpicmd_cfg_fa cfg
Definition: main.c:49
void PIOS_Video_Set3DConfig(enum pios_video_3d_mode mode, uint8_t right_eye_x_shift)
TIM_OCInitTypeDef tim_oc_init
Definition: pios_video.h:102
const struct pios_spi_cfg mask
Definition: pios_video.h:97
void PIOS_Video_SetXOffset(int8_t)
void PIOS_Video_Init(const struct pios_video_cfg *cfg)
struct pios_tim_channel hsync_capture
Definition: pios_video.h:100
void(* set_x_scale)(uint8_t)
Definition: pios_video.h:105
bool PIOS_Hsync_ISR()
enum channel_mode mode
Definition: pios_servo.c:58
void PIOS_Pixel_Init(void)
uint16_t PIOS_Video_GetLines(void)
DMA_TypeDef * mask_dma
Definition: pios_video.h:96
void PIOS_Video_SetLevels(uint8_t, uint8_t)
DMA_TypeDef * level_dma
Definition: pios_video.h:98
bool PIOS_Vsync_ISR()
uint16_t graphics_column_start
Definition: pios_video.h:88
uint8_t dma_buffer_length
Definition: pios_video.h:90