beautypg.com

Sensoray 2255 User Manual

Page 23

background image

Demo Application explanation

When the demo application opens, it tries to open all board instances(up to 8) in the system. It looks for
each board in order and opens them. The first board is /dev/s2255_0. The second board is
/dev/s2255_1

.

To open the board, the function S2255_DeviceOpen is called with the board number and a pointer to the
device handle. The source code for S2255_DeviceOpen is in the file s2255mid.c. For the Linux SDK, it
opens a handle to the device with the standard call “open”. This function also creates working buffers
for possible future conversion functions.

After the call to S2255_DeviceOpen, the mode for the 2255 must be set before starting any acquisition.
This is done by the S2255_SetMode function for each channel of the board being opened. The current
supported color modes for the Linux SDK are COLOR_YUVPL and COLOR_Y8. COLOR_RGB and
COLOR_YUVPK in s2255.h are for the Windows SDK only. Conversion to RGB is shown in the demo
application to display to XWindows. The above calls are done in “board_open(s2255demo.c),” which is
called from “app_init(s2255demo.c)”.

The demo application then uses a command processor to determine which command to execute. Basic
custom applications would just call whatever acquisition routines are required.

To start capturing on channel 1, the start_stream function is called. This starts the io_thread function
that performs XWindows capture

.

Capture thread

The first task in the capture thread is to get the current image size. This is done with the function
S2255_get_image_size(&mode) with an argument of a pointer to the mode for the current channel.

Two methods of capture are possible. The preferred is using MMAP. The thread makes an ioctl call to
S2255_IOC_REQBUF (In the future, this call may be moved to the middleware s2255mid.c, but the code
will be the same) with a getbuf_param_t (s2255ioctl.h). After this call, mmap is done on the resulting
buffer pointer to transform the kernel space(driver) buffer to a usable user space buffer area.
S2255_IOC_REQBUF is called for each system frame of number NUMFRAMES.

Once MMAP is complete, acquisition is started with the function S2255_StartAcquire. It has parameters
for the device handle and the current channel. The third argument is for Windows only and should be
ignored.

The next block of code creates a bitmap header and allocates work frames for the image manipulation.
The 2255 currently captures in hardware in YUVPL(planar YUV) or Y8(monochrome) modes. To get
RGB or YUY2, a transformation is required (image_linux.c).

After the work buffers and DIB header are created, the XWindows window and image memory is
created. The important information is ximage->data.

Following the XWindows creation is the acquisition loop while( !b->stop_rq[idx]) {}. The procedure is to
wait for a frame(S2255_wait_frame), transform(planar_422p_to_rgb565) and display the
frame(XshmPutImage, XCopyArea, XSync) , and then dequeue the frame(S2255_DQBUF). Optionally, if

23