Module: xenomai-abe
Branch: analogy
Commit: 7534af298704edfa5ff907bb9dc6a91b96b8328e
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=7534af298704edfa5ff907bb9dc6a91b96b8328e

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Fri Oct 22 22:20:21 2010 +0200

analogy: add a "sys" function for the ioctl BUFCONFIG

The tool analogy_config uses the level 0 of the library API. At this
level, a function was missing to configure the default buffer size.

---

 include/analogy/analogy.h  |    2 ++
 src/drvlib/analogy/async.c |    9 ++++-----
 src/drvlib/analogy/sys.c   |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/include/analogy/analogy.h b/include/analogy/analogy.h
index c40f2e7..88f7f1a 100644
--- a/include/analogy/analogy.h
+++ b/include/analogy/analogy.h
@@ -47,6 +47,8 @@ int a4l_sys_attach(int fd, a4l_lnkdesc_t * arg);
 
 int a4l_sys_detach(int fd);
 
+int a4l_sys_bufcfg(int fd, unsigned int idx_subd, unsigned long size);
+
 int a4l_sys_desc(int fd, a4l_desc_t * dsc, int pass);
 
 int a4l_sys_devinfo(int fd, a4l_dvinfo_t * info);
diff --git a/src/drvlib/analogy/async.c b/src/drvlib/analogy/async.c
index f342af3..176a289 100644
--- a/src/drvlib/analogy/async.c
+++ b/src/drvlib/analogy/async.c
@@ -109,8 +109,9 @@ int a4l_snd_cancel(a4l_desc_t * dsc, unsigned int idx_subd)
  *
  * @return 0 on success. Otherwise:
  *
- * - -EINVAL is returned if some argument is missing or wrong (Please,
- *    type "dmesg" for more info)
+ * - -EINVAL is returned if the analogy descriptor is not correct or
+      if some argument is missing or wrong (Please, type "dmesg" for
+      more info)
  * - -EPERM is returned if the function is called in an RT context or
  *    if the buffer to resize is mapped in user-space (Please, type
  *    "dmesg" for more info)
@@ -123,13 +124,11 @@ int a4l_snd_cancel(a4l_desc_t * dsc, unsigned int 
idx_subd)
 int a4l_set_bufsize(a4l_desc_t * dsc,
                    unsigned int idx_subd, unsigned long size)
 {
-       a4l_bufcfg_t cfg = { idx_subd, size };
-
        /* Basic checking */
        if (dsc == NULL || dsc->fd < 0)
                return -EINVAL;
 
-       return __sys_ioctl(dsc->fd, A4L_BUFCFG, &cfg);
+       return a4l_sys_bufcfg(dsc->fd, idx_subd, size);
 }
 
 /**
diff --git a/src/drvlib/analogy/sys.c b/src/drvlib/analogy/sys.c
index 51edcfe..4f22b45 100644
--- a/src/drvlib/analogy/sys.c
+++ b/src/drvlib/analogy/sys.c
@@ -179,4 +179,37 @@ int a4l_sys_detach(int fd)
        return __sys_ioctl(fd, A4L_DEVCFG, NULL);
 }
 
+/**
+ * @brief Configure the buffer size
+ *
+ *
+ * This function can configure the buffer size of the file descriptor
+ * currently in use. If the subdevice index is set to
+ * A4L_BUF_DEFMAGIC, it can also define the default buffser size at
+ * open time.
+ *
+ * @param[in] fd File descriptor as returned by a4l_sys_open()
+ * @param[in] idx_subd Index of the concerned subdevice
+ * @param[int] size Buffer size to be set
+ *
+ * @return 0 on success. Otherwise:
+ *
+ * - -EINVAL is returned if some argument is missing or wrong (Please,
+ *    type "dmesg" for more info)
+ * - -EPERM is returned if the function is called in an RT context or
+ *    if the buffer to resize is mapped in user-space (Please, type
+ *    "dmesg" for more info)
+ * - -EFAULT is returned if a user <-> kernel transfer went wrong
+ * - -EBUSY is returned if the selected subdevice is already
+ *    processing an asynchronous operation
+ * - -ENOMEM is returned if the system is out of memory
+ *
+ */
+int a4l_sys_bufcfg(int fd, unsigned int idx_subd, unsigned long size)
+{
+       a4l_bufcfg_t cfg = { idx_subd, size };
+
+       return __sys_ioctl(fd, A4L_BUFCFG, &cfg);
+}
+
 /** @} */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to