From patchwork Thu Feb 15 05:32:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Castagna X-Patchwork-Id: 10220601 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 D90F46056E for ; Thu, 15 Feb 2018 08:38:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C84F9290B4 for ; Thu, 15 Feb 2018 08:38:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD588290B8; Thu, 15 Feb 2018 08:38:33 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 6DB25290B4 for ; Thu, 15 Feb 2018 08:38:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2CB8F6E218; Thu, 15 Feb 2018 08:36:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id B82166E0A6 for ; Thu, 15 Feb 2018 05:33:18 +0000 (UTC) Received: by mail-qt0-f194.google.com with SMTP id d14so10601910qtg.1 for ; Wed, 14 Feb 2018 21:33:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Ily4A/X4vXl0kbYMNwWjKUJm2I87Lz2+srcVB5j/SYQ=; b=HPwufMJjskANen5G4m6QibdGUoTyP21p7zWB+NcnVBKdWZnh4gcaN98/LSw/HdqdRo qmluFjH9MgXyrstQU2PQnMZqD8H8nDrdxP4Ha9hfIVhS90bfhUAANvfSRteKVllHURQz +ZETcopgfX88KCwiPAdho+eqElXzLKcNrtioOZDSCFD6mq50rdwF9pChZEp2vjQB4Bqj gzZnLoL6ETMUflC75zseaF4jVm7DOM8m8ZujeSfhnLlSVagParVfOTpTJOjoPlqYPbx8 8/Zc8+2MTNWygzRmmtiHPr2dwMJxlNjOMG2LZe48n2e3z4an89fbbar9LbTo0hAYU7/5 k1Fw== X-Gm-Message-State: APf1xPBC82NUqEL1D0rc1PWu85ISn9BtLAxgbj8II4KyVeTZCIarDyJY gLu2ShYJIa4m0pTDvJtUs9YTmZ5E6xU= X-Google-Smtp-Source: AH8x22482sNjf1BipDm5nDToXCE8tNhc9EwVkW0cNvCnXoDL/ytdoXYThfrlPLXbRtPJoYIUn1Fy/g== X-Received: by 10.237.59.59 with SMTP id p56mr2562823qte.84.1518672797373; Wed, 14 Feb 2018 21:33:17 -0800 (PST) Received: from dcastagna1.nyc.corp.google.com ([2620:0:1003:101a:749d:49f2:f0b1:dd83]) by smtp.gmail.com with ESMTPSA id l62sm13808198qkl.23.2018.02.14.21.33.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 21:33:16 -0800 (PST) From: Daniele Castagna To: dri-devel@lists.freedesktop.org Subject: [PATCH 06/10] drm: Define helper to set legacy gamma table size Date: Thu, 15 Feb 2018 00:32:56 -0500 Message-Id: <20180215053300.70482-7-dcastagna@chromium.org> X-Mailer: git-send-email 2.16.1.291.g4437f3f132-goog In-Reply-To: <20180215053300.70482-1-dcastagna@chromium.org> References: <20180215053300.70482-1-dcastagna@chromium.org> X-Mailman-Approved-At: Thu, 15 Feb 2018 08:36:06 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "uma.shankar at intel.com (Uma Shankar)" Define a helper function to set legacy gamma table size for planes. (am from https://patchwork.kernel.org/patch/9971343/) Change-Id: I3d0c3e71d92300259cdfcebed4349207f64e4083 Signed-off-by: Uma Shankar --- drivers/gpu/drm/drm_color_mgmt.c | 41 ++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 3 +++ include/drm/drm_plane.h | 4 ++++ 3 files changed, 48 insertions(+) diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 0d002b045bd26..8f360b3ae0f24 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -203,6 +203,47 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, } EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size); +/** + * drm_mode_plane_set_gamma_size - set the gamma table size + * @plane: Plane to set the gamma table size for + * @gamma_size: size of the gamma table + * + * Drivers which support gamma tables should set this to the supported gamma + * table size when initializing the Plane. Currently the drm core only supports + * a fixed gamma table size. + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_mode_plane_set_gamma_size(struct drm_plane *plane, + int gamma_size) +{ + uint16_t *r_base, *g_base, *b_base; + int i; + + plane->gamma_size = gamma_size; + + plane->gamma_store = kcalloc(gamma_size, sizeof(uint16_t) * 3, + GFP_KERNEL); + if (!plane->gamma_store) { + plane->gamma_size = 0; + return -ENOMEM; + } + + r_base = plane->gamma_store; + g_base = r_base + gamma_size; + b_base = g_base + gamma_size; + for (i = 0; i < gamma_size; i++) { + r_base[i] = i << 8; + g_base[i] = i << 8; + b_base[i] = i << 8; + } + + + return 0; +} +EXPORT_SYMBOL(drm_mode_plane_set_gamma_size); + /** * drm_mode_gamma_set_ioctl - set the gamma table * @dev: DRM device diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index 155a9ba38471c..2f59c820e148c 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -42,4 +42,7 @@ void drm_plane_enable_color_mgmt(struct drm_plane *plane, bool plane_has_ctm, uint plane_gamma_lut_size); +int drm_mode_plane_set_gamma_size(struct drm_plane *plane, + int plane_gamma_size); + #endif diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index acabb85009a14..18d09eacbcd7d 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -585,6 +585,10 @@ struct drm_plane { struct drm_property *zpos_property; struct drm_property *rotation_property; + + /* Legacy FB Plane gamma size for reporting to userspace */ + uint32_t gamma_size; + uint16_t *gamma_store; }; #define obj_to_plane(x) container_of(x, struct drm_plane, base)