[media] v4l2: move dv-timings related code to v4l2-dv-timings.c
[deliverable/linux.git] / include / media / v4l2-dv-timings.h
1 /*
2 * v4l2-dv-timings - Internal header with dv-timings helper functions
3 *
4 * Copyright 2013 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
5 *
6 * This program is free software; you may redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
11 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
14 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
15 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 * SOFTWARE.
18 *
19 */
20
21 #ifndef __V4L2_DV_TIMINGS_H
22 #define __V4L2_DV_TIMINGS_H
23
24 #include <linux/videodev2.h>
25
26 /** v4l2_dv_valid_timings() - are these timings valid?
27 * @t: the v4l2_dv_timings struct.
28 * @cap: the v4l2_dv_timings_cap capabilities.
29 *
30 * Returns true if the given dv_timings struct is supported by the
31 * hardware capabilities, returns false otherwise.
32 */
33 bool v4l2_dv_valid_timings(const struct v4l2_dv_timings *t,
34 const struct v4l2_dv_timings_cap *cap);
35
36 /** v4l2_enum_dv_timings_cap() - Helper function to enumerate possible DV timings based on capabilities
37 * @t: the v4l2_enum_dv_timings struct.
38 * @cap: the v4l2_dv_timings_cap capabilities.
39 *
40 * This enumerates dv_timings using the full list of possible CEA-861 and DMT
41 * timings, filtering out any timings that are not supported based on the
42 * hardware capabilities.
43 *
44 * If a valid timing for the given index is found, it will fill in @t and
45 * return 0, otherwise it returns -EINVAL.
46 */
47 int v4l2_enum_dv_timings_cap(struct v4l2_enum_dv_timings *t,
48 const struct v4l2_dv_timings_cap *cap);
49
50 /** v4l2_find_dv_timings_cap() - Find the closest timings struct
51 * @t: the v4l2_enum_dv_timings struct.
52 * @cap: the v4l2_dv_timings_cap capabilities.
53 * @pclock_delta: maximum delta between t->pixelclock and the timing struct
54 * under consideration.
55 *
56 * This function tries to map the given timings to an entry in the
57 * full list of possible CEA-861 and DMT timings, filtering out any timings
58 * that are not supported based on the hardware capabilities.
59 *
60 * On success it will fill in @t with the found timings and it returns true.
61 * On failure it will return false.
62 */
63 bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
64 const struct v4l2_dv_timings_cap *cap,
65 unsigned pclock_delta);
66
67 /** v4l_match_dv_timings() - do two timings match?
68 * @measured: the measured timings data.
69 * @standard: the timings according to the standard.
70 * @pclock_delta: maximum delta in Hz between standard->pixelclock and
71 * the measured timings.
72 *
73 * Returns true if the two timings match, returns false otherwise.
74 */
75 bool v4l_match_dv_timings(const struct v4l2_dv_timings *measured,
76 const struct v4l2_dv_timings *standard,
77 unsigned pclock_delta);
78
79 /** v4l2_detect_cvt - detect if the given timings follow the CVT standard
80 * @frame_height - the total height of the frame (including blanking) in lines.
81 * @hfreq - the horizontal frequency in Hz.
82 * @vsync - the height of the vertical sync in lines.
83 * @polarities - the horizontal and vertical polarities (same as struct
84 * v4l2_bt_timings polarities).
85 * @fmt - the resulting timings.
86 *
87 * This function will attempt to detect if the given values correspond to a
88 * valid CVT format. If so, then it will return true, and fmt will be filled
89 * in with the found CVT timings.
90 */
91 bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,
92 u32 polarities, struct v4l2_dv_timings *fmt);
93
94 /** v4l2_detect_gtf - detect if the given timings follow the GTF standard
95 * @frame_height - the total height of the frame (including blanking) in lines.
96 * @hfreq - the horizontal frequency in Hz.
97 * @vsync - the height of the vertical sync in lines.
98 * @polarities - the horizontal and vertical polarities (same as struct
99 * v4l2_bt_timings polarities).
100 * @aspect - preferred aspect ratio. GTF has no method of determining the
101 * aspect ratio in order to derive the image width from the
102 * image height, so it has to be passed explicitly. Usually
103 * the native screen aspect ratio is used for this. If it
104 * is not filled in correctly, then 16:9 will be assumed.
105 * @fmt - the resulting timings.
106 *
107 * This function will attempt to detect if the given values correspond to a
108 * valid GTF format. If so, then it will return true, and fmt will be filled
109 * in with the found GTF timings.
110 */
111 bool v4l2_detect_gtf(unsigned frame_height, unsigned hfreq, unsigned vsync,
112 u32 polarities, struct v4l2_fract aspect,
113 struct v4l2_dv_timings *fmt);
114
115 /** v4l2_calc_aspect_ratio - calculate the aspect ratio based on bytes
116 * 0x15 and 0x16 from the EDID.
117 * @hor_landscape - byte 0x15 from the EDID.
118 * @vert_portrait - byte 0x16 from the EDID.
119 *
120 * Determines the aspect ratio from the EDID.
121 * See VESA Enhanced EDID standard, release A, rev 2, section 3.6.2:
122 * "Horizontal and Vertical Screen Size or Aspect Ratio"
123 */
124 struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait);
125
126 #endif
This page took 0.032702 seconds and 5 git commands to generate.