Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2281379ybl; Thu, 19 Dec 2019 10:57:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyj/el6mHg/whDJ08fHxcMeLlt7Zeoz17bVC7mDjfOWB5MJEzGhZM3NlR0GZhs9WsErjRv2 X-Received: by 2002:a05:6830:50:: with SMTP id d16mr10997112otp.155.1576781862744; Thu, 19 Dec 2019 10:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781862; cv=none; d=google.com; s=arc-20160816; b=K/HVQ/dWVkysbZcFDFZ4llKu1Be3xvHWFoVqKuc6/qq7AVAK7FYhL0XEJonwlTDsaq SMlvg4t78nDjQXe+nNzjFkRsr/LdTosCAbVI5BsTngdvEPnXYXk1xC464nUeLXtxxaGN kuLZUCyeOYC0J/2pBi79ubFVT4H2ajjs/Z/mMguqmsFJDrv+t54kW9WObm5y+yfXlKNW IES8mFDeoJSod3ezDVVYjxKMEu+EKz4Pb40h5hlXe5wYvRY5o3DhSkzOEDS3a4uc0RJZ bs2gx2ofcrgrLwxPwfrh2Rub+/hdsaHvWkrd0QfOaWVpoyDTO1gOBJ+Nk5aENWO7hduT 8mqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wQlllejtXuWXY5Rh25hlvuNaGA4dME09hZx6tU+9E9M=; b=Fpkb9CZTYtU6vHIf1TPln639dQqUVRYaKOMn6LmDTHuzqz/DrV07SsfXMDlmUFqPJT u/Twic7HRNNFRIH3TQjIH+8TkC8o8+gKgIOKBPX341y4QP3V1gCaIecRlJSuVcMaGbOq eDt3Bg9YkIck3B3ngAeXdWDY0NcE14g58q0HYwrH2768ibKeTdgQume0dvuHrIDzGCWP R1TgvB7E8C8zCRLR8AGvWv4+pXZEHAuqYa67kW+zESO+3o5S7X11hzQZSv63RyTsY1Dt tIZES0JX3p12ip5BAsur0XeP96mCYkaHgTiCTOOE5u8xCTneZRE858+5WAetcq1fh5QX abZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mr5OhWRI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5si4285367otb.26.2019.12.19.10.57.31; Thu, 19 Dec 2019 10:57:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mr5OhWRI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729665AbfLSSzQ (ORCPT + 99 others); Thu, 19 Dec 2019 13:55:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:51078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730396AbfLSSzM (ORCPT ); Thu, 19 Dec 2019 13:55:12 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F12F124679; Thu, 19 Dec 2019 18:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781711; bh=OqFCLd4WftZqa6i+YaD9py48siWJszgq0jImbq5JZ8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mr5OhWRIrVq16HotMv1lAAhs8N2qNRc6maThsDsahTd7UwkWJj49f0gLZJrgham3z 2KZFf/oS8sK74/c7ChnvknRU0eOEc86x4Tv23U++kybS6h6g4484fukzG+xuDzgrDR AZOjh3ipxo6bY9fVsRsTvuKf9rT38zBeH8AdVO+c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Blumenstingl , Neil Armstrong Subject: [PATCH 5.4 50/80] drm: meson: venc: cvbs: fix CVBS mode matching Date: Thu, 19 Dec 2019 19:34:42 +0100 Message-Id: <20191219183121.752291356@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183031.278083125@linuxfoundation.org> References: <20191219183031.278083125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Blumenstingl commit 43cb86799ff03e9819c07f37f72f80f8246ad7ed upstream. With commit 222ec1618c3ace ("drm: Add aspect ratio parsing in DRM layer") the drm core started honoring the picture_aspect_ratio field when comparing two drm_display_modes. Prior to that it was ignored. When the CVBS encoder driver was initially submitted there was no aspect ratio check. Switch from drm_mode_equal() to drm_mode_match() without DRM_MODE_MATCH_ASPECT_RATIO to fix "kmscube" and X.org output using the CVBS connector. When (for example) kmscube sets the output mode when using the CVBS connector it passes HDMI_PICTURE_ASPECT_NONE, making the drm_mode_equal() fail as it include the aspect ratio. Prior to this patch kmscube reported: failed to set mode: Invalid argument The CVBS mode checking in the sun4i (drivers/gpu/drm/sun4i/sun4i_tv.c sun4i_tv_mode_to_drm_mode) and ZTE (drivers/gpu/drm/zte/zx_tvenc.c tvenc_mode_{pal,ntsc}) drivers don't set the "picture_aspect_ratio" at all. The Meson VPU driver does not rely on the aspect ratio for the CVBS output so we can safely decouple it from the hdmi_picture_aspect setting. Cc: Fixes: 222ec1618c3ace ("drm: Add aspect ratio parsing in DRM layer") Fixes: bbbe775ec5b5da ("drm: Add support for Amlogic Meson Graphic Controller") Signed-off-by: Martin Blumenstingl Acked-by: Neil Armstrong [narmstrong: squashed with drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code] Signed-off-by: Neil Armstrong Link: https://patchwork.freedesktop.org/patch/msgid/20191208171832.1064772-3-martin.blumenstingl@googlemail.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/meson/meson_venc_cvbs.c | 48 ++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 21 deletions(-) --- a/drivers/gpu/drm/meson/meson_venc_cvbs.c +++ b/drivers/gpu/drm/meson/meson_venc_cvbs.c @@ -64,6 +64,25 @@ struct meson_cvbs_mode meson_cvbs_modes[ }, }; +static const struct meson_cvbs_mode * +meson_cvbs_get_mode(const struct drm_display_mode *req_mode) +{ + int i; + + for (i = 0; i < MESON_CVBS_MODES_COUNT; ++i) { + struct meson_cvbs_mode *meson_mode = &meson_cvbs_modes[i]; + + if (drm_mode_match(req_mode, &meson_mode->mode, + DRM_MODE_MATCH_TIMINGS | + DRM_MODE_MATCH_CLOCK | + DRM_MODE_MATCH_FLAGS | + DRM_MODE_MATCH_3D_FLAGS)) + return meson_mode; + } + + return NULL; +} + /* Connector */ static void meson_cvbs_connector_destroy(struct drm_connector *connector) @@ -136,14 +155,8 @@ static int meson_venc_cvbs_encoder_atomi struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { - int i; - - for (i = 0; i < MESON_CVBS_MODES_COUNT; ++i) { - struct meson_cvbs_mode *meson_mode = &meson_cvbs_modes[i]; - - if (drm_mode_equal(&crtc_state->mode, &meson_mode->mode)) - return 0; - } + if (meson_cvbs_get_mode(&crtc_state->mode)) + return 0; return -EINVAL; } @@ -191,24 +204,17 @@ static void meson_venc_cvbs_encoder_mode struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { + const struct meson_cvbs_mode *meson_mode = meson_cvbs_get_mode(mode); struct meson_venc_cvbs *meson_venc_cvbs = encoder_to_meson_venc_cvbs(encoder); struct meson_drm *priv = meson_venc_cvbs->priv; - int i; - for (i = 0; i < MESON_CVBS_MODES_COUNT; ++i) { - struct meson_cvbs_mode *meson_mode = &meson_cvbs_modes[i]; + if (meson_mode) { + meson_venci_cvbs_mode_set(priv, meson_mode->enci); - if (drm_mode_equal(mode, &meson_mode->mode)) { - meson_venci_cvbs_mode_set(priv, - meson_mode->enci); - - /* Setup 27MHz vclk2 for ENCI and VDAC */ - meson_vclk_setup(priv, MESON_VCLK_TARGET_CVBS, - MESON_VCLK_CVBS, MESON_VCLK_CVBS, - MESON_VCLK_CVBS, true); - break; - } + /* Setup 27MHz vclk2 for ENCI and VDAC */ + meson_vclk_setup(priv, MESON_VCLK_TARGET_CVBS, MESON_VCLK_CVBS, + MESON_VCLK_CVBS, MESON_VCLK_CVBS, true); } }