From patchwork Fri Jun 17 18:23:25 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: 9186367 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 9C8C6601C0 for ; Mon, 20 Jun 2016 00:45:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AD04200F5 for ; Mon, 20 Jun 2016 00:45:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7ED2F205AD; Mon, 20 Jun 2016 00:45:31 +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 2D874200F5 for ; Mon, 20 Jun 2016 00:45:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EFD36E03C; Mon, 20 Jun 2016 00:45:27 +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 AC8E26EC99 for ; Fri, 17 Jun 2016 18:23:45 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id i123so3657667pfg.3 for ; Fri, 17 Jun 2016 11:23:45 -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=PB0r01vlgMDckf670FYxt6oQiuVt0PbHVVgXX5qjq50=; b=YsI0zLmoTTMywF7nQ2n3us9u2tVpdx8XezeXcf1loKHK9RvzPX+s9iBNRsXS86dTTT R9aWHcc+rIhQDET0UgX8UwC9g8TabbDkfjtiXyeVsR7JWSBlLywVJpPI0BmQ3t3dVJJt rXxBmM5btZlS/2BaDe+pNyFW1s4EoYUvHlpp6OYCFdwyo5aq/tNcnzkJhb2atOeB4mkV YG68KKf+9MV0X8ULaLwLTiDU9I2bZl9XY7uRkX7ugwp9mwnkvbHSpN14tlhut55wSrlw gor9f6DHifDopx/SyRQNtbbmTA4hmZWdfaJA6Xao1KM6OBILkGkfuvNf5/VWIYU0RdlY 0mig== 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=PB0r01vlgMDckf670FYxt6oQiuVt0PbHVVgXX5qjq50=; b=QSlzP6AAS3npJG8Npf7oxGVFKQ7mCV4LAsBcNspz7KEox9msWrN5cTvN4BN6K5M9gP ALpAzBmefleFqOBUQrY34WWED5N4tRHUdGpoQEvn2gIJpnXAwQn2dS5IK7n7DsoJS+Im oyG3NCKEJ6QtyTgQZeO2LEGai0MmSaW23wqGd99oclkdQmxUzJbxDTNAgSJH/XNbGd3o X9kz+1VhUeoHT0nmzqE+rtAbuFD7x5saQtxRBrXDRLBdmXGXikhcUPW4gHBPBKd/GeSs vWjaRbQLzg62f0gC4/a+IT+HGoTPk0EJk1fIZKKHkAxwEshRPf863qOKukgB3kuI4G/o 579Q== X-Gm-Message-State: ALyK8tIZZpnhtHSZbxDWcEfhFN44+6SzPelShun6LGXrNz+HhvmXJ60HYqP7cPcXXkZ5Ww== X-Received: by 10.98.9.68 with SMTP id e65mr3726957pfd.121.1466187824686; Fri, 17 Jun 2016 11:23:44 -0700 (PDT) Received: from localhost.localdomain ([122.172.52.42]) by smtp.gmail.com with ESMTPSA id b71sm37717974pfc.51.2016.06.17.11.23.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jun 2016 11:23:44 -0700 (PDT) From: Vinay Simha BN To: Subject: [PATCH v2 1/2] drm/dsi: Implement dcs set/get display brightness Date: Fri, 17 Jun 2016 23:53:25 +0530 Message-Id: <1466187806-29465-1-git-send-email-simhavcs@gmail.com> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Mon, 20 Jun 2016 00:45:07 +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 Cc: Thierry Reding 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 49311fc..2c03784 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 72f5b15..4d77bb0 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