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/dri/chromeos/native_display_delegate_dri.cc

Issue 471433007: [Ozone-Dri] Adding initial content protection support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cast Created 6 years, 3 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
« no previous file with comments | « no previous file | ui/ozone/platform/dri/dri_wrapper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dri/chromeos/native_display_delegate_dri.h" 5 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "third_party/skia/include/core/SkCanvas.h" 8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "ui/display/types/chromeos/native_display_observer.h" 9 #include "ui/display/types/chromeos/native_display_observer.h"
10 #include "ui/events/ozone/device/device_event.h" 10 #include "ui/events/ozone/device/device_event.h"
11 #include "ui/events/ozone/device/device_manager.h" 11 #include "ui/events/ozone/device/device_manager.h"
12 #include "ui/ozone/platform/dri/chromeos/display_mode_dri.h" 12 #include "ui/ozone/platform/dri/chromeos/display_mode_dri.h"
13 #include "ui/ozone/platform/dri/chromeos/display_snapshot_dri.h" 13 #include "ui/ozone/platform/dri/chromeos/display_snapshot_dri.h"
14 #include "ui/ozone/platform/dri/dri_console_buffer.h" 14 #include "ui/ozone/platform/dri/dri_console_buffer.h"
15 #include "ui/ozone/platform/dri/dri_util.h" 15 #include "ui/ozone/platform/dri/dri_util.h"
16 #include "ui/ozone/platform/dri/dri_wrapper.h" 16 #include "ui/ozone/platform/dri/dri_wrapper.h"
17 #include "ui/ozone/platform/dri/screen_manager.h" 17 #include "ui/ozone/platform/dri/screen_manager.h"
18 18
19 namespace ui { 19 namespace ui {
20 20
21 namespace { 21 namespace {
22
22 const size_t kMaxDisplayCount = 2; 23 const size_t kMaxDisplayCount = 2;
24
25 const char kContentProtection[] = "Content Protection";
26
27 struct ContentProtectionMapping {
28 const char* name;
29 HDCPState state;
30 };
31
32 const ContentProtectionMapping kContentProtectionStates[] = {
33 {"Undesired", HDCP_STATE_UNDESIRED},
34 {"Desired", HDCP_STATE_DESIRED},
35 {"Enabled", HDCP_STATE_ENABLED}};
36
37 uint32_t GetContentProtectionValue(drmModePropertyRes* property,
38 HDCPState state) {
39 std::string name;
40 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
41 if (kContentProtectionStates[i].state == state) {
42 name = kContentProtectionStates[i].name;
43 break;
44 }
45 }
46
47 for (int i = 0; i < property->count_enums; ++i)
48 if (name == property->enums[i].name)
49 return i;
50
51 NOTREACHED();
52 return 0;
53 }
54
23 } // namespace 55 } // namespace
24 56
25 NativeDisplayDelegateDri::NativeDisplayDelegateDri( 57 NativeDisplayDelegateDri::NativeDisplayDelegateDri(
26 DriWrapper* dri, 58 DriWrapper* dri,
27 ScreenManager* screen_manager, 59 ScreenManager* screen_manager,
28 DeviceManager* device_manager) 60 DeviceManager* device_manager)
29 : dri_(dri), 61 : dri_(dri),
30 screen_manager_(screen_manager), 62 screen_manager_(screen_manager),
31 device_manager_(device_manager) { 63 device_manager_(device_manager) {
32 } 64 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 187 }
156 } 188 }
157 189
158 return true; 190 return true;
159 } 191 }
160 192
161 void NativeDisplayDelegateDri::CreateFrameBuffer(const gfx::Size& size) {} 193 void NativeDisplayDelegateDri::CreateFrameBuffer(const gfx::Size& size) {}
162 194
163 bool NativeDisplayDelegateDri::GetHDCPState(const DisplaySnapshot& output, 195 bool NativeDisplayDelegateDri::GetHDCPState(const DisplaySnapshot& output,
164 HDCPState* state) { 196 HDCPState* state) {
165 NOTIMPLEMENTED(); 197 const DisplaySnapshotDri& dri_output =
198 static_cast<const DisplaySnapshotDri&>(output);
199
200 ScopedDrmConnectorPtr connector(dri_->GetConnector(dri_output.connector()));
201 if (!connector) {
202 LOG(ERROR) << "Failed to get connector " << dri_output.connector();
203 return false;
204 }
205
206 ScopedDrmPropertyPtr hdcp_property(
207 dri_->GetProperty(connector.get(), kContentProtection));
208 if (!hdcp_property) {
209 LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist.";
210 return false;
211 }
212
213 DCHECK_LT(static_cast<int>(hdcp_property->prop_id), connector->count_props);
214 int hdcp_state_idx = connector->prop_values[hdcp_property->prop_id];
215 DCHECK_LT(hdcp_state_idx, hdcp_property->count_enums);
216
217 std::string name(hdcp_property->enums[hdcp_state_idx].name);
218 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
219 if (name == kContentProtectionStates[i].name) {
220 *state = kContentProtectionStates[i].state;
221 VLOG(3) << "HDCP state: " << *state << " (" << name << ")";
222 return true;
223 }
224 }
225
226 LOG(ERROR) << "Unknown content protection value '" << name << "'";
166 return false; 227 return false;
167 } 228 }
168 229
169 bool NativeDisplayDelegateDri::SetHDCPState(const DisplaySnapshot& output, 230 bool NativeDisplayDelegateDri::SetHDCPState(const DisplaySnapshot& output,
170 HDCPState state) { 231 HDCPState state) {
171 NOTIMPLEMENTED(); 232 const DisplaySnapshotDri& dri_output =
172 return false; 233 static_cast<const DisplaySnapshotDri&>(output);
234
235 ScopedDrmConnectorPtr connector(dri_->GetConnector(dri_output.connector()));
236 if (!connector) {
237 LOG(ERROR) << "Failed to get connector " << dri_output.connector();
238 return false;
239 }
240
241 ScopedDrmPropertyPtr hdcp_property(
242 dri_->GetProperty(connector.get(), kContentProtection));
243 if (!hdcp_property) {
244 LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist.";
245 return false;
246 }
247
248 return dri_->SetProperty(
249 dri_output.connector(),
250 hdcp_property->prop_id,
251 GetContentProtectionValue(hdcp_property.get(), state));
173 } 252 }
174 253
175 std::vector<ui::ColorCalibrationProfile> 254 std::vector<ui::ColorCalibrationProfile>
176 NativeDisplayDelegateDri::GetAvailableColorCalibrationProfiles( 255 NativeDisplayDelegateDri::GetAvailableColorCalibrationProfiles(
177 const ui::DisplaySnapshot& output) { 256 const ui::DisplaySnapshot& output) {
178 NOTIMPLEMENTED(); 257 NOTIMPLEMENTED();
179 return std::vector<ui::ColorCalibrationProfile>(); 258 return std::vector<ui::ColorCalibrationProfile>();
180 } 259 }
181 260
182 bool NativeDisplayDelegateDri::SetColorCalibrationProfile( 261 bool NativeDisplayDelegateDri::SetColorCalibrationProfile(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 break; 296 break;
218 } 297 }
219 } 298 }
220 299
221 if (!found) 300 if (!found)
222 screen_manager_->RemoveDisplayController(old_displays[i]->crtc()); 301 screen_manager_->RemoveDisplayController(old_displays[i]->crtc());
223 } 302 }
224 } 303 }
225 304
226 } // namespace ui 305 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/ozone/platform/dri/dri_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698