From patchwork Thu Dec 1 23:43:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9457401 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 3148B60235 for ; Thu, 1 Dec 2016 23:44:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 237D228518 for ; Thu, 1 Dec 2016 23:44:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 181F228536; Thu, 1 Dec 2016 23:44:24 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 90C0128518 for ; Thu, 1 Dec 2016 23:44:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8268A6E8FE; Thu, 1 Dec 2016 23:43:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from galahad.ideasonboard.com (galahad.ideasonboard.com [IPv6:2001:4b98:dc2:45:216:3eff:febb:480d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C9E76E8E7 for ; Thu, 1 Dec 2016 23:43:37 +0000 (UTC) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id BCA7221128; Fri, 2 Dec 2016 00:43:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1480635809; bh=bMRaUzlgtde5YoKn31N85aUUcMQxbeL9ISHzcEqrJq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NuNTMgVIu6kevHxfHzp1dPGotkOIpvaJp6NseB0/OdWJSiQYofpF3h5mlLAOJlSvG tPqm1qH3kYLDXX3YqbIuIVMrzldC/aIxIfaxS6Do8dxrY6/MP9T7rCuT/H6wX+LFCG 6RI+uq3BYb9mYHtVNUdvMcIJlbIB/IBKaOWMd2/0= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH 11/22] drm: bridge: dw-hdmi: Refactor hdmi_phy_configure resolution parameter Date: Fri, 2 Dec 2016 01:43:26 +0200 Message-Id: <1480635817-1258-12-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1480635817-1258-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1480635817-1258-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> Cc: Fabio Estevam , Jose Abreu , Ulrich Hecht , Kieran Bingham , linux-renesas-soc@vger.kernel.org, Russell King , Andy Yan , Vladimir Zapolskiy 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kieran Bingham The current code hard codes the call of hdmi_phy_configure() to be 8bpp and provides extraneous error checking to verify that this hardcoded value is correct. Simplify the passing of the data by setting the parameter to be of the enum type it represents rather than converting and then verifying the value. This will allow the compiler to check the value is acceptable based on the type, and remove the dead code that we currently have. Signed-off-by: Kieran Bingham Signed-off-by: Laurent Pinchart --- drivers/gpu/drm/bridge/dw-hdmi.c | 20 ++------------------ include/drm/bridge/dw_hdmi.h | 2 +- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index 107fea49c4c6..074ceb1e4897 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -931,30 +931,14 @@ static void dw_hdmi_phy_sel_interface_control(struct dw_hdmi *hdmi, u8 enable) } static int hdmi_phy_configure(struct dw_hdmi *hdmi, - unsigned char res, int cscon) + enum dw_hdmi_resolution res_idx, int cscon) { - unsigned res_idx; u8 val, msec; const struct dw_hdmi_plat_data *pdata = hdmi->plat_data; const struct dw_hdmi_mpll_config *mpll_config = pdata->mpll_cfg; const struct dw_hdmi_curr_ctrl *curr_ctrl = pdata->cur_ctr; const struct dw_hdmi_phy_config *phy_config = pdata->phy_config; - switch (res) { - case 0: /* color resolution 0 is 8 bit colour depth */ - case 8: - res_idx = DW_HDMI_RES_8; - break; - case 10: - res_idx = DW_HDMI_RES_10; - break; - case 12: - res_idx = DW_HDMI_RES_12; - break; - default: - return -EINVAL; - } - /* PLL/MPLL Cfg - always match on final entry */ for (; mpll_config->mpixelclock != ~0UL; mpll_config++) if (hdmi->hdmi_data.video_mode.mpixelclock <= @@ -1068,7 +1052,7 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi) dw_hdmi_phy_enable_powerdown(hdmi, true); /* Enable CSC */ - ret = hdmi_phy_configure(hdmi, 8, cscon); + ret = hdmi_phy_configure(hdmi, DW_HDMI_RES_8, cscon); if (ret) return ret; } diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index 3bb22a849830..e551b457c100 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -14,7 +14,7 @@ struct dw_hdmi; -enum { +enum dw_hdmi_resolution { DW_HDMI_RES_8, DW_HDMI_RES_10, DW_HDMI_RES_12,