Commit 9dd38819 authored by Phil Edworthy's avatar Phil Edworthy Committed by Paul Mundt

video: sh_mobile_lcdcfb: implement display panning

Signed-off-by: default avatarPhil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent c8c2df90
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#define _LDSR 0x46c #define _LDSR 0x46c
#define _LDCNT1R 0x470 #define _LDCNT1R 0x470
#define _LDCNT2R 0x474 #define _LDCNT2R 0x474
#define _LDRCNTR 0x478
#define _LDDDSR 0x47c #define _LDDDSR 0x47c
#define _LDDWD0R 0x800 #define _LDDWD0R 0x800
#define _LDDRDR 0x840 #define _LDDRDR 0x840
...@@ -94,7 +95,11 @@ static unsigned long lcdc_offs_sublcd[NR_CH_REGS] = { ...@@ -94,7 +95,11 @@ static unsigned long lcdc_offs_sublcd[NR_CH_REGS] = {
#define DISPLAY_BEU 0x00000008 #define DISPLAY_BEU 0x00000008
#define LCDC_ENABLE 0x00000001 #define LCDC_ENABLE 0x00000001
#define LDINTR_FE 0x00000400 #define LDINTR_FE 0x00000400
#define LDINTR_VSE 0x00000200
#define LDINTR_VEE 0x00000100
#define LDINTR_FS 0x00000004 #define LDINTR_FS 0x00000004
#define LDINTR_VSS 0x00000002
#define LDINTR_VES 0x00000001
struct sh_mobile_lcdc_priv; struct sh_mobile_lcdc_priv;
struct sh_mobile_lcdc_chan { struct sh_mobile_lcdc_chan {
...@@ -110,6 +115,8 @@ struct sh_mobile_lcdc_chan { ...@@ -110,6 +115,8 @@ struct sh_mobile_lcdc_chan {
struct fb_deferred_io defio; struct fb_deferred_io defio;
struct scatterlist *sglist; struct scatterlist *sglist;
unsigned long frame_end; unsigned long frame_end;
unsigned long pan_offset;
unsigned long new_pan_offset;
wait_queue_head_t frame_end_wait; wait_queue_head_t frame_end_wait;
}; };
...@@ -266,25 +273,31 @@ static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data) ...@@ -266,25 +273,31 @@ static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data)
struct sh_mobile_lcdc_priv *priv = data; struct sh_mobile_lcdc_priv *priv = data;
struct sh_mobile_lcdc_chan *ch; struct sh_mobile_lcdc_chan *ch;
unsigned long tmp; unsigned long tmp;
unsigned long ldintr;
int is_sub; int is_sub;
int k; int k;
/* acknowledge interrupt */ /* acknowledge interrupt */
tmp = lcdc_read(priv, _LDINTR); ldintr = tmp = lcdc_read(priv, _LDINTR);
tmp &= 0xffffff00; /* mask in high 24 bits */ /*
tmp |= 0x000000ff ^ LDINTR_FS; /* status in low 8 */ * disable further VSYNC End IRQs, preserve all other enabled IRQs,
* write 0 to bits 0-6 to ack all triggered IRQs.
*/
tmp &= 0xffffff00 & ~LDINTR_VEE;
lcdc_write(priv, _LDINTR, tmp); lcdc_write(priv, _LDINTR, tmp);
/* figure out if this interrupt is for main or sub lcd */ /* figure out if this interrupt is for main or sub lcd */
is_sub = (lcdc_read(priv, _LDSR) & (1 << 10)) ? 1 : 0; is_sub = (lcdc_read(priv, _LDSR) & (1 << 10)) ? 1 : 0;
/* wake up channel and disable clocks*/ /* wake up channel and disable clocks */
for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
ch = &priv->ch[k]; ch = &priv->ch[k];
if (!ch->enabled) if (!ch->enabled)
continue; continue;
/* Frame Start */
if (ldintr & LDINTR_FS) {
if (is_sub == lcdc_chan_is_sublcd(ch)) { if (is_sub == lcdc_chan_is_sublcd(ch)) {
ch->frame_end = 1; ch->frame_end = 1;
wake_up(&ch->frame_end_wait); wake_up(&ch->frame_end_wait);
...@@ -293,6 +306,16 @@ static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data) ...@@ -293,6 +306,16 @@ static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data)
} }
} }
/* VSYNC End */
if (ldintr & LDINTR_VES) {
/* Set the source address for the next refresh */
lcdc_write_chan(ch, LDSA1R, ch->dma_handle +
ch->new_pan_offset);
lcdc_write(ch->lcdc, _LDRCNTR, 0);
ch->pan_offset = ch->new_pan_offset;
}
}
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -649,6 +672,9 @@ static struct fb_fix_screeninfo sh_mobile_lcdc_fix = { ...@@ -649,6 +672,9 @@ static struct fb_fix_screeninfo sh_mobile_lcdc_fix = {
.type = FB_TYPE_PACKED_PIXELS, .type = FB_TYPE_PACKED_PIXELS,
.visual = FB_VISUAL_TRUECOLOR, .visual = FB_VISUAL_TRUECOLOR,
.accel = FB_ACCEL_NONE, .accel = FB_ACCEL_NONE,
.xpanstep = 0,
.ypanstep = 1,
.ywrapstep = 0,
}; };
static void sh_mobile_lcdc_fillrect(struct fb_info *info, static void sh_mobile_lcdc_fillrect(struct fb_info *info,
...@@ -672,13 +698,38 @@ static void sh_mobile_lcdc_imageblit(struct fb_info *info, ...@@ -672,13 +698,38 @@ static void sh_mobile_lcdc_imageblit(struct fb_info *info,
sh_mobile_lcdc_deferred_io_touch(info); sh_mobile_lcdc_deferred_io_touch(info);
} }
static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info)
{
struct sh_mobile_lcdc_chan *ch = info->par;
if (info->var.xoffset == var->xoffset &&
info->var.yoffset == var->yoffset)
return 0; /* No change, do nothing */
ch->new_pan_offset = (var->yoffset * info->fix.line_length) +
(var->xoffset * (info->var.bits_per_pixel / 8));
if (ch->new_pan_offset != ch->pan_offset) {
unsigned long ldintr;
ldintr = lcdc_read(ch->lcdc, _LDINTR);
ldintr |= LDINTR_VEE;
lcdc_write(ch->lcdc, _LDINTR, ldintr);
sh_mobile_lcdc_deferred_io_touch(info);
}
return 0;
}
static struct fb_ops sh_mobile_lcdc_ops = { static struct fb_ops sh_mobile_lcdc_ops = {
.owner = THIS_MODULE,
.fb_setcolreg = sh_mobile_lcdc_setcolreg, .fb_setcolreg = sh_mobile_lcdc_setcolreg,
.fb_read = fb_sys_read, .fb_read = fb_sys_read,
.fb_write = fb_sys_write, .fb_write = fb_sys_write,
.fb_fillrect = sh_mobile_lcdc_fillrect, .fb_fillrect = sh_mobile_lcdc_fillrect,
.fb_copyarea = sh_mobile_lcdc_copyarea, .fb_copyarea = sh_mobile_lcdc_copyarea,
.fb_imageblit = sh_mobile_lcdc_imageblit, .fb_imageblit = sh_mobile_lcdc_imageblit,
.fb_pan_display = sh_mobile_fb_pan_display,
}; };
static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp) static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp)
...@@ -846,6 +897,8 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -846,6 +897,8 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
goto err1; goto err1;
} }
init_waitqueue_head(&priv->ch[i].frame_end_wait); init_waitqueue_head(&priv->ch[i].frame_end_wait);
priv->ch[j].pan_offset = 0;
priv->ch[j].new_pan_offset = 0;
switch (pdata->ch[i].chan) { switch (pdata->ch[i].chan) {
case LCDC_CHAN_MAINLCD: case LCDC_CHAN_MAINLCD:
...@@ -888,7 +941,9 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -888,7 +941,9 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
info = priv->ch[i].info; info = priv->ch[i].info;
info->fbops = &sh_mobile_lcdc_ops; info->fbops = &sh_mobile_lcdc_ops;
info->var.xres = info->var.xres_virtual = cfg->lcd_cfg.xres; info->var.xres = info->var.xres_virtual = cfg->lcd_cfg.xres;
info->var.yres = info->var.yres_virtual = cfg->lcd_cfg.yres; info->var.yres = cfg->lcd_cfg.yres;
/* Default Y virtual resolution is 2x panel size */
info->var.yres_virtual = info->var.yres * 2;
info->var.width = cfg->lcd_size_cfg.width; info->var.width = cfg->lcd_size_cfg.width;
info->var.height = cfg->lcd_size_cfg.height; info->var.height = cfg->lcd_size_cfg.height;
info->var.activate = FB_ACTIVATE_NOW; info->var.activate = FB_ACTIVATE_NOW;
...@@ -898,7 +953,8 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -898,7 +953,8 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
info->fix = sh_mobile_lcdc_fix; info->fix = sh_mobile_lcdc_fix;
info->fix.line_length = cfg->lcd_cfg.xres * (cfg->bpp / 8); info->fix.line_length = cfg->lcd_cfg.xres * (cfg->bpp / 8);
info->fix.smem_len = info->fix.line_length * cfg->lcd_cfg.yres; info->fix.smem_len = info->fix.line_length *
info->var.yres_virtual;
buf = dma_alloc_coherent(&pdev->dev, info->fix.smem_len, buf = dma_alloc_coherent(&pdev->dev, info->fix.smem_len,
&priv->ch[i].dma_handle, GFP_KERNEL); &priv->ch[i].dma_handle, GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment