Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH v2 3/4] media: videobuf2-dma-contig: use dma_mmap_coherent if available
From: Hideki EIRAKU @ 2012-07-26 11:13 UTC (permalink / raw)
  To: Russell King, Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, Florian Tobias Schandinat, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-media, linux-fbdev,
	alsa-devel, Katsuya MATSUBARA, Hideki EIRAKU
In-Reply-To: <1343301191-26001-1-git-send-email-hdk@igel.co.jp>

Previously the vb2_dma_contig_mmap() function was using a dma_addr_t as a
physical address.  The two addressses are not necessarily the same.
For example, when using the IOMMU funtion on certain platforms, dma_addr_t
addresses are not directly mappable physical address.
dma_mmap_coherent() maps the address correctly.
It is available on ARM platforms.

Signed-off-by: Hideki EIRAKU <hdk@igel.co.jp>
---
 drivers/media/video/videobuf2-dma-contig.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c
index 4b71326..4dc85ab 100644
--- a/drivers/media/video/videobuf2-dma-contig.c
+++ b/drivers/media/video/videobuf2-dma-contig.c
@@ -101,14 +101,32 @@ static unsigned int vb2_dma_contig_num_users(void *buf_priv)
 static int vb2_dma_contig_mmap(void *buf_priv, struct vm_area_struct *vma)
 {
 	struct vb2_dc_buf *buf = buf_priv;
+#ifdef ARCH_HAS_DMA_MMAP_COHERENT
+	int ret;
+#endif
 
 	if (!buf) {
 		printk(KERN_ERR "No buffer to map\n");
 		return -EINVAL;
 	}
 
+#ifdef ARCH_HAS_DMA_MMAP_COHERENT
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+	ret = dma_mmap_coherent(buf->conf->dev, vma, buf->vaddr, buf->dma_addr,
+				buf->size);
+	if (ret) {
+		pr_err("Remapping memory failed, error: %d\n", ret);
+		return ret;
+	}
+	vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED;
+	vma->vm_private_data = &buf->handler;
+	vma->vm_ops = &vb2_common_vm_ops;
+	vma->vm_ops->open(vma);
+	return 0;
+#else
 	return vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size,
 				  &vb2_common_vm_ops, &buf->handler);
+#endif
 }
 
 static void *vb2_dma_contig_get_userptr(void *alloc_ctx, unsigned long vaddr,
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH v2 2/4] ALSA: pcm - Don't define ARCH_HAS_DMA_MMAP_COHERENT privately for ARM
From: Hideki EIRAKU @ 2012-07-26 11:13 UTC (permalink / raw)
  To: Russell King, Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, Florian Tobias Schandinat, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-media, linux-fbdev,
	alsa-devel, Katsuya MATSUBARA, Laurent Pinchart
In-Reply-To: <1343301191-26001-1-git-send-email-hdk@igel.co.jp>

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

The ARM architecture now defines ARCH_HAS_DMA_MMAP_COHERENT, there's no
need to define it privately anymore.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 sound/core/pcm_native.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 53b5ada..84ead60 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3156,13 +3156,6 @@ static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = {
 	.fault =	snd_pcm_mmap_data_fault,
 };
 
-#ifndef ARCH_HAS_DMA_MMAP_COHERENT
-/* This should be defined / handled globally! */
-#ifdef CONFIG_ARM
-#define ARCH_HAS_DMA_MMAP_COHERENT
-#endif
-#endif
-
 /*
  * mmap the DMA buffer on RAM
  */
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH v2 1/4] ARM: dma-mapping: define ARCH_HAS_DMA_MMAP_COHERENT
From: Hideki EIRAKU @ 2012-07-26 11:13 UTC (permalink / raw)
  To: Russell King, Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, Florian Tobias Schandinat, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-media, linux-fbdev,
	alsa-devel, Katsuya MATSUBARA, Hideki EIRAKU
In-Reply-To: <1343301191-26001-1-git-send-email-hdk@igel.co.jp>

ARCH_HAS_DMA_MMAP_COHERENT indicates that there is dma_mmap_coherent() API
in this architecture.  The name is already defined in PowerPC.

Signed-off-by: Hideki EIRAKU <hdk@igel.co.jp>
---
 arch/arm/include/asm/dma-mapping.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index bbef15d..f41cd30 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -187,6 +187,7 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
 			struct dma_attrs *attrs);
 
 #define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
+#define ARCH_HAS_DMA_MMAP_COHERENT
 
 static inline int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
 				  void *cpu_addr, dma_addr_t dma_addr,
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH v2 0/4] Use dma_mmap_coherent to support IOMMU mapper
From: Hideki EIRAKU @ 2012-07-26 11:13 UTC (permalink / raw)
  To: Russell King, Pawel Osciak, Marek Szyprowski, Kyungmin Park,
	Mauro Carvalho Chehab, Florian Tobias Schandinat, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-media, linux-fbdev,
	alsa-devel, Katsuya MATSUBARA, Hideki EIRAKU

There is a dma_mmap_coherent() API in some architectures.  This API
provides a mmap function for memory allocated by dma_alloc_coherent().
Some drivers mmap a dma_addr_t returned by dma_alloc_coherent() as a
physical address.  But such drivers do not work correctly when IOMMU
mapper is used.

v2:
- Rebase on fbdev-next branch of
  git://github.com/schandinat/linux-2.6.git.
- Initialize .fb_mmap in both sh_mobile_lcdc_overlay_ops and
  sh_mobile_lcdc_ops.
- Add Laurent's clean up patch.

Hideki EIRAKU (3):
  ARM: dma-mapping: define ARCH_HAS_DMA_MMAP_COHERENT
  media: videobuf2-dma-contig: use dma_mmap_coherent if available
  fbdev: sh_mobile_lcdc: use dma_mmap_coherent if available

Laurent Pinchart (1):
  ALSA: pcm - Don't define ARCH_HAS_DMA_MMAP_COHERENT privately for ARM

 arch/arm/include/asm/dma-mapping.h         |    1 +
 drivers/media/video/videobuf2-dma-contig.c |   18 ++++++++++++++++++
 drivers/video/sh_mobile_lcdcfb.c           |   28 ++++++++++++++++++++++++++++
 sound/core/pcm_native.c                    |    7 -------
 4 files changed, 47 insertions(+), 7 deletions(-)


^ permalink raw reply

* [PATCH] ALSA: pcm - Don't define ARCH_HAS_DMA_MMAP_COHERENT privately for ARM
From: Laurent Pinchart @ 2012-07-25 16:01 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1343197764-13659-1-git-send-email-hdk@igel.co.jp>

The ARM architecture now defines ARCH_HAS_DMA_MMAP_COHERENT, there's no
need to define it privately anymore.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 sound/core/pcm_native.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)

Hi Eiraku-san,

Could you please add this cleanup patch to your "Use dma_mmap_coherent to
support IOMMU mapper" series ?

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 53b5ada..84ead60 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3156,13 +3156,6 @@ static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = {
 	.fault =	snd_pcm_mmap_data_fault,
 };
 
