From: Liu Xiaowen Date: Mon, 5 Dec 2011 05:45:25 +0000 (+0800) Subject: ENGR00169387 add user space memory allocation for v4l2. X-Git-Tag: v3.0.35-fsl~1820 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5d9ce476cfa23a8b403b2e12f3a021b9bc5da351;p=karo-tx-linux.git ENGR00169387 add user space memory allocation for v4l2. add user space memory allocation for kernel v4l2 interface in ics. Signed-off-by: Liu Xiaowen --- diff --git a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c index 229e3f6fe42c..a6045061f505 100644 --- a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c +++ b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c @@ -297,6 +297,36 @@ static int mxc_v4l2_buffer_status(cam_data *cam, struct v4l2_buffer *buf) return 0; } +static int mxc_v4l2_release_bufs(cam_data *cam) +{ + pr_debug("In MVC:mxc_v4l2_release_bufs\n"); + return 0; +} + +static int mxc_v4l2_prepare_bufs(cam_data *cam, struct v4l2_buffer *buf) +{ + pr_debug("In MVC:mxc_v4l2_prepare_bufs\n"); + + if (buf->index < 0 || buf->index >= FRAME_NUM || buf->length < + PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage)) { + pr_err("ERROR: v4l2 capture: mxc_v4l2_prepare_bufs buffers " + "not allocated,index=%d, length=%d\n", buf->index, + buf->length); + return -EINVAL; + } + + cam->frame[buf->index].buffer.index = buf->index; + cam->frame[buf->index].buffer.flags = V4L2_BUF_FLAG_MAPPED; + cam->frame[buf->index].buffer.length = buf->length; + cam->frame[buf->index].buffer.m.offset = cam->frame[buf->index].paddress + = buf->m.offset; + cam->frame[buf->index].buffer.type = buf->type; + cam->frame[buf->index].buffer.memory = V4L2_MEMORY_USERPTR; + cam->frame[buf->index].index = buf->index; + + return 0; +} + /*************************************************************************** * Functions for handling the video stream. **************************************************************************/ @@ -1200,6 +1230,10 @@ static int mxc_v4l2_s_param(cam_data *cam, struct v4l2_streamparm *parm) currentparm.parm.capture.timeperframe.denominator, parm->parm.capture.timeperframe.denominator); + if (parm->parm.capture.capturemode == currentparm.parm.capture.capturemode) { + return 0; + } + /* This will change any camera settings needed. */ ipu_csi_enable_mclk_if(cam->ipu, CSI_MCLK_I2C, cam->csi, true, true); err = vidioc_int_s_parm(cam->sensor, parm); @@ -1813,8 +1847,7 @@ static long mxc_v4l_do_ioctl(struct file *file, req->count = FRAME_NUM; } - if ((req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) || - (req->memory != V4L2_MEMORY_MMAP)) { + if ((req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) { pr_err("ERROR: v4l2 capture: VIDIOC_REQBUFS: " "wrong buffer type\n"); retval = -EINVAL; @@ -1822,13 +1855,15 @@ static long mxc_v4l_do_ioctl(struct file *file, } mxc_streamoff(cam); - mxc_free_frame_buf(cam); + if (req->memory & V4L2_MEMORY_MMAP) + mxc_free_frame_buf(cam); cam->enc_counter = 0; INIT_LIST_HEAD(&cam->ready_q); INIT_LIST_HEAD(&cam->working_q); INIT_LIST_HEAD(&cam->done_q); - retval = mxc_allocate_frame_buf(cam, req->count); + if (req->memory & V4L2_MEMORY_MMAP) + retval = mxc_allocate_frame_buf(cam, req->count); break; } @@ -1848,11 +1883,19 @@ static long mxc_v4l_do_ioctl(struct file *file, break; } - memset(buf, 0, sizeof(buf)); - buf->index = index; + if (buf->memory & V4L2_MEMORY_MMAP) { + memset(buf, 0, sizeof(buf)); + buf->index = index; + } down(&cam->param_lock); - retval = mxc_v4l2_buffer_status(cam, buf); + if (buf->memory & V4L2_MEMORY_USERPTR) { + mxc_v4l2_release_bufs(cam); + retval = mxc_v4l2_prepare_bufs(cam, buf); + } + + if (buf->memory & V4L2_MEMORY_MMAP) + retval = mxc_v4l2_buffer_status(cam, buf); up(&cam->param_lock); break; } @@ -1907,7 +1950,6 @@ static long mxc_v4l_do_ioctl(struct file *file, } retval = mxc_v4l_dqueue(cam, buf); - break; } diff --git a/drivers/media/video/mxc/capture/mxc_v4l2_capture.h b/drivers/media/video/mxc/capture/mxc_v4l2_capture.h index 4de53aa964d8..d04b3d755449 100644 --- a/drivers/media/video/mxc/capture/mxc_v4l2_capture.h +++ b/drivers/media/video/mxc/capture/mxc_v4l2_capture.h @@ -36,7 +36,7 @@ #include -#define FRAME_NUM 3 +#define FRAME_NUM 10 /*! * v4l2 frame structure.