FYI: v4l-linuxulator support in FreeBSD-current now

Alexander Leidinger Alexander at Leidinger.net
Tue Jan 11 12:27:41 UTC 2011


Quoting Hans Petter Selasky <hselasky at c2i.net> (from Tue, 11 Jan 2011  
09:47:46 +0100):

> Hi,
>
> I've received the following patch for my cuse4bsd module. Could this be

 From Andrew Gallatin (gallatin@)?

> included in the kernel's linux.ko ? This patch allows for linux DVB
> applications running under FreeBSD linux emulation.

Yes, but I would prefer the person who submitted it could test it  
before it is committed.

Semi-OT: Are you sure the MODULE_DEPEND is not necessary for your  
module and should be included?

Bye,
Alexander.

> --HPS
>
> Index: cuse4bsd_kmod.c
> ===================================================================
> --- cuse4bsd_kmod.c     (revision 1700)
> +++ cuse4bsd_kmod.c     (working copy)
> @@ -1689,3 +1689,49 @@
>
>         return (0);
>  }
> +
> +
> +#include <sys/sysproto.h>
> +#if defined (__amd64__)
> +#include <machine/../linux32/linux.h>
> +#include <machine/../linux32/linux32_proto.h>
> +#else
> +#include <machine/../linux/linux.h>
> +#include <machine/../linux/linux_proto.h>
> +#endif
> +
> +#include <compat/linux/linux_ioctl.h>
> +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));
> +}
>
>



-- 
Seems this guy showed up at a party, and all of his friends jumped for
Joy.  But she sidestepped, and they missed.

http://www.Leidinger.net    Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org       netchild @ FreeBSD.org  : PGP ID = 72077137


More information about the freebsd-multimedia mailing list