summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiu Ying <b17645@freescale.com>2009-09-02 11:02:30 +0800
committerLiu Ying <b17645@freescale.com>2009-09-03 12:53:32 +0800
commite4bcb2ad7617c2fbfdf218ea04f72f24202dcaad (patch)
tree911ce2869c7f3d9c0ddf0cdabed637ac9616e428
parent398ca7ac4f48ec307c64c046b9377ead2ec452d7 (diff)
ENGR00115450 IPUv3 FB:Overlay window shouldn't exceed background boundary
The overlay window position should be limited so that overlay window will not exceed background window boundary. Signed-off-by: Liu Ying <b17645@freescale.com>
-rw-r--r--drivers/video/mxc/mxc_ipuv3_fb.c45
-rw-r--r--include/linux/mxcfb.h2
2 files changed, 46 insertions, 1 deletions
diff --git a/drivers/video/mxc/mxc_ipuv3_fb.c b/drivers/video/mxc/mxc_ipuv3_fb.c
index 6c6e33580874..d97abb41ecba 100644
--- a/drivers/video/mxc/mxc_ipuv3_fb.c
+++ b/drivers/video/mxc/mxc_ipuv3_fb.c
@@ -903,12 +903,57 @@ static int mxcfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
case MXCFB_SET_OVERLAY_POS:
{
struct mxcfb_pos pos;
+ struct fb_info *bg_fbi = NULL;
+ struct mxcfb_info *bg_mxcfbi = NULL;
+ int i;
+
+ if (mxc_fbi->ipu_ch != MEM_FG_SYNC) {
+ dev_err(fbi->device, "Should use the overlay "
+ "framebuffer to set the position of "
+ "the overlay window\n");
+ retval = -EINVAL;
+ break;
+ }
+
if (copy_from_user(&pos, (void *)arg, sizeof(pos))) {
retval = -EFAULT;
break;
}
+
+ for (i = 0; i < num_registered_fb; i++) {
+ bg_mxcfbi =
+ ((struct mxcfb_info *)(registered_fb[i]->par));
+
+ if (bg_mxcfbi->ipu_ch == MEM_BG_SYNC) {
+ bg_fbi = registered_fb[i];
+ break;
+ }
+ }
+
+ if (bg_fbi == NULL) {
+ dev_err(fbi->device, "Cannot find the "
+ "background framebuffer\n");
+ retval = -ENOENT;
+ break;
+ }
+
+ if (fbi->var.xres + pos.x > bg_fbi->var.xres)
+ pos.x = bg_fbi->var.xres - fbi->var.xres;
+ if (fbi->var.yres + pos.y > bg_fbi->var.yres)
+ pos.y = bg_fbi->var.yres - fbi->var.yres;
+
+ if (pos.x < 0)
+ pos.x = 0;
+ if (pos.y < 0)
+ pos.y = 0;
+
retval = ipu_disp_set_window_pos(mxc_fbi->ipu_ch,
pos.x, pos.y);
+
+ if (copy_to_user((void *)arg, &pos, sizeof(pos))) {
+ retval = -EFAULT;
+ break;
+ }
break;
}
case MXCFB_GET_FB_IPU_CHAN:
diff --git a/include/linux/mxcfb.h b/include/linux/mxcfb.h
index 1aeb29f4ac41..79c23c344dfa 100644
--- a/include/linux/mxcfb.h
+++ b/include/linux/mxcfb.h
@@ -54,7 +54,7 @@ struct mxcfb_pos {
#define MXCFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t)
#define MXCFB_SET_GBL_ALPHA _IOW('F', 0x21, struct mxcfb_gbl_alpha)
#define MXCFB_SET_CLR_KEY _IOW('F', 0x22, struct mxcfb_color_key)
-#define MXCFB_SET_OVERLAY_POS _IOW('F', 0x24, struct mxcfb_pos)
+#define MXCFB_SET_OVERLAY_POS _IOWR('F', 0x24, struct mxcfb_pos)
#define MXCFB_GET_FB_IPU_CHAN _IOR('F', 0x25, u_int32_t)
#define MXCFB_SET_LOC_ALPHA _IOWR('F', 0x26, struct mxcfb_loc_alpha)
#define MXCFB_SET_LOC_ALP_BUF _IOW('F', 0x27, unsigned long)