• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef DI_GTF_H
2 #define DI_GTF_H
3 
4 #include <stdbool.h>
5 
6 /**
7  * Low-level API for Generalized Timing Formula Standard version 1.1.
8  */
9 
10 /**
11  * Type of frequency parameter used in di_gtf_options.ip_freq_rqd.
12  */
13 enum di_gtf_ip_param {
14 	/* Vertical frame frequency (Hz) */
15 	DI_GTF_IP_PARAM_V_FRAME_RATE,
16 	/* Horizontal frequency (kHz) */
17 	DI_GTF_IP_PARAM_H_FREQ,
18 	/* Pixel clock rate (MHz) */
19 	DI_GTF_IP_PARAM_H_PIXELS,
20 };
21 
22 /**
23  * Input options for GTF.
24  */
25 struct di_gtf_options {
26 	/* Number of active image pixels displayed on a line, not including any
27 	 * margin */
28 	int h_pixels;
29 	/* Number of vertical lines in the displayed image */
30 	int v_lines;
31 	/* Whether margins are required */
32 	bool margins_rqd;
33 	/* Indicates which frequency parameter is specified in ip_freq_rqd */
34 	enum di_gtf_ip_param ip_param;
35 	/* Vertical frame frequency (in Hz), horizontal frequency (in kHz) or
36 	 * pixel clock rate (in MHz) */
37 	double ip_freq_rqd;
38 	/* Whether interlaced is required */
39 	bool int_rqd;
40 	/* Blanking formula gradient */
41 	double m;
42 	/* Blanking formula offset */
43 	double c;
44 	/* Blanking formula scaling factor */
45 	double k;
46 	/* Blanking formula scaling factor weighting */
47 	double j;
48 };
49 
50 #define DI_GTF_DEFAULT_M 600.0
51 #define DI_GTF_DEFAULT_C 40.0
52 #define DI_GTF_DEFAULT_K 128.0
53 #define DI_GTF_DEFAULT_J 20.0
54 
55 /**
56  * Output timing data for GTF.
57  */
58 struct di_gtf_timing {
59 	int h_pixels, v_lines;
60 	int h_sync, v_sync;
61 	int h_front_porch, h_back_porch;
62 	int v_front_porch, v_back_porch;
63 	int h_border, v_border;
64 	double pixel_freq_mhz; /* in mega-hertz */
65 };
66 
67 /**
68  * Compute a timing via the GTF formula.
69  */
70 void di_gtf_compute(struct di_gtf_timing *t, const struct di_gtf_options *options);
71 
72 #endif
73