From patchwork Fri Oct 31 22:53:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5207691 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 81E529F387 for ; Fri, 31 Oct 2014 23:57:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 979F220173 for ; Fri, 31 Oct 2014 23:57:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C0A1820120 for ; Fri, 31 Oct 2014 23:57:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B794C6E897; Fri, 31 Oct 2014 16:56:42 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by gabe.freedesktop.org (Postfix) with ESMTP id A7DE16E84A for ; Fri, 31 Oct 2014 15:56:54 -0700 (PDT) Received: by mail-pa0-f51.google.com with SMTP id kq14so8531292pab.24 for ; Fri, 31 Oct 2014 15:56:54 -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=VkvdZOD3WKgBqrj9glZQ68ZO4SXSc84+yBFyWV67Dto=; b=SRi/TrJL2POOIGW1MOzPifftcYPksEPFkWOBZ02l/0KJI6Cfsi1kYBR/GFnOQaRKzQ 2gyCrBZgNKxKrbLHK9FBXlTQxieKVQgI6hnTbIGX58Ir38H7ydSId3cDsH9w3S+oMLo0 mqXePs2n5VqDWj/69LNSrPZC1f4sEFWlcRrHUqOZPEfA6b7RpnbgElZgPDU/ZfQCM5v5 EACRYhizBnK82XnkKeBFJoKeT6FnezCkih/TJgWr3ZeLYUg0RTxXpTLXpYQkhzeXvw/9 nlgv0VYvnsNWz+vugsvIhyVsDk5CnS61S2qRq7VCd0eqKkPvH1ZiNQe9VRs1r9FhP+FH T74g== X-Received: by 10.67.30.34 with SMTP id kb2mr27081337pad.97.1414796214556; Fri, 31 Oct 2014 15:56:54 -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.56.53 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 15:56:53 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org Subject: [PATCH 08/72] gpu: ipu-v3: Add ipu_dp_set_gamma_correction() Date: Fri, 31 Oct 2014 15:53:51 -0700 Message-Id: <1414796095-10107-9-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:31 -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 Adds the function ipu_dp_set_gamma_correction(), which programs the piecewise linear curve that approximates a gamma correction curve. Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-dp.c | 46 +++++++++++++++++++++++++++++++++++++++++++ include/video/imx-ipu-v3.h | 2 ++ 2 files changed, 48 insertions(+) diff --git a/drivers/gpu/ipu-v3/ipu-dp.c b/drivers/gpu/ipu-v3/ipu-dp.c index e4026f1..472acd6 100644 --- a/drivers/gpu/ipu-v3/ipu-dp.c +++ b/drivers/gpu/ipu-v3/ipu-dp.c @@ -29,6 +29,8 @@ #define DP_COM_CONF 0x0 #define DP_GRAPH_WIND_CTRL 0x0004 #define DP_FG_POS 0x0008 +#define DP_GAMMA_C(i) (0x0014 + ((i) / 2) * 4) +#define DP_GAMMA_S(i) (0x0034 + ((i) / 4) * 4) #define DP_CSC_A_0 0x0044 #define DP_CSC_A_1 0x0048 #define DP_CSC_A_2 0x004C @@ -45,6 +47,8 @@ #define DP_COM_CONF_CSC_DEF_FG (3 << 8) #define DP_COM_CONF_CSC_DEF_BG (2 << 8) #define DP_COM_CONF_CSC_DEF_BOTH (1 << 8) +#define DP_COM_CONF_GAMMA_EN (1 << 12) +#define DP_COM_CONF_GAMMA_YUV_EN (1 << 13) #define IPUV3_NUM_FLOWS 3 @@ -208,6 +212,48 @@ int ipu_dp_set_chroma_key(struct ipu_dp *dp, bool enable, u32 color_key) } EXPORT_SYMBOL(ipu_dp_set_chroma_key); +/* + * Programs a piecewise linear curve that approximates the gamma curve. + * Sixteen lines in the curve must be provided, that is, m[] and b[] + * must each have sixteen entries, where m[] and b[] contain the slope + * and y-intercept of each line respectively. + */ +int ipu_dp_set_gamma_correction(struct ipu_dp *dp, bool enable, u32 *m, u32 *b) +{ + struct ipu_flow *flow = to_flow(dp); + struct ipu_dp_priv *priv = flow->priv; + u32 reg; + int i; + + mutex_lock(&priv->mutex); + + for (i = 0; i < 16; i += 2) + writel((b[i] & 0x1ff) | ((b[i + 1] & 0x1ff) << 16), + flow->base + DP_GAMMA_C(i)); + for (i = 0; i < 16; i += 4) + writel((m[i] & 0xff) | ((m[i + 1] & 0xff) << 8) | + ((m[i + 2] & 0xff) << 16) | ((m[i + 3] & 0xff) << 24), + flow->base + DP_GAMMA_S(i)); + + reg = readl(flow->base + DP_COM_CONF); + if (enable) { + if (flow->out_cs == IPUV3_COLORSPACE_YUV) + reg |= DP_COM_CONF_GAMMA_YUV_EN; + else + reg &= ~DP_COM_CONF_GAMMA_YUV_EN; + reg |= DP_COM_CONF_GAMMA_EN; + } else + reg &= ~DP_COM_CONF_GAMMA_EN; + writel(reg, flow->base + DP_COM_CONF); + + ipu_srm_dp_sync_update(priv->ipu); + + mutex_unlock(&priv->mutex); + + return 0; +} +EXPORT_SYMBOL(ipu_dp_set_gamma_correction); + int ipu_dp_set_window_pos(struct ipu_dp *dp, u16 x_pos, u16 y_pos) { struct ipu_flow *flow = to_flow(dp); diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index e878343..6fa86c7 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -274,6 +274,8 @@ int ipu_dp_set_window_pos(struct ipu_dp *, u16 x_pos, u16 y_pos); int ipu_dp_set_global_alpha(struct ipu_dp *dp, bool enable, u8 alpha, bool bg_chan); int ipu_dp_set_chroma_key(struct ipu_dp *dp, bool enable, u32 color_key); +int ipu_dp_set_gamma_correction(struct ipu_dp *dp, bool enable, + u32 *m, u32 *b); /* * IPU CMOS Sensor Interface (csi) functions