Xenomai API  2.5.6.1
include/analogy/subdevice.h
Go to the documentation of this file.
00001 
00023 #ifndef __ANALOGY_SUBDEVICE__
00024 #define __ANALOGY_SUBDEVICE__
00025 
00026 #ifdef __KERNEL__
00027 #include <linux/list.h>
00028 #endif /* __KERNEL__ */
00029 
00030 #include <analogy/types.h>
00031 #include <analogy/context.h>
00032 #include <analogy/instruction.h>
00033 #include <analogy/command.h>
00034 #include <analogy/channel_range.h>
00035 
00036 /* --- Subdevice flags desc stuff --- */
00037 
00038 /* TODO: replace ANALOGY_SUBD_AI with ANALOGY_SUBD_ANALOG
00039    and ANALOGY_SUBD_INPUT */
00040 
00041 /* Subdevice types masks */
00042 #define A4L_SUBD_MASK_READ 0x80000000
00043 #define A4L_SUBD_MASK_WRITE 0x40000000
00044 #define A4L_SUBD_MASK_SPECIAL 0x20000000
00045 
00060 #define A4L_SUBD_UNUSED (A4L_SUBD_MASK_SPECIAL|0x1)
00061 
00064 #define A4L_SUBD_AI (A4L_SUBD_MASK_READ|0x2)
00065 
00068 #define A4L_SUBD_AO (A4L_SUBD_MASK_WRITE|0x4)
00069 
00072 #define A4L_SUBD_DI (A4L_SUBD_MASK_READ|0x8)
00073 
00076 #define A4L_SUBD_DO (A4L_SUBD_MASK_WRITE|0x10)
00077 
00080 #define A4L_SUBD_DIO (A4L_SUBD_MASK_SPECIAL|0x20)
00081 
00084 #define A4L_SUBD_COUNTER (A4L_SUBD_MASK_SPECIAL|0x40)
00085 
00088 #define A4L_SUBD_TIMER (A4L_SUBD_MASK_SPECIAL|0x80)
00089 
00092 #define A4L_SUBD_MEMORY (A4L_SUBD_MASK_SPECIAL|0x100)
00093 
00096 #define A4L_SUBD_CALIB (A4L_SUBD_MASK_SPECIAL|0x200)
00097 
00100 #define A4L_SUBD_PROC (A4L_SUBD_MASK_SPECIAL|0x400)
00101 
00104 #define A4L_SUBD_SERIAL (A4L_SUBD_MASK_SPECIAL|0x800)
00105 
00108 #define A4L_SUBD_TYPES (A4L_SUBD_UNUSED |        \
00109                            A4L_SUBD_AI |         \
00110                            A4L_SUBD_AO |         \
00111                            A4L_SUBD_DI |         \
00112                            A4L_SUBD_DO |         \
00113                            A4L_SUBD_DIO |        \
00114                            A4L_SUBD_COUNTER | \
00115                            A4L_SUBD_TIMER |      \
00116                            A4L_SUBD_MEMORY |     \
00117                            A4L_SUBD_CALIB |      \
00118                            A4L_SUBD_PROC |       \
00119                            A4L_SUBD_SERIAL)
00120 
00129 /* Subdevice capabilities */
00134 #define A4L_SUBD_CMD 0x1000
00135 
00140 #define A4L_SUBD_MMAP 0x8000
00141 
00150 /* Subdevice status flag(s) */
00155 #define A4L_SUBD_BUSY_NR 0
00156 #define A4L_SUBD_BUSY (1 << A4L_SUBD_BUSY_NR)
00157 
00162 #define A4L_SUBD_CLEAN_NR 1
00163 #define A4L_SUBD_CLEAN (1 << A4L_SUBD_CLEAN_NR)
00164 
00165 
00168 #ifdef __KERNEL__
00169 
00170 /* --- Subdevice descriptor structure --- */
00171 
00172 struct a4l_device;
00173 struct a4l_buffer;
00174 
00180 struct a4l_subdevice {
00181 
00182         struct list_head list;
00185         struct a4l_device *dev;
00188         unsigned int idx;
00191         struct a4l_buffer *buf;
00194         /* Subdevice's status (busy, linked?) */
00195         unsigned long status;
00198         /* Descriptors stuff */
00199         unsigned long flags;
00201         a4l_chdesc_t *chan_desc;
00203         a4l_rngdesc_t *rng_desc;
00205         a4l_cmd_t *cmd_mask;
00208         /* Functions stuff */
00209         int (*insn_read) (struct a4l_subdevice *, a4l_kinsn_t *);
00211         int (*insn_write) (struct a4l_subdevice *, a4l_kinsn_t *);
00213         int (*insn_bits) (struct a4l_subdevice *, a4l_kinsn_t *);
00215         int (*insn_config) (struct a4l_subdevice *, a4l_kinsn_t *);
00217         int (*do_cmd) (struct a4l_subdevice *, a4l_cmd_t *);
00219         int (*do_cmdtest) (struct a4l_subdevice *, a4l_cmd_t *);
00221         int (*cancel) (struct a4l_subdevice *);
00223         void (*munge) (struct a4l_subdevice *, void *, unsigned long);
00225         int (*trigger) (struct a4l_subdevice *, lsampl_t);
00228         char priv[0];
00230 };
00231 typedef struct a4l_subdevice a4l_subd_t;
00232 
00233 #endif /* __KERNEL__ */
00234 
00237 #ifndef DOXYGEN_CPP
00238 
00239 /* --- Subdevice related IOCTL arguments structures --- */
00240 
00241 /* SUDBINFO IOCTL argument */
00242 struct a4l_subd_info {
00243         unsigned long flags;
00244         unsigned long status;
00245         unsigned char nb_chan;
00246 };
00247 typedef struct a4l_subd_info a4l_sbinfo_t;
00248 
00249 /* CHANINFO / NBCHANINFO IOCTL arguments */
00250 struct a4l_chan_info {
00251         unsigned long chan_flags;
00252         unsigned char nb_rng;
00253         unsigned char nb_bits;
00254 };
00255 typedef struct a4l_chan_info a4l_chinfo_t;
00256 
00257 struct a4l_chinfo_arg {
00258         unsigned int idx_subd;
00259         void *info;
00260 };
00261 typedef struct a4l_chinfo_arg a4l_chinfo_arg_t;
00262 
00263 /* RNGINFO / NBRNGINFO IOCTL arguments */
00264 struct a4l_rng_info {
00265         long min;
00266         long max;
00267         unsigned long flags;
00268 };
00269 typedef struct a4l_rng_info a4l_rnginfo_t;
00270 
00271 struct a4l_rng_info_arg {
00272         unsigned int idx_subd;
00273         unsigned int idx_chan;
00274         void *info;
00275 };
00276 typedef struct a4l_rng_info_arg a4l_rnginfo_arg_t;
00277 
00278 #ifdef __KERNEL__
00279 
00280 /* --- Subdevice related functions and macros --- */
00281 
00282 a4l_chan_t *a4l_get_chfeat(a4l_subd_t * sb, int idx);
00283 a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx);
00284 int a4l_check_chanlist(a4l_subd_t * subd,
00285                        unsigned char nb_chan, unsigned int *chans);
00286 
00287 #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0)
00288 /* The following macro considers that a DIO subdevice is firstly an
00289    output subdevice */
00290 #define a4l_subd_is_output(x) \
00291         ((A4L_SUBD_MASK_WRITE & (x)->flags) != 0 || \
00292          (A4L_SUBD_DIO & (x)->flags) != 0)
00293 
00294 /* --- Upper layer functions --- */
00295 
00296 a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx);
00297 a4l_subd_t * a4l_alloc_subd(int sizeof_priv,
00298                             void (*setup)(a4l_subd_t *));
00299 int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd);
00300 int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg);
00301 int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg);
00302 int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg);
00303 int a4l_ioctl_nbchaninfo(a4l_cxt_t * cxt, void *arg);
00304 int a4l_ioctl_nbrnginfo(a4l_cxt_t * cxt, void *arg);
00305 
00306 #endif /* __KERNEL__ */
00307 
00308 #endif /* !DOXYGEN_CPP */
00309 
00310 #endif /* __ANALOGY_SUBDEVICE__ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines