camera: fix vip driver havn't limit buffer number which application request when...
authorddl <ddl@rockchip.com>
Sun, 30 Jan 2011 13:11:19 +0000 (21:11 +0800)
committerddl <ddl@rockchip.com>
Sun, 30 Jan 2011 13:32:11 +0000 (21:32 +0800)
drivers/media/video/rk29_camera_oneframe.c

index 341ffd652dfa7dff5482752d53e6fba8db48f323..1e31a281ebefa6fa4428a2ece33aabbaca0a5ff3 100755 (executable)
@@ -262,7 +262,16 @@ static int rk29_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
 
     dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size);
 
+       /* planar capture requires Y, U and V buffers to be page aligned */
+    *size = PAGE_ALIGN(icd->user_width* icd->user_height * bytes_per_pixel);                               /* Y pages UV pages, yuv422*/
+       pcdev->vipmem_bsize = PAGE_ALIGN(pcdev->host_width * pcdev->host_height * bytes_per_pixel);
+
        if ((pcdev->host_width != pcdev->icd->user_width) || (pcdev->host_height != pcdev->icd->user_height)) {
+
+               if (*count > pcdev->vipmem_size/pcdev->vipmem_bsize) {    /* Buffers must be limited, when this resolution is genered by IPP */
+                       *count = pcdev->vipmem_size/pcdev->vipmem_bsize;
+               }
+
                if ((pcdev->camera_work_count != *count) && pcdev->camera_work) {
                        kfree(pcdev->camera_work);
                        pcdev->camera_work = NULL;
@@ -279,10 +288,6 @@ static int rk29_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
                }
        }
 
-    /* planar capture requires Y, U and V buffers to be page aligned */
-    *size = PAGE_ALIGN(icd->user_width* icd->user_height * bytes_per_pixel);                               /* Y pages UV pages, yuv422*/
-       pcdev->vipmem_bsize = PAGE_ALIGN(pcdev->host_width * pcdev->host_height * bytes_per_pixel);
-
     RK29CAMERA_DG("%s..%d.. videobuf size:%d, vipmem_buf size:%d \n",__FUNCTION__,__LINE__, *size,pcdev->vipmem_bsize);
 
     return 0;
@@ -371,8 +376,8 @@ static inline void rk29_videobuf_capture(struct videobuf_buffer *vb)
                        uv_addr = y_addr + pcdev->host_width*pcdev->host_height;
 
                        if (y_addr > (pcdev->vipmem_phybase + pcdev->vipmem_size - pcdev->vipmem_bsize)) {
-                               RK29CAMERA_TR("vipmem for IPP is overflow! %dx%d -> %dx%d vb_index:%d\n",pcdev->icd->user_width,
-                                                 pcdev->icd->user_height,pcdev->host_width,pcdev->host_height, vb->i);
+                               RK29CAMERA_TR("vipmem for IPP is overflow! %dx%d -> %dx%d vb_index:%d\n",pcdev->host_width,pcdev->host_height,
+                                                 pcdev->icd->user_width,pcdev->icd->user_height, vb->i);
                                BUG();
                        }
                } else {