linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: rmk+kernel@arm.linux.org.uk (Russell King)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 02/34] imx-drm: imx-hdmi: clean up setting CSC registers
Date: Tue, 18 Feb 2014 20:09:46 +0000	[thread overview]
Message-ID: <E1WFqzC-0007hy-I6@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20140218200900.GM21483@n2100.arm.linux.org.uk>

Rather than manually writing each register sequentially, we can use a
loop to reduce the amount of code.

Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/staging/imx-drm/imx-hdmi.c | 40 +++++++++++++-------------------------
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c
index cb316bf3ec56..18de310e50e0 100644
--- a/drivers/staging/imx-drm/imx-hdmi.c
+++ b/drivers/staging/imx-drm/imx-hdmi.c
@@ -480,6 +480,7 @@ static int is_color_space_interpolation(struct imx_hdmi *hdmi)
 static void imx_hdmi_update_csc_coeffs(struct imx_hdmi *hdmi)
 {
 	const u16 (*csc_coeff)[3][4] = &csc_coeff_default;
+	unsigned i;
 	u32 csc_scale = 1;
 	u8 val;
 
@@ -498,32 +499,19 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi *hdmi)
 		}
 	}
 
-	hdmi_writeb(hdmi, ((*csc_coeff)[0][0] & 0xff), HDMI_CSC_COEF_A1_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[0][0] >> 8), HDMI_CSC_COEF_A1_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[0][1] & 0xff), HDMI_CSC_COEF_A2_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[0][1] >> 8), HDMI_CSC_COEF_A2_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[0][2] & 0xff), HDMI_CSC_COEF_A3_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[0][2] >> 8), HDMI_CSC_COEF_A3_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[0][3] & 0xff), HDMI_CSC_COEF_A4_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[0][3] >> 8), HDMI_CSC_COEF_A4_MSB);
-
-	hdmi_writeb(hdmi, ((*csc_coeff)[1][0] & 0xff), HDMI_CSC_COEF_B1_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[1][0] >> 8), HDMI_CSC_COEF_B1_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[1][1] & 0xff), HDMI_CSC_COEF_B2_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[1][1] >> 8), HDMI_CSC_COEF_B2_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[1][2] & 0xff), HDMI_CSC_COEF_B3_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[1][2] >> 8), HDMI_CSC_COEF_B3_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[1][3] & 0xff), HDMI_CSC_COEF_B4_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[1][3] >> 8), HDMI_CSC_COEF_B4_MSB);
-
-	hdmi_writeb(hdmi, ((*csc_coeff)[2][0] & 0xff), HDMI_CSC_COEF_C1_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[2][0] >> 8), HDMI_CSC_COEF_C1_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[2][1] & 0xff), HDMI_CSC_COEF_C2_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[2][1] >> 8), HDMI_CSC_COEF_C2_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[2][2] & 0xff), HDMI_CSC_COEF_C3_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[2][2] >> 8), HDMI_CSC_COEF_C3_MSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[2][3] & 0xff), HDMI_CSC_COEF_C4_LSB);
-	hdmi_writeb(hdmi, ((*csc_coeff)[2][3] >> 8), HDMI_CSC_COEF_C4_MSB);
+	/* The CSC registers are sequential, alternating MSB then LSB */
+	for (i = 0; i < ARRAY_SIZE(csc_coeff_default[0]); i++) {
+		u16 coeff_a = (*csc_coeff)[0][i];
+		u16 coeff_b = (*csc_coeff)[1][i];
+		u16 coeff_c = (*csc_coeff)[2][i];
+
+		hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2);
+		hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2);
+		hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2);
+		hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2);
+		hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2);
+		hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2);
+	}
 
 	val = hdmi_readb(hdmi, HDMI_CSC_SCALE);
 	val &= ~HDMI_CSC_SCALE_CSCSCALE_MASK;
