From patchwork Fri Jun 26 13:51:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 6681171 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DEB31C05AC for ; Fri, 26 Jun 2015 14:00:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF595204A7 for ; Fri, 26 Jun 2015 14:00:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9DA782049C for ; Fri, 26 Jun 2015 14:00:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0276D6E724; Fri, 26 Jun 2015 07:00:11 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id A61DD7A143 for ; Fri, 26 Jun 2015 07:00:08 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 26 Jun 2015 07:00:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,685,1427785200"; d="scan'208";a="750978293" Received: from ramaling-desktop.iind.intel.com ([10.223.26.95]) by fmsmga002.fm.intel.com with ESMTP; 26 Jun 2015 07:00:05 -0700 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, chris@chris-wilson.co.uk, rodrigo.vivi@intel.com Date: Fri, 26 Jun 2015 19:21:51 +0530 Message-Id: <1435326722-24633-8-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1435326722-24633-1-git-send-email-ramalingam.c@intel.com> References: <1435326722-24633-1-git-send-email-ramalingam.c@intel.com> Cc: paulo.r.zanoni@intel.com Subject: [Intel-gfx] [RFC PATCH 07/18] drm/i915: Generic eDP DRRS implementation 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.6 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 This patch Implements the generic eDP DRRS functions and registers them with Generic DRRS state machine. Platform specific eDP DRRS functions will be implemented and registered with this generic eDP DRRS implementation. Hence extending the eDP DRRS to new platform is made simple. Signed-off-by: Ramalingam C --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/intel_dp.c | 6 +++ drivers/gpu/drm/i915/intel_drrs.c | 2 + drivers/gpu/drm/i915/intel_drv.h | 3 ++ drivers/gpu/drm/i915/intel_edp_drrs.c | 95 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_edp_drrs.h | 29 ++++++++++ 6 files changed, 136 insertions(+) create mode 100644 drivers/gpu/drm/i915/intel_edp_drrs.c create mode 100644 drivers/gpu/drm/i915/intel_edp_drrs.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 4f77fb2..9a3c43f 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -56,6 +56,7 @@ i915-y += intel_audio.o \ intel_psr.o \ intel_drrs.o \ intel_dsi_drrs.o \ + intel_edp_drrs.o \ intel_sideband.o \ intel_sprite.o i915-$(CONFIG_ACPI) += intel_acpi.o intel_opregion.o diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 738e98e..9ded4d1 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -1483,6 +1483,12 @@ found: pipe_config->port_clock, &pipe_config->dp_m_n); + if (intel_connector->panel.downclock_mode) + intel_link_compute_m_n(bpp, lane_count, + intel_connector->panel.downclock_mode->clock, + pipe_config->port_clock, + &pipe_config->dp_m2_n2); + if (IS_SKYLAKE(dev) && is_edp(intel_dp)) skl_edp_set_pll_config(pipe_config, common_rates[clock]); else if (IS_BROXTON(dev)) diff --git a/drivers/gpu/drm/i915/intel_drrs.c b/drivers/gpu/drm/i915/intel_drrs.c index 2a776d2..e5d8bcd 100644 --- a/drivers/gpu/drm/i915/intel_drrs.c +++ b/drivers/gpu/drm/i915/intel_drrs.c @@ -388,6 +388,8 @@ int intel_drrs_init(struct drm_device *dev, if (intel_encoder->type == INTEL_OUTPUT_DSI) { drrs->encoder_ops = get_intel_dsi_drrs_ops(); + } else if (intel_encoder->type == INTEL_OUTPUT_EDP) { + drrs->encoder_ops = get_intel_edp_drrs_ops(); } else { DRM_ERROR("DRRS: Unsupported Encoder\n"); ret = -EINVAL; diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 726c31d..d5354f3 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -38,6 +38,7 @@ #include #include "intel_drrs.h" +#include "intel_edp_drrs.h" /** * _wait_for - magic (register) wait macro @@ -758,6 +759,8 @@ struct intel_dp { unsigned long compliance_test_type; unsigned long compliance_test_data; bool compliance_test_active; + + struct edp_drrs_platform_ops *drrs_ops; }; struct intel_digital_port { diff --git a/drivers/gpu/drm/i915/intel_edp_drrs.c b/drivers/gpu/drm/i915/intel_edp_drrs.c new file mode 100644 index 0000000..606271b --- /dev/null +++ b/drivers/gpu/drm/i915/intel_edp_drrs.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2015, Intel Corporation. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Authors: + * Ramalingam C + * Durgadoss R + */ + +#include +#include + +#include "i915_drv.h" + +void intel_edp_set_drrs_state(struct i915_drrs *drrs) +{ + struct intel_encoder *intel_encoder = drrs->connector->encoder; + struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); + + intel_dp->drrs_ops->set_drrs_state(intel_encoder, + drrs->drrs_state.target_rr_type); +} + +int intel_edp_drrs_init(struct i915_drrs *drrs, + struct drm_display_mode *fixed_mode) +{ + struct intel_encoder *intel_encoder = drrs->connector->encoder; + struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); + struct drm_display_mode *downclock_mode; + int ret = -EINVAL; + + if (!intel_dp->drrs_ops || + !intel_dp->drrs_ops->set_drrs_state) { + DRM_ERROR("Required platform ops are NULL\n"); + return ret; + } + + if (fixed_mode->vrefresh == 0) + fixed_mode->vrefresh = drm_mode_vrefresh(fixed_mode); + + downclock_mode = intel_find_panel_downclock(intel_encoder->base.dev, + fixed_mode, &drrs->connector->base); + if (!downclock_mode) { + DRM_DEBUG("No Downclock mode is found\n"); + return ret; + } + + if (intel_dp->drrs_ops->init) { + ret = intel_dp->drrs_ops->init(intel_encoder); + if (ret < 0) + return ret; + } + + DRM_DEBUG("eDP DRRS modes:\n"); + drm_mode_debug_printmodeline(fixed_mode); + drm_mode_debug_printmodeline(downclock_mode); + + /* We are good to go .. */ + intel_panel_init(&drrs->connector->panel, fixed_mode, downclock_mode); + drrs->connector->panel.target_mode = NULL; + + drrs->drrs_state.type = SEAMLESS_DRRS_SUPPORT; + return ret; +} + +void intel_edp_drrs_exit(struct i915_drrs *drrs) +{ + struct intel_encoder *intel_encoder = drrs->connector->encoder; + struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); + + if (intel_dp->drrs_ops->exit) + intel_dp->drrs_ops->exit(intel_encoder); + + drrs->drrs_state.type = DRRS_NOT_SUPPORTED; +} + +struct drrs_encoder_ops edp_drrs_ops = { + .init = intel_edp_drrs_init, + .exit = intel_edp_drrs_exit, + .set_drrs_state = intel_edp_set_drrs_state, +}; + +/* Called by intel_drrs_init() to get ->ops for edp panel */ +struct drrs_encoder_ops *get_intel_edp_drrs_ops(void) +{ + return &edp_drrs_ops; +} diff --git a/drivers/gpu/drm/i915/intel_edp_drrs.h b/drivers/gpu/drm/i915/intel_edp_drrs.h new file mode 100644 index 0000000..5a23f004 --- /dev/null +++ b/drivers/gpu/drm/i915/intel_edp_drrs.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2015, Intel Corporation. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Author: + * Ramalingam C + */ + +#ifndef INTEL_EDP_DRRS_H +#define INTEL_EDP_DRRS_H + +struct intel_encoder; +struct edp_drrs_platform_ops { + int (*init)(struct intel_encoder *encoder); + void (*exit)(struct intel_encoder *encoder); + int (*set_drrs_state)(struct intel_encoder *encoder, + enum drrs_refresh_rate_type target_rr_type); +}; + +extern inline struct drrs_encoder_ops *get_intel_edp_drrs_ops(void); +#endif /* INTEL_EDP_DRRS_H */