Skip to contentSkip to conversation

About the VIDIOC_DQBUF

DISCUSSION xie 2 participants 7 messages Jun 8, 2009 – Jun 10, 2009 Media (V4L/DVB)

lore
Share & tools
lore

xie

author
#0 lore raw

Dear all ~~

I have met a issue when I used the mmap method for previewing . I just used the standard code as spec to get the image data :
status_t CameraHardwareProwave::V4l2Camera::v4l2CaptureMainloop()

{
	LOG_FUNCTION_NAME
	int rt  ;
	unsigned int i ;
	fd_set fds ;
	struct timeval tv ;
	struct v4l2_buffer buf ;

	for(;;){
		FD_ZERO(&fds) ;
		FD_SET(v4l2Fd, &fds) ;
		//now the time is long ,just for debug
		tv.tv_sec = 2 ;
		tv.tv_usec = 0 ;

		rt = select(v4l2Fd + 1, &fds, NULL, NULL, &tv) ;
		LOGD("The value of select return : %d\n", rt) ;
		
		/********** for debug
		if(V4L2_NOERROR != v4l2ReadFrame()){
			LOGE("READ ERROR") ;
		}
                ***********/
		
		if(-1 == rt){
			LOGE("there is something wrong in select function(select)") ;
			//no defined error manage
			return V4L2_IOCTL_ERROR ;
		}
		if(0 == rt){
			LOGE("wait for data timeout in select") ;
			return V4L2_TIMEOUT ;
		}

		memset(&buf, 0, sizeof(buf)) ;
		buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
		buf.memory = V4L2_MEMORY_MMAP ;
		if(-1 == ioctl(v4l2Fd, VIDIOC_DQBUF, &buf)){
		    LOGE("there is something wrong in dequeue buffer(VIDIOC_DQBUF)") ;
			return V4L2_IOCTL_ERROR ;
		}
		
		assert(i < n_buf) ;
		LOGE("buf.index  0buf.length = %d %d \n", buf.index , buf.length) ;
        memcpy((mCameraProwave->getPreviewHeap())->base(),
v4l2Buffer[buf.index].start, buf.length) ;
		if(-1 == ioctl(v4l2Fd, VIDIOC_QBUF, &buf)){
		    LOGE("there is something wrong in enqueue buffer(VIDIOC_QBUF)") ;
			return V4L2_IOCTL_ERROR ;
		}
		//break ;   //i don't know whether the break is needed ;
		 
	}
	return V4L2_NOERROR ;
}

when executed the VIDIOC_DQBUF IOCTL,the return value was right, but the value of buf.length would always be zero. Then I used the read() function to read raw data in the file handle for debug, and I can get the raw data. Anybody have met this issue before ? Who can give me some advices or tell me what is wrong , thanks a lot ~

#1 lore raw

Hello Xie,

I'm not sure which camera interface driver you are using, but it seems to be camera interface driver's problem. Let me guess, are you using pxa camera interface driver from Marvell?(proprietary but not in up stream kernel)
It just looks like that camera interface driver is not returning proper data in dqbuf.

And one more thing. I prefer to use byteused rather than length in buf. because as far as I know the size of preview data from camera is in byte unit which we need to copy to memory. But it should be possible to use length, I guess..
Cheers,

Nate

Quoted 68 lines · xie

Dear all ~~

I have met a issue when I used the mmap method for previewing . I just used the standard code as spec to get the image data :
status_t CameraHardwareProwave::V4l2Camera::v4l2CaptureMainloop() {
       LOG_FUNCTION_NAME
       int rt  ;
       unsigned int i ;
       fd_set fds ;
       struct timeval tv ;
       struct v4l2_buffer buf ;

       for(;;){
               FD_ZERO(&fds) ;
               FD_SET(v4l2Fd, &fds) ;
               //now the time is long ,just for debug tv.tv_sec = 2 ;
               tv.tv_usec = 0 ;

               rt = select(v4l2Fd + 1, &fds, NULL, NULL, &tv) ; LOGD("The value of select return : %d\n", rt) ;

               /********** for debug if(V4L2_NOERROR != v4l2ReadFrame()){ LOGE("READ ERROR") ; }
               ***********/

               if(-1 == rt){
                       LOGE("there is something wrong in select function(select)") ; //no defined error manage
                       return V4L2_IOCTL_ERROR ;
               }
               if(0 == rt){
                       LOGE("wait for data timeout in select") ; return V4L2_TIMEOUT ;
               }

               memset(&buf, 0, sizeof(buf)) ;
               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
               buf.memory = V4L2_MEMORY_MMAP ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_DQBUF, &buf)){
                   LOGE("there is something wrong in dequeue buffer(VIDIOC_DQBUF)") ; return V4L2_IOCTL_ERROR ;
               }

               assert(i < n_buf) ;
               LOGE("buf.index  0buf.length = %d %d \n", buf.index , buf.length) ; memcpy((mCameraProwave->getPreviewHeap())->base(), v4l2Buffer[buf.index].start, buf.length) ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_QBUF, &buf)){
                   LOGE("there is something wrong in enqueue buffer(VIDIOC_QBUF)") ; return V4L2_IOCTL_ERROR ;
               }
               //break ;   //i don't know whether the break is needed ;

       }
       return V4L2_NOERROR ;
}

when executed the VIDIOC_DQBUF IOCTL,the return value was right, but the value of buf.length would always  be zero. Then I used the read() function to read raw data in the file handle for debug, and I can get the raw data. Anybody have met this issue before ? Who can give me some advices or tell me what is wrong , thanks a lot ~

Signature · 8 lines
=
DongSoo, Nathaniel Kim
Engineer
Mobile S/W Platform Lab.
Digital Media & Communications R&D Centre
Samsung Electronics CO., LTD.
e-mail : [email protected]
          [email protected]
author
#2 lore raw

Hi Dongsoo, Nathaniel ~
You must be expert on V4l2 ~ Thanks very much for your help and advice ~!~
I used the MXC camera interface driver from Fressscale ,I readed the driver interface just now ,and have fouded that the driver not modified the buf.lenth but buf.byteused . You are very right , I will use the buf.byteused instead of buf.length ~

There is also a problem I want to consult to you ~ Can i get a full frame with the below method if the driver have no problem ?

memcpy((mCameraProwave->getPreviewHeap())->base(), v4l2Buffer[buf.index].start, buf.byteused) ;

Because I just need to implement a hal for getting the frame data and post it to top layer , so I used the memcpy simply . Am I right ~ ? Or what about your advice ?

Thanks a lot ~~

Quoted 89 lines · Nathaniel Kim

Hello Xie,

I'm not sure which camera interface driver you are using, but it seems to be camera interface driver's problem. Let me guess, are you using pxa camera interface driver from Marvell?(proprietary but not in up stream kernel)
It just looks like that camera interface driver is not returning proper data in dqbuf.

And one more thing. I prefer to use byteused rather than length in buf. because as far as I know the size of preview data from camera is in byte unit which we need to copy to memory. But it should be possible to use length, I guess..
Cheers,

Nate

Quoted 68 lines · xie

Dear all ~~

I have met a issue when I used the mmap method for previewing . I just used the standard code as spec to get the image data :
status_t CameraHardwareProwave::V4l2Camera::v4l2CaptureMainloop()

{
       LOG_FUNCTION_NAME
       int rt  ;
       unsigned int i ;
       fd_set fds ;
       struct timeval tv ;
       struct v4l2_buffer buf ;

       for(;;){
               FD_ZERO(&fds) ;
               FD_SET(v4l2Fd, &fds) ;
               //now the time is long ,just for debug
               tv.tv_sec = 2 ;
               tv.tv_usec = 0 ;

               rt = select(v4l2Fd + 1, &fds, NULL, NULL, &tv) ;
               LOGD("The value of select return : %d\n", rt) ;

               /********** for debug
               if(V4L2_NOERROR != v4l2ReadFrame()){
                       LOGE("READ ERROR") ;
               }
               ***********/

               if(-1 == rt){
                       LOGE("there is something wrong in select function(select)") ;
                       //no defined error manage
                       return V4L2_IOCTL_ERROR ;
               }
               if(0 == rt){
                       LOGE("wait for data timeout in select") ;
                       return V4L2_TIMEOUT ;
               }

               memset(&buf, 0, sizeof(buf)) ;
               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
               buf.memory = V4L2_MEMORY_MMAP ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_DQBUF, &buf)){
                   LOGE("there is something wrong in dequeue buffer(VIDIOC_DQBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }

               assert(i < n_buf) ;
               LOGE("buf.index  0buf.length = %d %d \n", buf.index , buf.length) ;
       memcpy((mCameraProwave->getPreviewHeap())->base(),
v4l2Buffer[buf.index].start, buf.length) ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_QBUF, &buf)){
                   LOGE("there is something wrong in enqueue buffer(VIDIOC_QBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }
               //break ;   //i don't know whether the break is needed ;

       }
       return V4L2_NOERROR ;
}

