svn commit: r221426 - head/sys/compat/linux
Author: netchild Date: Wed May 4 09:05:39 2011 New Revision: 221426 URL: http://svn.freebsd.org/changeset/base/221426 Log: This is v4l2 support for the linuxulator. This allows to access FreeBSD native devices which support the v4l2 API from processes running within the linuxulator, e.g. skype or flash can access the multimedia/pwcbsd or multimedia/webcamd supplied drivers. Submitted by: nox MFC after:1 month Modified: head/sys/compat/linux/linux_ioctl.c head/sys/compat/linux/linux_ioctl.h Modified: head/sys/compat/linux/linux_ioctl.c == --- head/sys/compat/linux/linux_ioctl.c Wed May 4 08:42:31 2011 (r221425) +++ head/sys/compat/linux/linux_ioctl.c Wed May 4 09:05:39 2011 (r221426) @@ -59,6 +59,9 @@ __FBSDID($FreeBSD$); #include sys/sx.h #include sys/tty.h #include sys/uio.h +#include sys/types.h +#include sys/mman.h +#include sys/resourcevar.h #include net/if.h #include net/if_dl.h @@ -83,6 +86,9 @@ __FBSDID($FreeBSD$); #include compat/linux/linux_videodev.h #include compat/linux/linux_videodev_compat.h +#include compat/linux/linux_videodev2.h +#include compat/linux/linux_videodev2_compat.h + CTASSERT(LINUX_IFNAMSIZ == IFNAMSIZ); static linux_ioctl_function_t linux_ioctl_cdrom; @@ -97,6 +103,7 @@ static linux_ioctl_function_t linux_ioct static linux_ioctl_function_t linux_ioctl_drm; static linux_ioctl_function_t linux_ioctl_sg; static linux_ioctl_function_t linux_ioctl_v4l; +static linux_ioctl_function_t linux_ioctl_v4l2; static linux_ioctl_function_t linux_ioctl_special; static linux_ioctl_function_t linux_ioctl_fbsd_usb; @@ -124,6 +131,8 @@ static struct linux_ioctl_handler sg_han { linux_ioctl_sg, LINUX_IOCTL_SG_MIN, LINUX_IOCTL_SG_MAX }; static struct linux_ioctl_handler video_handler = { linux_ioctl_v4l, LINUX_IOCTL_VIDEO_MIN, LINUX_IOCTL_VIDEO_MAX }; +static struct linux_ioctl_handler video2_handler = +{ linux_ioctl_v4l2, LINUX_IOCTL_VIDEO2_MIN, LINUX_IOCTL_VIDEO2_MAX }; static struct linux_ioctl_handler fbsd_usb = { linux_ioctl_fbsd_usb, FBSD_LUSB_MIN, FBSD_LUSB_MAX }; @@ -139,6 +148,7 @@ DATA_SET(linux_ioctl_handler_set, privat DATA_SET(linux_ioctl_handler_set, drm_handler); DATA_SET(linux_ioctl_handler_set, sg_handler); DATA_SET(linux_ioctl_handler_set, video_handler); +DATA_SET(linux_ioctl_handler_set, video2_handler); DATA_SET(linux_ioctl_handler_set, fbsd_usb); struct handler_element @@ -2988,6 +2998,302 @@ linux_ioctl_special(struct thread *td, s return (error); } +static int +linux_to_bsd_v4l2_standard(struct l_v4l2_standard *lvstd, struct v4l2_standard *vstd) +{ + vstd-index = lvstd-index; + vstd-id = lvstd-id; + memcpy(vstd-name, lvstd-name, sizeof(*lvstd) - offsetof(struct l_v4l2_standard, name)); + return (0); +} + +static int +bsd_to_linux_v4l2_standard(struct v4l2_standard *vstd, struct l_v4l2_standard *lvstd) +{ + lvstd-index = vstd-index; + lvstd-id = vstd-id; + memcpy(lvstd-name, vstd-name, sizeof(*lvstd) - offsetof(struct l_v4l2_standard, name)); + return (0); +} + +static int +linux_to_bsd_v4l2_buffer(struct l_v4l2_buffer *lvb, struct v4l2_buffer *vb) +{ + vb-index = lvb-index; + vb-type = lvb-type; + vb-bytesused = lvb-bytesused; + vb-flags = lvb-flags; + vb-field = lvb-field; + vb-timestamp.tv_sec = lvb-timestamp.tv_sec; + vb-timestamp.tv_usec = lvb-timestamp.tv_usec; + memcpy(vb-timecode, lvb-timecode, sizeof (lvb-timecode)); + vb-sequence = lvb-sequence; + vb-memory = lvb-memory; + if (lvb-memory == V4L2_MEMORY_USERPTR) + /* possible pointer size conversion */ + vb-m.userptr = (unsigned long)PTRIN(lvb-m.userptr); + else + vb-m.offset = lvb-m.offset; + vb-length = lvb-length; + vb-input = lvb-input; + vb-reserved = lvb-reserved; + return (0); +} + +static int +bsd_to_linux_v4l2_buffer(struct v4l2_buffer *vb, struct l_v4l2_buffer *lvb) +{ + lvb-index = vb-index; + lvb-type = vb-type; + lvb-bytesused = vb-bytesused; + lvb-flags = vb-flags; + lvb-field = vb-field; + lvb-timestamp.tv_sec = vb-timestamp.tv_sec; + lvb-timestamp.tv_usec = vb-timestamp.tv_usec; + memcpy(lvb-timecode, vb-timecode, sizeof (vb-timecode)); + lvb-sequence = vb-sequence; + lvb-memory = vb-memory; + if (vb-memory == V4L2_MEMORY_USERPTR) + /* possible pointer size conversion */ + lvb-m.userptr = PTROUT(vb-m.userptr); + else + lvb-m.offset = vb-m.offset; + lvb-length = vb-length; + lvb-input = vb-input; + lvb-reserved = vb-reserved; + return (0); +} + +static int +linux_to_bsd_v4l2_format(struct l_v4l2_format *lvf, struct v4l2_format *vf) +{ + vf-type = lvf-type; + if (lvf-type == V4L2_BUF_TYPE_VIDEO_OVERLAY
Re: svn commit: r221426 - head/sys/compat/linux
В Wed, 4 May 2011 09:05:39 + (UTC) Alexander Leidinger netch...@freebsd.org пишет: Author: netchild Date: Wed May 4 09:05:39 2011 New Revision: 221426 URL: http://svn.freebsd.org/changeset/base/221426 Log: This is v4l2 support for the linuxulator. This allows to access FreeBSD native devices which support the v4l2 API from processes running within the linuxulator, e.g. skype or flash can access the multimedia/pwcbsd or multimedia/webcamd supplied drivers. Submitted by: nox MFC after: 1 month Modified: head/sys/compat/linux/linux_ioctl.c head/sys/compat/linux/linux_ioctl.h Modified: head/sys/compat/linux/linux_ioctl.c == --- head/sys/compat/linux/linux_ioctl.c Wed May 4 08:42:31 2011 (r221425) +++ head/sys/compat/linux/linux_ioctl.c Wed May 4 09:05:39 2011 (r221426) @@ -59,6 +59,9 @@ __FBSDID($FreeBSD$); #include sys/sx.h #include sys/tty.h #include sys/uio.h +#include sys/types.h +#include sys/mman.h +#include sys/resourcevar.h #include net/if.h #include net/if_dl.h @@ -83,6 +86,9 @@ __FBSDID($FreeBSD$); #include compat/linux/linux_videodev.h #include compat/linux/linux_videodev_compat.h +#include compat/linux/linux_videodev2.h +#include compat/linux/linux_videodev2_compat.h + CTASSERT(LINUX_IFNAMSIZ == IFNAMSIZ); static linux_ioctl_function_t linux_ioctl_cdrom; @@ -97,6 +103,7 @@ static linux_ioctl_function_t linux_ioct static linux_ioctl_function_t linux_ioctl_drm; static linux_ioctl_function_t linux_ioctl_sg; static linux_ioctl_function_t linux_ioctl_v4l; +static linux_ioctl_function_t linux_ioctl_v4l2; static linux_ioctl_function_t linux_ioctl_special; static linux_ioctl_function_t linux_ioctl_fbsd_usb; @@ -124,6 +131,8 @@ static struct linux_ioctl_handler sg_han { linux_ioctl_sg, LINUX_IOCTL_SG_MIN, LINUX_IOCTL_SG_MAX }; static struct linux_ioctl_handler video_handler = { linux_ioctl_v4l, LINUX_IOCTL_VIDEO_MIN, LINUX_IOCTL_VIDEO_MAX }; +static struct linux_ioctl_handler video2_handler = +{ linux_ioctl_v4l2, LINUX_IOCTL_VIDEO2_MIN, LINUX_IOCTL_VIDEO2_MAX }; static struct linux_ioctl_handler fbsd_usb = { linux_ioctl_fbsd_usb, FBSD_LUSB_MIN, FBSD_LUSB_MAX }; @@ -139,6 +148,7 @@ DATA_SET(linux_ioctl_handler_set, privat DATA_SET(linux_ioctl_handler_set, drm_handler); DATA_SET(linux_ioctl_handler_set, sg_handler); DATA_SET(linux_ioctl_handler_set, video_handler); +DATA_SET(linux_ioctl_handler_set, video2_handler); DATA_SET(linux_ioctl_handler_set, fbsd_usb); struct handler_element @@ -2988,6 +2998,302 @@ linux_ioctl_special(struct thread *td, s return (error); } +static int +linux_to_bsd_v4l2_standard(struct l_v4l2_standard *lvstd, struct v4l2_standard *vstd) +{ + vstd-index = lvstd-index; + vstd-id = lvstd-id; + memcpy(vstd-name, lvstd-name, sizeof(*lvstd) - offsetof(struct l_v4l2_standard, name)); + return (0); +} + +static int +bsd_to_linux_v4l2_standard(struct v4l2_standard *vstd, struct l_v4l2_standard *lvstd) +{ + lvstd-index = vstd-index; + lvstd-id = vstd-id; + memcpy(lvstd-name, vstd-name, sizeof(*lvstd) - offsetof(struct l_v4l2_standard, name)); + return (0); +} + +static int +linux_to_bsd_v4l2_buffer(struct l_v4l2_buffer *lvb, struct v4l2_buffer *vb) +{ + vb-index = lvb-index; + vb-type = lvb-type; + vb-bytesused = lvb-bytesused; + vb-flags = lvb-flags; + vb-field = lvb-field; + vb-timestamp.tv_sec = lvb-timestamp.tv_sec; + vb-timestamp.tv_usec = lvb-timestamp.tv_usec; + memcpy(vb-timecode, lvb-timecode, sizeof (lvb-timecode)); + vb-sequence = lvb-sequence; + vb-memory = lvb-memory; + if (lvb-memory == V4L2_MEMORY_USERPTR) + /* possible pointer size conversion */ + vb-m.userptr = (unsigned long)PTRIN(lvb-m.userptr); + else + vb-m.offset = lvb-m.offset; + vb-length = lvb-length; + vb-input = lvb-input; + vb-reserved = lvb-reserved; + return (0); +} + +static int +bsd_to_linux_v4l2_buffer(struct v4l2_buffer *vb, struct l_v4l2_buffer *lvb) +{ + lvb-index = vb-index; + lvb-type = vb-type; + lvb-bytesused = vb-bytesused; + lvb-flags = vb-flags; + lvb-field = vb-field; + lvb-timestamp.tv_sec = vb-timestamp.tv_sec; + lvb-timestamp.tv_usec = vb-timestamp.tv_usec; + memcpy(lvb-timecode, vb-timecode, sizeof (vb-timecode)); + lvb-sequence = vb-sequence; + lvb-memory = vb-memory; + if (vb-memory == V4L2_MEMORY_USERPTR) + /* possible pointer size conversion */ + lvb-m.userptr = PTROUT(vb-m.userptr); + else + lvb-m.offset = vb-m.offset; + lvb-length = vb-length; + lvb-input = vb-input; + lvb-reserved = vb-reserved; + return (0); +} + +static int +linux_to_bsd_v4l2_format(struct
Re: svn commit: r221426 - head/sys/compat/linux
Quoting Ivan Klymenko fi...@ukr.net (from Wed, 4 May 2011 14:32:20 +0300): ... /usr/src/sys/modules/linux/../../compat/linux/linux_ioctl.c:91:49: error: compat/linux/linux_videodev2_compat.h: No such file or directory ... Fixed. Thanks, Alexander. -- http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID = B0063FE7 http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID = 72077137 In every hierarchy the cream rises until it sours. -- Dr. Laurence J. Peter ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org