blob: aefe4ef94ab130d00c6486bcd2e81b8b4780f70a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenkeeb1b772004-03-23 22:53:55 +00002/*
3 * (C) Copyright 2004
4 * Pierre Aubert, Staubli Faverges , <p.aubert@staubli.com>
wdenkeeb1b772004-03-23 22:53:55 +00005 */
6
Hans de Goedeb7ce12d2014-12-19 15:47:37 +01007#include <edid.h>
wdenkeeb1b772004-03-23 22:53:55 +00008
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +02009#ifndef CONFIG_SYS_DEFAULT_VIDEO_MODE
10#define CONFIG_SYS_DEFAULT_VIDEO_MODE 0x301
wdenkeeb1b772004-03-23 22:53:55 +000011#endif
12
13/* Some mode definitions */
14#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */
15#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */
16#define FB_SYNC_EXT 4 /* external sync */
17#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */
18#define FB_SYNC_BROADCAST 16 /* broadcast video timings */
19 /* vtotal = 144d/288n/576i => PAL */
20 /* vtotal = 121d/242n/484i => NTSC */
21#define FB_SYNC_ON_GREEN 32 /* sync on green */
22#define FB_VMODE_NONINTERLACED 0 /* non interlaced */
23#define FB_VMODE_INTERLACED 1 /* interlaced */
24#define FB_VMODE_DOUBLE 2 /* double scan */
25#define FB_VMODE_MASK 255
26
27#define FB_VMODE_YWRAP 256 /* ywrap instead of panning */
28#define FB_VMODE_SMOOTH_XPAN 512 /* smooth xpan possible (internally used) */
29#define FB_VMODE_CONUPDATE 512 /* don't update x/yoffset */
30
31
32/******************************************************************
33 * Resolution Struct
34 ******************************************************************/
35struct ctfb_res_modes {
36 int xres; /* visible resolution */
37 int yres;
Hans de Goede0c91d2572014-12-19 10:38:49 +010038 int refresh; /* vertical refresh rate in hz */
wdenkeeb1b772004-03-23 22:53:55 +000039 /* Timing: All values in pixclocks, except pixclock (of course) */
40 int pixclock; /* pixel clock in ps (pico seconds) */
Hans de Goede0c91d2572014-12-19 10:38:49 +010041 int pixclock_khz; /* pixel clock in kHz */
wdenkeeb1b772004-03-23 22:53:55 +000042 int left_margin; /* time from sync to picture */
43 int right_margin; /* time from picture to sync */
44 int upper_margin; /* time from sync to picture */
45 int lower_margin;
46 int hsync_len; /* length of horizontal sync */
47 int vsync_len; /* length of vertical sync */
48 int sync; /* see FB_SYNC_* */
49 int vmode; /* see FB_VMODE_* */
50};
51
52/******************************************************************
53 * Vesa Mode Struct
54 ******************************************************************/
55struct ctfb_vesa_modes {
56 int vesanr; /* Vesa number as in LILO (VESA Nr + 0x200} */
57 int resindex; /* index to resolution struct */
58 int bits_per_pixel; /* bpp */
59};
60
61#define RES_MODE_640x480 0
62#define RES_MODE_800x600 1
63#define RES_MODE_1024x768 2
64#define RES_MODE_960_720 3
65#define RES_MODE_1152x864 4
66#define RES_MODE_1280x1024 5
Hans de Goede59bb6102014-12-19 11:45:19 +010067#define RES_MODE_1280x720 6
68#define RES_MODE_1360x768 7
69#define RES_MODE_1920x1080 8
70#define RES_MODE_1920x1200 9
71#define RES_MODES_COUNT 10
wdenkeeb1b772004-03-23 22:53:55 +000072
73#define VESA_MODES_COUNT 19
74
75extern const struct ctfb_vesa_modes vesa_modes[];
76extern const struct ctfb_res_modes res_mode_init[];
77
78int video_get_params (struct ctfb_res_modes *pPar, char *penv);
Timur Tabia5dbdc82011-03-21 16:38:49 -050079
80int video_get_video_mode(unsigned int *xres, unsigned int *yres,
81 unsigned int *depth, unsigned int *freq, const char **options);
Hans de Goedee976b862014-12-19 13:22:47 +010082
83void video_get_ctfb_res_modes(int default_mode, unsigned int default_depth,
84 const struct ctfb_res_modes **mode_ret,
85 unsigned int *depth_ret,
86 const char **options);
Hans de Goedeeb3c0cf2014-12-19 14:27:46 +010087
88void video_get_option_string(const char *options, const char *name,
89 char *dest, int dest_len, const char *def);
90
91int video_get_option_int(const char *options, const char *name, int def);
Hans de Goedeb7ce12d2014-12-19 15:47:37 +010092
93int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
94 struct ctfb_res_modes *mode);
Giulio Benetti10374da2020-04-08 17:10:11 +020095/**
96 * video_ctfb_mode_to_display_timing() - Convert a ctfb(Cathode Tube Frame
97 * Buffer)_res_modes struct to a
98 * display_timing struct.
99 *
100 * @mode: Input ctfb_res_modes structure pointer to be converted
101 * from
102 * @timing: Output display_timing structure pointer to be converted to
103 */
104void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
105 struct display_timing *timing);