From patchwork Mon Aug 10 07:26:11 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: 6980271 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 0EA50C05AC for ; Mon, 10 Aug 2015 07:20:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 011E6206AA for ; Mon, 10 Aug 2015 07:20:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EC6F52062A for ; Mon, 10 Aug 2015 07:20:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E3856E218; Mon, 10 Aug 2015 00:20:08 -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 739916E20E for ; Mon, 10 Aug 2015 00:20:07 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 10 Aug 2015 00:20:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,643,1432623600"; d="scan'208";a="780299451" Received: from panda-dev.bj.intel.com ([10.238.154.59]) by fmsmga002.fm.intel.com with ESMTP; 10 Aug 2015 00:20:06 -0700 From: Xiong Zhang To: intel-gfx@lists.freedesktop.org Date: Mon, 10 Aug 2015 15:26:11 +0800 Message-Id: <1439191571-25847-4-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 4/4] drm/i915: Adding panel filter for VGA 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_crt.c | 81 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c index 521af2c..f8eedfc 100644 --- a/drivers/gpu/drm/i915/intel_crt.c +++ b/drivers/gpu/drm/i915/intel_crt.c @@ -288,24 +288,37 @@ intel_crt_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { struct drm_device *dev = connector->dev; + struct intel_connector *intel_connector = to_intel_connector(connector); + struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; + int max_clock = 0, clock; - int max_clock = 0; if (mode->flags & DRM_MODE_FLAG_DBLSCAN) return MODE_NO_DBLESCAN; - if (mode->clock < 25000) + clock = mode->clock; + 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 (clock < 25000) return MODE_CLOCK_LOW; if (IS_GEN2(dev)) max_clock = 350000; else max_clock = 400000; - if (mode->clock > max_clock) + if (clock > max_clock) return MODE_CLOCK_HIGH; /* The FDI receiver on LPT only supports 8bpc and only has 2 lanes. */ if (HAS_PCH_LPT(dev) && - (ironlake_get_lanes_required(mode->clock, 270000, 24) > 2)) + (ironlake_get_lanes_required(clock, 270000, 24) > 2)) return MODE_CLOCK_HIGH; return MODE_OK; @@ -315,6 +328,22 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder, struct intel_crtc_state *pipe_config) { struct drm_device *dev = encoder->base.dev; + struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; + struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc); + struct intel_crt *intel_crt = intel_encoder_to_crt(encoder); + struct intel_connector *intel_connector = intel_crt->connector; + + 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 (HAS_PCH_SPLIT(dev)) pipe_config->has_pch_encoder = true; @@ -489,6 +518,7 @@ static struct edid *intel_crt_get_edid(struct drm_connector *connector, static int intel_crt_ddc_get_modes(struct drm_connector *connector, struct i2c_adapter *adapter) { + struct intel_connector *intel_connector = to_intel_connector(connector); struct edid *edid; int ret; @@ -499,6 +529,20 @@ static int intel_crt_ddc_get_modes(struct drm_connector *connector, ret = intel_connector_update_modes(connector, edid); kfree(edid); + if (ret && intel_connector->panel.fixed_mode == NULL) { + struct drm_display_mode *fixed_mode = NULL, *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; } @@ -768,6 +812,18 @@ static int intel_crt_set_property(struct drm_connector *connector, struct drm_property *property, uint64_t value) { + struct intel_connector *intel_connector = to_intel_connector(connector); + + if (property == connector->dev->mode_config.scaling_mode_property) { + if (intel_connector->panel.fitting_mode == value) + return 0; + + intel_connector->panel.fitting_mode = value; + + if (connector->encoder && connector->encoder->crtc) + intel_crtc_restore_mode(connector->encoder->crtc); + } + return 0; } @@ -844,6 +900,21 @@ static const struct dmi_system_id intel_no_crt[] = { { } }; +static void +intel_crt_add_properties(struct drm_connector *connector) +{ + struct intel_connector *intel_connector = to_intel_connector(connector); + + /* Each pipe has pannel 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_crt_init(struct drm_device *dev) { struct drm_connector *connector; @@ -870,6 +941,8 @@ void intel_crt_init(struct drm_device *dev) drm_connector_init(dev, &intel_connector->base, &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); + intel_crt_add_properties(connector); + drm_encoder_init(dev, &crt->base.base, &intel_crt_enc_funcs, DRM_MODE_ENCODER_DAC);