-#ifndef ARCH_HAS_DMA_MMAP_COHERENT
-/* This should be defined / handled globally! */
-#ifdef CONFIG_ARM
-#define ARCH_HAS_DMA_MMAP_COHERENT
-#endif
-#endif
-
 /*
  * mmap the DMA buffer on RAM
  */
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related

* Re: [PATCH 4/4] fbcon: optimize parameters parsing loop.
From: paul @ 2012-07-25 14:14 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: florianschandinat, linux-kernel, linux-fbdev
In-Reply-To: <1343091626-11435-4-git-send-email-paul@crapouillou.net>

 From 67cecd09d850542e00a1d9a29567232d1224cf23 Mon Sep 17 00:00:00 2001
 From: Paul Cercueil <paul@crapouillou.net>
Date: Thu, 12 Jan 2012 19:40:24 +0100
Subject: [PATCH 4/4] fbcon: optimize parameters parsing loop.


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
  drivers/video/console/fbcon.c |    8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/video/console/fbcon.c 
b/drivers/video/console/fbcon.c
index 9b83b75..1ecaf68 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -441,8 +441,10 @@ static int __init fb_console_setup(char *this_opt)
  		return 1;

  	while ((options = strsep(&this_opt, ",")) != NULL) {
-		if (!strncmp(options, "font:", 5))
+		if (!strncmp(options, "font:", 5)) {
  			strlcpy(fontname, options + 5, sizeof(fontname));
+			continue;
+		}

  		if (!strncmp(options, "scrollback:", 11)) {
  			char *k;
@@ -468,6 +470,7 @@ static int __init fb_console_setup(char *this_opt)
  			/* (k && *k): Check for garbage after the suffix */
  			if (ret || (k && *k))
  				pr_warn("fbcon: scrollback: incorrect value.\n");
+			continue;
  		}

  		if (!strncmp(options, "map:", 4)) {
@@ -484,6 +487,7 @@ static int __init fb_console_setup(char *this_opt)
  			} else {
  				pr_warn("fbcon: map: incorrect value.\n");
  			}
+			continue;
  		}

  		if (!strncmp(options, "vc:", 3)) {
@@ -513,6 +517,7 @@ static int __init fb_console_setup(char *this_opt)
  				fbcon_is_default = 0;
  			else
  				pr_warn("fbcon: vc: incorrect value.\n");
+			continue;
  		}

  		if (!strncmp(options, "rotate:", 7)) {
@@ -525,6 +530,7 @@ static int __init fb_console_setup(char *this_opt)
  			} else {
  				pr_warn("fbcon: rotate: incorrect value.\n");
  			}
+			continue;
  		}
  	}
  	return 1;
-- 
1.7.10.4


^ permalink raw reply related

* Re: [PATCH 4/4] fbcon: optimize parameters parsing loop.
From: paul @ 2012-07-25 14:13 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: florianschandinat, linux-kernel, linux-fbdev
In-Reply-To: <1343091626-11435-4-git-send-email-paul@crapouillou.net>

Oh, I'm really sorry, I truely am.
It looks like that 4th patch is an old version, not the one that should 
have been sent.

Next message will be the correct patch. My apologies about that.

^ permalink raw reply

* Re: [PATCH 3/3] fbdev: sh_mobile_lcdc: use dma_mmap_coherent if available
From: Laurent Pinchart @ 2012-07-25 11:10 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1343197764-13659-4-git-send-email-hdk@igel.co.jp>

Hi Eiraku-san,

Thank you for the patch.

On Wednesday 25 July 2012 15:29:24 Hideki EIRAKU wrote:
> fb_mmap() implemented in fbmem.c uses smem_start as the physical
> address of the frame buffer.  In the sh_mobile_lcdc driver, the
> smem_start is a dma_addr_t that is not a physical address when IOMMU is
> enabled.  dma_mmap_coherent() maps the address correctly.  It is
> available on ARM platforms.

This looks good to me, but will need to be rebased on top of the 
sh_mobile_lcdc patches currently queued for v3.6. You can find them in the 
fbdev-next branch of git://github.com/schandinat/linux-2.6.git.

In particular, these patches add support for overlays exported through 
additional fbdev devices. You will need to initialize .fb_mmap in both 
sh_mobile_lcdc_overlay_ops and sh_mobile_lcdc_ops.

> Signed-off-by: Hideki EIRAKU <hdk@igel.co.jp>
> ---
>  drivers/video/sh_mobile_lcdcfb.c |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/video/sh_mobile_lcdcfb.c
> b/drivers/video/sh_mobile_lcdcfb.c index e672698..65732c4 100644
> --- a/drivers/video/sh_mobile_lcdcfb.c
> +++ b/drivers/video/sh_mobile_lcdcfb.c
> @@ -1393,6 +1393,17 @@ static int sh_mobile_lcdc_blank(int blank, struct
> fb_info *info) return 0;
>  }
> 
> +#ifdef ARCH_HAS_DMA_MMAP_COHERENT
> +static int
> +sh_mobile_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
> +{
> +	struct sh_mobile_lcdc_chan *ch = info->par;
> +
> +	return dma_mmap_coherent(ch->lcdc->dev, vma, ch->fb_mem,
> +				 ch->dma_handle, ch->fb_size);
> +}
> +#endif
> +
>  static struct fb_ops sh_mobile_lcdc_ops = {
>  	.owner          = THIS_MODULE,
>  	.fb_setcolreg	= sh_mobile_lcdc_setcolreg,
> @@ -1408,6 +1419,9 @@ static struct fb_ops sh_mobile_lcdc_ops = {
>  	.fb_release	= sh_mobile_release,
>  	.fb_check_var	= sh_mobile_check_var,
>  	.fb_set_par	= sh_mobile_set_par,
> +#ifdef ARCH_HAS_DMA_MMAP_COHERENT
> +	.fb_mmap	= sh_mobile_fb_mmap,
> +#endif
>  };
> 
>  static void
-- 
Regards,

Laurent Pinchart


^ permalink raw reply

* [PATCH 3/3] fbdev: sh_mobile_lcdc: use dma_mmap_coherent if available
From: Hideki EIRAKU @ 2012-07-25  6:29 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1343197764-13659-1-git-send-email-hdk@igel.co.jp>

fb_mmap() implemented in fbmem.c uses smem_start as the physical
address of the frame buffer.  In the sh_mobile_lcdc driver, the
smem_start is a dma_addr_t that is not a physical address when IOMMU is
enabled.  dma_mmap_coherent() maps the address correctly.  It is
available on ARM platforms.

Signed-off-by: Hideki EIRAKU <hdk@igel.co.jp>
---
 drivers/video/sh_mobile_lcdcfb.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index e672698..65732c4 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -1393,6 +1393,17 @@ static int sh_mobile_lcdc_blank(int blank, struct fb_info *info)
 	return 0;
 }
 
+#ifdef ARCH_HAS_DMA_MMAP_COHERENT
+static int
+sh_mobile_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+	struct sh_mobile_lcdc_chan *ch = info->par;
+
+	return dma_mmap_coherent(ch->lcdc->dev, vma, ch->fb_mem,
+				 ch->dma_handle, ch->fb_size);
+}
+#endif
+
 static struct fb_ops sh_mobile_lcdc_ops = {
 	.owner          = THIS_MODULE,
 	.fb_setcolreg	= sh_mobile_lcdc_setcolreg,
@@ -1408,6 +1419,9 @@ static struct fb_ops sh_mobile_lcdc_ops = {
 	.fb_release	= sh_mobile_release,
 	.fb_check_var	= sh_mobile_check_var,
 	.fb_set_par	= sh_mobile_set_par,
+#ifdef ARCH_HAS_DMA_MMAP_COHERENT
+	.fb_mmap	= sh_mobile_fb_mmap,
+#endif
 };
 
 static void
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 2/3] media: videobuf2-dma-contig: use dma_mmap_coherent if available
From: Hideki EIRAKU @ 2012-07-25  6:29 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1343197764-13659-1-git-send-email-hdk@igel.co.jp>

Previously the vb2_dma_contig_mmap() function was using a dma_addr_t as a
physical address.  The two addressses are not necessarily the same.
For example, when using the IOMMU funtion on certain platforms, dma_addr_t
addresses are not directly mappable physical address.
dma_mmap_coherent() maps the address correctly.
It is available on ARM platforms.

Signed-off-by: Hideki EIRAKU <hdk@igel.co.jp>
---
 drivers/media/video/videobuf2-dma-contig.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c
index 4b71326..4dc85ab 100644
--- a/drivers/media/video/videobuf2-dma-contig.c
+++ b/drivers/media/video/videobuf2-dma-contig.c
@@ -101,14 +101,32 @@ static unsigned int vb2_dma_contig_num_users(void *buf_priv)
 static int vb2_dma_contig_mmap(void *buf_priv, struct vm_area_struct *vma)
 {
 	struct vb2_dc_buf *buf = buf_priv;
+#ifdef ARCH_HAS_DMA_MMAP_COHERENT
+	int ret;
+#endif
 
 	if (!buf) {
 		printk(KERN_ERR "No buffer to map\n");
 		return -EINVAL;
 	}
 
+#ifdef ARCH_HAS_DMA_MMAP_COHERENT
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+	ret = dma_mmap_coherent(buf->conf->dev, vma, buf->vaddr, buf->dma_addr,
+				buf->size);
+	if (ret) {
+		pr_err("Remapping memory failed, error: %d\n", ret);
+		return ret;
+	}
+	vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED;
+	vma->vm_private_data = &buf->handler;
+	vma->vm_ops = &vb2_common_vm_ops;
+	vma->vm_ops->open(vma);
+	return 0;
+#else
 	return vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size,
 				  &vb2_common_vm_ops, &buf->handler);
+#endif
 }
 
 static void *vb2_dma_contig_get_userptr(void *alloc_ctx, unsigned long vaddr,
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 1/3] ARM: dma-mapping: define ARCH_HAS_DMA_MMAP_COHERENT
From: Hideki EIRAKU @ 2012-07-25  6:29 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1343197764-13659-1-git-send-email-hdk@igel.co.jp>

ARCH_HAS_DMA_MMAP_COHERENT indicates that there is dma_mmap_coherent() API
in this architecture.  The name is already defined in PowerPC.

Signed-off-by: Hideki EIRAKU <hdk@igel.co.jp>
---
 arch/arm/include/asm/dma-mapping.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index bbef15d..f41cd30 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -187,6 +187,7 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
 			struct dma_attrs *attrs);
 
 #define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
+#define ARCH_HAS_DMA_MMAP_COHERENT
 
 static inline int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
 				  void *cpu_addr, dma_addr_t dma_addr,
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 0/3] Use dma_mmap_coherent to support IOMMU mapper
From: Hideki EIRAKU @ 2012-07-25  6:29 UTC (permalink / raw)
  To: linux-arm-kernel

There is a dma_mmap_coherent() API in some architectures.  This API
provides a mmap function for memory allocated by dma_alloc_coherent().
Some drivers mmap a dma_addr_t returned by dma_alloc_coherent() as a
physical address.  But such drivers do not work correctly when IOMMU
mapper is used.

Hideki EIRAKU (3):
  ARM: dma-mapping: define ARCH_HAS_DMA_MMAP_COHERENT
  media: videobuf2-dma-contig: use dma_mmap_coherent if available
  fbdev: sh_mobile_lcdc: use dma_mmap_coherent if available

 arch/arm/include/asm/dma-mapping.h         |    1 +
 drivers/media/video/videobuf2-dma-contig.c |   18 ++++++++++++++++++
 drivers/video/sh_mobile_lcdcfb.c           |   14 ++++++++++++++
 3 files changed, 33 insertions(+), 0 deletions(-)


^ permalink raw reply

* [PATCH] OMAPDSS: DISPC: Use msleep instead of blocking mdelay
From: Jassi Brar @ 2012-07-24 14:15 UTC (permalink / raw)
  To: tomi.valkeinen, a0393947; +Cc: linux-omap, linux-fbdev, Jassi Brar

We have no reason to block in the error handler workqueue, so use msleep.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
---
 drivers/video/omap2/dss/dispc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c
index c56a51a..0e3ad44 100644
--- a/drivers/video/omap2/dss/dispc.c
+++ b/drivers/video/omap2/dss/dispc.c
@@ -3492,7 +3492,7 @@ static void dispc_error_worker(struct work_struct *work)
 					ovl->name);
 			dispc_ovl_enable(ovl->id, false);
 			dispc_mgr_go(ovl->manager->id);
-			mdelay(50);
+			msleep(50);
 		}
 	}
 
@@ -3524,7 +3524,7 @@ static void dispc_error_worker(struct work_struct *work)
 			}
 
 			dispc_mgr_go(mgr->id);
-			mdelay(50);
+			msleep(50);
 
 			if (enable)
 				dssdev->driver->enable(dssdev);
-- 
1.7.4.1


^ permalink raw reply related

* (no subject)
From: roboth roli company @ 2012-07-24 11:46 UTC (permalink / raw)
  To: linux-fbdev


 i am robothroli, Purchase manager from roli Merchant Ltd. We are
Import/export Company based in taiwan. We are interested in purchasing
your product and I would like to make an inquiry. Please inform me on:

Sample availability and price
Minimum order quantity
FOB Prices

Sincerely
Purchase Manager
robothroli




^ permalink raw reply

* Re: [PATCH v2] da8xx-fb: enable sync lost interrupt
From: Sergei Shtylyov @ 2012-07-24 11:21 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1343101413-1820-1-git-send-email-prakash.pm@ti.com>

Hello.

On 24-07-2012 7:43, Manjunathappa, Prakash wrote:

> Patch enables sync lost interrupt and interrupt handler already
> takes care to handle it.

> Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com>
> ---
> Since v1:
> Minor nit, replaced spaces with tabs.

>   drivers/video/da8xx-fb.c |    7 +++++--
>   1 files changed, 5 insertions(+), 2 deletions(-)

> diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
> index 47118c7..8163832 100644
> --- a/drivers/video/da8xx-fb.c
> +++ b/drivers/video/da8xx-fb.c
[...]
> @@ -718,6 +719,7 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
>   	u32 reg_int;
>
>   	if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
> +		pr_err("LCDC sync lost or underflow error occurred\n");

     You write "or" here. Perhaps it should be || instead of && above?

>   		lcd_disable_raster();
>   		lcdc_write(stat, LCD_MASKED_STAT_REG);
>   		lcd_enable_raster();
> @@ -773,6 +775,7 @@ static irqreturn_t lcdc_irq_handler_rev01(int irq, void *arg)
>   	u32 reg_ras;
>
>   	if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
> +		pr_err("LCDC sync lost or underflow error occurred\n");

    Same comment.

WBR, Sergei


^ permalink raw reply

* RE: [PATCH v2] da8xx-fb: allow frame to complete after disabling LCDC
From: Manjunathappa, Prakash @ 2012-07-24  9:34 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1343102984-6056-1-git-send-email-prakash.pm@ti.com>

On Tue, Jul 24, 2012 at 14:08:05, Madhvapathi Sriram wrote:
> On Tue, Jul 24, 2012 at 12:47 PM, Manjunathappa, Prakash
> <prakash.pm@ti.com> wrote:
> > Hi Sriram,
> >
> > On Tue, Jul 24, 2012 at 10:11:55, Madhvapathi Sriram wrote:
> >> On Tue, Jul 24, 2012 at 9:39 AM, Manjunathappa, Prakash
> >> <prakash.pm@ti.com> wrote:
> > [...]
> >> >  /* Disable the Raster Engine of the LCD Controller */
> >> > -static inline void lcd_disable_raster(void)
> >> > +static inline void lcd_disable_raster(bool wait_for_frame_done)
> >> >  {
> >> >         u32 reg;
> >> > +       u32 loop_cnt = 0;
> >> > +       u32 stat;
> >> > +       u32 i = 0;
> >> > +
> >> > +       /* 50 milli seconds should be sufficient for a frame to complete
> >> > */
> >> > +       if (wait_for_frame_done)
> >> > +               loop_cnt = 50;
> >> >
> >> >         reg = lcdc_read(LCD_RASTER_CTRL_REG);
> >> >         if (reg & LCD_RASTER_ENABLE)
> >> >                 lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
> >> > +
> >> > +       /* Wait for the current frame to complete */
> >> > +       do {
> >> > +               if (lcd_revision = LCD_VERSION_1)
> >> > +                       stat = lcdc_read(LCD_STAT_REG);
> >> > +               else
> >> > +                       stat = lcdc_read(LCD_RAW_STAT_REG);
> >> > +               mdelay(1);
> >> > +       } while (!(stat & LCD_FRAME_DONE) && (i++ < loop_cnt));
> >>
> >> Are you sure it should be do while? You call it from interrupt handler
> >> too (sync lost handling). In that case mdelay() from interrupt
> >> context..not a good idea I feel.
> >>
> >
> > Ok. I will change it as below:
> >
> > while (1) {
> >                if (lcd_revision = LCD_VERSION_1)
> >                        stat = lcdc_read(LCD_STAT_REG);
> >                else
> >                        stat = lcdc_read(LCD_RAW_STAT_REG);
> >                if((stat & LCD_FRAME_DONE) || (i++ > loop_cnt))
> >                     break;
> >                mdelay(1);
> > }
> >
> Hmm.. while(1) could be avoided though. Club all frame-done-wait
> related at one place. I leave it open for your choice.
> 
> Some where in the beginning of fxn....
> u32 stat_reg = LCD_STAT_REG;
> 
> Avoids conditions in loop....
> if (lcd_revision = LCD_VERSION_2)
>        stat_reg = LCD_RAW_STAT_REG;
> 
> if (wait_for_frame_done) {
>     u32 loop_count = 50;
> 
>     while (!(lcdc_read(stat_reg) & LCD_FRAME_DONE)) {
>            /* Handle timeout */
>            if(unlikely(0 = --loop_count)) {
>                 pr_err("LCD Controller timed out\n");
>                 break;
>            }
>            mdelay(1);
>     }
> }
> 
> 

Thanks Sriram, I will consider this.

> >> > +
> >> > +       if (lcd_revision = LCD_VERSION_1)
> >> > +               lcdc_write(stat, LCD_STAT_REG);
> >> > +       else
> >> > +               lcdc_write(stat, LCD_MASKED_STAT_REG);
> >> > +
> >> > +       if ((loop_cnt != 0) && (i >= loop_cnt)) {
> >> > +               pr_err("LCD Controller timed out\n");
> >> > +               return;
> >>
> >> return may not be necessary?
> >>
> >
> > Agree, I will remove it.
> >
> > Thanks,
> > Prakash
> >
> >> > +       }
> >> >  }
> >
> > [...]
> >
> 


^ permalink raw reply

* [GIT PULL] SH Mobile LCDC and MERAM patches
From: Laurent Pinchart @ 2012-07-24  9:16 UTC (permalink / raw)
  To: linux-fbdev

Hi Florian,

The following changes since commit 6fcdbc0c3a683003a00f383fceac80da1b7852ff:

  s3fb: Add Virge/MX (86C260) (2012-07-08 14:03:50 +0000)

are available in the git repository at:
  git://linuxtv.org/pinchartl/fbdev.git for-next

Laurent Pinchart (9):
      sh_mobile_meram: Rename operations to cache_[alloc|free|update]
      sh_mobile_meram: Use direct function calls for the public API
      sh_mobile_meram: Add direct MERAM allocation API
      fbdev: sh_mobile_lcdc: Destroy mutex at remove time
      fbdev: sh_mobile_lcdc: Fix line pitch computation
      fbdev: sh_mobile_lcdc: Use channel configuration to initialize fb device
      fbdev: sh_mobile_lcdc: Support horizontal panning
      fbdev: sh_mobile_lcdc: Fix overlay registers update during pan operation
      fbdev: sh_mobile_lcdc: Fix pan offset computation in YUV mode

 drivers/video/sh_mobile_lcdcfb.c |  209 +++++++++++++++++----------------
 drivers/video/sh_mobile_lcdcfb.h |    5 +-
 drivers/video/sh_mobile_meram.c  |  235 ++++++++++++++++++++-----------------
 include/video/sh_mobile_meram.h  |   71 ++++++++----
 4 files changed, 293 insertions(+), 227 deletions(-)

-- 
Regards,

Laurent Pinchart


^ permalink raw reply

* Re: [PATCH v2] da8xx-fb: allow frame to complete after disabling LCDC
From: Madhvapathi Sriram @ 2012-07-24  8:50 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1343102984-6056-1-git-send-email-prakash.pm@ti.com>