when executed the VIDIOC_DQBUF IOCTL,the return value was right, but the value of buf.length would always be zero. Then I used the read() function to read raw data in the file handle for debug, and I can get the raw data. Anybody have met this issue before ? Who can give me some advices or tell me what is wrong , thanks a lot ~

#3 lore raw

Hi,

Sorry I'm not an expert, you can expect expertise from maintainers not from me. But before answering your question about capturing, I'm not sure about what the "full frame" means. I just assume that you meant to say the biggest resolution of image frame, right?

So, when you are to capture a full resolution data while preview is working, you need to stop preview with streamoff, re-configure resolution with s_fmt to external camera module and start capturing issuing streamon with re-configured resolution. I think you are well-aware with this, aren't you? And in my opinion, memcpy may be cool for that. What else are you expecting to use? and for what? Anyway, I wish you luck.
Cheers,

Nate

Quoted 114 lines · xie

Hi Dongsoo, Nathaniel ~
You must be expert on V4l2 ~ Thanks very much for your help and advice ~!~
I used the MXC camera interface driver from Fressscale ,I readed the driver interface just now ,and have fouded that the driver not modified the buf.lenth but buf.byteused . You are very right , I will use the buf.byteused instead of buf.length ~

There is also a problem I want to consult to you ~ Can i get a full frame with the below method if the driver have no problem ?

memcpy((mCameraProwave->getPreviewHeap())->base(), v4l2Buffer[buf.index].start, buf.byteused) ;

Because I just need to implement a hal for getting the frame data and post it to top layer , so I used the memcpy simply . Am I right ~ ? Or what about your advice ?

Thanks a lot ~~

Quoted 89 lines · Nathaniel Kim

Hello Xie,

I'm not sure which camera interface driver you are using, but it seems to be camera interface driver's problem. Let me guess, are you using pxa camera interface driver from Marvell?(proprietary but not in up stream kernel)
It just looks like that camera interface driver is not returning proper data in dqbuf.

And one more thing. I prefer to use byteused rather than length in buf. because as far as I know the size of preview data from camera is in byte unit which we need to copy to memory. But it should be possible to use length, I guess..
Cheers,

Nate

Quoted 68 lines · xie

Dear all ~~

I have met a issue when I used the mmap method for previewing . I just used the standard code as spec to get the image data :
status_t CameraHardwareProwave::V4l2Camera::v4l2CaptureMainloop()

{
       LOG_FUNCTION_NAME
       int rt  ;
       unsigned int i ;
       fd_set fds ;
       struct timeval tv ;
       struct v4l2_buffer buf ;

       for(;;){
               FD_ZERO(&fds) ;
               FD_SET(v4l2Fd, &fds) ;
               //now the time is long ,just for debug
               tv.tv_sec = 2 ;
               tv.tv_usec = 0 ;

               rt = select(v4l2Fd + 1, &fds, NULL, NULL, &tv) ;
               LOGD("The value of select return : %d\n", rt) ;

               /********** for debug
               if(V4L2_NOERROR != v4l2ReadFrame()){
                       LOGE("READ ERROR") ;
               }
               ***********/

               if(-1 == rt){
                       LOGE("there is something wrong in select function(select)") ;
                       //no defined error manage
                       return V4L2_IOCTL_ERROR ;
               }
               if(0 == rt){
                       LOGE("wait for data timeout in select") ;
                       return V4L2_TIMEOUT ;
               }

               memset(&buf, 0, sizeof(buf)) ;
               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
               buf.memory = V4L2_MEMORY_MMAP ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_DQBUF, &buf)){
                   LOGE("there is something wrong in dequeue buffer(VIDIOC_DQBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }

               assert(i < n_buf) ;
               LOGE("buf.index  0buf.length = %d %d \n", buf.index , buf.length) ;
       memcpy((mCameraProwave->getPreviewHeap())->base(),
v4l2Buffer[buf.index].start, buf.length) ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_QBUF, &buf)){
                   LOGE("there is something wrong in enqueue buffer(VIDIOC_QBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }
               //break ;   //i don't know whether the break is needed ;

       }
       return V4L2_NOERROR ;
}

