From owner-freebsd-multimedia@FreeBSD.ORG Tue Jan 11 08:47:46 2011 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7515106566B for ; Tue, 11 Jan 2011 08:47:46 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe06.c2i.net [212.247.154.162]) by mx1.freebsd.org (Postfix) with ESMTP id 4CF188FC0A for ; Tue, 11 Jan 2011 08:47:45 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=uKwGHVgX/XpzFB6WQV71hE8vVR+wz8PlNBntNPh/OpQ= c=1 sm=1 a=4vW0rCAk17MA:10 a=Q9fys5e9bTEA:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=UAxoutJAh8-kMWsHnrEA:9 a=hseoWgufk9lwcqrPBXHe--iwBWgA:4 a=PUjeQqilurYA:10 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe06.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 72140784; Tue, 11 Jan 2011 09:47:43 +0100 From: Hans Petter Selasky To: "J.R. Oldroyd" Date: Tue, 11 Jan 2011 09:47:46 +0100 User-Agent: KMail/1.13.5 (FreeBSD/8.2-PRERELEASE; KDE/4.4.5; amd64; ; ) References: <20091204223126.00005392@unknown> <201001081650.14189.hselasky@c2i.net> <20100108114130.1cfe88c5@shibato.opal.com> In-Reply-To: <20100108114130.1cfe88c5@shibato.opal.com> X-Face: +~\`s("[*|O,="7?X@L.elg*F"OA\I/3%^p8g?ab%RN'(; _IjlA: hGE..Ew, XAQ*o#\/M~SC=S1-f9{EzRfT'|Hhll5Q]ha5Bt-s|oTlKMusi:1e[wJl}kd}GR Z0adGx-x_0zGbZj'e(Y[(UNle~)8CQWXW@:DX+9)_YlB[tIccCPN$7/L' MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201101110947.46399.hselasky@c2i.net> Cc: freebsd-multimedia@freebsd.org, emulation@freebsd.org, Alexander Leidinger Subject: Re: FYI: v4l-linuxulator support in FreeBSD-current now X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 08:47:47 -0000 Hi, I've received the following patch for my cuse4bsd module. Could this be included in the kernel's linux.ko ? This patch allows for linux DVB applications running under FreeBSD linux emulation. --HPS Index: cuse4bsd_kmod.c =================================================================== --- cuse4bsd_kmod.c (revision 1700) +++ cuse4bsd_kmod.c (working copy) @@ -1689,3 +1689,49 @@ return (0); } + + +#include +#if defined (__amd64__) +#include +#include +#else +#include +#include +#endif + +#include +MODULE_DEPEND(cuse4bsd, linux, 1, 1, 1); + +#define DVB_LINUX_IOCTL_MIN 0x6f00 +#define DVB_LINUX_IOCTL_MAX 0x6fff + + +static linux_ioctl_function_t cuse4bsd_linux_ioctl; +static struct linux_ioctl_handler cuse4bsd_linux_handler = + {cuse4bsd_linux_ioctl, DVB_LINUX_IOCTL_MIN, DVB_LINUX_IOCTL_MAX}; + +SYSINIT (cuse4bsd_linux_register, SI_SUB_KLD, SI_ORDER_MIDDLE, + linux_ioctl_register_handler, &cuse4bsd_linux_handler); +SYSUNINIT(cuse4bsd_linux_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE, + linux_ioctl_unregister_handler, &cuse4bsd_linux_handler); + +static int +cuse4bsd_linux_ioctl(struct thread *td, struct linux_ioctl_args *args) +{ + unsigned long cmd; + + /* swap the read/write bits, due to differences in bsd & linux ioctls*/ + cmd = (unsigned long)args->cmd; + if (cmd & (0x40 << 24)) { + cmd &= 0xffffff; + cmd |= (0x80 << 24); + } else if (cmd & (0x80 << 24)) { + cmd &= 0xffffff; + cmd |= (0x40 << 24); + } + args->cmd = (l_uint)cmd; + + /* Pass the ioctl off to our standard handler, now that its valid */ + return(ioctl(td, (struct ioctl_args *)args)); +}