From: ddl Date: Mon, 7 Mar 2011 09:47:18 +0000 (+0800) Subject: camera:camera driver must check vip memory is enough or not for scale process by IPP X-Git-Tag: firefly_0821_release~10685 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=76419122be6d6ef4e025ee957834015900cf9c2a;p=firefly-linux-kernel-4.4.55.git camera:camera driver must check vip memory is enough or not for scale process by IPP --- diff --git a/drivers/media/video/rk29_camera_oneframe.c b/drivers/media/video/rk29_camera_oneframe.c index bcdbbe41e93f..483568ad951a 100755 --- a/drivers/media/video/rk29_camera_oneframe.c +++ b/drivers/media/video/rk29_camera_oneframe.c @@ -1138,12 +1138,14 @@ static int rk29_camera_try_fmt(struct soc_camera_device *icd, struct v4l2_format *f) { struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); + struct rk29_camera_dev *pcdev = ici->priv; struct v4l2_subdev *sd = soc_camera_to_subdev(icd); const struct soc_camera_format_xlate *xlate; struct v4l2_pix_format *pix = &f->fmt.pix; __u32 pixfmt = pix->pixelformat; enum v4l2_field field; int ret,usr_w,usr_h; + int bytes_per_pixel; usr_w = pix->width; usr_h = pix->height; @@ -1169,13 +1171,25 @@ static int rk29_camera_try_fmt(struct soc_camera_device *icd, ret = v4l2_subdev_call(sd, video, try_fmt, f); pix->pixelformat = pixfmt; #ifdef CONFIG_VIDEO_RK29_WORK_IPP + bytes_per_pixel = (xlate->cam_fmt->depth + 7) >> 3; if ((pix->width > usr_w) && (pix->height > usr_h)) { - pix->width = usr_w; - pix->height = usr_h; - } else if ((pix->width < usr_w) && (pix->height < usr_h)) { - if (((usr_w>>1) < pix->width) && ((usr_h>>1) < pix->height)) { + /* Assume preview buffer minimum is 4 */ + if (PAGE_ALIGN(bytes_per_pixel*pix->width*pix->height)*4 <= pcdev->vipmem_size) { pix->width = usr_w; pix->height = usr_h; + } else { + RK29CAMERA_TR("vipmem for IPP is overflow, This resolution(%dx%d -> %dx%d) is invalidate!\n",pix->width,pix->height,usr_w,usr_h); + } + } else if ((pix->width < usr_w) && (pix->height < usr_h)) { + if (((usr_w>>1) < pix->width) && ((usr_h>>1) < pix->height)) { + if (PAGE_ALIGN(bytes_per_pixel*pix->width*pix->height)*4 <= pcdev->vipmem_size) { + pix->width = usr_w; + pix->height = usr_h; + } else { + RK29CAMERA_TR("vipmem for IPP is overflow, This resolution(%dx%d -> %dx%d) is invalidate!\n",pix->width,pix->height,usr_w,usr_h); + } + } else { + RK29CAMERA_TR("The aspect ratio(%dx%d//%dx%d) is bigger than 2 !\n",pix->width,pix->height,usr_w,usr_h); } } #endif