Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3423472imu; Mon, 24 Dec 2018 01:27:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN5My3miVK6W90OcDSmg8dj0dkcfhqmdnMtd6l4tuS4KKpZkcDFCzzyODmfHTsOxtNmiby2h X-Received: by 2002:a62:4d81:: with SMTP id a123mr12877640pfb.122.1545643662287; Mon, 24 Dec 2018 01:27:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545643662; cv=none; d=google.com; s=arc-20160816; b=zNJTgOHVAQ7osiS1yK6etEZ1ChzCyNb/YRKgVsoGi5HNTnohi8s7A3JJV862+8lPrf ON83p4RMaWikRT0K5rR+55BjSjjSdPZjYr7N7HrdCcsBpAuL2WEWLUPsRx07wg1EkX9f 8mlHiJdDUhNFgEFZp4ijAi8oPxdkNf+YJPTsqM9OYIacLOGEjxwWLl933Oj1SEANKSzo RxfBRWO6f2W9lBmm8cKeI0eIIAitNJfk1qC6SjVh67zHubwVcGO94J40hd+L+Jx2UTiL yRswhzpVepyWeO/hMFZdeP5lh3bpzGPI/EPY4YdT0qZk5IXHJeiU5NezMA2k13sLFHgH JmZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:nodisclaimer :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=SukNybEVP+ndTttNc6aBbi4Ihrv9RWD+ZNjF5C/OqXI=; b=kmckhiLvlagX71BJlGSh2ahz33+GkitzQ+LQGIKw+afiLyRKIc0+euSywVR4GxsSSd GYNuhvhnML3D9LglHdwALf8oNjR3+D0ila2LEXVz8U/kFWGAw5eVp5wDvrzz+YANbU+4 osdknLTKFqSqHO1cT3icKvvio46kbuyTI5zoXArTFQTIcJ5eNvm8TdouW/zteZVxoqUm q9DhssY3Xc0tlH3aWYof08Vzz/b16B3Z7bOF7nH1hQhdq+JLb7vVxjCRUY61kjWUkCSx 10l/vfKKv3M2GXLDVWIVQpWfuE51eX/BBI2hzKapdAC3q3bkdkU7WJvOUk6hXsaNoknQ AKTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector1-arm-com header.b=lzcLc2XL; 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 m14si27321198pgd.326.2018.12.24.01.27.26; Mon, 24 Dec 2018 01:27: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=@armh.onmicrosoft.com header.s=selector1-arm-com header.b=lzcLc2XL; 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 S1725897AbeLXJ0C (ORCPT + 99 others); Mon, 24 Dec 2018 04:26:02 -0500 Received: from mail-eopbgr150085.outbound.protection.outlook.com ([40.107.15.85]:46872 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725294AbeLXJ0C (ORCPT ); Mon, 24 Dec 2018 04:26:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SukNybEVP+ndTttNc6aBbi4Ihrv9RWD+ZNjF5C/OqXI=; b=lzcLc2XLOW/dNlx8iKpGAlyEfkuZTOJQjdaJzmrqiToAsxLdVgXTa1Bz2hZNLpPhj1GgmoBEmTw8PIiKA9IYscfrEkTahpdQJFQSy3qSYNyOoWmVf4HOE1mdOHUsuOMeBZyIy4z67F9vMCCDEkWbqtrrz+JxAuGNSTlwarYVGws= Received: from AM3PR08MB0611.eurprd08.prod.outlook.com (10.163.188.149) by AM3PR08MB0262.eurprd08.prod.outlook.com (10.161.35.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.23; Mon, 24 Dec 2018 09:25:58 +0000 Received: from AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d]) by AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d%2]) with mapi id 15.20.1446.026; Mon, 24 Dec 2018 09:25:58 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau CC: "Jonathan Chai (Arm Technology China)" , Brian Starkey , "Julien Yin (Arm Technology China)" , "thomas Sun (Arm Technology China)" , Alexandru-Cosmin Gheorghe , "Lowry Li (Arm Technology China)" , Ayan Halder , "Tiannan Zhu (Arm Technology China)" , "Jin Gao (Arm Technology China)" , "Yiqi Kang (Arm Technology China)" , nd , "malidp@foss.arm.com" , "airlied@linux.ie" , "yamada.masahiro@socionext.com" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "maarten.lankhorst@linux.intel.com" , "maxime.ripard@bootlin.com" , "sean@poorly.run" , "james qian wang (Arm Technology China)" Subject: [PATCH 04/11] drm/komeda: Add komeda_crtc_mode_valid/fixup Thread-Topic: [PATCH 04/11] drm/komeda: Add komeda_crtc_mode_valid/fixup Thread-Index: AQHUm2qtO4uAfkpXZkCldalRPnu4xg== Date: Mon, 24 Dec 2018 09:25:58 +0000 Message-ID: <20181224092435.2792-5-james.qian.wang@arm.com> References: <20181224092435.2792-1-james.qian.wang@arm.com> In-Reply-To: <20181224092435.2792-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: SYXPR01CA0099.ausprd01.prod.outlook.com (2603:10c6:0:2e::32) To AM3PR08MB0611.eurprd08.prod.outlook.com (2a01:111:e400:c408::21) authentication-results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM3PR08MB0262;6:Pub9X1a2JJN6G9G1MO06+nQpM/gsggMZAZpw62iwiJFei041ic/8YtOZ5qiQvhyHf2t/OKyajIRUYAzrTnXw1dIzqRKJynyBuO1xhSTXvKG/tYcp+A6ojDKvMH0lJA6fC2mPmJ47yE40ua2O8v3jQtx78Yo6Lr4qDrikm6aiYh7WUOEtU8w89FhhhQJWzU6OkFlTTsRhX2Q9tU493JSW8yeVbLnvu/+h+qhp9o34Ge30TlnZt4LGyQGfau8S2uoZWDp8kZBAeNw2XDL0BPZiuZwWYn2tsDsbaay/82SkBfAE2fQjb9PFUHfJSqtly9xTL20HU7l0D2332CWDTp6GuBVsAnxwTPjNLGsLbcvEXssdWKelnsAjuOFv22DWNorrPBetTTKlb8598PMG7oQDQJkj/AqA7lAynkobQXRK1tELWgQLrTmzqisI7a/2QlSm4JFfzgYvNyRLPv/w3086CQ==;5:k+pPKfH0xA1QmDAMHEZ4Ozw3v/ZcIY6q7d/0XjV1qU4WotQ4tY1BQq8WoNhTqXU4VT7UYKGTKqjwBEeUpdIYV3AMQXBW7zQOe+PAFn30RsQsv/ggkI2HlR11VCvgdCYeuiFVAFw8GSSR7ql1OOMMxsOv3/7upPMFWUhb+sZddLs=;7:Dn++/DwZbFFN6LcWy0m+J0goQ9L0uawfihNI1hmi4/QYwuAIyuRJMud/wa4r68gzPbICVqxHlEsL7Zo/2uex8BytugAPo/sCwCPMOaqstqUNR27jkv+FsBA+MY1TmnVu4d5m5Xlk1wJQnB2oVDJUXg== x-ms-office365-filtering-correlation-id: b472da53-efa7-4aa2-3614-08d66981cfca x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM3PR08MB0262; x-ms-traffictypediagnostic: AM3PR08MB0262: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(10201501046)(3231475)(944501520)(52105112)(3002001)(93006095)(93001095)(6055026)(6041310)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:AM3PR08MB0262;BCL:0;PCL:0;RULEID:;SRVR:AM3PR08MB0262; x-forefront-prvs: 0896BFCE6C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(136003)(376002)(39850400004)(346002)(199004)(189003)(4326008)(256004)(305945005)(53936002)(6862004)(71190400001)(71200400001)(486006)(7736002)(97736004)(446003)(2906002)(52116002)(6116002)(76176011)(1076003)(6436002)(86362001)(6512007)(5660300001)(11346002)(186003)(26005)(68736007)(3846002)(2616005)(476003)(55236004)(386003)(102836004)(6506007)(25786009)(103116003)(14454004)(105586002)(99286004)(54906003)(37006003)(6486002)(106356001)(316002)(8676002)(81166006)(81156014)(8936002)(6636002)(36756003)(478600001)(66066001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM3PR08MB0262;H:AM3PR08MB0611.eurprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: O9zJ4TENreE3pEvVLF6mKtyutEHLW6EtiNwSJe4+my0BrQNw/nVZDyE7uUsc2vyilZluQS2Ys4u1VCwKWKfXlBJCTw1R8eJ8HRmnXki3hhHMlF5M5Nv1dUwYt5qoPvLgyGrBX5zGxTzpgUM6leKkdIpS1KpVzTXqd6/8h+niEUafITrX4g4bOFuoBfmFEVblaidaleF+FPb44W2p4dC3g8NS2hDW1EjUSGXwxT9QKg9ih2436Iq7kQvacQGgBnkm1cUWA6k6zT5Ox4iN3JVb1rGPj2vHxHzggY71x6ibIvd9b/HR74PXxlJvlzQWNaqP spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: b472da53-efa7-4aa2-3614-08d66981cfca X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Dec 2018 09:25:58.2581 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0262 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org komeda_crtc_mode_valid compares the input mode->clk with main engine clk and AXI clk, and reject the mode if the required pixel clk can not be satisfied by main engine clk and AXI-clk. Signed-off-by: James (Qian) Wang --- .../gpu/drm/arm/display/komeda/komeda_crtc.c | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu= /drm/arm/display/komeda/komeda_crtc.c index b4640971e47e..05bdff137e50 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -90,9 +90,61 @@ komeda_crtc_atomic_flush(struct drm_crtc *crtc, komeda_crtc_do_flush(crtc, old); } =20 +static enum drm_mode_status +komeda_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mod= e *m) +{ + struct komeda_dev *mdev =3D crtc->dev->dev_private; + struct komeda_crtc *kcrtc =3D to_kcrtc(crtc); + struct komeda_pipeline *master =3D kcrtc->master; + long mode_clk, pxlclk; + + if (m->flags & DRM_MODE_FLAG_INTERLACE) + return MODE_NO_INTERLACE; + + /* main clock/AXI clk must be faster than pxlclk*/ + mode_clk =3D m->clock * 1000; + pxlclk =3D clk_round_rate(master->pxlclk, mode_clk); + if (pxlclk !=3D mode_clk) { + DRM_DEBUG_ATOMIC("pxlclk doesn't support %ld Hz\n", mode_clk); + + return MODE_NOCLOCK; + } + + if (clk_round_rate(mdev->mclk, mode_clk) < pxlclk) { + DRM_DEBUG_ATOMIC("mclk can't satisfy the requirement of %s-clk: %ld.\n", + m->name, pxlclk); + + return MODE_CLOCK_HIGH; + } + + if (clk_round_rate(master->aclk, mode_clk) < pxlclk) { + DRM_DEBUG_ATOMIC("aclk can't satisfy the requirement of %s-clk: %ld.\n", + m->name, pxlclk); + + return MODE_CLOCK_HIGH; + } + + return MODE_OK; +} + +static bool komeda_crtc_mode_fixup(struct drm_crtc *crtc, + const struct drm_display_mode *m, + struct drm_display_mode *adjusted_mode) +{ + struct komeda_crtc *kcrtc =3D to_kcrtc(crtc); + struct komeda_pipeline *master =3D kcrtc->master; + long mode_clk =3D m->clock * 1000; + + adjusted_mode->clock =3D clk_round_rate(master->pxlclk, mode_clk) / 1000; + + return true; +} + struct drm_crtc_helper_funcs komeda_crtc_helper_funcs =3D { .atomic_check =3D komeda_crtc_atomic_check, .atomic_flush =3D komeda_crtc_atomic_flush, + .mode_valid =3D komeda_crtc_mode_valid, + .mode_fixup =3D komeda_crtc_mode_fixup, }; =20 static const struct drm_crtc_funcs komeda_crtc_funcs =3D { --=20 2.17.1