From nobody@FreeBSD.org  Sat Apr 17 04:30:16 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 198F31065672
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 17 Apr 2010 04:30:16 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E24A18FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 17 Apr 2010 04:30:15 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o3H4UFLB013470
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 17 Apr 2010 04:30:15 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o3H4UFjQ013469;
	Sat, 17 Apr 2010 04:30:15 GMT
	(envelope-from nobody)
Message-Id: <201004170430.o3H4UFjQ013469@www.freebsd.org>
Date: Sat, 17 Apr 2010 04:30:15 GMT
From: Henry Hu <henry.hu.sh@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] multimedia/gstreamer-plugins-v4l2 says Device not configured
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         145770
>Category:       ports
>Synopsis:       [patch] multimedia/gstreamer-plugins-v4l2 says Device not configured
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-multimedia
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 17 04:40:01 UTC 2010
>Closed-Date:    Mon Jun 07 17:52:34 UTC 2010
>Last-Modified:  Mon Jun 07 17:52:34 UTC 2010
>Originator:     Henry Hu
>Release:        FreeBSD 8.0-STABLE
>Organization:
Tsinghua University, Beijing, China
>Environment:
FreeBSD henryhu9.net9.org 8.0-STABLE FreeBSD 8.0-STABLE #2: Sat Apr 10 22:11:13 CST 2010     root@henryhu9.net9.org:/usr/obj/usr/src/sys/MYKERNEL  i386

>Description:
After installing multimedia/gstreamer-plugins-v4l2, I still cannot use my webcam in programs such as emesene (SVN version).
With a simple test program, I found that v4l2 plugins failed to enumerate inputs, and says "Device not configured".
Later I found that the v4l2 layer returns EINVAL in linux, but returns ENXIO in freebsd, and the v4l2 plugin did not expect ENXIO.
So I changed the references to EINVAL in v4l2_calls.c to ENXIO, and the webcam works.
Maybe it's better to change the return code of the v4l2 layer in freebsd, so other programs would not bother from this problem.
>How-To-Repeat:
1. Install webcamd, video4bsd-kmod, and other v4l2 related things
2. Install gstreamer-plugins-v4l2
3. Try the following program, or test with emesene SVN version, or with pidgin.
http://giss.tv/wiki/index.php/Streaming_Tools#GStreamer_2
However, since the 320x240 mode does not work here, I changed it to 640x480.
>Fix:
see the patch below.

Patch attached with submission follows:

--- sys/v4l2/v4l2_calls.c.bak	2010-02-24 18:42:07.000000000 +0800
+++ sys/v4l2/v4l2_calls.c	2010-04-17 12:05:30.000000000 +0800
@@ -129,7 +129,7 @@
 
     input.index = n;
     if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
-      if (errno == EINVAL)
+      if (errno == EINVAL || errno == ENXIO)
         break;                  /* end of enumeration */
       else {
         GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
@@ -203,7 +203,7 @@
     standard.index = n;
 
     if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
-      if (errno == EINVAL || errno == ENOTTY)
+      if (errno == EINVAL || errno == ENOTTY || errno == ENXIO)
         break;                  /* end of enumeration */
       else {
         GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
@@ -247,7 +247,7 @@
 
     control.id = n;
     if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
-      if (errno == EINVAL) {
+      if (errno == EINVAL || errno == ENXIO) {
         if (n < V4L2_CID_PRIVATE_BASE) {
           GST_DEBUG_OBJECT (e, "skipping control %08x", n);
           /* continue so that we also check private controls */


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->freebsd-multimedia 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sat Apr 17 04:40:12 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145770 

From: Henry Hu <henry.hu.sh@gmail.com>
To: bug-followup@freebsd.org, henry.hu.sh@gmail.com
Cc:  
Subject: Re: ports/145770: [patch] multimedia/gstreamer-plugins-v4l2 says 
	Device not configured
Date: Sat, 17 Apr 2010 13:11:43 +0800

 I'm sorry, after upgrading video4bsd to cuse4bsd and upgrading
 webcamd, the problem goes. By the way, it also works at 320x240. Sorry
 for the inconvenience.
 However, there's a new problem: the first time I start a client after
 restarting webcamd, the client works, but it cannot exit unless I
 restart webcamd. However, if I do not restart webcamd, then the new
 clients started afterward exits cleanly. I found that the client is in
 the close syscall, and the call goes into cuse, and in
 cuse_client_receive_command it blocks in the cv_wait. I'm inspecting
 the problem.
 
 
 -- 
 Cheers,
 Henry
State-Changed-From-To: open->feedback 
State-Changed-By: sylvio 
State-Changed-When: Mon Apr 19 12:18:54 UTC 2010 
State-Changed-Why:  
- Waiting more detail of problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145770 

From: Sylvio Cesar Teixeira <sylvio@FreeBSD.org>
To: bug-followup@FreeBSD.org, henry.hu.sh@gmail.com
Cc:  
Subject: Re: ports/145770: [patch] multimedia/gstreamer-plugins-v4l2 says 
	Device not configured
Date: Mon, 19 Apr 2010 09:21:58 -0300

 Ok, as soon as possible report in more detail the problem. We are
 awaiting your return.

From: Henry Hu <henry.hu.sh@gmail.com>
To: bug-followup@freebsd.org, henry.hu.sh@gmail.com
Cc:  
Subject: Re: ports/145770: [patch] multimedia/gstreamer-plugins-v4l2 says 
	Device not configured
Date: Mon, 7 Jun 2010 20:37:25 +0800

 My webcam went wrong after the last post. After I fixed it and
 upgraded to new version of drivers(cuse4bsd 0.1.9, webcamd 0.1.14),
 the new problem also disappeared....
 Sorry for the inconvenience, and please close this PR.
 
 
 -- 
 Cheers,
 Henry
State-Changed-From-To: feedback->closed 
State-Changed-By: stefan 
State-Changed-When: Mon Jun 7 17:51:55 UTC 2010 
State-Changed-Why:  
Closed on submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145770 
>Unformatted:
