summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinyu Chen <xinyu.chen@freescale.com>2011-10-28 14:26:33 +0800
committerXinyu Chen <xinyu.chen@freescale.com>2011-10-28 14:26:33 +0800
commit7a17148d3dbed856922b89fb1fd050087afe1add (patch)
tree65ee1446ed1bf50151c10ed9403e3ee5ce85ca6f
parent0f37798272c047cc45577c5075486b242039596f (diff)
ENGR00159773-1 v4l2 capture: reserve the dummy frame buffer
V4l2 capture encoding start needs a dummy frame buffer for the first input frame, here just let it allocate only if it's not allocated or size is not big enough. Then no frequently dma alloc/free happen. Signed-off-by: Xinyu Chen <xinyu.chen@freescale.com>
-rw-r--r--drivers/media/video/mxc/capture/ipu_csi_enc.c37
-rw-r--r--drivers/media/video/mxc/capture/mxc_v4l2_capture.c7
2 files changed, 28 insertions, 16 deletions
diff --git a/drivers/media/video/mxc/capture/ipu_csi_enc.c b/drivers/media/video/mxc/capture/ipu_csi_enc.c
index e04525d7d8bc..118b4df9991e 100644
--- a/drivers/media/video/mxc/capture/ipu_csi_enc.c
+++ b/drivers/media/video/mxc/capture/ipu_csi_enc.c
@@ -195,18 +195,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(IPU_IRQ_CSI0_OUT_EOF);
@@ -243,12 +254,6 @@ static int csi_enc_disabling_tasks(void *private)
ipu_uninit_channel(CSI_MEM);
- if (cam->dummy_frame.vaddress != 0) {
- dma_free_coherent(0, cam->dummy_frame.buffer.length,
- cam->dummy_frame.vaddress,
- cam->dummy_frame.paddress);
- cam->dummy_frame.vaddress = 0;
- }
ipu_csi_enable_mclk_if(CSI_MCLK_ENC, cam->csi, false, false);
return err;
diff --git a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c
index 783747ddefb6..4ed3e59829be 100644
--- a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c
+++ b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c
@@ -2675,6 +2675,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");