]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/avbuf_v2_1/src/xavbuf.h
Update Zynq, MPSoc Cortex-A53 and MPSoc Cortex-R5 demo projects to build with the...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / avbuf_v2_1 / src / xavbuf.h
1 /*******************************************************************************
2  *
3  * Copyright (C) 2017 Xilinx, Inc.  All rights reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * Use of the Software is limited solely to applications:
16  * (a) running on a Xilinx device, or
17  * (b) that interact with a Xilinx device through a bus or interconnect.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22  * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  * SOFTWARE.
26  *
27  * Except as contained in this notice, the name of the Xilinx shall not be used
28  * in advertising or otherwise to promote the sale, use or other dealings in
29  * this Software without prior written authorization from Xilinx.
30  *
31 *******************************************************************************/
32 /******************************************************************************/
33 /**
34  *
35  * @file xavbuf.h
36  *
37  * This file implements all the functions related to the Video Pipeline of the
38  * DisplayPort Subsystem.
39  *
40  * Features supported by this driver
41  *      - Live Video and Graphics input.
42  *      - Non-Live Video Graphics input.
43  *      - Output Formats Supported - RGB, YUV444, YUV4222.
44  *
45  *
46  * <pre>
47  * MODIFICATION HISTORY:
48  *
49  * Ver   Who  Date     Changes
50  * ----- ---- -------- -----------------------------------------------
51  * 1.0   aad  06/24/17 Initial release.
52  * 2.0   aad  10/07/17 Added Enums for Video and Audio sources.
53  * </pre>
54  *
55 *******************************************************************************/
56 #ifndef XAVBUF_H_
57 /* Prevent circular inclusions by using protection macros. */
58 #define XAVBUF_H_
59
60
61 /******************************* Include Files ********************************/
62 #include "xavbuf_hw.h"
63 #include "sleep.h"
64 /****************************** Type Definitions ******************************/
65 /**
66  * This typedef describes all the Video Formats supported by the driver
67  */
68 typedef enum {
69         //Non-Live Video Formats
70         CbY0CrY1,
71         CrY0CbY1,
72         Y0CrY1Cb,
73         Y0CbY1Cr,
74         YV16,
75         YV24,
76         YV16Ci,
77         MONOCHROME,
78         YV16Ci2,
79         YUV444,
80         RGB888,
81         RGBA8880,
82         RGB888_10BPC,
83         YUV444_10BPC,
84         YV16Ci2_10BPC,
85         YV16Ci_10BPC,
86         YV16_10BPC,
87         YV24_10BPC,
88         MONOCHROME_10BPC,
89         YV16_420,
90         YV16Ci_420,
91         YV16Ci2_420,
92         YV16_420_10BPC,
93         YV16Ci_420_10BPC,
94         YV16Ci2_420_10BPC,
95
96         // Non-Live Graphics formats
97         RGBA8888,
98         ABGR8888,
99         RGB888_GFX,
100         BGR888,
101         RGBA5551,
102         RGBA4444,
103         RGB565,
104         BPP8,
105         BPP4,
106         BPP2,
107         BPP1,
108         YUV422,
109         YOnly,
110
111         //Live Input/Output Video/Graphics Formats
112         RGB_6BPC,
113         RGB_8BPC,
114         RGB_10BPC,
115         RGB_12BPC,
116         YCbCr444_6BPC,
117         YCbCr444_8BPC,
118         YCbCr444_10BPC,
119         YCbCr444_12BPC,
120         YCbCr422_8BPC,
121         YCbCr422_10BPC,
122         YCbCr422_12BPC,
123         YOnly_8BPC,
124         YOnly_10BPC,
125         YOnly_12BPC,
126 } XAVBuf_VideoFormat;
127
128 /**
129  * This data structure describes video planes.
130  */
131 typedef enum {
132         Interleaved,
133         SemiPlanar,
134         Planar
135 } XAVBuf_VideoModes;
136
137 /**
138  * This typedef describes the video source list
139  */
140 typedef enum {
141         XAVBUF_VIDSTREAM1_LIVE,
142         XAVBUF_VIDSTREAM1_NONLIVE,
143         XAVBUF_VIDSTREAM1_TPG,
144         XAVBUF_VIDSTREAM1_NONE,
145 } XAVBuf_VideoStream;
146
147 /**
148  * This typedef describes the graphics source list
149  */
150 typedef enum {
151         XAVBUF_VIDSTREAM2_DISABLEGFX = 0x0,
152         XAVBUF_VIDSTREAM2_NONLIVE_GFX = 0x4,
153         XAVBUF_VIDSTREAM2_LIVE_GFX = 0x8,
154         XAVBUF_VIDSTREAM2_NONE = 0xC0,
155 } XAVBuf_GfxStream;
156
157 /**
158  * This typedef describes the audio stream 1 source list
159  */
160 typedef enum {
161         XAVBUF_AUDSTREAM1_LIVE = 0x00,
162         XAVBUF_AUDSTREAM1_NONLIVE = 0x10,
163         XAVBUF_AUDSTREAM1_TPG = 0x20,
164         XAVBUF_AUDSTREAM1_NO_AUDIO = 0x30,
165 } XAVBuf_AudioStream1;
166
167 /**
168  * This typedef describes the audio stream 2 source list
169  */
170 typedef enum {
171         XAVBUF_AUDSTREAM2_NO_AUDIO = 0X00,
172         XAVBUF_AUDSTREAM2_AUDIOGFX = 0X40,
173 } XAVBuf_AudioStream2;
174
175 /**
176  * This typedef describes the attributes associated with the video formats.
177  */
178 typedef struct {
179         XAVBuf_VideoFormat VideoFormat;
180         u8 Value;
181         XAVBuf_VideoModes Mode;
182         u32 SF[3];
183         u8 SamplingEn;
184         u8 IsRGB;
185         u8 Swap;
186         u8 BPP;
187 } XAVBuf_VideoAttribute;
188
189 /**
190  * This typedef stores the attributes of an audio stream
191  */
192 typedef struct {
193         u32 Volume;
194         u8 SwapLR;
195 } XAVBuf_AudioAttribute;
196
197 /**
198  * This typedef stores the data associated with the Audio Video input modes.
199  */
200 typedef struct {
201         XAVBuf_VideoAttribute *NonLiveVideo, *NonLiveGraphics;
202         XAVBuf_VideoAttribute *LiveVideo, *LiveGraphics;
203         XAVBuf_AudioAttribute *Audio, *GraphicsAudio;
204         XAVBuf_VideoStream VideoSrc;
205         XAVBuf_GfxStream GraphicsSrc;
206         XAVBuf_AudioStream1 AudioSrc1;
207         XAVBuf_AudioStream2 AudioSrc2;
208         u8 AudioClk, VideoClk;
209 } XAVBuf_AVModes;
210
211 /**
212  * This structure stores the background color information.
213  */
214 typedef struct {
215         u16 RCr;
216         u16 GY;
217         u16 BCb;
218 } XAVBuf_BlenderBgClr;
219
220 /**
221  * This typedef stores the AVBuf Configuration information.
222  */
223 typedef struct {
224         u16 DeviceId;
225         u32 BaseAddr;
226 } XAVBuf_Config;
227
228 /**
229  * This typedef stores all the attributes associated to the Blender block of the
230  * DisplayPort Subsystem
231  */
232 typedef struct {
233         u8 GlobalAlphaEn;
234         u8 Alpha;
235         XAVBuf_VideoAttribute *OutputVideo;
236 } XAVBuf_Blender;
237
238 /**
239  * The XAVBuf driver instance data. The user is required to allocate a variable
240  * of this type for every XAVBUF instance in the system. A pointer to this type
241  * is then passed to the driver API functions
242  */
243 typedef struct {
244         XAVBuf_Config Config;
245         XAVBuf_AVModes AVMode;
246         XAVBuf_Blender Blender;
247 } XAVBuf;
248
249
250 /**************************** Function Prototypes *****************************/
251
252 /* xavbuf.c: Setup and initialization functions. */
253 void XAVBuf_CfgInitialize(XAVBuf *InstancePtr, u32 BaseAddr, u16 DeviceId);
254
255 /* xavbuf.c: Functions to setup the Input Video and Audio sources */
256 void XAVBuf_InputVideoSelect(XAVBuf *InstancePtr, XAVBuf_VideoStream VidStream,
257                               XAVBuf_GfxStream GfxStream);
258 void XAVBuf_InputAudioSelect(XAVBuf *InstancePtr, XAVBuf_AudioStream1 AudStream,
259                                 XAVBuf_AudioStream2 AudioStream2);
260
261 /* xavbuf.c: Functions to setup the Video Format attributes */
262 int XAVBuf_SetInputNonLiveVideoFormat(XAVBuf *InstancePtr,
263                                        XAVBuf_VideoFormat Format);
264 int XAVBuf_SetInputNonLiveGraphicsFormat(XAVBuf *InstancePtr,
265                                        XAVBuf_VideoFormat Format);
266 int XAVBuf_SetInputLiveVideoFormat(XAVBuf *InstancePtr,
267                                        XAVBuf_VideoFormat Format);
268 int XAVBuf_SetInputLiveGraphicsFormat(XAVBuf *InstancePtr,
269                                        XAVBuf_VideoFormat Format);
270 int XAVBuf_SetOutputVideoFormat(XAVBuf *InstancePtr, XAVBuf_VideoFormat Format);
271 XAVBuf_VideoAttribute *XAVBuf_GetLiveVideoAttribute(XAVBuf_VideoFormat Format);
272 XAVBuf_VideoAttribute *XAVBuf_GetNLiveVideoAttribute(XAVBuf_VideoFormat Format);
273 XAVBuf_VideoAttribute *XAVBuf_GetNLGraphicsAttribute(XAVBuf_VideoFormat Format);
274
275 /* xavbuf.c: Functions to setup the clock sources for video and audio */
276 void XAVBuf_SetAudioVideoClkSrc(XAVBuf *InstancePtr, u8 VideoClk, u8 AudioClk);
277
278 /* xavbuf.c: Functions that setup Video and Graphics pipeline depending on the
279  * sources and format selected.
280  */
281 void XAVBuf_ConfigureVideoPipeline(XAVBuf *InstancePtr);
282 void XAVBuf_ConfigureGraphicsPipeline(XAVBuf *InstancePtr);
283
284 /* Functions to setup Blender Properties */
285 void XAVBuf_BlendSetBgColor(XAVBuf *InstancePtr, XAVBuf_BlenderBgClr *Color);
286 void XAVBuf_SetBlenderAlpha(XAVBuf *InstancePtr, u8 Alpha, u8 Enable);
287 void XAVBuf_SoftReset(XAVBuf *InstancePtr);
288 void XABuf_LineResetDisable(XAVBuf *InstancePtr, u8 Disable);
289 void XAVBuf_ConfigureOutputVideo(XAVBuf *InstancePtr);
290
291 /* Audio Configuration functions */
292 void XAVBuf_AudioSoftReset(XAVBuf *InstancePtr);
293 void XAVBuf_AudioMixerVolumeControl(XAVBuf *InstancePtr, u8 Channel0Volume,
294                                         u8 Channel1Volume);
295
296 /* DPDMA Interface functions */
297 void XAVBuf_EnableGraphicsBuffers(XAVBuf *InstancePtr, u8 Enable);
298 void XAVBuf_EnableVideoBuffers(XAVBuf *InstancePtr, u8 Enable);
299 void XAVBuf_EnableAudio0Buffers(XAVBuf *InstancePtr, u8 Enable);
300 void XAVBuf_EnableAudio1Buffers(XAVBuf *InstancePtr, u8 Enable);
301
302 #endif //XAVBUF_H_