aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/sh7760fb.c
diff options
context:
space:
mode:
authorNobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>2008-11-21 00:34:25 -0500
committerPaul Mundt <lethal@linux-sh.org>2008-12-22 04:42:54 -0500
commit679dc3c92ca7894c3df70ee3333ff9878e7d90b9 (patch)
tree5537cbc3c53cbfb40f0975bdebec6b9f919b9995 /drivers/video/sh7760fb.c
parentf617682e9cabd5616dc2fe53c67762790eeb14d3 (diff)
sh: sh7760fb: Fix color pallette setting
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> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/video/sh7760fb.c')
-rw-r--r--drivers/video/sh7760fb.c86
1 files changed, 19 insertions, 67 deletions
diff --git a/drivers/video/sh7760fb.c b/drivers/video/sh7760fb.c
index 8d0212da4514..653bdfee3057 100644
--- a/drivers/video/sh7760fb.c
+++ b/drivers/video/sh7760fb.c
@@ -13,6 +13,8 @@
13 * 13 *
14 * Thanks to Siegfried Schaefer <s.schaefer at schaefer-edv.de> 14 * Thanks to Siegfried Schaefer <s.schaefer at schaefer-edv.de>
15 * for his original source and testing! 15 * for his original source and testing!
16 *
17 * sh7760_setcolreg get from drivers/video/sh_mobile_lcdcfb.c
16 */ 18 */
17 19
18#include <linux/completion.h> 20#include <linux/completion.h>
@@ -53,29 +55,6 @@ static irqreturn_t sh7760fb_irq(int irq, void *data)
53 return IRQ_HANDLED; 55 return IRQ_HANDLED;
54} 56}
55 57
56static void sh7760fb_wait_vsync(struct fb_info *info)
57{
58 struct sh7760fb_par *par = info->par;
59
60 if (par->pd->novsync)
61 return;
62
63 iowrite16(ioread16(par->base + LDINTR) & ~VINT_CHECK,
64 par->base + LDINTR);
65
66 if (par->irq < 0) {
67 /* poll for vert. retrace: status bit is sticky */
68 while (!(ioread16(par->base + LDINTR) & VINT_CHECK))
69 cpu_relax();
70 } else {
71 /* a "wait_for_irq_event(par->irq)" would be extremely nice */
72 init_completion(&par->vsync);
73 enable_irq(par->irq);
74 wait_for_completion(&par->vsync);
75 disable_irq_nosync(par->irq);
76 }
77}
78
79/* wait_for_lps - wait until power supply has reached a certain state. */ 58/* wait_for_lps - wait until power supply has reached a certain state. */
80static int wait_for_lps(struct sh7760fb_par *par, int val) 59static int wait_for_lps(struct sh7760fb_par *par, int val)
81{ 60{
@@ -117,55 +96,28 @@ static int sh7760fb_blank(int blank, struct fb_info *info)
117 return wait_for_lps(par, lps); 96 return wait_for_lps(par, lps);
118} 97}
119 98
120/* set color registers */ 99static int sh7760_setcolreg (u_int regno,
121static int sh7760fb_setcmap(struct fb_cmap *cmap, struct fb_info *info) 100 u_int red, u_int green, u_int blue,
101 u_int transp, struct fb_info *info)
122{ 102{
123 struct sh7760fb_par *par = info->par; 103 u32 *palette = info->pseudo_palette;
124 u32 s = cmap->start;
125 u32 l = cmap->len;
126 u16 *r = cmap->red;
127 u16 *g = cmap->green;
128 u16 *b = cmap->blue;
129 u32 col, tmo;
130 int ret;
131 104
132 ret = 0; 105 if (regno >= 16)
106 return -EINVAL;
133 107
134 sh7760fb_wait_vsync(info); 108 /* only FB_VISUAL_TRUECOLOR supported */
135 109
136 /* request palette access */ 110 red >>= 16 - info->var.red.length;
137 iowrite16(LDPALCR_PALEN, par->base + LDPALCR); 111 green >>= 16 - info->var.green.length;
112 blue >>= 16 - info->var.blue.length;
113 transp >>= 16 - info->var.transp.length;
138 114
139 /* poll for access grant */ 115 palette[regno] = (red << info->var.red.offset) |
140 tmo = 100; 116 (green << info->var.green.offset) |
141 while (!(ioread16(par->base + LDPALCR) & LDPALCR_PALS) && (--tmo)) 117 (blue << info->var.blue.offset) |
142 cpu_relax(); 118 (transp << info->var.transp.offset);
143 119
144 if (!tmo) { 120 return 0;
145 ret = 1;
146 dev_dbg(info->dev, "no palette access!\n");
147 goto out;
148 }
149
150 while (l && (s < 256)) {
151 col = ((*r) & 0xff) << 16;
152 col |= ((*g) & 0xff) << 8;
153 col |= ((*b) & 0xff);
154 col &= SH7760FB_PALETTE_MASK;
155 iowrite32(col, par->base + LDPR(s));
156
157 if (s < 16)
158 ((u32 *) (info->pseudo_palette))[s] = s;
159
160 s++;
161 l--;
162 r++;
163 g++;
164 b++;
165 }
166out:
167 iowrite16(0, par->base + LDPALCR);
168 return ret;
169} 121}
170 122
171static void encode_fix(struct fb_fix_screeninfo *fix, struct fb_info *info, 123static void encode_fix(struct fb_fix_screeninfo *fix, struct fb_info *info,
@@ -406,7 +358,7 @@ static struct fb_ops sh7760fb_ops = {
406 .owner = THIS_MODULE, 358 .owner = THIS_MODULE,
407 .fb_blank = sh7760fb_blank, 359 .fb_blank = sh7760fb_blank,
408 .fb_check_var = sh7760fb_check_var, 360 .fb_check_var = sh7760fb_check_var,
409 .fb_setcmap = sh7760fb_setcmap, 361 .fb_setcolreg = sh7760_setcolreg,
410 .fb_set_par = sh7760fb_set_par, 362 .fb_set_par = sh7760fb_set_par,
411 .fb_fillrect = cfb_fillrect, 363 .fb_fillrect = cfb_fillrect,
412 .fb_copyarea = cfb_copyarea, 364 .fb_copyarea = cfb_copyarea,