Skip to content

Commit

Permalink
Merge pull request xbmc#17650 from lrusak/drm-properties
Browse files Browse the repository at this point in the history
[GBM] CVideoLayerBridgeDRMPRIME: query supported values before setting them
  • Loading branch information
lrusak authored and Maven85 committed Aug 7, 2020
1 parent 6b4c319 commit 1ab320e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,11 @@ void CVideoLayerBridgeDRMPRIME::Configure(CVideoBufferDRMPRIME* buffer)
const VideoPicture& picture = buffer->GetPicture();

struct plane* plane = m_DRM->GetVideoPlane();
if (m_DRM->SupportsProperty(plane, "COLOR_ENCODING") &&
m_DRM->SupportsProperty(plane, "COLOR_RANGE"))
{
if (m_DRM->SupportsPropertyAndValue(plane, "COLOR_ENCODING", GetColorEncoding(picture)))
m_DRM->AddProperty(plane, "COLOR_ENCODING", GetColorEncoding(picture));

if (m_DRM->SupportsPropertyAndValue(plane, "COLOR_RANGE", GetColorRange(picture)))
m_DRM->AddProperty(plane, "COLOR_RANGE", GetColorRange(picture));
}

struct connector* connector = m_DRM->GetConnector();
if (m_DRM->SupportsProperty(connector, "HDR_OUTPUT_METADATA"))
Expand Down
26 changes: 26 additions & 0 deletions xbmc/windowing/gbm/DRMUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,32 @@ bool CDRMUtils::SupportsProperty(struct drm_object *object, const char *name)
return false;
}

bool CDRMUtils::SupportsPropertyAndValue(struct drm_object* object,
const char* name,
uint64_t value)
{
for (uint32_t i = 0; i < object->props->count_props; i++)
{
if (!StringUtils::EqualsNoCase(object->props_info[i]->name, name))
continue;

if (drm_property_type_is(object->props_info[i], DRM_MODE_PROP_ENUM) != 0)
{
for (int j = 0; j < object->props_info[i]->count_enums; j++)
{
if (object->props_info[i]->enums[j].value == value)
return true;
}
}

CLog::Log(LOGDEBUG, "CDRMUtils::{} - property '{}' does not support value '{}'", __FUNCTION__,
name, value);
break;
}

return false;
}

uint32_t CDRMUtils::GetPropertyId(struct drm_object *object, const char *name)
{
for (uint32_t i = 0; i < object->props->count_props; i++)
Expand Down
1 change: 1 addition & 0 deletions xbmc/windowing/gbm/DRMUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class CDRMUtils
virtual bool SetMode(const RESOLUTION_INFO& res);

bool SupportsProperty(struct drm_object *object, const char *name);
bool SupportsPropertyAndValue(struct drm_object* object, const char* name, uint64_t value);
virtual bool AddProperty(struct drm_object *object, const char *name, uint64_t value) { return false; }
virtual bool SetProperty(struct drm_object *object, const char *name, uint64_t value) { return false; }

Expand Down

0 comments on commit 1ab320e

Please sign in to comment.