Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_device.cc

Issue 1914343003: Reland: ash: reset color management when new screens are hotplugged (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ozone/platform/drm/gpu/drm_device.h" 5 #include "ui/ozone/platform/drm/gpu/drm_device.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return ctm; 213 return ctm;
214 } 214 }
215 215
216 bool SetBlobProperty(int fd, 216 bool SetBlobProperty(int fd,
217 uint32_t object_id, 217 uint32_t object_id,
218 uint32_t object_type, 218 uint32_t object_type,
219 uint32_t prop_id, 219 uint32_t prop_id,
220 const char* property_name, 220 const char* property_name,
221 unsigned char* data, 221 unsigned char* data,
222 size_t length) { 222 size_t length) {
223 uint32_t blob_id; 223 uint32_t blob_id = 0;
224 int res; 224 int res;
225 res = CreatePropertyBlob(fd, data, length, &blob_id); 225
226 if (res != 0) { 226 if (data) {
227 LOG(ERROR) << "Error creating property blob: " << base::safe_strerror(res) 227 res = CreatePropertyBlob(fd, data, length, &blob_id);
228 << " for property " << property_name; 228 if (res != 0) {
229 return false; 229 LOG(ERROR) << "Error creating property blob: " << base::safe_strerror(res)
230 << " for property " << property_name;
231 return false;
232 }
230 } 233 }
234
235 bool success = false;
231 res = drmModeObjectSetProperty(fd, object_id, object_type, prop_id, blob_id); 236 res = drmModeObjectSetProperty(fd, object_id, object_type, prop_id, blob_id);
232 if (res != 0) { 237 if (res != 0) {
233 LOG(ERROR) << "Error updating property: " << base::safe_strerror(res) 238 LOG(ERROR) << "Error updating property: " << base::safe_strerror(res)
234 << " for property " << property_name; 239 << " for property " << property_name;
240 } else {
241 success = true;
242 }
243 if (blob_id != 0)
235 DestroyPropertyBlob(fd, blob_id); 244 DestroyPropertyBlob(fd, blob_id);
236 return false; 245 return success;
237 }
238 DestroyPropertyBlob(fd, blob_id);
239 return true;
240 } 246 }
241 247
242 std::vector<GammaRampRGBEntry> ResampleLut( 248 std::vector<GammaRampRGBEntry> ResampleLut(
243 const std::vector<GammaRampRGBEntry>& lut_in, 249 const std::vector<GammaRampRGBEntry>& lut_in,
244 size_t desired_size) { 250 size_t desired_size) {
245 TRACE_EVENT1("drm", "ResampleLut", "desired_size", desired_size); 251 TRACE_EVENT1("drm", "ResampleLut", "desired_size", desired_size);
246 if (lut_in.size() == desired_size) 252 if (lut_in.size() == desired_size)
247 return lut_in; 253 return lut_in;
248 254
249 std::vector<GammaRampRGBEntry> result; 255 std::vector<GammaRampRGBEntry> result;
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 727
722 if (degamma_lut_size && gamma_lut_size) 728 if (degamma_lut_size && gamma_lut_size)
723 break; 729 break;
724 } 730 }
725 731
726 if (degamma_lut_size == 0 || gamma_lut_size == 0) { 732 if (degamma_lut_size == 0 || gamma_lut_size == 0) {
727 LOG(WARNING) << "No available (de)gamma tables."; 733 LOG(WARNING) << "No available (de)gamma tables.";
728 return false; 734 return false;
729 } 735 }
730 736
731 ScopedDrmColorLutPtr degamma_blob_data = 737 ScopedDrmColorLutPtr degamma_blob_data;
732 CreateLutBlob(ResampleLut(degamma_lut, degamma_lut_size)); 738 if (!degamma_lut.empty()) {
733 ScopedDrmColorLutPtr gamma_blob_data = 739 degamma_blob_data =
734 CreateLutBlob(ResampleLut(gamma_lut, gamma_lut_size)); 740 CreateLutBlob(ResampleLut(degamma_lut, degamma_lut_size));
robert.bradford 2016/04/27 12:29:46 Is there any way to put this into CreateLutBlob/Cr
735 ScopedDrmColorCtmPtr ctm_blob_data = CreateCTMBlob(correction_matrix); 741 }
742 ScopedDrmColorLutPtr gamma_blob_data;
743 if (!gamma_lut.empty())
744 gamma_blob_data = CreateLutBlob(ResampleLut(gamma_lut, gamma_lut_size));
745 ScopedDrmColorCtmPtr ctm_blob_data;
746 if (!correction_matrix.empty())
747 ctm_blob_data = CreateCTMBlob(correction_matrix);
736 748
737 for (uint32_t i = 0; i < crtc_props->count_props; ++i) { 749 for (uint32_t i = 0; i < crtc_props->count_props; ++i) {
738 ScopedDrmPropertyPtr property( 750 ScopedDrmPropertyPtr property(
739 drmModeGetProperty(file_.GetPlatformFile(), crtc_props->props[i])); 751 drmModeGetProperty(file_.GetPlatformFile(), crtc_props->props[i]));
740 if (!property) 752 if (!property)
741 continue; 753 continue;
742 754
743 if (!strcmp(property->name, "DEGAMMA_LUT")) { 755 if (!strcmp(property->name, "DEGAMMA_LUT")) {
744 if (!SetBlobProperty( 756 if (!SetBlobProperty(
745 file_.GetPlatformFile(), crtc_id, DRM_MODE_OBJECT_CRTC, 757 file_.GetPlatformFile(), crtc_id, DRM_MODE_OBJECT_CRTC,
(...skipping 17 matching lines...) Expand all
763 reinterpret_cast<unsigned char*>(ctm_blob_data.get()), 775 reinterpret_cast<unsigned char*>(ctm_blob_data.get()),
764 sizeof(DrmColorCtm))) 776 sizeof(DrmColorCtm)))
765 return false; 777 return false;
766 } 778 }
767 } 779 }
768 780
769 return true; 781 return true;
770 } 782 }
771 783
772 } // namespace ui 784 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698