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:
1.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/* * *
which
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);
2.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.
Instance:
/* Abort all pending video driver I/o jobs */
Fvid_control (Fvidchan, Iom_abort, NULL);
3.fvid-alloc () function: request to get the driver cache unit.
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.
Instance:
/* Allocate a buffer from the device */
Status = Fvid_alloc (Chanhandle, dispbuf);
4.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.
Instance:
/* Allocate a buffer from the device */
Status = Fvid_exchange (Chanhandle, dispbuf);
4.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.
Instance:
Example/* Free a buffer back to the device */
Status = Fvid_free (Chanhandle, dispbuf);
5.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.
Instance:
Example/* Allocate a buffer from the device */
Status = Fvid_delete (Chanhandle);