On Tue, Jul 24, 2012 at 12:47 PM, Manjunathappa, Prakash
<prakash.pm@ti.com> wrote:
> Hi Sriram,
>
> On Tue, Jul 24, 2012 at 10:11:55, Madhvapathi Sriram wrote:
>> On Tue, Jul 24, 2012 at 9:39 AM, Manjunathappa, Prakash
>> <prakash.pm@ti.com> wrote:
> [...]
>> >  /* Disable the Raster Engine of the LCD Controller */
>> > -static inline void lcd_disable_raster(void)
>> > +static inline void lcd_disable_raster(bool wait_for_frame_done)
>> >  {
>> >         u32 reg;
>> > +       u32 loop_cnt = 0;
>> > +       u32 stat;
>> > +       u32 i = 0;
>> > +
>> > +       /* 50 milli seconds should be sufficient for a frame to complete
>> > */
>> > +       if (wait_for_frame_done)
>> > +               loop_cnt = 50;
>> >
>> >         reg = lcdc_read(LCD_RASTER_CTRL_REG);
>> >         if (reg & LCD_RASTER_ENABLE)
>> >                 lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
>> > +
>> > +       /* Wait for the current frame to complete */
>> > +       do {
>> > +               if (lcd_revision = LCD_VERSION_1)
>> > +                       stat = lcdc_read(LCD_STAT_REG);
>> > +               else
>> > +                       stat = lcdc_read(LCD_RAW_STAT_REG);
>> > +               mdelay(1);
>> > +       } while (!(stat & LCD_FRAME_DONE) && (i++ < loop_cnt));
>>
>> Are you sure it should be do while? You call it from interrupt handler
>> too (sync lost handling). In that case mdelay() from interrupt
>> context..not a good idea I feel.
>>
>
> Ok. I will change it as below:
>
> while (1) {
>                if (lcd_revision = LCD_VERSION_1)
>                        stat = lcdc_read(LCD_STAT_REG);
>                else
>                        stat = lcdc_read(LCD_RAW_STAT_REG);
>                if((stat & LCD_FRAME_DONE) || (i++ > loop_cnt))
>                     break;
>                mdelay(1);
> }
>
Hmm.. while(1) could be avoided though. Club all frame-done-wait
related at one place. I leave it open for your choice.

Some where in the beginning of fxn....
u32 stat_reg = LCD_STAT_REG;

Avoids conditions in loop....
if (lcd_revision = LCD_VERSION_2)
       stat_reg = LCD_RAW_STAT_REG;

if (wait_for_frame_done) {
    u32 loop_count = 50;

    while (!(lcdc_read(stat_reg) & LCD_FRAME_DONE)) {
           /* Handle timeout */
           if(unlikely(0 = --loop_count)) {
                pr_err("LCD Controller timed out\n");
                break;
           }
           mdelay(1);
    }
}


>> > +
>> > +       if (lcd_revision = LCD_VERSION_1)
>> > +               lcdc_write(stat, LCD_STAT_REG);
>> > +       else
>> > +               lcdc_write(stat, LCD_MASKED_STAT_REG);
>> > +
>> > +       if ((loop_cnt != 0) && (i >= loop_cnt)) {
>> > +               pr_err("LCD Controller timed out\n");
>> > +               return;
>>
>> return may not be necessary?
>>
>
> Agree, I will remove it.
>
> Thanks,
> Prakash
>
>> > +       }
>> >  }
>
> [...]
>

^ permalink raw reply

* RE: [PATCH v2] da8xx-fb: allow frame to complete after disabling LCDC
From: Manjunathappa, Prakash @ 2012-07-24  8:26 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1343102984-6056-1-git-send-email-prakash.pm@ti.com>

On Tue, Jul 24, 2012 at 12:47:02, Manjunathappa, Prakash wrote:
> Hi Sriram,
> 
> On Tue, Jul 24, 2012 at 10:11:55, Madhvapathi Sriram wrote:
> > On Tue, Jul 24, 2012 at 9:39 AM, Manjunathappa, Prakash
> > <prakash.pm@ti.com> wrote:
> [...]
> > >  /* Disable the Raster Engine of the LCD Controller */
> > > -static inline void lcd_disable_raster(void)
> > > +static inline void lcd_disable_raster(bool wait_for_frame_done)
> > >  {
> > >         u32 reg;
> > > +       u32 loop_cnt = 0;
> > > +       u32 stat;
> > > +       u32 i = 0;
> > > +
> > > +       /* 50 milli seconds should be sufficient for a frame to complete
> > > */
> > > +       if (wait_for_frame_done)
> > > +               loop_cnt = 50;
> > >
> > >         reg = lcdc_read(LCD_RASTER_CTRL_REG);
> > >         if (reg & LCD_RASTER_ENABLE)
> > >                 lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
> > > +
> > > +       /* Wait for the current frame to complete */
> > > +       do {
> > > +               if (lcd_revision = LCD_VERSION_1)
> > > +                       stat = lcdc_read(LCD_STAT_REG);
> > > +               else
> > > +                       stat = lcdc_read(LCD_RAW_STAT_REG);
> > > +               mdelay(1);
> > > +       } while (!(stat & LCD_FRAME_DONE) && (i++ < loop_cnt));
> > 
> > Are you sure it should be do while? You call it from interrupt handler
> > too (sync lost handling). In that case mdelay() from interrupt
> > context..not a good idea I feel.
> > 
> 
> Ok. I will change it as below:
> 
> while (1) {
>                if (lcd_revision = LCD_VERSION_1)
>                        stat = lcdc_read(LCD_STAT_REG);
>                else
>                        stat = lcdc_read(LCD_RAW_STAT_REG);
>                if((stat & LCD_FRAME_DONE) || (i++ > loop_cnt))

s/i++/++i

Thanks,
Prakash

>                     break;
>                mdelay(1);
> }
> 
> > > +
> > > +       if (lcd_revision = LCD_VERSION_1)
> > > +               lcdc_write(stat, LCD_STAT_REG);
> > > +       else
> > > +               lcdc_write(stat, LCD_MASKED_STAT_REG);
> > > +
> > > +       if ((loop_cnt != 0) && (i >= loop_cnt)) {
> > > +               pr_err("LCD Controller timed out\n");
> > > +               return;
> > 
> > return may not be necessary?
> > 
> 
> Agree, I will remove it.
> 
> Thanks,
> Prakash
> 
> > > +       }
> > >  }
> 
> [...] 
> 
> 


^ permalink raw reply

* [PATCH] fbdev: Make pixel_to_pat() failure mode more friendly
From: Benjamin Herrenschmidt @ 2012-07-24  8:19 UTC (permalink / raw)
  To: linux-fbdev

If we accidentally pass an incorrect bpp value to pixel_to_pat(),
it panics. This is pretty useless, as we generally have the various
console locks held at that point, so nothing will be displayed,
and there is no reason to make this a fatal event.

Let's WARN instead.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

diff --git a/drivers/video/fb_draw.h b/drivers/video/fb_draw.h
index 04c01fa..624ee11 100644
--- a/drivers/video/fb_draw.h
+++ b/drivers/video/fb_draw.h
@@ -3,6 +3,7 @@
 
 #include <asm/types.h>
 #include <linux/fb.h>
