rk3036 lcdc&tve: fix driver load error.
authorZheng Yang <zhengyang@rock-chips.com>
Sat, 12 Jul 2014 03:29:03 +0000 (11:29 +0800)
committerZheng Yang <zhengyang@rock-chips.com>
Sat, 12 Jul 2014 03:29:03 +0000 (11:29 +0800)
arch/arm/boot/dts/rk3036-sdk.dts
arch/arm/boot/dts/rk3036.dtsi
drivers/video/rockchip/display-sys.c
drivers/video/rockchip/lcdc/rk3036_lcdc.c
drivers/video/rockchip/rk_fb.c
drivers/video/rockchip/tve/rk3036/Kconfig
drivers/video/rockchip/tve/rk3036/rk3036_tve.c

index 6a64e8cb879a330b478a07d188f45588734316f0..d11cd215663d9475e7165fb6614088b5af7b3b72 100755 (executable)
 &lcdc {
        status = "okay";
 };
+
+&tve {
+       status = "okay";
+};
index ab609658bd3b990c1a7206936f9baf0af723b4ce..a074217b419bb5bf40fcdb85c2e1016bdf9a26e7 100755 (executable)
        
        lcdc: lcdc@10118000 {
                compatible = "rockchip,rk3036-lcdc";
-               reg = <0x10118000 0x4000>;
+               reg = <0x10118000 0x200>;
                interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
                clocks = <&clk_gates9 6>, <&dclk_lcdc1>, <&clk_gates9 5>;
                status = "disabled";
        };
 
