# How to compile / find the gspca driver on FreeBSD in Linux compatibility mode



## ziomario (Jan 25, 2022)

Hello,

I've just compiled the gspca driver on a linux vm virtualized with bhyve to be able to place video calls to my friends using my kinect 2. I've achieved the goal,compiling the source code found on this github :

https://github.com/jm2/gspca-kinect2

with the help of this script :


```
nano /home/marietto/Scrivania/kinect.sh

/usr/sbin/rmmod gspca_kinect2.ko
/usr/sbin/rmmod gspca_main
/usr/sbin/insmod /home/marietto/Scrivania/gspca-kinect2/gspca-kinect2-jm2/gspca_main.ko
/usr/sbin/insmod /home/marietto/Scrivania/gspca-kinect2/gspca-kinect2-jm2/gspca_kinect2.ko
ffmpeg \
    -i /dev/video1 \
# don't do vsync, for less delay
    -vsync drop \
# drop half the frames, and scale to 720p -- good enough for webcam use
# also mirror horizontally for webcam use -- other cams do this intrinsically but we need to do it ourselves
    -filter:v fps=30,scale=1280:-1,hflip \
# good general-purpose pixel format supported by many apps
    -pix_fmt yuyv422 \
# convert the colorspace, so the colors look better (not blown out too much)
    -color_trc bt709 \
    -color_primaries bt709 \
    -color_range tv \
# output device format
    -f v4l2 \
# output device
    /dev/video0
```

really the goal that I want to achieve is different. I want to do the same,but on FreeBSD. Unfortunately I haven't the competence to compile the driver for FreeBSD. I've found this web page :

http://info.iet.unipi.it/~luigi/FreeBSD/linux_bsd_kld.html

where I read that "Luigi Rizzo" has already did it,some time ago,but I haven't been able to find the the source code or the binary. I read that it has been deleted from the ports,as u can read here :

https://www.freshports.org/multimedia/linux-gspca-kmod/

and this page doesn't even exist anymore :

https://svnweb.freebsd.org/ports/head/multimedia/linux-gspca-kmod/ 

what do u suggest me to do ? thanks.


----------



## Phishfry (Jan 26, 2022)

2013 is too old for a kmod. Note says does not build on 8.
Go another route.

If persistent look for the ports makefile and look for the distfile online.
It might still exist. Even then you could only use it as a guide for your own new version.
That is your only option beside contacting this person.


----------



## Phishfry (Jan 26, 2022)

ziomario said:


> what do u suggest me to do ?


I have an archive of old FreeBSD versions. I cull thru them for useful ports.tgz when experimenting with the dead.
Download 7.4, extract ports tarfile. Read desired port makefile for distfile name and location.


----------



## Phishfry (Jan 26, 2022)

But all this is a waste. Too old.
kmod for Linux susbystem from 9 years ago?
FailOK


----------



## Phishfry (Jan 26, 2022)

Fetched ports tree from here:


			Index of /pub/FreeBSD-Archive/old-releases/amd64/7.4-RELEASE/ports/
		


Extracted ports.tgz to a temp location and drilled down to your desired port.


```
# New ports collection makefile for:    gspcav1-kmod
# Date created:                1 February 2007
# Whom:                    luigi
#
# $FreeBSD: ports/multimedia/linux-gspca-kmod/Makefile,v 1.7 2010/11/23 13:20:03 pav Exp $
#

PORTNAME=    linux-gspca-kmod
PORTVERSION=    1.0.20
PORTREVISION=    1
CATEGORIES=    multimedia kld
MASTER_SITES=    http://mxhaard.free.fr/spca50x/Download/oldrelease/
DISTNAME=    gspcav1-20071220

MAINTAINER=    luigi@FreeBSD.org
COMMENT=    A port of the linux gspcav1 webcam driver

# Requires the linux emulation layer to be built
BUILD_DEPENDS=    /usr/share/mk/bsd.linux_kmod.mk:${PORTSDIR}/devel/linux-kmod-compat

NO_PACKAGE=    depends on kernel sources

# This is our Makefile to be used for build/install.
MAKEFILE=    Makefile.kld
ALL_TARGET=    depend all

.include <bsd.port.pre.mk>

.if ${OSVERSION} >= 800000
BROKEN=        does not compile on 8.X
.endif

post-extract:
    @${CP} ${FILESDIR}/${MAKEFILE} ${WRKSRC}

.include <bsd.port.post.mk>
```

OK now you have the distfile location.
So start searching there....

Sometimes if you are really lucky you guess the correct file extensions:


			http://mxhaard.free.fr/spca50x/Download/oldrelease/gspcav1-20071220.tar.gz
		


There are patches inside the ports directory for the FreeBSD build.
Those are the porters work that should interest you..


----------



## Phishfry (Jan 26, 2022)

Not that I expect any of this to work. But these are the steps it takes to try and revive an old port.

I recommend you look heavily at the patches and try to port them to a moden day 'gspcav' version. (If that exists)
Of course throw the dice and see what builds first...Then death by 1000 cuts and then try and rebase.


----------



## Phishfry (Jan 26, 2022)

So the project is still alive.





						gspca - LinuxTVWiki
					






					www.linuxtv.org
				








						LinuxTV GIT repositories
					






					git.linuxtv.org
				




I would look at the patches and see how much difference there is in the trees.
Have the patches been worked back in to base? Doubtful but you start there.
Familiarize youself with old codebase compared to new. Would the patches still cleanly apply?
Wiki last change was 2012. So it ain't hoppin.


----------



## ziomario (Jan 26, 2022)

Thanks for your valuable help,but I really don't know what to do. It is too much for me. Is there a section on freebsd forums where I can propose the job ? maybe someone is interested to try. I have a stupid question to ask you. This driver works on freebsd 7.4, right ? Could I install freebsd 7.4 and  then,making a lot of upgrades,could I reach the latest freeBSD version,13,hoping that the driver still work until there ?


----------



## ziomario (Feb 3, 2022)

Can someone give an answer to my stupid question ? thanks.


----------



## Phishfry (Feb 3, 2022)

ziomario said:


> where I can propose the job ?


How much does a working webcam cost?
Maybe you change course?


----------



## ondra_knezour (Feb 3, 2022)

ziomario said:


> Could I install freebsd 7.4 and  then,making a lot of upgrades,could I reach the latest freeBSD version,13,hoping that the driver still work until there ?


No.


----------



## ziomario (Feb 3, 2022)

Phishfry said:


> How much does a working webcam cost?
> Maybe you change course?



for me it's a challenge. I like to use the kinects because it has a good compromise between resolution and audio video independent channels.


----------

