Hans Verkuil | b18787e | 2013-07-29 08:40:55 -0300 | [diff] [blame] | 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 | |
Hans Verkuil | d1c65ad | 2013-08-19 10:19:54 -0300 | [diff] [blame^] | 26 | /** v4l2_dv_timings_presets: list of all dv_timings presets. |
| 27 | */ |
| 28 | extern const struct v4l2_dv_timings v4l2_dv_timings_presets[]; |
| 29 | |
Hans Verkuil | b18787e | 2013-07-29 08:40:55 -0300 | [diff] [blame] | 30 | /** v4l2_dv_valid_timings() - are these timings valid? |
| 31 | * @t: the v4l2_dv_timings struct. |
| 32 | * @cap: the v4l2_dv_timings_cap capabilities. |
| 33 | * |
| 34 | * Returns true if the given dv_timings struct is supported by the |
| 35 | * hardware capabilities, returns false otherwise. |
| 36 | */ |
| 37 | bool v4l2_dv_valid_timings(const struct v4l2_dv_timings *t, |
| 38 | const struct v4l2_dv_timings_cap *cap); |
| 39 | |
| 40 | /** v4l2_enum_dv_timings_cap() - Helper function to enumerate possible DV timings based on capabilities |
| 41 | * @t: the v4l2_enum_dv_timings struct. |
| 42 | * @cap: the v4l2_dv_timings_cap capabilities. |
| 43 | * |
| 44 | * This enumerates dv_timings using the full list of possible CEA-861 and DMT |
| 45 | * timings, filtering out any timings that are not supported based on the |
| 46 | * hardware capabilities. |
| 47 | * |
| 48 | * If a valid timing for the given index is found, it will fill in @t and |
| 49 | * return 0, otherwise it returns -EINVAL. |
| 50 | */ |
| 51 | int v4l2_enum_dv_timings_cap(struct v4l2_enum_dv_timings *t, |
| 52 | const struct v4l2_dv_timings_cap *cap); |
| 53 | |
| 54 | /** v4l2_find_dv_timings_cap() - Find the closest timings struct |
| 55 | * @t: the v4l2_enum_dv_timings struct. |
| 56 | * @cap: the v4l2_dv_timings_cap capabilities. |
| 57 | * @pclock_delta: maximum delta between t->pixelclock and the timing struct |
| 58 | * under consideration. |
| 59 | * |
| 60 | * This function tries to map the given timings to an entry in the |
| 61 | * full list of possible CEA-861 and DMT timings, filtering out any timings |
| 62 | * that are not supported based on the hardware capabilities. |
| 63 | * |
| 64 | * On success it will fill in @t with the found timings and it returns true. |
| 65 | * On failure it will return false. |
| 66 | */ |
| 67 | bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t, |
| 68 | const struct v4l2_dv_timings_cap *cap, |
| 69 | unsigned pclock_delta); |
| 70 | |
Hans Verkuil | ef1ed8f | 2013-08-15 08:28:47 -0300 | [diff] [blame] | 71 | /** v4l2_match_dv_timings() - do two timings match? |
Hans Verkuil | 2576415 | 2013-07-29 08:40:56 -0300 | [diff] [blame] | 72 | * @measured: the measured timings data. |
| 73 | * @standard: the timings according to the standard. |
| 74 | * @pclock_delta: maximum delta in Hz between standard->pixelclock and |
| 75 | * the measured timings. |
| 76 | * |
| 77 | * Returns true if the two timings match, returns false otherwise. |
| 78 | */ |
Hans Verkuil | ef1ed8f | 2013-08-15 08:28:47 -0300 | [diff] [blame] | 79 | bool v4l2_match_dv_timings(const struct v4l2_dv_timings *measured, |
| 80 | const struct v4l2_dv_timings *standard, |
| 81 | unsigned pclock_delta); |
Hans Verkuil | 2576415 | 2013-07-29 08:40:56 -0300 | [diff] [blame] | 82 | |
Hans Verkuil | 0216dc2 | 2013-08-15 08:02:40 -0300 | [diff] [blame] | 83 | /** v4l2_print_dv_timings() - log the contents of a dv_timings struct |
| 84 | * @dev_prefix:device prefix for each log line. |
| 85 | * @prefix: additional prefix for each log line, may be NULL. |
| 86 | * @t: the timings data. |
| 87 | * @detailed: if true, give a detailed log. |
| 88 | */ |
| 89 | void v4l2_print_dv_timings(const char *dev_prefix, const char *prefix, |
| 90 | const struct v4l2_dv_timings *t, bool detailed); |
| 91 | |
Hans Verkuil | 2576415 | 2013-07-29 08:40:56 -0300 | [diff] [blame] | 92 | /** v4l2_detect_cvt - detect if the given timings follow the CVT standard |
| 93 | * @frame_height - the total height of the frame (including blanking) in lines. |
| 94 | * @hfreq - the horizontal frequency in Hz. |
| 95 | * @vsync - the height of the vertical sync in lines. |
| 96 | * @polarities - the horizontal and vertical polarities (same as struct |
| 97 | * v4l2_bt_timings polarities). |
| 98 | * @fmt - the resulting timings. |
| 99 | * |
| 100 | * This function will attempt to detect if the given values correspond to a |
| 101 | * valid CVT format. If so, then it will return true, and fmt will be filled |
| 102 | * in with the found CVT timings. |
| 103 | */ |
| 104 | bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync, |
| 105 | u32 polarities, struct v4l2_dv_timings *fmt); |
| 106 | |
| 107 | /** v4l2_detect_gtf - detect if the given timings follow the GTF standard |
| 108 | * @frame_height - the total height of the frame (including blanking) in lines. |
| 109 | * @hfreq - the horizontal frequency in Hz. |
| 110 | * @vsync - the height of the vertical sync in lines. |
| 111 | * @polarities - the horizontal and vertical polarities (same as struct |
| 112 | * v4l2_bt_timings polarities). |
| 113 | * @aspect - preferred aspect ratio. GTF has no method of determining the |
| 114 | * aspect ratio in order to derive the image width from the |
| 115 | * image height, so it has to be passed explicitly. Usually |
| 116 | * the native screen aspect ratio is used for this. If it |
| 117 | * is not filled in correctly, then 16:9 will be assumed. |
| 118 | * @fmt - the resulting timings. |
| 119 | * |
| 120 | * This function will attempt to detect if the given values correspond to a |
| 121 | * valid GTF format. If so, then it will return true, and fmt will be filled |
| 122 | * in with the found GTF timings. |
| 123 | */ |
| 124 | bool v4l2_detect_gtf(unsigned frame_height, unsigned hfreq, unsigned vsync, |
| 125 | u32 polarities, struct v4l2_fract aspect, |
| 126 | struct v4l2_dv_timings *fmt); |
| 127 | |
| 128 | /** v4l2_calc_aspect_ratio - calculate the aspect ratio based on bytes |
| 129 | * 0x15 and 0x16 from the EDID. |
| 130 | * @hor_landscape - byte 0x15 from the EDID. |
| 131 | * @vert_portrait - byte 0x16 from the EDID. |
| 132 | * |
| 133 | * Determines the aspect ratio from the EDID. |
| 134 | * See VESA Enhanced EDID standard, release A, rev 2, section 3.6.2: |
| 135 | * "Horizontal and Vertical Screen Size or Aspect Ratio" |
| 136 | */ |
| 137 | struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait); |
| 138 | |
Hans Verkuil | b18787e | 2013-07-29 08:40:55 -0300 | [diff] [blame] | 139 | #endif |