From patchwork Thu May 4 07:14:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 9710855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E32260235 for ; Thu, 4 May 2017 07:16:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A4BC28601 for ; Thu, 4 May 2017 07:16:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EA2328673; Thu, 4 May 2017 07:16:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0417528601 for ; Thu, 4 May 2017 07:16:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57C3B6E406; Thu, 4 May 2017 07:16:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7E4C86E406 for ; Thu, 4 May 2017 07:16:02 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v447EfVd005082; Thu, 4 May 2017 02:14:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1493882081; bh=nPG1vh8op6Q0GU4sAEl+Je5OyzdKlxCODTpils7xMZQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=t36yR9L/u3iP1UxhvdTNsC6dEu4jsKvrmS6JNhed3eCA+aoHjFTXlX9tVzwfMhNB5 IVkU0HWwTJfCxeo1mlAFL+9MLYN41/JwH1Ic2B8WQaDUA7XmhhAZRIftmfN5kB+om+ 6t1HEkvQHT2bYVVz05Lp92MMIhxOQ8GpSXS6rMoY= Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v447EaaS027430; Thu, 4 May 2017 02:14:36 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Thu, 4 May 2017 02:14:35 -0500 Received: from jadmar.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v447EUTx019975; Thu, 4 May 2017 02:14:33 -0500 From: Jyri Sarha To: Subject: [PATCH RFC v2 1/2] drm: Add optinal YCBCR_ENCODING property to drm_plane Date: Thu, 4 May 2017 10:14:25 +0300 Message-ID: <7e2f54feee6108f859a11ac08e0377592d21e2e3.1493881618.git.jsarha@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 Cc: Liviu.Dudau@arm.com, Jyri Sarha , tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a standard optinal property to control YCbCr conversion in DRM planes. The property is stored to drm_plane object to allow different set of supported conversion modes for different planes on the device. Signed-off-by: Jyri Sarha --- drivers/gpu/drm/drm_atomic.c | 5 ++++ drivers/gpu/drm/drm_color_mgmt.c | 59 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_plane.c | 3 ++ include/drm/drm_color_mgmt.h | 14 ++++++++++ include/drm/drm_plane.h | 6 ++++ 5 files changed, 87 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 4033384..bcef93d 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -732,6 +732,7 @@ int drm_atomic_plane_set_property(struct drm_plane *plane, { struct drm_device *dev = plane->dev; struct drm_mode_config *config = &dev->mode_config; + int ret; if (property == config->prop_fb_id) { struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, val); @@ -774,6 +775,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane, state->rotation = val; } else if (property == plane->zpos_property) { state->zpos = val; + } else if (property == plane->ycbcr_encoding_property) { + state->ycbcr_encoding = val; } else if (plane->funcs->atomic_set_property) { return plane->funcs->atomic_set_property(plane, state, property, val); @@ -834,6 +837,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane, *val = state->rotation; } else if (property == plane->zpos_property) { *val = state->zpos; + } else if (property == plane->ycbcr_encoding_property) { + *val = state->ycbcr_encoding; } else if (plane->funcs->atomic_get_property) { return plane->funcs->atomic_get_property(plane, state, property, val); } else { diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 533f3a3..245b14a 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -33,6 +33,11 @@ * properties on the &drm_crtc object. They are set up by calling * drm_crtc_enable_color_mgmt(). * + * Support for different YCbCr color encodings is controlled trough + * plane specific YCBCR_ENCODING property. + * + * The &drm_crtc object's properties are: + * * "DEGAMMA_LUT”: * Blob property to set the degamma lookup table (LUT) mapping pixel data * from the framebuffer before it is given to the transformation matrix. @@ -85,6 +90,13 @@ * drm_mode_crtc_set_gamma_size(). Drivers which support both should use * drm_atomic_helper_legacy_gamma_set() to alias the legacy gamma ramp with the * "GAMMA_LUT" property above. + * + * The &drm_plane object's properties are: + * + * "YCBCR_ENCODING" + * Optional plane enum property to control YCbCr to RGB + * conversion. The driver provides a subset of standard + * enum values supported by the DRM plane. */ /** @@ -333,3 +345,50 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev, drm_modeset_unlock(&crtc->mutex); return ret; } + +static char *ycbcr_encoding_name[] = { + [DRM_PLANE_YCBCR_BT601_FULL_RANGE] = "BT.601 full range", + [DRM_PLANE_YCBCR_BT601_LIMITED_RANGE] = "BT.601 limited range", + [DRM_PLANE_YCBCR_BT709_LIMITED_RANGE] = "BT.709 limited range", + [DRM_PLANE_YCBCR_BT2020_LIMITED_RANGE] = "BT.2020 limited range", +}; + +/** + * drm_plane_create_ycbcr_properties - ycbcr related plane properties + * @enum_list: drm_prop_enum_list array of supported modes without names + * @enum_list_len: length of enum_list array + * @default_mode: default YCbCr encoding + * + * Create and attach plane specific YCBCR_ENCODING property to to the + * drm_plane object. The supported encodings should be provided in the + * enum_list parameter. The enum_list parameter should not contain the + * enum names, because the standard names are added by this function. + */ +int drm_plane_create_ycbcr_properties(struct drm_plane *plane, + struct drm_prop_enum_list *enum_list, + unsigned int enum_list_len, + enum drm_plane_ycbcr_encoding default_mode) +{ + struct drm_device *dev = plane->dev; + struct drm_property *prop; + unsigned int i; + + if (WARN_ON(plane->ycbcr_encoding_property != NULL)) + return -EEXIST; + + for (i = 0; i < enum_list_len; i++) { + enum drm_plane_ycbcr_encoding encoding = enum_list[i].type; + + enum_list[i].name = ycbcr_encoding_name[encoding]; + } + + prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC, + "YCBCR_ENCODING", + enum_list, enum_list_len); + if (!prop) + return -ENOMEM; + plane->ycbcr_encoding_property = prop; + drm_object_attach_property(&plane->base, prop, default_mode); + + return 0; +} diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index fedd4d6..007c4d7 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -244,6 +244,9 @@ void drm_plane_cleanup(struct drm_plane *plane) kfree(plane->name); + if (plane->ycbcr_encoding_property) + drm_property_destroy(dev, plane->ycbcr_encoding_property); + memset(plane, 0, sizeof(*plane)); } EXPORT_SYMBOL(drm_plane_cleanup); diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index 03a59cb..1771394 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -26,6 +26,8 @@ #include struct drm_crtc; +struct drm_plane; +struct drm_prop_enum_list; uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); @@ -37,4 +39,16 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, int gamma_size); +enum drm_plane_ycbcr_encoding { + DRM_PLANE_YCBCR_BT601_FULL_RANGE = 0, + DRM_PLANE_YCBCR_BT601_LIMITED_RANGE, + DRM_PLANE_YCBCR_BT709_LIMITED_RANGE, + DRM_PLANE_YCBCR_BT2020_LIMITED_RANGE, +}; + +int drm_plane_create_ycbcr_properties(struct drm_plane *plane, + struct drm_prop_enum_list *enum_list, + unsigned int enum_list_len, + enum drm_plane_ycbcr_encoding default_mode); + #endif diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 9ab3e70..4d0510f 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -26,6 +26,7 @@ #include #include #include +#include struct drm_crtc; struct drm_printer; @@ -112,6 +113,9 @@ struct drm_plane_state { unsigned int zpos; unsigned int normalized_zpos; + /* YCbCr to RGB conversion */ + enum drm_plane_ycbcr_encoding ycbcr_encoding; + /* Clipped coordinates */ struct drm_rect src, dst; @@ -523,6 +527,8 @@ struct drm_plane { struct drm_property *zpos_property; struct drm_property *rotation_property; + + struct drm_property *ycbcr_encoding_property; }; #define obj_to_plane(x) container_of(x, struct drm_plane, base)