• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "impl/vr_hwc.h"
17 
18 #include "android-base/stringprintf.h"
19 #include <binder/IServiceManager.h>
20 #include <cutils/properties.h>
21 #include <private/dvr/display_client.h>
22 #include <ui/Fence.h>
23 #include <utils/Trace.h>
24 
25 #include <mutex>
26 
27 #include "vr_composer_client.h"
28 
29 using namespace android::hardware::graphics::common::V1_0;
30 using namespace android::hardware::graphics::composer::V2_3;
31 
32 using android::base::StringPrintf;
33 using android::hardware::hidl_handle;
34 using android::hardware::hidl_string;
35 using android::hardware::hidl_vec;
36 using android::hardware::Return;
37 using android::hardware::Void;
38 
39 namespace types = android::hardware::graphics::common;
40 
41 namespace android {
42 namespace dvr {
43 namespace {
44 
45 const Display kDefaultDisplayId = 1;
46 const Config kDefaultConfigId = 1;
47 
CreateGraphicBuffer(const native_handle_t * handle,const IVrComposerClient::BufferMetadata & metadata)48 sp<GraphicBuffer> CreateGraphicBuffer(
49     const native_handle_t* handle,
50     const IVrComposerClient::BufferMetadata& metadata) {
51    sp<GraphicBuffer> buffer = new GraphicBuffer(
52       handle, GraphicBuffer::CLONE_HANDLE, metadata.width, metadata.height,
53       static_cast<int32_t>(metadata.format), metadata.layerCount,
54       metadata.usage, metadata.stride);
55    if (buffer->initCheck() != OK) {
56      ALOGE("Failed to create graphic buffer");
57      return nullptr;
58    }
59 
60    return buffer;
61 }
62 
GetPrimaryDisplaySize(int32_t * width,int32_t * height)63 void GetPrimaryDisplaySize(int32_t* width, int32_t* height) {
64   *width = 1080;
65   *height = 1920;
66 
67   int error = 0;
68   auto display_client = display::DisplayClient::Create(&error);
69   if (!display_client) {
70     ALOGE("Could not connect to display service : %s(%d)", strerror(error),
71           error);
72     return;
73   }
74 
75   auto status = display_client->GetDisplayMetrics();
76   if (!status) {
77     ALOGE("Could not get display metrics from display service : %s(%d)",
78           status.GetErrorMessage().c_str(), status.error());
79     return;
80   }
81 
82   *width = status.get().display_width;
83   *height = status.get().display_height;
84 }
85 
86 }  // namespace
87 
HwcDisplay(int32_t width,int32_t height)88 HwcDisplay::HwcDisplay(int32_t width, int32_t height)
89     : width_(width), height_(height) {}
90 
~HwcDisplay()91 HwcDisplay::~HwcDisplay() {}
92 
SetClientTarget(const native_handle_t * handle,base::unique_fd fence)93 bool HwcDisplay::SetClientTarget(const native_handle_t* handle,
94                                  base::unique_fd fence) {
95   if (handle)
96     buffer_ = CreateGraphicBuffer(handle, buffer_metadata_);
97 
98   fence_ = new Fence(fence.release());
99   return true;
100 }
101 
SetClientTargetMetadata(const IVrComposerClient::BufferMetadata & metadata)102 void HwcDisplay::SetClientTargetMetadata(
103     const IVrComposerClient::BufferMetadata& metadata) {
104   buffer_metadata_ = metadata;
105 }
106 
CreateLayer()107 HwcLayer* HwcDisplay::CreateLayer() {
108   uint64_t layer_id = layer_ids_++;
109   layers_.push_back(HwcLayer(layer_id));
110   return &layers_.back();
111 }
112 
GetLayer(Layer id)113 HwcLayer* HwcDisplay::GetLayer(Layer id) {
114   for (size_t i = 0; i < layers_.size(); ++i)
115     if (layers_[i].info.id == id)
116       return &layers_[i];
117 
118   return nullptr;
119 }
120 
DestroyLayer(Layer id)121 bool HwcDisplay::DestroyLayer(Layer id) {
122   for (auto it = layers_.begin(); it != layers_.end(); ++it) {
123     if (it->info.id == id) {
124       layers_.erase(it);
125       return true;
126     }
127   }
128 
129   return false;
130 }
131 
GetChangedCompositionTypes(std::vector<Layer> * layer_ids,std::vector<IComposerClient::Composition> * types)132 void HwcDisplay::GetChangedCompositionTypes(
133     std::vector<Layer>* layer_ids,
134     std::vector<IComposerClient::Composition>* types) {
135   std::sort(layers_.begin(), layers_.end(),
136             [](const auto& lhs, const auto& rhs) {
137               return lhs.info.z_order < rhs.info.z_order;
138             });
139 
140   const size_t no_layer = std::numeric_limits<size_t>::max();
141   size_t first_client_layer = no_layer, last_client_layer = no_layer;
142   for (size_t i = 0; i < layers_.size(); ++i) {
143     switch (layers_[i].composition_type) {
144       case IComposerClient::Composition::SOLID_COLOR:
145       case IComposerClient::Composition::CURSOR:
146       case IComposerClient::Composition::SIDEBAND:
147         if (first_client_layer == no_layer)
148           first_client_layer = i;
149 
150         last_client_layer = i;
151         break;
152       default:
153         break;
154     }
155   }
156 
157   for (size_t i = 0; i < layers_.size(); ++i) {
158     if (i >= first_client_layer && i <= last_client_layer) {
159       if (layers_[i].composition_type != IComposerClient::Composition::CLIENT) {
160         layer_ids->push_back(layers_[i].info.id);
161         types->push_back(IComposerClient::Composition::CLIENT);
162         layers_[i].composition_type = IComposerClient::Composition::CLIENT;
163       }
164 
165       continue;
166     }
167 
168     if (layers_[i].composition_type != IComposerClient::Composition::DEVICE) {
169       layer_ids->push_back(layers_[i].info.id);
170       types->push_back(IComposerClient::Composition::DEVICE);
171       layers_[i].composition_type = IComposerClient::Composition::DEVICE;
172     }
173   }
174 }
175 
GetFrame(std::vector<ComposerView::ComposerLayer> * out_frames)176 Error HwcDisplay::GetFrame(
177     std::vector<ComposerView::ComposerLayer>* out_frames) {
178   bool queued_client_target = false;
179   std::vector<ComposerView::ComposerLayer> frame;
180   for (const auto& layer : layers_) {
181     if (layer.composition_type == IComposerClient::Composition::CLIENT) {
182       if (queued_client_target)
183         continue;
184 
185       if (!buffer_.get()) {
186         ALOGE("Client composition requested but no client target buffer");
187         return Error::BAD_LAYER;
188       }
189 
190       ComposerView::ComposerLayer client_target_layer = {
191           .buffer = buffer_,
192           .fence = fence_.get() ? fence_ : new Fence(-1),
193           .display_frame = {0, 0, static_cast<int32_t>(buffer_->getWidth()),
194             static_cast<int32_t>(buffer_->getHeight())},
195           .crop = {0.0f, 0.0f, static_cast<float>(buffer_->getWidth()),
196             static_cast<float>(buffer_->getHeight())},
197           .blend_mode = IComposerClient::BlendMode::NONE,
198       };
199 
200       frame.push_back(client_target_layer);
201       queued_client_target = true;
202     } else {
203       if (!layer.info.buffer.get() || !layer.info.fence.get()) {
204         ALOGV("Layer requested without valid buffer");
205         continue;
206       }
207 
208       frame.push_back(layer.info);
209     }
210   }
211 
212   out_frames->swap(frame);
213   return Error::NONE;
214 }
215 
UpdateLastFrameAndGetLastFrameLayers()216 std::vector<Layer> HwcDisplay::UpdateLastFrameAndGetLastFrameLayers() {
217   std::vector<Layer> last_frame_layers;
218   last_frame_layers.swap(last_frame_layers_ids_);
219 
220   for (const auto& layer : layers_)
221     last_frame_layers_ids_.push_back(layer.info.id);
222 
223   return last_frame_layers;
224 }
225 
SetColorTransform(const float * matrix,int32_t hint)226 void HwcDisplay::SetColorTransform(const float* matrix, int32_t hint) {
227   color_transform_hint_ = hint;
228   if (matrix)
229     memcpy(color_transform_, matrix, sizeof(color_transform_));
230 }
231 
dumpDebugInfo(std::string * result) const232 void HwcDisplay::dumpDebugInfo(std::string* result) const {
233   if (!result) {
234     return;
235   }
236   *result += StringPrintf("HwcDisplay: width: %d, height: %d, layers size: %zu, colormode: %d\
237       , config: %d\n", width_, height_, layers_.size(), color_mode_, active_config_);
238   *result += StringPrintf("HwcDisplay buffer metadata: width: %d, height: %d, stride: %d,\
239       layerCount: %d, pixelFormat: %d\n", buffer_metadata_.width, buffer_metadata_.height,
240       buffer_metadata_.stride, buffer_metadata_.layerCount, buffer_metadata_.format);
241   for (const auto& layer : layers_) {
242     layer.dumpDebugInfo(result);
243   }
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 // VrHwcClient
248 
VrHwc()249 VrHwc::VrHwc() {
250   vsync_callback_ = new VsyncCallback;
251 }
252 
~VrHwc()253 VrHwc::~VrHwc() {
254   vsync_callback_->SetEventCallback(nullptr);
255 }
256 
hasCapability(hwc2_capability_t)257 bool VrHwc::hasCapability(hwc2_capability_t /* capability */) { return false; }
258 
registerEventCallback(EventCallback * callback)259 void VrHwc::registerEventCallback(EventCallback* callback) {
260   std::unique_lock<std::mutex> lock(mutex_);
261   event_callback_ = callback;
262   int32_t width, height;
263   GetPrimaryDisplaySize(&width, &height);
264   // Create the primary display late to avoid initialization issues between
265   // VR HWC and SurfaceFlinger.
266   displays_[kDefaultDisplayId].reset(new HwcDisplay(width, height));
267 
268   // Surface flinger will make calls back into vr_hwc when it receives the
269   // onHotplug() call, so it's important to release mutex_ here.
270   lock.unlock();
271   event_callback_->onHotplug(kDefaultDisplayId,
272                              hardware::graphics::composer::V2_1::
273                                  IComposerCallback::Connection::CONNECTED);
274   lock.lock();
275   UpdateVsyncCallbackEnabledLocked();
276 }
277 
unregisterEventCallback()278 void VrHwc::unregisterEventCallback() {
279   std::lock_guard<std::mutex> guard(mutex_);
280   event_callback_ = nullptr;
281   UpdateVsyncCallbackEnabledLocked();
282 }
283 
getMaxVirtualDisplayCount()284 uint32_t VrHwc::getMaxVirtualDisplayCount() { return 1; }
285 
destroyVirtualDisplay(Display display)286 Error VrHwc::destroyVirtualDisplay(Display display) {
287   std::lock_guard<std::mutex> guard(mutex_);
288   if (display == kDefaultDisplayId || displays_.erase(display) == 0)
289     return Error::BAD_DISPLAY;
290   ComposerView::Frame frame;
291   frame.display_id = display;
292   frame.removed = true;
293   if (observer_)
294     observer_->OnNewFrame(frame);
295   return Error::NONE;
296 }
297 
createLayer(Display display,Layer * outLayer)298 Error VrHwc::createLayer(Display display, Layer* outLayer) {
299   std::lock_guard<std::mutex> guard(mutex_);
300   auto display_ptr = FindDisplay(display);
301   if (!display_ptr)
302     return Error::BAD_DISPLAY;
303 
304   HwcLayer* layer = display_ptr->CreateLayer();
305   *outLayer = layer->info.id;
306   return Error::NONE;
307 }
308 
destroyLayer(Display display,Layer layer)309 Error VrHwc::destroyLayer(Display display, Layer layer) {
310   std::lock_guard<std::mutex> guard(mutex_);
311   auto display_ptr = FindDisplay(display);
312   if (!display_ptr) {
313     return Error::BAD_DISPLAY;
314   }
315 
316   return display_ptr->DestroyLayer(layer) ? Error::NONE : Error::BAD_LAYER;
317 }
318 
getActiveConfig(Display display,Config * outConfig)319 Error VrHwc::getActiveConfig(Display display, Config* outConfig) {
320   std::lock_guard<std::mutex> guard(mutex_);
321   if (!FindDisplay(display))
322     return Error::BAD_DISPLAY;
323   *outConfig = kDefaultConfigId;
324   return Error::NONE;
325 }
326 
getDisplayAttribute(Display display,Config config,IComposerClient::Attribute attribute,int32_t * outValue)327 Error VrHwc::getDisplayAttribute(Display display, Config config,
328                                  IComposerClient::Attribute attribute,
329                                  int32_t* outValue) {
330   std::lock_guard<std::mutex> guard(mutex_);
331   auto display_ptr = FindDisplay(display);
332   if (!display_ptr) {
333     return Error::BAD_DISPLAY;
334   }
335   if (config != kDefaultConfigId) {
336     return Error::BAD_CONFIG;
337   }
338 
339   switch (attribute) {
340     case IComposerClient::Attribute::WIDTH:
341       *outValue = display_ptr->width();
342       break;
343     case IComposerClient::Attribute::HEIGHT:
344       *outValue = display_ptr->height();
345       break;
346     case IComposerClient::Attribute::VSYNC_PERIOD:
347       {
348         int error = 0;
349         auto display_client = display::DisplayClient::Create(&error);
350         if (!display_client) {
351           ALOGE("Could not connect to display service : %s(%d)",
352                 strerror(error), error);
353           // Return a default value of 30 fps
354           *outValue = 1000 * 1000 * 1000 / 30;
355         } else {
356           auto metrics = display_client->GetDisplayMetrics();
357           *outValue = metrics.get().vsync_period_ns;
358         }
359       }
360       break;
361     case IComposerClient::Attribute::DPI_X:
362     case IComposerClient::Attribute::DPI_Y:
363       {
364         constexpr int32_t kDefaultDPI = 300;
365         int32_t dpi = property_get_int32("ro.vr.hwc.dpi", kDefaultDPI);
366         if (dpi <= 0) {
367           dpi = kDefaultDPI;
368         }
369         *outValue = 1000 * dpi;
370       }
371       break;
372     default:
373       return Error::BAD_PARAMETER;
374   }
375 
376   return Error::NONE;
377 }
378 
getDisplayConfigs(Display display,hidl_vec<Config> * outConfigs)379 Error VrHwc::getDisplayConfigs(Display display, hidl_vec<Config>* outConfigs) {
380   std::lock_guard<std::mutex> guard(mutex_);
381   if (!FindDisplay(display))
382     return Error::BAD_DISPLAY;
383   std::vector<Config> configs(1, kDefaultConfigId);
384   *outConfigs = hidl_vec<Config>(configs);
385   return Error::NONE;
386 }
387 
getDisplayName(Display,hidl_string * outName)388 Error VrHwc::getDisplayName(Display /* display */, hidl_string* outName) {
389   *outName = hidl_string();
390   return Error::NONE;
391 }
392 
getDisplayType(Display display,IComposerClient::DisplayType * outType)393 Error VrHwc::getDisplayType(Display display,
394                             IComposerClient::DisplayType* outType) {
395   std::lock_guard<std::mutex> guard(mutex_);
396   auto display_ptr = FindDisplay(display);
397   if (!display_ptr) {
398     *outType = IComposerClient::DisplayType::INVALID;
399     return Error::BAD_DISPLAY;
400   }
401 
402   if (display == kDefaultDisplayId)
403     *outType = IComposerClient::DisplayType::PHYSICAL;
404   else
405     *outType = IComposerClient::DisplayType::VIRTUAL;
406 
407   return Error::NONE;
408 }
409 
getDozeSupport(Display display,bool * outSupport)410 Error VrHwc::getDozeSupport(Display display, bool* outSupport) {
411   *outSupport = false;
412   std::lock_guard<std::mutex> guard(mutex_);
413   if (!FindDisplay(display))
414     return Error::BAD_DISPLAY;
415   return Error::NONE;
416 }
417 
setActiveConfig(Display display,Config config)418 Error VrHwc::setActiveConfig(Display display, Config config) {
419   std::lock_guard<std::mutex> guard(mutex_);
420   auto display_ptr = FindDisplay(display);
421   if (!display_ptr)
422     return Error::BAD_DISPLAY;
423   if (config != kDefaultConfigId)
424     return Error::BAD_CONFIG;
425 
426   display_ptr->set_active_config(config);
427   return Error::NONE;
428 }
429 
setVsyncEnabled(Display display,IComposerClient::Vsync enabled)430 Error VrHwc::setVsyncEnabled(Display display, IComposerClient::Vsync enabled) {
431   std::lock_guard<std::mutex> guard(mutex_);
432   auto display_ptr = FindDisplay(display);
433   if (!display_ptr)
434     return Error::BAD_DISPLAY;
435 
436   if (enabled != IComposerClient::Vsync::ENABLE &&
437       enabled != IComposerClient::Vsync::DISABLE) {
438     return Error::BAD_PARAMETER;
439   }
440 
441   Error set_vsync_result = Error::NONE;
442   if (display == kDefaultDisplayId) {
443     sp<IVsyncService> vsync_service = interface_cast<IVsyncService>(
444         defaultServiceManager()->getService(
445             String16(IVsyncService::GetServiceName())));
446     if (vsync_service == nullptr) {
447       ALOGE("Failed to get vsync service");
448       return Error::NO_RESOURCES;
449     }
450 
451     if (enabled == IComposerClient::Vsync::ENABLE) {
452       ALOGI("Enable vsync");
453       display_ptr->set_vsync_enabled(true);
454       status_t result = vsync_service->registerCallback(vsync_callback_);
455       if (result != OK) {
456         ALOGE("%s service registerCallback() failed: %s (%d)",
457             IVsyncService::GetServiceName(), strerror(-result), result);
458         set_vsync_result = Error::NO_RESOURCES;
459       }
460     } else if (enabled == IComposerClient::Vsync::DISABLE) {
461       ALOGI("Disable vsync");
462       display_ptr->set_vsync_enabled(false);
463       status_t result = vsync_service->unregisterCallback(vsync_callback_);
464       if (result != OK) {
465         ALOGE("%s service unregisterCallback() failed: %s (%d)",
466             IVsyncService::GetServiceName(), strerror(-result), result);
467         set_vsync_result = Error::NO_RESOURCES;
468       }
469     }
470 
471     UpdateVsyncCallbackEnabledLocked();
472   }
473 
474   return set_vsync_result;
475 }
476 
setColorTransform(Display display,const float * matrix,int32_t hint)477 Error VrHwc::setColorTransform(Display display, const float* matrix,
478                                int32_t hint) {
479   std::lock_guard<std::mutex> guard(mutex_);
480   auto display_ptr = FindDisplay(display);
481   if (!display_ptr)
482     return Error::BAD_DISPLAY;
483 
484   display_ptr->SetColorTransform(matrix, hint);
485   return Error::NONE;
486 }
487 
setClientTarget(Display display,buffer_handle_t target,int32_t acquireFence,int32_t,const std::vector<hwc_rect_t> &)488 Error VrHwc::setClientTarget(Display display, buffer_handle_t target,
489                              int32_t acquireFence, int32_t /* dataspace */,
490                              const std::vector<hwc_rect_t>& /* damage */) {
491   base::unique_fd fence(acquireFence);
492   std::lock_guard<std::mutex> guard(mutex_);
493   auto display_ptr = FindDisplay(display);
494   if (!display_ptr)
495     return Error::BAD_DISPLAY;
496 
497   if (target == nullptr)
498     return Error::NONE;
499 
500   if (!display_ptr->SetClientTarget(target, std::move(fence)))
501     return Error::BAD_PARAMETER;
502 
503   return Error::NONE;
504 }
505 
setOutputBuffer(Display display,buffer_handle_t,int32_t releaseFence)506 Error VrHwc::setOutputBuffer(Display display, buffer_handle_t /* buffer */,
507                              int32_t releaseFence) {
508   base::unique_fd fence(releaseFence);
509   std::lock_guard<std::mutex> guard(mutex_);
510   auto display_ptr = FindDisplay(display);
511   if (!display_ptr)
512     return Error::BAD_DISPLAY;
513 
514   // TODO(dnicoara): Is it necessary to do anything here?
515   return Error::NONE;
516 }
517 
validateDisplay(Display display,std::vector<Layer> * outChangedLayers,std::vector<IComposerClient::Composition> * outCompositionTypes,uint32_t *,std::vector<Layer> *,std::vector<uint32_t> *)518 Error VrHwc::validateDisplay(
519     Display display, std::vector<Layer>* outChangedLayers,
520     std::vector<IComposerClient::Composition>* outCompositionTypes,
521     uint32_t* /* outDisplayRequestMask */,
522     std::vector<Layer>* /* outRequestedLayers */,
523     std::vector<uint32_t>* /* outRequestMasks */) {
524   std::lock_guard<std::mutex> guard(mutex_);
525   auto display_ptr = FindDisplay(display);
526   if (!display_ptr)
527     return Error::BAD_DISPLAY;
528 
529   display_ptr->GetChangedCompositionTypes(outChangedLayers,
530                                           outCompositionTypes);
531   return Error::NONE;
532 }
533 
acceptDisplayChanges(Display)534 Error VrHwc::acceptDisplayChanges(Display /* display */) { return Error::NONE; }
535 
presentDisplay(Display display,int32_t * outPresentFence,std::vector<Layer> * outLayers,std::vector<int32_t> * outReleaseFences)536 Error VrHwc::presentDisplay(Display display, int32_t* outPresentFence,
537                             std::vector<Layer>* outLayers,
538                             std::vector<int32_t>* outReleaseFences) {
539   *outPresentFence = -1;
540   outLayers->clear();
541   outReleaseFences->clear();
542 
543   std::lock_guard<std::mutex> guard(mutex_);
544   auto display_ptr = FindDisplay(display);
545 
546   if (!display_ptr)
547     return Error::BAD_DISPLAY;
548 
549   ComposerView::Frame frame;
550   std::vector<Layer> last_frame_layers;
551   Error status = display_ptr->GetFrame(&frame.layers);
552   frame.display_id = display;
553   frame.display_width = display_ptr->width();
554   frame.display_height = display_ptr->height();
555   frame.active_config = display_ptr->active_config();
556   frame.power_mode = display_ptr->power_mode();
557   frame.vsync_enabled = display_ptr->vsync_enabled() ?
558       IComposerClient::Vsync::ENABLE : IComposerClient::Vsync::DISABLE;
559   frame.color_transform_hint = display_ptr->color_transform_hint();
560   frame.color_mode = display_ptr->color_mode();
561   memcpy(frame.color_transform, display_ptr->color_transform(),
562          sizeof(frame.color_transform));
563   if (status != Error::NONE)
564     return status;
565 
566   last_frame_layers = display_ptr->UpdateLastFrameAndGetLastFrameLayers();
567 
568   base::unique_fd fence;
569   if (observer_)
570     fence = observer_->OnNewFrame(frame);
571 
572   if (fence.get() < 0)
573     return Error::NONE;
574 
575   *outPresentFence = dup(fence.get());
576   outLayers->swap(last_frame_layers);
577   for (size_t i = 0; i < outLayers->size(); ++i)
578     outReleaseFences->push_back(dup(fence.get()));
579 
580   return Error::NONE;
581 }
582 
setLayerCursorPosition(Display display,Layer layer,int32_t x,int32_t y)583 Error VrHwc::setLayerCursorPosition(Display display, Layer layer, int32_t x,
584                                     int32_t y) {
585   std::lock_guard<std::mutex> guard(mutex_);
586   auto display_ptr = FindDisplay(display);
587   if (!display_ptr)
588     return Error::BAD_DISPLAY;
589 
590   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
591   if (!hwc_layer)
592     return Error::BAD_LAYER;
593 
594   hwc_layer->info.cursor_x = x;
595   hwc_layer->info.cursor_y = y;
596   return Error::NONE;
597 }
598 
setLayerBuffer(Display display,Layer layer,buffer_handle_t buffer,int32_t acquireFence)599 Error VrHwc::setLayerBuffer(Display display, Layer layer,
600                             buffer_handle_t buffer, int32_t acquireFence) {
601   base::unique_fd fence(acquireFence);
602   std::lock_guard<std::mutex> guard(mutex_);
603   auto display_ptr = FindDisplay(display);
604   if (!display_ptr)
605     return Error::BAD_DISPLAY;
606 
607   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
608   if (!hwc_layer)
609     return Error::BAD_LAYER;
610 
611   hwc_layer->info.buffer = CreateGraphicBuffer(
612       buffer, hwc_layer->buffer_metadata);
613   hwc_layer->info.fence = new Fence(fence.release());
614 
615   return Error::NONE;
616 }
617 
setLayerSurfaceDamage(Display display,Layer layer,const std::vector<hwc_rect_t> & damage)618 Error VrHwc::setLayerSurfaceDamage(Display display, Layer layer,
619                                    const std::vector<hwc_rect_t>& damage) {
620   std::lock_guard<std::mutex> guard(mutex_);
621   auto display_ptr = FindDisplay(display);
622   if (!display_ptr)
623     return Error::BAD_DISPLAY;
624 
625   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
626   if (!hwc_layer)
627     return Error::BAD_LAYER;
628 
629   hwc_layer->info.damaged_regions = damage;
630   return Error::NONE;
631 }
632 
setLayerBlendMode(Display display,Layer layer,int32_t mode)633 Error VrHwc::setLayerBlendMode(Display display, Layer layer, int32_t mode) {
634   std::lock_guard<std::mutex> guard(mutex_);
635   auto display_ptr = FindDisplay(display);
636   if (!display_ptr)
637     return Error::BAD_DISPLAY;
638 
639   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
640   if (!hwc_layer)
641     return Error::BAD_LAYER;
642 
643   hwc_layer->info.blend_mode =
644       static_cast<ComposerView::ComposerLayer::BlendMode>(mode);
645 
646   return Error::NONE;
647 }
648 
setLayerColor(Display display,Layer layer,IComposerClient::Color color)649 Error VrHwc::setLayerColor(Display display, Layer layer,
650                            IComposerClient::Color color) {
651   std::lock_guard<std::mutex> guard(mutex_);
652   auto display_ptr = FindDisplay(display);
653   if (!display_ptr)
654     return Error::BAD_DISPLAY;
655 
656   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
657   if (!hwc_layer)
658     return Error::BAD_LAYER;
659 
660   hwc_layer->info.color = color;
661   return Error::NONE;
662 }
663 
setLayerCompositionType(Display display,Layer layer,int32_t type)664 Error VrHwc::setLayerCompositionType(Display display, Layer layer,
665                                      int32_t type) {
666   std::lock_guard<std::mutex> guard(mutex_);
667   auto display_ptr = FindDisplay(display);
668   if (!display_ptr)
669     return Error::BAD_DISPLAY;
670 
671   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
672   if (!hwc_layer)
673     return Error::BAD_LAYER;
674 
675   hwc_layer->composition_type = static_cast<HwcLayer::Composition>(type);
676 
677   return Error::NONE;
678 }
679 
setLayerDataspace(Display display,Layer layer,int32_t dataspace)680 Error VrHwc::setLayerDataspace(Display display, Layer layer,
681                                int32_t dataspace) {
682   std::lock_guard<std::mutex> guard(mutex_);
683   auto display_ptr = FindDisplay(display);
684   if (!display_ptr)
685     return Error::BAD_DISPLAY;
686 
687   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
688   if (!hwc_layer)
689     return Error::BAD_LAYER;
690 
691   hwc_layer->info.dataspace = dataspace;
692   return Error::NONE;
693 }
694 
setLayerDisplayFrame(Display display,Layer layer,const hwc_rect_t & frame)695 Error VrHwc::setLayerDisplayFrame(Display display, Layer layer,
696                                   const hwc_rect_t& frame) {
697   std::lock_guard<std::mutex> guard(mutex_);
698   auto display_ptr = FindDisplay(display);
699   if (!display_ptr)
700     return Error::BAD_DISPLAY;
701 
702   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
703   if (!hwc_layer)
704     return Error::BAD_LAYER;
705 
706   hwc_layer->info.display_frame =
707       {frame.left, frame.top, frame.right, frame.bottom};
708 
709   return Error::NONE;
710 }
711 
setLayerPlaneAlpha(Display display,Layer layer,float alpha)712 Error VrHwc::setLayerPlaneAlpha(Display display, Layer layer, float alpha) {
713   std::lock_guard<std::mutex> guard(mutex_);
714   auto display_ptr = FindDisplay(display);
715   if (!display_ptr)
716     return Error::BAD_DISPLAY;
717 
718   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
719   if (!hwc_layer)
720     return Error::BAD_LAYER;
721 
722   hwc_layer->info.alpha = alpha;
723 
724   return Error::NONE;
725 }
726 
setLayerSidebandStream(Display display,Layer,buffer_handle_t)727 Error VrHwc::setLayerSidebandStream(Display display, Layer /* layer */,
728                                     buffer_handle_t /* stream */) {
729   std::lock_guard<std::mutex> guard(mutex_);
730   if (!FindDisplay(display))
731     return Error::BAD_DISPLAY;
732   return Error::NONE;
733 }
734 
setLayerSourceCrop(Display display,Layer layer,const hwc_frect_t & crop)735 Error VrHwc::setLayerSourceCrop(Display display, Layer layer,
736                                 const hwc_frect_t& crop) {
737   std::lock_guard<std::mutex> guard(mutex_);
738   auto display_ptr = FindDisplay(display);
739   if (!display_ptr)
740     return Error::BAD_DISPLAY;
741 
742   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
743   if (!hwc_layer)
744     return Error::BAD_LAYER;
745 
746   hwc_layer->info.crop = {crop.left, crop.top, crop.right, crop.bottom};
747 
748   return Error::NONE;
749 }
750 
setLayerTransform(Display display,Layer layer,int32_t transform)751 Error VrHwc::setLayerTransform(Display display, Layer layer,
752                                int32_t transform) {
753   std::lock_guard<std::mutex> guard(mutex_);
754   auto display_ptr = FindDisplay(display);
755   if (!display_ptr)
756     return Error::BAD_DISPLAY;
757 
758   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
759   if (!hwc_layer)
760     return Error::BAD_LAYER;
761 
762   hwc_layer->info.transform = transform;
763   return Error::NONE;
764 }
765 
setLayerVisibleRegion(Display display,Layer layer,const std::vector<hwc_rect_t> & visible)766 Error VrHwc::setLayerVisibleRegion(Display display, Layer layer,
767                                    const std::vector<hwc_rect_t>& visible) {
768   std::lock_guard<std::mutex> guard(mutex_);
769   auto display_ptr = FindDisplay(display);
770   if (!display_ptr)
771     return Error::BAD_DISPLAY;
772 
773   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
774   if (!hwc_layer)
775     return Error::BAD_LAYER;
776 
777   hwc_layer->info.visible_regions = visible;
778   return Error::NONE;
779 }
780 
setLayerZOrder(Display display,Layer layer,uint32_t z)781 Error VrHwc::setLayerZOrder(Display display, Layer layer, uint32_t z) {
782   std::lock_guard<std::mutex> guard(mutex_);
783   auto display_ptr = FindDisplay(display);
784   if (!display_ptr)
785     return Error::BAD_DISPLAY;
786 
787   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
788   if (!hwc_layer)
789     return Error::BAD_LAYER;
790 
791   hwc_layer->info.z_order = z;
792 
793   return Error::NONE;
794 }
795 
setLayerInfo(Display display,Layer layer,uint32_t type,uint32_t appId)796 Error VrHwc::setLayerInfo(Display display, Layer layer, uint32_t type,
797                           uint32_t appId) {
798   std::lock_guard<std::mutex> guard(mutex_);
799   auto display_ptr = FindDisplay(display);
800   if (!display_ptr)
801     return Error::BAD_DISPLAY;
802 
803   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
804   if (!hwc_layer)
805     return Error::BAD_LAYER;
806 
807   hwc_layer->info.type = type;
808   hwc_layer->info.app_id = appId;
809 
810   return Error::NONE;
811 }
812 
setClientTargetMetadata(Display display,const IVrComposerClient::BufferMetadata & metadata)813 Error VrHwc::setClientTargetMetadata(
814     Display display, const IVrComposerClient::BufferMetadata& metadata) {
815   std::lock_guard<std::mutex> guard(mutex_);
816   auto display_ptr = FindDisplay(display);
817   if (!display_ptr)
818     return Error::BAD_DISPLAY;
819 
820   display_ptr->SetClientTargetMetadata(metadata);
821 
822   return Error::NONE;
823 }
824 
setLayerBufferMetadata(Display display,Layer layer,const IVrComposerClient::BufferMetadata & metadata)825 Error VrHwc::setLayerBufferMetadata(
826     Display display, Layer layer,
827     const IVrComposerClient::BufferMetadata& metadata) {
828   std::lock_guard<std::mutex> guard(mutex_);
829   auto display_ptr = FindDisplay(display);
830   if (!display_ptr)
831     return Error::BAD_DISPLAY;
832 
833   HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
834   if (!hwc_layer)
835     return Error::BAD_LAYER;
836 
837   hwc_layer->buffer_metadata = metadata;
838 
839   return Error::NONE;
840 }
841 
getCapabilities(getCapabilities_cb hidl_cb)842 Return<void> VrHwc::getCapabilities(getCapabilities_cb hidl_cb) {
843   hidl_cb(hidl_vec<Capability>());
844   return Void();
845 }
846 
dumpDebugInfo(dumpDebugInfo_cb hidl_cb)847 Return<void> VrHwc::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
848   std::string result;
849 
850   {
851     std::lock_guard<std::mutex> guard(mutex_);
852     result = "\nVrHwc states:\n";
853     for (const auto& pair : displays_) {
854       result += StringPrintf("Display id: %lu\n", (unsigned long)pair.first);
855       pair.second->dumpDebugInfo(&result);
856     }
857     result += "\n";
858   }
859 
860   hidl_cb(hidl_string(result));
861   return Void();
862 }
863 
createClient(createClient_cb hidl_cb)864 Return<void> VrHwc::createClient(createClient_cb hidl_cb) {
865   std::lock_guard<std::mutex> guard(mutex_);
866 
867   Error status = Error::NONE;
868   sp<VrComposerClient> client;
869   if (!client_.promote().get()) {
870     client = new VrComposerClient(*this);
871   } else {
872     ALOGE("Already have a client");
873     status = Error::NO_RESOURCES;
874   }
875 
876   client_ = client;
877   hidl_cb(status, client);
878   return Void();
879 }
880 
createClient_2_3(IComposer::createClient_2_3_cb hidl_cb)881 Return<void> VrHwc::createClient_2_3(IComposer::createClient_2_3_cb hidl_cb) {
882   std::lock_guard<std::mutex> guard(mutex_);
883 
884   Error status = Error::NONE;
885   sp<VrComposerClient> client;
886   if (!client_.promote().get()) {
887     client = new VrComposerClient(*this);
888   } else {
889     ALOGE("Already have a client");
890     status = Error::NO_RESOURCES;
891   }
892 
893   client_ = client;
894   hidl_cb(status, client);
895   return Void();
896 }
897 
ForceDisplaysRefresh()898 void VrHwc::ForceDisplaysRefresh() {
899   std::lock_guard<std::mutex> guard(mutex_);
900   if (event_callback_ != nullptr) {
901     for (const auto& pair : displays_)
902       event_callback_->onRefresh(pair.first);
903   }
904 }
905 
RegisterObserver(Observer * observer)906 void VrHwc::RegisterObserver(Observer* observer) {
907   std::lock_guard<std::mutex> guard(mutex_);
908   if (observer_)
909     ALOGE("Overwriting observer");
910   else
911     observer_ = observer;
912 }
913 
UnregisterObserver(Observer * observer)914 void VrHwc::UnregisterObserver(Observer* observer) {
915   std::lock_guard<std::mutex> guard(mutex_);
916   if (observer != observer_)
917     ALOGE("Trying to unregister unknown observer");
918   else
919     observer_ = nullptr;
920 }
921 
FindDisplay(Display display)922 HwcDisplay* VrHwc::FindDisplay(Display display) {
923   auto iter = displays_.find(display);
924   return iter == displays_.end() ? nullptr : iter->second.get();
925 }
926 
UpdateVsyncCallbackEnabledLocked()927 void VrHwc::UpdateVsyncCallbackEnabledLocked() {
928   auto primary_display = FindDisplay(kDefaultDisplayId);
929   LOG_ALWAYS_FATAL_IF(event_callback_ != nullptr && primary_display == nullptr,
930       "Should have created the primary display by now");
931   bool send_vsync =
932       event_callback_ != nullptr && primary_display->vsync_enabled();
933   vsync_callback_->SetEventCallback(send_vsync ? event_callback_ : nullptr);
934 }
935 
debug(const hidl_handle & fd,const hidl_vec<hidl_string> & args)936 Return<void> VrHwc::debug(const hidl_handle& fd,
937                           const hidl_vec<hidl_string>& args) {
938   std::string result;
939 
940   {
941     std::lock_guard<std::mutex> guard(mutex_);
942     for (const auto& pair : displays_) {
943       result += StringPrintf("Display id: %d\n", static_cast<int>(pair.first));
944       pair.second->dumpDebugInfo(&result);
945     }
946     result += "\n";
947   }
948 
949   FILE* out = fdopen(dup(fd->data[0]), "w");
950   fprintf(out, "%s", result.c_str());
951   fclose(out);
952 
953   return Void();
954 }
955 
dumpDebugInfo(std::string * result) const956 void HwcLayer::dumpDebugInfo(std::string* result) const {
957   if (!result) {
958     return;
959   }
960   *result += StringPrintf("Layer: composition_type: %d, type: %d, app_id: %d, z_order: %d,\
961       cursor_x: %d, cursor_y: %d, color(rgba): (%d,%d,%d,%d), dataspace: %d, transform: %d,\
962       display_frame(LTRB): (%d,%d,%d,%d), crop(LTRB): (%.1f,%.1f,%.1f,%.1f), blend_mode: %d\n",
963       composition_type, info.type, info.app_id, info.z_order, info.cursor_x, info.cursor_y,
964       info.color.r, info.color.g, info.color.b, info.color.a, info.dataspace, info.transform,
965       info.display_frame.left, info.display_frame.top, info.display_frame.right,
966       info.display_frame.bottom, info.crop.left, info.crop.top, info.crop.right,
967       info.crop.bottom, info.blend_mode);
968   *result += StringPrintf("Layer buffer metadata: width: %d, height: %d, stride: %d, layerCount: %d\
969       , pixelFormat: %d\n", buffer_metadata.width, buffer_metadata.height, buffer_metadata.stride,
970       buffer_metadata.layerCount, buffer_metadata.format);
971 }
972 
onVsync(int64_t vsync_timestamp)973 status_t VrHwc::VsyncCallback::onVsync(int64_t vsync_timestamp) {
974   ATRACE_NAME("vr_hwc onVsync");
975   std::lock_guard<std::mutex> guard(mutex_);
976   if (callback_ != nullptr)
977     callback_->onVsync(kDefaultDisplayId, vsync_timestamp);
978   return OK;
979 }
980 
SetEventCallback(EventCallback * callback)981 void VrHwc::VsyncCallback::SetEventCallback(EventCallback* callback) {
982   std::lock_guard<std::mutex> guard(mutex_);
983   callback_ = callback;
984 }
985 
986 // composer::V2_2::ComposerHal
setReadbackBuffer(Display display,const native_handle_t * bufferHandle,android::base::unique_fd fenceFd)987 Error VrHwc::setReadbackBuffer(Display display,
988                                const native_handle_t* bufferHandle,
989                                android::base::unique_fd fenceFd) {
990   return Error::NONE;
991 }
992 
getReadbackBufferFence(Display display,android::base::unique_fd * outFenceFd)993 Error VrHwc::getReadbackBufferFence(Display display,
994                                     android::base::unique_fd* outFenceFd) {
995   return Error::NONE;
996 }
997 
createVirtualDisplay_2_2(uint32_t width,uint32_t height,types::V1_1::PixelFormat * format,Display * outDisplay)998 Error VrHwc::createVirtualDisplay_2_2(uint32_t width, uint32_t height,
999                                       types::V1_1::PixelFormat* format,
1000                                       Display* outDisplay) {
1001   *format = types::V1_1::PixelFormat::RGBA_8888;
1002   *outDisplay = display_count_;
1003   displays_[display_count_].reset(new HwcDisplay(width, height));
1004   display_count_++;
1005   return Error::NONE;
1006 }
1007 
setPowerMode_2_2(Display display,IComposerClient::PowerMode mode)1008 Error VrHwc::setPowerMode_2_2(Display display,
1009                               IComposerClient::PowerMode mode) {
1010   bool dozeSupported = false;
1011 
1012   Error dozeSupportError = getDozeSupport(display, &dozeSupported);
1013 
1014   if (dozeSupportError != Error::NONE)
1015     return dozeSupportError;
1016 
1017   std::lock_guard<std::mutex> guard(mutex_);
1018   auto display_ptr = FindDisplay(display);
1019   if (!display_ptr)
1020     return Error::BAD_DISPLAY;
1021 
1022   if (mode < IComposerClient::PowerMode::OFF ||
1023       mode > IComposerClient::PowerMode::DOZE_SUSPEND) {
1024     return Error::BAD_PARAMETER;
1025   }
1026 
1027   if (!dozeSupported && (mode == IComposerClient::PowerMode::DOZE ||
1028                          mode == IComposerClient::PowerMode::DOZE_SUSPEND)) {
1029     return Error::UNSUPPORTED;
1030   }
1031 
1032   display_ptr->set_power_mode(mode);
1033   return Error::NONE;
1034 }
1035 
setLayerFloatColor(Display display,Layer layer,IComposerClient::FloatColor color)1036 Error VrHwc::setLayerFloatColor(Display display, Layer layer,
1037                                 IComposerClient::FloatColor color) {
1038   return Error::NONE;
1039 }
1040 
getRenderIntents(Display display,types::V1_1::ColorMode mode,std::vector<RenderIntent> * outIntents)1041 Error VrHwc::getRenderIntents(Display display, types::V1_1::ColorMode mode,
1042                               std::vector<RenderIntent>* outIntents) {
1043   return Error::NONE;
1044 }
1045 
getDataspaceSaturationMatrix(types::V1_1::Dataspace dataspace)1046 std::array<float, 16> VrHwc::getDataspaceSaturationMatrix(
1047     types::V1_1::Dataspace dataspace) {
1048   return {};
1049 }
1050 
1051 // composer::V2_3::ComposerHal
getHdrCapabilities_2_3(Display,hidl_vec<Hdr> *,float * outMaxLuminance,float * outMaxAverageLuminance,float * outMinLuminance)1052 Error VrHwc::getHdrCapabilities_2_3(Display /*display*/,
1053                                     hidl_vec<Hdr>* /*outTypes*/,
1054                                     float* outMaxLuminance,
1055                                     float* outMaxAverageLuminance,
1056                                     float* outMinLuminance) {
1057   *outMaxLuminance = 0;
1058   *outMaxAverageLuminance = 0;
1059   *outMinLuminance = 0;
1060   return Error::NONE;
1061 }
1062 
setLayerPerFrameMetadata_2_3(Display display,Layer layer,const std::vector<IComposerClient::PerFrameMetadata> & metadata)1063 Error VrHwc::setLayerPerFrameMetadata_2_3(
1064     Display display, Layer layer,
1065     const std::vector<IComposerClient::PerFrameMetadata>& metadata) {
1066   return Error::NONE;
1067 }
1068 
getPerFrameMetadataKeys_2_3(Display display,std::vector<IComposerClient::PerFrameMetadataKey> * outKeys)1069 Error VrHwc::getPerFrameMetadataKeys_2_3(
1070     Display display,
1071     std::vector<IComposerClient::PerFrameMetadataKey>* outKeys) {
1072   return Error::NONE;
1073 }
1074 
setColorMode_2_3(Display display,ColorMode mode,RenderIntent intent)1075 Error VrHwc::setColorMode_2_3(Display display, ColorMode mode,
1076                               RenderIntent intent) {
1077   std::lock_guard<std::mutex> guard(mutex_);
1078   auto display_ptr = FindDisplay(display);
1079   if (!display_ptr)
1080     return Error::BAD_DISPLAY;
1081 
1082   if (mode < ColorMode::NATIVE || mode > ColorMode::DISPLAY_P3)
1083     return Error::BAD_PARAMETER;
1084 
1085   display_ptr->set_color_mode(mode);
1086   return Error::NONE;
1087 }
1088 
getRenderIntents_2_3(Display display,ColorMode mode,std::vector<RenderIntent> * outIntents)1089 Error VrHwc::getRenderIntents_2_3(Display display, ColorMode mode,
1090                                   std::vector<RenderIntent>* outIntents) {
1091   return Error::NONE;
1092 }
1093 
getColorModes_2_3(Display display,hidl_vec<ColorMode> * outModes)1094 Error VrHwc::getColorModes_2_3(Display display, hidl_vec<ColorMode>* outModes) {
1095   return Error::NONE;
1096 }
1097 
getClientTargetSupport_2_3(Display display,uint32_t width,uint32_t height,PixelFormat format,Dataspace dataspace)1098 Error VrHwc::getClientTargetSupport_2_3(Display display, uint32_t width,
1099                                         uint32_t height, PixelFormat format,
1100                                         Dataspace dataspace) {
1101   return Error::NONE;
1102 }
1103 
getReadbackBufferAttributes_2_3(Display display,PixelFormat * outFormat,Dataspace * outDataspace)1104 Error VrHwc::getReadbackBufferAttributes_2_3(Display display,
1105                                              PixelFormat* outFormat,
1106                                              Dataspace* outDataspace) {
1107   return Error::NONE;
1108 }
1109 
getDisplayIdentificationData(Display display,uint8_t * outPort,std::vector<uint8_t> * outData)1110 Error VrHwc::getDisplayIdentificationData(Display display, uint8_t* outPort,
1111                                           std::vector<uint8_t>* outData) {
1112   int error = 0;
1113   auto display_client = display::DisplayClient::Create(&error);
1114   if (!display_client) {
1115     ALOGE("Could not connect to display service : %s(%d)", strerror(error),
1116           error);
1117     return Error::BAD_CONFIG;
1118   }
1119   auto edid_data = display_client->GetConfigurationData(
1120       display::ConfigFileType::kDeviceEdid);
1121   auto display_identification_port =
1122       display_client->GetDisplayIdentificationPort();
1123   *outPort = display_identification_port.get();
1124 
1125   std::copy(edid_data.get().begin(), edid_data.get().end(),
1126             std::back_inserter(*outData));
1127   return Error::NONE;
1128 }
1129 
setLayerColorTransform(Display display,Layer layer,const float * matrix)1130 Error VrHwc::setLayerColorTransform(Display display, Layer layer,
1131                                     const float* matrix) {
1132   return Error::NONE;
1133 }
1134 
getDisplayedContentSamplingAttributes(Display display,PixelFormat & format,Dataspace & dataspace,hidl_bitfield<IComposerClient::FormatColorComponent> & componentMask)1135 Error VrHwc::getDisplayedContentSamplingAttributes(
1136     Display display, PixelFormat& format, Dataspace& dataspace,
1137     hidl_bitfield<IComposerClient::FormatColorComponent>& componentMask) {
1138   return Error::NONE;
1139 }
1140 
setDisplayedContentSamplingEnabled(Display display,IComposerClient::DisplayedContentSampling enable,hidl_bitfield<IComposerClient::FormatColorComponent> componentMask,uint64_t maxFrames)1141 Error VrHwc::setDisplayedContentSamplingEnabled(
1142     Display display, IComposerClient::DisplayedContentSampling enable,
1143     hidl_bitfield<IComposerClient::FormatColorComponent> componentMask,
1144     uint64_t maxFrames) {
1145   return Error::NONE;
1146 }
1147 
getDisplayedContentSample(Display display,uint64_t maxFrames,uint64_t timestamp,uint64_t & frameCount,hidl_vec<uint64_t> & sampleComponent0,hidl_vec<uint64_t> & sampleComponent1,hidl_vec<uint64_t> & sampleComponent2,hidl_vec<uint64_t> & sampleComponent3)1148 Error VrHwc::getDisplayedContentSample(Display display, uint64_t maxFrames,
1149                                        uint64_t timestamp, uint64_t& frameCount,
1150                                        hidl_vec<uint64_t>& sampleComponent0,
1151                                        hidl_vec<uint64_t>& sampleComponent1,
1152                                        hidl_vec<uint64_t>& sampleComponent2,
1153                                        hidl_vec<uint64_t>& sampleComponent3) {
1154   return Error::NONE;
1155 }
1156 
getDisplayCapabilities(Display display,std::vector<IComposerClient::DisplayCapability> * outCapabilities)1157 Error VrHwc::getDisplayCapabilities(
1158     Display display,
1159     std::vector<IComposerClient::DisplayCapability>* outCapabilities) {
1160   return Error::NONE;
1161 }
1162 
setLayerPerFrameMetadataBlobs(Display display,Layer layer,std::vector<IComposerClient::PerFrameMetadataBlob> & blobs)1163 Error VrHwc::setLayerPerFrameMetadataBlobs(
1164     Display display, Layer layer,
1165     std::vector<IComposerClient::PerFrameMetadataBlob>& blobs) {
1166   return Error::NONE;
1167 }
1168 
getDisplayBrightnessSupport(Display display,bool * outSupport)1169 Error VrHwc::getDisplayBrightnessSupport(Display display, bool* outSupport) {
1170   return Error::NONE;
1171 }
1172 
setDisplayBrightness(Display display,float brightness)1173 Error VrHwc::setDisplayBrightness(Display display, float brightness) {
1174   return Error::NONE;
1175 }
1176 
1177 }  // namespace dvr
1178 }  // namespace android
1179