-- 
1.8.3.1

  parent reply	other threads:[~2014-02-18 20:09 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-18 20:09 [PATCH 00/34] imx-drm stuff again Russell King - ARM Linux
2014-02-18 20:09 ` [PATCH 01/34] imx-drm: imx-hdmi: convert HDMI clock settings to tabular form Russell King
2014-02-18 20:09 ` Russell King [this message]
2014-02-18 20:09 ` [PATCH 03/34] imx-drm: imx-hdmi: provide register modification function Russell King
2014-02-18 20:09 ` [PATCH 04/34] imx-drm: imx-hdmi: clean up setting of vp_conf Russell King
2014-02-18 20:10 ` [PATCH 05/34] imx-drm: imx-hdmi: fix CTS/N setup at init time Russell King
2014-02-18 20:10 ` [PATCH 06/34] imx-drm: ipu-v3: more inteligent DI clock selection Russell King
2014-02-18 20:10 ` [PATCH 07/34] imx-drm: ipu-v3: don't use clk_round_rate() before clk_set_rate() Russell King
2014-02-18 20:10 ` [PATCH 08/34] imx-drm: ipu-v3: more clocking fixes Russell King
2014-02-18 20:10 ` [PATCH 09/34] imx-drm: add imx6 DT configuration for HDMI Russell King
2014-02-18 20:10 ` [PATCH 10/34] imx-drm: update and fix imx6 DT descriptions for v3 HDMI driver Russell King
2014-02-18 20:10 ` [PATCH 11/34] imx-drm: imx-drm-core: sanitise imx_drm_encoder_get_mux_id() Russell King
2014-02-18 20:10 ` [PATCH 12/34] imx-drm: imx-drm-core: use array instead of list for CRTCs Russell King
2014-02-18 20:10 ` [PATCH 13/34] imx-drm: provide common connector mode validation function Russell King
2014-02-18 20:10 ` [PATCH 14/34] imx-drm: simplify setup of panel format Russell King
2014-02-18 20:10 ` [PATCH 15/34] imx-drm: convert to componentised device support Russell King
2014-02-18 20:10 ` [PATCH 16/34] imx-drm: imx-hdmi: convert to a component device Russell King
2014-02-18 20:11 ` [PATCH 17/34] imx-drm: delay publishing sysfs connector entries Russell King
2014-02-18 20:11 ` [PATCH 18/34] imx-drm: remove separate imx-fbdev Russell King
2014-02-18 20:11 ` [PATCH 19/34] imx-drm: remove imx-fb.c Russell King
2014-02-18 20:11 ` [PATCH 20/34] imx-drm: use supplied drm_device where possible Russell King
2014-02-18 20:11 ` [PATCH 21/34] imx-drm: imx-drm-core: provide helper function to parse possible crtcs Russell King
2014-02-18 20:11 ` [PATCH 22/34] imx-drm: imx-drm-core: provide common connector and encoder cleanup functions Russell King
2014-02-18 20:11 ` [PATCH 23/34] imx-drm: parallel-display,imx-tve,imx-ldb: initialise drm components directly Russell King
2014-02-18 20:11 ` [PATCH 24/34] imx-drm: imx-hdmi: " Russell King
2014-02-18 20:11 ` [PATCH 25/34] imx-drm: imx-drm-core: remove imx_drm_connector and imx_drm_encoder code Russell King
2014-02-18 20:11 ` [PATCH 26/34] imx-drm: imx-drm-core: get rid of drm_mode_group_init_legacy_group() Russell King
2014-02-18 20:11 ` [PATCH 27/34] imx-drm: imx-drm-core: kill off mutex Russell King
2014-02-18 20:12 ` [PATCH 28/34] imx-drm: imx-drm-core: move allocation of imxdrm device to driver load function Russell King
2014-02-18 20:12 ` [PATCH 29/34] imx-drm: imx-drm-core: various cleanups Russell King
2014-02-18 20:12 ` [PATCH 30/34] imx-drm: imx-drm-core: add core hotplug connector support Russell King
2014-02-18 20:12 ` [PATCH 31/34] imx-drm: imx-hdmi: add hotplug support to HDMI component Russell King
2014-02-18 20:12 ` [PATCH 32/34] imx-drm: dw-hdmi-audio: add audio driver Russell King
2014-02-18 20:12 ` [PATCH 33/34] imx-drm: dw-hdmi-audio: parse ELD from HDMI driver Russell King
2014-02-18 20:12 ` [PATCH 34/34] imx-drm: add CEC " Russell King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1WFqzC-0007hy-I6@rmk-PC.arm.linux.org.uk \
    --to=rmk+kernel@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).