+#include <linux/bug.h>
 
     /*
      *  Compose two values, using a bitmask as decision value
@@ -41,7 +42,8 @@ pixel_to_pat( u32 bpp, u32 pixel)
 	case 32:
 		return 0x0000000100000001ul*pixel;
 	default:
-		panic("pixel_to_pat(): unsupported pixelformat\n");
+		WARN(1, "pixel_to_pat(): unsupported pixelformat %d\n", bpp);
+		return 0;
     }
 }
 #else
@@ -66,7 +68,8 @@ pixel_to_pat( u32 bpp, u32 pixel)
 	case 32:
 		return 0x00000001ul*pixel;
 	default:
-		panic("pixel_to_pat(): unsupported pixelformat\n");
+		WARN(1, "pixel_to_pat(): unsupported pixelformat %d\n", bpp);
+		return 0;
     }
 }
 #endif



^ permalink raw reply related

* RE: [PATCH v2] da8xx-fb: allow frame to complete after disabling LCDC
From: Manjunathappa, Prakash @ 2012-07-24  7:17 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1343102984-6056-1-git-send-email-prakash.pm@ti.com>

Hi Sriram,

On Tue, Jul 24, 2012 at 10:11:55, Madhvapathi Sriram wrote:
> On Tue, Jul 24, 2012 at 9:39 AM, Manjunathappa, Prakash
> <prakash.pm@ti.com> wrote:
[...]
> >  /* Disable the Raster Engine of the LCD Controller */
> > -static inline void lcd_disable_raster(void)
> > +static inline void lcd_disable_raster(bool wait_for_frame_done)
> >  {
> >         u32 reg;
> > +       u32 loop_cnt = 0;
> > +       u32 stat;
> > +       u32 i = 0;
> > +
> > +       /* 50 milli seconds should be sufficient for a frame to complete
> > */
> > +       if (wait_for_frame_done)
> > +               loop_cnt = 50;
> >
> >         reg = lcdc_read(LCD_RASTER_CTRL_REG);
> >         if (reg & LCD_RASTER_ENABLE)
> >                 lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
> > +
> > +       /* Wait for the current frame to complete */
> > +       do {
> > +               if (lcd_revision = LCD_VERSION_1)
> > +                       stat = lcdc_read(LCD_STAT_REG);
> > +               else
> > +                       stat = lcdc_read(LCD_RAW_STAT_REG);
> > +               mdelay(1);
> > +       } while (!(stat & LCD_FRAME_DONE) && (i++ < loop_cnt));
> 
> Are you sure it should be do while? You call it from interrupt handler
> too (sync lost handling). In that case mdelay() from interrupt
> context..not a good idea I feel.
> 

Ok. I will change it as below:

while (1) {
               if (lcd_revision = LCD_VERSION_1)
                       stat = lcdc_read(LCD_STAT_REG);
               else
                       stat = lcdc_read(LCD_RAW_STAT_REG);
               if((stat & LCD_FRAME_DONE) || (i++ > loop_cnt))
                    break;
               mdelay(1);
}

> > +
> > +       if (lcd_revision = LCD_VERSION_1)
> > +               lcdc_write(stat, LCD_STAT_REG);
> > +       else
> > +               lcdc_write(stat, LCD_MASKED_STAT_REG);
> > +
> > +       if ((loop_cnt != 0) && (i >= loop_cnt)) {
> > +               pr_err("LCD Controller timed out\n");
> > +               return;
> 
> return may not be necessary?
> 

Agree, I will remove it.

Thanks,
Prakash

> > +       }
> >  }

[...] 


^ permalink raw reply

* Re: [PATCH v2] da8xx-fb: allow frame to complete after disabling LCDC
From: Madhvapathi Sriram @ 2012-07-24  4:53 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1343102984-6056-1-git-send-email-prakash.pm@ti.com>

