linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sh: sh7760fb: Fix color pallette setting
@ 2008-11-21  5:34 ` Nobuhiro Iwamatsu
  2008-11-21  7:46   ` Paul Mundt
  2008-11-21  8:45   ` fb_setcmap vs fb_setcolreg (was: Re: [PATCH] sh: sh7760fb: Fix color pallette setting) Geert Uytterhoeven
  0 siblings, 2 replies; 4+ messages in thread
From: Nobuhiro Iwamatsu @ 2008-11-21  5:34 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Linux-sh

The setting of the color palette was wrong, fixed it.
And removed fb_setcmap, and added fb_setcolreg function.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
---
 drivers/video/sh7760fb.c |   94 +++++++++++----------------------------------
 1 files changed, 23 insertions(+), 71 deletions(-)

diff --git a/drivers/video/sh7760fb.c b/drivers/video/sh7760fb.c
index 8d0212d..653bdfe 100644
--- a/drivers/video/sh7760fb.c
+++ b/drivers/video/sh7760fb.c
@@ -13,6 +13,8 @@
  *
  * Thanks to Siegfried Schaefer <s.schaefer at schaefer-edv.de>
  *     for his original source and testing!
+ *
+ * sh7760_setcolreg get from drivers/video/sh_mobile_lcdcfb.c
  */

 #include <linux/completion.h>
@@ -53,29 +55,6 @@ static irqreturn_t sh7760fb_irq(int irq, void *data)
 	return IRQ_HANDLED;
 }

-static void sh7760fb_wait_vsync(struct fb_info *info)
-{
-	struct sh7760fb_par *par = info->par;
-
-	if (par->pd->novsync)
-		return;
-
-	iowrite16(ioread16(par->base + LDINTR) & ~VINT_CHECK,
-		  par->base + LDINTR);
-
-	if (par->irq < 0) {
-		/* poll for vert. retrace: status bit is sticky */
-		while (!(ioread16(par->base + LDINTR) & VINT_CHECK))
-			cpu_relax();
-	} else {
-		/* a "wait_for_irq_event(par->irq)" would be extremely nice */
-		init_completion(&par->vsync);
-		enable_irq(par->irq);
-		wait_for_completion(&par->vsync);
-		disable_irq_nosync(par->irq);
-	}
-}
-
 /* wait_for_lps - wait until power supply has reached a certain state. */
 static int wait_for_lps(struct sh7760fb_par *par, int val)
 {
@@ -117,55 +96,28 @@ static int sh7760fb_blank(int blank, struct fb_info *info)
 	return wait_for_lps(par, lps);
 }

-/* set color registers */
-static int sh7760fb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
+static int sh7760_setcolreg (u_int regno,
+	u_int red, u_int green, u_int blue,
+	u_int transp, struct fb_info *info)
 {
-	struct sh7760fb_par *par = info->par;
-	u32 s = cmap->start;
-	u32 l = cmap->len;
-	u16 *r = cmap->red;
-	u16 *g = cmap->green;
-	u16 *b = cmap->blue;
-	u32 col, tmo;
-	int ret;
+	u32 *palette = info->pseudo_palette;

-	ret = 0;
+	if (regno >= 16)
+		return -EINVAL;

-	sh7760fb_wait_vsync(info);
+	/* only FB_VISUAL_TRUECOLOR supported */

-	/* request palette access */
-	iowrite16(LDPALCR_PALEN, par->base + LDPALCR);
+	red >>= 16 - info->var.red.length;
+	green >>= 16 - info->var.green.length;
+	blue >>= 16 - info->var.blue.length;
+	transp >>= 16 - info->var.transp.length;

-	/* poll for access grant */
-	tmo = 100;
-	while (!(ioread16(par->base + LDPALCR) & LDPALCR_PALS) && (--tmo))
-		cpu_relax();
+	palette[regno] = (red << info->var.red.offset) |
+		(green << info->var.green.offset) |
+		(blue << info->var.blue.offset) |
+		(transp << info->var.transp.offset);

-	if (!tmo) {
-		ret = 1;
-		dev_dbg(info->dev, "no palette access!\n");
-		goto out;
-	}
-
-	while (l && (s < 256)) {
-		col = ((*r) & 0xff) << 16;
-		col |= ((*g) & 0xff) << 8;
-		col |= ((*b) & 0xff);
-		col &= SH7760FB_PALETTE_MASK;
-		iowrite32(col, par->base + LDPR(s));
-
-		if (s < 16)
-			((u32 *) (info->pseudo_palette))[s] = s;
-
-		s++;
-		l--;
-		r++;
-		g++;
-		b++;
-	}
-out:
-	iowrite16(0, par->base + LDPALCR);
-	return ret;
+	return 0;
 }

 static void encode_fix(struct fb_fix_screeninfo *fix, struct fb_info *info,
@@ -406,7 +358,7 @@ static struct fb_ops sh7760fb_ops = {
 	.owner = THIS_MODULE,
 	.fb_blank = sh7760fb_blank,
 	.fb_check_var = sh7760fb_check_var,
-	.fb_setcmap = sh7760fb_setcmap,
+	.fb_setcolreg = sh7760_setcolreg,
 	.fb_set_par = sh7760fb_set_par,
 	.fb_fillrect = cfb_fillrect,
 	.fb_copyarea = cfb_copyarea,
-- 
1.5.6.5


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

* [PATCH] sh: sh7760fb: Add support SH7720/SH7721 of Renesas
@ 2008-11-21  5:35 Nobuhiro Iwamatsu
  2008-11-21  5:34 ` [PATCH] sh: sh7760fb: Fix color pallette setting Nobuhiro Iwamatsu
  0 siblings, 1 reply; 4+ messages in thread
