Re: [PATCH hwc v2 08/18] drm_hwcomposer: Parse and store possible_clones information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 11, 2018 at 04:22:19PM +0100, Alexandru Gheorghe wrote:
> drmModeEncoder has a field called possible_clones. It's a bit mask
> which tells if the encoder could be simultaneously connected, to the
> same CRTC, with the encoders specified in the possible_clones mask.
> 
> Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@xxxxxxx>
> ---
>  drmencoder.cpp   | 8 ++++++++
>  drmencoder.h     | 4 ++++
>  drmresources.cpp | 9 ++++++++-
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drmencoder.cpp b/drmencoder.cpp
> index 1da7ec3..ff675f5 100644
> --- a/drmencoder.cpp
> +++ b/drmencoder.cpp
> @@ -39,6 +39,14 @@ DrmCrtc *DrmEncoder::crtc() const {
>    return crtc_;
>  }
>  
> +bool DrmEncoder::can_clone(DrmEncoder *encoder) {
> +  return possible_clones_.find(encoder) != possible_clones_.end();
> +}

The find() call is probably enough to justify CamelCase for this function. FTR,
I _hate_ this part of the style guide and wish I had just picked one or the
other.

To improve readability, can you also change the name of "encoder" to
"possible_clone" like below so it's super obvious what this does?

> +
> +void DrmEncoder::add_possible_clone(DrmEncoder *possible_clone) {
> +  possible_clones_[possible_clone] = true;
> +}
> +
>  void DrmEncoder::set_crtc(DrmCrtc *crtc) {
>    crtc_ = crtc;
>    set_display(crtc->display());
> diff --git a/drmencoder.h b/drmencoder.h
> index 7e06691..5e7c010 100644
> --- a/drmencoder.h
> +++ b/drmencoder.h
> @@ -21,6 +21,7 @@
>  
>  #include <stdint.h>
>  #include <vector>
> +#include <map>

Alphabetical

>  #include <xf86drmMode.h>
>  
>  namespace android {
> @@ -43,6 +44,8 @@ class DrmEncoder {
>    const std::vector<DrmCrtc *> &possible_crtcs() const {
>      return possible_crtcs_;
>    }
> +  bool can_clone(DrmEncoder *encoder);
> +  void add_possible_clone(DrmEncoder *possible_clone);
>  
>   private:
>    uint32_t id_;
> @@ -50,6 +53,7 @@ class DrmEncoder {
>    int display_;
>  
>    std::vector<DrmCrtc *> possible_crtcs_;
> +  std::map<DrmEncoder *, bool> possible_clones_;
>  };
>  }
>  
> diff --git a/drmresources.cpp b/drmresources.cpp
> index a5ddda0..39f50be 100644
> --- a/drmresources.cpp
> +++ b/drmresources.cpp
> @@ -97,6 +97,7 @@ int DrmResources::Init(ResourceManager *resource_manager, char *path,
>      crtcs_.emplace_back(std::move(crtc));
>    }
>  
> +  std::vector<int> possible_clones;
>    for (int i = 0; !ret && i < res->count_encoders; ++i) {
>      drmModeEncoderPtr e = drmModeGetEncoder(fd(), res->encoders[i]);
>      if (!e) {
> @@ -117,12 +118,18 @@ int DrmResources::Init(ResourceManager *resource_manager, char *path,
>  
>      std::unique_ptr<DrmEncoder> enc(
>          new DrmEncoder(e, current_crtc, possible_crtcs));
> -
> +    possible_clones.push_back(e->possible_clones);
>      drmModeFreeEncoder(e);
>  
>      encoders_.emplace_back(std::move(enc));
>    }
>  
> +  for (uint32_t i = 0; i < encoders_.size(); i++) {
> +    for (uint32_t j = 0; j < encoders_.size(); j++)

for (auto &enc: encoders_) {
  for (auto &clone: encoders_) {

Or something similarly C++'y, looping through indices is sooo last decade :-)


> +      if (possible_clones[i] & (1 << j))
> +        encoders_[i]->add_possible_clone(encoders_[j].get());
> +  }
> +
>    for (int i = 0; !ret && i < res->count_connectors; ++i) {
>      drmModeConnectorPtr c = drmModeGetConnector(fd(), res->connectors[i]);
>      if (!c) {
> -- 
> 2.7.4
> 

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux