From patchwork Mon Mar 30 19:49:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 6124211 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7280BF4A6 for ; Mon, 30 Mar 2015 19:54:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0E30202A1 for ; Mon, 30 Mar 2015 19:54:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B84F7201F2 for ; Mon, 30 Mar 2015 19:54:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ycfhy-0007Sp-Pf; Mon, 30 Mar 2015 19:50:50 +0000 Received: from pandora.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ycfgy-0005SR-7I for linux-arm-kernel@lists.infradead.org; Mon, 30 Mar 2015 19:49:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From; bh=ihmpPYAhU05U6uW4kBNhUzyvCwzsOm6cGq/SZHKs60I=; b=XprQROjfGxT0NGrQCekune1sYihiYsMUmIqnxNWM9bHE0V7rdd7q/sPTk1blRr1T9U5w/vI/vJCVklTSzSrsv6A/md93h4V4FKxzY3G1mcWPqT2ySohYUwWRvpwI2sHDhZtfEgDWdRO8x0GLQinj1jWxK5mURySWcueXP4ySkNc=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:56516 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1YcfgY-0001Fp-NT; Mon, 30 Mar 2015 20:49:22 +0100 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1YcfgX-00036O-B0; Mon, 30 Mar 2015 20:49:21 +0100 From: Russell King To: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/i2c: tda998x: use drm_hdmi_avi_infoframe_from_display_mode() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 30 Mar 2015 20:49:21 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150330_124948_598284_2A21558D X-CRM114-Status: GOOD ( 14.36 ) X-Spam-Score: -0.1 (/) Cc: David Airlie X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make use of the DRM HDMI AVI infoframe helper to construct the AVI infoframe, rather than coding this up ourselves. This allows DRM to supply proper aspect ratio information derived from the DRM display mode structure. Signed-off-by: Russell King --- I noticed this helper in the kernel over the last weekend, and thought it would be a good idea to update the TDA998x driver to it. It changes the info frame slightly, eg: old: 00000000: 82 02 0d 4d 02 08 08 10 00 00 00 00 00 00 00 00 old: 00000010: 00 new: 00000000: 82 02 0d 1d 12 28 08 10 00 00 00 00 00 00 00 00 new: 00000010: 00 Differences are that we now include the picture aspect ratio, which is set according to the data in the drm_display_mode, or appropriately for the CEA mode. We also were not setting the active aspect present bit despite setting the field. Technically, this could be viewed as a bug fix, but I haven't seen any evidence to show any bad behaviour, neither before nor after this change. drivers/gpu/drm/i2c/tda998x_drv.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index 43d5d91fe880..fbc9c1facdfe 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -610,19 +610,21 @@ tda998x_write_aif(struct tda998x_priv *priv, struct tda998x_encoder_params *p) static void tda998x_write_avi(struct tda998x_priv *priv, struct drm_display_mode *mode) { - u8 buf[PB(HDMI_AVI_INFOFRAME_SIZE) + 1]; + struct hdmi_avi_infoframe frame; + u8 buf[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE]; + ssize_t len; - memset(buf, 0, sizeof(buf)); - buf[HB(0)] = HDMI_INFOFRAME_TYPE_AVI; - buf[HB(1)] = 0x02; - buf[HB(2)] = HDMI_AVI_INFOFRAME_SIZE; - buf[PB(1)] = HDMI_SCAN_MODE_UNDERSCAN; - buf[PB(2)] = HDMI_ACTIVE_ASPECT_PICTURE; - buf[PB(3)] = HDMI_QUANTIZATION_RANGE_FULL << 2; - buf[PB(4)] = drm_match_cea_mode(mode); - - tda998x_write_if(priv, DIP_IF_FLAGS_IF2, REG_IF2_HB0, buf, - sizeof(buf)); + drm_hdmi_avi_infoframe_from_display_mode(&frame, mode); + + frame.quantization_range = HDMI_QUANTIZATION_RANGE_FULL; + + len = hdmi_avi_infoframe_pack(&frame, buf, sizeof(buf)); + if (len < 0) { + dev_err(&priv->hdmi->dev, "hdmi_avi_infoframe_pack() failed: %d\n", len); + return; + } + + tda998x_write_if(priv, DIP_IF_FLAGS_IF2, REG_IF2_HB0, buf, len); } static void tda998x_audio_mute(struct tda998x_priv *priv, bool on)