From patchwork Mon Dec 24 09:25:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10742139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D268E13AD for ; Mon, 24 Dec 2018 09:26:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C10CB26E96 for ; Mon, 24 Dec 2018 09:26:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B431F28F33; Mon, 24 Dec 2018 09:26:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4C81726E96 for ; Mon, 24 Dec 2018 09:26:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77C856E554; Mon, 24 Dec 2018 09:26:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30072.outbound.protection.outlook.com [40.107.3.72]) by gabe.freedesktop.org (Postfix) with ESMTPS id D36FA6E554 for ; Mon, 24 Dec 2018 09:26:00 +0000 (UTC) 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 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) 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Tiannan Zhu \(Arm Technology China\)" , "airlied@linux.ie" , "Jonathan Chai \(Arm Technology China\)" , Alexandru-Cosmin Gheorghe , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "yamada.masahiro@socionext.com" , "james qian wang \(Arm Technology China\)" , "malidp@foss.arm.com" , "Yiqi Kang \(Arm Technology China\)" , "maxime.ripard@bootlin.com" , "thomas Sun \(Arm Technology China\)" , "Jin Gao \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , "sean@poorly.run" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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); } +static enum drm_mode_status +komeda_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *m) +{ + struct komeda_dev *mdev = crtc->dev->dev_private; + struct komeda_crtc *kcrtc = to_kcrtc(crtc); + struct komeda_pipeline *master = 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 = m->clock * 1000; + pxlclk = clk_round_rate(master->pxlclk, mode_clk); + if (pxlclk != 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 = to_kcrtc(crtc); + struct komeda_pipeline *master = kcrtc->master; + long mode_clk = m->clock * 1000; + + adjusted_mode->clock = clk_round_rate(master->pxlclk, mode_clk) / 1000; + + return true; +} + struct drm_crtc_helper_funcs komeda_crtc_helper_funcs = { .atomic_check = komeda_crtc_atomic_check, .atomic_flush = komeda_crtc_atomic_flush, + .mode_valid = komeda_crtc_mode_valid, + .mode_fixup = komeda_crtc_mode_fixup, }; static const struct drm_crtc_funcs komeda_crtc_funcs = {