public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: konkers-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org,
	olof-nZhT3qVonbNeoWH0uzbU5w@public.gmane.org,
	Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 1/2] video: tegra: Add dc color dithering support
Date: Fri, 15 Apr 2011 20:18:58 -0700	[thread overview]
Message-ID: <1302923939-374-1-git-send-email-rmorell@nvidia.com> (raw)

This change adds support for display color dithering configuration in
the display control structure.  Two dithering modes are possible:
ordered and error-diffusion mode.  Error-diffusion dithering is usually
considered higher quality, but can only be used when the active region
is less than 640 pixels wide.

This is based on patches from Chao Jiang <chaoj-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 arch/arm/mach-tegra/include/mach/dc.h |    7 +++++++
 drivers/video/tegra/dc/dc.c           |   24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-tegra/include/mach/dc.h b/arch/arm/mach-tegra/include/mach/dc.h
index 254b732..696e6ed 100644
--- a/arch/arm/mach-tegra/include/mach/dc.h
+++ b/arch/arm/mach-tegra/include/mach/dc.h
@@ -44,6 +44,12 @@ enum {
 	TEGRA_DC_OUT_HDMI,
 };
 
+enum {
+	TEGRA_DC_DISABLE_DITHER = 1,
+	TEGRA_DC_ORDERED_DITHER,
+	TEGRA_DC_ERRDIFF_DITHER,
+};
+
 struct tegra_dc_out {
 	int			type;
 	unsigned		flags;
@@ -58,6 +64,7 @@ struct tegra_dc_out {
 	unsigned		order;
 	unsigned		align;
 	unsigned		depth;
+	unsigned		dither;
 
 	struct tegra_dc_mode	*modes;
 	int			n_modes;
diff --git a/drivers/video/tegra/dc/dc.c b/drivers/video/tegra/dc/dc.c
index 16789c2..4241a24 100644
--- a/drivers/video/tegra/dc/dc.c
+++ b/drivers/video/tegra/dc/dc.c
@@ -890,6 +890,30 @@ static void tegra_dc_set_color_control(struct tegra_dc *dc)
 		break;
 	}
 
+	/*
+	 * The line buffer for error-diffusion dither is limited to 640 pixels
+	 * per line, so we can't use it if the active region is larger than 640
+	 * pixels.  Be nice and fall back to ordered dithering, but warn so the
+	 * platform data can be corrected.
+	 */
+	if (WARN_ON(dc->out->dither == TEGRA_DC_ERRDIFF_DITHER &&
+		    dc->mode.h_active > 640)) {
+		dc->out->dither = TEGRA_DC_ORDERED_DITHER;
+	}
+
+	switch (dc->out->dither) {
+	case TEGRA_DC_DISABLE_DITHER:
+		color_control |= DITHER_CONTROL_DISABLE;
+		break;
+	case TEGRA_DC_ORDERED_DITHER:
+		color_control |= DITHER_CONTROL_ORDERED;
+		break;
+	case TEGRA_DC_ERRDIFF_DITHER:
+		BUG_ON(dc->mode.h_active > 640);
+		color_control |= DITHER_CONTROL_ERRDIFF;
+		break;
+	}
+
 	tegra_dc_writel(dc, color_control, DC_DISP_DISP_COLOR_CONTROL);
 }
 
-- 
1.7.3.4

             reply	other threads:[~2011-04-16  3:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-16  3:18 Robert Morell [this message]
     [not found] ` <1302923939-374-1-git-send-email-rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-04-16  3:18   ` [PATCH 2/2] arm: tegra: ventana: fix display depth, dithering Robert Morell
2011-04-16  6:26   ` [PATCH 1/2] video: tegra: Add dc color dithering support Mayuresh Janorkar
2011-04-17  6:15   ` Olof Johansson
2011-04-18 16:19   ` Erik Gilling
2011-04-18 17:28   ` [PATCH v2 " Robert Morell
2011-04-18 17:28   ` [PATCH v2 2/2] arm: tegra: ventana: fix display depth, dithering Robert Morell

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=1302923939-374-1-git-send-email-rmorell@nvidia.com \
    --to=rmorell-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
    --cc=konkers-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=olof-nZhT3qVonbNeoWH0uzbU5w@public.gmane.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