summaryrefslogtreecommitdiff
path: root/drivers/video/wmt/edid.h
blob: b476a78056740409cd368efaa53cc895624b4797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*++
 * linux/drivers/video/wmt/edid.h
 * WonderMedia video post processor (VPP) driver
 *
 * Copyright c 2014  WonderMedia  Technologies, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * WonderMedia Technologies, Inc.
 * 4F, 533, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C
--*/

#ifndef EDID_H
#define EDID_H

#define EDID_BLOCK_MAX	4

/*------------------------------------------------------------------------------
    Following definitions, please refer spec of EDID. You may refer it on
    http://en.wikipedia.org/wiki/EDID#EDID_1.3_data_format
------------------------------------------------------------------------------*/

#define EDID_LENGTH	0x80

/*------------------------------------------------------------------------------
  Offset 00-19: HEADER INFORMATION
------------------------------------------------------------------------------*/
/*  00¡V07: Header information "00h FFh FFh FFh FFh FFh FFh 00h" */
#define EDID_HEADER	0x00
#define EDID_HEADER_END	0x07

/* 08¡V09: Manufacturer ID. These IDs are assigned by Microsoft.
	"00001=A¡¨; ¡§00010=B¡¨; ... ¡§11010=Z¡¨. Bit 7 (at address 08h) is 0,
	the first character (letter) is located at bits 6 ¡÷ 2
	(at address 08h), the second character (letter) is located at
	bits 1 & 0 (at address 08h) and bits 7 ¡÷ 5 (at address 09h), and the
	third character (letter) is located at bits 4 ¡÷ 0 (at address 09h).
*/
#define ID_MANUFACTURER_NAME		0x08
#define ID_MANUFACTURER_NAME_END	0x09

/*  10¡V11: Product ID Code (stored as LSB first). Assigned by manufacturer */
#define ID_MODEL	0x0a

/*  12¡V15: 32-bit Serial Number. No requirement for the format. Usually
	stored as LSB first. In order to maintain compatibility with previous
	requirements the field should set at least one byte of the field to be
	non-zero if an ASCII serial number descriptor is
	provided in the detailed timing section.
*/
#define ID_SERIAL_NUMBER	0x0c

/* 16: Week of Manufacture. This varies by manufacturer. One way is to count
	January 1-7 as week 1, January 8-15 as week 2 and so on. Some count
	based on the week number (Sunday-Saturday). Valid range is 1-54.
	17: Year of Manufacture. Add 1990 to the value for actual year. */
#define MANUFACTURE_WEEK	0x10
#define MANUFACTURE_YEAR	0x11

/*	18: EDID Version Number. "01h"
	19: EDID Revision Number "03h" */
#define EDID_STRUCT_VERSION	0x12
#define EDID_STRUCT_REVISION	0x13

#define EDID_MAX_HOR_IMAGE_SIZE 0x15
#define EDID_MAX_VER_IMAGE_SIZE 0x16

/*------------------------------------------------------------------------------
  Offset 20-24: BASIC DISPLAY PARAMETERS
------------------------------------------------------------------------------*/
#define DPMS_FLAGS		0x18
#define ESTABLISHED_TIMING_I	0x23
#define ESTABLISHED_TIMING_II	0x24
#define MANUFACTURERS_TIMINGS	0x25

#define STANDARD_TIMING_IDENTIFICATION_START	0x26
#define STANDARD_TIMING_IDENTIFICATION_SIZE	16

#define DETAILED_TIMING_DESCRIPTIONS_START	0x36
#define DETAILED_TIMING_DESCRIPTION_SIZE	18
#define NO_DETAILED_TIMING_DESCRIPTIONS		4

#define DETAILED_TIMING_DESCRIPTION_1		0x36
#define DETAILED_TIMING_DESCRIPTION_2		0x48
#define DETAILED_TIMING_DESCRIPTION_3		0x5a
#define DETAILED_TIMING_DESCRIPTION_4		0x6c

#define EDID_TMR_INTERLACE	BIT(31)
#define EDID_TMR_FREQ		0xFF
struct edid_timing_t {
	unsigned int resx;
	unsigned int resy;
	int freq;	/* EDID_TMR_XXX */
};

struct vic_3d_t {
	char vic;
	unsigned int mask;
};

/* EDID option flag */
#define EDID_OPT_VALID		0x01
#define EDID_OPT_YUV422		0x10
#define EDID_OPT_YUV444		0x20
#define EDID_OPT_AUDIO		0x40
#define EDID_OPT_UNDERSCAN	0x80
#define EDID_OPT_HDMI		0x100
#define EDID_OPT_3D		BIT(9)
#define EDID_OPT_16_9		BIT(10)

struct edid_info_t {
	unsigned int establish_timing;
	struct edid_timing_t standard_timing[8];
	struct fb_videomode detail_timing[4];
	struct fb_videomode cea_timing[6];
	char cea_vic[8];
	struct vic_3d_t vic_3d[16];
	unsigned int pixel_clock_limit;
	unsigned int option;
	unsigned short hdmi_phy_addr;
	int width;
	int height;
};

#define VENDOR_NAME_LEN              4
#define MONITOR_NAME_LEN             20
#define AUD_SAD_NUM                  32
struct sad_t {
	char flag; /* 0: sad available, 1: sad invalid */
	char sad_byte[3];
};

struct tv_name_t{
	char vendor_name[VENDOR_NAME_LEN];
	char monitor_name[MONITOR_NAME_LEN];
};

struct edid_parsed_t {
        struct tv_name_t tv_name;
	struct sad_t sad[AUD_SAD_NUM];
};

extern struct edid_info_t edid_info;
extern int edid_msg_enable;
extern int edid_disable;
extern struct edid_parsed_t edid_parsed;

extern int edid_parse(char *edid, struct edid_info_t *info);
extern int edid_find_support(struct edid_info_t *info, unsigned int resx,
	unsigned int resy, int freq, struct fb_videomode **vmode);
extern void edid_dump(char *edid);
extern int edid_checksum(char *edid, int len);
extern unsigned int edid_get_hdmi_phy_addr(void);
extern unsigned int edid_get_hdmi_3d_mask(struct edid_info_t *info,
	int vic);

#endif