Developer World
Spresense SDK Library v3.2.0-ebc0364
videomode.h
1/****************************************************************************
2 * include/nuttx/video/videomode.h
3 * EDID (Extended Display Identification Data) Format
4 *
5 * Copyright (C) 2019 Gregory Nutt. All rights reserved.
6 * Author: Gregory Nutt <gnutt@nuttx.org>
7 *
8 * Some of structures in this file derive from FreeBSD which has a
9 * compatible 2-clause BSD license:
10 *
11 * Copyright (c) 2006 Itronix Inc. All rights reserved.
12 * Written by Garrett D'Amore for Itronix Inc.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
23 * distribution.
24 * 3. Neither the name NuttX nor the names of its contributors may be
25 * used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
35 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
36 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 *
41 ****************************************************************************/
42
43#ifndef __INCLUDE_NUTTX_VIDEO_VIDEOMODE_H
44#define __INCLUDE_NUTTX_VIDEO_VIDEOMODE_H
45
46/****************************************************************************
47 * Included Files
48 ****************************************************************************/
49
50#include <stdint.h>
51#include <stdbool.h>
52
53/****************************************************************************
54 * Pre-processor Definitions
55 ****************************************************************************/
56
57/* Video mode flags used in struct hdmi_videomode_s */
58
59#define VID_PHSYNC (1 << 0)
60#define VID_NHSYNC (1 << 1)
61#define VID_PVSYNC (1 << 2)
62#define VID_NVSYNC (1 << 3)
63#define VID_INTERLACE (1 << 4)
64#define VID_DBLSCAN (1 << 5)
65#define VID_CSYNC (1 << 6)
66#define VID_PCSYNC (1 << 7)
67#define VID_NCSYNC (1 << 8)
68#define VID_HSKEW (1 << 9)
69#define VID_BCAST (1 << 10)
70#define VID_PIXMUX (1 << 12)
71#define VID_DBLCLK (1 << 13)
72#define VID_CLKDIV2 (1 << 14)
73
74/****************************************************************************
75 * Pre-processor Definitions
76 ****************************************************************************/
77
78/* This structure represents one video mode extracted from the EDID.
79 * CAREFUL: Fields may not change without also modification to initializer
80 * in videomode_lookup.c.
81 */
82
84{
85 uint32_t dotclock; /* Dot clock frequency in kHz. */
86 uint16_t hdisplay;
87 uint16_t hsync_start;
88 uint16_t hsync_end;
89 uint16_t htotal;
90 uint16_t vdisplay;
91 uint16_t vsync_start;
92 uint16_t vsync_end;
93 uint16_t vtotal;
94 uint16_t hskew;
95 uint16_t flags; /* Video mode flags; see above. */
96 FAR const char *name;
97};
98
99/****************************************************************************
100 * Public Function Prototypes
101 ****************************************************************************/
102
103/****************************************************************************
104 * Name: sort_videomodes
105 *
106 * Description:
107 * Sort video modes by refresh rate, aspect ratio, then resolution.
108 * Preferred mode or largest mode is first in the list and other modes
109 * are sorted on closest match to that mode.
110 *
111 * Note that the aspect ratio calculation treats "close" aspect ratios
112 * (within 12.5%) as the same for this purpose.
113 *
114 * Input Parameters:
115 * modes - A reference to the first entry in a list of video modes
116 * preferred - A pointer to the pointer to the preferred mode in the list
117 * nmodes - The number of modes in the list
118 *
119 * Returned Value:
120 * None
121 *
122 ****************************************************************************/
123
124void sort_videomodes(FAR struct videomode_s *modes,
125 FAR struct videomode_s **preferred,
126 unsigned int nmodes);
127
128/****************************************************************************
129 * Name: videomode_lookup
130 *
131 * Description:
132 * Find the video mode in a look-up table
133 *
134 ****************************************************************************/
135
136FAR const struct videomode_s *videomode_lookup_by_name(FAR const char *name);
137
138/****************************************************************************
139 * Name: videomode_lookup_by_dotclock
140 *
141 * Description:
142 * Find the video mode in a look-up table with the matching width and
143 * height and the closest dot clock that does not exceed the requested
144 * dot clock.
145 *
146 ****************************************************************************/
147
148#if 0 /* Not used */
149FAR const struct videomode_s *
150 videomode_lookup_by_dotclock(uint16_t width, uint16_t height,
151 uint32_t dotclock);
152#endif
153
154/****************************************************************************
155 * Name: videomode_lookup_by_refresh
156 *
157 * Description:
158 * Find the video mode in a look-up table with the matching width and
159 * height and the closest refresh rate that does not exceed the requested
160 * rate.
161 *
162 ****************************************************************************/
163
164#if 0 /* Not used */
165FAR const struct videomode_s *
166 videomode_lookup_by_refresh(uint16_t width, uint16_t height,
167 uint16_t refresh);
168#endif
169
170/****************************************************************************
171 * Name: videomode_dump
172 *
173 * Description:
174 * Dump the content of a video mode one one line to the SYSLOG.
175 *
176 * Input Parameters:
177 * prefix - A string to print at the beginning of the line. May be
178 * NULL
179 * videomode - The videomode to be dumped
180 * terse - True: Print only a minimal amount of data, sufficient to
181 * identify the video mode.
182 *
183 * Returned Value:
184 * None
185 *
186 ****************************************************************************/
187
188void videomode_dump(FAR const char *prefix,
189 FAR const struct videomode_s *videomode, bool terse);
190
191#endif /* __INCLUDE_NUTTX_VIDEO_VIDEOMODE_H */
Definition: videomode.h:84