diff options
author | Xinyu Chen <xinyu.chen@freescale.com> | 2011-12-14 12:05:29 +0800 |
---|---|---|
committer | Xinyu Chen <xinyu.chen@freescale.com> | 2011-12-16 10:59:00 +0800 |
commit | 4d8b15d336b9d66054f654d8734af29f81ce81be (patch) | |
tree | a675fb27ed7afc3c433f915195ca36da7f1046b4 /drivers | |
parent | 4bd95322c76015dabb6442950f1a10c80912586b (diff) |
ENGR00169880 v4l2 capture: reserve dummy framebuffer for 8M on probe
On GB with 512MB DDR size, when we taking 5M pixel picture,
the v4l2 capture will first allocate a 8M continuous memory for
first frame, which may cause allocation failed.
Reserve this buffer on probe when safe.
Signed-off-by: Xinyu Chen <xinyu.chen@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/mxc/capture/ipu_csi_enc.c | 31 | ||||
-rw-r--r-- | drivers/media/video/mxc/capture/mxc_v4l2_capture.c | 15 |
2 files changed, 36 insertions, 10 deletions
diff --git a/drivers/media/video/mxc/capture/ipu_csi_enc.c b/drivers/media/video/mxc/capture/ipu_csi_enc.c index 0261a7ecd212..83a43c5e1a9e 100644 --- a/drivers/media/video/mxc/capture/ipu_csi_enc.c +++ b/drivers/media/video/mxc/capture/ipu_csi_enc.c @@ -235,18 +235,29 @@ static int csi_enc_enabling_tasks(void *private) int err = 0; CAMERA_TRACE("IPU:In csi_enc_enabling_tasks\n"); - cam->dummy_frame.vaddress = dma_alloc_coherent(0, - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage), - &cam->dummy_frame.paddress, - GFP_DMA | GFP_KERNEL); - if (cam->dummy_frame.vaddress == 0) { - pr_err("ERROR: v4l2 capture: Allocate dummy frame " - "failed.\n"); - return -ENOBUFS; + if (cam->dummy_frame.vaddress && + cam->dummy_frame.buffer.length + < PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage)) { + dma_free_coherent(0, cam->dummy_frame.buffer.length, + cam->dummy_frame.vaddress, + cam->dummy_frame.paddress); + cam->dummy_frame.vaddress = 0; + } + + if (!cam->dummy_frame.vaddress) { + cam->dummy_frame.vaddress = dma_alloc_coherent(0, + PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage), + &cam->dummy_frame.paddress, + GFP_DMA | GFP_KERNEL); + if (cam->dummy_frame.vaddress == 0) { + pr_err("ERROR: v4l2 capture: Allocate dummy frame " + "failed.\n"); + return -ENOBUFS; + } + cam->dummy_frame.buffer.length = + PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage); } cam->dummy_frame.buffer.type = V4L2_BUF_TYPE_PRIVATE; - cam->dummy_frame.buffer.length = - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage); cam->dummy_frame.buffer.m.offset = cam->dummy_frame.paddress; ipu_clear_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF); diff --git a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c index bc119c108106..21dcb1a46d50 100644 --- a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c +++ b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c @@ -2569,6 +2569,14 @@ static void init_camera_struct(cam_data *cam, struct platform_device *pdev) init_waitqueue_head(&cam->power_queue); spin_lock_init(&cam->queue_int_lock); spin_lock_init(&cam->dqueue_int_lock); + + cam->dummy_frame.vaddress = dma_alloc_coherent(0, + SZ_8M, &cam->dummy_frame.paddress, + GFP_DMA | GFP_KERNEL); + if (cam->dummy_frame.vaddress == 0) + pr_err("ERROR: v4l2 capture: Allocate dummy frame " + "failed.\n"); + cam->dummy_frame.buffer.length = SZ_8M; } static ssize_t show_streaming(struct device *dev, @@ -2659,6 +2667,13 @@ static int mxc_v4l2_probe(struct platform_device *pdev) static int mxc_v4l2_remove(struct platform_device *pdev) { + if (g_cam->dummy_frame.vaddress != 0) { + dma_free_coherent(0, g_cam->dummy_frame.buffer.length, + g_cam->dummy_frame.vaddress, + g_cam->dummy_frame.paddress); + g_cam->dummy_frame.vaddress = 0; + } + if (g_cam->open_count) { pr_err("ERROR: v4l2 capture:camera open " "-- setting ops to NULL\n"); |