int s3cfb_set_alpha_blending(struct s3cfb_global *ctrl, int id) { struct s3c_platform_fb *pdata = to_fb_plat(ctrl->dev); struct s3cfb_window *win = ctrl->fb[id]->par; struct s3cfb_alpha *alpha = &win->alpha; u32 avalue = 0, cfg; u32 shw; if (id == 0) { dev_err(ctrl->dev, "[fb%d] does not support alpha blending\n", id); return -EINVAL; } if ((pdata->hw_ver == 0x62) || (pdata->hw_ver == 0x70)) { shw = readl(ctrl->regs + S3C_WINSHMAP); shw |= S3C_WINSHMAP_PROTECT(id); writel(shw, ctrl->regs + S3C_WINSHMAP); } cfg = readl(ctrl->regs + S3C_WINCON(id)); cfg &= ~(S3C_WINCON_BLD_MASK | S3C_WINCON_ALPHA_SEL_MASK); if (alpha->mode == PIXEL_BLENDING) { dev_dbg(ctrl->dev, "[fb%d] alpha mode: pixel blending\n", id); /* fixing to DATA[31:24] for alpha value */ cfg |= (S3C_WINCON_BLD_PIXEL | S3C_WINCON_ALPHA1_SEL); } else { dev_dbg(ctrl->dev, "[fb%d] alpha mode: plane %d blending\n", id, alpha->channel); cfg |= S3C_WINCON_BLD_PLANE; if (alpha->channel == 0) { cfg |= S3C_WINCON_ALPHA0_SEL; avalue = (alpha->value << S3C_VIDOSD_ALPHA0_SHIFT); } else { cfg |= S3C_WINCON_ALPHA1_SEL; avalue = (alpha->value << S3C_VIDOSD_ALPHA1_SHIFT); } } writel(cfg, ctrl->regs + S3C_WINCON(id)); writel(avalue, ctrl->regs + S3C_VIDOSD_C(id)); if ((pdata->hw_ver == 0x62) || (pdata->hw_ver == 0x70)) { shw = readl(ctrl->regs + S3C_WINSHMAP); shw &= ~(S3C_WINSHMAP_PROTECT(id)); writel(shw, ctrl->regs + S3C_WINSHMAP); } return 0; }
int s3cfb_set_oneshot(struct s3cfb_global *ctrl, int id) { /* s3cfb_set_window_position */ struct s3c_platform_fb *pdata = to_fb_plat(ctrl->dev); struct fb_var_screeninfo *var = &ctrl->fb[id]->var; struct s3cfb_window *win = ctrl->fb[id]->par; u32 cfg, shw; u32 offset = (var->xres_virtual - var->xres) * var->bits_per_pixel / 8; /* Shadow Register Protection */ if ((pdata->hw_ver == 0x62) || (pdata->hw_ver == 0x70)) { shw = readl(ctrl->regs + S3C_WINSHMAP); shw |= S3C_WINSHMAP_PROTECT(id); writel(shw, ctrl->regs + S3C_WINSHMAP); } cfg = S3C_VIDOSD_LEFT_X(win->x) | S3C_VIDOSD_TOP_Y(win->y); writel(cfg, ctrl->regs + S3C_VIDOSD_A(id)); cfg = S3C_VIDOSD_RIGHT_X(win->x + var->xres - 1) | S3C_VIDOSD_BOTTOM_Y(win->y + var->yres - 1); writel(cfg, ctrl->regs + S3C_VIDOSD_B(id)); dev_dbg(ctrl->dev, "[fb%d] offset: (%d, %d, %d, %d)\n", id, win->x, win->y, win->x + var->xres - 1, win->y + var->yres - 1); /* s3cfb_set_window_size */ if (id <= 2) { cfg = S3C_VIDOSD_SIZE(var->xres * var->yres); if (id == 0) writel(cfg, ctrl->regs + S3C_VIDOSD_C(id)); else writel(cfg, ctrl->regs + S3C_VIDOSD_D(id)); dev_dbg(ctrl->dev, "[fb%d] resolution: %d x %d\n", id, var->xres, var->yres); } /* s3cfb_set_buffer_size */ cfg = S3C_VIDADDR_PAGEWIDTH(var->xres * var->bits_per_pixel / 8); cfg |= S3C_VIDADDR_OFFSIZE(offset); writel(cfg, ctrl->regs + S3C_VIDADDR_SIZE(id)); /* Shadow Register Un-Protection */ if ((pdata->hw_ver == 0x62) || (pdata->hw_ver == 0x70)) { shw = readl(ctrl->regs + S3C_WINSHMAP); shw &= ~(S3C_WINSHMAP_PROTECT(id)); writel(shw, ctrl->regs + S3C_WINSHMAP); } return 0; }
int s3cfb_set_window_size(struct s3cfb_global *ctrl, int id) { struct fb_var_screeninfo *var = &ctrl->fb[id]->var; u32 cfg; if (id > 2) return 0; cfg = S3C_VIDOSD_SIZE(var->xres * var->yres); if (id == 0) writel(cfg, ctrl->regs + S3C_VIDOSD_C(id)); else writel(cfg, ctrl->regs + S3C_VIDOSD_D(id)); dev_dbg(ctrl->dev, "[fb%d] resolution: %d x %d\n", id, var->xres, var->yres); return 0; }
int s3cfb_set_alpha_blending(struct s3cfb_global *ctrl, int id) { struct s3cfb_window *win = ctrl->fb[id]->par; struct s3cfb_alpha *alpha = &win->alpha; unsigned int avalue = 0, cfg; if (id == 0) { dev_err(ctrl->dev, "[fb%d] does not support alpha blending\n", id); return -EINVAL; } cfg = readl(ctrl->regs + S3C_WINCON(id)); cfg &= ~(S3C_WINCON_BLD_MASK | S3C_WINCON_ALPHA_SEL_MASK); if (alpha->mode == PIXEL_BLENDING) { dev_dbg(ctrl->dev, "[fb%d] alpha mode: pixel blending\n", id); /* fixing to DATA[31:24] for alpha value */ cfg |= (S3C_WINCON_BLD_PIXEL | S3C_WINCON_ALPHA1_SEL); } else { dev_dbg(ctrl->dev, "[fb%d] alpha mode: plane %d blending\n", id, alpha->channel); cfg |= S3C_WINCON_BLD_PLANE; if (alpha->channel == 0) { cfg |= S3C_WINCON_ALPHA0_SEL; avalue = (alpha->value << S3C_VIDOSD_ALPHA0_SHIFT); } else { cfg |= S3C_WINCON_ALPHA1_SEL; avalue = (alpha->value << S3C_VIDOSD_ALPHA1_SHIFT); } } writel(cfg, ctrl->regs + S3C_WINCON(id)); writel(avalue, ctrl->regs + S3C_VIDOSD_C(id)); return 0; }
int s3cfb_set_oneshot(struct s3cfb_global *ctrl, int id) { struct s3c_platform_fb *pdata = to_fb_plat(ctrl->dev); struct fb_var_screeninfo *var = &ctrl->fb[id]->var; struct fb_fix_screeninfo *fix = &ctrl->fb[id]->fix; struct s3cfb_window *win = ctrl->fb[id]->par; u32 cfg, shw; u32 offset = (var->xres_virtual - var->xres) * var->bits_per_pixel / 8; dma_addr_t start_addr = 0, end_addr = 0; /* Shadow Register Protection */ if ((pdata->hw_ver == 0x62) || (pdata->hw_ver == 0x70)) { shw = readl(ctrl->regs + S3C_WINSHMAP); shw |= S3C_WINSHMAP_PROTECT(id); writel(shw, ctrl->regs + S3C_WINSHMAP); } /* s3cfb_set_window_position */ cfg = S3C_VIDOSD_LEFT_X(win->x) | S3C_VIDOSD_TOP_Y(win->y); writel(cfg, ctrl->regs + S3C_VIDOSD_A(id)); cfg = S3C_VIDOSD_RIGHT_X(win->x + var->xres - 1) | S3C_VIDOSD_BOTTOM_Y(win->y + var->yres - 1); writel(cfg, ctrl->regs + S3C_VIDOSD_B(id)); dev_dbg(ctrl->dev, "[fb%d] offset: (%d, %d, %d, %d)\n", id, win->x, win->y, win->x + var->xres - 1, win->y + var->yres - 1); /* s3cfb_set_buffer_address */ if (fix->smem_start) { start_addr = fix->smem_start + ((var->xres_virtual * var->yoffset + var->xoffset) * (var->bits_per_pixel / 8)); end_addr = start_addr + fix->line_length * var->yres; } writel(start_addr, ctrl->regs + S3C_VIDADDR_START0(id)); writel(end_addr, ctrl->regs + S3C_VIDADDR_END0(id)); dev_dbg(ctrl->dev, "[fb%d] start_addr: 0x%08x, end_addr: 0x%08x\n", id, start_addr, end_addr); /* s3cfb_set_window_size */ if (id <= 2) { cfg = S3C_VIDOSD_SIZE(var->xres * var->yres); if (id == 0) writel(cfg, ctrl->regs + S3C_VIDOSD_C(id)); else writel(cfg, ctrl->regs + S3C_VIDOSD_D(id)); dev_dbg(ctrl->dev, "[fb%d] resolution: %d x %d\n", id, var->xres, var->yres); } /* s3cfb_set_buffer_size */ cfg = S3C_VIDADDR_PAGEWIDTH(var->xres * var->bits_per_pixel / 8); cfg |= S3C_VIDADDR_OFFSIZE(offset); writel(cfg, ctrl->regs + S3C_VIDADDR_SIZE(id)); /* Shadow Register Un-Protection */ if ((pdata->hw_ver == 0x62) || (pdata->hw_ver == 0x70)) { shw = readl(ctrl->regs + S3C_WINSHMAP); shw &= ~(S3C_WINSHMAP_PROTECT(id)); writel(shw, ctrl->regs + S3C_WINSHMAP); } return 0; }