when executed the VIDIOC_DQBUF IOCTL,the return value was right, but the value of buf.length would always be zero. Then I used the read() function to read raw data in the file handle for debug, and I can get the raw data. Anybody have met this issue before ? Who can give me some advices or tell me what is wrong , thanks a lot ~

Signature · 8 lines
=
DongSoo, Nathaniel Kim
Engineer
Mobile S/W Platform Lab.
Digital Media & Communications R&D Centre
Samsung Electronics CO., LTD.
e-mail : [email protected]
          [email protected]
author
#4 lore raw

hi ~~ Dongsoo, Nathaniel ~

I am sorry for disturbing you, and not descripe the question clear ~ Thanks very much for your help ~~

I know that I must stop preview with streamoff and re-configure with s_fmt ~~ I have asked to you before ~!~

The "full frame" means a complete frame ~Because I just need to get the frame data and post it to multimedia framework, so I want to consult to you that if I can get a complete frame with memcpy ~~

I want to know that can I get a complete frame from buf.start to the end , and the memory-lenth is buf.byteused ~

            buf.byteused
    |-----------------------------|

buf.start end

Quoted 137 lines · Nathaniel Kim

Hi,

Sorry I'm not an expert, you can expect expertise from maintainers not from me. But before answering your question about capturing, I'm not sure about what the "full frame" means. I just assume that you meant to say the biggest resolution of image frame, right?

So, when you are to capture a full resolution data while preview is working, you need to stop preview with streamoff, re-configure resolution with s_fmt to external camera module and start capturing issuing streamon with re-configured resolution. I think you are well-aware with this, aren't you? And in my opinion, memcpy may be cool for that. What else are you expecting to use? and for what? Anyway, I wish you luck.
Cheers,

Nate

Quoted 114 lines · xie

Hi Dongsoo, Nathaniel ~
You must be expert on V4l2 ~ Thanks very much for your help and advice ~!~
I used the MXC camera interface driver from Fressscale ,I readed the driver interface just now ,and have fouded that the driver not modified the buf.lenth but buf.byteused . You are very right , I will use the buf.byteused instead of buf.length ~

There is also a problem I want to consult to you ~ Can i get a full frame with the below method if the driver have no problem ?

memcpy((mCameraProwave->getPreviewHeap())->base(), v4l2Buffer[buf.index].start, buf.byteused) ;

Because I just need to implement a hal for getting the frame data and post it to top layer , so I used the memcpy simply . Am I right ~ ? Or what about your advice ?

Thanks a lot ~~

Quoted 89 lines · Nathaniel Kim

Hello Xie,

I'm not sure which camera interface driver you are using, but it seems to be camera interface driver's problem. Let me guess, are you using pxa camera interface driver from Marvell?(proprietary but not in up stream kernel)
It just looks like that camera interface driver is not returning proper data in dqbuf.

And one more thing. I prefer to use byteused rather than length in buf. because as far as I know the size of preview data from camera is in byte unit which we need to copy to memory. But it should be possible to use length, I guess..
Cheers,

Nate

Quoted 68 lines · xie

Dear all ~~

I have met a issue when I used the mmap method for previewing . I just used the standard code as spec to get the image data :
status_t CameraHardwareProwave::V4l2Camera::v4l2CaptureMainloop()

{
       LOG_FUNCTION_NAME
       int rt  ;
       unsigned int i ;
       fd_set fds ;
       struct timeval tv ;
       struct v4l2_buffer buf ;

       for(;;){
               FD_ZERO(&fds) ;
               FD_SET(v4l2Fd, &fds) ;
               //now the time is long ,just for debug
               tv.tv_sec = 2 ;
               tv.tv_usec = 0 ;

               rt = select(v4l2Fd + 1, &fds, NULL, NULL, &tv) ;
               LOGD("The value of select return : %d\n", rt) ;

               /********** for debug
               if(V4L2_NOERROR != v4l2ReadFrame()){
                       LOGE("READ ERROR") ;
               }
               ***********/

               if(-1 == rt){
                       LOGE("there is something wrong in select function(select)") ;
                       //no defined error manage
                       return V4L2_IOCTL_ERROR ;
               }
               if(0 == rt){
                       LOGE("wait for data timeout in select") ;
                       return V4L2_TIMEOUT ;
               }

               memset(&buf, 0, sizeof(buf)) ;
               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
               buf.memory = V4L2_MEMORY_MMAP ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_DQBUF, &buf)){
                   LOGE("there is something wrong in dequeue buffer(VIDIOC_DQBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }

               assert(i < n_buf) ;
               LOGE("buf.index  0buf.length = %d %d \n", buf.index , buf.length) ;
       memcpy((mCameraProwave->getPreviewHeap())->base(),
v4l2Buffer[buf.index].start, buf.length) ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_QBUF, &buf)){
                   LOGE("there is something wrong in enqueue buffer(VIDIOC_QBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }
               //break ;   //i don't know whether the break is needed ;

       }
       return V4L2_NOERROR ;
}

when executed the VIDIOC_DQBUF IOCTL,the return value was right, but the value of buf.length would always be zero. Then I used the read() function to read raw data in the file handle for debug, and I can get the raw data. Anybody have met this issue before ? Who can give me some advices or tell me what is wrong , thanks a lot ~

#5 lore raw

Hi,

Sorry I still don't get what the full frame means, but I might consider that is the maximum resolution-ed image data coming from external camera module. And whatever it is, you might have no problem getting data through memcpy with buf.byteused size. Cheers,

Nate

Quoted 165 lines · xie

hi ~~ Dongsoo, Nathaniel ~

I am sorry for disturbing you, and not descripe the question clear ~ Thanks very much for your help ~~

I know that I must stop preview with streamoff and re-configure with s_fmt ~~ I have asked to you before ~!~

The "full frame" means a complete frame ~Because I just need to get the frame data and post it to multimedia framework, so I want to consult to you that if I can get a complete frame with memcpy ~~

I want to know that can I get a complete frame from buf.start to the end , and the memory-lenth is buf.byteused ~

buf.byteused

   |-----------------------------|
buf.start                        end
Quoted 137 lines · Nathaniel Kim

Hi,

Sorry I'm not an expert, you can expect expertise from maintainers not from me. But before answering your question about capturing, I'm not sure about what the "full frame" means. I just assume that you meant to say the biggest resolution of image frame, right?

So, when you are to capture a full resolution data while preview is working, you need to stop preview with streamoff, re-configure resolution with s_fmt to external camera module and start capturing issuing streamon with re-configured resolution. I think you are well-aware with this, aren't you? And in my opinion, memcpy may be cool for that. What else are you expecting to use? and for what? Anyway, I wish you luck.
Cheers,

Nate

Quoted 114 lines · xie

Hi Dongsoo, Nathaniel ~
You must be expert on V4l2 ~ Thanks very much for your help and advice ~!~
I used the MXC camera interface driver from Fressscale ,I readed the driver interface just now ,and have fouded that the driver not modified the buf.lenth but buf.byteused . You are very right , I will use the buf.byteused instead of buf.length ~

There is also a problem I want to consult to you ~ Can i get a full frame with the below method if the driver have no problem ?

memcpy((mCameraProwave->getPreviewHeap())->base(), v4l2Buffer[buf.index].start, buf.byteused) ;

Because I just need to implement a hal for getting the frame data and post it to top layer , so I used the memcpy simply . Am I right ~ ? Or what about your advice ?

Thanks a lot ~~

Quoted 89 lines · Nathaniel Kim

