From patchwork Sat Mar 13 22:33:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 85771 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2DMX0u6024165 for ; Sat, 13 Mar 2010 22:33:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759372Ab0CMWc6 (ORCPT ); Sat, 13 Mar 2010 17:32:58 -0500 Received: from smtp-vbr12.xs4all.nl ([194.109.24.32]:4202 "EHLO smtp-vbr12.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759356Ab0CMWc5 convert rfc822-to-8bit (ORCPT ); Sat, 13 Mar 2010 17:32:57 -0500 Received: from tschai.localnet (cm-84.208.87.21.getinternet.no [84.208.87.21]) (authenticated bits=0) by smtp-vbr12.xs4all.nl (8.13.8/8.13.8) with ESMTP id o2DMWs25086168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 13 Mar 2010 23:32:54 +0100 (CET) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [PATCH for v4l-utils] qv4l2: fix UVC support Date: Sat, 13 Mar 2010 23:33:16 +0100 User-Agent: KMail/1.12.2 (Linux/2.6.33-tschai; KDE/4.3.1; x86_64; ; ) Cc: Hans de Goede MIME-Version: 1.0 Message-Id: <201003132333.16618.hverkuil@xs4all.nl> X-Virus-Scanned: by XS4ALL Virus Scanner Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 13 Mar 2010 22:33:00 +0000 (UTC) diff --git a/utils/qv4l2-qt4/general-tab.cpp b/utils/qv4l2-qt4/general-tab.cpp index 50a3edc..706b15d 100644 --- a/utils/qv4l2-qt4/general-tab.cpp +++ b/utils/qv4l2-qt4/general-tab.cpp @@ -198,11 +198,23 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) if (m_querycap.capabilities & V4L2_CAP_STREAMING) { v4l2_requestbuffers reqbuf; - if (reqbufs_user_cap(reqbuf, 1)) + // Yuck. The videobuf framework does not accept a count of 0. + // This is out-of-spec, but it means that the only way to test which + // method is supported is to give it a non-zero count. But non-videobuf + // drivers like uvc do not allow e.g. S_FMT calls after a REQBUFS call + // with non-zero counts unless there is a REQBUFS call with count == 0 + // in between. This is actual proper behavior, although somewhat + // unexpected. So the only way at the moment to do this that works + // everywhere is to call REQBUFS with a count of 1, and then again with + // a count of 0. + if (reqbufs_user_cap(reqbuf, 1)) { m_capMethods->addItem("User pointer I/O", QVariant(methodUser)); - - if (reqbufs_mmap_cap(reqbuf, 1)) + reqbufs_user_cap(reqbuf, 0); + } + if (reqbufs_mmap_cap(reqbuf, 1)) { m_capMethods->addItem("Memory mapped I/O", QVariant(methodMmap)); + reqbufs_mmap_cap(reqbuf, 0); + } } if (m_querycap.capabilities & V4L2_CAP_READWRITE) { m_capMethods->addItem("read()", QVariant(methodRead)); diff --git a/utils/qv4l2-qt4/qv4l2.cpp b/utils/qv4l2-qt4/qv4l2.cpp index 96cb4d7..63881be 100644 --- a/utils/qv4l2-qt4/qv4l2.cpp +++ b/utils/qv4l2-qt4/qv4l2.cpp @@ -352,7 +352,7 @@ void ApplicationWindow::stopCapture() if (-1 == munmap(m_buffers[i].start, m_buffers[i].length)) perror("munmap"); // Free all buffers. - reqbufs_mmap_out(reqbufs, 0); + reqbufs_mmap_cap(reqbufs, 0); break; case methodUser: @@ -360,6 +360,8 @@ void ApplicationWindow::stopCapture() perror("VIDIOC_STREAMOFF"); for (i = 0; i < m_nbuffers; ++i) free(m_buffers[i].start); + // Free all buffers. + reqbufs_user_cap(reqbufs, 0); break; } free(m_buffers);