From patchwork Mon Aug 10 07:26:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Xiong Y" X-Patchwork-Id: 6980261 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 3E894C05AC for ; Mon, 10 Aug 2015 07:20:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BFB8206AA for ; Mon, 10 Aug 2015 07:20:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A10A92062A for ; Mon, 10 Aug 2015 07:20:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 145D66E207; Mon, 10 Aug 2015 00:20:05 -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 4EE0F6E207 for ; Mon, 10 Aug 2015 00:20:04 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 10 Aug 2015 00:20:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,643,1432623600"; d="scan'208";a="780299415" Received: from panda-dev.bj.intel.com ([10.238.154.59]) by fmsmga002.fm.intel.com with ESMTP; 10 Aug 2015 00:20:03 -0700 From: Xiong Zhang To: intel-gfx@lists.freedesktop.org Date: Mon, 10 Aug 2015 15:26:10 +0800 Message-Id: <1439191571-25847-3-git-send-email-xiong.y.zhang@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1439191571-25847-1-git-send-email-xiong.y.zhang@intel.com> References: <1439191571-25847-1-git-send-email-xiong.y.zhang@intel.com> Subject: [Intel-gfx] [PATCH 3/4] drm/i915: Adding panel filter for HDMI 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=-4.2 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 Signed-off-by: Xiong Zhang --- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_hdmi.c | 79 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 76 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index f57a0b4..0a4632b 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -672,6 +672,8 @@ struct intel_hdmi { bool enable, struct drm_display_mode *adjusted_mode); bool (*infoframe_enabled)(struct drm_encoder *encoder); + + struct intel_connector *attached_connector; }; struct intel_dp_mst_encoder; diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c index 70bad5b..6f1638c 100644 --- a/drivers/gpu/drm/i915/intel_hdmi.c +++ b/drivers/gpu/drm/i915/intel_hdmi.c @@ -1191,6 +1191,8 @@ intel_hdmi_mode_valid(struct drm_connector *connector, { struct intel_hdmi *hdmi = intel_attached_hdmi(connector); struct drm_device *dev = intel_hdmi_to_dev(hdmi); + struct intel_connector *intel_connector = to_intel_connector(connector); + struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; enum drm_mode_status status; int clock; @@ -1201,6 +1203,18 @@ intel_hdmi_mode_valid(struct drm_connector *connector, if (mode->flags & DRM_MODE_FLAG_DBLCLK) clock *= 2; + if (!intel_panel_scale_none(&intel_connector->panel)) { + if (mode->hdisplay > fixed_mode->hdisplay) + return MODE_PANEL; + + if (mode->vdisplay > fixed_mode->vdisplay) + return MODE_PANEL; + + clock = fixed_mode->clock; + if (fixed_mode->flags & DRM_MODE_FLAG_DBLCLK) + clock *= 2; + } + /* check if we can do 8bpc */ status = hdmi_port_clock_valid(hdmi, clock, true); @@ -1249,8 +1263,9 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder, struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); struct drm_device *dev = encoder->base.dev; struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; - int clock_8bpc = pipe_config->base.adjusted_mode.crtc_clock; - int clock_12bpc = clock_8bpc * 3 / 2; + struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc); + struct intel_connector *intel_connector = intel_hdmi->attached_connector; + int clock_8bpc, clock_12bpc; int desired_bpp; pipe_config->has_hdmi_sink = intel_hdmi->has_hdmi_sink; @@ -1258,6 +1273,18 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder, if (pipe_config->has_hdmi_sink) pipe_config->has_infoframe = true; + if (!intel_panel_scale_none(&intel_connector->panel)) { + intel_fixed_panel_mode(intel_connector->panel.fixed_mode, + adjusted_mode); + + if (!HAS_PCH_SPLIT(dev)) + intel_gmch_panel_fitting(intel_crtc, pipe_config, + intel_connector->panel.fitting_mode); + else + intel_pch_panel_fitting(intel_crtc, pipe_config, + intel_connector->panel.fitting_mode); + } + if (intel_hdmi->color_range_auto) { /* See CEA-861-E - 5.1 Default Encoding Parameters */ if (pipe_config->has_hdmi_sink && @@ -1267,6 +1294,8 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder, intel_hdmi->color_range = 0; } + clock_8bpc = adjusted_mode->crtc_clock; + clock_12bpc = clock_8bpc * 3 / 2; if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) { pipe_config->pixel_multiplier = 2; clock_8bpc *= 2; @@ -1410,13 +1439,30 @@ intel_hdmi_force(struct drm_connector *connector) static int intel_hdmi_get_modes(struct drm_connector *connector) { - struct edid *edid; + struct intel_connector *intel_connector = to_intel_connector(connector); + struct edid *edid = intel_connector->detect_edid; + int ret; - edid = to_intel_connector(connector)->detect_edid; if (edid == NULL) return 0; - return intel_connector_update_modes(connector, edid); + ret = intel_connector_update_modes(connector, edid); + if (ret && intel_connector->panel.fixed_mode == NULL) { + struct drm_display_mode *fixed_mode = NULL; + struct drm_display_mode *scan; + + list_for_each_entry(scan, &connector->probed_modes, head) { + if (scan->type & DRM_MODE_TYPE_PREFERRED) + fixed_mode = drm_mode_duplicate(connector->dev, + scan); + } + + if (fixed_mode) + intel_panel_init(&intel_connector->panel, + fixed_mode, NULL); + } + + return ret; } static bool @@ -1441,6 +1487,7 @@ intel_hdmi_set_property(struct drm_connector *connector, struct intel_digital_port *intel_dig_port = hdmi_to_dig_port(intel_hdmi); struct drm_i915_private *dev_priv = connector->dev->dev_private; + struct intel_connector *intel_connector = to_intel_connector(connector); int ret; ret = drm_object_property_set_value(&connector->base, property, val); @@ -1512,6 +1559,15 @@ intel_hdmi_set_property(struct drm_connector *connector, goto done; } + if (property == connector->dev->mode_config.scaling_mode_property) { + if (intel_connector->panel.fitting_mode == val) + return 0; + + intel_connector->panel.fitting_mode = val; + + goto done; + } + return -EINVAL; done: @@ -1942,11 +1998,22 @@ intel_attach_aspect_ratio_property(struct drm_connector *connector) static void intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector) { + struct intel_connector *intel_connector = to_intel_connector(connector); + intel_attach_force_audio_property(connector); intel_attach_broadcast_rgb_property(connector); intel_hdmi->color_range_auto = true; intel_attach_aspect_ratio_property(connector); intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE; + + /* Each pipe has panel filter since Ironlake. */ + if (INTEL_INFO(connector->dev)->gen >= 5) { + drm_mode_create_scaling_mode_property(connector->dev); + drm_object_attach_property(&connector->base, + connector->dev->mode_config.scaling_mode_property, + DRM_MODE_SCALE_NONE); + intel_connector->panel.fitting_mode = DRM_MODE_SCALE_NONE; + } } void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, @@ -1959,6 +2026,8 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, struct drm_i915_private *dev_priv = dev->dev_private; enum port port = intel_dig_port->port; + intel_hdmi->attached_connector = intel_connector; + drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, DRM_MODE_CONNECTOR_HDMIA); drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs);