OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/display/x11/edid_parser_x11.h" | 5 #include "ui/display/x11/edid_parser_x11.h" |
6 | 6 |
7 #include <X11/extensions/Xrandr.h> | 7 #include <X11/extensions/Xrandr.h> |
8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 int randr_version_minor = 0; | 21 int randr_version_minor = 0; |
22 static bool is_randr_available = XRRQueryVersion( | 22 static bool is_randr_available = XRRQueryVersion( |
23 base::MessagePumpX11::GetDefaultXDisplay(), | 23 base::MessagePumpX11::GetDefaultXDisplay(), |
24 &randr_version_major, &randr_version_minor); | 24 &randr_version_major, &randr_version_minor); |
25 return is_randr_available; | 25 return is_randr_available; |
26 } | 26 } |
27 | 27 |
28 // Get the EDID data from the |output| and stores to |edid|. | 28 // Get the EDID data from the |output| and stores to |edid|. |
29 // Returns true if EDID property is successfully obtained. Otherwise returns | 29 // Returns true if EDID property is successfully obtained. Otherwise returns |
30 // false and does not touch |edid|. | 30 // false and does not touch |edid|. |
31 bool GetEDIDProperty(XID output, std::vector<uint8>* edid) { | 31 bool GetEDIDProperty(XID output, std::vector<uint8_t>* edid) { |
32 if (!IsRandRAvailable()) | 32 if (!IsRandRAvailable()) |
33 return false; | 33 return false; |
34 | 34 |
35 Display* display = base::MessagePumpX11::GetDefaultXDisplay(); | 35 Display* display = base::MessagePumpX11::GetDefaultXDisplay(); |
36 | 36 |
37 static Atom edid_property = XInternAtom( | 37 static Atom edid_property = XInternAtom( |
38 base::MessagePumpX11::GetDefaultXDisplay(), | 38 base::MessagePumpX11::GetDefaultXDisplay(), |
39 RR_PROPERTY_RANDR_EDID, false); | 39 RR_PROPERTY_RANDR_EDID, false); |
40 | 40 |
41 bool has_edid_property = false; | 41 bool has_edid_property = false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 edid->assign(prop, prop + nitems); | 74 edid->assign(prop, prop + nitems); |
75 XFree(prop); | 75 XFree(prop); |
76 return true; | 76 return true; |
77 } | 77 } |
78 | 78 |
79 // Gets some useful data from the specified output device, such like | 79 // Gets some useful data from the specified output device, such like |
80 // manufacturer's ID, product code, and human readable name. Returns false if it | 80 // manufacturer's ID, product code, and human readable name. Returns false if it |
81 // fails to get those data and doesn't touch manufacturer ID/product code/name. | 81 // fails to get those data and doesn't touch manufacturer ID/product code/name. |
82 // NULL can be passed for unwanted output parameters. | 82 // NULL can be passed for unwanted output parameters. |
83 bool GetOutputDeviceData(XID output, | 83 bool GetOutputDeviceData(XID output, |
84 uint16* manufacturer_id, | 84 uint16_t* manufacturer_id, |
85 std::string* human_readable_name) { | 85 std::string* human_readable_name) { |
86 std::vector<uint8> edid; | 86 std::vector<uint8_t> edid; |
87 if (!GetEDIDProperty(output, &edid)) | 87 if (!GetEDIDProperty(output, &edid)) |
88 return false; | 88 return false; |
89 | 89 |
90 bool result = ParseOutputDeviceData( | 90 bool result = ParseOutputDeviceData( |
91 edid, manufacturer_id, human_readable_name); | 91 edid, manufacturer_id, human_readable_name); |
92 return result; | 92 return result; |
93 } | 93 } |
94 | 94 |
95 } // namespace | 95 } // namespace |
96 | 96 |
97 bool GetDisplayId(XID output_id, uint8 output_index, int64* display_id_out) { | 97 bool GetDisplayId(XID output_id, |
98 std::vector<uint8> edid; | 98 uint8_t output_index, |
| 99 int64_t* display_id_out) { |
| 100 std::vector<uint8_t> edid; |
99 if (!GetEDIDProperty(output_id, &edid)) | 101 if (!GetEDIDProperty(output_id, &edid)) |
100 return false; | 102 return false; |
101 | 103 |
102 bool result = GetDisplayIdFromEDID(edid, output_index, display_id_out); | 104 bool result = GetDisplayIdFromEDID(edid, output_index, display_id_out); |
103 return result; | 105 return result; |
104 } | 106 } |
105 | 107 |
106 std::string GetDisplayName(RROutput output) { | 108 std::string GetDisplayName(RROutput output) { |
107 std::string display_name; | 109 std::string display_name; |
108 GetOutputDeviceData(output, NULL, &display_name); | 110 GetOutputDeviceData(output, NULL, &display_name); |
109 return display_name; | 111 return display_name; |
110 } | 112 } |
111 | 113 |
112 bool GetOutputOverscanFlag(RROutput output, bool* flag) { | 114 bool GetOutputOverscanFlag(RROutput output, bool* flag) { |
113 std::vector<uint8> edid; | 115 std::vector<uint8_t> edid; |
114 if (!GetEDIDProperty(output, &edid)) | 116 if (!GetEDIDProperty(output, &edid)) |
115 return false; | 117 return false; |
116 | 118 |
117 bool found = ParseOutputOverscanFlag(edid, flag); | 119 bool found = ParseOutputOverscanFlag(edid, flag); |
118 return found; | 120 return found; |
119 } | 121 } |
120 | 122 |
121 } // namespace ui | 123 } // namespace ui |
OLD | NEW |