From patchwork Fri Jul 24 12:24:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Deepak M X-Patchwork-Id: 6860211 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E6B4B9F380 for ; Fri, 24 Jul 2015 12:20:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C6C6204CF for ; Fri, 24 Jul 2015 12:20:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6C7D0204B5 for ; Fri, 24 Jul 2015 12:20:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 410BD6E760; Fri, 24 Jul 2015 05:20:08 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B01F6E760 for ; Fri, 24 Jul 2015 05:20:07 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 24 Jul 2015 05:20:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,538,1432623600"; d="scan'208";a="753801641" Received: from mdeepakubuntudesk01-desktop.iind.intel.com ([10.223.25.91]) by fmsmga001.fm.intel.com with ESMTP; 24 Jul 2015 05:20:05 -0700 From: Deepak M To: intel-gfx@lists.freedesktop.org Date: Fri, 24 Jul 2015 17:54:09 +0530 Message-Id: <1437740649-9168-1-git-send-email-m.deepak@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <20150706125106.GZ2156@phenom.ffwll.local> References: <20150706125106.GZ2156@phenom.ffwll.local> MIME-Version: 1.0 Cc: Deepak M Subject: [Intel-gfx] =?utf-8?q?=5BRFC_CABC_PATCH_v2_3/3=5D_drm/i915=3A_CAB?= =?utf-8?q?C_support_for_backlight_control?= X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 In CABC (Content Adaptive Brightness Control) content grey level scale can be increased while simultaneously decreasing brightness of the backlight to achieve same perceived brightness. The CABC is not standardized and panel vendors are free to follow their implementation. The CABC implementaion here assumes that the panels use standard SW register for control. In this design there will be no PWM signal from the SoC and DCS commands are sent to enable and control the backlight brightness. v2: - Created a new backlight driver for cabc, which will be registered only when it cabc is supported by panel. (Addressed comment from Daniel Vetter) Signed-off-by: Deepak M --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/intel_drv.h | 3 +- drivers/gpu/drm/i915/intel_dsi.c | 13 ++ drivers/gpu/drm/i915/intel_dsi_cabc.c | 349 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_dsi_cabc.h | 45 +++++ drivers/gpu/drm/i915/intel_panel.c | 22 ++- include/video/mipi_display.h | 8 + 7 files changed, 436 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_dsi_cabc.c create mode 100644 drivers/gpu/drm/i915/intel_dsi_cabc.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index de21965..a73953c 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -75,6 +75,7 @@ i915-y += dvo_ch7017.o \ intel_dp_mst.o \ intel_dsi.o \ intel_dsi_pll.o \ + intel_dsi_cabc.o \ intel_dsi_panel_vbt.o \ intel_dvo.o \ intel_hdmi.o \ diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 3f0a890..9f806dd5 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1319,7 +1319,8 @@ extern struct drm_display_mode *intel_find_panel_downclock( struct drm_connector *connector); void intel_backlight_register(struct drm_device *dev); void intel_backlight_unregister(struct drm_device *dev); - +extern int cabc_backlight_device_register(struct intel_connector *connector); +extern void cabc_backlight_device_unregister(struct intel_connector *connector); /* intel_psr.c */ void intel_psr_enable(struct intel_dp *intel_dp); diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c index 98998e9..8f006f2 100644 --- a/drivers/gpu/drm/i915/intel_dsi.c +++ b/drivers/gpu/drm/i915/intel_dsi.c @@ -34,6 +34,7 @@ #include "i915_drv.h" #include "intel_drv.h" #include "intel_dsi.h" +#include "intel_dsi_cabc.h" static const struct { u16 panel_id; @@ -376,6 +377,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder) struct drm_device *dev = encoder->base.dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); + struct intel_connector *connector = intel_dsi->attached_connector; enum port port; DRM_DEBUG_KMS("\n"); @@ -396,6 +398,9 @@ static void intel_dsi_enable(struct intel_encoder *encoder) intel_dsi_port_enable(encoder); } + + if (dev_priv->vbt.dsi.config->cabc_supported) + cabc_enable_backlight(connector); } static void intel_dsi_pre_enable(struct intel_encoder *encoder) @@ -469,11 +474,15 @@ static void intel_dsi_disable(struct intel_encoder *encoder) struct drm_device *dev = encoder->base.dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); + struct intel_connector *connector = intel_dsi->attached_connector; enum port port; u32 temp; DRM_DEBUG_KMS("\n"); + if (dev_priv->vbt.dsi.config->cabc_supported) + cabc_disable_backlight(connector); + if (is_vid_mode(intel_dsi)) { for_each_dsi_port(port, intel_dsi->ports) wait_for_dsi_fifo_empty(intel_dsi, port); @@ -1099,6 +1108,10 @@ void intel_dsi_init(struct drm_device *dev) intel_panel_init(&intel_connector->panel, fixed_mode, NULL); + if (dev_priv->vbt.dsi.config->cabc_supported) + cabc_setup_backlight(connector, + intel_encoder->crtc_mask == + (1 << PIPE_A) ? PIPE_A : PIPE_B); return; err: diff --git a/drivers/gpu/drm/i915/intel_dsi_cabc.c b/drivers/gpu/drm/i915/intel_dsi_cabc.c new file mode 100644 index 0000000..2a78326 --- /dev/null +++ b/drivers/gpu/drm/i915/intel_dsi_cabc.c @@ -0,0 +1,349 @@ +/* + * Copyright © 2006-2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#include +#include +#include "intel_drv.h" +#include "intel_dsi.h" +#include "i915_drv.h" +#include "intel_dsi_cabc.h" +#include