mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
reformat missing files
This commit is contained in:
parent
177e44de98
commit
43135c43bc
2
Makefile
2
Makefile
@ -393,7 +393,7 @@ clean:
|
|||||||
|
|
||||||
HDRS = $(wildcard *.h)
|
HDRS = $(wildcard *.h)
|
||||||
indent:
|
indent:
|
||||||
for i in $(SRCS) $(HDRS); do \
|
for i in $(SRCS) drm.c hdr.c $(HDRS); do \
|
||||||
clang-format -i $$i; \
|
clang-format -i $$i; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
200
drm.c
200
drm.c
@ -1,9 +1,7 @@
|
|||||||
#include <unistd.h>
|
#include <drm_fourcc.h>
|
||||||
#include <gbm.h>
|
#include <gbm.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <xf86drm.h>
|
#include <unistd.h>
|
||||||
#include <xf86drmMode.h>
|
|
||||||
#include <drm_fourcc.h>
|
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
|
|
||||||
@ -13,8 +11,7 @@
|
|||||||
// DRM
|
// DRM
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
struct _Drm_Render_
|
struct _Drm_Render_ {
|
||||||
{
|
|
||||||
int fd_drm;
|
int fd_drm;
|
||||||
drmModeModeInfo mode;
|
drmModeModeInfo mode;
|
||||||
drmModeCrtc *saved_crtc;
|
drmModeCrtc *saved_crtc;
|
||||||
@ -24,7 +21,6 @@ struct _Drm_Render_
|
|||||||
uint32_t hdr_metadata;
|
uint32_t hdr_metadata;
|
||||||
uint32_t mmWidth, mmHeight; // Size in mm
|
uint32_t mmWidth, mmHeight; // Size in mm
|
||||||
uint32_t hdr_blob_id;
|
uint32_t hdr_blob_id;
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef struct _Drm_Render_ VideoRender;
|
typedef struct _Drm_Render_ VideoRender;
|
||||||
|
|
||||||
@ -46,10 +42,7 @@ struct type_name {
|
|||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *util_lookup_type_name(unsigned int type,
|
static const char *util_lookup_type_name(unsigned int type, const struct type_name *table, unsigned int count) {
|
||||||
const struct type_name *table,
|
|
||||||
unsigned int count)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
@ -80,21 +73,16 @@ static const struct type_name connector_type_names[] = {
|
|||||||
{DRM_MODE_CONNECTOR_DPI, "DPI"},
|
{DRM_MODE_CONNECTOR_DPI, "DPI"},
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *util_lookup_connector_type_name(unsigned int type)
|
const char *util_lookup_connector_type_name(unsigned int type) {
|
||||||
{
|
return util_lookup_type_name(type, connector_type_names, ARRAY_SIZE(connector_type_names));
|
||||||
return util_lookup_type_name(type, connector_type_names,
|
|
||||||
ARRAY_SIZE(connector_type_names));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t GetPropertyValue(int fd_drm, uint32_t objectID,
|
static uint64_t GetPropertyValue(int fd_drm, uint32_t objectID, uint32_t objectType, const char *propName) {
|
||||||
uint32_t objectType, const char *propName)
|
|
||||||
{
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
uint64_t value = 0;
|
uint64_t value = 0;
|
||||||
drmModePropertyPtr Prop;
|
drmModePropertyPtr Prop;
|
||||||
drmModeObjectPropertiesPtr objectProps =
|
drmModeObjectPropertiesPtr objectProps = drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
||||||
drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
|
||||||
|
|
||||||
for (i = 0; i < objectProps->count_props; i++) {
|
for (i = 0; i < objectProps->count_props; i++) {
|
||||||
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
||||||
@ -115,20 +103,16 @@ static uint64_t GetPropertyValue(int fd_drm, uint32_t objectID,
|
|||||||
|
|
||||||
#ifdef DRM_DEBUG
|
#ifdef DRM_DEBUG
|
||||||
if (!found)
|
if (!found)
|
||||||
fprintf(stderr, "GetPropertyValue: Unable to find value for property \'%s\'.\n",
|
fprintf(stderr, "GetPropertyValue: Unable to find value for property \'%s\'.\n", propName);
|
||||||
propName);
|
|
||||||
#endif
|
#endif
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
static uint32_t GetPropertyID(int fd_drm, uint32_t objectID,
|
static uint32_t GetPropertyID(int fd_drm, uint32_t objectID, uint32_t objectType, const char *propName) {
|
||||||
uint32_t objectType, const char *propName)
|
|
||||||
{
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
uint32_t value = -1;
|
uint32_t value = -1;
|
||||||
drmModePropertyPtr Prop;
|
drmModePropertyPtr Prop;
|
||||||
drmModeObjectPropertiesPtr objectProps =
|
drmModeObjectPropertiesPtr objectProps = drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
||||||
drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
|
||||||
|
|
||||||
for (i = 0; i < objectProps->count_props; i++) {
|
for (i = 0; i < objectProps->count_props; i++) {
|
||||||
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
||||||
@ -151,15 +135,12 @@ static uint32_t GetPropertyID(int fd_drm, uint32_t objectID,
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SetPropertyRequest(drmModeAtomicReqPtr ModeReq, int fd_drm,
|
static int SetPropertyRequest(drmModeAtomicReqPtr ModeReq, int fd_drm, uint32_t objectID, uint32_t objectType,
|
||||||
uint32_t objectID, uint32_t objectType,
|
const char *propName, uint64_t value) {
|
||||||
const char *propName, uint64_t value)
|
|
||||||
{
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint64_t id = 0;
|
uint64_t id = 0;
|
||||||
drmModePropertyPtr Prop;
|
drmModePropertyPtr Prop;
|
||||||
drmModeObjectPropertiesPtr objectProps =
|
drmModeObjectPropertiesPtr objectProps = drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
||||||
drmModeObjectGetProperties(fd_drm, objectID, objectType);
|
|
||||||
|
|
||||||
for (i = 0; i < objectProps->count_props; i++) {
|
for (i = 0; i < objectProps->count_props; i++) {
|
||||||
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
if ((Prop = drmModeGetProperty(fd_drm, objectProps->props[i])) == NULL)
|
||||||
@ -177,15 +158,13 @@ static int SetPropertyRequest(drmModeAtomicReqPtr ModeReq, int fd_drm,
|
|||||||
drmModeFreeObjectProperties(objectProps);
|
drmModeFreeObjectProperties(objectProps);
|
||||||
|
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
printf( "SetPropertyRequest: Unable to find value for property \'%s\'.\n",
|
printf("SetPropertyRequest: Unable to find value for property \'%s\'.\n", propName);
|
||||||
propName);
|
|
||||||
|
|
||||||
return drmModeAtomicAddProperty(ModeReq, objectID, id, value);
|
return drmModeAtomicAddProperty(ModeReq, objectID, id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CuvidSetVideoMode(void);
|
static void CuvidSetVideoMode(void);
|
||||||
void set_video_mode(int width, int height)
|
void set_video_mode(int width, int height) {
|
||||||
{
|
|
||||||
drmModeConnector *connector;
|
drmModeConnector *connector;
|
||||||
drmModeModeInfo *mode;
|
drmModeModeInfo *mode;
|
||||||
int ii;
|
int ii;
|
||||||
@ -195,11 +174,8 @@ void set_video_mode(int width, int height)
|
|||||||
for (ii = 0; ii < connector->count_modes; ii++) {
|
for (ii = 0; ii < connector->count_modes; ii++) {
|
||||||
mode = &connector->modes[ii];
|
mode = &connector->modes[ii];
|
||||||
printf("Mode %d %dx%d Rate %d\n", ii, mode->hdisplay, mode->vdisplay, mode->vrefresh);
|
printf("Mode %d %dx%d Rate %d\n", ii, mode->hdisplay, mode->vdisplay, mode->vrefresh);
|
||||||
if (width == mode->hdisplay &&
|
if (width == mode->hdisplay && height == mode->vdisplay && mode->vrefresh == DRMRefresh &&
|
||||||
height == mode->vdisplay &&
|
render->mode.hdisplay != width && render->mode.vdisplay != height &&
|
||||||
mode->vrefresh == DRMRefresh &&
|
|
||||||
render->mode.hdisplay != width &&
|
|
||||||
render->mode.vdisplay != height &&
|
|
||||||
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||||
VideoWindowWidth = mode->hdisplay;
|
VideoWindowWidth = mode->hdisplay;
|
||||||
@ -215,8 +191,7 @@ void set_video_mode(int width, int height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int FindDevice(VideoRender * render)
|
static int FindDevice(VideoRender *render) {
|
||||||
{
|
|
||||||
drmVersion *version;
|
drmVersion *version;
|
||||||
drmModeRes *resources;
|
drmModeRes *resources;
|
||||||
drmModeConnector *connector;
|
drmModeConnector *connector;
|
||||||
@ -243,20 +218,17 @@ static int FindDevice(VideoRender * render)
|
|||||||
|
|
||||||
int ret = drmSetMaster(render->fd_drm);
|
int ret = drmSetMaster(render->fd_drm);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
{
|
|
||||||
drm_magic_t magic;
|
drm_magic_t magic;
|
||||||
|
|
||||||
ret = drmGetMagic(render->fd_drm, &magic);
|
ret = drmGetMagic(render->fd_drm, &magic);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
{
|
|
||||||
Debug(3, "drm:%s - failed to get drm magic: %s\n", __FUNCTION__, strerror(errno));
|
Debug(3, "drm:%s - failed to get drm magic: %s\n", __FUNCTION__, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = drmAuthMagic(render->fd_drm, magic);
|
ret = drmAuthMagic(render->fd_drm, magic);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
{
|
|
||||||
Debug(3, "drm:%s - failed to authorize drm magic: %s\n", __FUNCTION__, strerror(errno));
|
Debug(3, "drm:%s - failed to authorize drm magic: %s\n", __FUNCTION__, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -290,9 +262,8 @@ static int FindDevice(VideoRender * render)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Debug(3,"[FindDevice] DRM have %i connectors, %i crtcs, %i encoders\n",
|
Debug(3, "[FindDevice] DRM have %i connectors, %i crtcs, %i encoders\n", resources->count_connectors,
|
||||||
resources->count_connectors, resources->count_crtcs,
|
resources->count_crtcs, resources->count_encoders);
|
||||||
resources->count_encoders);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// find all available connectors
|
// find all available connectors
|
||||||
@ -303,8 +274,10 @@ static int FindDevice(VideoRender * render)
|
|||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(connectorstr,"%s-%u",util_lookup_connector_type_name(connector->connector_type),connector->connector_type_id);
|
sprintf(connectorstr, "%s-%u", util_lookup_connector_type_name(connector->connector_type),
|
||||||
printf("Connector >%s< is %sconnected\n",connectorstr,connector->connection == DRM_MODE_CONNECTED?"":"not ");
|
connector->connector_type_id);
|
||||||
|
printf("Connector >%s< is %sconnected\n", connectorstr,
|
||||||
|
connector->connection == DRM_MODE_CONNECTED ? "" : "not ");
|
||||||
if (DRMConnector && strcmp(DRMConnector, connectorstr))
|
if (DRMConnector && strcmp(DRMConnector, connectorstr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -325,9 +298,10 @@ static int FindDevice(VideoRender * render)
|
|||||||
}
|
}
|
||||||
render->crtc_id = encoder->crtc_id;
|
render->crtc_id = encoder->crtc_id;
|
||||||
|
|
||||||
render->hdr_metadata = GetPropertyID(render->fd_drm, connector->connector_id,
|
render->hdr_metadata = GetPropertyID(render->fd_drm, connector->connector_id, DRM_MODE_OBJECT_CONNECTOR,
|
||||||
DRM_MODE_OBJECT_CONNECTOR, "HDR_OUTPUT_METADATA");
|
"HDR_OUTPUT_METADATA");
|
||||||
printf("ID %d of METADATA in Connector %d connected %d\n",render->hdr_metadata,connector->connector_id,connector->connection);
|
printf("ID %d of METADATA in Connector %d connected %d\n", render->hdr_metadata, connector->connector_id,
|
||||||
|
connector->connection);
|
||||||
|
|
||||||
memcpy(&render->mode, &connector->modes[0], sizeof(drmModeModeInfo)); // set fallback
|
memcpy(&render->mode, &connector->modes[0], sizeof(drmModeModeInfo)); // set fallback
|
||||||
// search Modes for Connector
|
// search Modes for Connector
|
||||||
@ -337,15 +311,12 @@ static int FindDevice(VideoRender * render)
|
|||||||
printf("Mode %d %dx%d Rate %d\n", ii, mode->hdisplay, mode->vdisplay, mode->vrefresh);
|
printf("Mode %d %dx%d Rate %d\n", ii, mode->hdisplay, mode->vdisplay, mode->vrefresh);
|
||||||
|
|
||||||
if (VideoWindowWidth && VideoWindowHeight) { // preset by command line
|
if (VideoWindowWidth && VideoWindowHeight) { // preset by command line
|
||||||
if (VideoWindowWidth == mode->hdisplay &&
|
if (VideoWindowWidth == mode->hdisplay && VideoWindowHeight == mode->vdisplay &&
|
||||||
VideoWindowHeight == mode->vdisplay &&
|
mode->vrefresh == DRMRefresh && !(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||||
mode->vrefresh == DRMRefresh &&
|
|
||||||
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
|
||||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
if (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||||
VideoWindowWidth = mode->hdisplay;
|
VideoWindowWidth = mode->hdisplay;
|
||||||
@ -360,7 +331,8 @@ static int FindDevice(VideoRender * render)
|
|||||||
VideoWindowWidth = render->mode.hdisplay;
|
VideoWindowWidth = render->mode.hdisplay;
|
||||||
VideoWindowHeight = render->mode.vdisplay;
|
VideoWindowHeight = render->mode.vdisplay;
|
||||||
if (found)
|
if (found)
|
||||||
printf("Use Mode %d %dx%d Rate %d\n",ii,render->mode.hdisplay,render->mode.vdisplay,render->mode.vrefresh);
|
printf("Use Mode %d %dx%d Rate %d\n", ii, render->mode.hdisplay, render->mode.vdisplay,
|
||||||
|
render->mode.vrefresh);
|
||||||
drmModeFreeConnector(connector);
|
drmModeFreeConnector(connector);
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
@ -384,16 +356,16 @@ static int FindDevice(VideoRender * render)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t type = GetPropertyValue(render->fd_drm, plane_res->planes[j],
|
uint64_t type = GetPropertyValue(render->fd_drm, plane_res->planes[j], DRM_MODE_OBJECT_PLANE, "type");
|
||||||
DRM_MODE_OBJECT_PLANE, "type");
|
|
||||||
uint64_t zpos = 0;
|
uint64_t zpos = 0;
|
||||||
|
|
||||||
#ifdef DRM_DEBUG // If more then 2 crtcs this must rewriten!!!
|
#ifdef DRM_DEBUG // If more then 2 crtcs this must rewriten!!!
|
||||||
printf("[FindDevice] Plane id %i crtc_id %i possible_crtcs %i possible CRTC %i type %s\n",
|
printf("[FindDevice] Plane id %i crtc_id %i possible_crtcs %i possible CRTC %i type %s\n", plane->plane_id,
|
||||||
plane->plane_id, plane->crtc_id, plane->possible_crtcs, resources->crtcs[i],
|
plane->crtc_id, plane->possible_crtcs, resources->crtcs[i],
|
||||||
(type == DRM_PLANE_TYPE_PRIMARY) ? "primary plane" :
|
(type == DRM_PLANE_TYPE_PRIMARY) ? "primary plane"
|
||||||
(type == DRM_PLANE_TYPE_OVERLAY) ? "overlay plane" :
|
: (type == DRM_PLANE_TYPE_OVERLAY) ? "overlay plane"
|
||||||
(type == DRM_PLANE_TYPE_CURSOR) ? "cursor plane" : "No plane type");
|
: (type == DRM_PLANE_TYPE_CURSOR) ? "cursor plane"
|
||||||
|
: "No plane type");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// test pixel format and plane caps
|
// test pixel format and plane caps
|
||||||
@ -423,8 +395,7 @@ static int FindDevice(VideoRender * render)
|
|||||||
drmModeFreeResources(resources);
|
drmModeFreeResources(resources);
|
||||||
|
|
||||||
#ifdef DRM_DEBUG
|
#ifdef DRM_DEBUG
|
||||||
printf("[FindDevice] DRM setup CRTC: %i video_plane: %i \n",
|
printf("[FindDevice] DRM setup CRTC: %i video_plane: %i \n", render->crtc_id, render->video_plane);
|
||||||
render->crtc_id, render->video_plane);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// save actual modesetting
|
// save actual modesetting
|
||||||
@ -436,8 +407,7 @@ static int FindDevice(VideoRender * render)
|
|||||||
///
|
///
|
||||||
/// Initialize video output module.
|
/// Initialize video output module.
|
||||||
///
|
///
|
||||||
void VideoInitDrm()
|
void VideoInitDrm() {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!(render = calloc(1, sizeof(*render)))) {
|
if (!(render = calloc(1, sizeof(*render)))) {
|
||||||
@ -454,8 +424,7 @@ void VideoInitDrm()
|
|||||||
|
|
||||||
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
|
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
|
||||||
|
|
||||||
get_platform_display =
|
get_platform_display = (void *)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
|
|
||||||
assert(get_platform_display != NULL);
|
assert(get_platform_display != NULL);
|
||||||
|
|
||||||
eglDisplay = get_platform_display(EGL_PLATFORM_GBM_KHR, gbm.dev, NULL);
|
eglDisplay = get_platform_display(EGL_PLATFORM_GBM_KHR, gbm.dev, NULL);
|
||||||
@ -478,12 +447,10 @@ void VideoInitDrm()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("set CRTC %d of Connector %d aktiv\n", render->crtc_id, render->connector_id);
|
printf("set CRTC %d of Connector %d aktiv\n", render->crtc_id, render->connector_id);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
||||||
DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id, DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID",
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
render->crtc_id);
|
||||||
DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id);
|
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
|
||||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
|
||||||
|
|
||||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||||
@ -492,11 +459,9 @@ void VideoInitDrm()
|
|||||||
fprintf(stderr, "cannot destroy property blob (%d): %m\n", errno);
|
fprintf(stderr, "cannot destroy property blob (%d): %m\n", errno);
|
||||||
|
|
||||||
drmModeAtomicFree(ModeReq);
|
drmModeAtomicFree(ModeReq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_drm_aspect(int *num,int *den)
|
void get_drm_aspect(int *num, int *den) {
|
||||||
{
|
|
||||||
*num = VideoWindowWidth;
|
*num = VideoWindowWidth;
|
||||||
*den = VideoWindowHeight;
|
*den = VideoWindowHeight;
|
||||||
}
|
}
|
||||||
@ -516,7 +481,6 @@ void InitBo(int bpp) {
|
|||||||
assert(gbm.surface != NULL);
|
assert(gbm.surface != NULL);
|
||||||
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, gbm.surface, NULL);
|
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, gbm.surface, NULL);
|
||||||
assert(eglSurface != NULL);
|
assert(eglSurface != NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct gbm_bo *previous_bo = NULL;
|
static struct gbm_bo *previous_bo = NULL;
|
||||||
@ -537,8 +501,8 @@ static void drm_swap_buffers () {
|
|||||||
uint32_t handle = gbm_bo_get_handle(bo).u32;
|
uint32_t handle = gbm_bo_get_handle(bo).u32;
|
||||||
uint32_t pitch = gbm_bo_get_stride(bo);
|
uint32_t pitch = gbm_bo_get_stride(bo);
|
||||||
|
|
||||||
|
drmModeAddFB(render->fd_drm, VideoWindowWidth, VideoWindowHeight, render->bpp == 10 ? 30 : 24, 32, pitch, handle,
|
||||||
drmModeAddFB (render->fd_drm, VideoWindowWidth,VideoWindowHeight,render->bpp==10? 30:24, 32, pitch, handle, &fb);
|
&fb);
|
||||||
// drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
|
// drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
|
||||||
|
|
||||||
if (m_need_modeset) {
|
if (m_need_modeset) {
|
||||||
@ -556,23 +520,19 @@ static void drm_swap_buffers () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Need to disable the CRTC in order to submit the HDR data....
|
// Need to disable the CRTC in order to submit the HDR data....
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, DRM_MODE_OBJECT_CRTC, "ACTIVE", 0);
|
||||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 0);
|
|
||||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||||
|
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id, DRM_MODE_OBJECT_CONNECTOR, "Colorspace",
|
||||||
DRM_MODE_OBJECT_CONNECTOR, "Colorspace",old_color==AVCOL_PRI_BT2020?9:2 );
|
old_color == AVCOL_PRI_BT2020 ? 9 : 2);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane, DRM_MODE_OBJECT_PLANE, "COLOR_ENCODING",
|
||||||
DRM_MODE_OBJECT_PLANE, "COLOR_ENCODING",old_color==AVCOL_PRI_BT2020?2:1 );
|
old_color == AVCOL_PRI_BT2020 ? 2 : 1);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane, DRM_MODE_OBJECT_PLANE, "COLOR_RANGE", 0);
|
||||||
DRM_MODE_OBJECT_PLANE, "COLOR_RANGE",0 );
|
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id, DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID",
|
||||||
DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
render->crtc_id);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
||||||
DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id);
|
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
|
||||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
|
||||||
|
|
||||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||||
fprintf(stderr, "cannot set atomic mode modeset 2 (%d): %m\n", errno);
|
fprintf(stderr, "cannot set atomic mode modeset 2 (%d): %m\n", errno);
|
||||||
@ -592,7 +552,6 @@ static void drm_swap_buffers () {
|
|||||||
}
|
}
|
||||||
previous_bo = bo;
|
previous_bo = bo;
|
||||||
previous_fb = fb;
|
previous_fb = fb;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drm_clean_up() {
|
static void drm_clean_up() {
|
||||||
@ -607,8 +566,8 @@ static void drm_clean_up () {
|
|||||||
gbm_surface_release_buffer(gbm.surface, previous_bo);
|
gbm_surface_release_buffer(gbm.surface, previous_bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
drmModeSetCrtc (render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id,
|
drmModeSetCrtc(render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id, render->saved_crtc->x,
|
||||||
render->saved_crtc->x, render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode);
|
render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode);
|
||||||
drmModeFreeCrtc(render->saved_crtc);
|
drmModeFreeCrtc(render->saved_crtc);
|
||||||
|
|
||||||
if (has_modeset) {
|
if (has_modeset) {
|
||||||
@ -626,25 +585,19 @@ static void drm_clean_up () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Need to disable the CRTC in order to submit the HDR data....
|
// Need to disable the CRTC in order to submit the HDR data....
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, DRM_MODE_OBJECT_CRTC, "ACTIVE", 0);
|
||||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 0);
|
|
||||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||||
|
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id, DRM_MODE_OBJECT_CONNECTOR,
|
||||||
DRM_MODE_OBJECT_CONNECTOR, "HDR_OUTPUT_METADATA", 0);
|
"HDR_OUTPUT_METADATA", 0);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id, DRM_MODE_OBJECT_CONNECTOR, "Colorspace", 2);
|
||||||
DRM_MODE_OBJECT_CONNECTOR, "Colorspace",2 );
|
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane, DRM_MODE_OBJECT_PLANE, "COLOR_ENCODING", 1);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane, DRM_MODE_OBJECT_PLANE, "COLOR_RANGE", 1);
|
||||||
DRM_MODE_OBJECT_PLANE, "COLOR_ENCODING",1 );
|
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id, DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID",
|
||||||
DRM_MODE_OBJECT_PLANE, "COLOR_RANGE",1 );
|
render->crtc_id);
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
||||||
DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
|
||||||
DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id);
|
|
||||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
|
||||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
|
||||||
|
|
||||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||||
@ -677,5 +630,4 @@ static void drm_clean_up () {
|
|||||||
close(render->fd_drm);
|
close(render->fd_drm);
|
||||||
eglDisplay = NULL;
|
eglDisplay = NULL;
|
||||||
free(render);
|
free(render);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
367
hdr.c
367
hdr.c
@ -87,7 +87,6 @@ struct hdr_output_metadata {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
enum hdr_metadata_eotf {
|
enum hdr_metadata_eotf {
|
||||||
EOTF_TRADITIONAL_GAMMA_SDR,
|
EOTF_TRADITIONAL_GAMMA_SDR,
|
||||||
EOTF_TRADITIONAL_GAMMA_HDR,
|
EOTF_TRADITIONAL_GAMMA_HDR,
|
||||||
@ -95,27 +94,15 @@ enum hdr_metadata_eotf {
|
|||||||
EOTF_HLG,
|
EOTF_HLG,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum metadata_id {
|
enum metadata_id {
|
||||||
METADATA_TYPE1,
|
METADATA_TYPE1,
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void weston_hdr_metadata(void *data, uint16_t display_primary_r_x, uint16_t display_primary_r_y,
|
||||||
weston_hdr_metadata(void *data,
|
uint16_t display_primary_g_x, uint16_t display_primary_g_y, uint16_t display_primary_b_x,
|
||||||
uint16_t display_primary_r_x,
|
uint16_t display_primary_b_y, uint16_t white_point_x, uint16_t white_point_y,
|
||||||
uint16_t display_primary_r_y,
|
uint16_t min_luminance, uint16_t max_luminance, uint16_t max_cll, uint16_t max_fall,
|
||||||
uint16_t display_primary_g_x,
|
enum hdr_metadata_eotf eotf) {
|
||||||
uint16_t display_primary_g_y,
|
|
||||||
uint16_t display_primary_b_x,
|
|
||||||
uint16_t display_primary_b_y,
|
|
||||||
uint16_t white_point_x,
|
|
||||||
uint16_t white_point_y,
|
|
||||||
uint16_t min_luminance,
|
|
||||||
uint16_t max_luminance,
|
|
||||||
uint16_t max_cll,
|
|
||||||
uint16_t max_fall,
|
|
||||||
enum hdr_metadata_eotf eotf)
|
|
||||||
{
|
|
||||||
uint8_t *data8;
|
uint8_t *data8;
|
||||||
uint16_t *data16;
|
uint16_t *data16;
|
||||||
|
|
||||||
@ -155,151 +142,302 @@ struct weston_colorspace {
|
|||||||
struct weston_colorspace hdr10;
|
struct weston_colorspace hdr10;
|
||||||
|
|
||||||
static const struct weston_colorspace bt470m = {
|
static const struct weston_colorspace bt470m = {
|
||||||
.r = {{ 0.670f, 0.330f, }},
|
.r = {{
|
||||||
.g = {{ 0.210f, 0.710f, }},
|
0.670f,
|
||||||
.b = {{ 0.140f, 0.080f, }},
|
0.330f,
|
||||||
.whitepoint = {{ 0.3101f, 0.3162f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.210f,
|
||||||
|
0.710f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.140f,
|
||||||
|
0.080f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3101f,
|
||||||
|
0.3162f,
|
||||||
|
}},
|
||||||
.name = "BT.470 M",
|
.name = "BT.470 M",
|
||||||
.whitepoint_name = "C",
|
.whitepoint_name = "C",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace bt470bg = {
|
static const struct weston_colorspace bt470bg = {
|
||||||
.r = {{ 0.640f, 0.330f, }},
|
.r = {{
|
||||||
.g = {{ 0.290f, 0.600f, }},
|
0.640f,
|
||||||
.b = {{ 0.150f, 0.060f, }},
|
0.330f,
|
||||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.290f,
|
||||||
|
0.600f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.150f,
|
||||||
|
0.060f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3127f,
|
||||||
|
0.3290f,
|
||||||
|
}},
|
||||||
.name = "BT.470 B/G",
|
.name = "BT.470 B/G",
|
||||||
.whitepoint_name = "D65",
|
.whitepoint_name = "D65",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace smpte170m = {
|
static const struct weston_colorspace smpte170m = {
|
||||||
.r = {{ 0.630f, 0.340f, }},
|
.r = {{
|
||||||
.g = {{ 0.310f, 0.595f, }},
|
0.630f,
|
||||||
.b = {{ 0.155f, 0.070f, }},
|
0.340f,
|
||||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.310f,
|
||||||
|
0.595f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.155f,
|
||||||
|
0.070f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3127f,
|
||||||
|
0.3290f,
|
||||||
|
}},
|
||||||
.name = "SMPTE 170M",
|
.name = "SMPTE 170M",
|
||||||
.whitepoint_name = "D65",
|
.whitepoint_name = "D65",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace smpte240m = {
|
static const struct weston_colorspace smpte240m = {
|
||||||
.r = {{ 0.630f, 0.340f, }},
|
.r = {{
|
||||||
.g = {{ 0.310f, 0.595f, }},
|
0.630f,
|
||||||
.b = {{ 0.155f, 0.070f, }},
|
0.340f,
|
||||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.310f,
|
||||||
|
0.595f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.155f,
|
||||||
|
0.070f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3127f,
|
||||||
|
0.3290f,
|
||||||
|
}},
|
||||||
.name = "SMPTE 240M",
|
.name = "SMPTE 240M",
|
||||||
.whitepoint_name = "D65",
|
.whitepoint_name = "D65",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace bt709 = {
|
static const struct weston_colorspace bt709 = {
|
||||||
.r = {{ 0.640f, 0.330f, }},
|
.r = {{
|
||||||
.g = {{ 0.300f, 0.600f, }},
|
0.640f,
|
||||||
.b = {{ 0.150f, 0.060f, }},
|
0.330f,
|
||||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.300f,
|
||||||
|
0.600f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.150f,
|
||||||
|
0.060f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3127f,
|
||||||
|
0.3290f,
|
||||||
|
}},
|
||||||
.name = "BT.709",
|
.name = "BT.709",
|
||||||
.whitepoint_name = "D65",
|
.whitepoint_name = "D65",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace bt2020 = {
|
static const struct weston_colorspace bt2020 = {
|
||||||
.r = {{ 0.708f, 0.292f, }},
|
.r = {{
|
||||||
.g = {{ 0.170f, 0.797f, }},
|
0.708f,
|
||||||
.b = {{ 0.131f, 0.046f, }},
|
0.292f,
|
||||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.170f,
|
||||||
|
0.797f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.131f,
|
||||||
|
0.046f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3127f,
|
||||||
|
0.3290f,
|
||||||
|
}},
|
||||||
.name = "BT.2020",
|
.name = "BT.2020",
|
||||||
.whitepoint_name = "D65",
|
.whitepoint_name = "D65",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace srgb = {
|
static const struct weston_colorspace srgb = {
|
||||||
.r = {{ 0.640f, 0.330f, }},
|
.r = {{
|
||||||
.g = {{ 0.300f, 0.600f, }},
|
0.640f,
|
||||||
.b = {{ 0.150f, 0.060f, }},
|
0.330f,
|
||||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.300f,
|
||||||
|
0.600f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.150f,
|
||||||
|
0.060f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3127f,
|
||||||
|
0.3290f,
|
||||||
|
}},
|
||||||
.name = "sRGB",
|
.name = "sRGB",
|
||||||
.whitepoint_name = "D65",
|
.whitepoint_name = "D65",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace adobergb = {
|
static const struct weston_colorspace adobergb = {
|
||||||
.r = {{ 0.640f, 0.330f, }},
|
.r = {{
|
||||||
.g = {{ 0.210f, 0.710f, }},
|
0.640f,
|
||||||
.b = {{ 0.150f, 0.060f, }},
|
0.330f,
|
||||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.210f,
|
||||||
|
0.710f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.150f,
|
||||||
|
0.060f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3127f,
|
||||||
|
0.3290f,
|
||||||
|
}},
|
||||||
.name = "AdobeRGB",
|
.name = "AdobeRGB",
|
||||||
.whitepoint_name = "D65",
|
.whitepoint_name = "D65",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace dci_p3 = {
|
static const struct weston_colorspace dci_p3 = {
|
||||||
.r = {{ 0.680f, 0.320f, }},
|
.r = {{
|
||||||
.g = {{ 0.265f, 0.690f, }},
|
0.680f,
|
||||||
.b = {{ 0.150f, 0.060f, }},
|
0.320f,
|
||||||
.whitepoint = {{ 0.3127f, 0.3290f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.265f,
|
||||||
|
0.690f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.150f,
|
||||||
|
0.060f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.3127f,
|
||||||
|
0.3290f,
|
||||||
|
}},
|
||||||
.name = "DCI-P3 D65",
|
.name = "DCI-P3 D65",
|
||||||
.whitepoint_name = "D65",
|
.whitepoint_name = "D65",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace prophotorgb = {
|
static const struct weston_colorspace prophotorgb = {
|
||||||
.r = {{ 0.7347f, 0.2653f, }},
|
.r = {{
|
||||||
.g = {{ 0.1596f, 0.8404f, }},
|
0.7347f,
|
||||||
.b = {{ 0.0366f, 0.0001f, }},
|
0.2653f,
|
||||||
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.1596f,
|
||||||
|
0.8404f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.0366f,
|
||||||
|
0.0001f,
|
||||||
|
}},
|
||||||
.whitepoint = {{.3457, .3585}},
|
.whitepoint = {{.3457, .3585}},
|
||||||
.name = "ProPhoto RGB",
|
.name = "ProPhoto RGB",
|
||||||
.whitepoint_name = "D50",
|
.whitepoint_name = "D50",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace ciergb = {
|
static const struct weston_colorspace ciergb = {
|
||||||
.r = {{ 0.7347f, 0.2653f, }},
|
.r = {{
|
||||||
.g = {{ 0.2738f, 0.7174f, }},
|
0.7347f,
|
||||||
.b = {{ 0.1666f, 0.0089f, }},
|
0.2653f,
|
||||||
.whitepoint = {{ 1.0f / 3.0f, 1.0f / 3.0f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.2738f,
|
||||||
|
0.7174f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.1666f,
|
||||||
|
0.0089f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
1.0f / 3.0f,
|
||||||
|
1.0f / 3.0f,
|
||||||
|
}},
|
||||||
.name = "CIE RGB",
|
.name = "CIE RGB",
|
||||||
.whitepoint_name = "E",
|
.whitepoint_name = "E",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace ciexyz = {
|
static const struct weston_colorspace ciexyz = {
|
||||||
.r = {{ 1.0f, 0.0f, }},
|
.r = {{
|
||||||
.g = {{ 0.0f, 1.0f, }},
|
1.0f,
|
||||||
.b = {{ 0.0f, 0.0f, }},
|
0.0f,
|
||||||
.whitepoint = {{ 1.0f / 3.0f, 1.0f / 3.0f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
1.0f / 3.0f,
|
||||||
|
1.0f / 3.0f,
|
||||||
|
}},
|
||||||
.name = "CIE XYZ",
|
.name = "CIE XYZ",
|
||||||
.whitepoint_name = "E",
|
.whitepoint_name = "E",
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct weston_colorspace ap0 = {
|
const struct weston_colorspace ap0 = {
|
||||||
.r = {{ 0.7347f, 0.2653f, }},
|
.r = {{
|
||||||
.g = {{ 0.0000f, 1.0000f, }},
|
0.7347f,
|
||||||
.b = {{ 0.0001f, -0.0770f, }},
|
0.2653f,
|
||||||
.whitepoint = {{ .32168f, .33767f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.0000f,
|
||||||
|
1.0000f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.0001f,
|
||||||
|
-0.0770f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
.32168f,
|
||||||
|
.33767f,
|
||||||
|
}},
|
||||||
.name = "ACES primaries #0",
|
.name = "ACES primaries #0",
|
||||||
.whitepoint_name = "D60",
|
.whitepoint_name = "D60",
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct weston_colorspace ap1 = {
|
const struct weston_colorspace ap1 = {
|
||||||
.r = {{ 0.713f, 0.393f, }},
|
.r = {{
|
||||||
.g = {{ 0.165f, 0.830f, }},
|
0.713f,
|
||||||
.b = {{ 0.128f, 0.044f, }},
|
0.393f,
|
||||||
.whitepoint = {{ 0.32168f, 0.33767f, }},
|
}},
|
||||||
|
.g = {{
|
||||||
|
0.165f,
|
||||||
|
0.830f,
|
||||||
|
}},
|
||||||
|
.b = {{
|
||||||
|
0.128f,
|
||||||
|
0.044f,
|
||||||
|
}},
|
||||||
|
.whitepoint = {{
|
||||||
|
0.32168f,
|
||||||
|
0.33767f,
|
||||||
|
}},
|
||||||
.name = "ACES primaries #1",
|
.name = "ACES primaries #1",
|
||||||
.whitepoint_name = "D60",
|
.whitepoint_name = "D60",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct weston_colorspace *const colorspaces[] = {
|
static const struct weston_colorspace *const colorspaces[] = {
|
||||||
&bt470m,
|
&bt470m, &bt470bg, &smpte170m, &smpte240m, &bt709, &bt2020, &srgb,
|
||||||
&bt470bg,
|
&adobergb, &dci_p3, &prophotorgb, &ciergb, &ciexyz, &ap0, &ap1,
|
||||||
&smpte170m,
|
|
||||||
&smpte240m,
|
|
||||||
&bt709,
|
|
||||||
&bt2020,
|
|
||||||
&srgb,
|
|
||||||
&adobergb,
|
|
||||||
&dci_p3,
|
|
||||||
&prophotorgb,
|
|
||||||
&ciergb,
|
|
||||||
&ciexyz,
|
|
||||||
&ap0,
|
|
||||||
&ap1,
|
|
||||||
};
|
};
|
||||||
#define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0])
|
#define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0])
|
||||||
const struct weston_colorspace *
|
const struct weston_colorspace *weston_colorspace_lookup(const char *name) {
|
||||||
weston_colorspace_lookup(const char *name)
|
|
||||||
{
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
@ -317,15 +455,10 @@ weston_colorspace_lookup(const char *name)
|
|||||||
|
|
||||||
static int cleanup = 0;
|
static int cleanup = 0;
|
||||||
|
|
||||||
|
static uint16_t encode_xyy(float xyy) { return xyy * 50000; }
|
||||||
static uint16_t encode_xyy(float xyy)
|
|
||||||
{
|
|
||||||
return xyy * 50000;
|
|
||||||
}
|
|
||||||
static AVMasteringDisplayMetadata md_save = {0};
|
static AVMasteringDisplayMetadata md_save = {0};
|
||||||
static AVContentLightMetadata ld_save = {0};
|
static AVContentLightMetadata ld_save = {0};
|
||||||
static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSideData *sd2)
|
static void set_hdr_metadata(int color, int trc, AVFrameSideData *sd1, AVFrameSideData *sd2) {
|
||||||
{
|
|
||||||
drmModeAtomicReqPtr ModeReq;
|
drmModeAtomicReqPtr ModeReq;
|
||||||
struct weston_colorspace *cs;
|
struct weston_colorspace *cs;
|
||||||
enum hdr_metadata_eotf eotf;
|
enum hdr_metadata_eotf eotf;
|
||||||
@ -335,13 +468,10 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
|||||||
struct AVMasteringDisplayMetadata *md = NULL;
|
struct AVMasteringDisplayMetadata *md = NULL;
|
||||||
struct AVContentLightMetadata *ld = NULL;
|
struct AVContentLightMetadata *ld = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// clean up FFMEPG stuff
|
// clean up FFMEPG stuff
|
||||||
if (trc == AVCOL_TRC_BT2020_10)
|
if (trc == AVCOL_TRC_BT2020_10)
|
||||||
trc = AVCOL_TRC_ARIB_STD_B67;
|
trc = AVCOL_TRC_ARIB_STD_B67;
|
||||||
|
|
||||||
|
|
||||||
if ((old_color == color && old_trc == trc && !sd1 && !sd2) || !render->hdr_metadata)
|
if ((old_color == color && old_trc == trc && !sd1 && !sd2) || !render->hdr_metadata)
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
|
|
||||||
@ -354,8 +484,7 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
|||||||
if (md && !memcmp(md, &md_save, sizeof(md_save)))
|
if (md && !memcmp(md, &md_save, sizeof(md_save)))
|
||||||
if (ld && !memcmp(ld, &ld_save, sizeof(ld_save))) {
|
if (ld && !memcmp(ld, &ld_save, sizeof(ld_save))) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (ld && !memcmp(ld, &ld_save, sizeof(ld_save))) {
|
||||||
else if (ld && !memcmp(ld,&ld_save,sizeof(ld_save))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +498,6 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
|||||||
old_color = color;
|
old_color = color;
|
||||||
old_trc = trc;
|
old_trc = trc;
|
||||||
|
|
||||||
|
|
||||||
if (VulkanTargetColorSpace != 3) { // no HDR TV
|
if (VulkanTargetColorSpace != 3) { // no HDR TV
|
||||||
m_need_modeset = 1; // change in colorsettings
|
m_need_modeset = 1; // change in colorsettings
|
||||||
return;
|
return;
|
||||||
@ -414,17 +542,14 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
|||||||
|
|
||||||
if (md) { // we got Metadata
|
if (md) { // we got Metadata
|
||||||
if (md->has_primaries) {
|
if (md->has_primaries) {
|
||||||
Debug(3,"Mastering Display Metadata,\n has_primaries:%d has_luminance:%d \n"
|
Debug(3,
|
||||||
|
"Mastering Display Metadata,\n has_primaries:%d has_luminance:%d \n"
|
||||||
"r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) \n"
|
"r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) \n"
|
||||||
"min_luminance=%f, max_luminance=%f\n",
|
"min_luminance=%f, max_luminance=%f\n",
|
||||||
md->has_primaries, md->has_luminance,
|
md->has_primaries, md->has_luminance, av_q2d(md->display_primaries[0][0]),
|
||||||
av_q2d(md->display_primaries[0][0]),
|
av_q2d(md->display_primaries[0][1]), av_q2d(md->display_primaries[1][0]),
|
||||||
av_q2d(md->display_primaries[0][1]),
|
av_q2d(md->display_primaries[1][1]), av_q2d(md->display_primaries[2][0]),
|
||||||
av_q2d(md->display_primaries[1][0]),
|
av_q2d(md->display_primaries[2][1]), av_q2d(md->white_point[0]), av_q2d(md->white_point[1]),
|
||||||
av_q2d(md->display_primaries[1][1]),
|
|
||||||
av_q2d(md->display_primaries[2][0]),
|
|
||||||
av_q2d(md->display_primaries[2][1]),
|
|
||||||
av_q2d(md->white_point[0]), av_q2d(md->white_point[1]),
|
|
||||||
av_q2d(md->min_luminance), av_q2d(md->max_luminance));
|
av_q2d(md->min_luminance), av_q2d(md->max_luminance));
|
||||||
|
|
||||||
cs = &hdr10;
|
cs = &hdr10;
|
||||||
@ -449,23 +574,15 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
|||||||
MaxFALL = ld->MaxFALL;
|
MaxFALL = ld->MaxFALL;
|
||||||
}
|
}
|
||||||
data.metadata_type = 7; // ????????????????????????
|
data.metadata_type = 7; // ????????????????????????
|
||||||
weston_hdr_metadata(&data.hdmi_metadata_type1,
|
weston_hdr_metadata(&data.hdmi_metadata_type1, encode_xyy(cs->r.f[0]), encode_xyy(cs->r.f[1]),
|
||||||
encode_xyy(cs->r.f[0]),
|
encode_xyy(cs->g.f[0]), encode_xyy(cs->g.f[1]), encode_xyy(cs->b.f[0]), encode_xyy(cs->b.f[1]),
|
||||||
encode_xyy(cs->r.f[1]),
|
encode_xyy(cs->whitepoint.f[0]), encode_xyy(cs->whitepoint.f[1]),
|
||||||
encode_xyy(cs->g.f[0]),
|
|
||||||
encode_xyy(cs->g.f[1]),
|
|
||||||
encode_xyy(cs->b.f[0]),
|
|
||||||
encode_xyy(cs->b.f[1]),
|
|
||||||
encode_xyy(cs->whitepoint.f[0]),
|
|
||||||
encode_xyy(cs->whitepoint.f[1]),
|
|
||||||
max_lum, // max_display_mastering_luminance
|
max_lum, // max_display_mastering_luminance
|
||||||
min_lum, // min_display_mastering_luminance
|
min_lum, // min_display_mastering_luminance
|
||||||
MaxCLL, // Maximum Content Light Level (MaxCLL)
|
MaxCLL, // Maximum Content Light Level (MaxCLL)
|
||||||
MaxFALL, // Maximum Frame-Average Light Level (MaxFALL)
|
MaxFALL, // Maximum Frame-Average Light Level (MaxFALL)
|
||||||
eotf);
|
eotf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ret = drmModeCreatePropertyBlob(render->fd_drm, &data, sizeof(data), &render->hdr_blob_id);
|
ret = drmModeCreatePropertyBlob(render->fd_drm, &data, sizeof(data), &render->hdr_blob_id);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("DRM: HDR metadata: failed blob create \n");
|
printf("DRM: HDR metadata: failed blob create \n");
|
||||||
@ -473,8 +590,7 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = drmModeConnectorSetProperty(render->fd_drm, render->connector_id,
|
ret = drmModeConnectorSetProperty(render->fd_drm, render->connector_id, render->hdr_metadata, render->hdr_blob_id);
|
||||||
render->hdr_metadata, render->hdr_blob_id);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("DRM: HDR metadata: failed property set %d\n", ret);
|
printf("DRM: HDR metadata: failed property set %d\n", ret);
|
||||||
|
|
||||||
@ -487,5 +603,4 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
|||||||
m_need_modeset = 1;
|
m_need_modeset = 1;
|
||||||
|
|
||||||
Debug(3, "DRM: HDR metadata: prop set\n");
|
Debug(3, "DRM: HDR metadata: prop set\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user