public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] video: tegra: Add dc color dithering support
@ 2011-04-16  3:18 Robert Morell
       [not found] ` <1302923939-374-1-git-send-email-rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Morell @ 2011-04-16  3:18 UTC (permalink / raw)
  To: linux-tegra-u79uwXL29TY76Z2rM5mHXA
  Cc: konkers-z5hGa2qSFaRBDgjK7y7TUQ, olof-nZhT3qVonbNeoWH0uzbU5w,
	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 <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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] arm: tegra: ventana: fix display depth, dithering
       [not found] ` <1302923939-374-1-git-send-email-rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-04-16  3:18   ` Robert Morell
  2011-04-16  6:26   ` [PATCH 1/2] video: tegra: Add dc color dithering support Mayuresh Janorkar
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Morell @ 2011-04-16  3:18 UTC (permalink / raw)
  To: linux-tegra-u79uwXL29TY76Z2rM5mHXA
  Cc: konkers-z5hGa2qSFaRBDgjK7y7TUQ, olof-nZhT3qVonbNeoWH0uzbU5w,
	Ari Hirvonen, Robert Morell

From: Ari Hirvonen <ahirvonen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

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

Signed-off-by: Ari Hirvonen <ahirvonen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Varun Colbert <vcolbert-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Tested-by: Robert Morell<rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
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(-)

diff --git a/arch/arm/mach-tegra/board-ventana-panel.c b/arch/arm/mach-tegra/board-ventana-panel.c
index f3e75e2..07919a4 100644
--- a/arch/arm/mach-tegra/board-ventana-panel.c
+++ b/arch/arm/mach-tegra/board-ventana-panel.c
@@ -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),
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] video: tegra: Add dc color dithering support
       [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   ` Mayuresh Janorkar
  2011-04-17  6:15   ` Olof Johansson
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Mayuresh Janorkar @ 2011-04-16  6:26 UTC (permalink / raw)
  To: Robert Morell
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	konkers-z5hGa2qSFaRBDgjK7y7TUQ, olof-nZhT3qVonbNeoWH0uzbU5w

On Sat, Apr 16, 2011 at 8:48 AM, Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>
> 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;
If would be a Good idea to add default case here.
> +       }
> +
>        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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] video: tegra: Add dc color dithering support
       [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
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Olof Johansson @ 2011-04-17  6:15 UTC (permalink / raw)
  To: Robert Morell
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	konkers-z5hGa2qSFaRBDgjK7y7TUQ

On Fri, Apr 15, 2011 at 8:18 PM, Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
> 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>

Acked-by: Olof Johansson <olof-nZhT3qVonbNeoWH0uzbU5w@public.gmane.org>


-Olof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] video: tegra: Add dc color dithering support
       [not found] ` <1302923939-374-1-git-send-email-rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
                     ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: Erik Gilling @ 2011-04-18 16:19 UTC (permalink / raw)
  To: Robert Morell
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, olof-nZhT3qVonbNeoWH0uzbU5w

On Fri, Apr 15, 2011 at 8:18 PM, Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:

 snip

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

> +       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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] video: tegra: Add dc color dithering support
       [not found] ` <1302923939-374-1-git-send-email-rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2011-04-18 16:19   ` Erik Gilling
@ 2011-04-18 17:28   ` Robert Morell
  2011-04-18 17:28   ` [PATCH v2 2/2] arm: tegra: ventana: fix display depth, dithering Robert Morell
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Morell @ 2011-04-18 17:28 UTC (permalink / raw)
  To: linux-tegra-u79uwXL29TY76Z2rM5mHXA
  Cc: konkers-z5hGa2qSFaRBDgjK7y7TUQ, olof-nZhT3qVonbNeoWH0uzbU5w,
	mayureshjanorkar-Re5JQEeQqe8AvxtiuMwx3w, 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 <chaoj-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
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(-)

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..658cabd 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) {
+	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);
 }
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] arm: tegra: ventana: fix display depth, dithering
       [not found] ` <1302923939-374-1-git-send-email-rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
                     ` (4 preceding siblings ...)
  2011-04-18 17:28   ` [PATCH v2 " Robert Morell
@ 2011-04-18 17:28   ` Robert Morell
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Morell @ 2011-04-18 17:28 UTC (permalink / raw)
  To: linux-tegra-u79uwXL29TY76Z2rM5mHXA
  Cc: konkers-z5hGa2qSFaRBDgjK7y7TUQ, olof-nZhT3qVonbNeoWH0uzbU5w,
	mayureshjanorkar-Re5JQEeQqe8AvxtiuMwx3w, Ari Hirvonen,
	Robert Morell

From: Ari Hirvonen <ahirvonen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

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

Signed-off-by: Ari Hirvonen <ahirvonen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Varun Colbert <vcolbert-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Tested-by: Robert Morell<rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Robert Morell <rmorell-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
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(-)

diff --git a/arch/arm/mach-tegra/board-ventana-panel.c b/arch/arm/mach-tegra/board-ventana-panel.c
index f3e75e2..07919a4 100644
--- a/arch/arm/mach-tegra/board-ventana-panel.c
+++ b/arch/arm/mach-tegra/board-ventana-panel.c
@@ -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),
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-04-18 17:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-16  3:18 [PATCH 1/2] video: tegra: Add dc color dithering support Robert Morell
     [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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox