From patchwork Mon May 11 23:36:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 23127 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4BNb5jT018710 for ; Mon, 11 May 2009 23:37:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758209AbZEKXgz (ORCPT ); Mon, 11 May 2009 19:36:55 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758625AbZEKXgz (ORCPT ); Mon, 11 May 2009 19:36:55 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:33744 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758209AbZEKXgy (ORCPT ); Mon, 11 May 2009 19:36:54 -0400 Received: from 200-153-220-101.dsl.telesp.net.br ([200.153.220.101] helo=pedra.chehab.org) by bombadil.infradead.org with esmtpsa (Exim 4.69 #1 (Red Hat Linux)) id 1M3f3E-0008QU-Uq; Mon, 11 May 2009 23:36:53 +0000 Date: Mon, 11 May 2009 20:36:47 -0300 From: Mauro Carvalho Chehab To: "Dongsoo, Nathaniel Kim" Cc: Hans Verkuil , "linux-media@vger.kernel.org" , "kyungmin.park@samsung.com" , "jongse.won@samsung.com" , =?UTF-8?B?6rmA7ZiV7KSA?= Subject: Re: About using VIDIOC_REQBUFS Message-ID: <20090511203647.6c982275@pedra.chehab.org> In-Reply-To: <5e9665e10904230315o46ef5f95o8c393a9148976880@mail.gmail.com> References: <5e9665e10904230315o46ef5f95o8c393a9148976880@mail.gmail.com> X-Mailer: Claws Mail 3.3.1 (GTK+ 2.10.4; x86_64-redhat-linux-gnu) Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Em Thu, 23 Apr 2009 19:15:14 +0900 "Dongsoo, Nathaniel Kim" escreveu: > Hello Hans, > > Is it an ordinary way to use twice reqbuf without closing and > re-opening between them? > > I mean like this, > > 1. Open device > 2. VIDIOC_REQBUFS > > 3. VIDIOC_STREAMON > > 4. VIDIOC_STREAMOFF > 5. VIDIOC_REQBUFS > > 6. VIDIOC_STREAMON > > I suppose there should be a strict order for this. That order seems to > be wrong but necessary when we do capturing a JPEG data which size > (not resolution) is bigger than the preview data size. (Assuming that > user is using mmap) > Please let me know the right way for that kind of case. Just close and > re-open with big enough size for JPEG? or mmap with big enough size in > the first place? That's a very good question. You shouldn't be needing to close/open the device for this to work, but between (4) and (5), you'll need to call VIDIOC_S_FMT, to change the videobuf size, and, to be safe, unmap the videobuf memory. A code like the above may give different results depending on the way videobuffer handling is implemented. A good idea is to test it with vivi driver (that uses videobuf), with debugs enabled, and compare with other drivers. I did such test with vivi and it worked properly (although I didn't change the data size). If you want to test, I used the driver-test program, available at the development tree, with the patch bellow. I didn't actually tested to resize the stream, but from vivi logs, the mmapped buffers seem to be properly allocated/deallocated. Cheers, Mauro --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/v4l2-apps/test/driver-test.c b/v4l2-apps/test/driver-test.c --- a/v4l2-apps/test/driver-test.c +++ b/v4l2-apps/test/driver-test.c @@ -30,7 +30,7 @@ int main(void) { struct v4l2_driver drv; struct drv_list *cur; - unsigned int count = 10, i; + unsigned int count = 10, i, j; double freq; if (v4l2_open ("/dev/video0", 1,&drv)<0) { @@ -97,45 +97,47 @@ int main(void) fflush (stdout); sleep(1); - v4l2_mmap_bufs(&drv, 2); + for (j = 0; j < 5; j++) { + v4l2_mmap_bufs(&drv, 2); - v4l2_start_streaming(&drv); + v4l2_start_streaming(&drv); - printf("Waiting for frames...\n"); + printf("Waiting for frames...\n"); - for (i=0;i