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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/*
* Copyright 2007 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* Author: Soren Sandmann <sandmann@redhat.com> */
#include <config.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "edid.h"
typedef struct Vendor Vendor;
struct Vendor {
const char vendor_id[4];
const char vendor_name[28];
};
/* This list of vendor codes derived from lshw
*
* http://ezix.org/project/wiki/HardwareLiSter
*
* Note: we now prefer to use data coming from hwdata (and shipped with
* mate-desktop). See
* http://git.fedorahosted.org/git/?p=hwdata.git;a=blob_plain;f=pnp.ids;hb=HEAD
* All contributions to the list of vendors should go there.
*/
static const struct Vendor vendors[] = {
{"AIC", "AG Neovo"},
{"ACR", "Acer"},
{"DEL", "DELL"},
{"SAM", "SAMSUNG"},
{"SNY", "SONY"},
{"SEC", "Epson"},
{"WAC", "Wacom"},
{"NEC", "NEC"},
{"CMO", "CMO"}, /* Chi Mei */
{"BNQ", "BenQ"},
{"ABP", "Advansys"},
{"ACC", "Accton"},
{"ACE", "Accton"},
{"ADP", "Adaptec"},
{"ADV", "AMD"},
{"AIR", "AIR"},
{"AMI", "AMI"},
{"ASU", "ASUS"},
{"ATI", "ATI"},
{"ATK", "Allied Telesyn"},
{"AZT", "Aztech"},
{"BAN", "Banya"},
{"BRI", "Boca Research"},
{"BUS", "Buslogic"},
{"CCI", "Cache Computers Inc."},
{"CHA", "Chase"},
{"CMD", "CMD Technology, Inc."},
{"COG", "Cogent"},
{"CPQ", "Compaq"},
{"CRS", "Crescendo"},
{"CSC", "Crystal"},
{"CSI", "CSI"},
{"CTL", "Creative Labs"},
{"DBI", "Digi"},
{"DEC", "Digital Equipment"},
{"DBK", "Databook"},
{"EGL", "Eagle Technology"},
{"ELS", "ELSA"},
{"ESS", "ESS"},
{"FAR", "Farallon"},
{"FDC", "Future Domain"},
{"HWP", "Hewlett-Packard"},
{"IBM", "IBM"},
{"INT", "Intel"},
{"ISA", "Iomega"},
{"LEN", "Lenovo"},
{"MDG", "Madge"},
{"MDY", "Microdyne"},
{"MET", "Metheus"},
{"MIC", "Micronics"},
{"MLX", "Mylex"},
{"NVL", "Novell"},
{"OLC", "Olicom"},
{"PRO", "Proteon"},
{"RII", "Racal"},
{"RTL", "Realtek"},
{"SCM", "SCM"},
{"SKD", "SysKonnect"},
{"SGI", "SGI"},
{"SMC", "SMC"},
{"SNI", "Siemens Nixdorf"},
{"STL", "Stallion Technologies"},
{"SUN", "Sun"},
{"SUP", "SupraExpress"},
{"SVE", "SVEC"},
{"TCC", "Thomas-Conrad"},
{"TCI", "Tulip"},
{"TCM", "3Com"},
{"TCO", "Thomas-Conrad"},
{"TEC", "Tecmar"},
{"TRU", "Truevision"},
{"TOS", "Toshiba"},
{"TYN", "Tyan"},
{"UBI", "Ungermann-Bass"},
{"USC", "UltraStor"},
{"VDM", "Vadem"},
{"VMI", "Vermont"},
{"WDC", "Western Digital"},
{"ZDS", "Zeos"},
/* From http://faydoc.tripod.com/structures/01/0136.htm */
{"ACT", "Targa"},
{"ADI", "ADI"},
{"AOC", "AOC Intl"},
{"API", "Acer America"},
{"APP", "Apple Computer"},
{"ART", "ArtMedia"},
{"AST", "AST Research"},
{"CPL", "Compal"},
{"CTX", "Chuntex Electronic Co."},
{"DPC", "Delta Electronics"},
{"DWE", "Daewoo"},
{"ECS", "ELITEGROUP"},
{"EIZ", "EIZO"},
{"FCM", "Funai"},
{"GSM", "LG Electronics"},
{"GWY", "Gateway 2000"},
{"HEI", "Hyundai"},
{"HIT", "Hitachi"},
{"HSL", "Hansol"},
{"HTC", "Hitachi"},
{"ICL", "Fujitsu ICL"},
{"IVM", "Idek Iiyama"},
{"KFC", "KFC Computek"},
{"LKM", "ADLAS"},
{"LNK", "LINK Tech"},
{"LTN", "Lite-On"},
{"MAG", "MAG InnoVision"},
{"MAX", "Maxdata"},
{"MEI", "Panasonic"},
{"MEL", "Mitsubishi"},
{"MIR", "miro"},
{"MTC", "MITAC"},
{"NAN", "NANAO"},
{"NEC", "NEC Tech"},
{"NOK", "Nokia"},
{"OQI", "OPTIQUEST"},
{"PBN", "Packard Bell"},
{"PGS", "Princeton"},
{"PHL", "Philips"},
{"REL", "Relisys"},
{"SDI", "Samtron"},
{"SMI", "Smile"},
{"SPT", "Sceptre"},
{"SRC", "Shamrock Technology"},
{"STP", "Sceptre"},
{"TAT", "Tatung"},
{"TRL", "Royal Information Company"},
{"TSB", "Toshiba, Inc."},
{"UNM", "Unisys"},
{"VSC", "ViewSonic"},
{"WTC", "Wen Tech"},
{"ZCM", "Zenith Data Systems"},
{"???", "Unknown"},
};
static GHashTable* pnp_ids = NULL;
static void read_pnp_ids(void)
{
gchar* contents;
gchar** lines;
gchar* line;
gchar* code, *name;
gint i;
if (pnp_ids)
return;
pnp_ids = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
if (g_file_get_contents(PNP_IDS, &contents, NULL, NULL))
{
lines = g_strsplit(contents, "\n", -1);
for (i = 0; lines[i]; i++)
{
line = lines[i];
if (line[0] && line[1] && line[2] && line[3] == '\t' && line[4])
{
code = line;
line[3] = '\0';
name = line + 4;
g_hash_table_insert(pnp_ids, code, name);
}
}
g_free(lines);
g_free(contents);
}
}
static const char* find_vendor(const char* code)
{
const char* vendor_name;
int i;
read_pnp_ids();
vendor_name = g_hash_table_lookup(pnp_ids, code);
if (vendor_name)
return vendor_name;
for (i = 0; i < sizeof(vendors) / sizeof(vendors[0]); ++i)
{
const Vendor* v = &(vendors[i]);
if (strcmp(v->vendor_id, code) == 0)
return v->vendor_name;
}
return code;
}
char* make_display_name(const MonitorInfo* info)
{
const char* vendor;
int width_mm, height_mm, inches;
if (info)
{
vendor = find_vendor(info->manufacturer_code);
}
else
{
/* Translators: "Unknown" here is used to identify a monitor for which
* we don't know the vendor. When a vendor is known, the name of the
* vendor is used. */
vendor = C_("Monitor vendor", "Unknown");
}
if (info && info->width_mm != -1 && info->height_mm)
{
width_mm = info->width_mm;
height_mm = info->height_mm;
}
else if (info && info->n_detailed_timings)
{
width_mm = info->detailed_timings[0].width_mm;
height_mm = info->detailed_timings[0].height_mm;
}
else
{
width_mm = -1;
height_mm = -1;
}
if (width_mm != -1 && height_mm != -1)
{
double d = sqrt (width_mm * width_mm + height_mm * height_mm);
inches = (int) (d / 25.4 + 0.5);
}
else
{
inches = -1;
}
if (inches > 0)
{
return g_strdup_printf("%s %d\"", vendor, inches);
}
else
{
return g_strdup(vendor);
}
}
|