From: Nobuhiro Iwamatsu @ 2008-11-21  5:35 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Linux-sh

SH7720 and 7721 has IP of Frame Buffer same as SH7760.
This driver can support these.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
---
 drivers/video/Kconfig |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 3f3ce13..f416d3d 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2021,17 +2021,19 @@ config FB_COBALT
 	depends on FB && MIPS_COBALT

 config FB_SH7760
-       bool "SH7760/SH7763 LCDC support"
-       depends on FB && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763)
-       select FB_CFB_FILLRECT
-       select FB_CFB_COPYAREA
-       select FB_CFB_IMAGEBLIT
-       help
-         Support for the SH7760/SH7763 integrated (D)STN/TFT LCD Controller.
-         Supports display resolutions up to 1024x1024 pixel, grayscale and
-         color operation, with depths ranging from 1 bpp to 8 bpp monochrome
-         and 8, 15 or 16 bpp color; 90 degrees clockwise display rotation for
-         panels <= 320 pixel horizontal resolution.
+	bool "SH7760/SH7763/SH7720/SH7721 LCDC support"
+	depends on FB && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763 \
+		|| CPU_SUBTYPE_SH7720 || CPU_SUBTYPE_SH7721)
+	select FB_CFB_FILLRECT
+	select FB_CFB_COPYAREA
+	select FB_CFB_IMAGEBLIT
+	---help---
+	  Support for the SH7760/SH7763/SH7720/SH7721 integrated
+	  (D)STN/TFT LCD Controller.
+	  Supports display resolutions up to 1024x1024 pixel, grayscale and
+	  color operation, with depths ranging from 1 bpp to 8 bpp monochrome
+	  and 8, 15 or 16 bpp color; 90 degrees clockwise display rotation for
+	  panels <= 320 pixel horizontal resolution.

 config FB_VIRTUAL
 	tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)"
-- 
1.5.6.5


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

* Re: [PATCH] sh: sh7760fb: Fix color pallette setting
  2008-11-21  5:34 ` [PATCH] sh: sh7760fb: Fix color pallette setting Nobuhiro Iwamatsu
@ 2008-11-21  7:46   ` Paul Mundt
  2008-11-21  8:45   ` fb_setcmap vs fb_setcolreg (was: Re: [PATCH] sh: sh7760fb: Fix color pallette setting) Geert Uytterhoeven
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Mundt @ 2008-11-21  7:46 UTC (permalink / raw)
  To: Nobuhiro Iwamatsu; +Cc: linux-fbdev-devel, Linux-sh

On Fri, Nov 21, 2008 at 02:34:25PM +0900, Nobuhiro Iwamatsu wrote:
> The setting of the color palette was wrong, fixed it.
> And removed fb_setcmap, and added fb_setcolreg function.
> 
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>

On Fri, Nov 21, 2008 at 02:35:29PM +0900, Nobuhiro Iwamatsu wrote:
> SH7720 and 7721 has IP of Frame Buffer same as SH7760.
> This driver can support these.
> 
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>

Applied, thanks.

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

* fb_setcmap vs fb_setcolreg (was: Re: [PATCH] sh: sh7760fb: Fix color pallette setting)
  2008-11-21  5:34 ` [PATCH] sh: sh7760fb: Fix color pallette setting Nobuhiro Iwamatsu
  2008-11-21  7:46   ` Paul Mundt
@ 2008-11-21  8:45   ` Geert Uytterhoeven
  1 sibling, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2008-11-21  8:45 UTC (permalink / raw)
  To: Linux Frame Buffer Device Development

On Fri, 21 Nov 2008, Nobuhiro Iwamatsu wrote:
> The setting of the color palette was wrong, fixed it.
> And removed fb_setcmap, and added fb_setcolreg function.

BTW, several drivers (radeonfb, omapfb, uvesafb, viafb) implement both
.fb_setcmap and .fb_setcolreg, which is a bit silly, as drivers/video/fbcmap.c
won't ever call .fb_setcolreg if .fb_setcmap is present.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

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

end of thread, other threads:[~2008-11-21  8:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21  5:35 [PATCH] sh: sh7760fb: Add support SH7720/SH7721 of Renesas Nobuhiro Iwamatsu
2008-11-21  5:34 ` [PATCH] sh: sh7760fb: Fix color pallette setting Nobuhiro Iwamatsu
2008-11-21  7:46   ` Paul Mundt
2008-11-21  8:45   ` fb_setcmap vs fb_setcolreg (was: Re: [PATCH] sh: sh7760fb: Fix color pallette setting) Geert Uytterhoeven

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).