Hello Xie,

I'm not sure which camera interface driver you are using, but it seems to be camera interface driver's problem. Let me guess, are you using pxa camera interface driver from Marvell?(proprietary but not in up stream kernel)
It just looks like that camera interface driver is not returning proper data in dqbuf.

And one more thing. I prefer to use byteused rather than length in buf. because as far as I know the size of preview data from camera is in byte unit which we need to copy to memory. But it should be possible to use length, I guess..
Cheers,

Nate

Quoted 68 lines · xie

Dear all ~~

I have met a issue when I used the mmap method for previewing . I just used the standard code as spec to get the image data :
status_t CameraHardwareProwave::V4l2Camera::v4l2CaptureMainloop()

{
       LOG_FUNCTION_NAME
       int rt  ;
       unsigned int i ;
       fd_set fds ;
       struct timeval tv ;
       struct v4l2_buffer buf ;

       for(;;){
               FD_ZERO(&fds) ;
               FD_SET(v4l2Fd, &fds) ;
               //now the time is long ,just for debug
               tv.tv_sec = 2 ;
               tv.tv_usec = 0 ;

               rt = select(v4l2Fd + 1, &fds, NULL, NULL, &tv) ;
               LOGD("The value of select return : %d\n", rt) ;

               /********** for debug
               if(V4L2_NOERROR != v4l2ReadFrame()){
                       LOGE("READ ERROR") ;
               }
               ***********/

               if(-1 == rt){
                       LOGE("there is something wrong in select function(select)") ;
                       //no defined error manage
                       return V4L2_IOCTL_ERROR ;
               }
               if(0 == rt){
                       LOGE("wait for data timeout in select") ;
                       return V4L2_TIMEOUT ;
               }

               memset(&buf, 0, sizeof(buf)) ;
               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
               buf.memory = V4L2_MEMORY_MMAP ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_DQBUF, &buf)){
                   LOGE("there is something wrong in dequeue buffer(VIDIOC_DQBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }

               assert(i < n_buf) ;
               LOGE("buf.index  0buf.length = %d %d \n", buf.index , buf.length) ;
       memcpy((mCameraProwave->getPreviewHeap())->base(),
v4l2Buffer[buf.index].start, buf.length) ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_QBUF, &buf)){
                   LOGE("there is something wrong in enqueue buffer(VIDIOC_QBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }
               //break ;   //i don't know whether the break is needed ;

       }
       return V4L2_NOERROR ;
}

when executed the VIDIOC_DQBUF IOCTL,the return value was right, but the value of buf.length would always be zero. Then I used the read() function to read raw data in the file handle for debug, and I can get the raw data. Anybody have met this issue before ? Who can give me some advices or tell me what is wrong , thanks a lot ~

Signature · 8 lines
=
DongSoo, Nathaniel Kim
Engineer
Mobile S/W Platform Lab.
Digital Media & Communications R&D Centre
Samsung Electronics CO., LTD.
e-mail : [email protected]
          [email protected]
author
#6 lore raw

hi ~~

I have found the problem ~~ The 3'rd partner didn't give us the right v4l2 driver. Thanks for your help ~~

Best wishes

Quoted 179 lines · Nathaniel Kim

Hi,

Sorry I still don't get what the full frame means, but I might consider that is the maximum resolution-ed image data coming from external camera module. And whatever it is, you might have no problem getting data through memcpy with buf.byteused size. Cheers,

Nate

Quoted 165 lines · xie

hi ~~ Dongsoo, Nathaniel ~

I am sorry for disturbing you, and not descripe the question clear ~ Thanks very much for your help ~~

I know that I must stop preview with streamoff and re-configure with s_fmt ~~ I have asked to you before ~!~

The "full frame" means a complete frame ~Because I just need to get the frame data and post it to multimedia framework, so I want to consult to you that if I can get a complete frame with memcpy ~~

I want to know that can I get a complete frame from buf.start to the end , and the memory-lenth is buf.byteused ~

buf.byteused

   |-----------------------------|
buf.start                        end
Quoted 137 lines · Nathaniel Kim

Hi,

