Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add some extra V4L ioctl() requests to latest V4L userla...



details:   https://anonhg.NetBSD.org/src/rev/c2b520cb45f1
branches:  trunk
changeset: 937177:c2b520cb45f1
user:      rjs <rjs%NetBSD.org@localhost>
date:      Mon Aug 10 19:27:27 2020 +0000

description:
Add some extra V4L ioctl() requests to latest V4L userland to work.

Import sys/videoio.h from OpenBSD, this is just the Linux headers
concatenated together.

diffstat:

 sys/dev/usb/uvideo.c |    12 +-
 sys/dev/video.c      |    71 +-
 sys/sys/videoio.h    |  3951 +++++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 3353 insertions(+), 681 deletions(-)

diffs (truncated from 4264 to 300 lines):

diff -r 70dd182c6bc2 -r c2b520cb45f1 sys/dev/usb/uvideo.c
--- a/sys/dev/usb/uvideo.c      Mon Aug 10 19:20:33 2020 +0000
+++ b/sys/dev/usb/uvideo.c      Mon Aug 10 19:27:27 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvideo.c,v 1.58 2020/05/24 17:28:20 jakllsch Exp $     */
+/*     $NetBSD: uvideo.c,v 1.59 2020/08/10 19:27:27 rjs Exp $  */
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.58 2020/05/24 17:28:20 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.59 2020/08/10 19:27:27 rjs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1909,17 +1909,19 @@
 {
        struct uvideo_softc *sc = addr;
        struct uvideo_stream *vs = sc->sc_stream_in;
-       struct uvideo_pixel_format *pixel_format;
+       struct uvideo_format *video_format;
        int off;
 
        if (sc->sc_dying)
                return EIO;
 
        off = 0;
-       SIMPLEQ_FOREACH(pixel_format, &vs->vs_pixel_formats, entries) {
+       SIMPLEQ_FOREACH(video_format, &vs->vs_formats, entries) {
                if (off++ != index)
                        continue;
-               format->pixel_format = pixel_format->pixel_format;
+               format->pixel_format = video_format->format.pixel_format;
+               format->width = video_format->format.width;
+               format->height = video_format->format.height;
                return 0;
        }
 
diff -r 70dd182c6bc2 -r c2b520cb45f1 sys/dev/video.c
--- a/sys/dev/video.c   Mon Aug 10 19:20:33 2020 +0000
+++ b/sys/dev/video.c   Mon Aug 10 19:27:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: video.c,v 1.37 2020/05/22 11:23:51 jmcneill Exp $ */
+/* $NetBSD: video.c,v 1.38 2020/08/10 19:27:27 rjs Exp $ */
 
 /*
  * Copyright (c) 2008 Patrick Mahoney <pat%polycrystal.org@localhost>
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.37 2020/05/22 11:23:51 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.38 2020/08/10 19:27:27 rjs Exp $");
 
 #include "video.h"
 #if NVIDEO > 0
@@ -808,6 +808,49 @@
 }
 
 static int
+video_enum_framesizes(struct video_softc *sc, struct v4l2_frmsizeenum *frmdesc)
+{
+       const struct video_hw_if *hw;
+       struct video_format vfmt;
+       struct v4l2_format fmt;
+       int err;
+
+       hw = sc->hw_if;
+       if (hw->enum_format == NULL)
+               return ENOTTY;
+
+       err = hw->enum_format(sc->hw_softc, frmdesc->index, &vfmt);
+       if (err != 0)
+               return err;
+
+       video_format_to_v4l2_format(&vfmt, &fmt);
+       if (fmt.fmt.pix.pixelformat != frmdesc->pixel_format) {
+               printf("video_enum_framesizes: type mismatch %x %x\n",
+                   fmt.fmt.pix.pixelformat, frmdesc->pixel_format);
+       }
+       
+       frmdesc->type = V4L2_FRMSIZE_TYPE_DISCRETE; /* TODO: only one type for now */
+       frmdesc->discrete.width = vfmt.width;
+       frmdesc->discrete.height = vfmt.height;
+       return 0;
+}
+
+static int
+video_enum_frameival(struct video_softc *sc, struct v4l2_frmivalenum *frmdesc)
+{
+       const struct video_hw_if *hw;
+
+       hw = sc->hw_if;
+       if (hw->enum_format == NULL)
+               return ENOTTY;
+
+       frmdesc->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+       frmdesc->discrete.numerator = 1;
+       frmdesc->discrete.denominator = 15;
+       return 0;
+}
+
+static int
 video_get_format(struct video_softc *sc,
                      struct v4l2_format *format)
 {
@@ -1870,7 +1913,7 @@
        buf->m.offset = b50->m.offset;
        /* XXX: Handle userptr */
        buf->length = b50->length;
-       buf->input = b50->input;
+       buf->reserved2 = b50->reserved2;
        buf->reserved = b50->reserved;
 }
 
@@ -1891,7 +1934,7 @@
        b50->m.offset = buf->m.offset;
        /* XXX: Handle userptr */
        b50->length = buf->length;
-       b50->input = buf->input;
+       b50->reserved2 = buf->reserved2;
        b50->reserved = buf->reserved;
 }
 #endif
@@ -1914,6 +1957,8 @@
        struct v4l2_requestbuffers *reqbufs;
        struct v4l2_buffer *buf;
        struct v4l2_streamparm *parm;
+       struct v4l2_frmsizeenum *size;
+       struct v4l2_frmivalenum *ival;
        v4l2_std_id *stdid;
        enum v4l2_buf_type *typep;
        int *ip;
@@ -2077,6 +2122,12 @@
        case VIDIOC_STREAMOFF:
                typep = data;
                return video_stream_off(sc, *typep);
+       case VIDIOC_ENUM_FRAMESIZES:
+               size = data;
+               return video_enum_framesizes(sc, size);
+       case VIDIOC_ENUM_FRAMEINTERVALS:
+               ival = data;
+               return video_enum_frameival(sc, ival);
        default:
                DPRINTF(("videoioctl: invalid cmd %s (%lx)\n",
                         video_ioctl_str(cmd), cmd));
@@ -2150,10 +2201,10 @@
                str = "VIDIOC_STREAMOFF";
                break;
        case VIDIOC_G_PARM:
-               str = "VIDIOC_G_PARAM";
+               str = "VIDIOC_G_PARM";
                break;
        case VIDIOC_S_PARM:
-               str = "VIDIOC_S_PARAM";
+               str = "VIDIOC_S_PARM";
                break;
        case VIDIOC_G_STD:
                str = "VIDIOC_G_STD";
@@ -2257,6 +2308,12 @@
        case VIDIOC_S_PRIORITY:
                str = "VIDIOC_S_PRIORITY";
                break;
+       case VIDIOC_ENUM_FRAMESIZES:
+               str = "VIDIOC_ENUM_FRAMESIZES";
+               break;
+       case VIDIOC_ENUM_FRAMEINTERVALS:
+               str = "VIDIOC_FRAMEINTERVALS";
+               break;
        default:
                str = "unknown";
                break;
@@ -2520,7 +2577,7 @@
                buf->memory = V4L2_MEMORY_MMAP;
                buf->m.offset = offset;
                buf->length = PAGE_ALIGN(vs->vs_format.sample_size);
-               buf->input = 0;
+               buf->reserved2 = 0;
                buf->reserved = 0;
 
                offset += buf->length;
diff -r 70dd182c6bc2 -r c2b520cb45f1 sys/sys/videoio.h
--- a/sys/sys/videoio.h Mon Aug 10 19:20:33 2020 +0000
+++ b/sys/sys/videoio.h Mon Aug 10 19:27:27 2020 +0000
@@ -1,34 +1,65 @@
-/* $NetBSD: videoio.h,v 1.11 2018/12/02 00:40:40 christos Exp $ */
-
-/*-
- * Copyright (c) 2005, 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
- * All rights reserved.
+/* $NetBSD: videoio.h,v 1.12 2020/08/10 19:27:28 rjs Exp $ */
+/* $OpenBSD: videoio.h,v 1.16 2017/02/17 06:48:33 feinerer Exp $       */
+/*
+ *  Video for Linux Two header file
+ *
+ *  Copyright (C) 1999-2012 the contributors
+ *  Copyright (C) 2012 Nokia Corporation
+ *  Contact: Sakari Ailus <sakari.ailus%iki.fi@localhost>
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  Alternatively you can redistribute this file under the terms of the
+ *  BSD license as stated below:
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *  3. The names of its contributors may not be used to endorse or promote
+ *     products derived from this software without specific prior written
+ *     permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ *  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *     Header file for v4l or V4L2 drivers and applications
+ * with public API.
+ * All kernel-specific stuff were moved to media/v4l2-dev.h, so
+ * no #if __KERNEL tests are allowed here
+ *
+ *     See https://linuxtv.org for more info
+ *
+ *     Author: Bill Dirks <bill%thedirks.org@localhost>
+ *             Justin Schoeman
+ *              Hans Verkuil <hverkuil%xs4all.nl@localhost>
+ *             et al.
  */
 
-/* See http://v4l2spec.bytesex.org/ for Video4Linux 2 specifications */
-
-#ifndef _HAVE_SYS_VIDEOIO_H
-#define _HAVE_SYS_VIDEOIO_H
+#ifndef _SYS_VIDEOIO_H_
+#define _SYS_VIDEOIO_H_
 
 #include <sys/types.h>
 #include <sys/ioccom.h>
@@ -37,133 +68,1861 @@
 #include <compat/sys/time.h>
 #endif
 
-#ifndef _KERNEL
-#ifndef __linux_sized_types__
-#define __linux_sized_types__
-#define __u64  uint64_t
-#define __u32  uint32_t
-#define __u16  uint16_t
-#define __u8   uint8_t
-#define __s64  int64_t
-#define __s32  int32_t
-#define __s16  int16_t
-#define __s8   int8_t
-#endif /* __linux_sized_types__ */
-#endif
-
-typedef uint64_t v4l2_std_id;
-#define v4l2_fourcc(a,b,c,d) (((uint32_t)(a) << 0) |   \



Home | Main Index | Thread Index | Old Index