Subversion Repositories shark

Rev

Rev 1676 | Blame | Compare with Previous | Last modification | View Log | RSS feed

%----------------------------------------------------------------------------
\chapter{The Frame Grabber Library}
%----------------------------------------------------------------------------

The library is divided in 2 layers: the low level and the high level. The first
one is in charge of the acquisition board hardware control and supplies a
generic interface for the higher level. The second layer supplies some API
function for a comunication between the application and a generir video device
(framegrammer, webcam, etc.).

%----------------------------------------------------------------------------
\section{BTTV low lever driver}
%----------------------------------------------------------------------------

At the actual stage of developement is the only low lever driver ported from
Linux to S.Ha.R.K. Support acquisition boards based on BookTree BT8x8 chips.
Presents only 2 functions for opening and closing cards.

\vspace{7mm}

\begin{intest}
BTTV26\_INIT\index{BTTV26\_init()}
\end{intest}

\begin{description}
\item [\textbf{int BTTV26\_init(void);}]
\item [\textbf{Description:}] It initializes the acquisition board interface and the
library's internal data
structures.
\end{description}

\begin{intest}
BTTV26\_CLOSE\index{BTTV26\_close()}
\end{intest}

\begin{description}
\item [\textbf{int BTTV26\_close(void);}]
\item [\textbf{Description:}] It close the acquisition board interface.
\end{description
}

%----------------------------------------------------------------------------
\section{VideoDevice high lever interface}
%----------------------------------------------------------------------------

This library supplies an abstract layer created to obtain a common interface
between different low level driver. The interaction with an application is quite
simple and implies only 2 functions: the first one open the comunication between
the application and the hardware through the low level driver, the second one
send commands to the device.

\vspace{7mm}

\begin{intest}
VIDEODEV26\_OPEN\index{VIDEODEV26\_open()}
\end{intest}

\begin{description}
\item [\textbf{int VIDEODEV26\_open(int num);}]
\item [\textbf{Description:}] It initializes the acquisition board interface and the
library's internal data structures. The parametetr \texttt{num} define the
device that must be opened. \item [Return]value: 0 if the module is installed; 1
otherwise.
\end{description}

\begin{intest}
VIDEODEV26\_IOCTL\index{VIDEODEV26\_ioctl()}
\end{intest}

\begin{description}
\item [\textbf{int VIDEODEV26\_ioctl(int num, unsigned int cmd,
unsigned long arg);}
]
\item [\textbf{Description:}] It send the command \texttt{cmd}, with argument
\texttt{arg}, to the device number \texttt{num}. \item [Return]value: It depends
from the command executed.
\end{description
}

%----------------------------------------------------------------------------
\subsection{Video Devices Commands}
%----------------------------------------------------------------------------

This is a list of most commond videodev commands. Most of them are supported by
the BTTV low lever driver. There is only a major change implemented during the
porting phase: the VIDIOCSYNC function requires an aperiodic task PID as input.
When the new frame is ready, the task is activated.

\vspace{7mm}

\begin{description}
\item [The]full command list is:
\end{description}

VIDIOCSYNC - Synchronize with memory mapped capture.

VIDIOCGCAP - Get video/radio device capabilities.

VIDIOCGCHAN - Get source properties.

VIDIOCSCHAN - Select source and set properties.

VIDIOCGTUNER - Get tuner properties.

VIDIOCSTUNER - Select tuner and set properties.

VIDIOCGPICT - Get video image (picture) properties.

VIDIOCSPICT - Set video image (picture) properties.

VIDIOCCAPTURE - Enable or disable video capturing.

VIDIOCGWIN - Get video output window properties.

VIDIOCSWIN - Set video output properties.

VIDIOCGFBUF - Get direct video output frame buffer properties.

VIDIOCSFBUF - Set direct video output frame buffer properties.

VIDIOCGFREQ - Get tuner frequency property.

VIDIOCSFREQ - Set tuner frequency property (i.e., tune to new frequency).

VIDIOCGAUDIO - Get audio properties.

VIDIOCSAUDIO - Set audio properties.

VIDIOCMCAPTURE - Initiate memory mapped capture.

VIDIOCGMBUF - Get memory mapped buffer properties.

\begin{description}
\item [Example:]
\end{description}

\begin{tt}
\begin{verbatim}
/* Init videodev driver */

VIDEODEV26_open(FRAME_GRABBER_NUMBER);

/* Select the input channel */

res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGCHAN,(unsigned long)&chan);

chan.channel = channel;
chan.type = VIDEO_VC_TUNER;
chan.norm = VIDEO_TYPE_CAMERA;
res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSCHAN,(unsigned long)&chan);

/* Enable the tuner */

tuner.tuner = 0;
tuner.mode = VIDEO_MODE_PAL;
res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSTUNER,(unsigned long)&tuner);

/* Select palette and depth */

res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGPICT,(unsigned long)&vpic);

#ifdef COLOR
vpic.palette = VIDEO_PALETTE_RGB24;
vpic.depth = 24;
#else
vpic.palette = VIDEO_PALETTE_GREY;
vpic.depth = 8;
#endif

vpic.brightness = 35000;
vpic.hue = 32000;
vpic.contrast = 32000;
vpic.colour = 32000;
res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSPICT,(unsigned long)&vpic);

/* Set window dimensions */

res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGWIN,(unsigned long)&win);

win.x = 0;
win.y = 0;
win.width = FG_W;
win.height = FG_H;
res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSWIN,(unsigned long)&win);

/* Set the buffer */

res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSFBUF,(unsigned long)(fbuf));

/* IMPORTANT: Set the aperiodic elaboration task */

/* When the new frame is ready, the task elaborate_PID (aperiodic), is activated.*/

VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSYNC,(unsigned long)(elaborate_PID));
\end{verbatim}
\end{tt
}