Sorry I'm not an expert, you can expect expertise from maintainers not from me. But before answering your question about capturing, I'm not sure about what the "full frame" means. I just assume that you meant to say the biggest resolution of image frame, right?

So, when you are to capture a full resolution data while preview is working, you need to stop preview with streamoff, re-configure resolution with s_fmt to external camera module and start capturing issuing streamon with re-configured resolution. I think you are well-aware with this, aren't you? And in my opinion, memcpy may be cool for that. What else are you expecting to use? and for what? Anyway, I wish you luck.
Cheers,

Nate

Quoted 114 lines · xie

Hi Dongsoo, Nathaniel ~
You must be expert on V4l2 ~ Thanks very much for your help and advice ~!~
I used the MXC camera interface driver from Fressscale ,I readed the driver interface just now ,and have fouded that the driver not modified the buf.lenth but buf.byteused . You are very right , I will use the buf.byteused instead of buf.length ~

There is also a problem I want to consult to you ~ Can i get a full frame with the below method if the driver have no problem ?

memcpy((mCameraProwave->getPreviewHeap())->base(), v4l2Buffer[buf.index].start, buf.byteused) ;

Because I just need to implement a hal for getting the frame data and post it to top layer , so I used the memcpy simply . Am I right ~ ? Or what about your advice ?

Thanks a lot ~~

Quoted 89 lines · Nathaniel Kim

Hello Xie,

I'm not sure which camera interface driver you are using, but it seems to be camera interface driver's problem. Let me guess, are you using pxa camera interface driver from Marvell?(proprietary but not in up stream kernel)
It just looks like that camera interface driver is not returning proper data in dqbuf.

And one more thing. I prefer to use byteused rather than length in buf. because as far as I know the size of preview data from camera is in byte unit which we need to copy to memory. But it should be possible to use length, I guess..
Cheers,

Nate

Quoted 68 lines · xie

Dear all ~~

I have met a issue when I used the mmap method for previewing . I just used the standard code as spec to get the image data :
status_t CameraHardwareProwave::V4l2Camera::v4l2CaptureMainloop()

{
       LOG_FUNCTION_NAME
       int rt  ;
       unsigned int i ;
       fd_set fds ;
       struct timeval tv ;
       struct v4l2_buffer buf ;

       for(;;){
               FD_ZERO(&fds) ;
               FD_SET(v4l2Fd, &fds) ;
               //now the time is long ,just for debug
               tv.tv_sec = 2 ;
               tv.tv_usec = 0 ;

               rt = select(v4l2Fd + 1, &fds, NULL, NULL, &tv) ;
               LOGD("The value of select return : %d\n", rt) ;

               /********** for debug
               if(V4L2_NOERROR != v4l2ReadFrame()){
                       LOGE("READ ERROR") ;
               }
               ***********/

               if(-1 == rt){
                       LOGE("there is something wrong in select function(select)") ;
                       //no defined error manage
                       return V4L2_IOCTL_ERROR ;
               }
               if(0 == rt){
                       LOGE("wait for data timeout in select") ;
                       return V4L2_TIMEOUT ;
               }

               memset(&buf, 0, sizeof(buf)) ;
               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
               buf.memory = V4L2_MEMORY_MMAP ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_DQBUF, &buf)){
                   LOGE("there is something wrong in dequeue buffer(VIDIOC_DQBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }

               assert(i < n_buf) ;
               LOGE("buf.index  0buf.length = %d %d \n", buf.index , buf.length) ;
       memcpy((mCameraProwave->getPreviewHeap())->base(),
v4l2Buffer[buf.index].start, buf.length) ;
               if(-1 == ioctl(v4l2Fd, VIDIOC_QBUF, &buf)){
                   LOGE("there is something wrong in enqueue buffer(VIDIOC_QBUF)") ;
                       return V4L2_IOCTL_ERROR ;
               }
               //break ;   //i don't know whether the break is needed ;

       }
       return V4L2_NOERROR ;
}

when executed the VIDIOC_DQBUF IOCTL,the return value was right, but the value of buf.length would always be zero. Then I used the read() function to read raw data in the file handle for debug, and I can get the raw data. Anybody have met this issue before ? Who can give me some advices or tell me what is wrong , thanks a lot ~