DM642 Fvid Driver Writing Summary

Source: Internet
Author: User
Tags dio
DM642 Fvid Driver Writing summary

TI company developed the peripheral driver for DSP, introduced the Dsp/bios device Driver Kit (DDK), defined the standard device driver model, and provided a series of API interfaces. The peripheral driver is divided into two tiers:

The ① class driver (class driver). The class driver is used to provide an interface to an application. This part of the program is independent of the device, the main functions include maintaining the device data buffer, providing API interface to provide layer program call, and coordinate the application to synchronize and block the peripheral operation, and provide the adaptation layer to the mini drive layer, and implement the mapping of API interface function to mini driver layer program. Class drivers are hardware-independent, as long as the peripheral driver model is selected, the class driver is set and no modifications are required.

② Mini Drive (mini driver). Mini drivers are related to devices, so designing a mini driver is a key point in peripheral driver development. The interface format of the mini-driver and the class-driven layer is uniform, but the operation of the mini-driver on the underlying hardware varies depending on the hardware platform. The mini-driver receives the Iom_packet command packet from the class-driven layer, deciding what to do with the underlying hardware.


The peripheral driver model can also be divided into the following 3 categories:

①pip/pio model. based on the I/O model of the data pipeline, each pipeline maintains its own buffer. The Notifyreader () and Notifywriter () functions are excited to synchronize data when the data is written to the buffer or the data is fetched from the buffer.

②sio/dio model. Data Flow-based I/O model, a data flow is one-way, either input, or output, and the Sio/dio model uses an asynchronous way to manipulate I/O, for data read and write, processing can be done simultaneously.

③gio model. The general-purpose I/O model, which is flexible and does not have an adaptation layer, operates the mini-driver directly, and is used primarily to design new device-driven models.

Compare Pio, Sio and Gio

PIO supports a lower level of communication and is suitable for designing relatively simple peripheral drivers. For example, the audio acquisition and playback implemented on TI's 6X11DSK board are generally based on the PIO model. The SIO model has a good buffer allocation and recovery mechanism, more suitable for the description of video equipment, Sio provides a very rich function, GIO model design is aimed at special hardware of the new equipment, in accordance with the actual situation and function using GIO device driver model.


Fvid Drive Model

TI Company originally designed the GIO model flawed, mainly in the data buffer management problem, the application after acquiring the device driver buffer for data processing, the buffer can not be returned to the device driver. TI Company in the introduction of DM642 this is mainly used for video processing of the DSP chip at the same time, the GIO model has been improved, and put forward a special Fvid model for video equipment.

The Fvid model is built on the GIO model, encapsulating the Fvid_free () function in the GIO model with the Fvid_alloc (), Fvid_exchange (), and Gio_submit () functions. Resolves an issue where the driver cannot reclaim buffers in the GIO model.


In addition, the Fvid model is designed specifically for the fvid_frame structure. This structure contains the commonly used video signal information, such as the number of rows, number of columns, YUV structure, field frequency, etc., is suitable for describing video data frames, for the video design of the Fvid model is mainly for the dm64x system design. the specific implementation of the Mini-driver functions is as follows:

The ①mdbinddev () function. when an application establishes a device interface (such as the Fvid_create () function), it is called to implement device bonding, which completes initialization of external devices. Instead of the Mdubinddev () function, using the Mdubinddev () function causes the device to be in an invalid state and can no longer be used.

The ②mdcreatechan () function. Use this function to establish a communication channel for applications and drivers, and to request buffers for each channel. In the Fvid model released by TI, 3 buffers are allocated for each channel, exchanging data with external devices in turn, and each buffer corresponds to 1 frames of video data. corresponding to Mdcreatechan () is the Md_deletechan () function, which removes the device channel and frees the buffer resource.

The ③mdsubmitchan () function. responsible for managing buffers, accepting Fvid_alloc (), Fvid_exchange (), Fvid_free () three commands issued by the application, and processing them respectively. Where the Fvid_alloc command gets the buffers in the driver, the application takes the latest frame of video data from three buffers, processes the data in it, and only the remaining buffers are used to accept data entered by the external device. Fvid_exchange () swaps the used buffers with the latest data buffers for the driver, the application finishes processing 1 frames of data, returns the 1 frames of data to the driver, and reads the new 1 frame data for processing. Fvid_free () returns the used buffers back to the driver, and the application returns the data frames that are processed back to the driver, instead of requesting a new data frame from the driver.

The ④mdcontrolchan () function. for the operation of external video devices, the acquisition and output of video data is completed. The application passes the command to the Gio_control () function through the Fvid_control () function, and then Gio_control () passes the command to the Mdcontrolchan () function, and finally distributes the commands to the specified device. fvid function:

fvid_create () function: is to allocate and initialize the Fvid channel object;


syntax:fvidchan = fvid_create (name, mode, *status, Optargs, *attrs);

parameter definition:

String name/* Handle to an instance of the device */

INT Mode/* Pointer to buffer allocated by driver */

INT *status/* Pointer to size of buffer pointed to by */

