Pet*_*r.O 21 hardware monitors
I have extracted the shorthand version of the current monitor attached to the computer.
Here is an example: vendor "VSC", prod id "18500"
In Ubuntu's Monitor Preferences, it is identified as Viewsonic Corporation 16".
How can I extract this human readable form? ... and also, how can I determine if a monitor is a CRT or an LCD? (this is actually what got me started on this quest)
The EDID format can be found on Wikipedia: Extended display identification data
Here is the code used to get the EDID Vendor and Product id
edid=$(xrandr -q --verbose |
sed -n '/^[[:space:]]\+00ffffffffffff00/,/[^a-fA-F0-9[:space:]]/{
/[^a-fA-F0-9[:space:]]/d
s/[[:space:]]\+//g; p}')
nibble=({0..1}{0..1}{0..1}{0..1})
vend=$(for i in {16..19} ;do
printf "%s" ${nibble[$((16#${edid:$i:1}))]}
done)
vend="$(for i in 1 6 11 ;do
printf \\x$(printf %x $((2#${vend:$i:5} +64)))
done)"
prod=$((16#${edid:22:2}${edid:20:2}))
printf "monitor: vendor \"%s\", prod id \"%s\"\n" "${vend}" "$prod"
Run Code Online (Sandbox Code Playgroud)
编辑:这是xrandr -q verbose输出的前导行......直到EDID十六进制转储结束
Screen 0: minimum 320 x 200, current 1280 x 960, maximum 8192 x 8192
VGA1 connected 1280x960+0+0 (0x47) normal (normal left inverted right x axis y axis) 320mm x 240mm
Identifier: 0x41
Timestamp: 26386
Subpixel: unknown
Clones:
CRTC: 0
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
EDID:
00ffffffffffff005a63444809000000
15090101682018b1e84f22a157479925
0f484ffffe00315945596159714f8140
818001010101000000ff004848393231
30303030390a2020000000fd0032781e
46ff000a202020202020000000fc0056
696577536f6e696320453737000000fc
00312d320a2020202020202020200084
1280x1024 (0x46) 108.0MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 64.0KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.0Hz
1280x960 (0x47) ....
...
... etc
Run Code Online (Sandbox Code Playgroud)
don*_*sti 13
在 Ubuntu 的 Monitor Preferences 中,它被标识为 Viewsonic Corporation 16"。我如何提取这种人类可读的形式?
人类可读的形式(“Viewsonic Corporation”)不是(直接)来自您的 EDID:
Ubuntu 在下面使用 gnome 库。libgnome-desktop 解码 edid并 - 通过pnp-ids - 将三个字母的供应商 ID(在您的特定情况下为“VSC”)转换为显示的漂亮名称。
gnome-pnp-ids.c,第 51 行:
* Note: we now prefer to use data coming from hwdata (and shipped with gnome-desktop)*
Run Code Online (Sandbox Code Playgroud)
在我的系统上
grep VSC /usr/share/hwdata/pnp.ids
Run Code Online (Sandbox Code Playgroud)
返回:
VSC ViewSonic Corporation
Run Code Online (Sandbox Code Playgroud)
除此之外,可以从 EDID 中提取附加信息,即从描述符块中提取。来自同一个维基百科链接:
描述符块。详细的时序描述符,按优先顺序递减。在所有详细的时序描述符之后,允许使用其他描述符:
- 监控范围限制(必需)
- ASCII 文本(显示器名称(必填)、显示器序列号或非结构化文本)
- 6 附加标准时序信息块
- 色点数据
当前定义的描述符类型是:
- 0xFF:监视器序列号(文本)
- 0xFE:未指明的文本(text)
- 0xFD:监控范围限制。6 或 13 字节二进制描述符。
- 0xFC:监视器名称(文本)
- 0xFB:附加白点数据。2× 5 字节描述符,用 0A 20 20 填充。
- 0xFA:附加的标准时序标识符。6× 2 字节描述符,用 0A 填充。
在您的 EDID 中,您0xFF在描述符 1(字节 54-71)中有(序列号):
00 ff 00 48 48 39 32 31 30 30 30 30 39 0a 20 20 00 00
Run Code Online (Sandbox Code Playgroud)
并且您0xFC在描述符 3(字节 90-107)和 4(字节 108-125)中有(监视器名称):
00 fc 00 56 69 65 77 53 6f 6e 69 63 20 45 37 37 00 00
00 fc 00 31 2d 32 0a 20 20 20 20 20 20 20 20 20 00 84
Run Code Online (Sandbox Code Playgroud)
所以这只是从那里提取信息的问题,例如描述符 3:
56 69 65 77 53 6f 6e 69 63 20 45 37 37>>优派E77
有一些 linux 工具可以解析 EDID……我使用monitor-edid. 这是我机器上 Perl dumper 格式的输出:
(
+{
'EISA_ID' => 'CMO1574',
'checksum' => 25,
'detailed_timings' => [
{
'ModeLine' => '"1600x900" 97.75 1600 1648 1680 1760 900 903 908 926 -hsync -vsync',
'ModeLine_comment' => '# Monitor preferred modeline (60.0 Hz vsync, 55.5 kHz hsync, ratio 16/9, 118 dpi)',
'digital_composite' => 3,
'horizontal_active' => 1600,
'horizontal_blanking' => 160,
'horizontal_border' => 0,
'horizontal_dpi' => '118.139534883721',
'horizontal_image_size' => 344,
'horizontal_sync_offset' => 48,
'horizontal_sync_positive' => 0,
'horizontal_sync_pulse_width' => 32,
'interlaced' => 0,
'pixel_clock' => '97.75',
'preferred' => 1,
'stereo' => 0,
'vertical_active' => 900,
'vertical_blanking' => 26,
'vertical_border' => 0,
'vertical_dpi' => '118.445595854922',
'vertical_image_size' => 193,
'vertical_sync_offset' => 3,
'vertical_sync_positive' => 0,
'vertical_sync_pulse_width' => 5
}
],
'diagonal_size' => '15.5292379824145',
'edid_revision' => 3,
'edid_version' => 1,
'established_timings' => [],
'extension_flag' => 0,
'feature_support' => {
'DPMS_active_off' => 0,
'DPMS_standby' => 0,
'DPMS_suspend' => 0,
'GTF_compliance' => 0,
'has_preferred_timing' => 1,
'rgb' => 0,
'sRGB_compliance' => 0
},
'file' => '/sys/class/drm/card0-LVDS-1/edid',
'gamma' => 120,
'manufacturer_name' => 'CMO',
'max_size_horizontal' => '34.4',
'max_size_precision' => 'mm',
'max_size_vertical' => '19.3',
'monitor_details' => '',
'monitor_text' => [
'N156O6-L01',
'CMO',
'N156O6-L01'
],
'product_code' => 5492,
'ratio' => '1.78238341968912',
'ratio_name' => '16/9',
'ratio_precision' => 'mm',
'serial_number' => 0,
'standard_timings' => [],
'video_input_definition' => {
'composite_sync' => 0,
'digital' => 1,
'separate_sync' => 0,
'sync_on_green' => 0,
'voltage_level' => 0
},
'week' => 41,
'year' => 2008
}
,
)
Run Code Online (Sandbox Code Playgroud)
最后,我不知道如何确定(在 linux 中)显示器是 LCD 还是 CRT。我不知道任何库的实现这种功能(像这样一个从MS)。
像这样的东西应该工作得更好(所有其他答案在这里都没有100%工作):
for file in `ls -1 /sys/class/drm/*/edid`; do text=$(tr -d '\0' <"$file"); if [ -n "$text" ]; then edid-decode "$file" | grep -e Manufacturer: -e Product; sleep 0.0001; fi done
Run Code Online (Sandbox Code Playgroud)
我在这里用两台显示器进行了测试。我的主要显示器是内置笔记本电脑显示器,辅助显示器是 DELL 25"。输出如下:
Manufacturer: DELL Model 53359 Serial Number 809781068
Display Product Serial Number: YKFWP5790DGL
Display Product Name: DELL U2515H
Manufacturer: LGD Model 1133 Serial Number 0
Run Code Online (Sandbox Code Playgroud)
您必须已经在您的发行版中安装了edid-decode。我的设置是使用 Ubuntu 20.04 的 DELL Latitude e5450。