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

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: 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;
alexst (slow to review) 2014/08/26 00:32:04 Once you found a name, you should break.
dnicoara 2014/08/26 00:43:51 Done.
43
44 for (int i = 0; i < property->count_enums; ++i)
45 if (name == property->enums[i].name)
46 return i;
47
48 NOTREACHED();
49 return 0;
50 }
51
23 } // namespace 52 } // namespace
24 53
25 NativeDisplayDelegateDri::NativeDisplayDelegateDri( 54 NativeDisplayDelegateDri::NativeDisplayDelegateDri(
26 DriWrapper* dri, 55 DriWrapper* dri,
27 ScreenManager* screen_manager, 56 ScreenManager* screen_manager,
28 DeviceManager* device_manager) 57 DeviceManager* device_manager)
29 : dri_(dri), 58 : dri_(dri),
30 screen_manager_(screen_manager), 59 screen_manager_(screen_manager),
31 device_manager_(device_manager) { 60 device_manager_(device_manager) {
32 } 61 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 184 }
156 } 185 }
157 186
158 return true; 187 return true;
159 } 188 }
160 189
161 void NativeDisplayDelegateDri::CreateFrameBuffer(const gfx::Size& size) {} 190 void NativeDisplayDelegateDri::CreateFrameBuffer(const gfx::Size& size) {}
162 191
163 bool NativeDisplayDelegateDri::GetHDCPState(const DisplaySnapshot& output, 192 bool NativeDisplayDelegateDri::GetHDCPState(const DisplaySnapshot& output,
164 HDCPState* state) { 193 HDCPState* state) {
165 NOTIMPLEMENTED(); 194 const DisplaySnapshotDri& dri_output =
195 static_cast<const DisplaySnapshotDri&>(output);
196
197 ScopedDrmConnectorPtr connector(dri_->GetConnector(dri_output.connector()));
198 if (!connector) {
199 LOG(ERROR) << "Failed to get connector " << dri_output.connector();
200 return false;
201 }
202
203 ScopedDrmPropertyPtr hdcp_property(
204 dri_->GetProperty(connector.get(), kContentProtection));
205 if (!hdcp_property) {
206 LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist.";
207 return false;
208 }
209
210 DCHECK_LT(hdcp_property->prop_id, connector->count_props);
211 DCHECK_LT(connector->prop_values[hdcp_property->prop_id],
212 hdcp_property->count_enums);
213
214 std::string name(
215 hdcp_property->enums[connector->prop_values[hdcp_property->prop_id]]
alexst (slow to review) 2014/08/26 00:32:04 nit: it was a bit hard for me to parse this, maybe
dnicoara 2014/08/26 00:43:51 Done.
216 .name);
217 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
218 if (name == kContentProtectionStates[i].name) {
219 *state = kContentProtectionStates[i].state;
220 VLOG(3) << "HDCP state: " << *state << " (" << name << ")";
221 return true;
222 }
223 }
224
225 LOG(ERROR) << "Unknown content protection value '" << name << "'";
166 return false; 226 return false;
167 } 227 }
168 228
169 bool NativeDisplayDelegateDri::SetHDCPState(const DisplaySnapshot& output, 229 bool NativeDisplayDelegateDri::SetHDCPState(const DisplaySnapshot& output,
170 HDCPState state) { 230 HDCPState state) {
171 NOTIMPLEMENTED(); 231 const DisplaySnapshotDri& dri_output =
172 return false; 232 static_cast<const DisplaySnapshotDri&>(output);
233
234 ScopedDrmConnectorPtr connector(dri_->GetConnector(dri_output.connector()));
235 if (!connector) {
236 LOG(ERROR) << "Failed to get connector " << dri_output.connector();
237 return false;
238 }
239
240 ScopedDrmPropertyPtr hdcp_property(
241 dri_->GetProperty(connector.get(), kContentProtection));
242 if (!hdcp_property) {
243 LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist.";
244 return false;
245 }
246
247 return dri_->SetProperty(
248 dri_output.connector(),
249 hdcp_property->prop_id,
250 GetContentProtectionValue(hdcp_property.get(), state));
173 } 251 }
174 252
175 std::vector<ui::ColorCalibrationProfile> 253 std::vector<ui::ColorCalibrationProfile>
176 NativeDisplayDelegateDri::GetAvailableColorCalibrationProfiles( 254 NativeDisplayDelegateDri::GetAvailableColorCalibrationProfiles(
177 const ui::DisplaySnapshot& output) { 255 const ui::DisplaySnapshot& output) {
178 NOTIMPLEMENTED(); 256 NOTIMPLEMENTED();
179 return std::vector<ui::ColorCalibrationProfile>(); 257 return std::vector<ui::ColorCalibrationProfile>();
180 } 258 }
181 259
182 bool NativeDisplayDelegateDri::SetColorCalibrationProfile( 260 bool NativeDisplayDelegateDri::SetColorCalibrationProfile(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 break; 295 break;
218 } 296 }
219 } 297 }
220 298
221 if (!found) 299 if (!found)
222 screen_manager_->RemoveDisplayController(old_displays[i]->crtc()); 300 screen_manager_->RemoveDisplayController(old_displays[i]->crtc());
223 } 301 }
224 } 302 }
225 303
226 } // namespace ui 304 } // 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