]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/video/s3c-fb.c
V4L/DVB: drivers/media/video: Adjust confusing if indentation
[karo-tx-linux.git] / drivers / video / s3c-fb.c
index a95314ddf70958a7b3e33399d4dbccbda0d07ff0..f9aca9d13d1b566e1da5e035a98f7e1ee34c0b1d 100644 (file)
@@ -634,6 +634,13 @@ static int s3c_fb_set_par(struct fb_info *info)
        writel(data, regs + sfb->variant.wincon + (win_no * 4));
        writel(0x0, regs + sfb->variant.winmap + (win_no * 4));
 
+       /* Enable DMA channel for this window */
+       if (sfb->variant.has_shadowcon) {
+               data = readl(sfb->regs + SHADOWCON);
+               data |= SHADOWCON_CHx_ENABLE(win_no);
+               writel(data, sfb->regs + SHADOWCON);
+       }
+
        shadow_protect_win(win, 0);
 
        return 0;
@@ -1019,6 +1026,28 @@ static struct fb_ops s3c_fb_ops = {
        .fb_ioctl       = s3c_fb_ioctl,
 };
 
+/**
+ * s3c_fb_missing_pixclock() - calculates pixel clock
+ * @mode: The video mode to change.
+ *
+ * Calculate the pixel clock when none has been given through platform data.
+ */
+static void __devinit s3c_fb_missing_pixclock(struct fb_videomode *mode)
+{
+       u64 pixclk = 1000000000000ULL;
+       u32 div;
+
+       div  = mode->left_margin + mode->hsync_len + mode->right_margin +
+              mode->xres;
+       div *= mode->upper_margin + mode->vsync_len + mode->lower_margin +
+              mode->yres;
+       div *= mode->refresh ? : 60;
+
+       do_div(pixclk, div);
+
+       mode->pixclock = pixclk;
+}
+
 /**
  * s3c_fb_alloc_memory() - allocate display memory for framebuffer window
  * @sfb: The base resources for the hardware.
@@ -1091,7 +1120,15 @@ static void s3c_fb_free_memory(struct s3c_fb *sfb, struct s3c_fb_win *win)
  */
 static void s3c_fb_release_win(struct s3c_fb *sfb, struct s3c_fb_win *win)
 {
+       u32 data;
+
        if (win->fbinfo) {
+               if (sfb->variant.has_shadowcon) {
+                       data = readl(sfb->regs + SHADOWCON);
+                       data &= ~SHADOWCON_CHx_ENABLE(win->index);
+                       data &= ~SHADOWCON_CHx_LOCAL_ENABLE(win->index);
+                       writel(data, sfb->regs + SHADOWCON);
+               }
                unregister_framebuffer(win->fbinfo);
                if (win->fbinfo->cmap.len)
                        fb_dealloc_cmap(&win->fbinfo->cmap);
@@ -1349,6 +1386,9 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
                if (!pd->win[win])
                        continue;
 
+               if (!pd->win[win]->win_mode.pixclock)
+                       s3c_fb_missing_pixclock(&pd->win[win]->win_mode);
+
                ret = s3c_fb_probe_win(sfb, win, fbdrv->win[win],
                                       &sfb->windows[win]);
                if (ret < 0) {