pvrxxx, linux code and modules

Greg 'groggy' Lehey grog at FreeBSD.org
Mon Apr 16 05:50:58 UTC 2007

On Monday, 16 April 2007 at  0:08:14 +0200, Jan Branbergen wrote:
> Greg,
> i am writing you because i know you are an experienced freebsd
> developer and you are the maintainer of the mythtv port.
> i am trying to get the pvrxxx port to support as many cards as possible.
> in the process, i have been using linux source code to get the job
> done. i have defined a .h file full of defines and redefines so i can
> include linux-source with as little altertation as possible:
> - include fbsd-compat.h file
> - run sed over the source-file to replace "struct i2c_client" by "device_t"
> - uncomment some stuff i can't solve with the fbsd-compat.h file (
> the linux attach routines )
> - add some stuff ( couple of lines ) to support fbsd-compat.h
> - create an entry point to call the main function of the linux-module
> - link it in

This is all quite interesting.  Can you point me to the code
(privately if you prefer)?  What state is the code in?

> however, i feel that it should be possible to create separate
> kernel-modules of these linux-modules: tuner.ko, tveeprom.ko,
> cx25840.ko etc....
> but i don't have the knowledge to make this happen:
> - how do i create an entry point into the module ( which i can call
> to get work done? )

I could tell you for storage devices (I wrote the corresponding code
for Vinum), but I'm not very well informed about tuners.  Your best
bet here is to look at existing code.  Take a look at
bktr_mem_modevent in /usr/src/sys/dev/bktr/bktr_mem.c.  At the very
end of this file you'll also find the declaration for the module.  The
variables SI_SUB_DRIVERS and SI_ORDER_FIRST determine the sequence in
which the driver is called for probing.  Both are deefined in

> i would appreciate if you would take a look at what i have done with
> tuner.c, tveeprom.c, tda9887.c, cx25840-core.c etc in the pvrxxx
> port.

Can you point me to the latest version (preferably a static URL)?
I've put in a link to the latest version I know in
multimedia/mythtv/pkg-descr, but it's related to a date.

> would it be possible to create an automated procedure to transform
> these linux-modules to freebsd-modules at the source level?

Everything's possible, but I'd expect that to be far more work than
would be worthwhile.

> for example: the bktr driver would be able to use the same tuner.ko
> as the pvrxxx driver does ( a module based on the linux source ).

One big problem we'd have with this kind of code is the licensing
issue.  I started preparing to import your code to the tree, but
there's so much GPL stuff in there that it's a real problem.

I've been thinking around this general issue for a while, and haven't
come to any concrete conclusions.  Thoughts:

- I need to understand better how tuners work.  I've been thinking of
  writing a document on the subject, something that people could use
  for help when writing drivers.  If you know of anything, even
  partial or badly laid out, please let me know.

- We need to decide on the driver architecture we use.  Our current
  tuner drivers (both of them!) use an interface that is incompatible
  with V4L.  V4L has a number of advantages, including complexity and
  likelihood of change, but it's the de facto standard, and if we get
  involved, we may be able to help improve the definition.

- Luigi has done some related work on USB webcams.  Take a look at
  http://info.iet.unipi.it/~luigi/FreeBSD/linux_bsd_kld.html .  I've
  been meaning to read it for a while, but haven't got a round tuit
  yet.  I expect two advantages from this approach:

  - It should be relatively easy to add new drivers.
  - It should get round the GPL can of worms.

See complete headers for address and phone numbers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-multimedia/attachments/20070416/6e0122fb/attachment.pgp

More information about the freebsd-multimedia mailing list