From patchwork Fri Oct 31 22:54:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5207731 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2F72C9F318 for ; Fri, 31 Oct 2014 23:57:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41BB420172 for ; Fri, 31 Oct 2014 23:57:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 25BF3201B9 for ; Fri, 31 Oct 2014 23:57:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 19BE26E8B8; Fri, 31 Oct 2014 16:56:44 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by gabe.freedesktop.org (Postfix) with ESMTP id B37FB6E84B for ; Fri, 31 Oct 2014 15:57:34 -0700 (PDT) Received: by mail-pa0-f42.google.com with SMTP id bj1so8573346pad.15 for ; Fri, 31 Oct 2014 15:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H6wYmeV42jkwCJXZBblWADlaQZiYdc0/GimYkyegqg0=; b=yxqqNznDObiMrroylAWCCgF4btoVlesrBx8EoILS10GENBM9K5xBU0LbLBf1V1X2Oc +AO+6gCgTmmoROr5AhyRQ5Yqb6saifzDppYOZZL5Cml2qqzU2Rzn9bDZaPNWPJa9CmqZ uaa7NTIc9UxDlw/cSFXvutTGa/JKfGqgLFTa+vGYW72pg8GqTVvX2wnLA0TuhCb4lmmr oPaZxSrLWTH5NHNsjSbo2mIekLneMOr+pC9crHV0Wbd/2YQYpIyvOKKOHSsBRLXDr9L7 fVwKvXPgrUqgaYj4b8fkKrcKPIGhSwhlRvKMyDHNTLiICpSr3eEUDjDb7SCrONCthYjV BLag== X-Received: by 10.69.26.133 with SMTP id iy5mr27891146pbd.114.1414796254581; Fri, 31 Oct 2014 15:57:34 -0700 (PDT) Received: from mothership.mgc.mentorg.com (c-50-152-159-227.hsd1.ca.comcast.net. [50.152.159.227]) by mx.google.com with ESMTPSA id ev8sm10870656pdb.28.2014.10.31.15.57.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 15:57:34 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org Subject: [PATCH 56/72] imx-drm: Implement custom ioctl to set gamma Date: Fri, 31 Oct 2014 15:54:39 -0700 Message-Id: <1414796095-10107-57-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> References: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> X-Mailman-Approved-At: Fri, 31 Oct 2014 16:56:32 -0700 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Implement i.MX specific ioctl to set gamma directly using slope and y-intercept values that define the piecewise linear gamma correction curve. Signed-off-by: Steve Longerbeam --- drivers/staging/imx-drm/imx-drm-core.c | 40 +++++++++++++++++++++++++++++++- drivers/staging/imx-drm/imx-drm.h | 3 +-- drivers/staging/imx-drm/ipuv3-crtc.c | 9 +++++++ include/uapi/drm/imx_drm.h | 30 ++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 include/uapi/drm/imx_drm.h diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 084ed53..4c85fd3 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "imx-drm.h" @@ -122,6 +123,18 @@ static struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc) return NULL; } +static struct imx_drm_crtc *imx_drm_find_crtc_by_id(struct drm_device *drm, + u32 crtc_id) +{ + struct drm_crtc *crtc; + + crtc = drm_crtc_find(drm, crtc_id); + if (!crtc) + return NULL; + + return imx_drm_find_crtc(crtc); +} + int imx_drm_panel_format_pins(struct drm_encoder *encoder, u32 interface_pix_fmt, int hsync_pin, int vsync_pin) { @@ -537,8 +550,33 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, } EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id); +static int drm_imx_set_gamma_ioctl(struct drm_device *drm, void *data, + struct drm_file *file_priv) +{ + struct drm_imx_gamma *g = data; + struct imx_drm_crtc_helper_funcs *helper; + struct imx_drm_crtc *imx_crtc; + int ret = -EINVAL; + + if (!drm_core_check_feature(drm, DRIVER_MODESET)) + return -ENODEV; + + drm_modeset_lock_all(drm); + + imx_crtc = imx_drm_find_crtc_by_id(drm, g->crtc_id); + if (!imx_crtc) + goto out_unlock; + + helper = &imx_crtc->imx_drm_helper_funcs; + ret = helper->gamma_set(imx_crtc->crtc, g->enable, g->m, g->b); + +out_unlock: + drm_modeset_unlock_all(drm); + return ret; +} + static const struct drm_ioctl_desc imx_drm_ioctls[] = { - /* none so far */ + DRM_IOCTL_DEF_DRV(IMX_SET_GAMMA, drm_imx_set_gamma_ioctl, DRM_AUTH), }; static struct drm_driver imx_drm_driver = { diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index bf6b06b..0bb4735 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -21,6 +21,7 @@ struct imx_drm_crtc_helper_funcs { void (*disable_vblank)(struct drm_crtc *crtc, int pipe); int (*set_interface_pix_fmt)(struct drm_crtc *crtc, u32 encoder_type, u32 pix_fmt, int hsync_pin, int vsync_pin); + int (*gamma_set)(struct drm_crtc *crtc, bool enable, u32 *m, u32 *b); const struct drm_crtc_helper_funcs *crtc_helper_funcs; const struct drm_crtc_funcs *crtc_funcs; }; @@ -52,6 +53,4 @@ int imx_drm_encoder_parse_of(struct drm_device *drm, void imx_drm_connector_destroy(struct drm_connector *connector); void imx_drm_encoder_destroy(struct drm_encoder *encoder); -#define DRM_IMX_GAMMA_SIZE 16 - #endif /* _IMX_DRM_H_ */ diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 4f2ba40..8d7c998 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -29,6 +29,7 @@ #include #include #include +#include #include