|
Flags to define the subdevice type
|
#define | A4L_SUBD_UNUSED (A4L_SUBD_MASK_SPECIAL|0x1) |
| Unused subdevice.
|
|
#define | A4L_SUBD_AI (A4L_SUBD_MASK_READ|0x2) |
| Analog input subdevice.
|
|
#define | A4L_SUBD_AO (A4L_SUBD_MASK_WRITE|0x4) |
| Analog output subdevice.
|
|
#define | A4L_SUBD_DI (A4L_SUBD_MASK_READ|0x8) |
| Digital input subdevice.
|
|
#define | A4L_SUBD_DO (A4L_SUBD_MASK_WRITE|0x10) |
| Digital output subdevice.
|
|
#define | A4L_SUBD_DIO (A4L_SUBD_MASK_SPECIAL|0x20) |
| Digital input/output subdevice.
|
|
#define | A4L_SUBD_COUNTER (A4L_SUBD_MASK_SPECIAL|0x40) |
| Counter subdevice.
|
|
#define | A4L_SUBD_TIMER (A4L_SUBD_MASK_SPECIAL|0x80) |
| Timer subdevice.
|
|
#define | A4L_SUBD_MEMORY (A4L_SUBD_MASK_SPECIAL|0x100) |
| Memory, EEPROM, DPRAM.
|
|
#define | A4L_SUBD_CALIB (A4L_SUBD_MASK_SPECIAL|0x200) |
| Calibration subdevice DACs.
|
|
#define | A4L_SUBD_PROC (A4L_SUBD_MASK_SPECIAL|0x400) |
| Processor, DSP.
|
|
#define | A4L_SUBD_SERIAL (A4L_SUBD_MASK_SPECIAL|0x800) |
| Serial IO subdevice.
|
|
#define | A4L_SUBD_TYPES |
| Mask which gathers all the types.
|
|
|
Flags to define the subdevice's capabilities
|
#define | A4L_SUBD_CMD 0x1000 |
| The subdevice can handle command (i.e it can perform asynchronous acquisition)
|
|
#define | A4L_SUBD_MMAP 0x8000 |
| The subdevice support mmap operations (technically, any driver can do it; however, the developer might want that his driver must be accessed through read / write.
|
|
|
Flags to define the subdevice's status
|
#define | A4L_SUBD_BUSY_NR 0 |
| The subdevice is busy, a synchronous or an asynchronous acquisition is occuring.
|
|
#define | A4L_SUBD_BUSY (1 << A4L_SUBD_BUSY_NR) |
| The subdevice is busy, a synchronous or an asynchronous acquisition is occuring.
|
|
#define | A4L_SUBD_CLEAN_NR 1 |
| The subdevice is about to be cleaned in the middle of the detach procedure.
|
|
#define | A4L_SUBD_CLEAN (1 << A4L_SUBD_CLEAN_NR) |
| The subdevice is busy, a synchronous or an asynchronous acquisition is occuring.
|
|
Subdevice declaration in a driver
The subdevice structure is the most complex one in the Analogy driver layer. It contains some description fields to fill and some callbacks to declare.
The description fields are:
- flags: to define the subdevice type and its capabilities;
- chan_desc: to describe the channels which compose the subdevice;
- rng_desc: to declare the usable ranges;
The functions callbacks are:
- do_cmd() and do_cmdtest(): to perform asynchronous acquisitions thanks to commands;
- cancel(): to abort a working asynchronous acquisition;
- munge(): to apply modifications on the data freshly acquired during an asynchronous transfer. Warning: using this feature with can significantly reduce the performances (if the munge operation is complex, it will trigger high CPU charge and if the acquisition device is DMA capable, many cache-misses and cache-replaces will occur (the benefits of the DMA controller will vanish);
- trigger(): optionally to launch an asynchronous acquisition;
- insn_read(), insn_write(), insn_bits(), insn_config(): to perform synchronous acquisition operations.
Once the subdevice is filled, it must be inserted into the driver structure thanks to a4l_add_subd().
int a4l_add_subd |
( |
a4l_dev_t * |
dev, |
|
|
a4l_subd_t * |
subd |
|
) |
| |
Add a subdevice to the driver descriptor.
Once the driver descriptor structure is initialized, the function a4l_add_subd() must be used so to add some subdevices to the driver.
- Parameters
-
[in] | dev | Device descriptor structure |
[in] | subd | Subdevice descriptor structure |
- Returns
- the index with which the subdevice has been registered, in case of error a negative error code is returned.
Allocate a subdevice descriptor.
This is a helper function so as to get a suitable subdevice descriptor
- Parameters
-
[in] | sizeof_priv | Size of the subdevice's private data |
[in] | setup | Setup function to be called after the allocation |
- Returns
- the index with which the subdevice has been registered, in case of error a negative error code is returned.
a4l_subd_t* a4l_get_subd |
( |
a4l_dev_t * |
dev, |
|
|
int |
idx |
|
) |
| |
Get a pointer to the subdevice descriptor referenced by its registration index.
This function is scarcely useful as all the drivers callbacks get the related subdevice descriptor as first argument. This function is not optimized, it goes through a linked list to get the proper pointer. So it must not be used in real-time context but at initialization / cleanup time (attach / detach).
- Parameters
-
[in] | dev | Device descriptor structure |
[in] | idx | Subdevice index |
- Returns
- 0 on success, otherwise negative error code.