Re: Initialize v4l2_requestbuffers struct to avoid invalid mmap
On Thu, May 28, 2020 at 12:23:58PM +0200, Martin Pieuchot wrote: > On 26/05/20(Tue) 11:30, Ingo Feinerer wrote: > > video(1) supports reading frames from a webcam via mmap(). To inform the > > V4L2 device about the number of desired buffers containing the frames to > > be memory-mapped, a VIDIOC_REQBUFS ioctl call is used. > > > > At the moment the v4l2_requestbuffers struct used for the VIDIOC_REQBUFS > > ioctl > > is only partially initialized which leads to an invalid mmap for my webcam: > > The kernel driver, uvideo(4) or utvfu(4) is responsible for the rest of > the initialization. Thanks for the hint. uvideo_reqbufs() is ignoring both struct members `type` and `memory` so it makes no difference when using video(1) as is. I wrote a small program that just fetches one frame and can confirm it works. However, I have a camera that only supports the MJPEG encoding which video(1) cannot handle. So I am using libv4l (pkg_add libv4l) which can convert encodings on the fly: LD_PRELOAD=/usr/local/lib/v4l2convert.so video libv4l inspects the `type` and `memory` struct members (https://git.linuxtv.org/v4l-utils.git/tree/lib/libv4l2/libv4l2.c#n1308) and fails if `memory != V4L2_MEMORY_MMAP`. So the real question is if video(1) should "support" libv4l ... Best regards, Ingo
Initialize v4l2_requestbuffers struct to avoid invalid mmap
video(1) supports reading frames from a webcam via mmap(). To inform the V4L2 device about the number of desired buffers containing the frames to be memory-mapped, a VIDIOC_REQBUFS ioctl call is used. At the moment the v4l2_requestbuffers struct used for the VIDIOC_REQBUFS ioctl is only partially initialized which leads to an invalid mmap for my webcam: video: mmap: Invalid argument With the following diff applied my camera works (only on EHCI ports with USB 3.0 disabled in BIOS but that is a different story). OK? Index: video.c === RCS file: /cvs/xenocara/app/video/video.c,v retrieving revision 1.29 diff -u -p -r1.29 video.c --- video.c 6 Nov 2019 05:46:51 - 1.29 +++ video.c 26 May 2020 09:14:39 - @@ -1354,6 +1354,8 @@ mmap_init(struct video *vid) /* request buffers */ rb.count = MMAP_NUM_BUFS; + rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + rb.memory = V4L2_MEMORY_MMAP; r = ioctl(vid->dev.fd, VIDIOC_REQBUFS, ); if (r == -1) { warn("ioctl VIDIOC_REQBUFS");
Re: problems with libm
Moritz Buhl wrote: > ... I noticed that some floating point operations cause failures of other > tests. > ... > Many edge cases for complex floating point operations are not covered at all. Hi, https://marc.info/?l=openbsd-tech=150737856618497=2 is another example of an edge case for complex floating point operations. https://github.com/wch/r-source/blob/trunk/src/main/complex.c#L452-L455 gives a solution by checking if the imaginary part of the input complex number is too large (as otherwise sinh() is called which grows exponentially (see e.g. https://www.wolframalpha.com/input/?i=sinh(x) ) resulting in an overflow.) Note that the ctan() implementation in R is under GPL, so I am unsure if the check can be taken as is and committed to OpenBSD. s_ctanf.c probably needs a similar treatment. Best regards, Ingo Index: s_ctan.c === RCS file: /cvs/src/lib/libm/src/s_ctan.c,v retrieving revision 1.7 diff -u -p -r1.7 s_ctan.c --- s_ctan.c12 Sep 2016 19:47:02 - 1.7 +++ s_ctan.c11 Jul 2019 12:31:41 - @@ -135,9 +135,11 @@ double complex ctan(double complex z) { double complex w; - double d; + double d, wy, x, y; - d = cos (2.0 * creal (z)) + cosh (2.0 * cimag (z)); + x = 2.0 * creal(z); + y = 2.0 * cimag(z); + d = cos(x) + cosh(y); if (fabs(d) < 0.25) d = _ctans (z); @@ -148,7 +150,12 @@ ctan(double complex z) return (w); } - w = sin (2.0 * creal(z)) / d + (sinh (2.0 * cimag(z)) / d) * I; + if (isnan(y) || fabs(y) < 50.0) + wy = sinh(y) / d; + else + wy = (y < 0 ? -1.0 : 1.0); + + w = sin(x) / d + wy * I; return (w); } DEF_STD(ctan);
if_umb.c: typos
A few messsage -> message fixes. Index: if_umb.c === RCS file: /cvs/src/sys/dev/usb/if_umb.c,v retrieving revision 1.21 diff -u -p -r1.21 if_umb.c --- if_umb.c2 Oct 2018 19:49:10 - 1.21 +++ if_umb.c14 Jan 2019 13:16:50 - @@ -1197,7 +1197,7 @@ umb_decode_response(struct umb_softc *sc umb_command_done(sc, response, len); break; default: - DPRINTF("%s: discard messsage %s\n", DEVNAM(sc), + DPRINTF("%s: discard message %s\n", DEVNAM(sc), umb_request2str(type)); break; } @@ -1211,19 +1211,19 @@ umb_handle_indicate_status_msg(struct um uint32_t cid; if (len < sizeof (*m)) { - DPRINTF("%s: discard short %s messsage\n", DEVNAM(sc), + DPRINTF("%s: discard short %s message\n", DEVNAM(sc), umb_request2str(letoh32(m->hdr.type))); return; } if (memcmp(m->devid, umb_uuid_basic_connect, sizeof (m->devid))) { - DPRINTF("%s: discard %s messsage for other UUID '%s'\n", + DPRINTF("%s: discard %s message for other UUID '%s'\n", DEVNAM(sc), umb_request2str(letoh32(m->hdr.type)), umb_uuid2str(m->devid)); return; } infolen = letoh32(m->infolen); if (len < sizeof (*m) + infolen) { - DPRINTF("%s: discard truncated %s messsage (want %d, got %d)\n", + DPRINTF("%s: discard truncated %s message (want %d, got %d)\n", DEVNAM(sc), umb_request2str(letoh32(m->hdr.type)), (int)sizeof (*m) + infolen, len); return; @@ -2333,7 +2333,7 @@ umb_command_done(struct umb_softc *sc, v int qmimsg = 0; if (len < sizeof (*cmd)) { - DPRINTF("%s: discard short %s messsage\n", DEVNAM(sc), + DPRINTF("%s: discard short %s message\n", DEVNAM(sc), umb_request2str(letoh32(cmd->hdr.type))); return; } @@ -2341,7 +2341,7 @@ umb_command_done(struct umb_softc *sc, v if (memcmp(cmd->devid, umb_uuid_basic_connect, sizeof (cmd->devid))) { if (memcmp(cmd->devid, umb_uuid_qmi_mbim, sizeof (cmd->devid))) { - DPRINTF("%s: discard %s messsage for other UUID '%s'\n", + DPRINTF("%s: discard %s message for other UUID '%s'\n", DEVNAM(sc), umb_request2str(letoh32(cmd->hdr.type)), umb_uuid2str(cmd->devid)); return; @@ -2370,7 +2370,7 @@ umb_command_done(struct umb_softc *sc, v infolen = letoh32(cmd->infolen); if (len < sizeof (*cmd) + infolen) { - DPRINTF("%s: discard truncated %s messsage (want %d, got %d)\n", + DPRINTF("%s: discard truncated %s message (want %d, got %d)\n", DEVNAM(sc), umb_cid2str(cid), (int)sizeof (*cmd) + infolen, len); return;
ctan(3) NaN
Hi, I think I found a bug/inconsistency/regression in ctan(3) introduced somewhere after 6.1 release. Originally observed in math/R (https://marc.info/?l=openbsd-ports=150728711530471=2) the behavior can be reproduced with following C program: --8<--- #include #include #include int main(int argc, char *argv[]) { // http://en.cppreference.com/w/c/numeric/complex/ctan double complex z = ctan(1); // behaves like real tangent along the real line printf("tan(1+0i) = %f%+fi ( tan(1)=%f)\n", creal(z), cimag(z), tan(1)); // http://en.cppreference.com/w/c/numeric/complex/ctan double complex z2 = ctan(I); // behaves like tanh along the imaginary line printf("tan(0+1i) = %f%+fi (tanh(1)=%f)\n", creal(z2), cimag(z2), tanh(1)); double complex z3 = ctan(1+1000I); printf("tan(1+1000i) = %f%+fi\n", creal(z3), cimag(z3)); } --8<--- cc ctan.c -lm ./a.out The correct solution for the z3 example is "0+1i". On a -current amd64 system (both clang and gcc give identical results): $ ./a.out tan(1+0i) = 1.557408+0.00i ( tan(1)=1.557408) tan(0+1i) = 0.00+0.761594i (tanh(1)=0.761594) tan(1+1000i) = -nan-nani On 6.1 release amd64 with gcc 4.2.1: $ ./a.out tan(1+0i) = 1.557408+0.00i ( tan(1)=1.557408) tan(0+1i) = 0.00+0.761594i (tanh(1)=0.761594) tan(1+1000i) = 0.00-nani This result seems to be "sufficiently different from wrong" that R is somehow able to return the correct solution on 6.1 release: R> (z <- tan(1+1000i)) [1] 0+1i On a Debian 9.1 Linux with gcc 6.3.0: $ ./a.out tan(1+0i) = 1.557408+0.00i ( tan(1)=1.557408) tan(0+1i) = 0.00+0.761594i (tanh(1)=0.761594) tan(1+1000i) = 0.00+1.00i Ideas, pointers and solutions are highly appreciated. Best regards, Ingo
Re: Sync sys/videoio.h with recent Linux kernel
On Sun, Jan 29, 2017 at 11:23:06AM +0100, Martin Pieuchot wrote: > On 28/01/17(Sat) 11:55, Ingo Feinerer wrote: > > in a previous commit > > (http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/videoio.h?rev=1.12=text/x-cvsweb-markup) > > we updated our V4L2 API. However, one file (v4l2-common.h) could not be > > inlined as it was only GPL2 licensed. > > > > After discussion with the authors they agreed to dual license (GPL + BSD) > > this > > file as well > > (https://git.linuxtv.org/media_tree.git/commit/?id=80100fd9ebb9f2414892a1178d26a4253e6c0bcf) > > which allows us to fully comply with the V4L2 API. The attached diff > > implements this and syncs with videodev2.h from the Linux kernel version > > 4.10-rc5 at the same time > > (https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/videodev2.h?id=refs/tags/v4.10-rc5). > > > > (The sync with a recent Linux videodev2.h is a prerequisite for updating the > > port multimedia/libv4l to 1.12.2.) > > > > I compiled a current kernel on amd64. My camera still works fine (tested > > with > > luvcview and baresip in combination with libv4l 1.12.2). > > > > OK? > > This needs to go in a bulk since most users of this API are ports. May I ask for OKs after naddy@'s successful amd64 bulk build? Best regards, Ingo
Sync sys/videoio.h with recent Linux kernel
Hi, in a previous commit (http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/videoio.h?rev=1.12=text/x-cvsweb-markup) we updated our V4L2 API. However, one file (v4l2-common.h) could not be inlined as it was only GPL2 licensed. After discussion with the authors they agreed to dual license (GPL + BSD) this file as well (https://git.linuxtv.org/media_tree.git/commit/?id=80100fd9ebb9f2414892a1178d26a4253e6c0bcf) which allows us to fully comply with the V4L2 API. The attached diff implements this and syncs with videodev2.h from the Linux kernel version 4.10-rc5 at the same time (https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/videodev2.h?id=refs/tags/v4.10-rc5). (The sync with a recent Linux videodev2.h is a prerequisite for updating the port multimedia/libv4l to 1.12.2.) I compiled a current kernel on amd64. My camera still works fine (tested with luvcview and baresip in combination with libv4l 1.12.2). OK? Best regards, Ingo Index: sys/sys/videoio.h === RCS file: /cvs/src/sys/sys/videoio.h,v retrieving revision 1.14 diff -u -p -r1.14 videoio.h --- sys/sys/videoio.h 27 Jan 2016 13:07:09 - 1.14 +++ sys/sys/videoio.h 28 Jan 2017 10:45:55 - @@ -3,6 +3,8 @@ * Video for Linux Two header file * * Copyright (C) 1999-2012 the contributors + * Copyright (C) 2012 Nokia Corporation + * Contact: Sakari Ailus* * 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 @@ -47,7 +49,7 @@ * All kernel-specific stuff were moved to media/v4l2-dev.h, so * no #if __KERNEL tests are allowed here * - * See http://linuxtv.org for more info + * See https://linuxtv.org for more info * * Author: Bill Dirks * Justin Schoeman @@ -60,8 +62,84 @@ #include #include #include -/* Ignore #include as it is GPL2. - * Inline #include +#ifndef __u8 +typedef u_int8_t __u8; +#endif +#ifndef __u16 +typedef u_int16_t __u16; +#endif +#ifndef __u32 +typedef u_int32_t __u32; +#endif +#ifndef __u64 +typedef u_int64_t __u64; +#endif +#ifndef __s32 +typedef int32_t __s32; +#endif +#ifndef __s64 +typedef int64_t __s64; +#endif +#ifndef __le32 +typedef __u32 __le32; +#endif +/* Inline #include + * (v4l2-common.h was split off from videodev2.h and has the same BSD license.) + * + * Begin of v4l2-common.h + */ +/* + * + * Selection interface definitions + * + */ + +/* Current cropping area */ +#define V4L2_SEL_TGT_CROP 0x +/* Default cropping area */ +#define V4L2_SEL_TGT_CROP_DEFAULT 0x0001 +/* Cropping bounds */ +#define V4L2_SEL_TGT_CROP_BOUNDS 0x0002 +/* Native frame size */ +#define V4L2_SEL_TGT_NATIVE_SIZE 0x0003 +/* Current composing area */ +#define V4L2_SEL_TGT_COMPOSE 0x0100 +/* Default composing area */ +#define V4L2_SEL_TGT_COMPOSE_DEFAULT 0x0101 +/* Composing bounds */ +#define V4L2_SEL_TGT_COMPOSE_BOUNDS0x0102 +/* Current composing area plus all padding pixels */ +#define V4L2_SEL_TGT_COMPOSE_PADDED0x0103 + +/* Backward compatibility target definitions --- to be removed. */ +#define V4L2_SEL_TGT_CROP_ACTIVE V4L2_SEL_TGT_CROP +#define V4L2_SEL_TGT_COMPOSE_ACTIVEV4L2_SEL_TGT_COMPOSE +#define V4L2_SUBDEV_SEL_TGT_CROP_ACTUALV4L2_SEL_TGT_CROP +#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL V4L2_SEL_TGT_COMPOSE +#define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDSV4L2_SEL_TGT_CROP_BOUNDS +#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS V4L2_SEL_TGT_COMPOSE_BOUNDS + +/* Selection flags */ +#define V4L2_SEL_FLAG_GE (1 << 0) +#define V4L2_SEL_FLAG_LE (1 << 1) +#define V4L2_SEL_FLAG_KEEP_CONFIG (1 << 2) + +/* Backward compatibility flag definitions --- to be removed. */ +#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE V4L2_SEL_FLAG_GE +#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE +#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG + +struct v4l2_edid { + __u32 pad; + __u32 start_block; + __u32 blocks; + __u32 reserved[5]; + __u8 *edid; +}; +/* + * End of v4l2-common.h + */ +/* Inline #include * (v4l2-controls.h was split off from videodev2.h and has the same BSD license.) * * Begin of v4l2-controls.h @@ -175,8 +253,10 @@ enum v4l2_colorfx { * We reserve 16 controls for this driver. */ #define V4L2_CID_USER_S2255_BASE (V4L2_CID_USER_BASE + 0x1030) -/* The base for the si476x driver controls. See include/media/si476x.h for the list - * of controls. Total of 16 controls is reserved for this driver */ +/* + * The base for the si476x driver controls. See include/media/drv-intf/si476x.h + * for the list of controls. Total of 16 controls is reserved for this driver + */ #define V4L2_CID_USER_SI476X_BASE (V4L2_CID_USER_BASE + 0x1040) /* The base for the TI VPE driver
Re: List Ericsson N5321gw as supported umb(4) device
On Thu, Nov 24, 2016 at 07:01:52PM +0100, Otto Moerbeek wrote: > On Wed, Nov 23, 2016 at 08:56:53PM +0100, Ingo Feinerer wrote: > > the "Lenovo N5321gw" is working for me with umb(4) > > (https://marc.info/?l=openbsd-misc=147992993614369=2). So mention it > > as a supported device in umb.4? > > > > (Lenovo seems to call it Ericsson N5321gw on its support sites, so I'll > > use this wording.) > > > > OK? > > This is a different card than Lenovo H5321gw, right? I have that one, > but there are some problems with which make it work non-optimal. > These problems are being ironed out as we speak. I do not know. The Lenovo support site is quite confusing for me: http://support.lenovo.com/downloads/ds039685 Lenovo lists a single firmware for H5321gw/C5621gw/N5321gw but on the other side different names are explicitly used: $ usbdevs -v port 4 addr 2: high speed, self powered, config 1, N5321 gw(0x193e), Lenovo(0x0bdb), rev 0.00 Best regards, Ingo
List Ericsson N5321gw as supported umb(4) device
Hi, the "Lenovo N5321gw" is working for me with umb(4) (https://marc.info/?l=openbsd-misc=147992993614369=2). So mention it as a supported device in umb.4? (Lenovo seems to call it Ericsson N5321gw on its support sites, so I'll use this wording.) OK? Best regards, Ingo Index: umb.4 === RCS file: /cvs/src/share/man/man4/umb.4,v retrieving revision 1.4 diff -u -p -r1.4 umb.4 --- umb.4 22 Aug 2016 06:45:12 - 1.4 +++ umb.4 23 Nov 2016 19:27:23 - @@ -44,6 +44,7 @@ PIN again even if the system was reboote The following devices should work: .Pp .Bl -tag -width Ds -offset indent -compact +.It Ericsson N5321gw .It Medion Mobile S4222 (MediaTek OEM) .It Sierra Wireless EM8805 .It Sierra Wireless MC8305
Medion Mobile S4222 works with umb(4)
Hi, just a short report that the "Medion Mobile S4222" UMTS stick (attached via USB) works fine with the new umb(4): umsm0 at uhub0 port 2 configuration 1 interface 0 "MediaTek Inc Product" rev 2.00/3.00 addr 10 umsm0 detached umb1 at uhub0 port 2 configuration 1 interface 0 "MediaTek Inc Product" rev 2.00/3.00 addr 10 umsm0 at uhub0 port 2 configuration 1 interface 2 "MediaTek Inc Product" rev 2.00/3.00 addr 10 ucom3 at umsm0 umsm1 at uhub0 port 2 configuration 1 interface 3 "MediaTek Inc Product" rev 2.00/3.00 addr 10 ucom4 at umsm1 umsm2 at uhub0 port 2 configuration 1 interface 4 "MediaTek Inc Product" rev 2.00/3.00 addr 10 ucom5 at umsm2 umsm3 at uhub0 port 2 configuration 1 interface 5 "MediaTek Inc Product" rev 2.00/3.00 addr 10 ucom6 at umsm3 Is it worth documenting this (in analogy to umsm(4))? (Btw. mdoc(7) states for "Tn": "do not use this in new manuals". However, for consistency with the existing entries I kept it.) Best regards, Ingo Index: umb.4 === RCS file: /cvs/src/share/man/man4/umb.4,v retrieving revision 1.2 diff -u -p -r1.2 umb.4 --- umb.4 20 Jun 2016 09:03:08 - 1.2 +++ umb.4 24 Jun 2016 12:42:30 - @@ -44,6 +44,7 @@ PIN again even if the system was reboote The following devices should work: .Pp .Bl -tag -width Ds -offset indent -compact +.It Tn Medion Mobile S4222 (MediaTek OEM) .It Tn Sierra Wireless EM8805 .It Tn Sierra Wireless MC8305 .El
Adapt video.4 for recent videoio.h change
Hi, video.4 manual page diff to cope with recent videoio.h change. OK? Best regards, Ingo Index: video.4 === RCS file: /cvs/src/share/man/man4/video.4,v retrieving revision 1.12 diff -u -p -r1.12 video.4 --- video.4 18 Oct 2014 08:01:34 - 1.12 +++ video.4 1 Jan 2016 16:29:35 - @@ -54,31 +54,34 @@ struct v4l2_capability { u_int8_tbus_info[32]; u_int32_t version; u_int32_t capabilities; - u_int32_t reserved[4]; + u_int32_t device_caps; + u_int32_t reserved[3]; }; .Ed .It Dv VIDIOC_ENUM_FMT Fa "struct v4l2_fmtdesc *" Enumerate image formats. .Bd -literal struct v4l2_fmtdesc { - u_int32_t index; - enum v4l2_buf_type type; - u_int32_t flags; - u_int8_tdescription[32]; - u_int32_t pixelformat; - u_int32_t reserved[4]; + u_int32_t index; + u_int32_t type; + u_int32_t flags; + u_int8_tdescription[32]; + u_int32_t pixelformat; + u_int32_t reserved[4]; }; .Ed .It Dv VIDIOC_S_FMT Fa "struct v4l2_format *" Set the data format. .Bd -literal struct v4l2_format { - enum v4l2_buf_type type; + u_int32_t type; union { struct v4l2_pix_format pix; + struct v4l2_pix_format_mplane pix_mp; struct v4l2_window win; struct v4l2_vbi_format vbi; struct v4l2_sliced_vbi_format sliced; + struct v4l2_sdr_format sdr; u_int8_traw_data[200]; } fmt; }; @@ -99,7 +102,8 @@ struct v4l2_input { u_int32_t tuner; v4l2_std_id std; u_int32_t status; - u_int32_t reserved[32]; + u_int32_t capabilities; + u_int32_t reserved[3]; }; .Ed .It Dv VIDIOC_G_INPUT Fa "int *" @@ -110,10 +114,10 @@ Select the current video input. Initiate memory mapping or user pointer I/O. .Bd -literal struct v4l2_requestbuffers { - u_int32_t count; - enum v4l2_buf_type type; - enum v4l2_memorymemory; - u_int32_t reserved[2]; + u_int32_t count; + u_int32_t type; + u_int32_t memory; + u_int32_t reserved[2]; }; .Ed .It Dv VIDIOC_QUERYBUF Fa "struct v4l2_buffer *" @@ -121,20 +125,22 @@ Query the status of a buffer. .Bd -literal struct v4l2_buffer { u_int32_t index; - enum v4l2_buf_type type; + u_int32_t type; u_int32_t bytesused; u_int32_t flags; - enum v4l2_field field; + u_int32_t field; struct timeval timestamp; struct v4l2_timecodetimecode; u_int32_t sequence; - enum v4l2_memorymemory; + u_int32_t memory; union { - u_int32_t offset; - unsigned long userptr; + u_int32_t offset; + unsigned long userptr; + struct v4l2_plane *planes; + int32_t fd; } m; u_int32_t length; - u_int32_t input; + u_int32_t reserved2; u_int32_t reserved; }; .Ed @@ -169,7 +175,7 @@ struct v4l2_frmivalemun { union { struct v4l2_fract discrete; struct v4l2_frmival_stepwisestepwise; - } un; + }; u_int32_t reserved[2]; }; @@ -183,7 +189,7 @@ struct v4l2_frmival_stepwise { Set streaming parameters. .Bd -literal struct v4l2_streamparm { - enum v4l2_buf_type type; + u_int32_t type; union { struct v4l2_captureparm capture; struct v4l2_outputparm output; @@ -218,15 +224,15 @@ Same structures as for Enumerate control items. .Bd -literal struct v4l2_queryctrl { - u_int32_t id; - enum v4l2_ctrl_type type; - u_int8_tname[32]; - int32_t minimum; - int32_t maximum; - int32_t step; - int32_t default_value; - u_int32_t flags; - u_int32_t reserved[2]; + u_int32_t id; + u_int32_t type; + u_int8_tname[32]; + int32_t minimum; + int32_t maximum; + int32_t step; + int32_t default_value; + u_int32_t flags; + u_int32_t reserved[2]; }; .Ed .El @@ -242,6
Update V4L2 API (sys/videoio.h)
Hi, I would like to update our V4L2 (Video for Linux Two) API. The plan is to sync sys/videoio.h with a recent version of linux/videodev2.h (which has a BSD license statement in it) from the Linux kernel sources. However, videodev2.h now includes two additional headers: 1) linux/v4l2-common.h: GPL2 licensed 2) linux/v4l2-controls.h: has the same BSD license statement as videodev2.h as it was split off from it. The proposed diff completely ignores v4l2-common.h. That should work out as it is not designed to be included directly, contains only new #defines and structs (compared to what we have now in videoio.h), and is very short. As a consequence I had to comment out two lines in videoio.h which are not present in our current version anyway. As there is now just v4l2-controls.h left I propose to merge this file directly back into videoio.h. The alternative would be to have it as a separate file sys/v4l2-controls.h. In Linux it is not designed to be included on its own (but just by videodev2.h). This proposal is a revised version of https://marc.info/?l=openbsd-cvs=145019666410552=2 (which was reverted because of GPL2 considerations) which worked out in a ports bulk build by ajacoutot@. I am pretty confident that skipping v4l2-common.h does not hurt us, so no new bulk build should be strictly necessary. The original version had two OKs but I would like to restart the process because of the restructuring. So I am looking for feedback and OKs. (After that I'd like to address whitespace and formatting in videoio.h to ease further syncs. Moreover, the man page video.4 will be updated as well.) Best regards, Ingo Index: videoio.h === RCS file: /cvs/src/sys/sys/videoio.h,v retrieving revision 1.11 diff -u -p -r1.11 videoio.h --- videoio.h 15 Dec 2015 17:01:44 - 1.11 +++ videoio.h 20 Dec 2015 08:20:01 - @@ -2,7 +2,7 @@ /* * Video for Linux Two header file * - * Copyright (C) 1999-2007 the contributors + * Copyright (C) 1999-2012 the contributors * * 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 @@ -59,6 +59,926 @@ #define _SYS_VIDEOIO_H_ #include #include +/* Ignore #include as it is GPL2. + * Inline #include + * (v4l2-controls.h was split off from videodev2.h and has the same BSD license.) + * + * Begin of v4l2-controls.h + */ +/* Control classes */ +#define V4L2_CTRL_CLASS_USER 0x0098 /* Old-style 'user' controls */ +#define V4L2_CTRL_CLASS_MPEG 0x0099 /* MPEG-compression controls */ +#define V4L2_CTRL_CLASS_CAMERA 0x009a /* Camera class controls */ +#define V4L2_CTRL_CLASS_FM_TX 0x009b /* FM Modulator controls */ +#define V4L2_CTRL_CLASS_FLASH 0x009c /* Camera flash controls */ +#define V4L2_CTRL_CLASS_JPEG 0x009d /* JPEG-compression controls */ +#define V4L2_CTRL_CLASS_IMAGE_SOURCE 0x009e /* Image source controls */ +#define V4L2_CTRL_CLASS_IMAGE_PROC 0x009f /* Image processing controls */ +#define V4L2_CTRL_CLASS_DV 0x00a0 /* Digital Video controls */ +#define V4L2_CTRL_CLASS_FM_RX 0x00a1 /* FM Receiver controls */ +#define V4L2_CTRL_CLASS_RF_TUNER 0x00a2 /* RF tuner controls */ +#define V4L2_CTRL_CLASS_DETECT 0x00a3 /* Detection controls */ + +/* User-class control IDs */ + +#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) +#define V4L2_CID_USER_BASE V4L2_CID_BASE +#define V4L2_CID_USER_CLASS(V4L2_CTRL_CLASS_USER | 1) +#define V4L2_CID_BRIGHTNESS(V4L2_CID_BASE+0) +#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) +#define V4L2_CID_SATURATION(V4L2_CID_BASE+2) +#define V4L2_CID_HUE (V4L2_CID_BASE+3) +#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5) +#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6) +#define V4L2_CID_AUDIO_BASS(V4L2_CID_BASE+7) +#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) +#define V4L2_CID_AUDIO_MUTE(V4L2_CID_BASE+9) +#define V4L2_CID_AUDIO_LOUDNESS(V4L2_CID_BASE+10) +#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) /* Deprecated */ +#define V4L2_CID_AUTO_WHITE_BALANCE(V4L2_CID_BASE+12) +#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) +#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) +#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) +#define V4L2_CID_GAMMA (V4L2_CID_BASE+16) +#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* Deprecated */ +#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) +#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) +#define V4L2_CID_GAIN (V4L2_CID_BASE+19) +#define V4L2_CID_HFLIP
Add V4L2_FMT_FLAG_EMULATED to videoio.h
I would like to add V4L2_FMT_FLAG_EMULATED to sys/videoio.h as libv4l (https://github.com/jasperla/openbsd-wip/tree/master/multimedia/libv4l) returns the flag for emulated (i.e., not natively supported by your webcam) video formats. In turn some userspace applications (like the SIP user-agent baresip) look for this flag as well. OK? Best regards, Ingo Index: videoio.h === RCS file: /cvs/src/sys/sys/videoio.h,v retrieving revision 1.8 diff -u -p -r1.8 videoio.h --- videoio.h 23 Oct 2014 07:34:48 - 1.8 +++ videoio.h 20 Nov 2015 19:02:10 - @@ -360,6 +360,7 @@ struct v4l2_fmtdesc { }; #define V4L2_FMT_FLAG_COMPRESSED 0x0001 +#define V4L2_FMT_FLAG_EMULATED 0x0002 /* * F R A M E S I Z E E N U M E R A T I O N
cdce(4) and MBIM
Has anyone experiences with USB devices (e.g. UMTS modem) offering Mobile Broadband Interface Model (MBIM) interfaces? According to www.usb.org/developers/docs/devclass_docs/MBIM10Errata1_073013.zip MBIM is comparable to NCM (The largest deviation from NCM 1.0 is that devices transfer raw IP packets instead of packets with 802.3 headers.) which is supported by cdce(4). By hardcoding vendor and device ID in sys/dev/usb/if_cdce.c I managed to have a modem with MBIM interface attach via cdce: cdce0 at uhub0 port 4 configuration 1 interface 0 MediaTek Inc Product rev 2.00/3.00 addr 2 cdce0: address XX:XX:XX:XX:XX:XX ifconfig appears to work as well cdce0: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500 lladdr XX:XX:XX:XX:XX:XX priority: 0 but dhclient gets no response. /var/log/messages contains cdce0: watchdog timeout cdce0: usb error on tx: TIMEOUT Any ideas? Best regards, Ingo
Add Medion Mobile S4222 to umsm(4)
A man page diff corresponding to the recent umsm commit by Martin Pieuchot. Best regards, Ingo Index: share/man/man4/umsm.4 === RCS file: /cvs/src/share/man/man4/umsm.4,v retrieving revision 1.89 diff -u -p -r1.89 umsm.4 --- share/man/man4/umsm.4 19 Mar 2014 22:56:44 - 1.89 +++ share/man/man4/umsm.4 6 Jan 2015 18:20:59 - @@ -81,6 +81,7 @@ driver: .It Li IIJMobile 120FU (ZTE OEM) Ta USB .It Li Kyocera KPC650 Ta CardBus .It Li Medion Mobile S4012 (Huawei E1550 OEM) Ta USB +.It Li Medion Mobile S4222 (MediaTek OEM) Ta USB .It Li Novatel Wireless ES620 Ta USB .It Li Novatel Wireless Ovation U727 Ta USB .It Li Novatel Wireless U760 Ta USB @@ -158,6 +159,8 @@ but only the first port can be used to m the second one is for management. The Option GlobeTrotter HSDPA/HSUPA modems have three serial ports, but only the last port can be used to make PPP connections. +The Medion Mobile S4222 has four serial ports, but only the first +port can be used to make connections. .Pp Some modems require multi-link PPP operation. For example, the Huawei E1550 has four serial ports.
MediaTek Inc. UMTS stick
Please find attached at the end of this mail a diff for the MediaTek Inc. DC_4COM (that is the product name that the Linux option driver uses: https://raw.githubusercontent.com/torvalds/linux/master/drivers/usb/serial/option.c) UMTS USB stick (= MEDION S4222). It solves the problems described at http://article.gmane.org/gmane.os.openbsd.misc/219029 . This gives me umsm0 at uhub7 port 1 configuration 1 interface 0 MediaTek Inc Product rev 2.00/3.00 addr 4 umsm0 detached umsm0 at uhub7 port 1 configuration 1 interface 2 MediaTek Inc Product rev 2.00/3.00 addr 4 ucom0 at umsm0 umsm1 at uhub7 port 1 configuration 1 interface 3 MediaTek Inc Product rev 2.00/3.00 addr 4 ucom1 at umsm1 umsm2 at uhub7 port 1 configuration 1 interface 4 MediaTek Inc Product rev 2.00/3.00 addr 4 ucom2 at umsm2 umsm3 at uhub7 port 1 configuration 1 interface 5 MediaTek Inc Product rev 2.00/3.00 addr 4 ucom3 at umsm3 umass0 at uhub7 port 1 configuration 1 interface 6 MediaTek Inc Product rev 2.00/3.00 addr 4 umass0: using SCSI over Bulk-Only scsibus4 at umass0: 2 targets, initiator 0 sd1 at scsibus4 targ 1 lun 0: MEDIATEK, FLASH DISK, 6225 SCSI0 0/direct removable ugen0 at uhub7 port 1 configuration 1 MediaTek Inc Product rev 2.00/3.00 addr 4 and ucom0 (cuaU0) now works as expected (successfully tested with cu and pppd). Please note that I had to ignore the first two interfaces when umsm attaches (otherwise ucom[0-3] do not work although they attach). Best regards, Ingo Index: sys/dev/usb/usbdevs === RCS file: /cvs/src/sys/dev/usb/usbdevs,v retrieving revision 1.641 diff -u -p -r1.641 usbdevs --- sys/dev/usb/usbdevs 4 Dec 2014 10:41:42 - 1.641 +++ sys/dev/usb/usbdevs 5 Jan 2015 11:20:33 - @@ -452,6 +452,7 @@ vendor CTC 0x0e5e CONWISE Technology vendor HAWKING 0x0e66 Hawking vendor FOSSIL 0x0e67 Fossil vendor GMATE 0x0e7e G.Mate +vendor MEDIATEK0x0e8d MediaTek Inc. vendor OTI 0x0ea0 Ours Technology vendor PILOTECH0x0eaf Pilotech vendor NOVATECH0x0eb0 Nova Tech @@ -2824,6 +2825,10 @@ product MCT ML_4500 0x0302 ML-4500 /* MDS products */ product MDS ISDBT 0x0001 MDS ISDB-T tuner + +/* MediaTek Inc. products */ +product MEDIATEK UMASS_INSTALLER 0x0002 USB installer +product MEDIATEK DC_4COM 0x00a5 UMTS USB modem /* MEI products */ product MEI CASHFLOW_SC0x1100 Cashflow-SC Index: sys/dev/usb/umsm.c === RCS file: /cvs/src/sys/dev/usb/umsm.c,v retrieving revision 1.100 diff -u -p -r1.100 umsm.c --- sys/dev/usb/umsm.c 12 Jul 2014 21:24:33 - 1.100 +++ sys/dev/usb/umsm.c 5 Jan 2015 11:20:33 - @@ -109,8 +109,9 @@ struct umsm_type { #defineDEV_UMASS5 0x0100 #defineDEV_UMASS6 0x0200 #defineDEV_UMASS7 0x0400 +#defineDEV_UMASS8 0x1000 #define DEV_UMASS (DEV_UMASS1 | DEV_UMASS2 | DEV_UMASS3 | DEV_UMASS4 | \ -DEV_UMASS5 | DEV_UMASS6 | DEV_UMASS7) +DEV_UMASS5 | DEV_UMASS6 | DEV_UMASS7 | DEV_UMASS8) }; static const struct umsm_type umsm_devs[] = { @@ -154,6 +155,9 @@ static const struct umsm_type umsm_devs[ {{ USB_VENDOR_KYOCERA2, USB_PRODUCT_KYOCERA2_KPC650 }, 0}, + {{ USB_VENDOR_MEDIATEK, USB_PRODUCT_MEDIATEK_UMASS_INSTALLER }, DEV_UMASS8}, + {{ USB_VENDOR_MEDIATEK, USB_PRODUCT_MEDIATEK_DC_4COM }, 0}, + /* XXX Some qualcomm devices are missing */ {{ USB_VENDOR_QUALCOMM, USB_PRODUCT_QUALCOMM_MSM_DRIVER }, DEV_UMASS1}, {{ USB_VENDOR_QUALCOMM, USB_PRODUCT_QUALCOMM_MSM_DRIVER2 }, DEV_UMASS4}, @@ -303,6 +307,11 @@ umsm_match(struct device *parent, void * return UMATCH_VENDOR_IFACESUBCLASS; } else return UMATCH_NONE; + /* Ignore first two (MBIM?) interfaces of USB_PRODUCT_MEDIATEK_DC_4COM */ + } else if (uaa-vendor == USB_VENDOR_MEDIATEK + uaa-product == USB_PRODUCT_MEDIATEK_DC_4COM + (uaa-ifaceno == 0 || uaa-ifaceno == 1)) { + return UMATCH_NONE; } else return UMATCH_VENDOR_IFACESUBCLASS; } @@ -703,6 +712,13 @@ umsm_umass_changemode(struct umsm_softc cbw.bCBWFlags = CBWFLAGS_IN; cbw.CBWCDB[0] = UMASS_SERVICE_ACTION_OUT; cbw.CBWCDB[1] = 0x03; + break; + case DEV_UMASS8: + USETDW(cbw.dCBWDataTransferLength, 0x0); + cbw.bCBWFlags = CBWFLAGS_OUT; + cbw.CBWCDB[0] = 0xf0; + cbw.CBWCDB[1] = 0x01; + cbw.CBWCDB[2] = 0x03; break; default: DPRINTF((%s: unknown device type.\n,
Re: MediaTek Inc. UMTS stick
On Mon, Jan 05, 2015 at 02:03:38PM +0100, Martin Pieuchot wrote: Thanks for your diff. No need to cross lists, tech@ is the good place for a diff :) OK :) On 05/01/15(Mon) 13:08, Ingo Feinerer wrote: Please find attached at the end of this mail a diff for the MediaTek Inc. DC_4COM (that is the product name that the Linux option driver uses: https://raw.githubusercontent.com/torvalds/linux/master/drivers/usb/serial/option.c) UMTS USB stick (= MEDION S4222). It solves the problems described at http://article.gmane.org/gmane.os.openbsd.misc/219029 . This gives me umsm0 at uhub7 port 1 configuration 1 interface 0 MediaTek Inc Product rev 2.00/3.00 addr 4 umsm0 detached umsm0 at uhub7 port 1 configuration 1 interface 2 MediaTek Inc Product rev 2.00/3.00 addr 4 ucom0 at umsm0 umsm1 at uhub7 port 1 configuration 1 interface 3 MediaTek Inc Product rev 2.00/3.00 addr 4 ucom1 at umsm1 umsm2 at uhub7 port 1 configuration 1 interface 4 MediaTek Inc Product rev 2.00/3.00 addr 4 ucom2 at umsm2 umsm3 at uhub7 port 1 configuration 1 interface 5 MediaTek Inc Product rev 2.00/3.00 addr 4 ucom3 at umsm3 umass0 at uhub7 port 1 configuration 1 interface 6 MediaTek Inc Product rev 2.00/3.00 addr 4 umass0: using SCSI over Bulk-Only scsibus4 at umass0: 2 targets, initiator 0 sd1 at scsibus4 targ 1 lun 0: MEDIATEK, FLASH DISK, 6225 SCSI0 0/direct removable ugen0 at uhub7 port 1 configuration 1 MediaTek Inc Product rev 2.00/3.00 addr 4 and ucom0 (cuaU0) now works as expected (successfully tested with cu and pppd). Please note that I had to ignore the first two interfaces when umsm attaches (otherwise ucom[0-3] do not work although they attach). How did you find this out? Trial and error. The linux kernel seems to filter base on the interface subclass and protocol. I'd prefer if you could do the same, as filtering on interface index is fragile. Bad things can happen if the device number is reused for example. True. Please find attached a revised diff. The interface class, subclass, and protocol values now directly match those in https://raw.githubusercontent.com/torvalds/linux/master/drivers/usb/serial/option.c and coincide with my observations. Successfully tested on amd64. In general I think it would be more elegant to have a table of whitelisted interfaces instead of hardcoding the device. However, as long there are no more special devices the current proposed solution is more succinct. One more comment: +/* MediaTek Inc. products */ +product MEDIATEK UMASS_INSTALLER 0x0002 USB installer +product MEDIATEK DC_4COM 0x00a5 UMTS USB modem I'd simply use MEDIATEK UMASS this way you won't exceed 80 columns in umsn.c. Done. This diff also includes a more detailed comment explaining that this whitelist stunt is needed (requested by Stuart Henderson). Thanks a lot for your input! Best regards, Ingo Index: sys/dev/usb/usbdevs === RCS file: /cvs/src/sys/dev/usb/usbdevs,v retrieving revision 1.641 diff -u -p -r1.641 usbdevs --- sys/dev/usb/usbdevs 4 Dec 2014 10:41:42 - 1.641 +++ sys/dev/usb/usbdevs 5 Jan 2015 18:38:00 - @@ -452,6 +452,7 @@ vendor CTC 0x0e5e CONWISE Technology vendor HAWKING 0x0e66 Hawking vendor FOSSIL 0x0e67 Fossil vendor GMATE 0x0e7e G.Mate +vendor MEDIATEK0x0e8d MediaTek Inc. vendor OTI 0x0ea0 Ours Technology vendor PILOTECH0x0eaf Pilotech vendor NOVATECH0x0eb0 Nova Tech @@ -2824,6 +2825,10 @@ product MCT ML_4500 0x0302 ML-4500 /* MDS products */ product MDS ISDBT 0x0001 MDS ISDB-T tuner + +/* MediaTek Inc. products */ +product MEDIATEK UMASS 0x0002 USB MSM installer +product MEDIATEK DC_4COM 0x00a5 UMTS USB modem /* MEI products */ product MEI CASHFLOW_SC0x1100 Cashflow-SC Index: sys/dev/usb/umsm.c === RCS file: /cvs/src/sys/dev/usb/umsm.c,v retrieving revision 1.100 diff -u -p -r1.100 umsm.c --- sys/dev/usb/umsm.c 12 Jul 2014 21:24:33 - 1.100 +++ sys/dev/usb/umsm.c 5 Jan 2015 18:38:00 - @@ -109,8 +109,9 @@ struct umsm_type { #defineDEV_UMASS5 0x0100 #defineDEV_UMASS6 0x0200 #defineDEV_UMASS7 0x0400 +#defineDEV_UMASS8 0x1000 #define DEV_UMASS (DEV_UMASS1 | DEV_UMASS2 | DEV_UMASS3 | DEV_UMASS4 | \ -DEV_UMASS5 | DEV_UMASS6 | DEV_UMASS7) +DEV_UMASS5 | DEV_UMASS6 | DEV_UMASS7 | DEV_UMASS8) }; static const struct umsm_type umsm_devs[] = { @@ -154,6 +155,9 @@ static const struct umsm_type umsm_devs[ {{ USB_VENDOR_KYOCERA2, USB_PRODUCT_KYOCERA2_KPC650 }, 0}, + {{ USB_VENDOR_MEDIATEK, USB_PRODUCT_MEDIATEK_UMASS }, DEV_UMASS8}, + {{ USB_VENDOR_MEDIATEK