video: rockchip: fb: no need close all win when hdmi switch screen at first time
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / rk_fb.c
index d7aad15415d2c837e2cea0792d02f3673672057b..c8393580a0591778ece9416f72190590b7192b06 100644 (file)
@@ -31,6 +31,8 @@
 #include <linux/linux_logo.h>
 #include <linux/dma-mapping.h>
 #include <linux/regulator/consumer.h>
+#include <linux/of_address.h>
+#include <linux/memblock.h>
 
 #include "bmp_helper.h"
 
@@ -2227,8 +2229,10 @@ static int rk_fb_set_win_buffer(struct fb_info *info,
                                    ion_import_dma_buf(rk_fb->ion_client,
                                                       ion_fd);
                                if (IS_ERR(hdl)) {
-                                       pr_info("%s: Could not import handle:"
-                                               " %ld\n", __func__, (long)hdl);
+                                       pr_info("%s: win[%d]area[%d] can't import handle\n",
+                                               __func__, win_par->win_id, i);
+                                       pr_info("fd: %d, hdl: 0x%p, ion_client: 0x%p\n",
+                                               ion_fd, hdl, rk_fb->ion_client);
                                        return -EINVAL;
                                        break;
                                }
@@ -2648,6 +2652,7 @@ err_null_frame:
        win_data->ret_fence_fd = -1;
        pr_info("win num = %d,null frame\n", regs->win_num);
 err2:
+       rk_fb_config_debug(dev_drv, win_data, regs, 0);
        kfree(regs);
        mutex_unlock(&dev_drv->output_lock);
 
@@ -3627,7 +3632,6 @@ int rk_fb_switch_screen(struct rk_screen *screen, int enable, int lcdc_id)
                        /* If there is more than one lcdc device, we disable
                         *  the layer which attached to this device
                         */
-                       dev_drv->suspend_flag = 1;
                        flush_kthread_worker(&dev_drv->update_regs_worker);
                        for (i = 0; i < dev_drv->lcdc_win_num; i++) {
                                if (dev_drv->win[i] && dev_drv->win[i]->state)
@@ -3641,6 +3645,13 @@ int rk_fb_switch_screen(struct rk_screen *screen, int enable, int lcdc_id)
                mutex_unlock(&dev_drv->switch_screen);
                return 0;
        } else {
+               if (load_screen || (rk_fb->disp_policy != DISPLAY_POLICY_BOX)) {
+                       for (i = 0; i < dev_drv->lcdc_win_num; i++) {
+                               if (dev_drv->win[i] && dev_drv->win[i]->state &&
+                                       dev_drv->ops->win_direct_en)
+                                       dev_drv->ops->win_direct_en(dev_drv, i, 0);
+                       }
+               }
                if (dev_drv->uboot_logo) {
                        if (dev_drv->cur_screen->mode.xres !=
                                screen->mode.xres ||
@@ -3657,6 +3668,7 @@ int rk_fb_switch_screen(struct rk_screen *screen, int enable, int lcdc_id)
                dev_drv->cur_screen->x_mirror = dev_drv->rotate_mode & X_MIRROR;
                dev_drv->cur_screen->y_mirror = dev_drv->rotate_mode & Y_MIRROR;
        }
+
        if (!dev_drv->uboot_logo || load_screen ||
            (rk_fb->disp_policy != DISPLAY_POLICY_BOX)) {
                for (i = 0; i < dev_drv->lcdc_win_num; i++) {
@@ -3693,7 +3705,7 @@ int rk_fb_switch_screen(struct rk_screen *screen, int enable, int lcdc_id)
                                        dev_drv->ops->cfg_done(dev_drv);
                                } else if (!dev_drv->win[win_id]->state) {
                                        dev_drv->ops->open(dev_drv, win_id, 1);
-                                       dev_drv->suspend_flag = 0;
+                                       /* dev_drv->suspend_flag = 0; */
                                        /* mutex_lock(&dev_drv->win_config);
                                         * info->var.xoffset = 0;
                                         * info->var.yoffset = 0;
@@ -4127,9 +4139,28 @@ bool is_prmry_rk_lcdc_registered(void)
                return false;
 }
 
-__weak phys_addr_t uboot_logo_base;
-__weak phys_addr_t uboot_logo_size;
-__weak phys_addr_t uboot_logo_offset;
+phys_addr_t uboot_logo_base;
+phys_addr_t uboot_logo_size;
+phys_addr_t uboot_logo_offset;
+
+static int __init rockchip_uboot_mem_late_init(void)
+{
+       int err;
+
+       if (uboot_logo_size) {
+               void *start = phys_to_virt(uboot_logo_base);
+               void *end = phys_to_virt(uboot_logo_base + uboot_logo_size);
+
+               err = memblock_free(uboot_logo_base, uboot_logo_size);
+               if (err < 0)
+                       pr_err("%s: freeing memblock failed: %d\n",
+                              __func__, err);
+               free_reserved_area(start, end, -1, "logo");
+       }
+       return 0;
+}
+
+late_initcall(rockchip_uboot_mem_late_init);
 
 int rk_fb_register(struct rk_lcdc_driver *dev_drv,
                   struct rk_lcdc_win *win, int id)
@@ -4293,8 +4324,7 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
                                start += PAGE_SIZE;
                                i++;
                        }
-                       vaddr = vmap(pages, nr_pages, VM_MAP,
-                                    pgprot_writecombine(PAGE_KERNEL));
+                       vaddr = vmap(pages, nr_pages, VM_MAP, PAGE_KERNEL);
                        if (!vaddr) {
                                pr_err("failed to vmap phy addr 0x%lx\n",
                                       (long)(uboot_logo_base +
@@ -4368,8 +4398,7 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
                                start += PAGE_SIZE;
                                i++;
                        }
-                       vaddr = vmap(pages, nr_pages, VM_MAP,
-                                    pgprot_writecombine(PAGE_KERNEL));
+                       vaddr = vmap(pages, nr_pages, VM_MAP, PAGE_KERNEL);
                        if (!vaddr) {
                                pr_err("failed to vmap phy addr 0x%x\n",
                                       start);
@@ -4471,7 +4500,8 @@ static int rk_fb_probe(struct platform_device *pdev)
 {
        struct rk_fb *rk_fb = NULL;
        struct device_node *np = pdev->dev.of_node;
-       u32 mode;
+       u32 mode, ret;
+       struct device_node *node;
 
        if (!np) {
                dev_err(&pdev->dev, "Missing device tree node.\n");
@@ -4513,6 +4543,27 @@ static int rk_fb_probe(struct platform_device *pdev)
        }
 #endif
 
+       node = of_parse_phandle(np, "memory-region", 0);
+       if (node) {
+               struct resource r;
+
+               ret = of_address_to_resource(node, 0, &r);
+               if (ret)
+                       return ret;
+
+               if (uboot_logo_on) {
+                       uboot_logo_base = r.start;
+                       uboot_logo_size = resource_size(&r);
+
+                       if (uboot_logo_size > SZ_16M)
+                               uboot_logo_offset = SZ_16M;
+                       else
+                               uboot_logo_offset = 0;
+               }
+               pr_info("logo: base=0x%llx, size=0x%llx, offset=0x%llx\n",
+                       uboot_logo_base, uboot_logo_size, uboot_logo_offset);
+       }
+
        fb_pdev = pdev;
        dev_info(&pdev->dev, "rockchip framebuffer driver probe\n");
        return 0;