rpms/amsn/devel amsn-0.97-libng-fixes.patch, NONE, 1.1 amsn-0.97-libng-libv4l2.patch, NONE, 1.1 amsn.spec, 1.17, 1.18

Hans de Goede jwrdegoede at fedoraproject.org
Wed Oct 22 14:57:12 UTC 2008


Author: jwrdegoede

Update of /cvs/extras/rpms/amsn/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv392

Modified Files:
	amsn.spec 
Added Files:
	amsn-0.97-libng-fixes.patch amsn-0.97-libng-libv4l2.patch 
Log Message:
* Wed Oct 22 2008 Hans de Goede <hdegoede at redhat.com> - 0.97-4
- Patch the webcam part to use libv4l so that it will work with the new gspca
  driver in F-10


amsn-0.97-libng-fixes.patch:

--- NEW FILE amsn-0.97-libng-fixes.patch ---
diff -ur amsn-0.97.orig/utils/linux/capture/libng/plugins/drv0-v4l2.c amsn-0.97/utils/linux/capture/libng/plugins/drv0-v4l2.c
--- amsn-0.97.orig/utils/linux/capture/libng/plugins/drv0-v4l2.c	2007-12-24 19:07:23.000000000 +0100
+++ amsn-0.97/utils/linux/capture/libng/plugins/drv0-v4l2.c	2008-10-22 11:24:17.000000000 +0200
@@ -206,7 +206,7 @@
     int rc;
 
     rc = ioctl(fd,cmd,arg);
-    if (0 == rc && ng_debug < 2)
+    if (rc >= 0 && ng_debug < 2)
 	return rc;
     if (mayfail && errno == mayfail && ng_debug < 2)
 	return rc;
@@ -1014,6 +1014,10 @@
     h->queue = 0;
     h->waiton = 0;
 
