From b7bff6a27bb35b73a0a8258930b482a170a3701f Mon Sep 17 00:00:00 2001 From: hjc Date: Tue, 23 Dec 2014 14:26:48 +0800 Subject: [PATCH] rk fb: add win mirror pos config Signed-off-by: hjc --- drivers/video/rockchip/lcdc/rk3368_lcdc.c | 59 ++++++----------------- drivers/video/rockchip/rk_fb.c | 57 +++------------------- 2 files changed, 22 insertions(+), 94 deletions(-) diff --git a/drivers/video/rockchip/lcdc/rk3368_lcdc.c b/drivers/video/rockchip/lcdc/rk3368_lcdc.c index c80b5f3e0b04..305fef7bf24d 100644 --- a/drivers/video/rockchip/lcdc/rk3368_lcdc.c +++ b/drivers/video/rockchip/lcdc/rk3368_lcdc.c @@ -770,7 +770,8 @@ static int rk3368_lcdc_area_xst(struct rk_lcdc_win *win, int area_num) return 0; } -static int rk3368_lcdc_area_swap(struct rk_lcdc_win *win, int area_num) +static int __maybe_unused + rk3368_lcdc_area_swap(struct rk_lcdc_win *win, int area_num) { struct rk_lcdc_win_area area_temp; @@ -909,8 +910,8 @@ static int rk3368_init_fbdc_config(struct rk_lcdc_driver *dev_drv, int win_id) mb_w_size = 16; break; case VOP_FORMAT_RGB565: - mb_w_size = 32; fbdc_dsp_width_ratio = 1; + mb_w_size = 32; break; default: dev_err(lcdc_dev->dev, @@ -1136,15 +1137,10 @@ static int rk3368_win_2_3_reg_update(struct rk_lcdc_driver *dev_drv, int win_id) struct lcdc_device *lcdc_dev = container_of(dev_drv, struct lcdc_device, driver); struct rk_lcdc_win *win = dev_drv->win[win_id]; - struct rk_screen *screen = dev_drv->cur_screen; unsigned int mask, val, off; off = (win_id - 2) * 0x50; rk3368_lcdc_area_xst(win, win->area_num); - if (((screen->y_mirror == 1) || (win->mirror_en)) && - (win->area_num > 1)) { - rk3368_lcdc_area_swap(win, win->area_num); - } if (win->state == 1) { rk3368_lcdc_csc_mode(lcdc_dev, win); @@ -3740,10 +3736,10 @@ static int rk3368_lcdc_get_dsp_addr(struct rk_lcdc_driver *dev_drv, static struct lcdc_cabc_mode cabc_mode[4] = { /* pixel_num,8 stage_up, stage_down */ - {5, 148, 20, 300}, /*mode 1 */ - {10, 148, 20, 300}, /*mode 2 */ - {15, 148, 20, 300}, /*mode 3 */ - {20, 148, 20, 300}, /*mode 4 */ + {5, 282, 171, 300}, /*mode 1 */ + {10, 282, 171, 300}, /*mode 2 */ + {15, 282, 171, 300}, /*mode 3 */ + {20, 282, 171, 300}, /*mode 4 */ }; static int rk3368_lcdc_set_dsp_cabc(struct rk_lcdc_driver *dev_drv, int mode) @@ -3755,38 +3751,10 @@ static int rk3368_lcdc_set_dsp_cabc(struct rk_lcdc_driver *dev_drv, int mode) u32 pixel_num, global_su; u32 stage_up_rec, stage_down_rec, global_su_rec; u32 mask = 0, val = 0, cabc_en = 0; - u32 __maybe_unused max_mode_num = - sizeof(cabc_mode) / sizeof(struct lcdc_cabc_mode); dev_drv->cabc_mode = mode; -#if 0/*ndef CONFIG_RK_FPGA*/ - /* iomux connect to vop or pwm */ - if (mode == 0) { - DBG(3, "close cabc and select rk pwm\n"); - val = 0x30002; - writel_relaxed(val, RK_GRF_VIRT + rk3368_GRF_GPIO3C_IOMUX); - cabc_en = 0; - } else if (mode > 0 && mode <= max_mode_num) { - DBG(3, "open cabc and select vop pwm\n"); - val = 0x30003; - writel_relaxed(val, RK_GRF_VIRT + rk3368_GRF_GPIO3C_IOMUX); - cabc_en = 1; - } else if (mode > 0x10 && mode <= (max_mode_num + 0x10)) { - DBG(3, "open cabc and select rk pwm\n"); - val = 0x30003; - writel_relaxed(val, RK_GRF_VIRT + rk3368_GRF_GPIO3C_IOMUX); - cabc_en = 1; - mode -= 0x10; - } else if (mode == 0xff) { - DBG(3, "close cabc and select vop pwm\n"); - val = 0x30002; - writel_relaxed(val, RK_GRF_VIRT + rk3368_GRF_GPIO3C_IOMUX); - cabc_en = 0; - } else { - dev_err(lcdc_dev->dev, "invalid cabc mode value:%d", mode); - return 0; - } -#endif + cabc_en = (mode > 0) ? 1 : 0; + if (cabc_en == 0) { spin_lock(&lcdc_dev->reg_lock); if (lcdc_dev->clk_on) { @@ -3811,12 +3779,13 @@ static int rk3368_lcdc_set_dsp_cabc(struct rk_lcdc_driver *dev_drv, int mode) spin_lock(&lcdc_dev->reg_lock); if (lcdc_dev->clk_on) { - mask = m_CABC_CALC_PIXEL_NUM; - val = v_CABC_CALC_PIXEL_NUM(calc_pixel); + mask = m_CABC_CALC_PIXEL_NUM | m_CABC_EN; + val = v_CABC_CALC_PIXEL_NUM(calc_pixel) | + v_CABC_EN(cabc_en); lcdc_msk_reg(lcdc_dev, CABC_CTRL0, mask, val); - mask = m_CABC_TOTAL_PIXEL_NUM; - val = v_CABC_TOTAL_PIXEL_NUM(total_pixel); + mask = m_CABC_TOTAL_PIXEL_NUM | m_CABC_LUT_EN; + val = v_CABC_TOTAL_PIXEL_NUM(total_pixel) | v_CABC_LUT_EN(0); lcdc_msk_reg(lcdc_dev, CABC_CTRL1, mask, val); mask = m_CABC_STAGE_UP | m_CABC_STAGE_UP_REC | diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index bd7429b3e8cf..a5c6a3c29baa 100644 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -1431,7 +1431,8 @@ static int rk_fb_pan_display(struct fb_var_screeninfo *var, } /* x y mirror ,jump line */ - if (screen->y_mirror == 1) { + if ((screen->y_mirror == 1) || + (win->mirror_en == 1)) { if (screen->interlace == 1) { win->area[0].y_offset = yoffset * stride * 2 + ((win->area[0].yact - 1) * 2 + 1) * stride + @@ -1451,7 +1452,8 @@ static int rk_fb_pan_display(struct fb_var_screeninfo *var, } } if (is_pic_yuv == 1) { - if (screen->y_mirror == 1) { + if ((screen->y_mirror == 1) || + (win->mirror_en == 1)) { if (screen->interlace == 1) { win->area[0].c_offset = uv_y_off * uv_stride * 2 + @@ -3258,51 +3260,6 @@ static int rk_fb_set_par(struct fb_info *info) break; } - /* x y mirror ,jump line */ - if (screen->y_mirror == 1) { - if (screen->interlace == 1) { - win->area[0].y_offset = yoffset * stride * 2 + - ((win->area[0].yact - 1) * 2 + 1) * stride + - xoffset * pixel_width / 8; - } else { - win->area[0].y_offset = yoffset * stride + - (win->area[0].yact - 1) * stride + - xoffset * pixel_width / 8; - } - } else { - if (screen->interlace == 1) { - win->area[0].y_offset = - yoffset * stride * 2 + xoffset * pixel_width / 8; - } else { - win->area[0].y_offset = - yoffset * stride + xoffset * pixel_width / 8; - } - } - if (is_pic_yuv == 1) { - if (screen->y_mirror == 1) { - if (screen->interlace == 1) { - win->area[0].c_offset = - uv_y_off * uv_stride * 2 + - ((uv_y_act - 1) * 2 + 1) * uv_stride + - uv_x_off * pixel_width / 8; - } else { - win->area[0].c_offset = uv_y_off * uv_stride + - (uv_y_act - 1) * uv_stride + - uv_x_off * pixel_width / 8; - } - } else { - if (screen->interlace == 1) { - win->area[0].c_offset = - uv_y_off * uv_stride * 2 + - uv_x_off * pixel_width / 8; - } else { - win->area[0].c_offset = - uv_y_off * uv_stride + - uv_x_off * pixel_width / 8; - } - } - } - win->area[0].format = fb_data_fmt; win->area[0].y_vir_stride = stride >> 2; win->area[0].uv_vir_stride = uv_stride >> 2; @@ -3577,7 +3534,8 @@ int rk_fb_switch_screen(struct rk_screen *screen, int enable, int lcdc_id) dev_drv->ops->backlight_close(dev_drv, 1); if (dev_drv->ops->dsp_black) dev_drv->ops->dsp_black(dev_drv, 1); - if (dev_drv->ops->set_screen_scaler) + if ((dev_drv->ops->set_screen_scaler) && + (rk_fb->disp_policy != DISPLAY_POLICY_BOX)) dev_drv->ops->set_screen_scaler(dev_drv, dev_drv->screen0, 0); } @@ -3673,7 +3631,8 @@ int rk_fb_switch_screen(struct rk_screen *screen, int enable, int lcdc_id) } hdmi_switch_complete = 1; if ((rk_fb->disp_mode == ONE_DUAL) || (rk_fb->disp_mode == NO_DUAL)) { - if (dev_drv->ops->set_screen_scaler) + if ((dev_drv->ops->set_screen_scaler) && + (rk_fb->disp_policy != DISPLAY_POLICY_BOX)) dev_drv->ops->set_screen_scaler(dev_drv, dev_drv->screen0, 1); if (dev_drv->ops->dsp_black) dev_drv->ops->dsp_black(dev_drv, 0); -- 2.34.1