Index: chromeos/display/output_util.cc |
diff --git a/chromeos/display/output_util.cc b/chromeos/display/output_util.cc |
index aa235b05f3cf248c11ba23f7b04b5b85ef96a092..f320f9b336cfdae9cffa5aa3af9b6d6f2ecd4f68 100644 |
--- a/chromeos/display/output_util.cc |
+++ b/chromeos/display/output_util.cc |
@@ -8,6 +8,7 @@ |
#include <X11/extensions/Xrandr.h> |
#include <X11/Xatom.h> |
+#include "base/hash.h" |
#include "base/message_loop.h" |
#include "base/string_util.h" |
#include "base/sys_byteorder.h" |
@@ -20,16 +21,16 @@ const char kInternal_LVDS[] = "LVDS"; |
const char kInternal_eDP[] = "eDP"; |
// Returns 64-bit persistent ID for the specified manufacturer's ID and |
-// product_code, and the index of the output it is connected to. |
+// product_name, and the index of the output it is connected to. |
// |output_index| is used to distinguish the displays of the same type. For |
// example, swapping two identical display between two outputs will not be |
// treated as swap. The 'serial number' field in EDID isn't used here because |
// it is not guaranteed to have unique number and it may have the same fixed |
// value (like 0). |
int64 GetID(uint16 manufacturer_id, |
- uint16 product_code, |
+ uint32 product_code, |
uint8 output_index) { |
- return ((static_cast<int64>(manufacturer_id) << 24) | |
+ return ((static_cast<int64>(manufacturer_id) << 40) | |
(static_cast<int64>(product_code) << 8) | output_index); |
} |
@@ -121,12 +122,21 @@ std::string GetDisplayName(XID output_id) { |
bool GetDisplayId(XID output_id, size_t output_index, int64* display_id_out) { |
uint16 manufacturer_id = 0; |
uint16 product_code = 0; |
- if (GetOutputDeviceData( |
- output_id, &manufacturer_id, &product_code, NULL) && |
- manufacturer_id != 0) { |
+ std::string product_name; |
+ |
+ // GetOutputDeviceData fails if it doesn't have product_name. |
+ GetOutputDeviceData( |
+ output_id, &manufacturer_id, &product_code, &product_name); |
+ |
+ // Generates product specific value from product_name. See crbug.com/240341 |
+ // for why we prefer product name string instead of product code in EDID. |
+ uint32 product_specific_code = product_name.empty() ? |
+ static_cast<uint32>(product_code) : base::Hash(product_name); |
oshima
2013/05/20 20:29:40
May be we should mask the product_code with 0xFFFF
marcheu
2013/05/20 20:54:43
I think it's fine either way. It's probably also f
Jun Mukai
2013/05/21 01:28:25
Hmm, I'm not sure what's the mask should be... is
oshima
2013/05/21 01:40:00
0xFFFC (sorry it was typo) produces 9844 for 9846/
|
+ if (manufacturer_id != 0) { |
// An ID based on display's index will be assigned later if this call |
// fails. |
- *display_id_out = GetID(manufacturer_id, product_code, output_index); |
+ *display_id_out = GetID( |
+ manufacturer_id, product_specific_code, output_index); |
return true; |
} |
return false; |