From patchwork Fri Dec 8 15:45:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10102809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7806E60360 for ; Fri, 8 Dec 2017 15:45:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B41B28DD0 for ; Fri, 8 Dec 2017 15:45:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59C4128DCD; Fri, 8 Dec 2017 15:45:59 +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=-4.2 required=2.0 tests=BAYES_00, 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 4A31428DCB for ; Fri, 8 Dec 2017 15:45:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE5CF6E927; Fri, 8 Dec 2017 15:45:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb2-smtp-cloud9.xs4all.net (lb2-smtp-cloud9.xs4all.net [194.109.24.26]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6C6B86E927 for ; Fri, 8 Dec 2017 15:45:56 +0000 (UTC) Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud9.xs4all.net with ESMTPA id NKqUe2Gp2nIXbNKqXenZfO; Fri, 08 Dec 2017 16:45:54 +0100 From: Hans Verkuil Subject: [PATCH] drm/sun4i: validate modes for HDMI To: Maling list - DRI developers , Maxime Ripard , Chen-Yu Tsai Message-ID: <50a4a5fd-d111-616a-8793-b5f68fea85f8@xs4all.nl> Date: Fri, 8 Dec 2017 16:45:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Language: en-US X-CMAE-Envelope: MS4wfBb4zILd5dujj/Jdu1EsWiZefd66CYONY+eIsdp7Fhp5tFYJsrA28UO8NaK87D1ay249qqbj5UH1ZPeQTot6IXpcxy/Ezxi6upyXq/tVmlitDqwBaUbv yi48CxmZVJyB8spPvitAbwfGYpzeQCK/MDORTUPflBcBQXNXNgQS7ji+rqKTEuX4CAQGhkVaLRGI788GQiNzS1cKizPHdTjuppB7nVEc+NqXEkbGdsMq9P63 VOS4rc4oFADMyAhZAg+Jx+9piZ0cQb+geA6an++tKvk= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When I connected my cubieboard running 4.15-rc1 to my 4k display I got no picture. Some digging found that there is no check against the upper pixelclock limit of the HDMI output, so X selects a 4kp60 format at 594 MHz, which obviously won't work. The patch below adds a check for the upper bound of what this hardware can do, and it checks if the requested tmds clock can be obtained. Signed-off-by: Hans Verkuil diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index 6d19d2ac68d1..62d52102d0f7 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -211,7 +211,17 @@ static int sun4i_hdmi_get_modes(struct drm_connector *connector) static int sun4i_hdmi_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { - if (mode->clock > 170000) + struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector); + unsigned long rate = mode->clock * 1000; + long rounded_rate; + + /* 165 MHz is the typical max pixelclock frequency for HDMI <= 1.2 */ + if (rate > 165000000) + return MODE_CLOCK_HIGH; + rounded_rate = clk_round_rate(hdmi->tmds_clk, rate); + if (rounded_rate < rate) + return MODE_CLOCK_LOW; + if (rounded_rate > rate) return MODE_CLOCK_HIGH; return MODE_OK; }