Skip to contentSkip to conversation

video: tegra: Add dc color dithering support

PATCH Superseded Robert Morell 4 participants 7 messages Apr 16, 2011 – Apr 18, 2011 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 video: tegra: Add dc color dithering support

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 <[email protected]>

---
 arch/arm/mach-tegra/include/mach/dc.h |    7 +++++++
 drivers/video/tegra/dc/dc.c           |   24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/include/mach/dc.h +7 -0
index 254b732..696e6ed 100644
@@ -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;
drivers/video/tegra/dc/dc.c +24 -0
index 16789c2..4241a24 100644
@@ -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);
 }
 
Signature · 1 line
1.7.3.4
#2 lore raw

PATCH 2/2 arm: tegra: ventana: fix display depth, dithering

In reply to a message not in the archive

From: Ari Hirvonen <[email protected]>

Ventana has a 6-bit-per-component panel, so set the bit depth to 18, and enable ordered dithering for smoother gradients.

---
I was going to add this to harmony as well, but harmonay doesn't even have tegra_dc_out platform data in linux-tegra, so it needs some more love before this can be added.

 arch/arm/mach-tegra/board-ventana-panel.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/board-ventana-panel.c +2 -0
index f3e75e2..07919a4 100644
@@ -204,6 +204,8 @@ static struct tegra_dc_out ventana_disp1_out = {
 
 	.align		= TEGRA_DC_ALIGN_MSB,
 	.order		= TEGRA_DC_ORDER_RED_BLUE,
+	.depth		= 18,
+	.dither		= TEGRA_DC_ORDERED_DITHER,
 
 	.modes	 	= ventana_panel_modes,
 	.n_modes 	= ARRAY_SIZE(ventana_panel_modes),
Signature · 1 line
1.7.3.4
#3 lore raw
In reply to a message not in the archive
Quoted 60 lines · Robert Morell

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 <[email protected]>

---
 arch/arm/mach-tegra/include/mach/dc.h |    7 +++++++ drivers/video/tegra/dc/dc.c           |   24 ++++++++++++++++++++++++

 2 files changed, 31 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/include/mach/dc.h +7 -0
index 254b732..696e6ed 100644
@@ -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;
drivers/video/tegra/dc/dc.c +12 -0
index 16789c2..4241a24 100644
@@ -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) {

drivers/video/tegra/dc/dc.c static void tegra_dc_set_color_control(struct tegra_dc *dc) · line 914

Quoted 10 lines
drivers/video/tegra/dc/dc.c +10 -0
+       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;

If would be a Good idea to add default case here.

Quoted 12 lines
drivers/video/tegra/dc/dc.c +2 -1
+       }
+
        tegra_dc_writel(dc, color_control, DC_DISP_DISP_COLOR_CONTROL);
  }
 
--

1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to a message not in the archive
Quoted 9 lines · Robert Morell

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 <[email protected]>

-Olof

#5 lore raw
In reply to a message not in the archive

On Fri, Apr 15, 2011 at 8:18 PM, Robert Morell <[email protected]> wrote:

snip

Quoted 10 lines

+       /*
+        * 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;
+       }

snip

Quoted 5 lines

+       case TEGRA_DC_ERRDIFF_DITHER:
+               BUG_ON(dc->mode.h_active > 640);
+               color_control |= DITHER_CONTROL_ERRDIFF;
+               break;
+       }

Since you explicitly make this condition impossible above, the BUG_ON is not needed.

-Erik

#6 lore raw

PATCH v2 1/2 video: tegra: Add dc color dithering support

In reply to a message not in the archive

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 <[email protected]>

---
Version 2 adds a default case and removes redundant BUG_ON().

 arch/arm/mach-tegra/include/mach/dc.h |    7 +++++++
 drivers/video/tegra/dc/dc.c           |   24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/include/mach/dc.h +7 -0
index 254b732..696e6ed 100644
@@ -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;
drivers/video/tegra/dc/dc.c +24 -0
index 16789c2..658cabd 100644
@@ -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) {
+	default:
+	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:
+		color_control |= DITHER_CONTROL_ERRDIFF;
+		break;
+	}
+
 	tegra_dc_writel(dc, color_control, DC_DISP_DISP_COLOR_CONTROL);
 }
 
Signature · 1 line
1.7.3.4
#7 lore raw

PATCH v2 2/2 arm: tegra: ventana: fix display depth, dithering

In reply to a message not in the archive

From: Ari Hirvonen <[email protected]>

Ventana has a 6-bit-per-component panel, so set the bit depth to 18, and enable ordered dithering for smoother gradients.

---
I was going to add this to harmony as well, but harmonay doesn't even have tegra_dc_out platform data in linux-tegra, so it needs some more love before this can be added.

Version 2 is unchanged.

 arch/arm/mach-tegra/board-ventana-panel.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/board-ventana-panel.c +2 -0
index f3e75e2..07919a4 100644
@@ -204,6 +204,8 @@ static struct tegra_dc_out ventana_disp1_out = {
 
 	.align		= TEGRA_DC_ALIGN_MSB,
 	.order		= TEGRA_DC_ORDER_RED_BLUE,
+	.depth		= 18,
+	.dither		= TEGRA_DC_ORDERED_DITHER,
 
 	.modes	 	= ventana_panel_modes,
 	.n_modes 	= ARRAY_SIZE(ventana_panel_modes),
Signature · 1 line
1.7.3.4