Module Name:    src
Committed By:   jakllsch
Date:           Sat Aug 13 02:49:07 UTC 2011

Modified Files:
        src/sys/dev: video.c
        src/sys/sys: videoio.h

Log Message:
Restore binary compatibility with NetBSD 5 binaries that utilize video(4).


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/video.c
cvs rdiff -u -r1.7 -r1.8 src/sys/sys/videoio.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/video.c
diff -u src/sys/dev/video.c:1.26 src/sys/dev/video.c:1.27
--- src/sys/dev/video.c:1.26	Sun Dec 26 23:41:45 2010
+++ src/sys/dev/video.c	Sat Aug 13 02:49:06 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: video.c,v 1.26 2010/12/26 23:41:45 jmcneill Exp $ */
+/* $NetBSD: video.c,v 1.27 2011/08/13 02:49:06 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2008 Patrick Mahoney <p...@polycrystal.org>
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.26 2010/12/26 23:41:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.27 2011/08/13 02:49:06 jakllsch Exp $");
 
 #include "video.h"
 #if NVIDEO > 0
@@ -1781,49 +1781,55 @@
 }
 
 
+/*
+ * Before 64-bit time_t, timeval's tv_sec was 'long'.  Thus on LP64 ports
+ * v4l2_buffer is the same size and layout as before.  However it did change
+ * on LP32 ports, and we thus handle this difference here for "COMPAT_50".
+ */
+
+#ifndef _LP64
 static void
-buf32tobuf(const void *data, struct v4l2_buffer *buf)
+buf50tobuf(const void *data, struct v4l2_buffer *buf)
 {
-	const struct v4l2_buffer32 *b32 = data;
+	const struct v4l2_buffer50 *b50 = data;
 
-	buf->index = b32->index;
-	buf->type = b32->type;
-	buf->bytesused = b32->bytesused;
-	buf->flags = b32->flags;
-	buf->field = b32->field;
-	buf->timestamp.tv_sec = b32->timestamp.tv_sec;
-	buf->timestamp.tv_usec = b32->timestamp.tv_usec;
-	buf->timecode = b32->timecode;
-	buf->sequence = b32->sequence;
-	buf->memory = b32->memory;
-	buf->m.offset = b32->m.offset;
+	buf->index = b50->index;
+	buf->type = b50->type;
+	buf->bytesused = b50->bytesused;
+	buf->flags = b50->flags;
+	buf->field = b50->field;
+	timeval50_to_timeval(&b50->timestamp, &buf->timestamp);
+	buf->timecode = b50->timecode;
+	buf->sequence = b50->sequence;
+	buf->memory = b50->memory;
+	buf->m.offset = b50->m.offset;
 	/* XXX: Handle userptr */
-	buf->length = b32->length;
-	buf->input = b32->input;
-	buf->reserved = b32->reserved;
+	buf->length = b50->length;
+	buf->input = b50->input;
+	buf->reserved = b50->reserved;
 }
 
 static void
-buftobuf32(void *data, const struct v4l2_buffer *buf)
+buftobuf50(void *data, const struct v4l2_buffer *buf)
 {
-	struct v4l2_buffer32 *b32 = data;
+	struct v4l2_buffer50 *b50 = data;
 
-	b32->index = buf->index;
-	b32->type = buf->type;
-	b32->bytesused = buf->bytesused;
-	b32->flags = buf->flags;
-	b32->field = buf->field;
-	b32->timestamp.tv_sec = (uint32_t)buf->timestamp.tv_sec;
-	b32->timestamp.tv_usec = buf->timestamp.tv_usec;
-	b32->timecode = buf->timecode;
-	b32->sequence = buf->sequence;
-	b32->memory = buf->memory;
-	b32->m.offset = buf->m.offset;
+	b50->index = buf->index;
+	b50->type = buf->type;
+	b50->bytesused = buf->bytesused;
+	b50->flags = buf->flags;
+	b50->field = buf->field;
+	timeval_to_timeval50(&buf->timestamp, &b50->timestamp);
+	b50->timecode = buf->timecode;
+	b50->sequence = buf->sequence;
+	b50->memory = buf->memory;
+	b50->m.offset = buf->m.offset;
 	/* XXX: Handle userptr */
-	b32->length = buf->length;
-	b32->input = buf->input;
-	b32->reserved = buf->reserved;
+	b50->length = buf->length;
+	b50->input = buf->input;
+	b50->reserved = buf->reserved;
 }
+#endif
 
 int
 videoioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
@@ -1841,10 +1847,14 @@
 	struct v4l2_control *control;
 	struct v4l2_queryctrl *query;
 	struct v4l2_requestbuffers *reqbufs;
-	struct v4l2_buffer *buf, bufspace;
+	struct v4l2_buffer *buf;
 	v4l2_std_id *stdid;
 	enum v4l2_buf_type *typep;
-	int *ip, error;
+	int *ip;
+#ifndef _LP64
+	struct v4l2_buffer bufspace;
+	int error;
+#endif
 
 	sc = device_private(device_lookup(&video_cd, VIDEOUNIT(dev)));
 
@@ -1960,27 +1970,33 @@
 	case VIDIOC_QUERYBUF:
 		buf = data;
 		return video_query_buf(sc, buf);
-	case VIDIOC_QUERYBUF32:
-		buf32tobuf(data, buf = &bufspace);
+#ifndef _LP64
+	case VIDIOC_QUERYBUF50:
+		buf50tobuf(data, buf = &bufspace);
 		if ((error = video_query_buf(sc, buf)) != 0)
 			return error;
-		buftobuf32(data, buf);
+		buftobuf50(data, buf);
 		return 0;
+#endif
 	case VIDIOC_QBUF:
 		buf = data;
 		return video_queue_buf(sc, buf);
-	case VIDIOC_QBUF32:
-		buf32tobuf(data, buf = &bufspace);
+#ifndef _LP64
+	case VIDIOC_QBUF50:
+		buf50tobuf(data, buf = &bufspace);
 		return video_queue_buf(sc, buf);
+#endif
 	case VIDIOC_DQBUF:
 		buf = data;
 		return video_dequeue_buf(sc, buf);
-	case VIDIOC_DQBUF32:
-		buf32tobuf(data, buf = &bufspace);
+#ifndef _LP64
+	case VIDIOC_DQBUF50:
+		buf50tobuf(data, buf = &bufspace);
 		if ((error = video_dequeue_buf(sc, buf)) != 0)
 			return error;
-		buftobuf32(data, buf);
+		buftobuf50(data, buf);
 		return 0;
+#endif
 	case VIDIOC_STREAMON:
 		typep = data;
 		return video_stream_on(sc, *typep);
@@ -2023,9 +2039,11 @@
 	case VIDIOC_QUERYBUF:
 		str = "VIDIOC_QUERYBUF";
 		break;
-	case VIDIOC_QUERYBUF32:
-		str = "VIDIOC_QUERYBUF32";
+#ifndef _LP64
+	case VIDIOC_QUERYBUF50:
+		str = "VIDIOC_QUERYBUF50";
 		break;
+#endif
 	case VIDIOC_G_FBUF:
 		str = "VIDIOC_G_FBUF";
 		break;
@@ -2038,15 +2056,19 @@
 	case VIDIOC_QBUF:
 		str = "VIDIOC_QBUF";
 		break;
-	case VIDIOC_QBUF32:
-		str = "VIDIOC_QBUF32";
+#ifndef _LP64
+	case VIDIOC_QBUF50:
+		str = "VIDIOC_QBUF50";
 		break;
+#endif
 	case VIDIOC_DQBUF:
 		str = "VIDIOC_DQBUF";
 		break;
-	case VIDIOC_DQBUF32:
-		str = "VIDIOC_DQBUF32";
+#ifndef _LP64
+	case VIDIOC_DQBUF50:
+		str = "VIDIOC_DQBUF50";
 		break;
+#endif
 	case VIDIOC_STREAMON:
 		str = "VIDIOC_STREAMON";
 		break;

Index: src/sys/sys/videoio.h
diff -u src/sys/sys/videoio.h:1.7 src/sys/sys/videoio.h:1.8
--- src/sys/sys/videoio.h:1.7	Sat Nov 14 10:37:27 2009
+++ src/sys/sys/videoio.h	Sat Aug 13 02:49:06 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: videoio.h,v 1.7 2009/11/14 10:37:27 njoly Exp $ */
+/* $NetBSD: videoio.h,v 1.8 2011/08/13 02:49:06 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2005, 2008 Jared D. McNeill <jmcne...@invisible.ca>
@@ -32,6 +32,9 @@
 
 #include <sys/types.h>
 #include <sys/time.h>
+#ifdef _KERNEL
+#include <compat/sys/time.h>
+#endif
 
 #ifndef _KERNEL
 #define __u64	uint64_t
@@ -153,28 +156,27 @@
 	uint32_t	reserved;
 };
 
-struct v4l2_buffer32 {
+#ifdef _KERNEL
+struct v4l2_buffer50 {
 	uint32_t	index;
 	enum v4l2_buf_type type;
 	uint32_t	bytesused;
 	uint32_t	flags;
 	enum v4l2_field	field;
-	struct {
-		uint32_t tv_sec;
-		uint32_t tv_usec;
-	} timestamp;
+	struct timeval50 timestamp;
 	struct v4l2_timecode timecode;
 	uint32_t	sequence;
 	enum v4l2_memory memory;
 	union {
-		uint32_t offset;
-		uint32_t userptr;
+		uint32_t	offset;
+		unsigned long	userptr;
 	} m;
 	uint32_t	length;
 	uint32_t	input;
 	uint32_t	reserved;
 };
 
+#endif
 struct v4l2_rect {
 	int32_t		left;
 	int32_t		top;
@@ -323,7 +325,7 @@
 		struct v4l2_vbi_format vbi;
 		uint8_t		raw_data[200];
 	} fmt;
-} __packed;
+};
 
 struct v4l2_frequency {
 	uint32_t	tuner;
@@ -695,14 +697,11 @@
 /* 6 and 7 are VIDIOC_[SG]_COMP, which are unsupported */
 #define VIDIOC_REQBUFS		_IOWR('V', 8, struct v4l2_requestbuffers)
 #define VIDIOC_QUERYBUF		_IOWR('V', 9, struct v4l2_buffer)
-#define VIDIOC_QUERYBUF32	_IOWR('V', 9, struct v4l2_buffer32)
 #define VIDIOC_G_FBUF		_IOR('V', 10, struct v4l2_framebuffer)
 #define VIDIOC_S_FBUF		_IOW('V', 11, struct v4l2_framebuffer)
 #define VIDIOC_OVERLAY		_IOW('V', 14, int)
 #define VIDIOC_QBUF		_IOWR('V', 15, struct v4l2_buffer)
-#define VIDIOC_QBUF32		_IOWR('V', 15, struct v4l2_buffer32)
 #define VIDIOC_DQBUF		_IOWR('V', 17, struct v4l2_buffer)
-#define VIDIOC_DQBUF32		_IOWR('V', 17, struct v4l2_buffer32)
 #define VIDIOC_STREAMON		_IOW('V', 18, int)
 #define VIDIOC_STREAMOFF	_IOW('V', 19, int)
 #define VIDIOC_G_PARM		_IOWR('V', 21, struct v4l2_streamparm)
@@ -742,4 +741,10 @@
 #define VIDIOC_G_PRIORITY	_IOR('V', 67, enum v4l2_priority)
 #define VIDIOC_S_PRIORITY	_IOW('V', 68, enum v4l2_priority)
 
+#ifdef _KERNEL
+#define VIDIOC_QUERYBUF50	_IOWR('V', 9, struct v4l2_buffer50)
+#define VIDIOC_QBUF50		_IOWR('V', 15, struct v4l2_buffer50)
+#define VIDIOC_DQBUF50		_IOWR('V', 17, struct v4l2_buffer50)
+#endif
+
 #endif /* !_HAVE_SYS_VIDEOIO_H */

Reply via email to