From patchwork Wed Jun 19 21:07:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11005291 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 7676914B6 for ; Wed, 19 Jun 2019 21:11:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6374028856 for ; Wed, 19 Jun 2019 21:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5740228857; Wed, 19 Jun 2019 21:11:55 +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 EBCC928856 for ; Wed, 19 Jun 2019 21:11:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0D5006E46C; Wed, 19 Jun 2019 21:11:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id B17D86E46C for ; Wed, 19 Jun 2019 21:11:49 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id d126so328620pfd.2 for ; Wed, 19 Jun 2019 14:11:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hy05C9mn0/yIf2WjCYd8ymGDA+P844rg5bgddBHlUN8=; b=bY34Dd2TGo1snWhWXZbB45E4ke6wfb7op6o0rGmkZ8ScLOZys/fTixGqe3rBj/AH4l 5pysBquK65U2CTCgktPU3h+Gi8YcpVG7o7KN3FD6m/41+MFofz/Pfw6sv2VnzDdkiVmE XIZy0qrb6ZY6IZasNSYZsc5xQykKqcJkXAodP0Kq/Lp4GNI6bFLXwY2yRhTBR/XwVq3B ikRedALpFnILPJHwK5JfMRfpN1TWFfxaiTBR7qhlMCY1AYfwLFjmEUo2B/tHilwzYWI3 YdpTO+FSJx3gKC8IOEg+VyR4nXItCBBAGGIAf2oQVvSeQnSOX6NIDSpypNqKcjuTckmI FnnA== X-Gm-Message-State: APjAAAWzcKNLbCG3LoblGp7TMkGp22gAzXSMNs5UHsDXloJqiOYN5DCS z6WBek03Lo8lClO9YjWGN7DVCw== X-Google-Smtp-Source: APXvYqwXqPl24uyJF3v+5dkgkWEhaRF4Tfy/+nmYhsNEFIVfi0rh/PxJeKfAiWOS6/1USM4Ra2YThw== X-Received: by 2002:a63:6b46:: with SMTP id g67mr1788869pgc.45.1560978708910; Wed, 19 Jun 2019 14:11:48 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id p7sm35319117pfp.131.2019.06.19.14.11.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 14:11:48 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Laurent Pinchart , seanpaul@chromium.org Subject: [PATCH v2 2/2] drm/bridge/synopsys: dw-hdmi: Allow platforms to provide custom audio tables Date: Wed, 19 Jun 2019 14:07:18 -0700 Message-Id: <20190619210718.134951-2-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190619210718.134951-1-dianders@chromium.org> References: <20190619210718.134951-1-dianders@chromium.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hy05C9mn0/yIf2WjCYd8ymGDA+P844rg5bgddBHlUN8=; b=KGpaeoheFWBtMSk4WBMgOkawtt9gRWlcsmiS6qSo8xgzQC0X5za9DjD3rUH7b2a0re Tfg2n0jZMP+ZXKpDk2U9LapSmaxrigwOaUBbPePTSX7TI28dHCYv/th/bDTLjH3Bs2tJ dt8drzYooa55fn0wXwevkiH+aWBOLbRRBPZMs= 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: jernej.skrabec@siol.net, narmstrong@baylibre.com, maxime.ripard@bootlin.com, Zheng Yang , David Airlie , jonas@kwiboo.se, Douglas Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, dgreid@chromium.org, jbrunet@baylibre.com, Sam Ravnborg , Thomas Gleixner , cychiang@chromium.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On some platforms using dw_hdmi it may not be possible to make an HDMI pixel clock exactly, but it may be possible to make a rate that is close enough to be within spec. For instance on rk3288 we can make 25,176,471 Hz instead of 25,174,825.1748... Hz (25.2 MHz / 1.001). A future patch to the rk3288 platform code could enable support for this clock rate and specify the N/CTS that would be ideal. NOTE: I haven't yet posted said patch due to complexities with knowing whether dw_hdmi can control the dynamic PLL on rk3288. Thus for now there are no users of this feature yet. Signed-off-by: Douglas Anderson --- Changes in v2: - Split out the ability of a platform to provide custom tables. drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 27 ++++++++++++++--------- include/drm/bridge/dw_hdmi.h | 8 +++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 7cdffebcc7cb..b6027edf2942 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -60,13 +60,6 @@ enum hdmi_datamap { YCbCr422_12B = 0x12, }; -struct dw_hdmi_audio_tmds_n { - unsigned long tmds; - unsigned int n_32k; - unsigned int n_44k1; - unsigned int n_48k; -}; - /* * Unless otherwise noted, entries in this table are 100% optimization. * Values can be obtained from hdmi_compute_n() but that function is @@ -603,6 +596,7 @@ static void hdmi_set_cts_n(struct dw_hdmi *hdmi, unsigned int cts, static int hdmi_match_tmds_n_table(struct dw_hdmi *hdmi, unsigned int freq, unsigned long pixel_clk) { + const struct dw_hdmi_plat_data *plat_data = hdmi->plat_data; const struct dw_hdmi_audio_tmds_n *tmds_n = NULL; int mult = 1; int i; @@ -612,10 +606,21 @@ static int hdmi_match_tmds_n_table(struct dw_hdmi *hdmi, unsigned int freq, freq /= 2; } - for (i = 0; common_tmds_n_table[i].tmds != 0; i++) { - if (pixel_clk == common_tmds_n_table[i].tmds) { - tmds_n = &common_tmds_n_table[i]; - break; + if (plat_data->tmds_n_table) { + for (i = 0; plat_data->tmds_n_table[i].tmds != 0; i++) { + if (pixel_clk == plat_data->tmds_n_table[i].tmds) { + tmds_n = &plat_data->tmds_n_table[i]; + break; + } + } + } + + if (tmds_n == NULL) { + for (i = 0; common_tmds_n_table[i].tmds != 0; i++) { + if (pixel_clk == common_tmds_n_table[i].tmds) { + tmds_n = &common_tmds_n_table[i]; + break; + } } } diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index c402364aec0d..5ee6b0a127aa 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -90,6 +90,13 @@ enum dw_hdmi_phy_type { DW_HDMI_PHY_VENDOR_PHY = 0xfe, }; +struct dw_hdmi_audio_tmds_n { + unsigned long tmds; + unsigned int n_32k; + unsigned int n_44k1; + unsigned int n_48k; +}; + struct dw_hdmi_mpll_config { unsigned long mpixelclock; struct { @@ -137,6 +144,7 @@ struct dw_hdmi_plat_data { const struct dw_hdmi_mpll_config *mpll_cfg; const struct dw_hdmi_curr_ctrl *cur_ctr; const struct dw_hdmi_phy_config *phy_config; + const struct dw_hdmi_audio_tmds_n *tmds_n_table; int (*configure_phy)(struct dw_hdmi *hdmi, const struct dw_hdmi_plat_data *pdata, unsigned long mpixelclock);