+    /* unrequest buffers (only needed for some drivers) */
+    h->reqbufs.count = 0;
+    xioctl(h->fd, VIDIOC_REQBUFS, &h->reqbufs, EINVAL); 
+
     /* turn on preview (if needed) */
     if (h->ov_on != h->ov_enabled) {
 	h->ov_on = h->ov_enabled;
@@ -1051,6 +1055,17 @@
     fmt->width        = h->fmt_v4l2.fmt.pix.width;
     fmt->height       = h->fmt_v4l2.fmt.pix.height;
     fmt->bytesperline = h->fmt_v4l2.fmt.pix.bytesperline;
+    /* struct v4l2_format.fmt.pix.bytesperline is bytesperline for the
+       main plane for planar formats, where as we want it to be the total 
+       bytesperline for all planes */
+    switch (fmt->fmtid) {
+        case VIDEO_YUV422P:
+          fmt->bytesperline *= 2;
+          break;
+        case VIDEO_YUV420P:
+          fmt->bytesperline = fmt->bytesperline * 3 / 2;
+          break;
+    }
     if (0 == fmt->bytesperline)
 	fmt->bytesperline = fmt->width * ng_vfmt_to_depth[fmt->fmtid] / 8;
     h->fmt_me = *fmt;
Only in amsn-0.97/utils/linux/capture/libng/plugins: drv0-v4l2.c.orig
Only in amsn-0.97/utils/linux/capture/libng/plugins: drv0-v4l2.c.rej
Only in amsn-0.97/utils/linux/capture/libng/plugins: drv0-v4l2.c~

amsn-0.97-libng-libv4l2.patch:

--- NEW FILE amsn-0.97-libng-libv4l2.patch ---
diff -ur amsn-0.97.orig/utils/linux/capture/libng/plugins/Rules.mk amsn-0.97/utils/linux/capture/libng/plugins/Rules.mk
--- amsn-0.97.orig/utils/linux/capture/libng/plugins/Rules.mk	2007-12-24 19:07:23.000000000 +0100
+++ amsn-0.97/utils/linux/capture/libng/plugins/Rules.mk	2008-10-22 16:21:09.000000000 +0200
@@ -33,6 +33,8 @@
 	$(capture_dir)/libng/plugins/drv0-v4l2.o \
 	$(capture_dir)/libng/plugins/struct-v4l2.o \
 	$(capture_dir)/libng/plugins/struct-dump.o
+	@$(echo_link_so) -lv4l2
+	@$(link_so) -lv4l2
 
 $(capture_dir)/libng/plugins/drv1-v4l.so: \
 	$(capture_dir)/libng/plugins/drv1-v4l.o \
Only in amsn-0.97/utils/linux/capture/libng/plugins: Rules.mk~
diff -ur amsn-0.97.orig/utils/linux/capture/libng/plugins/drv0-v4l2.c amsn-0.97/utils/linux/capture/libng/plugins/drv0-v4l2.c
--- amsn-0.97.orig/utils/linux/capture/libng/plugins/drv0-v4l2.c	2008-10-22 14:55:50.000000000 +0200
+++ amsn-0.97/utils/linux/capture/libng/plugins/drv0-v4l2.c	2008-10-22 16:33:39.000000000 +0200
@@ -36,12 +36,27 @@
 #include "struct-dump.h"
 #include "struct-v4l2.h"
 
+/* FIXME replace with autoconf detection */
+#define HAVE_LIBV4L  
+
+#ifdef HAVE_LIBV4L
+#include <libv4l2.h>
+#else
+#define v4l2_fd_open(fd, flags) (fd)
+#define v4l2_close close
+#define v4l2_dup dup
+#define v4l2_ioctl ioctl
+#define v4l2_read read  
+#define v4l2_mmap mmap
+#define v4l2_munmap munmap
+#endif  
+
 /* ---------------------------------------------------------------------- */
 
 /* open+close */
 static void*   v4l2_init(char *device);
-static int     v4l2_open(void *handle);
-static int     v4l2_close(void *handle);
+static int     v4l2_open_handle(void *handle);
+static int     v4l2_close_handle(void *handle);
 static int     v4l2_fini(void *handle);
 static struct ng_devinfo* v4l2_probe(int verbose);
 
@@ -134,8 +149,8 @@
     .priority      = 1,
 
     .init          = v4l2_init,
-    .open          = v4l2_open,
-    .close         = v4l2_close,
+    .open          = v4l2_open_handle,
+    .close         = v4l2_close_handle,
     .fini          = v4l2_fini,
     .devname       = v4l2_devname,
     .busname       = v4l2_busname,
@@ -205,7 +220,7 @@
 {
     int rc;
 
-    rc = ioctl(fd,cmd,arg);
+    rc = v4l2_ioctl(fd,cmd,arg);
     if (rc >= 0 && ng_debug < 2)
 	return rc;
     if (mayfail && errno == mayfail && ng_debug < 2)
@@ -262,7 +277,7 @@
     }
 
     h->streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-    ioctl(h->fd,VIDIOC_G_PARM,&h->streamparm);
+    v4l2_ioctl(h->fd,VIDIOC_G_PARM,&h->streamparm);
 
     /* controls */
     for (i = 0; i < MAX_CTRL; i++) {
@@ -487,9 +502,10 @@
 /* ---------------------------------------------------------------------- */
 
 static int
-v4l2_open(void *handle)
+v4l2_open_handle(void *handle)
 {
     struct v4l2_handle *h = handle;
+    int libv4l2_fd;
 
     if (ng_debug)
 	fprintf(stderr, "v4l2: open\n");
@@ -497,22 +513,32 @@
     h->fd = ng_chardev_open(h->device, O_RDWR, MAJOR_NUM, 1);
     if (-1 == h->fd)
 	return -1;
+    /* Note the v4l2_xxx functions are designed so that if they get passed an  
+       unknown fd, the will behave exactly as their regular xxx counterparts,
+       so if v4l2_fd_open fails, we continue as normal (missing the libv4l2
+       custom cam format to normal formats conversion). Chances are big we will
+       still fail then though, as normally v4l2_fd_open only fails if the
+       device is not a v4l2 device. */     
+    libv4l2_fd = v4l2_fd_open(h->fd, 0);  
+    if (libv4l2_fd != -1)  
+        h->fd = libv4l2_fd;  
+
     if (-1 == xioctl(h->fd,VIDIOC_QUERYCAP,&h->cap,EINVAL)) {
-	close(h->fd);
+	v4l2_close(h->fd);
 	return -1;
     }
     return 0;
 }
 
 static int
-v4l2_close(void *handle)
+v4l2_close_handle(void *handle)
 {
     struct v4l2_handle *h = handle;
 
     if (ng_debug)
 	fprintf(stderr, "v4l2: close\n");
     BUG_ON(h->fd == -1,"device not open");
-    close(h->fd);
+    v4l2_close(h->fd);
     h->fd = -1;
     return 0;
 }
@@ -532,7 +558,7 @@
 
     h->fd     = -1;
     h->device = strdup(device ? device : ng_dev.video);
-    if (0 != v4l2_open(h))
+    if (0 != v4l2_open_handle(h))
 	goto err;
 
     if (ng_debug)
@@ -575,12 +601,12 @@
     /* check for MPEG capabilities */
     v4l2_probe_mpeg(h);
 
-    v4l2_close(h);
+    v4l2_close_handle(h);
     return h;
 
  err:
     if (h->fd != -1)
-	close(h->fd);
+	v4l2_close(h->fd);
     if (h)
 	free(h);
     return NULL;
@@ -958,7 +984,7 @@
 	h->buf_me[i].fmt  = h->fmt_me;
 	h->buf_me[i].size = h->buf_me[i].fmt.bytesperline *
 	    h->buf_me[i].fmt.height;
-	h->buf_me[i].data = mmap(NULL, h->buf_v4l2[i].length,
+	h->buf_me[i].data = v4l2_mmap(NULL, h->buf_v4l2[i].length,
 				 PROT_READ | PROT_WRITE, MAP_SHARED,
 				 h->fd, h->buf_v4l2[i].m.offset);
 	if (MAP_FAILED == h->buf_me[i].data) {
@@ -999,7 +1025,7 @@
     unsigned int i;
     
     /* stop capture */
-    if (-1 == ioctl(h->fd,VIDIOC_STREAMOFF,&h->fmt_v4l2.type))
+    if (-1 == v4l2_ioctl(h->fd,VIDIOC_STREAMOFF,&h->fmt_v4l2.type))
 	perror("ioctl VIDIOC_STREAMOFF");
     
     /* free buffers */
@@ -1008,7 +1034,7 @@
 	    ng_waiton_video_buf(&h->buf_me[i]);
 	if (ng_debug)
 	    print_bufinfo(&h->buf_v4l2[i]);
-	if (-1 == munmap(h->buf_me[i].data,h->buf_v4l2[i].length))
+	if (-1 == v4l2_munmap(h->buf_me[i].data,h->buf_v4l2[i].length))
 	    perror("munmap");
     }
     h->queue = 0;
@@ -1133,7 +1159,7 @@
 	buf->info.ts = ng_tofday_to_timestamp(&h->buf_v4l2[frame].timestamp);
     } else {
 	buf = ng_malloc_video_buf(NULL, &h->fmt_me);
-	rc = read(h->fd,buf->data,buf->size);
+	rc = v4l2_read(h->fd,buf->data,buf->size);
 	if (rc < 0) {
 	  perror("v4l2: read");
 	  ng_release_video_buf(buf);
@@ -1163,11 +1189,11 @@
     BUG_ON(h->fd == -1,"device not open");
     buf = ng_malloc_video_buf(NULL, &h->fmt_me);
     if (h->cap.capabilities & V4L2_CAP_READWRITE) {
-	rc = read(h->fd,buf->data,buf->size);
+	rc = v4l2_read(h->fd,buf->data,buf->size);
 	if (-1 == rc  &&  EBUSY == errno  &&  h->ov_on) {
 	    h->ov_on = 0;
 	    xioctl(h->fd, VIDIOC_OVERLAY, &h->ov_on, 0);
-	    rc = read(h->fd,buf->data,buf->size);
+	    rc = v4l2_read(h->fd,buf->data,buf->size);
 	    h->ov_on = 1;
 	    xioctl(h->fd, VIDIOC_OVERLAY, &h->ov_on, 0);
 	}
@@ -1245,7 +1271,7 @@
 	goto done;
 
     /* check for ivtv driver */
-    if (0 == ioctl(h->fd, IVTV_IOC_G_CODEC, &codec)) {
+    if (0 == v4l2_ioctl(h->fd, IVTV_IOC_G_CODEC, &codec)) {
 	h->flags |= CAN_MPEG_PS;
 	h->flags |= CAN_MPEG_TS;
 	h->mpeg = MPEG_TYPE_IVTV;
@@ -1284,13 +1310,13 @@
     {
 	struct ivtv_ioctl_codec codec;
 
-	if (0 != ioctl(h->fd, IVTV_IOC_G_CODEC, &codec))
+	if (0 != v4l2_ioctl(h->fd, IVTV_IOC_G_CODEC, &codec))
 	    return NULL;
 	if (flags & MPEG_FLAGS_PS)
 	    codec.stream_type = IVTV_STREAM_PS;
 	if (flags & MPEG_FLAGS_TS)
 	    codec.stream_type = IVTV_STREAM_TS;
-	if (0 != ioctl(h->fd, IVTV_IOC_S_CODEC, &codec))
+	if (0 != v4l2_ioctl(h->fd, IVTV_IOC_S_CODEC, &codec))
 	    return NULL;
 	return h->device;
     }
Only in amsn-0.97/utils/linux/capture/libng/plugins: drv0-v4l2.c.orig
Only in amsn-0.97/utils/linux/capture/libng/plugins: drv0-v4l2.c.rej
Only in amsn-0.97/utils/linux/capture/libng/plugins: drv0-v4l2.c~


Index: amsn.spec
===================================================================
RCS file: /cvs/extras/rpms/amsn/devel/amsn.spec,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- amsn.spec	12 Feb 2008 10:35:15 -0000	1.17
+++ amsn.spec	22 Oct 2008 14:56:41 -0000	1.18
@@ -3,13 +3,15 @@
 
 Name:           amsn
 Version:        0.97
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        MSN Messenger clone for Linux, Mac and Windows
 
 Group:          Applications/Internet
 License:        GPLv2
 URL:            http://www.amsn-project.net/
 Source0:        http://dl.sourceforge.net/amsn/%{name}-%{version}.tar.bz2
+Patch0:         amsn-0.97-libng-fixes.patch
+Patch1:         amsn-0.97-libng-libv4l2.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  autoconf, desktop-file-utils, tk-devel, which, libpng-devel, libjpeg-devel
@@ -34,6 +36,9 @@
 
 %prep
 %setup -q
+%patch0 -p1
+%patch1 -p1
+
 rm -r utils/bwidget1.8.0
 rm -r skins/default/winicons
 
@@ -125,6 +130,10 @@
 
 
 %changelog
+* Wed Oct 22 2008 Hans de Goede <hdegoede at redhat.com> - 0.97-4
+- Patch the webcam part to use libv4l so that it will work with the new gspca
+  driver in F-10
+
 * Thu Feb 12 2008 Sander Hoentjen <sander at hoentjen.eu> - 0.97-3
 - Rebuilt for gcc-4.3
 




More information about the fedora-extras-commits mailing list