aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-03-13 00:26:33 -0400
committerPaul Mackerras <paulus@samba.org>2008-03-13 00:26:33 -0400
commitbed04a4413376265746053be2a9cfbfc80c98ec9 (patch)
tree8f582294a655f70496cd08aedeb86de31dbad140 /drivers/video
parente37c772e36a7943b2e0bd8f48312e78474c0df15 (diff)
parentc463be3520065ef8c05e3cbdf946c69604e91ceb (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/Kconfig13
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/bf54x-lq043fb.c6
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c685
-rw-r--r--drivers/video/hitfb.c4
-rw-r--r--drivers/video/mbx/mbxfb.c2
-rw-r--r--drivers/video/pvr2fb.c12
-rw-r--r--drivers/video/sm501fb.c20
-rw-r--r--drivers/video/stifb.c22
-rw-r--r--drivers/video/tridentfb.c55
10 files changed, 774 insertions, 46 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 758435f8a6f8..e0b0580705e4 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -553,6 +553,19 @@ config FB_BF54X_LQ043
553 help 553 help
554 This is the framebuffer device driver for a SHARP LQ043T1DG01 TFT LCD 554 This is the framebuffer device driver for a SHARP LQ043T1DG01 TFT LCD
555 555
556config FB_BFIN_T350MCQB
557 tristate "Varitronix COG-T350MCQB TFT LCD display (BF527 EZKIT)"
558 depends on FB && BLACKFIN
559 select BFIN_GPTIMERS
560 select FB_CFB_FILLRECT
561 select FB_CFB_COPYAREA
562 select FB_CFB_IMAGEBLIT
563 help
564 This is the framebuffer device driver for a Varitronix VL-PS-COG-T350MCQB-01 display TFT LCD
565 This display is a QVGA 320x240 24-bit RGB display interfaced by an 8-bit wide PPI
566 It uses PPI[0..7] PPI_FS1, PPI_FS2 and PPI_CLK.
567
568
556config FB_STI 569config FB_STI
557 tristate "HP STI frame buffer device support" 570 tristate "HP STI frame buffer device support"
558 depends on FB && PARISC 571 depends on FB && PARISC
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 83e02b3429b6..03371c789039 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -122,6 +122,7 @@ obj-$(CONFIG_FB_EFI) += efifb.o
122obj-$(CONFIG_FB_VGA16) += vga16fb.o 122obj-$(CONFIG_FB_VGA16) += vga16fb.o
123obj-$(CONFIG_FB_OF) += offb.o 123obj-$(CONFIG_FB_OF) += offb.o
124obj-$(CONFIG_FB_BF54X_LQ043) += bf54x-lq043fb.o 124obj-$(CONFIG_FB_BF54X_LQ043) += bf54x-lq043fb.o
125obj-$(CONFIG_FB_BFIN_T350MCQB) += bfin-t350mcqb-fb.o
125 126
126# the test framebuffer is last 127# the test framebuffer is last
127obj-$(CONFIG_FB_VIRTUAL) += vfb.o 128obj-$(CONFIG_FB_VIRTUAL) += vfb.o
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index 0ce791e6f79c..986a550c0439 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * 9 *
10 * Modified: 10 * Modified:
11 * Copyright 2004-2007 Analog Devices Inc. 11 * Copyright 2007-2008 Analog Devices Inc.
12 * 12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 * 14 *
@@ -241,7 +241,7 @@ static int request_ports(struct bfin_bf54xfb_info *fbi)
241 u16 eppi_req_18[] = EPPI0_18; 241 u16 eppi_req_18[] = EPPI0_18;
242 u16 disp = fbi->mach_info->disp; 242 u16 disp = fbi->mach_info->disp;
243 243
244 if (gpio_request(disp, NULL)) { 244 if (gpio_request(disp, DRIVER_NAME)) {
245 printk(KERN_ERR "Requesting GPIO %d faild\n", disp); 245 printk(KERN_ERR "Requesting GPIO %d faild\n", disp);
246 return -EFAULT; 246 return -EFAULT;
247 } 247 }
@@ -672,7 +672,7 @@ static int __init bfin_bf54x_probe(struct platform_device *pdev)
672 &bfin_lq043fb_bl_ops); 672 &bfin_lq043fb_bl_ops);
673 bl_dev->props.max_brightness = 255; 673 bl_dev->props.max_brightness = 255;
674 674
675 lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops); 675 lcd_dev = lcd_device_register(DRIVER_NAME, &pdev->dev, NULL, &bfin_lcd_ops);
676 lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n"); 676 lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
677#endif 677#endif
678 678
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
new file mode 100644
index 000000000000..a2bb2de9e020
--- /dev/null
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -0,0 +1,685 @@
1/*
2 * File: drivers/video/bfin-t350mcqb-fb.c
3 * Based on:
4 * Author: Michael Hennerich <hennerich@blackfin.uclinux.org>
5 *
6 * Created:
7 * Description: Blackfin LCD Framebufer driver
8 *
9 *
10 * Modified:
11 * Copyright 2004-2007 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/module.h>
32#include <linux/kernel.h>
33#include <linux/errno.h>
34#include <linux/string.h>
35#include <linux/fb.h>
36#include <linux/init.h>
37#include <linux/types.h>
38#include <linux/interrupt.h>
39#include <linux/device.h>
40#include <linux/backlight.h>
41#include <linux/lcd.h>
42#include <linux/dma-mapping.h>
43#include <linux/platform_device.h>
44
45#include <asm/blackfin.h>
46#include <asm/irq.h>
47#include <asm/dma-mapping.h>
48#include <asm/dma.h>
49#include <asm/portmux.h>
50#include <asm/gptimers.h>
51
52#define NO_BL_SUPPORT
53
54#define LCD_X_RES 320 /* Horizontal Resolution */
55#define LCD_Y_RES 240 /* Vertical Resolution */
56#define LCD_BPP 24 /* Bit Per Pixel */
57
58#define DMA_BUS_SIZE 16
59#define LCD_CLK (12*1000*1000) /* 12MHz */
60
61#define CLOCKS_PER_PIX 3
62
63 /*
64 * HS and VS timing parameters (all in number of PPI clk ticks)
65 */
66
67#define U_LINE 1 /* Blanking Lines */
68
69#define H_ACTPIX (LCD_X_RES * CLOCKS_PER_PIX) /* active horizontal pixel */
70#define H_PERIOD (408 * CLOCKS_PER_PIX) /* HS period */
71#define H_PULSE 90 /* HS pulse width */
72#define H_START 204 /* first valid pixel */
73
74#define V_LINES (LCD_Y_RES + U_LINE) /* total vertical lines */
75#define V_PULSE (3 * H_PERIOD) /* VS pulse width (1-5 H_PERIODs) */
76#define V_PERIOD (H_PERIOD * V_LINES) /* VS period */
77
78#define ACTIVE_VIDEO_MEM_OFFSET (U_LINE * H_ACTPIX)
79
80#define BFIN_LCD_NBR_PALETTE_ENTRIES 256
81
82#define DRIVER_NAME "bfin-t350mcqb"
83static char driver_name[] = DRIVER_NAME;
84
85struct bfin_t350mcqbfb_info {
86 struct fb_info *fb;
87 struct device *dev;
88 unsigned char *fb_buffer; /* RGB Buffer */
89 dma_addr_t dma_handle;
90 int lq043_mmap;
91 int lq043_open_cnt;
92 int irq;
93 spinlock_t lock; /* lock */
94};
95
96static int nocursor;
97module_param(nocursor, int, 0644);
98MODULE_PARM_DESC(nocursor, "cursor enable/disable");
99
100#define PPI_TX_MODE 0x2
101#define PPI_XFER_TYPE_11 0xC
102#define PPI_PORT_CFG_01 0x10
103#define PPI_PACK_EN 0x80
104#define PPI_POLS_1 0x8000
105
106static void bfin_t350mcqb_config_ppi(struct bfin_t350mcqbfb_info *fbi)
107{
108 bfin_write_PPI_DELAY(H_START);
109 bfin_write_PPI_COUNT(H_ACTPIX-1);
110 bfin_write_PPI_FRAME(V_LINES);
111
112 bfin_write_PPI_CONTROL(PPI_TX_MODE | /* output mode , PORT_DIR */
113 PPI_XFER_TYPE_11 | /* sync mode XFR_TYPE */
114 PPI_PORT_CFG_01 | /* two frame sync PORT_CFG */
115 PPI_PACK_EN | /* packing enabled PACK_EN */
116 PPI_POLS_1); /* faling edge syncs POLS */
117}
118
119static inline void bfin_t350mcqb_disable_ppi(void)
120{
121 bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() & ~PORT_EN);
122}
123
124static inline void bfin_t350mcqb_enable_ppi(void)
125{
126 bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() | PORT_EN);
127}
128
129static void bfin_t350mcqb_start_timers(void)
130{
131 unsigned long flags;
132
133 local_irq_save(flags);
134 enable_gptimers(TIMER1bit);
135 enable_gptimers(TIMER0bit);
136 local_irq_restore(flags);
137}
138
139static void bfin_t350mcqb_stop_timers(void)
140{
141 disable_gptimers(TIMER0bit | TIMER1bit);
142
143 set_gptimer_status(0, TIMER_STATUS_TRUN0 | TIMER_STATUS_TRUN1 |
144 TIMER_STATUS_TIMIL0 | TIMER_STATUS_TIMIL1 |
145 TIMER_STATUS_TOVF0 | TIMER_STATUS_TOVF1);
146
147}
148
149static void bfin_t350mcqb_init_timers(void)
150{
151
152 bfin_t350mcqb_stop_timers();
153
154 set_gptimer_period(TIMER0_id, H_PERIOD);
155 set_gptimer_pwidth(TIMER0_id, H_PULSE);
156 set_gptimer_config(TIMER0_id, TIMER_MODE_PWM | TIMER_PERIOD_CNT |
157 TIMER_TIN_SEL | TIMER_CLK_SEL|
158 TIMER_EMU_RUN);
159
160 set_gptimer_period(TIMER1_id, V_PERIOD);
161 set_gptimer_pwidth(TIMER1_id, V_PULSE);
162 set_gptimer_config(TIMER1_id, TIMER_MODE_PWM | TIMER_PERIOD_CNT |
163 TIMER_TIN_SEL | TIMER_CLK_SEL |
164 TIMER_EMU_RUN);
165
166}
167
168static void bfin_t350mcqb_config_dma(struct bfin_t350mcqbfb_info *fbi)
169{
170
171 set_dma_config(CH_PPI,
172 set_bfin_dma_config(DIR_READ, DMA_FLOW_AUTO,
173 INTR_DISABLE, DIMENSION_2D,
174 DATA_SIZE_16,
175 DMA_NOSYNC_KEEP_DMA_BUF));
176 set_dma_x_count(CH_PPI, (LCD_X_RES * LCD_BPP) / DMA_BUS_SIZE);
177 set_dma_x_modify(CH_PPI, DMA_BUS_SIZE / 8);
178 set_dma_y_count(CH_PPI, V_LINES);
179
180 set_dma_y_modify(CH_PPI, DMA_BUS_SIZE / 8);
181 set_dma_start_addr(CH_PPI, (unsigned long)fbi->fb_buffer);
182
183}
184
185static int bfin_t350mcqb_request_ports(int action)
186{
187 u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
188 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2,
189 P_PPI0_D3, P_PPI0_D4, P_PPI0_D5,
190 P_PPI0_D6, P_PPI0_D7, 0};
191
192 if (action) {
193 if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) {
194 printk(KERN_ERR "Requesting Peripherals faild\n");
195 return -EFAULT;
196 }
197 } else
198 peripheral_free_list(ppi0_req_8);
199
200 return 0;
201}
202
203static int bfin_t350mcqb_fb_open(struct fb_info *info, int user)
204{
205 struct bfin_t350mcqbfb_info *fbi = info->par;
206
207 spin_lock(&fbi->lock);
208 fbi->lq043_open_cnt++;
209
210 if (fbi->lq043_open_cnt <= 1) {
211
212 bfin_t350mcqb_disable_ppi();
213 SSYNC();
214
215 bfin_t350mcqb_config_dma(fbi);
216 bfin_t350mcqb_config_ppi(fbi);
217 bfin_t350mcqb_init_timers();
218
219 /* start dma */
220 enable_dma(CH_PPI);
221 bfin_t350mcqb_enable_ppi();
222 bfin_t350mcqb_start_timers();
223 }
224
225 spin_unlock(&fbi->lock);
226
227 return 0;
228}
229
230static int bfin_t350mcqb_fb_release(struct fb_info *info, int user)
231{
232 struct bfin_t350mcqbfb_info *fbi = info->par;
233
234 spin_lock(&fbi->lock);
235
236 fbi->lq043_open_cnt--;
237 fbi->lq043_mmap = 0;
238
239 if (fbi->lq043_open_cnt <= 0) {
240 bfin_t350mcqb_disable_ppi();
241 SSYNC();
242 disable_dma(CH_PPI);
243 bfin_t350mcqb_stop_timers();
244 memset(fbi->fb_buffer, 0, info->fix.smem_len);
245 }
246
247 spin_unlock(&fbi->lock);
248
249 return 0;
250}
251
252static int bfin_t350mcqb_fb_check_var(struct fb_var_screeninfo *var,
253 struct fb_info *info)
254{
255
256 if (var->bits_per_pixel != LCD_BPP) {
257 pr_debug("%s: depth not supported: %u BPP\n", __FUNCTION__,
258 var->bits_per_pixel);
259 return -EINVAL;
260 }
261
262 if (info->var.xres != var->xres || info->var.yres != var->yres ||
263 info->var.xres_virtual != var->xres_virtual ||
264 info->var.yres_virtual != var->yres_virtual) {
265 pr_debug("%s: Resolution not supported: X%u x Y%u \n",
266 __FUNCTION__, var->xres, var->yres);
267 return -EINVAL;
268 }
269
270 /*
271 * Memory limit
272 */
273
274 if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) {
275 pr_debug("%s: Memory Limit requested yres_virtual = %u\n",
276 __FUNCTION__, var->yres_virtual);
277 return -ENOMEM;
278 }
279
280 return 0;
281}
282
283static int bfin_t350mcqb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
284{
285 struct bfin_t350mcqbfb_info *fbi = info->par;
286
287 if (fbi->lq043_mmap)
288 return -1;
289
290 spin_lock(&fbi->lock);
291 fbi->lq043_mmap = 1;
292 spin_unlock(&fbi->lock);
293
294 vma->vm_start = (unsigned long)(fbi->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET);
295
296 vma->vm_end = vma->vm_start + info->fix.smem_len;
297 /* For those who don't understand how mmap works, go read
298 * Documentation/nommu-mmap.txt.
299 * For those that do, you will know that the VM_MAYSHARE flag
300 * must be set in the vma->vm_flags structure on noMMU
301 * Other flags can be set, and are documented in
302 * include/linux/mm.h
303 */
304 vma->vm_flags |= VM_MAYSHARE;
305
306 return 0;
307}
308
309int bfin_t350mcqb_fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
310{
311 if (nocursor)
312 return 0;
313 else
314 return -EINVAL; /* just to force soft_cursor() call */
315}
316
317static int bfin_t350mcqb_fb_setcolreg(u_int regno, u_int red, u_int green,
318 u_int blue, u_int transp,
319 struct fb_info *info)
320{
321 if (regno >= BFIN_LCD_NBR_PALETTE_ENTRIES)
322 return -EINVAL;
323
324 if (info->var.grayscale) {
325 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
326 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
327 }
328
329 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
330
331 u32 value;
332 /* Place color in the pseudopalette */
333 if (regno > 16)
334 return -EINVAL;
335
336 red >>= (16 - info->var.red.length);
337 green >>= (16 - info->var.green.length);
338 blue >>= (16 - info->var.blue.length);
339
340 value = (red << info->var.red.offset) |
341 (green << info->var.green.offset) |
342 (blue << info->var.blue.offset);
343 value &= 0xFFFFFF;
344
345 ((u32 *) (info->pseudo_palette))[regno] = value;
346
347 }
348
349 return 0;
350}
351
352static struct fb_ops bfin_t350mcqb_fb_ops = {
353 .owner = THIS_MODULE,
354 .fb_open = bfin_t350mcqb_fb_open,
355 .fb_release = bfin_t350mcqb_fb_release,
356 .fb_check_var = bfin_t350mcqb_fb_check_var,
357 .fb_fillrect = cfb_fillrect,
358 .fb_copyarea = cfb_copyarea,
359 .fb_imageblit = cfb_imageblit,
360 .fb_mmap = bfin_t350mcqb_fb_mmap,
361 .fb_cursor = bfin_t350mcqb_fb_cursor,
362 .fb_setcolreg = bfin_t350mcqb_fb_setcolreg,
363};
364
365#ifndef NO_BL_SUPPORT
366static int bl_get_brightness(struct backlight_device *bd)
367{
368 return 0;
369}
370
371static struct backlight_ops bfin_lq043fb_bl_ops = {
372 .get_brightness = bl_get_brightness,
373};
374
375static struct backlight_device *bl_dev;
376
377static int bfin_lcd_get_power(struct lcd_device *dev)
378{
379 return 0;
380}
381
382static int bfin_lcd_set_power(struct lcd_device *dev, int power)
383{
384 return 0;
385}
386
387static int bfin_lcd_get_contrast(struct lcd_device *dev)
388{
389 return 0;
390}
391
392static int bfin_lcd_set_contrast(struct lcd_device *dev, int contrast)
393{
394
395 return 0;
396}
397
398static int bfin_lcd_check_fb(struct fb_info *fi)
399{
400 if (!fi || (fi == &bfin_t350mcqb_fb))
401 return 1;
402 return 0;
403}
404
405static struct lcd_ops bfin_lcd_ops = {
406 .get_power = bfin_lcd_get_power,
407 .set_power = bfin_lcd_set_power,
408 .get_contrast = bfin_lcd_get_contrast,
409 .set_contrast = bfin_lcd_set_contrast,
410 .check_fb = bfin_lcd_check_fb,
411};
412
413static struct lcd_device *lcd_dev;
414#endif
415
416static irqreturn_t bfin_t350mcqb_irq_error(int irq, void *dev_id)
417{
418 /*struct bfin_t350mcqbfb_info *info = (struct bfin_t350mcqbfb_info *)dev_id;*/
419
420 u16 status = bfin_read_PPI_STATUS();
421 bfin_write_PPI_STATUS(0xFFFF);
422
423 if (status) {
424 bfin_t350mcqb_disable_ppi();
425 disable_dma(CH_PPI);
426
427 /* start dma */
428 enable_dma(CH_PPI);
429 bfin_t350mcqb_enable_ppi();
430 bfin_write_PPI_STATUS(0xFFFF);
431 }
432
433 return IRQ_HANDLED;
434}
435
436static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
437{
438 struct bfin_t350mcqbfb_info *info;
439 struct fb_info *fbinfo;
440 int ret;
441
442 printk(KERN_INFO DRIVER_NAME ": %dx%d %d-bit RGB FrameBuffer initializing...\n",
443 LCD_X_RES, LCD_Y_RES, LCD_BPP);
444
445 if (request_dma(CH_PPI, "CH_PPI") < 0) {
446 printk(KERN_ERR DRIVER_NAME
447 ": couldn't request CH_PPI DMA\n");
448 ret = -EFAULT;
449 goto out1;
450 }
451
452 fbinfo =
453 framebuffer_alloc(sizeof(struct bfin_t350mcqbfb_info), &pdev->dev);
454 if (!fbinfo) {
455 ret = -ENOMEM;
456 goto out2;
457 }
458
459 info = fbinfo->par;
460 info->fb = fbinfo;
461 info->dev = &pdev->dev;
462
463 platform_set_drvdata(pdev, fbinfo);
464
465 strcpy(fbinfo->fix.id, driver_name);
466
467 fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
468 fbinfo->fix.type_aux = 0;
469 fbinfo->fix.xpanstep = 0;
470 fbinfo->fix.ypanstep = 0;
471 fbinfo->fix.ywrapstep = 0;
472 fbinfo->fix.accel = FB_ACCEL_NONE;
473 fbinfo->fix.visual = FB_VISUAL_TRUECOLOR;
474
475 fbinfo->var.nonstd = 0;
476 fbinfo->var.activate = FB_ACTIVATE_NOW;
477 fbinfo->var.height = -1;
478 fbinfo->var.width = -1;
479 fbinfo->var.accel_flags = 0;
480 fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
481
482 fbinfo->var.xres = LCD_X_RES;
483 fbinfo->var.xres_virtual = LCD_X_RES;
484 fbinfo->var.yres = LCD_Y_RES;
485 fbinfo->var.yres_virtual = LCD_Y_RES;
486 fbinfo->var.bits_per_pixel = LCD_BPP;
487
488 fbinfo->var.red.offset = 0;
489 fbinfo->var.green.offset = 8;
490 fbinfo->var.blue.offset = 16;
491 fbinfo->var.transp.offset = 0;
492 fbinfo->var.red.length = 8;
493 fbinfo->var.green.length = 8;
494 fbinfo->var.blue.length = 8;
495 fbinfo->var.transp.length = 0;
496 fbinfo->fix.smem_len = LCD_X_RES * LCD_Y_RES * LCD_BPP / 8;
497
498 fbinfo->fix.line_length = fbinfo->var.xres_virtual *
499 fbinfo->var.bits_per_pixel / 8;
500
501
502 fbinfo->fbops = &bfin_t350mcqb_fb_ops;
503 fbinfo->flags = FBINFO_FLAG_DEFAULT;
504
505 info->fb_buffer =
506 dma_alloc_coherent(NULL, fbinfo->fix.smem_len, &info->dma_handle,
507 GFP_KERNEL);
508
509 if (NULL == info->fb_buffer) {
510 printk(KERN_ERR DRIVER_NAME
511 ": couldn't allocate dma buffer.\n");
512 ret = -ENOMEM;
513 goto out3;
514 }
515
516 memset(info->fb_buffer, 0, fbinfo->fix.smem_len);
517
518 fbinfo->screen_base = (void *)info->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET;
519 fbinfo->fix.smem_start = (int)info->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET;
520
521 fbinfo->fbops = &bfin_t350mcqb_fb_ops;
522
523 fbinfo->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL);
524 if (!fbinfo->pseudo_palette) {
525 printk(KERN_ERR DRIVER_NAME
526 "Fail to allocate pseudo_palette\n");
527
528 ret = -ENOMEM;
529 goto out4;
530 }
531
532 memset(fbinfo->pseudo_palette, 0, sizeof(u32) * 16);
533
534 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0)
535 < 0) {
536 printk(KERN_ERR DRIVER_NAME
537 "Fail to allocate colormap (%d entries)\n",
538 BFIN_LCD_NBR_PALETTE_ENTRIES);
539 ret = -EFAULT;
540 goto out5;
541 }
542
543 if (bfin_t350mcqb_request_ports(1)) {
544 printk(KERN_ERR DRIVER_NAME ": couldn't request gpio port.\n");
545 ret = -EFAULT;
546 goto out6;
547 }
548
549 info->irq = platform_get_irq(pdev, 0);
550 if (info->irq < 0) {
551 ret = -EINVAL;
552 goto out7;
553 }
554
555 if (request_irq(info->irq, (void *)bfin_t350mcqb_irq_error, IRQF_DISABLED,
556 "PPI ERROR", info) < 0) {
557 printk(KERN_ERR DRIVER_NAME
558 ": unable to request PPI ERROR IRQ\n");
559 ret = -EFAULT;
560 goto out7;
561 }
562
563 if (register_framebuffer(fbinfo) < 0) {
564 printk(KERN_ERR DRIVER_NAME
565 ": unable to register framebuffer.\n");
566 ret = -EINVAL;
567 goto out8;
568 }
569#ifndef NO_BL_SUPPORT
570 bl_dev =
571 backlight_device_register("bf52x-bl", NULL, NULL,
572 &bfin_lq043fb_bl_ops);
573 bl_dev->props.max_brightness = 255;
574
575 lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops);
576 lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
577#endif
578
579 return 0;
580
581out8:
582 free_irq(info->irq, info);
583out7:
584 bfin_t350mcqb_request_ports(0);
585out6:
586 fb_dealloc_cmap(&fbinfo->cmap);
587out5:
588 kfree(fbinfo->pseudo_palette);
589out4:
590 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
591 info->dma_handle);
592out3:
593 framebuffer_release(fbinfo);
594out2:
595 free_dma(CH_PPI);
596out1:
597 platform_set_drvdata(pdev, NULL);
598
599 return ret;
600}
601
602static int bfin_t350mcqb_remove(struct platform_device *pdev)
603{
604
605 struct fb_info *fbinfo = platform_get_drvdata(pdev);
606 struct bfin_t350mcqbfb_info *info = fbinfo->par;
607
608 free_dma(CH_PPI);
609 free_irq(info->irq, info);
610
611 if (info->fb_buffer != NULL)
612 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
613 info->dma_handle);
614
615 kfree(fbinfo->pseudo_palette);
616 fb_dealloc_cmap(&fbinfo->cmap);
617
618#ifndef NO_BL_SUPPORT
619 lcd_device_unregister(lcd_dev);
620 backlight_device_unregister(bl_dev);
621#endif
622
623 unregister_framebuffer(fbinfo);
624
625 bfin_t350mcqb_request_ports(0);
626
627 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n");
628
629 return 0;
630}
631
632#ifdef CONFIG_PM
633static int bfin_t350mcqb_suspend(struct platform_device *pdev, pm_message_t state)
634{
635 struct fb_info *fbinfo = platform_get_drvdata(pdev);
636 struct bfin_t350mcqbfb_info *info = fbinfo->par;
637
638 bfin_t350mcqb_disable_ppi();
639 disable_dma(CH_PPI);
640 bfin_write_PPI_STATUS(0xFFFF);
641
642 return 0;
643}
644
645static int bfin_t350mcqb_resume(struct platform_device *pdev)
646{
647 struct fb_info *fbinfo = platform_get_drvdata(pdev);
648 struct bfin_t350mcqbfb_info *info = fbinfo->par;
649
650 enable_dma(CH_PPI);
651 bfin_t350mcqb_enable_ppi();
652
653 return 0;
654}
655#else
656#define bfin_t350mcqb_suspend NULL
657#define bfin_t350mcqb_resume NULL
658#endif
659
660static struct platform_driver bfin_t350mcqb_driver = {
661 .probe = bfin_t350mcqb_probe,
662 .remove = bfin_t350mcqb_remove,
663 .suspend = bfin_t350mcqb_suspend,
664 .resume = bfin_t350mcqb_resume,
665 .driver = {
666 .name = DRIVER_NAME,
667 .owner = THIS_MODULE,
668 },
669};
670
671static int __devinit bfin_t350mcqb_driver_init(void)
672{
673 return platform_driver_register(&bfin_t350mcqb_driver);
674}
675
676static void __exit bfin_t350mcqb_driver_cleanup(void)
677{
678 platform_driver_unregister(&bfin_t350mcqb_driver);
679}
680
681MODULE_DESCRIPTION("Blackfin TFT LCD Driver");
682MODULE_LICENSE("GPL");
683
684module_init(bfin_t350mcqb_driver_init);
685module_exit(bfin_t350mcqb_driver_cleanup);
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 756c0ce85911..392a8be6aa76 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -403,7 +403,7 @@ static int __init hitfb_probe(struct platform_device *dev)
403 return 0; 403 return 0;
404} 404}
405 405
406static int __devexit hitfb_remove(struct platform_device *dev) 406static int __exit hitfb_remove(struct platform_device *dev)
407{ 407{
408 return unregister_framebuffer(&fb_info); 408 return unregister_framebuffer(&fb_info);
409} 409}
@@ -439,7 +439,7 @@ static int hitfb_resume(struct platform_device *dev)
439 439
440static struct platform_driver hitfb_driver = { 440static struct platform_driver hitfb_driver = {
441 .probe = hitfb_probe, 441 .probe = hitfb_probe,
442 .remove = __devexit_p(hitfb_remove), 442 .remove = __exit_p(hitfb_remove),
443#ifdef CONFIG_PM 443#ifdef CONFIG_PM
444 .suspend = hitfb_suspend, 444 .suspend = hitfb_suspend,
445 .resume = hitfb_resume, 445 .resume = hitfb_resume,
diff --git a/drivers/video/mbx/mbxfb.c b/drivers/video/mbx/mbxfb.c
index 80cd117ca65c..01f77bcc68f9 100644
--- a/drivers/video/mbx/mbxfb.c
+++ b/drivers/video/mbx/mbxfb.c
@@ -889,7 +889,7 @@ static int __devinit mbxfb_probe(struct platform_device *dev)
889 struct mbxfb_info *mfbi; 889 struct mbxfb_info *mfbi;
890 struct mbxfb_platform_data *pdata; 890 struct mbxfb_platform_data *pdata;
891 891
892 dev_dbg(dev, "mbxfb_probe\n"); 892 dev_dbg(&dev->dev, "mbxfb_probe\n");
893 893
894 pdata = dev->dev.platform_data; 894 pdata = dev->dev.platform_data;
895 if (!pdata) { 895 if (!pdata) {
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 6a3d0b574897..8c863a7f654b 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -1,16 +1,12 @@
1/* drivers/video/pvr2fb.c 1/*
2 * drivers/video/pvr2fb.c
2 * 3 *
3 * Frame buffer and fbcon support for the NEC PowerVR2 found within the Sega 4 * Frame buffer and fbcon support for the NEC PowerVR2 found within the Sega
4 * Dreamcast. 5 * Dreamcast.
5 * 6 *
6 * Copyright (c) 2001 M. R. Brown <mrbrown@0xd6.org> 7 * Copyright (c) 2001 M. R. Brown <mrbrown@0xd6.org>
7 * Copyright (c) 2001, 2002, 2003, 2004, 2005 Paul Mundt <lethal@linux-sh.org> 8 * Copyright (c) 2001 - 2008 Paul Mundt <lethal@linux-sh.org>
8 *
9 * This file is part of the LinuxDC project (linuxdc.sourceforge.net).
10 * 9 *
11 */
12
13/*
14 * This driver is mostly based on the excellent amifb and vfb sources. It uses 10 * This driver is mostly based on the excellent amifb and vfb sources. It uses
15 * an odd scheme for converting hardware values to/from framebuffer values, 11 * an odd scheme for converting hardware values to/from framebuffer values,
16 * here are some hacked-up formulas: 12 * here are some hacked-up formulas:
@@ -490,7 +486,7 @@ static int pvr2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
490 } else { 486 } else {
491 var->sync &= ~FB_SYNC_BROADCAST; 487 var->sync &= ~FB_SYNC_BROADCAST;
492 var->vmode &= ~FB_VMODE_INTERLACED; 488 var->vmode &= ~FB_VMODE_INTERLACED;
493 var->vmode |= pvr2_var.vmode; 489 var->vmode |= FB_VMODE_NONINTERLACED;
494 } 490 }
495 491
496 if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_TEST) { 492 if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_TEST) {
diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c
index e83dfba7e636..742b5c656d66 100644
--- a/drivers/video/sm501fb.c
+++ b/drivers/video/sm501fb.c
@@ -237,12 +237,14 @@ static int sm501fb_check_var(struct fb_var_screeninfo *var,
237 237
238 /* check we can fit these values into the registers */ 238 /* check we can fit these values into the registers */
239 239
240 if (var->hsync_len > 255 || var->vsync_len > 255) 240 if (var->hsync_len > 255 || var->vsync_len > 63)
241 return -EINVAL; 241 return -EINVAL;
242 242
243 if ((var->xres + var->right_margin) >= 4096) 243 /* hdisplay end and hsync start */
244 if ((var->xres + var->right_margin) > 4096)
244 return -EINVAL; 245 return -EINVAL;
245 246
247 /* vdisplay end and vsync start */
246 if ((var->yres + var->lower_margin) > 2048) 248 if ((var->yres + var->lower_margin) > 2048)
247 return -EINVAL; 249 return -EINVAL;
248 250
@@ -281,19 +283,21 @@ static int sm501fb_check_var(struct fb_var_screeninfo *var,
281 var->blue.length = var->bits_per_pixel; 283 var->blue.length = var->bits_per_pixel;
282 var->blue.offset = 0; 284 var->blue.offset = 0;
283 var->transp.length = 0; 285 var->transp.length = 0;
286 var->transp.offset = 0;
284 287
285 break; 288 break;
286 289
287 case 16: 290 case 16:
288 if (sm->pdata->flags & SM501_FBPD_SWAP_FB_ENDIAN) { 291 if (sm->pdata->flags & SM501_FBPD_SWAP_FB_ENDIAN) {
289 var->red.offset = 11;
290 var->green.offset = 5;
291 var->blue.offset = 0;
292 } else {
293 var->blue.offset = 11; 292 var->blue.offset = 11;
294 var->green.offset = 5; 293 var->green.offset = 5;
295 var->red.offset = 0; 294 var->red.offset = 0;
295 } else {
296 var->red.offset = 11;
297 var->green.offset = 5;
298 var->blue.offset = 0;
296 } 299 }
300 var->transp.offset = 0;
297 301
298 var->red.length = 5; 302 var->red.length = 5;
299 var->green.length = 6; 303 var->green.length = 6;
@@ -397,7 +401,7 @@ static int sm501fb_set_par_common(struct fb_info *info,
397 break; 401 break;
398 402
399 case 16: 403 case 16:
400 info->fix.visual = FB_VISUAL_DIRECTCOLOR; 404 info->fix.visual = FB_VISUAL_TRUECOLOR;
401 break; 405 break;
402 406
403 case 32: 407 case 32:
@@ -613,6 +617,7 @@ static int sm501fb_set_par_crt(struct fb_info *info)
613 617
614 case 16: 618 case 16:
615 control |= SM501_DC_CRT_CONTROL_16BPP; 619 control |= SM501_DC_CRT_CONTROL_16BPP;
620 sm501fb_setup_gamma(fbi, SM501_DC_CRT_PALETTE);
616 break; 621 break;
617 622
618 case 32: 623 case 32:
@@ -750,6 +755,7 @@ static int sm501fb_set_par_pnl(struct fb_info *info)
750 755
751 case 16: 756 case 16:
752 control |= SM501_DC_PANEL_CONTROL_16BPP; 757 control |= SM501_DC_PANEL_CONTROL_16BPP;
758 sm501fb_setup_gamma(fbi, SM501_DC_PANEL_PALETTE);
753 break; 759 break;
754 760
755 case 32: 761 case 32:
diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c
index e7c8db2eb49b..f98be301140c 100644
--- a/drivers/video/stifb.c
+++ b/drivers/video/stifb.c
@@ -505,16 +505,24 @@ ngleSetupAttrPlanes(struct stifb_info *fb, int BufferNumber)
505static void 505static void
506rattlerSetupPlanes(struct stifb_info *fb) 506rattlerSetupPlanes(struct stifb_info *fb)
507{ 507{
508 int saved_id, y;
509
510 /* Write RAMDAC pixel read mask register so all overlay
511 * planes are display-enabled. (CRX24 uses Bt462 pixel
512 * read mask register for overlay planes, not image planes).
513 */
508 CRX24_SETUP_RAMDAC(fb); 514 CRX24_SETUP_RAMDAC(fb);
509 515
510 /* replacement for: SETUP_FB(fb, CRX24_OVERLAY_PLANES); */ 516 /* change fb->id temporarily to fool SETUP_FB() */
511 WRITE_WORD(0x83000300, fb, REG_14); 517 saved_id = fb->id;
512 SETUP_HW(fb); 518 fb->id = CRX24_OVERLAY_PLANES;
513 WRITE_BYTE(1, fb, REG_16b1); 519 SETUP_FB(fb);
520 fb->id = saved_id;
521
522 for (y = 0; y < fb->info.var.yres; ++y)
523 memset(fb->info.screen_base + y * fb->info.fix.line_length,
524 0xff, fb->info.var.xres * fb->info.var.bits_per_pixel/8);
514 525
515 fb_memset((void*)fb->info.fix.smem_start, 0xff,
516 fb->info.var.yres*fb->info.fix.line_length);
517
518 CRX24_SET_OVLY_MASK(fb); 526 CRX24_SET_OVLY_MASK(fb);
519 SETUP_FB(fb); 527 SETUP_FB(fb);
520} 528}
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
index 70fb4ee2b421..0a4e07d43d2d 100644
--- a/drivers/video/tridentfb.c
+++ b/drivers/video/tridentfb.c
@@ -564,7 +564,7 @@ static inline void write3CE(int reg, unsigned char val)
564 t_outb(val, 0x3CF); 564 t_outb(val, 0x3CF);
565} 565}
566 566
567static inline void enable_mmio(void) 567static void enable_mmio(void)
568{ 568{
569 /* Goto New Mode */ 569 /* Goto New Mode */
570 outb(0x0B, 0x3C4); 570 outb(0x0B, 0x3C4);
@@ -579,6 +579,21 @@ static inline void enable_mmio(void)
579 outb(inb(0x3D5) | 0x01, 0x3D5); 579 outb(inb(0x3D5) | 0x01, 0x3D5);
580} 580}
581 581
582static void disable_mmio(void)
583{
584 /* Goto New Mode */
585 t_outb(0x0B, 0x3C4);
586 t_inb(0x3C5);
587
588 /* Unprotect registers */
589 t_outb(NewMode1, 0x3C4);
590 t_outb(0x80, 0x3C5);
591
592 /* Disable MMIO */
593 t_outb(PCIReg, 0x3D4);
594 t_outb(t_inb(0x3D5) & ~0x01, 0x3D5);
595}
596
582#define crtc_unlock() write3X4(CRTVSyncEnd, read3X4(CRTVSyncEnd) & 0x7F) 597#define crtc_unlock() write3X4(CRTVSyncEnd, read3X4(CRTVSyncEnd) & 0x7F)
583 598
584/* Return flat panel's maximum x resolution */ 599/* Return flat panel's maximum x resolution */
@@ -730,7 +745,7 @@ static unsigned int __devinit get_memsize(void)
730 switch (tmp) { 745 switch (tmp) {
731 746
732 case 0x01: 747 case 0x01:
733 k = 512; 748 k = 512 * Kb;
734 break; 749 break;
735 case 0x02: 750 case 0x02:
736 k = 6 * Mb; /* XP */ 751 k = 6 * Mb; /* XP */
@@ -1239,9 +1254,9 @@ static int __devinit trident_pci_probe(struct pci_dev * dev,
1239 default_par.io_virt = ioremap_nocache(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); 1254 default_par.io_virt = ioremap_nocache(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1240 1255
1241 if (!default_par.io_virt) { 1256 if (!default_par.io_virt) {
1242 release_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1243 debug("ioremap failed\n"); 1257 debug("ioremap failed\n");
1244 return -1; 1258 err = -1;
1259 goto out_unmap1;
1245 } 1260 }
1246 1261
1247 enable_mmio(); 1262 enable_mmio();
@@ -1252,25 +1267,21 @@ static int __devinit trident_pci_probe(struct pci_dev * dev,
1252 1267
1253 if (!request_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len, "tridentfb")) { 1268 if (!request_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len, "tridentfb")) {
1254 debug("request_mem_region failed!\n"); 1269 debug("request_mem_region failed!\n");
1270 disable_mmio();
1255 err = -1; 1271 err = -1;
1256 goto out_unmap; 1272 goto out_unmap1;
1257 } 1273 }
1258 1274
1259 fb_info.screen_base = ioremap_nocache(tridentfb_fix.smem_start, 1275 fb_info.screen_base = ioremap_nocache(tridentfb_fix.smem_start,
1260 tridentfb_fix.smem_len); 1276 tridentfb_fix.smem_len);
1261 1277
1262 if (!fb_info.screen_base) { 1278 if (!fb_info.screen_base) {
1263 release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
1264 debug("ioremap failed\n"); 1279 debug("ioremap failed\n");
1265 err = -1; 1280 err = -1;
1266 goto out_unmap; 1281 goto out_unmap2;
1267 } 1282 }
1268 1283
1269 output("%s board found\n", pci_name(dev)); 1284 output("%s board found\n", pci_name(dev));
1270#if 0
1271 output("Trident board found : mem = %X, io = %X, mem_v = %X, io_v = %X\n",
1272 tridentfb_fix.smem_start, tridentfb_fix.mmio_start, fb_info.screen_base, default_par.io_virt);
1273#endif
1274 displaytype = get_displaytype(); 1285 displaytype = get_displaytype();
1275 1286
1276 if (flatpanel) 1287 if (flatpanel)
@@ -1288,9 +1299,12 @@ static int __devinit trident_pci_probe(struct pci_dev * dev,
1288 1299
1289 if (!fb_find_mode(&default_var, &fb_info, mode, NULL, 0, NULL, bpp)) { 1300 if (!fb_find_mode(&default_var, &fb_info, mode, NULL, 0, NULL, bpp)) {
1290 err = -EINVAL; 1301 err = -EINVAL;
1291 goto out_unmap; 1302 goto out_unmap2;
1292 } 1303 }
1293 fb_alloc_cmap(&fb_info.cmap, 256, 0); 1304 err = fb_alloc_cmap(&fb_info.cmap, 256, 0);
1305 if (err < 0)
1306 goto out_unmap2;
1307
1294 if (defaultaccel && acc) 1308 if (defaultaccel && acc)
1295 default_var.accel_flags |= FB_ACCELF_TEXT; 1309 default_var.accel_flags |= FB_ACCELF_TEXT;
1296 else 1310 else
@@ -1300,19 +1314,24 @@ static int __devinit trident_pci_probe(struct pci_dev * dev,
1300 fb_info.device = &dev->dev; 1314 fb_info.device = &dev->dev;
1301 if (register_framebuffer(&fb_info) < 0) { 1315 if (register_framebuffer(&fb_info) < 0) {
1302 printk(KERN_ERR "tridentfb: could not register Trident framebuffer\n"); 1316 printk(KERN_ERR "tridentfb: could not register Trident framebuffer\n");
1317 fb_dealloc_cmap(&fb_info.cmap);
1303 err = -EINVAL; 1318 err = -EINVAL;
1304 goto out_unmap; 1319 goto out_unmap2;
1305 } 1320 }
1306 output("fb%d: %s frame buffer device %dx%d-%dbpp\n", 1321 output("fb%d: %s frame buffer device %dx%d-%dbpp\n",
1307 fb_info.node, fb_info.fix.id, default_var.xres, 1322 fb_info.node, fb_info.fix.id, default_var.xres,
1308 default_var.yres, default_var.bits_per_pixel); 1323 default_var.yres, default_var.bits_per_pixel);
1309 return 0; 1324 return 0;
1310 1325
1311out_unmap: 1326out_unmap2:
1312 if (default_par.io_virt)
1313 iounmap(default_par.io_virt);
1314 if (fb_info.screen_base) 1327 if (fb_info.screen_base)
1315 iounmap(fb_info.screen_base); 1328 iounmap(fb_info.screen_base);
1329 release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
1330 disable_mmio();
1331out_unmap1:
1332 if (default_par.io_virt)
1333 iounmap(default_par.io_virt);
1334 release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1316 return err; 1335 return err;
1317} 1336}
1318 1337
@@ -1323,7 +1342,7 @@ static void __devexit trident_pci_remove(struct pci_dev *dev)
1323 iounmap(par->io_virt); 1342 iounmap(par->io_virt);
1324 iounmap(fb_info.screen_base); 1343 iounmap(fb_info.screen_base);
1325 release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len); 1344 release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
1326 release_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); 1345 release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1327} 1346}
1328 1347
1329/* List of boards that we are trying to support */ 1348/* List of boards that we are trying to support */