PTR Optargs/* * *

Fvid_attrs *attrs/* * *

among them:

The name is a handle to the device instance, and is a string mode that is selected for only two values: Iom_input sets the acquisition mode, Iom_output sets the display mode.

Status is the state value returned by the lower Mini driver.

Attrs is a pointer to the FVID_ATTRS structure:


fvid_attrs is defined as follows:

typedef struct FVID_ATTRS {

Uns timeout;

} fvid_attrs;


The timeout member is used to specify semaphore synchronization, and its value can be:

Sys_forever: Will let Fvid_alloc, Fvid_free and Fvid_exchange call indeterminate wait until this call is complete.

The timeout value of a number causes these APIs to block for a specified amount of time (in the system clock). A value of 0 will not block APIs, they will return immediately, in which case the application will check the returned status value to ensure that the call has completed successfully.


Note: Fvid_alloc, Fvid_free and Fvid_exchange are called only in Dsp/bios task (TSK).


return value of Fvid_create:


If the channel is successfully opened, then Fvid_create returns a handle to the channel. This handle can be used to allow subsequent modules to invoke this channel.

Real Columns:


/* Initialize the attributes */

Fvid_attrs dispattrs = fvid_attrs;

/* Create A instance to a video display device */chan-

Handle = Fvid_create ("\display0", Iom_input, NULL, null,&dispattrs);


Fvid_control ():

Fvid_control () function is: Send a control command to the lower Mini_driver

syntax: status = Fvid_control (Fvidchan, cmd, args);


parameter definition:

Fvid_handle Fvidchan/* Handle to an instance of the device * *

Int cmd/* control command */

PTR args/* Pointer to control command arguments */

Return Value Int Status/* Returns iom_completed if successful */


parameter Description:

Fvidchan is a handle to the channel created by Fvid_create ().

CMD has two values: the Iom_abort----function is to abort so the undetermined I/O work.

Iom_flush----function is so that the work of the acquisition port is discarded, so the display I/O is working normally.

Args is a pointer to a command (parameter or struct) to be passed.

Return value: If the call succeeds, Fvid_control returns iom_completed. If an error occurs, the call returns a negative value.

Example:

/* Abort all pending video driver I/o jobs */

Fvid_control (Fvidchan, Iom_abort, NULL);


Fvid-alloc ()

syntax:status = Fvid_alloc (Fvidchan, BUFP);

parameter definition:

Fvid_handle Fvidchan/* Handle to an instance of the device * *

PTR BUFP/* Pointer to buffer allocated by driver */

Return Value Int Status/* Returns iom_completed if successful */

parameter Description:

Fvidchan is a handle to the channel created by Fvid_create ().

BUFP is an output parameter that points to a pointer to the requested drive cache space.

Return value: If the call succeeds, Fvid_alloc () returns iom_completed, and if an error occurs, the call returns a negative value.

Note: This function can only be called after the peripheral has been loaded and initialized. The handle should be provided by the fvid_create () function.

Example:

/* Allocate a buffer from the device */

Status = Fvid_alloc (Chanhandle, dispbuf); Fvid_exchange ()

Fvid_exchange () function: swaps the application and driver cache space, which is actually equivalent to the combination of the Fvid_free () and Fvid_alloc () functions.

syntax: status = Fvid_exchange (Fvidchan, BUFP);

parameter definition:

Fvid_handle Fvidchan/* Handle to an instance of the device * *

PTR BUFP/* Pointer to buffer exchanged by driver */

Lguns *psize/* Pointer to size of buffer pointed to by BUFP */

parameter Description:

Fvidchan is a handle to the channel created by Fvid_create ().

BUFP is the input and output parameter, which is just beginning to point to the cache space that the application needs to swap, after the swap, points to the memory space after the cache space exchange with the driver.

PSize is a pointer to the BUFP memory size.

return Value: If the call succeeds, Fvid_exchange () returns iom_completed, and if an error occurs, the call returns a negative value.

Note: This function can only be called after the peripheral has been loaded and initialized. The handle should be provided by the fvid_create () function.

Example:

/* Allocate a buffer from the device */

Status = Fvid_exchange (Chanhandle, dispbuf); Fvid_free () Effect:

Fvid_free () function : Frees the cache that returns the application request to the driver

syntax: status = Fvid_free (Fvidchan, BUFP);

parameter definition:

Fvid_handle Fvidchan/* Handle to an instance of the device * *

PTR BUFP/* Pointer to buffer to being relinquished to driver */

Lguns *psize/* Pointer to size of buffer pointed to by BUFP */

parameter Description:

Fvidchan is a handle to the channel created by Fvid_create ().

BUFP is an input parameter that points to an application that needs to release the cached space returned.

PSize is a pointer to the BUFP memory size.

return Value: If the call succeeds, Fvid_free () returns iom_completed, and if an error occurs, the call returns a negative value.

Note: This function can only be called after the peripheral has been loaded and initialized. The handle should be provided by the fvid_create () function.

Example:

Example/* Free a buffer back to the device */

Status = Fvid_free (Chanhandle, dispbuf);


fvid_delete () Effect:

fvid_delete () Effect: apply to close a Fvid channel object.

syntax: status = Fvid_delete (Fvidchan);

parameter definition:

Fvid_handle Fvidchan/* Handle to an instance of the device * *

The description of the ginseng said:

Fvidchan is a handle to the channel created by Fvid_create ().

return Value: If the call succeeds, Fvid_delete () returns iom_completed, and if an error occurs, the call returns a negative value.

Note: This function can only be called after the peripheral has been loaded and initialized. The handle should be provided by the fvid_create () function.

Example:

Example/* Allocate a buffer from the device */

Status = Fvid_delete (Chanhandle);



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.