-       tve {
+       tve: tve{
                compatible = "rockchip,rk3036-tve";
                reg = <0x10118200 0x100>;
                status = "disabled";
index 932cec6853e43c1bc662173891ff2a791abfb745..0fbb96fe910ea75c5d09d8a9e8b79cb49bf7036e 100644 (file)
@@ -224,12 +224,12 @@ static int display_resume(struct device *dev)
 
 void rk_display_device_enable(struct rk_display_device *ddev)
 {
-#ifndef CONFIG_DISPLAY_AUTO_SWITCH     
-       return;
-#else
+//#ifndef CONFIG_DISPLAY_AUTO_SWITCH   
+//     return;
+//#else
        struct list_head *pos, *head = &display_device_list;
        struct rk_display_device *dev = NULL, *dev_enabled = NULL, *dev_enable = NULL;
-       int enable = 0,connect, has_connect = 0;
+       int enable = 0,connect;
        
        list_for_each(pos, head) {
                dev = list_entry(pos, struct rk_display_device, list);
@@ -257,7 +257,7 @@ void rk_display_device_enable(struct rk_display_device *ddev)
        }
                
 
-#endif
+//#endif
 }
 EXPORT_SYMBOL(rk_display_device_enable);
 
index 0b729551bbc58579bc4403afbc2a0b0fff40085f..2be4bd4f7a51a918f07a739cdce0c86eacf352e0 100644 (file)
@@ -1209,9 +1209,8 @@ static struct rk_lcdc_drv_ops lcdc_drv_ops = {
 
 static int rk3036_lcdc_parse_dt(struct lcdc_device *lcdc_dev)
 {
-       struct device_node *np = lcdc_dev->dev->of_node;
-
 #if defined(CONFIG_ROCKCHIP_IOMMU)
+       struct device_node *np = lcdc_dev->dev->of_node;
        int val;
        if (of_property_read_u32(np, "rockchip,iommu-enabled", &val))
                lcdc_dev->driver.iommu_enabled = 0;
@@ -1230,7 +1229,7 @@ static int rk3036_lcdc_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct resource *res;
        int ret;
-       
+
        lcdc_dev = devm_kzalloc(dev,
                                sizeof(struct lcdc_device), GFP_KERNEL);
        if (!lcdc_dev) {
@@ -1255,7 +1254,7 @@ static int rk3036_lcdc_probe(struct platform_device *pdev)
        dev_set_name(lcdc_dev->dev, "lcdc%d", lcdc_dev->id);
        dev_drv = &lcdc_dev->driver;
        dev_drv->dev = dev;
-       dev_drv->prop = 0;
+       dev_drv->prop = PRMRY;
        dev_drv->id = lcdc_dev->id;
        dev_drv->ops = &lcdc_drv_ops;
        dev_drv->lcdc_win_num = ARRAY_SIZE(lcdc_win);
index e6d061fface288f702937b3fc66b52d4091372d5..3cacdd847a41b0a15d6e3d43dc70a80a920c0980 100755 (executable)
@@ -686,6 +686,7 @@ static int rk_fb_open(struct fb_info *info, int user)
        int win_id;
 
        win_id = dev_drv->ops->fb_get_win_id(dev_drv, info->fix.id);
+       dev_drv->win[win_id]->logicalstate++;
        /* if this win aready opened ,no need to reopen */
        if (dev_drv->win[win_id]->state)
                return 0;
@@ -714,32 +715,35 @@ static int rk_fb_close(struct fb_info *info, int user)
        struct rk_lcdc_win *win = NULL;
        int win_id = dev_drv->ops->fb_get_win_id(dev_drv, info->fix.id);
        if (win_id >= 0) {
-               win = dev_drv->win[win_id];
-               info->fix.smem_start = win->reserved;
-
-               info->var.xres = dev_drv->screen0->mode.xres;
-               info->var.yres = dev_drv->screen0->mode.yres;
-               info->var.grayscale |=
-                   (info->var.xres << 8) + (info->var.yres << 20);
-               info->var.xres_virtual = info->var.xres;
-               info->var.yres_virtual = info->var.yres;
+               dev_drv->win[win_id]->logicalstate--;
+               if(!dev_drv->win[win_id]->logicalstate) {
+                       win = dev_drv->win[win_id];
+                       info->fix.smem_start = win->reserved;
+       
+                       info->var.xres = dev_drv->screen0->mode.xres;
+                       info->var.yres = dev_drv->screen0->mode.yres;
+                       info->var.grayscale |=
+                           (info->var.xres << 8) + (info->var.yres << 20);
+                       info->var.xres_virtual = info->var.xres;
+                       info->var.yres_virtual = info->var.yres;
 #if defined(CONFIG_LOGO_LINUX_BMP)
-               info->var.bits_per_pixel = 32;
+                       info->var.bits_per_pixel = 32;
 #else
-               info->var.bits_per_pixel = 16;
+                       info->var.bits_per_pixel = 16;
 #endif
-
-               info->fix.line_length =
-                   (info->var.xres_virtual) * (info->var.bits_per_pixel >> 3);
-               info->var.width = dev_drv->screen0->width;
-               info->var.height = dev_drv->screen0->height;
-               info->var.pixclock = dev_drv->pixclock;
-               info->var.left_margin = dev_drv->screen0->mode.left_margin;
-               info->var.right_margin = dev_drv->screen0->mode.right_margin;
-               info->var.upper_margin = dev_drv->screen0->mode.upper_margin;
-               info->var.lower_margin = dev_drv->screen0->mode.lower_margin;
-               info->var.vsync_len = dev_drv->screen0->mode.vsync_len;
-               info->var.hsync_len = dev_drv->screen0->mode.hsync_len;
+       
+                       info->fix.line_length =
+                           (info->var.xres_virtual) * (info->var.bits_per_pixel >> 3);
+                       info->var.width = dev_drv->screen0->width;
+                       info->var.height = dev_drv->screen0->height;
+                       info->var.pixclock = dev_drv->pixclock;
+                       info->var.left_margin = dev_drv->screen0->mode.left_margin;
+                       info->var.right_margin = dev_drv->screen0->mode.right_margin;
+                       info->var.upper_margin = dev_drv->screen0->mode.upper_margin;
+                       info->var.lower_margin = dev_drv->screen0->mode.lower_margin;
+                       info->var.vsync_len = dev_drv->screen0->mode.vsync_len;
+                       info->var.hsync_len = dev_drv->screen0->mode.hsync_len;
+               }
        }
 
        return 0;
index c39ed5d6dabd0a4cefda58bb40826bbde814df08..1f023116651848ca5bef2481ecc7914a7008ab24 100644 (file)
@@ -1,6 +1,6 @@
 config RK3036_TV_ENCODER
        bool "rk3036 tv encoder support"
-       depends on LCDC_RK3036
+       depends on LCDC_RK3036 && RK_TVENCODER
        default n
        help
                Support RK3036 output CVBS.
index ebe29da4840620fb04f8f9918915eac63c14f969..5ea55fbdede506eb4d682adf2597bfafeab94a5e 100644 (file)
 #include <linux/rockchip/iomap.h>
 #include "rk3036_tve.h"
 
+#define DEBUG
+#ifdef DEBUG
+#define TVEDBG(format, ...) \
+               printk(KERN_INFO "RK3036 TVE: " format "\n", ## __VA_ARGS__)
+#else
+#define TVEDBG(format, ...)
+#endif
 
 static const struct fb_videomode rk3036_cvbs_mode [] = {
        /*      name            refresh xres    yres    pixclock        h_bp    h_fp    v_bp    v_fp    h_pw    v_pw    polariry        PorI            flag*/
-       {       "NTSC",         60,     720,    480,    27000000,       69,     12,     19,     2,      63,     3,      0,      FB_VMODE_INTERLACED,    0},
-       {       "PAL",          50,     720,    576,    27000000,       57,     19,     19,     0,      62,     3,      0,      FB_VMODE_INTERLACED,    0},
+       {       "NTSC",         60,     720,    576,    27000000,       57,     19,     19,     0,      62,     3,      0,      FB_VMODE_INTERLACED,    0},
+       {       "PAL",          50,     720,    480,    27000000,       69,     12,     19,     2,      63,     3,      0,      FB_VMODE_INTERLACED,    0},
 };
 
 static struct rk3036_tve *rk3036_tve = NULL;
@@ -36,6 +43,9 @@ static struct rk3036_tve *rk3036_tve = NULL;
 static void dac_enable(bool enable)
 {
        u32 mask, val;
+       
+       TVEDBG("%s enable %d\n", __FUNCTION__, enable);
+       
        if(enable) {
                mask = m_VBG_EN | m_DAC_EN;
                val = mask;
@@ -48,6 +58,8 @@ static void dac_enable(bool enable)
 
 static void tve_set_mode (int mode)
 {
+       TVEDBG("%s mode %d\n", __FUNCTION__, mode);
+       
        tve_writel(TV_RESET, v_RESET(1));
        udelay(100);
        tve_writel(TV_RESET, v_RESET(0));
@@ -145,6 +157,7 @@ static int tve_switch_fb(const struct fb_videomode *modedb, int enable)
 
 static int cvbs_set_enable(struct rk_display_device *device, int enable)
 {
+       TVEDBG("%s enable %d\n", __FUNCTION__, enable);
        if(rk3036_tve->enable != enable)
        {
                rk3036_tve->enable = enable;
@@ -165,16 +178,19 @@ static int cvbs_set_enable(struct rk_display_device *device, int enable)
 
 static int cvbs_get_enable(struct rk_display_device *device)
 {
+       TVEDBG("%s enable %d\n", __FUNCTION__, rk3036_tve->enable);
        return rk3036_tve->enable;
 }
 
 static int cvbs_get_status(struct rk_display_device *device)
 {
+       TVEDBG("%s \n", __FUNCTION__);
        return 1;
 }
 
 static int cvbs_get_modelist(struct rk_display_device *device, struct list_head **modelist)
 {
+       TVEDBG("%s \n", __FUNCTION__);
        *modelist = &(rk3036_tve->modelist);
        return 0;
 }
@@ -182,7 +198,7 @@ static int cvbs_get_modelist(struct rk_display_device *device, struct list_head
 static int cvbs_set_mode(struct rk_display_device *device, struct fb_videomode *mode)
 {
        int i;
-
+       TVEDBG("%s \n", __FUNCTION__);
        for(i = 0; i < ARRAY_SIZE(rk3036_cvbs_mode); i++)
        {
                if(fb_mode_is_equal(&rk3036_cvbs_mode[i], mode))
@@ -256,7 +272,7 @@ static int rk3036_tve_probe(struct platform_device *pdev)
        INIT_LIST_HEAD(&(rk3036_tve->modelist));
        for(i = 0; i < ARRAY_SIZE(rk3036_cvbs_mode); i++)
                fb_add_videomode(&rk3036_cvbs_mode[i], &(rk3036_tve->modelist));
-
+       rk3036_tve->mode = (struct fb_videomode*)&rk3036_cvbs_mode[1];
        rk3036_tve->ddev = rk_display_device_register(&display_cvbs, &pdev->dev, NULL);
        rk_display_device_enable(rk3036_tve->ddev);