aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/da8xx-fb.c
diff options
context:
space:
mode:
authorSudhakar Rajashekhara <sudhakar.raj@ti.com>2009-09-22 19:47:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 10:39:51 -0400
commit2f93e8f4822fdd48fa9c4c901eea87ab1c902f87 (patch)
tree04759bd6c4f81f4b30a2ecce237e690a6369e138 /drivers/video/da8xx-fb.c
parent4ed824d9aead77a6a4eb1e89c3b3d270ba386fad (diff)
davinci-fb-frame-buffer-driver-for-ti-da8xx-omap-l1xx-v4
Since the previous version, return values in ioctl() function have been modified. [akpm@linux-foundation.org: simplify lcd_disable_raster()] Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com> Signed-off-by: Pavel Kiryukhin <pkiryukhin@ru.mvista.com> Signed-off-by: Steve Chen <schen@mvista.com> Acked-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/da8xx-fb.c')
-rw-r--r--drivers/video/da8xx-fb.c61
1 files changed, 21 insertions, 40 deletions
diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index e0bbc66499c8..42e1005e2916 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -107,7 +107,6 @@ static inline void lcdc_write(unsigned int val, unsigned int addr)
107} 107}
108 108
109struct da8xx_fb_par { 109struct da8xx_fb_par {
110 wait_queue_head_t da8xx_wq;
111 resource_size_t p_palette_base; 110 resource_size_t p_palette_base;
112 unsigned char *v_palette_base; 111 unsigned char *v_palette_base;
113 struct clk *lcdc_clk; 112 struct clk *lcdc_clk;
@@ -158,6 +157,7 @@ struct da8xx_panel {
158 int vbp; /* Vertical back porch */ 157 int vbp; /* Vertical back porch */
159 int vsw; /* Vertical Sync Pulse Width */ 158 int vsw; /* Vertical Sync Pulse Width */
160 int pxl_clk; /* Pixel clock */ 159 int pxl_clk; /* Pixel clock */
160 unsigned char invert_pxl_clk; /* Invert Pixel clock */
161}; 161};
162 162
163static struct da8xx_panel known_lcd_panels[] = { 163static struct da8xx_panel known_lcd_panels[] = {
@@ -173,6 +173,7 @@ static struct da8xx_panel known_lcd_panels[] = {
173 .vbp = 2, 173 .vbp = 2,
174 .vsw = 0, 174 .vsw = 0,
175 .pxl_clk = 0x10, 175 .pxl_clk = 0x10,
176 .invert_pxl_clk = 1,
176 }, 177 },
177 /* Sharp LK043T1DG01 */ 178 /* Sharp LK043T1DG01 */
178 [1] = { 179 [1] = {
@@ -186,29 +187,18 @@ static struct da8xx_panel known_lcd_panels[] = {
186 .vbp = 2, 187 .vbp = 2,
187 .vsw = 10, 188 .vsw = 10,
188 .pxl_clk = 0x12, 189 .pxl_clk = 0x12,
190 .invert_pxl_clk = 0,
189 }, 191 },
190}; 192};
191 193
192/* Disable the Raster Engine of the LCD Controller */ 194/* Disable the Raster Engine of the LCD Controller */
193static int lcd_disable_raster(struct da8xx_fb_par *par) 195static void lcd_disable_raster(struct da8xx_fb_par *par)
194{ 196{
195 int ret = 0;
196 u32 reg; 197 u32 reg;
197 198
198 reg = lcdc_read(LCD_RASTER_CTRL_REG); 199 reg = lcdc_read(LCD_RASTER_CTRL_REG);
199 if (reg & LCD_RASTER_ENABLE) { 200 if (reg & LCD_RASTER_ENABLE)
200 lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG); 201 lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
201 ret = wait_event_interruptible_timeout(par->da8xx_wq,
202 !lcdc_read(LCD_STAT_REG) &
203 LCD_END_OF_FRAME0, WSI_TIMEOUT);
204 }
205
206 if (ret < 0)
207 return ret;
208 if (ret == 0)
209 return -ETIMEDOUT;
210
211 return 0;
212} 202}
213 203
214static void lcd_blit(int load_mode, struct da8xx_fb_par *par) 204static void lcd_blit(int load_mode, struct da8xx_fb_par *par)
@@ -256,7 +246,7 @@ static int lcd_cfg_dma(int burst_size)
256 default: 246 default:
257 return -EINVAL; 247 return -EINVAL;
258 } 248 }
259 lcdc_write(reg | LCD_END_OF_FRAME_INT_ENA, LCD_DMA_CTRL_REG); 249 lcdc_write(reg, LCD_DMA_CTRL_REG);
260 250
261 return 0; 251 return 0;
262} 252}
@@ -342,11 +332,6 @@ static int lcd_cfg_display(const struct lcd_ctrl_config *cfg)
342 else 332 else
343 reg &= ~LCD_SYNC_EDGE; 333 reg &= ~LCD_SYNC_EDGE;
344 334
345 if (cfg->invert_pxl_clock)
346 reg |= LCD_INVERT_PIXEL_CLOCK;
347 else
348 reg &= ~LCD_INVERT_PIXEL_CLOCK;
349
350 if (cfg->invert_line_clock) 335 if (cfg->invert_line_clock)
351 reg |= LCD_INVERT_LINE_CLOCK; 336 reg |= LCD_INVERT_LINE_CLOCK;
352 else 337 else
@@ -456,19 +441,15 @@ static int fb_setcolreg(unsigned regno, unsigned red, unsigned green,
456 return 0; 441 return 0;
457} 442}
458 443
459static int lcd_reset(struct da8xx_fb_par *par) 444static void lcd_reset(struct da8xx_fb_par *par)
460{ 445{
461 int ret = 0;
462
463 /* Disable the Raster if previously Enabled */ 446 /* Disable the Raster if previously Enabled */
464 if (lcdc_read(LCD_RASTER_CTRL_REG) & LCD_RASTER_ENABLE) 447 if (lcdc_read(LCD_RASTER_CTRL_REG) & LCD_RASTER_ENABLE)
465 ret = lcd_disable_raster(par); 448 lcd_disable_raster(par);
466 449
467 /* DMA has to be disabled */ 450 /* DMA has to be disabled */
468 lcdc_write(0, LCD_DMA_CTRL_REG); 451 lcdc_write(0, LCD_DMA_CTRL_REG);
469 lcdc_write(0, LCD_RASTER_CTRL_REG); 452 lcdc_write(0, LCD_RASTER_CTRL_REG);
470
471 return ret;
472} 453}
473 454
474static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg, 455static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
@@ -477,14 +458,19 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
477 u32 bpp; 458 u32 bpp;
478 int ret = 0; 459 int ret = 0;
479 460
480 ret = lcd_reset(par); 461 lcd_reset(par);
481 if (ret != 0)
482 return ret;
483 462
484 /* Configure the LCD clock divisor. */ 463 /* Configure the LCD clock divisor. */
485 lcdc_write(LCD_CLK_DIVISOR(panel->pxl_clk) | 464 lcdc_write(LCD_CLK_DIVISOR(panel->pxl_clk) |
486 (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG); 465 (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG);
487 466
467 if (panel->invert_pxl_clk)
468 lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
469 LCD_INVERT_PIXEL_CLOCK), LCD_RASTER_TIMING_2_REG);
470 else
471 lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) &
472 ~LCD_INVERT_PIXEL_CLOCK), LCD_RASTER_TIMING_2_REG);
473
488 /* Configure the DMA burst size. */ 474 /* Configure the DMA burst size. */
489 ret = lcd_cfg_dma(cfg->dma_burst_sz); 475 ret = lcd_cfg_dma(cfg->dma_burst_sz);
490 if (ret < 0) 476 if (ret < 0)
@@ -528,7 +514,6 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
528static irqreturn_t lcdc_irq_handler(int irq, void *arg) 514static irqreturn_t lcdc_irq_handler(int irq, void *arg)
529{ 515{
530 u32 stat = lcdc_read(LCD_STAT_REG); 516 u32 stat = lcdc_read(LCD_STAT_REG);
531 struct da8xx_fb_par *par = arg;
532 u32 reg; 517 u32 reg;
533 518
534 if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) { 519 if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
@@ -539,7 +524,6 @@ static irqreturn_t lcdc_irq_handler(int irq, void *arg)
539 } else 524 } else
540 lcdc_write(stat, LCD_STAT_REG); 525 lcdc_write(stat, LCD_STAT_REG);
541 526
542 wake_up_interruptible(&par->da8xx_wq);
543 return IRQ_HANDLED; 527 return IRQ_HANDLED;
544} 528}
545 529
@@ -594,13 +578,12 @@ static int fb_check_var(struct fb_var_screeninfo *var,
594static int __devexit fb_remove(struct platform_device *dev) 578static int __devexit fb_remove(struct platform_device *dev)
595{ 579{
596 struct fb_info *info = dev_get_drvdata(&dev->dev); 580 struct fb_info *info = dev_get_drvdata(&dev->dev);
597 int ret = 0;
598 581
599 if (info) { 582 if (info) {
600 struct da8xx_fb_par *par = info->par; 583 struct da8xx_fb_par *par = info->par;
601 584
602 if (lcdc_read(LCD_RASTER_CTRL_REG) & LCD_RASTER_ENABLE) 585 if (lcdc_read(LCD_RASTER_CTRL_REG) & LCD_RASTER_ENABLE)
603 ret = lcd_disable_raster(par); 586 lcd_disable_raster(par);
604 lcdc_write(0, LCD_RASTER_CTRL_REG); 587 lcdc_write(0, LCD_RASTER_CTRL_REG);
605 588
606 /* disable DMA */ 589 /* disable DMA */
@@ -619,7 +602,7 @@ static int __devexit fb_remove(struct platform_device *dev)
619 release_mem_region(lcdc_regs->start, resource_size(lcdc_regs)); 602 release_mem_region(lcdc_regs->start, resource_size(lcdc_regs));
620 603
621 } 604 }
622 return ret; 605 return 0;
623} 606}
624 607
625static int fb_ioctl(struct fb_info *info, unsigned int cmd, 608static int fb_ioctl(struct fb_info *info, unsigned int cmd,
@@ -634,11 +617,11 @@ static int fb_ioctl(struct fb_info *info, unsigned int cmd,
634 case FBIPUT_BRIGHTNESS: 617 case FBIPUT_BRIGHTNESS:
635 case FBIGET_COLOR: 618 case FBIGET_COLOR:
636 case FBIPUT_COLOR: 619 case FBIPUT_COLOR:
637 return -EINVAL; 620 return -ENOTTY;
638 case FBIPUT_HSYNC: 621 case FBIPUT_HSYNC:
639 if (copy_from_user(&sync_arg, (char *)arg, 622 if (copy_from_user(&sync_arg, (char *)arg,
640 sizeof(struct lcd_sync_arg))) 623 sizeof(struct lcd_sync_arg)))
641 return -EINVAL; 624 return -EFAULT;
642 lcd_cfg_horizontal_sync(sync_arg.back_porch, 625 lcd_cfg_horizontal_sync(sync_arg.back_porch,
643 sync_arg.pulse_width, 626 sync_arg.pulse_width,
644 sync_arg.front_porch); 627 sync_arg.front_porch);
@@ -646,7 +629,7 @@ static int fb_ioctl(struct fb_info *info, unsigned int cmd,
646 case FBIPUT_VSYNC: 629 case FBIPUT_VSYNC:
647 if (copy_from_user(&sync_arg, (char *)arg, 630 if (copy_from_user(&sync_arg, (char *)arg,
648 sizeof(struct lcd_sync_arg))) 631 sizeof(struct lcd_sync_arg)))
649 return -EINVAL; 632 return -EFAULT;
650 lcd_cfg_vertical_sync(sync_arg.back_porch, 633 lcd_cfg_vertical_sync(sync_arg.back_porch,
651 sync_arg.pulse_width, 634 sync_arg.pulse_width,
652 sync_arg.front_porch); 635 sync_arg.front_porch);
@@ -773,8 +756,6 @@ static int __init fb_probe(struct platform_device *device)
773 756
774 par->lcdc_clk = fb_clk; 757 par->lcdc_clk = fb_clk;
775 758
776 init_waitqueue_head(&par->da8xx_wq);
777
778 par->irq = platform_get_irq(device, 0); 759 par->irq = platform_get_irq(device, 0);
779 if (par->irq < 0) { 760 if (par->irq < 0) {
780 ret = -ENOENT; 761 ret = -ENOENT;