On Tue, Jul 24, 2012 at 9:39 AM, Manjunathappa, Prakash
<prakash.pm@ti.com> wrote:
>
> Wait for active frame transfer to complete after disabling LCDC.
> At the same this wait is not be required when there are sync and
> underflow errors.
> More information on disable and reset sequence can be found in
> section 13.4.6 of AM335x TRM @www.ti.com/am335x.
>
> Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com>
> ---
> Patch applies on top of below patch under review:
> http://marc.info/?l=linux-fbdev&m\x134280060828708&w=2
> "video: da8xx-fb: do clock reset of revision 2 LCDC before enabling"
> Since v1:
> Changed the commit message, also added link to hardware specification.
>
>  drivers/video/da8xx-fb.c |   48
> ++++++++++++++++++++++++++++++++++++---------
>  1 files changed, 38 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
> index a908dfd..0fb4d7d 100644
> --- a/drivers/video/da8xx-fb.c
> +++ b/drivers/video/da8xx-fb.c
> @@ -31,6 +31,7 @@
>  #include <linux/cpufreq.h>
>  #include <linux/console.h>
>  #include <linux/slab.h>
> +#include <linux/delay.h>
>  #include <video/da8xx-fb.h>
>  #include <asm/div64.h>
>
> @@ -45,6 +46,7 @@
>  #define LCD_PL_LOAD_DONE               BIT(6)
>  #define LCD_FIFO_UNDERFLOW             BIT(5)
>  #define LCD_SYNC_LOST                  BIT(2)
> +#define LCD_FRAME_DONE                 BIT(0)
>
>  /* LCD DMA Control Register */
>  #define LCD_DMA_BURST_SIZE(x)          ((x) << 4)
> @@ -279,13 +281,39 @@ static inline void lcd_enable_raster(void)
>  }
>
>  /* Disable the Raster Engine of the LCD Controller */
> -static inline void lcd_disable_raster(void)
> +static inline void lcd_disable_raster(bool wait_for_frame_done)
>  {
>         u32 reg;
> +       u32 loop_cnt = 0;
> +       u32 stat;
> +       u32 i = 0;
> +
> +       /* 50 milli seconds should be sufficient for a frame to complete
> */
> +       if (wait_for_frame_done)
> +               loop_cnt = 50;
>
>         reg = lcdc_read(LCD_RASTER_CTRL_REG);
>         if (reg & LCD_RASTER_ENABLE)
>                 lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
> +
> +       /* Wait for the current frame to complete */
> +       do {
> +               if (lcd_revision = LCD_VERSION_1)
> +                       stat = lcdc_read(LCD_STAT_REG);
> +               else
> +                       stat = lcdc_read(LCD_RAW_STAT_REG);
> +               mdelay(1);
> +       } while (!(stat & LCD_FRAME_DONE) && (i++ < loop_cnt));

Are you sure it should be do while? You call it from interrupt handler
too (sync lost handling). In that case mdelay() from interrupt
context..not a good idea I feel.

> +
> +       if (lcd_revision = LCD_VERSION_1)
> +               lcdc_write(stat, LCD_STAT_REG);
> +       else
> +               lcdc_write(stat, LCD_MASKED_STAT_REG);
> +
> +       if ((loop_cnt != 0) && (i >= loop_cnt)) {
> +               pr_err("LCD Controller timed out\n");
> +               return;

return may not be necessary?

> +       }
>  }
>
>  static void lcd_blit(int load_mode, struct da8xx_fb_par *par)
> @@ -626,7 +654,7 @@ static int fb_setcolreg(unsigned regno, unsigned red,
> unsigned green,
>  static void lcd_reset(struct da8xx_fb_par *par)
>  {
>         /* Disable the Raster if previously Enabled */
> -       lcd_disable_raster();
> +       lcd_disable_raster(false);
>
>         /* DMA has to be disabled */
>         lcdc_write(0, LCD_DMA_CTRL_REG);
> @@ -724,7 +752,7 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq,
> void *arg)
>
>         if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
>                 pr_err("LCDC sync lost or underflow error occurred\n");
> -               lcd_disable_raster();
> +               lcd_disable_raster(false);
>                 lcdc_write(stat, LCD_MASKED_STAT_REG);
>                 lcd_enable_raster();
>         } else if (stat & LCD_PL_LOAD_DONE) {
> @@ -734,7 +762,7 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq,
> void *arg)
>                  * interrupt via the following write to the status
> register. If
>                  * this is done after then one gets multiple PL done
> interrupts.
>                  */
> -               lcd_disable_raster();
> +               lcd_disable_raster(false);
>
>                 lcdc_write(stat, LCD_MASKED_STAT_REG);
>
> @@ -780,7 +808,7 @@ static irqreturn_t lcdc_irq_handler_rev01(int irq,
> void *arg)
>
>         if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
>                 pr_err("LCDC sync lost or underflow error occurred\n");
> -               lcd_disable_raster();
> +               lcd_disable_raster(false);
>                 lcdc_write(stat, LCD_STAT_REG);
>                 lcd_enable_raster();
>         } else if (stat & LCD_PL_LOAD_DONE) {
> @@ -790,7 +818,7 @@ static irqreturn_t lcdc_irq_handler_rev01(int irq,
> void *arg)
>                  * interrupt via the following write to the status
> register. If
>                  * this is done after then one gets multiple PL done
> interrupts.
>                  */
> -               lcd_disable_raster();
> +               lcd_disable_raster(false);
>
>                 lcdc_write(stat, LCD_STAT_REG);
>
> @@ -887,7 +915,7 @@ static int lcd_da8xx_cpufreq_transition(struct
> notifier_block *nb,
>         if (val = CPUFREQ_POSTCHANGE) {
>                 if (par->lcd_fck_rate != clk_get_rate(par->lcdc_clk)) {
>                         par->lcd_fck_rate = clk_get_rate(par->lcdc_clk);
> -                       lcd_disable_raster();
> +                       lcd_disable_raster(true);
>                         lcd_calc_clk_divider(par);
>                         lcd_enable_raster();
>                 }
> @@ -924,7 +952,7 @@ static int __devexit fb_remove(struct platform_device
> *dev)
>                 if (par->panel_power_ctrl)
>                         par->panel_power_ctrl(0);
>
> -               lcd_disable_raster();
> +               lcd_disable_raster(true);
>                 lcdc_write(0, LCD_RASTER_CTRL_REG);
>
>                 /* disable DMA  */
> @@ -1037,7 +1065,7 @@ static int cfb_blank(int blank, struct fb_info
> *info)
>                 if (par->panel_power_ctrl)
>                         par->panel_power_ctrl(0);
>
> -               lcd_disable_raster();
> +               lcd_disable_raster(true);
>                 break;
>         default:
>                 ret = -EINVAL;
> @@ -1377,7 +1405,7 @@ static int fb_suspend(struct platform_device *dev,
> pm_message_t state)
>                 par->panel_power_ctrl(0);
>
>         fb_set_suspend(info, 1);
> -       lcd_disable_raster();
> +       lcd_disable_raster(true);
>         clk_disable(par->lcdc_clk);
>         console_unlock();
>
> --
> 1.7.1
>
> _______________________________________________
> Davinci-linux-open-source mailing list
> Davinci-linux-open-source@linux.davincidsp.com
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

^ permalink raw reply

* [PATCH] da8xx-fb: do not turn ON LCD backlight unless LCDC is enabled
From: Manjunathappa, Prakash @ 2012-07-24  4:27 UTC (permalink / raw)
  To: linux-fbdev

LCD blink is observed during suspend/resume and blank/unblank
operations as backlight is ON during LCDC disable and enable.
So make sure to turn OFF backlight before disabling and turn
it ON after enabling.

Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com>
---
 drivers/video/da8xx-fb.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index 0fb4d7d..1a569ae 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -1056,10 +1056,10 @@ static int cfb_blank(int blank, struct fb_info *info)
 	par->blank = blank;
 	switch (blank) {
 	case FB_BLANK_UNBLANK:
+		lcd_enable_raster();
+
 		if (par->panel_power_ctrl)
 			par->panel_power_ctrl(1);
-
-		lcd_enable_raster();
 		break;
 	case FB_BLANK_POWERDOWN:
 		if (par->panel_power_ctrl)
@@ -1417,11 +1417,12 @@ static int fb_resume(struct platform_device *dev)
 	struct da8xx_fb_par *par = info->par;
 
 	console_lock();
+	clk_enable(par->lcdc_clk);
+	lcd_enable_raster();
+
 	if (par->panel_power_ctrl)
 		par->panel_power_ctrl(1);
 
-	clk_enable(par->lcdc_clk);
-	lcd_enable_raster();
 	fb_set_suspend(info, 0);
 	console_unlock();
 
-- 
1.7.1


^ permalink raw reply related

* [PATCH v2] da8xx-fb: allow frame to complete after disabling LCDC
From: Manjunathappa, Prakash @ 2012-07-24  4:21 UTC (permalink / raw)
  To: linux-fbdev

Wait for active frame transfer to complete after disabling LCDC.
At the same this wait is not be required when there are sync and
underflow errors.
More information on disable and reset sequence can be found in
section 13.4.6 of AM335x TRM @www.ti.com/am335x.

Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com>
---
Patch applies on top of below patch under review:
http://marc.info/?l=linux-fbdev&m\x134280060828708&w=2
"video: da8xx-fb: do clock reset of revision 2 LCDC before enabling"
Since v1:
Changed the commit message, also added link to hardware specification.

 drivers/video/da8xx-fb.c |   48 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index a908dfd..0fb4d7d 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -31,6 +31,7 @@
 #include <linux/cpufreq.h>
 #include <linux/console.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 #include <video/da8xx-fb.h>
 #include <asm/div64.h>
 
@@ -45,6 +46,7 @@
 #define LCD_PL_LOAD_DONE		BIT(6)
 #define LCD_FIFO_UNDERFLOW		BIT(5)
 #define LCD_SYNC_LOST			BIT(2)
+#define LCD_FRAME_DONE			BIT(0)
 
 /* LCD DMA Control Register */
 #define LCD_DMA_BURST_SIZE(x)		((x) << 4)
@@ -279,13 +281,39 @@ static inline void lcd_enable_raster(void)
 }
 
 /* Disable the Raster Engine of the LCD Controller */
-static inline void lcd_disable_raster(void)
+static inline void lcd_disable_raster(bool wait_for_frame_done)
 {
 	u32 reg;
+	u32 loop_cnt = 0;
+	u32 stat;
+	u32 i = 0;
+
+	/* 50 milli seconds should be sufficient for a frame to complete */
+	if (wait_for_frame_done)
+		loop_cnt = 50;
 
 	reg = lcdc_read(LCD_RASTER_CTRL_REG);
 	if (reg & LCD_RASTER_ENABLE)
 		lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+
+	/* Wait for the current frame to complete */
+	do {
+		if (lcd_revision = LCD_VERSION_1)
+			stat = lcdc_read(LCD_STAT_REG);
+		else
+			stat = lcdc_read(LCD_RAW_STAT_REG);
+		mdelay(1);
+	} while (!(stat & LCD_FRAME_DONE) && (i++ < loop_cnt));
+
+	if (lcd_revision = LCD_VERSION_1)
+		lcdc_write(stat, LCD_STAT_REG);
+	else
+		lcdc_write(stat, LCD_MASKED_STAT_REG);
+
+	if ((loop_cnt != 0) && (i >= loop_cnt)) {
+		pr_err("LCD Controller timed out\n");
+		return;
+	}
 }
 
 static void lcd_blit(int load_mode, struct da8xx_fb_par *par)
@@ -626,7 +654,7 @@ static int fb_setcolreg(unsigned regno, unsigned red, unsigned green,
 static void lcd_reset(struct da8xx_fb_par *par)
 {
 	/* Disable the Raster if previously Enabled */
-	lcd_disable_raster();
+	lcd_disable_raster(false);
 
 	/* DMA has to be disabled */
 	lcdc_write(0, LCD_DMA_CTRL_REG);
@@ -724,7 +752,7 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
 
 	if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
 		pr_err("LCDC sync lost or underflow error occurred\n");
-		lcd_disable_raster();
+		lcd_disable_raster(false);
 		lcdc_write(stat, LCD_MASKED_STAT_REG);
 		lcd_enable_raster();
 	} else if (stat & LCD_PL_LOAD_DONE) {
@@ -734,7 +762,7 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
 		 * interrupt via the following write to the status register. If
 		 * this is done after then one gets multiple PL done interrupts.
 		 */
-		lcd_disable_raster();
+		lcd_disable_raster(false);
 
 		lcdc_write(stat, LCD_MASKED_STAT_REG);
 
@@ -780,7 +808,7 @@ static irqreturn_t lcdc_irq_handler_rev01(int irq, void *arg)
 
 	if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
 		pr_err("LCDC sync lost or underflow error occurred\n");
-		lcd_disable_raster();
+		lcd_disable_raster(false);
 		lcdc_write(stat, LCD_STAT_REG);
 		lcd_enable_raster();
 	} else if (stat & LCD_PL_LOAD_DONE) {
@@ -790,7 +818,7 @@ static irqreturn_t lcdc_irq_handler_rev01(int irq, void *arg)
 		 * interrupt via the following write to the status register. If
 		 * this is done after then one gets multiple PL done interrupts.
 		 */
-		lcd_disable_raster();
+		lcd_disable_raster(false);
 
 		lcdc_write(stat, LCD_STAT_REG);
 
@@ -887,7 +915,7 @@ static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb,
 	if (val = CPUFREQ_POSTCHANGE) {
 		if (par->lcd_fck_rate != clk_get_rate(par->lcdc_clk)) {
 			par->lcd_fck_rate = clk_get_rate(par->lcdc_clk);
-			lcd_disable_raster();
+			lcd_disable_raster(true);
 			lcd_calc_clk_divider(par);
 			lcd_enable_raster();
 		}
@@ -924,7 +952,7 @@ static int __devexit fb_remove(struct platform_device *dev)
 		if (par->panel_power_ctrl)
 			par->panel_power_ctrl(0);
 
-		lcd_disable_raster();
+		lcd_disable_raster(true);
 		lcdc_write(0, LCD_RASTER_CTRL_REG);
 
 		/* disable DMA  */
@@ -1037,7 +1065,7 @@ static int cfb_blank(int blank, struct fb_info *info)
 		if (par->panel_power_ctrl)
 			par->panel_power_ctrl(0);
 
-		lcd_disable_raster();
+		lcd_disable_raster(true);
 		break;
 	default:
 		ret = -EINVAL;
@@ -1377,7 +1405,7 @@ static int fb_suspend(struct platform_device *dev, pm_message_t state)
 		par->panel_power_ctrl(0);
 
 	fb_set_suspend(info, 1);
-	lcd_disable_raster();
+	lcd_disable_raster(true);
 	clk_disable(par->lcdc_clk);
 	console_unlock();
 
-- 
1.7.1


^ permalink raw reply related

* [PATCH v2] da8xx-fb: enable sync lost interrupt
From: Manjunathappa, Prakash @ 2012-07-24  3:55 UTC (permalink / raw)
  To: linux-fbdev

Patch enables sync lost interrupt and interrupt handler already
takes care to handle it.

Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com>
---
Since v1:
Minor nit, replaced spaces with tabs.

 drivers/video/da8xx-fb.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index 47118c7..8163832 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -54,6 +54,7 @@
 #define LCD_DMA_BURST_8			0x3
 #define LCD_DMA_BURST_16		0x4
 #define LCD_V1_END_OF_FRAME_INT_ENA	BIT(2)
+#define LCD_V1_SYNC_LOST_ENA		BIT(5)
 #define LCD_V2_END_OF_FRAME0_INT_ENA	BIT(8)
 #define LCD_V2_END_OF_FRAME1_INT_ENA	BIT(9)
 #define LCD_DUAL_FRAME_BUFFER_ENABLE	BIT(0)
@@ -441,10 +442,10 @@ static int lcd_cfg_display(const struct lcd_ctrl_config *cfg)
 
 	/* enable additional interrupts here */
 	if (lcd_revision = LCD_VERSION_1) {
-		reg |= LCD_V1_UNDERFLOW_INT_ENA;
+		reg |= LCD_V1_UNDERFLOW_INT_ENA | LCD_V1_SYNC_LOST_ENA;
 	} else {
 		reg_int = lcdc_read(LCD_INT_ENABLE_SET_REG) |
-			LCD_V2_UNDERFLOW_INT_ENA;
+			LCD_V2_UNDERFLOW_INT_ENA | LCD_SYNC_LOST;
 		lcdc_write(reg_int, LCD_INT_ENABLE_SET_REG);
 	}
 
@@ -718,6 +719,7 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
 	u32 reg_int;
 
 	if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
+		pr_err("LCDC sync lost or underflow error occurred\n");
 		lcd_disable_raster();
 		lcdc_write(stat, LCD_MASKED_STAT_REG);
 		lcd_enable_raster();
@@ -773,6 +775,7 @@ static irqreturn_t lcdc_irq_handler_rev01(int irq, void *arg)
 	u32 reg_ras;
 
 	if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
+		pr_err("LCDC sync lost or underflow error occurred\n");
 		lcd_disable_raster();
 		lcdc_write(stat, LCD_STAT_REG);
 		lcd_enable_raster();
-- 
1.7.1


^ permalink raw reply related


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