From: <sunpeng.li-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: "Leo (Sunpeng) Li" <sunpeng.li-5C7GfCeVMHo@public.gmane.org>,
michel-otUistvHUpPR7s880joybQ@public.gmane.org,
harry.wentland-5C7GfCeVMHo@public.gmane.org
Subject: [PATCH xf86-video-amdgpu 01/13] Add color management properties to driver-private CRTC object
Date: Thu, 3 May 2018 14:31:43 -0400 [thread overview]
Message-ID: <1525372315-28462-2-git-send-email-sunpeng.li@amd.com> (raw)
In-Reply-To: <1525372315-28462-1-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
From: "Leo (Sunpeng) Li" <sunpeng.li@amd.com>
Non-legacy color management consists of 3 properties on the CRTC:
Degamma LUT, Color Transformation Matrix (CTM), and Gamma LUT.
Add these properties to the driver-private CRTC, and initialize them
when the CRTC is initialized. These values are refered to as "staged"
values. They exist in the DDX driver, but require a "push" to DRM in
order to be realized in hardware.
Also add a destructor for the driver-private CRTC, which cleans up the
non-legacy properties.
Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
---
src/drmmode_display.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++-
src/drmmode_display.h | 8 ++++
2 files changed, 114 insertions(+), 1 deletion(-)
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 49284c6..0ffc6ad 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -747,6 +747,83 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
}
}
+enum drmmode_cm_prop {
+ CM_GAMMA_LUT_SIZE,
+ CM_DEGAMMA_LUT_SIZE,
+ CM_GAMMA_LUT,
+ CM_CTM,
+ CM_DEGAMMA_LUT,
+ CM_NUM_PROPS,
+ CM_INVALID_PROP = -1,
+};
+
+char *CM_PROP_NAMES[] = {
+ "GAMMA_LUT_SIZE",
+ "DEGAMMA_LUT_SIZE",
+ "GAMMA_LUT",
+ "CTM",
+ "DEGAMMA_LUT",
+};
+
+/**
+ * Return the enum of the color management property with the given name.
+ */
+static enum drmmode_cm_prop get_cm_enum_from_str(const char *prop_name)
+{
+ enum drmmode_cm_prop ret;
+
+ for (ret = 0; ret < CM_NUM_PROPS; ret++) {
+ if (!strcmp(prop_name, CM_PROP_NAMES[ret]))
+ return ret;
+ }
+ return CM_INVALID_PROP;
+}
+
+/**
+ * Query DRM for the property value of the specified color management property,
+ * on the specified CRTC.
+ *
+ * @crtc: The CRTC to query DRM properties on.
+ * @prop_id: Color management property enum.
+ * Return: The property value (if property is DRM blob, return blob_id) of the
+ * specified color property. 0 if property not found.
+ */
+static uint64_t get_drm_cm_prop_value(xf86CrtcPtr crtc,
+ enum drmmode_cm_prop prop_id)
+{
+ AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(crtc->scrn);
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmModeObjectPropertiesPtr drm_props;
+ int i;
+
+ /* Get list of DRM CRTC properties, and their values */
+ drm_props = drmModeObjectGetProperties(pAMDGPUEnt->fd,
+ drmmode_crtc->mode_crtc->crtc_id,
+ DRM_MODE_OBJECT_CRTC);
+ if (!drm_props)
+ goto err_allocs;
+
+ for (i = 0; i < drm_props->count_props; i++) {
+ drmModePropertyPtr drm_prop;
+
+ drm_prop = drmModeGetProperty(pAMDGPUEnt->fd,
+ drm_props->props[i]);
+ if (!drm_prop)
+ goto err_allocs;
+
+ if (get_cm_enum_from_str(drm_prop->name) == prop_id){
+ drmModeFreeProperty(drm_prop);
+ return drm_props->prop_values[i];
+ }
+
+ drmModeFreeProperty(drm_prop);
+ }
+
+err_allocs:
+ drmModeFreeObjectProperties(drm_props);
+ return 0;
+}
+
static void
drmmode_crtc_gamma_do_set(xf86CrtcPtr crtc, uint16_t *red, uint16_t *green,
uint16_t *blue, int size)
@@ -1293,6 +1370,22 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
return TRUE;
}
+static void drmmode_crtc_destroy(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+ drmModeFreeCrtc(drmmode_crtc->mode_crtc);
+
+ /* Free LUTs and CTM */
+ free(drmmode_crtc->gamma_lut);
+ free(drmmode_crtc->degamma_lut);
+ free(drmmode_crtc->ctm);
+
+ free(drmmode_crtc);
+ crtc->driver_private = NULL;
+}
+
+
static xf86CrtcFuncsRec drmmode_crtc_funcs = {
.dpms = drmmode_crtc_dpms,
.set_mode_major = drmmode_set_mode_major,
@@ -1309,7 +1402,7 @@ static xf86CrtcFuncsRec drmmode_crtc_funcs = {
.shadow_create = drmmode_crtc_shadow_create,
.shadow_allocate = drmmode_crtc_shadow_allocate,
.shadow_destroy = drmmode_crtc_shadow_destroy,
- .destroy = NULL, /* XXX */
+ .destroy = drmmode_crtc_destroy,
.set_scanout_pixmap = drmmode_set_scanout_pixmap,
};
@@ -1353,6 +1446,18 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
crtc->driver_private = drmmode_crtc;
drmmode_crtc_hw_id(crtc);
+ drmmode_crtc->gamma_lut_size =
+ (uint32_t)get_drm_cm_prop_value(crtc, CM_GAMMA_LUT_SIZE);
+ drmmode_crtc->degamma_lut_size =
+ (uint32_t)get_drm_cm_prop_value(crtc, CM_DEGAMMA_LUT_SIZE);
+ drmmode_crtc->ctm = calloc(1, sizeof(*drmmode_crtc->ctm));
+ if (drmmode_crtc->ctm == NULL)
+ return 0;
+
+ /* Init to identity matrix. Values are in S31.32 fixed-point format */
+ drmmode_crtc->ctm->matrix[0] = drmmode_crtc->ctm->matrix[4] =
+ drmmode_crtc->ctm->matrix[8] = (uint64_t)1 << 32;
+
/* Mark num'th crtc as in use on this device. */
pAMDGPUEnt->assigned_crtcs |= (1 << num);
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, AMDGPU_LOGLEVEL_DEBUG,
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 25ae9f8..21498e3 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -109,6 +109,14 @@ typedef struct {
unsigned present_vblank_msc;
Bool present_flip_expected;
#endif
+
+ uint32_t gamma_lut_size;
+ struct drm_color_lut *gamma_lut;
+
+ uint32_t degamma_lut_size;
+ struct drm_color_lut *degamma_lut;
+
+ struct drm_color_ctm *ctm;
} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
typedef struct {
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2018-05-03 18:31 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 18:31 [PATCH xf86-video-amdgpu 00/13] Enabling Color Management - Round 2 sunpeng.li-5C7GfCeVMHo
[not found] ` <1525372315-28462-1-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-05-03 18:31 ` sunpeng.li-5C7GfCeVMHo [this message]
[not found] ` <1525372315-28462-2-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-05-16 17:07 ` [PATCH xf86-video-amdgpu 01/13] Add color management properties to driver-private CRTC object Michel Dänzer
[not found] ` <0dda7c80-2bdc-52a7-8dcf-ad5a7f6e9346-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-05-17 21:43 ` Leo Li
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 02/13] Push color properties to kernel DRM on CRTC init sunpeng.li-5C7GfCeVMHo
[not found] ` <1525372315-28462-3-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-05-16 17:08 ` Michel Dänzer
[not found] ` <a2b8ff58-edcc-bb95-f630-1926b1a8874b-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-05-17 21:43 ` Leo Li
[not found] ` <db641905-9dea-015d-24d2-fa25d136abfc-5C7GfCeVMHo@public.gmane.org>
2018-05-18 7:52 ` Michel Dänzer
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 03/13] List disabled color properties on RandR outputs without a CRTC sunpeng.li-5C7GfCeVMHo
[not found] ` <1525372315-28462-4-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-05-16 17:09 ` Michel Dänzer
[not found] ` <62d1f2e3-d271-658a-7bf4-88b41b080266-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-05-17 21:43 ` Leo Li
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 04/13] Use CRTC's color properties if output has a CRTC attached sunpeng.li-5C7GfCeVMHo
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 05/13] Enable setting of color properties though RandR sunpeng.li-5C7GfCeVMHo
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 06/13] Compose non-legacy with legacy gamma LUT before pushing to kernel DRM sunpeng.li-5C7GfCeVMHo
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 07/13] Also compose LUT when setting legacy gamma sunpeng.li-5C7GfCeVMHo
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 08/13] Set driver-private CRTC's dpms mode on disable sunpeng.li-5C7GfCeVMHo
[not found] ` <1525372315-28462-9-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-05-16 17:09 ` Michel Dänzer
[not found] ` <12553d4f-c171-112b-bad6-6f53d47aa8e3-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-05-17 21:43 ` Leo Li
[not found] ` <6cf602ed-b43d-d446-74a0-a39d35042f5a-5C7GfCeVMHo@public.gmane.org>
2018-05-18 10:35 ` Michel Dänzer
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 09/13] Move drmmode_do_crtc_dpms sunpeng.li-5C7GfCeVMHo
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 10/13] Push staged color properties when DPMS state toggles On sunpeng.li-5C7GfCeVMHo
[not found] ` <1525372315-28462-11-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-05-16 17:10 ` Michel Dänzer
[not found] ` <23a9fe2a-df1c-6ecb-b60e-bdcb22d8179c-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-05-17 21:44 ` Leo Li
[not found] ` <f323d1de-d517-805f-d373-a7310ec6496c-5C7GfCeVMHo@public.gmane.org>
2018-05-18 8:01 ` Michel Dänzer
[not found] ` <6500b993-624a-45aa-6310-958ca8c1f21b-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-05-24 19:01 ` Leo Li
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 11/13] Push staged color properties on output detect sunpeng.li-5C7GfCeVMHo
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 12/13] Update color properties on modeset major sunpeng.li-5C7GfCeVMHo
2018-05-03 18:31 ` [PATCH xf86-video-amdgpu 13/13] Refactor pushing color management properties into a function sunpeng.li-5C7GfCeVMHo
2018-05-14 13:38 ` [PATCH xf86-video-amdgpu 00/13] Enabling Color Management - Round 2 Leo Li
2018-05-14 14:17 ` Michel Dänzer
2018-05-16 17:06 ` Michel Dänzer
[not found] ` <b3a7fcde-fe69-5944-1857-c2b43fa068de-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-05-17 21:43 ` Leo Li
[not found] ` <62c350eb-8634-5bab-e14e-6d75315e3f56-5C7GfCeVMHo@public.gmane.org>
2018-05-18 8:10 ` Michel Dänzer
[not found] ` <8fe3423f-8d9e-120c-32e1-7a6a7fd81606-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-05-24 20:29 ` Leo Li
[not found] ` <7c183caf-d2de-cf56-ed31-7922b24d3a8e-5C7GfCeVMHo@public.gmane.org>
2018-05-25 7:51 ` Michel Dänzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1525372315-28462-2-git-send-email-sunpeng.li@amd.com \
--to=sunpeng.li-5c7gfcevmho@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=harry.wentland-5C7GfCeVMHo@public.gmane.org \
--cc=michel-otUistvHUpPR7s880joybQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox