From patchwork Sun Jul 31 15:15:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinay Simha B N X-Patchwork-Id: 9253587 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 160EE60865 for ; Mon, 1 Aug 2016 01:29:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 073B228405 for ; Mon, 1 Aug 2016 01:29:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F02CA28408; Mon, 1 Aug 2016 01:29:18 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C31B28405 for ; Mon, 1 Aug 2016 01:29:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1FBCE6E166; Mon, 1 Aug 2016 01:28:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3530C6E169 for ; Sun, 31 Jul 2016 15:15:55 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id g202so8647792pfb.1 for ; Sun, 31 Jul 2016 08:15:55 -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=xktoSPMcwpXWkkQ8R8oVqLmFF5MA3qFiZIzuDCeyT4U=; b=mStQh6l/mtyiWD8DNWSyvT271XqaOn6SSt4kLOgIS0+aV22haMJHMj9RyGz2ct2etd Q9JcIyPfPSFXVzEz07wnEx0e4JEBTc/YFJ2sAhoCVMJ7Nra3lGugHsyswF0T++PRbEXI KX8BQIFBTD/9E+mr2t04JovOkE0OUFlNRTcZxhCGmJfQCV7PXlnmT8qGhKC3bm8AD611 P3trcs/4Dm+u2qTVwyqFJGXiuHKi4Nd+JKajk+ysVIDR6Hg/Qt3gyk8+KNkJe059UTij e+MBwRGybqluG6Dbyogroen8SHxIDpOPSHMTmVjbyTbAz6R3aBFCF5kq1VyPjeSPw786 wrTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xktoSPMcwpXWkkQ8R8oVqLmFF5MA3qFiZIzuDCeyT4U=; b=e6zBqA7TVAD5xoyh3PFu7NboVQHrVlReGXoyQkGXYdJa9ijb4umL+vIK9JZePmi+NM nWx+URIH9N1yrpTXWdnV5tCqbPOlrDk/MHeGhhNf+9Rs2K7I3MNlHPCkAjigyjVgffkc 3D2keQdnEKNgWt/IiGPfDNYP5L2GNHOM+pyD499xwxrppPSqCuWyjjdlYufHqqTe3dpY e3AGputMs3/DZHFdPCTlEJ608ho/qr8gTNGEyyIiXwaokQvhEGDqLxeY+YS7SZMCB7gt v8Xofm8HNxXhpNv1At1+SYi5C5oimJNnjY1RjVyHPtFzGirZS+QJfrJkkhotYtrJfao9 LlrA== X-Gm-Message-State: AEkoout/tNT9u9tHO6tgawBVapq8KdRh4VLrcx0U28cAl/gNBMEbjHU2oX6IBM4m+3uaDQ== X-Received: by 10.98.13.157 with SMTP id 29mr87105030pfn.105.1469978153394; Sun, 31 Jul 2016 08:15:53 -0700 (PDT) Received: from localhost.localdomain ([122.172.218.84]) by smtp.gmail.com with ESMTPSA id t1sm38760602pfa.86.2016.07.31.08.15.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 31 Jul 2016 08:15:52 -0700 (PDT) From: Vinay Simha BN To: Subject: [RESEND] [PATCH v3 3/4] drm/dsi: Implement dcs set/get display brightness Date: Sun, 31 Jul 2016 20:45:22 +0530 Message-Id: <1469978126-925-3-git-send-email-simhavcs@gmail.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1469978126-925-1-git-send-email-simhavcs@gmail.com> References: <1469978126-925-1-git-send-email-simhavcs@gmail.com> X-Mailman-Approved-At: Mon, 01 Aug 2016 01:28:21 +0000 Cc: Emil Velikov , open list , "open list:DRM DRIVERS" , Vinay Simha BN , Archit Taneja 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-Virus-Scanned: ClamAV using ClamSMTP Provide a small convenience wrapper that set/get the display brightness value Cc: John Stultz Cc: Sumit Semwal Cc: Archit Taneja Cc: Rob Clark Cc: Jani Nikula Cc: Thierry Reding Cc: Emil Velikov Signed-off-by: Vinay Simha BN Reviewed-by: Emil Velikov --- v1: *tested in nexus7 2nd gen. v2: * implemented jani review comments -functions name mapped accordingly -bl value increased from 0xff to 0xffff -backlight interface will be handled in panel driver, so it is moved from the mipi_dsi helper function v3: * emil review comments (err < 0) supposed to be (err <= 0) --- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 4 ++++ 2 files changed, 53 insertions(+) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index af0d471..43aa743 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -1041,6 +1041,55 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) } EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format); +/** + * mipi_dsi_dcs_get_display_brightness() - gets the current brightness value + * of the display + * @dsi: DSI peripheral device + * @brightness: brightness value + * + * Return: 0 on success or a negative error code on failure. + */ +int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, + u16 *brightness) +{ + ssize_t err; + + err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS, + brightness, sizeof(*brightness)); + if (err <= 0) { + if (err == 0) + err = -ENODATA; + + return err; + } + + return 0; +} +EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness); + +/** + * mipi_dsi_dcs_set_display_brightness() - sets the brightness value of + * the display + * @dsi: DSI peripheral device + * @brightness: brightness value + * + * Return: 0 on success or a negative error code on failure. + */ +int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, + u16 brightness) +{ + ssize_t err; + u8 bl_value[2] = { brightness & 0xff, brightness >> 8 }; + + err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, + bl_value, sizeof(bl_value)); + if (err < 0) + return err; + + return 0; +} +EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness); + static int mipi_dsi_drv_probe(struct device *dev) { struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver); diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index 47ac925..404c373 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -270,6 +270,10 @@ int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi); int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi, enum mipi_dsi_dcs_tear_mode mode); int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format); +int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, + u16 *brightness); +int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, + u16 brightness); /** * struct mipi_dsi_driver - DSI driver