From patchwork Mon Jun 13 10:25:27 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: 9174763 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 418A66075D for ; Tue, 14 Jun 2016 00:28:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33F4527D45 for ; Tue, 14 Jun 2016 00:28:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2883228047; Tue, 14 Jun 2016 00:28:43 +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 A614327DF9 for ; Tue, 14 Jun 2016 00:28:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA46F6E59D; Tue, 14 Jun 2016 00:28:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-x242.google.com (mail-pa0-x242.google.com [IPv6:2607:f8b0:400e:c03::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8F6C6E50A for ; Mon, 13 Jun 2016 10:26:04 +0000 (UTC) Received: by mail-pa0-x242.google.com with SMTP id hf6so2433752pac.2 for ; Mon, 13 Jun 2016 03:26:04 -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; bh=e7fGqapT6c3WzodszBaOfiR2m6owmoxme8OhFvDFK2U=; b=mrXOpdGseE1avXg6vQtVyBOOGbuofg1tWnKjzAr1B8QATuXOWnYkKach7jk/HfRXvX uyOxaO12ZPhs+HaNtIstpuSieNAIay9wx+8zNDjRIpte2jytaAKwJ2ubMCwsnxisilpm 7R0+hBdTfyjGrKItJexnLbEtII9ksh1jhTqc0L6Pt59s5eaD7qwcRabVspBZgVGRDDki /XaAmDE++zWCoDtndZ+JoauqGelzt6fueEyb4N5t1/Bk5lo5EtWZAHoHcdZKZw9oWvxk DtUOCrW4ydDJMsjsrfJw639eFOTNTR+sCcAgxGJcmdSH26YVm6RXVFb6YVIynSmm84Iv RHRQ== 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; bh=e7fGqapT6c3WzodszBaOfiR2m6owmoxme8OhFvDFK2U=; b=meQo5H0AVAlXI7lUiIVGQjeJN6BKRWudoKXTKe9qZdQ+DnW5H4yCPh5vvuUE58ijtC KfFjq2A9pcZQj5i06lf9mLnQoBFyieG7nxgUC+1RF6Vo/LNFsvx18i/zWCgy21OhNOet E6sVo/SRc33+izlFK6zpWViPTN1koEZ0sd+kTfnSRQQSzEnxBaSugm0YiVRdZVOhIoIn 2wHLkRAKzuqrFY7Eh4T982Y9eF8JV8J13Wy3P7QIsVTNNb1ro5BEIBPOj2vW7WJdFWbC A/OGECUDGrler6UESDo06Q9yKhIcnasJ0CTA9L8UiH/8La2zVdg0B3b/KhgiMaQTooVq 1Rxw== X-Gm-Message-State: ALyK8tIf0HudaesDMVc6y6BEcXG2lKQ9xeISU3E9gI6j//iHqNl5QvMxs7nQvCmYP/KtiQ== X-Received: by 10.66.4.129 with SMTP id k1mr21134833pak.45.1465813563567; Mon, 13 Jun 2016 03:26:03 -0700 (PDT) Received: from localhost.localdomain ([202.83.17.75]) by smtp.gmail.com with ESMTPSA id s131sm36493354pfs.45.2016.06.13.03.26.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jun 2016 03:26:02 -0700 (PDT) From: Vinay Simha BN To: Subject: [PATCH v2 1/2] drm/dsi: Implement dcs set/get display brightness Date: Mon, 13 Jun 2016 15:55:27 +0530 Message-Id: <1465813529-30621-1-git-send-email-simhavcs@gmail.com> X-Mailer: git-send-email 2.1.2 X-Mailman-Approved-At: Tue, 14 Jun 2016 00:28:22 +0000 Cc: 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 Signed-off-by: Vinay Simha BN --- 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 --- 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 7938ce7..5661a00 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -1025,6 +1025,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 ec55285..4494641 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -268,6 +268,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