• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef DI_CVT_H
2 #define DI_CVT_H
3 
4 /**
5  * Low-level API for VESA Coordinated Video Timings (CVT) version 2.0.
6  */
7 
8 #include <stdbool.h>
9 #include <stdint.h>
10 
11 enum di_cvt_reduced_blanking_version {
12 	DI_CVT_REDUCED_BLANKING_NONE,
13 	DI_CVT_REDUCED_BLANKING_V1,
14 	DI_CVT_REDUCED_BLANKING_V2,
15 	DI_CVT_REDUCED_BLANKING_V3,
16 };
17 
18 /**
19  * Input parameters, defined in table 3-1.
20  */
21 struct di_cvt_options {
22 	/* Version of the reduced blanking timing formula to be used */
23 	enum di_cvt_reduced_blanking_version red_blank_ver;
24 	/* Desired active (visible) horizontal pixels and vertical lines per
25 	 * frame */
26 	int32_t h_pixels, v_lines;
27 	/* Target vertical refresh rate (in Hz) */
28 	double ip_freq_rqd;
29 	/* Whether to generate a "video-optimized" timing variant (RBv2 only) */
30 	bool video_opt;
31 	/* Desired VBlank time (in µs, RBv3 only, must be greater than 460) */
32 	double vblank;
33 	/* Desired additional number of pixels to add to the base HBlank
34 	 * duration (RBv3 only, must be a multiple of 8 between 0 and 120) */
35 	int32_t additional_hblank;
36 	/* Indicates whether the VSync location is early (RBv3 only) */
37 	bool early_vsync_rqd;
38 	/* Whether interlaced is required (no RB and RBv1 only) */
39 	bool int_rqd;
40 	/* Whether margins are required (no RB and RBv1 only) */
41 	bool margins_rqd;
42 };
43 
44 /**
45  * Output parameters, defined in table 3-4.
46  */
47 struct di_cvt_timing {
48 	/* Pixel clock frequency (in MHz) */
49 	double act_pixel_freq;
50 	/* Total number of active (visible) pixels per line */
51 	double total_active_pixels;
52 	/* Total number of active (visible) vertical lines per frame */
53 	double v_lines_rnd;
54 	/* Number of pixels in the horizontal front porch period */
55 	double h_front_porch;
56 	/* Number of pixels in the HSync period */
57 	double h_sync;
58 	/* Number of pixels in the horizontal back porch period */
59 	double h_back_porch;
60 	/* Number of lines in the vertical front porch period */
61 	double v_front_porch;
62 	/* Number of lines in the VSync period */
63 	double v_sync;
64 	/* Number of lines in the vertical back porch period */
65 	double v_back_porch;
66 	/* Frame rate (in Hz) */
67 	double act_frame_rate;
68 };
69 
70 /**
71  * Compute a timing via the CVT formula.
72  */
73 void
74 di_cvt_compute(struct di_cvt_timing *t, const struct di_cvt_options *options);
75 
76 #endif
77