From patchwork Fri Feb 19 15:46:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lionel Landwerlin X-Patchwork-Id: 8362281 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 20F67C0554 for ; Fri, 19 Feb 2016 15:46:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E771120461 for ; Fri, 19 Feb 2016 15:46:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AF6AF20458 for ; Fri, 19 Feb 2016 15:46:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC9F36EFB6; Fri, 19 Feb 2016 15:46:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 3AD506EFB3 for ; Fri, 19 Feb 2016 15:46:27 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP; 19 Feb 2016 07:46:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,471,1449561600"; d="scan'208";a="50945766" Received: from pnogax-mobl.ger.corp.intel.com (HELO ivy.ger.corp.intel.com) ([10.252.60.226]) by fmsmga004.fm.intel.com with ESMTP; 19 Feb 2016 07:46:19 -0800 From: Lionel Landwerlin To: intel-gfx@lists.freedesktop.org Date: Fri, 19 Feb 2016 15:46:11 +0000 Message-Id: <1455896774-18259-3-git-send-email-lionel.g.landwerlin@intel.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1455896774-18259-1-git-send-email-lionel.g.landwerlin@intel.com> References: <1455896774-18259-1-git-send-email-lionel.g.landwerlin@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/5] lib: kms: add helpers for color management properties on pipes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP v2: Rename CTM_MATRIX property to CTM Signed-off-by: Lionel Landwerlin --- lib/igt_kms.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 17 +++++++++++++- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index dd4ca45..22996d5 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1179,6 +1179,21 @@ void igt_display_init(igt_display_t *display, int drm_fd) &prop_value, NULL); pipe->background = (uint32_t)prop_value; + get_crtc_property(display->drm_fd, output->config.crtc->crtc_id, + "DEGAMMA_LUT", + &pipe->degamma_property, + NULL, + NULL); + get_crtc_property(display->drm_fd, output->config.crtc->crtc_id, + "CTM_MATRIX", + &pipe->ctm_property, + NULL, + NULL); + get_crtc_property(display->drm_fd, output->config.crtc->crtc_id, + "GAMMA_LUT", + &pipe->gamma_property, + NULL, + NULL); } } } @@ -1328,6 +1343,16 @@ static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, enum igt_plane plane) return &pipe->planes[idx]; } +bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name, + uint32_t *prop_id, uint64_t *value, + drmModePropertyPtr *prop) +{ + return get_crtc_property(pipe->display->drm_fd, + pipe->crtc_id, + name, + prop_id, value, prop); +} + static uint32_t igt_plane_get_fb_id(igt_plane_t *plane) { if (plane->fb) @@ -1635,6 +1660,17 @@ static int igt_output_commit(igt_output_t *output, pipe->background_changed = false; } + if (pipe->color_mgmt_changed) { + igt_crtc_set_property(output, pipe->degamma_property, + pipe->degamma_blob); + igt_crtc_set_property(output, pipe->ctm_property, + pipe->ctm_blob); + igt_crtc_set_property(output, pipe->gamma_property, + pipe->gamma_blob); + + pipe->color_mgmt_changed = false; + } + for (i = 0; i < pipe->n_planes; i++) { igt_plane_t *plane = &pipe->planes[i]; @@ -1967,6 +2003,44 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation) plane->rotation_changed = true; } +static void +igt_pipe_replace_blob(igt_pipe_t *pipe, uint64_t *blob, void *ptr, size_t length) +{ + igt_display_t *display = pipe->display; + uint32_t blob_id = 0; + + if (*blob != 0) + igt_assert(drmModeDestroyPropertyBlob(display->drm_fd, + *blob) == 0); + + if (length > 0) + igt_assert(drmModeCreatePropertyBlob(display->drm_fd, + ptr, length, &blob_id) == 0); + + *blob = blob_id; +} + +void +igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length) +{ + igt_pipe_replace_blob(pipe, &pipe->degamma_blob, ptr, length); + pipe->color_mgmt_changed = 1; +} + +void +igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length) +{ + igt_pipe_replace_blob(pipe, &pipe->ctm_blob, ptr, length); + pipe->color_mgmt_changed = 1; +} + +void +igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length) +{ + igt_pipe_replace_blob(pipe, &pipe->gamma_blob, ptr, length); + pipe->color_mgmt_changed = 1; +} + /** * igt_crtc_set_background: * @pipe: pipe pointer to which background color to be set diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 77327c2..11a37d5 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -215,6 +215,15 @@ struct igt_pipe { uint64_t background; /* Background color MSB BGR 16bpc LSB */ uint32_t background_changed : 1; uint32_t background_property; + + uint64_t degamma_blob; + uint32_t degamma_property; + uint64_t ctm_blob; + uint32_t ctm_property; + uint64_t gamma_blob; + uint32_t gamma_property; + uint32_t color_mgmt_changed : 1; + uint32_t crtc_id; }; @@ -253,12 +262,19 @@ drmModeModeInfo *igt_output_get_mode(igt_output_t *output); void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode); void igt_output_set_pipe(igt_output_t *output, enum pipe pipe); igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane); +bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name, + uint32_t *prop_id, uint64_t *value, + drmModePropertyPtr *prop); static inline bool igt_plane_supports_rotation(igt_plane_t *plane) { return plane->rotation_property != 0; } +void igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length); +void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length); +void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length); + void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb); void igt_plane_set_position(igt_plane_t *plane, int x, int y); void igt_plane_set_size(igt_plane_t *plane, int w, int h); @@ -294,4 +310,3 @@ const unsigned char* igt_kms_get_alt_edid(void); #endif /* __IGT_KMS_H__ */ -