[Xenomai-git] Alexis Berlemont : analogy: add wf_generate tool

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: e83bfe75344e75db96fe706e168a5a7ed334eb71
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=e83bfe75344e75db96fe706e168a5a7ed334eb71

Author: Alexis Berlemont 
Date:   Sun Oct 31 16:01:24 2010 +0100

analogy: add wf_generate tool

---

 src/utils/analogy/Makefile.am |   18 +++-
 src/utils/analogy/wf_facilities.c |   24 ++--
 src/utils/analogy/wf_facilities.h |   16 ++--
 src/utils/analogy/wf_generate.c   |  232 +
 4 files changed, 266 insertions(+), 24 deletions(-)

diff --git a/src/utils/analogy/Makefile.am b/src/utils/analogy/Makefile.am
index 3d8cb5e..8e7734f 100644
--- a/src/utils/analogy/Makefile.am
+++ b/src/utils/analogy/Makefile.am
@@ -1,6 +1,13 @@
 sbin_PROGRAMS = analogy_config
 
-bin_PROGRAMS = cmd_read cmd_write cmd_bits insn_read insn_write insn_bits
+bin_PROGRAMS = \
+   cmd_read \
+   cmd_write \
+   cmd_bits \
+   insn_read \
+   insn_write \
+   insn_bits \
+   wf_generate
 
 CPPFLAGS = \
@XENO_USER_CFLAGS@ \
@@ -9,11 +16,11 @@ CPPFLAGS = \
 LDFLAGS = \
@XENO_USER_LDFLAGS@
 
-lib_LIBRARIES = libwaveform.a
+noinst_HEADERS = wf_facilities.h
 
-libwaveform_a_SOURCES = signal_generation.c
+lib_LIBRARIES = libwaveform.a
 
-noinst_HEADERS = signal_generation.h
+libwaveform_a_SOURCES = wf_facilities.c
 
 analogy_config_SOURCES = analogy_config.c
 analogy_config_LDADD = \
@@ -58,3 +65,6 @@ insn_bits_LDADD = \
../../drvlib/analogy/libanalogy.la \
../../skins/rtdm/librtdm.la \
../../skins/common/libxenomai.la
+
+wf_generate_SOURCES = wf_generate.c
+wf_generate_LDADD = ./libwaveform.a -lm
diff --git a/src/utils/analogy/wf_facilities.c 
b/src/utils/analogy/wf_facilities.c
index ce250e7..08d105e 100644
--- a/src/utils/analogy/wf_facilities.c
+++ b/src/utils/analogy/wf_facilities.c
@@ -10,7 +10,7 @@
 #define PI 3.14159265358979323846
 #endif
 
-void a4l_sg_init_sine(struct waveform_config *config, double *values)
+void a4l_wf_init_sine(struct waveform_config *config, double *values)
 {
int i;
 
@@ -24,7 +24,7 @@ void a4l_sg_init_sine(struct waveform_config *config, double 
*values)
}
 }
 
-void a4l_sg_init_sawtooth(struct waveform_config *config, double *values)
+void a4l_wf_init_sawtooth(struct waveform_config *config, double *values)
 {
int i;
 
@@ -41,7 +41,7 @@ void a4l_sg_init_sawtooth(struct waveform_config *config, 
double *values)
}
 }
 
-void a4l_sg_init_triangular(struct waveform_config *config, double *values)
+void a4l_wf_init_triangular(struct waveform_config *config, double *values)
 {
int i;
 
@@ -67,7 +67,7 @@ void a4l_sg_init_triangular(struct waveform_config *config, 
double *values)
}
 }
 
-void a4l_sg_init_steps(struct waveform_config *config, double *values)
+void a4l_wf_init_steps(struct waveform_config *config, double *values)
 {
int i;

@@ -82,7 +82,7 @@ void a4l_sg_init_steps(struct waveform_config *config, double 
*values)
}
 }
 
-void a4l_sg_set_sample_count(struct waveform_config *config)
+void a4l_wf_set_sample_count(struct waveform_config *config)
 {
int sample_count = MIN_SAMPLE_COUNT;
int best_count = MIN_SAMPLE_COUNT;
@@ -116,7 +116,7 @@ void a4l_sg_set_sample_count(struct waveform_config *config)
config->spl_count = best_count;
 }
 
-int a4l_sg_check_config(struct waveform_config *config)
+int a4l_wf_check_config(struct waveform_config *config)
 {
 
if (config->wf_amplitude == 0)
@@ -134,18 +134,18 @@ int a4l_sg_check_config(struct waveform_config *config)
 }
 
 static void (* init_values[])(struct waveform_config *, double *) = {
-   a4l_sg_init_sine,
-   a4l_sg_init_sawtooth,
-   a4l_sg_init_triangular,
-   a4l_sg_init_steps,
+   a4l_wf_init_sine,
+   a4l_wf_init_sawtooth,
+   a4l_wf_init_triangular,
+   a4l_wf_init_steps,
 };
 
-void a4l_sg_init_values(struct waveform_config *config, double *values)
+void a4l_wf_init_values(struct waveform_config *config, double *values)
 {
init_values[config->wf_kind](config, values);
 }
 
-void a4l_sg_dump_values(struct waveform_config *config, double *values)
+void a4l_wf_dump_values(struct waveform_config *config, double *values)
 {
int i;

diff --git a/src/utils/analogy/wf_facilities.h 
b/src/utils/analogy/wf_facilities.h
index 6c99d51..7c9c705 100644
--- a/src/utils/analogy/wf_facilities.h
+++ b/src/utils/analogy/wf_facilities.h
@@ -24,13 +24,13 @@ struct waveform_config {
int spl_count;
 };
 
-void a4l_sg_init_sine(struct waveform_config *config, double *values);
-void a4l_sg_init_sawtooth(struct waveform_config *config, double *values);
-void a4l_sg_init_triangular(struct waveform_config *config, double *values);
-void a4l_sg_init_steps(struct waveform_config *config, double *values);
-void a4l_sg_set_sample_count(struct waveform_config *config);
-int a4l_sg_check_config(struct waveform_config *config

[Xenomai-git] Alexis Berlemont : analogy: add buffer configuration facility in analogy_config

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 9c15666c7744f68b8ff4a4dc55ca67480266c6d2
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=9c15666c7744f68b8ff4a4dc55ca67480266c6d2

Author: Alexis Berlemont 
Date:   Sat Oct 23 16:32:26 2010 +0200

analogy: add buffer configuration facility in analogy_config

The option "-S" has been added. It allows the user to configure the
default size of the asynchronous buffer. The default size is the size
allocated at open time (of the analogy device).

---

 src/utils/analogy/analogy_config.c |  241 ++-
 1 files changed, 151 insertions(+), 90 deletions(-)

diff --git a/src/utils/analogy/analogy_config.c 
b/src/utils/analogy/analogy_config.c
index 1482322..52290bf 100644
--- a/src/utils/analogy/analogy_config.c
+++ b/src/utils/analogy/analogy_config.c
@@ -31,14 +31,18 @@
 
 #include 
 
-/* Declare precompilation constants */
-#define __NBMIN_ARG 2
-#define __NBMAX_ARG 3
 #define __OPTS_DELIMITER ","
 
+enum actions {
+   DO_ATTACH = 0x1,
+   DO_DETACH = 0x2,
+   DO_BUFCONFIG = 0x4,
+};
+
 /* Declare prog variables */
 int vlevel = 1;
-int unatt_act = 0;
+enum actions actions = 0;
+int bufsize = -1;
 struct option a4l_conf_opts[] = {
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
@@ -47,13 +51,38 @@ struct option a4l_conf_opts[] = {
{"remove", no_argument, NULL, 'r'},
{"read-buffer-size", required_argument, NULL, 'R'},
{"write-buffer-size", required_argument, NULL, 'W'},
+   {"buffer-size", required_argument, NULL, 'S'},
{0},
 };
 
-int compute_opts(char *opts, unsigned int *nb, unsigned long *res)
+/* Misc functions */
+void do_print_version(void)
+{
+   fprintf(stdout, "analogy_config: version %s\n", PACKAGE_VERSION);
+}
+
+void do_print_usage(void)
+{
+   fprintf(stdout,
+   "usage:\tanalogy_config [OPTS] devfile driver "
+   "\n");
+   fprintf(stdout, "\tOPTS:\t -v, --verbose: verbose output\n");
+   fprintf(stdout, "\t\t -q, --quiet: quiet output\n");
+   fprintf(stdout, "\t\t -V, --version: print program version\n");
+   fprintf(stdout, "\t\t -r, --remove: detach a device\n");
+   fprintf(stdout, 
+   "\t\t -S, --buffer-size: set default buffer size in kB\n");
+   fprintf(stdout, "\tDeprecated options:\n");
+   fprintf(stdout,
+   "\t\t -R, --read-buffer-size: read buffer size in kB\n");
+   fprintf(stdout,
+   "\t\t -W, --write-buffer-size: write buffer size in kB\n");
+}
+
+int parse_extra_arg(char *opts, unsigned int *nb, unsigned long *res)
 {
 
-   int ret = 0, len, ofs;
+   int err = 0, len, ofs;
 
/* Check arg and inits it */
if (nb == NULL)
@@ -71,7 +100,7 @@ int compute_opts(char *opts, unsigned int *nb, unsigned long 
*res)
if (res != NULL) {
res[(*nb) - 1] = strtoul(opts, NULL, 0);
if (errno != 0) {
-   ret = -errno;
+   err = -errno;
goto out_compute_opts;
}   
}
@@ -80,43 +109,52 @@ int compute_opts(char *opts, unsigned int *nb, unsigned 
long *res)
 
 out_compute_opts:
(*nb) *= sizeof(unsigned long);
-   return ret;
+   return err;
 }
 
-/* Misc functions */
-void do_print_version(void)
+int process_extra_arg(a4l_lnkdesc_t *lnkdsc, char *arg)
 {
-   fprintf(stdout, "analogy_config: version %s\n", PACKAGE_VERSION);
-}
+   int err = 0;
+   
+   if ((err = parse_extra_arg(arg, &lnkdsc->opts_size, NULL)) < 0) {
+   goto err_opts;
+   }
 
-void do_print_usage(void)
-{
-   fprintf(stdout,
-   "usage:\tanalogy_config [OPTS] devfile driver "
-   "\n");
-   fprintf(stdout, "\tOPTS:\t -v, --verbose: verbose output\n");
-   fprintf(stdout, "\t\t -q, --quiet: quiet output\n");
-   fprintf(stdout, "\t\t -V, --version: print program version\n");
-   fprintf(stdout, "\t\t -r, --remove: remove configured driver\n");
-   fprintf(stdout,
-   "\t\t -R, --read-buffer-size: read buffer size in kB\n");
-   fprintf(stdout,
-   "\t\t -W, --write-buffer-size: write buffer size in kB\n");
+   lnkdsc->opts = malloc(lnkdsc->opts_size);
+   if (lnkdsc->opts == NULL) {
+   fprintf(stderr,
+   "analogy_config: memory allocation failed\n");
+   err = -ENOMEM;
+   goto out;
+   }
+
+   if ((err = parse_extra_arg(arg, 
+  &lnkdsc->opts_size, lnkdsc->opts)) < 0) {
+   goto err_opts;
+   }   
+
+out:
+   return err;
+
+err_opts:
+   fprintf(stderr,
+   "analogy_config: specific-driver options recovery failed\n");
+   fprintf(stderr,
+   "\twarn

[Xenomai-git] Alexis Berlemont : analogy: implement configuration of buffer default size

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: b401bf2c7c855978aef102f44a9764ee93210129
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=b401bf2c7c855978aef102f44a9764ee93210129

Author: Alexis Berlemont 
Date:   Tue Oct 19 23:52:20 2010 +0200

analogy: implement configuration of buffer default size

---

 include/analogy/buffer.h  |8 
 include/analogy/transfer.h|3 +++
 include/analogy/types.h   |4 +---
 ksrc/drivers/analogy/buffer.c |   17 +++--
 ksrc/drivers/analogy/rtdm_interface.c |   10 +-
 ksrc/drivers/analogy/transfer.c   |4 
 6 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h
index b5be3f0..86d0a64 100644
--- a/include/analogy/buffer.h
+++ b/include/analogy/buffer.h
@@ -456,9 +456,17 @@ typedef struct a4l_mmap_arg a4l_mmap_t;
(might be used with BUFCFG ioctl) */
 #define A4L_BUF_MAXSIZE 0x100
 #define A4L_BUF_DEFSIZE 0x1
+#define A4L_BUF_DEFMAGIC 0xffaaff55
 
 /* BUFCFG ioctl argument structure */
 struct a4l_buffer_config {
+   /* NOTE: with the last buffer implementation, the field
+  idx_subd became useless; the buffer are now
+  per-context. So, the buffer size configuration is specific
+  to an opened device. There is a little exception: we can
+  define a default buffer size for a device. 
+  So far, a hack is used to implement the configuration of
+  the default buffer size */
unsigned int idx_subd;
unsigned long buf_size;
 };
diff --git a/include/analogy/transfer.h b/include/analogy/transfer.h
index 929022b..2850834 100644
--- a/include/analogy/transfer.h
+++ b/include/analogy/transfer.h
@@ -57,6 +57,9 @@ struct a4l_transfer {
unsigned int nb_subd;
a4l_subd_t **subds;
 
+   /* Buffer stuff: the default size */
+   unsigned int default_bufsize;
+
/* IRQ in use */
/* TODO: irq_desc should vanish */
a4l_irq_desc_t irq_desc;
diff --git a/include/analogy/types.h b/include/analogy/types.h
index e3974eb..89dbb8a 100644
--- a/include/analogy/types.h
+++ b/include/analogy/types.h
@@ -25,9 +25,7 @@
 
 #ifndef DOXYGEN_CPP
 
-/* --- Misc precompilation constants --- */
-
-#define A4L_DEFAULT_BFSIZE 0x1
+/* --- Misc precompilation constant --- */
 #define A4L_NAMELEN 20
 
 /* --- Common Analogy types --- */
diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c
index 8bd7d38..7623674 100644
--- a/ksrc/drivers/analogy/buffer.c
+++ b/ksrc/drivers/analogy/buffer.c
@@ -117,7 +117,7 @@ static void a4l_reinit_buffer(a4l_buf_t *buf_desc)
 
 void a4l_init_buffer(a4l_buf_t *buf_desc)
 {
-
+   memset(buf_desc, 0, sizeof(a4l_buf_t));
a4l_init_sync(&buf_desc->sync);
a4l_reinit_buffer(buf_desc);
 }
@@ -598,16 +598,21 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg)
 arg, sizeof(a4l_bufcfg_t)) != 0)
return -EFAULT;
 
-   if (subd && test_bit(A4L_SUBD_BUSY_NR, &subd->status)) {
-   __a4l_err("a4l_ioctl_bufcfg: acquisition in progress\n");
-   return -EBUSY;
-   }
-
if (buf_cfg.buf_size > A4L_BUF_MAXSIZE) {
__a4l_err("a4l_ioctl_bufcfg: buffer size too big (<=16MB)\n");
return -EINVAL;
}
 
+   if (buf_cfg.idx_subd == A4L_BUF_DEFMAGIC) {
+   cxt->dev->transfer.default_bufsize = buf_cfg.buf_size;
+   return 0;
+   }
+
+   if (subd && test_bit(A4L_SUBD_BUSY_NR, &subd->status)) {
+   __a4l_err("a4l_ioctl_bufcfg: acquisition in progress\n");
+   return -EBUSY;
+   }
+
if (test_bit(A4L_BUF_MAP, &buf->flags)) {
__a4l_err("a4l_ioctl_bufcfg: please unmap before "
  "configuring buffer\n");
diff --git a/ksrc/drivers/analogy/rtdm_interface.c 
b/ksrc/drivers/analogy/rtdm_interface.c
index 65acc86..906a20f 100644
--- a/ksrc/drivers/analogy/rtdm_interface.c
+++ b/ksrc/drivers/analogy/rtdm_interface.c
@@ -136,11 +136,11 @@ int a4l_open(struct rtdm_dev_context *context,
 
/* Allocate the asynchronous buffer 
   NOTE: it should be interesting to allocate the buffer only
-  on demand especially if the system is short of memory
-  NOTE2: the default buffer size could be configured via
-  kernel config*/
-   a4l_alloc_buffer(cxt->buffer, A4L_DEFAULT_BFSIZE);
-
+  on demand especially if the system is short of memory */
+   if (cxt->dev->transfer.default_bufsize)
+   a4l_alloc_buffer(cxt->buffer, 
+cxt->dev->transfer.default_bufsize);
+   
return 0;
 }
 
diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c
index dc34997..c0f2945 100644
--- a/ksrc/drivers/analogy/transfer.c
+++ b/ksrc/drivers/analogy/transfer.c
@@ -92,6 +92,8 

[Xenomai-git] Alexis Berlemont : analogy: rename waveform files

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 73e52110c5487bd19659cf849f41c5bb596452c6
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=73e52110c5487bd19659cf849f41c5bb596452c6

Author: Alexis Berlemont 
Date:   Mon Oct 18 07:53:19 2010 +0200

analogy: rename waveform files

---

 .../{signal_generation.c => wf_facilities.c}   |0 
 .../{signal_generation.h => wf_facilities.h}   |0 
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/src/utils/analogy/signal_generation.c 
b/src/utils/analogy/wf_facilities.c
similarity index 100%
rename from src/utils/analogy/signal_generation.c
rename to src/utils/analogy/wf_facilities.c
diff --git a/src/utils/analogy/signal_generation.h 
b/src/utils/analogy/wf_facilities.h
similarity index 100%
rename from src/utils/analogy/signal_generation.h
rename to src/utils/analogy/wf_facilities.h


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


[Xenomai-git] Alexis Berlemont : analogy: fix the default size of the buffer

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 19cab71e2d113b9f90b50bedb91c0ffbe9dd72c3
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=19cab71e2d113b9f90b50bedb91c0ffbe9dd72c3

Author: Alexis Berlemont 
Date:   Sun Oct 17 15:54:04 2010 +0200

analogy: fix the default size of the buffer

---

 include/analogy/types.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/analogy/types.h b/include/analogy/types.h
index eec4ad0..e3974eb 100644
--- a/include/analogy/types.h
+++ b/include/analogy/types.h
@@ -27,7 +27,7 @@
 
 /* --- Misc precompilation constants --- */
 
-#define A4L_DEFAULT_BFSIZE 0x1000
+#define A4L_DEFAULT_BFSIZE 0x1
 #define A4L_NAMELEN 20
 
 /* --- Common Analogy types --- */


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


[Xenomai-git] Alexis Berlemont : analogy: [pcimio] minor fix in log messages

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 298552c00b8ef3e8c41a5761c44346529e0cecc0
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=298552c00b8ef3e8c41a5761c44346529e0cecc0

Author: Alexis Berlemont 
Date:   Sun Oct 17 16:00:42 2010 +0200

analogy: [pcimio] minor fix in log messages

---

 ksrc/drivers/analogy/national_instruments/mite.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ksrc/drivers/analogy/national_instruments/mite.c 
b/ksrc/drivers/analogy/national_instruments/mite.c
index 9b0394a..a093ee2 100644
--- a/ksrc/drivers/analogy/national_instruments/mite.c
+++ b/ksrc/drivers/analogy/national_instruments/mite.c
@@ -579,7 +579,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, 
a4l_subd_t *subd)
nbytes_ub = mite_bytes_written_to_memory_ub(mite_chan);
 
if(a4l_buf_prepare_absput(subd, nbytes_ub) != 0) {
-   __a4l_info("MITE: DMA overwrite of free area\n");
+   __a4l_err("MITE: DMA overwrite of free area\n");
return -EPIPE;
}



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


[Xenomai-git] Alexis Berlemont : analogy: add a "sys" function for the ioctl BUFCONFIG

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 9a05f220b1d597efaa89cfb5482d54ac3c50c5f0
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=9a05f220b1d597efaa89cfb5482d54ac3c50c5f0

Author: Alexis Berlemont 
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


[Xenomai-git] Alexis Berlemont : analogy: minor changes

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: f54da70f9969098871b4db9c904ccf59b0222eb2
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=f54da70f9969098871b4db9c904ccf59b0222eb2

Author: Alexis Berlemont 
Date:   Mon Oct 18 23:48:08 2010 +0200

analogy: minor changes

---

 src/utils/analogy/wf_facilities.c |4 +---
 src/utils/analogy/wf_facilities.h |2 --
 2 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/src/utils/analogy/wf_facilities.c 
b/src/utils/analogy/wf_facilities.c
index 2f443c5..ce250e7 100644
--- a/src/utils/analogy/wf_facilities.c
+++ b/src/utils/analogy/wf_facilities.c
@@ -4,9 +4,7 @@
 #include 
 #include 
 
-#include 
-
-#include "signal_generation.h"
+#include "wf_facilities.h"
 
 #ifndef PI
 #define PI 3.14159265358979323846
diff --git a/src/utils/analogy/wf_facilities.h 
b/src/utils/analogy/wf_facilities.h
index 6f6d2cf..6c99d51 100644
--- a/src/utils/analogy/wf_facilities.h
+++ b/src/utils/analogy/wf_facilities.h
@@ -3,8 +3,6 @@
 
 #include 
 
-#include 
-
 #define MAX_SAMPLE_COUNT 8096
 #define MIN_SAMPLE_COUNT 2
 


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


[Xenomai-git] Alexis Berlemont : analogy: add first version of waveform generation

2010-11-02 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: a9bfca5bd6daa6813f108f3bfcba5c8a8351954b
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a9bfca5bd6daa6813f108f3bfcba5c8a8351954b

Author: Alexis Berlemont 
Date:   Sat Oct 16 14:59:54 2010 +0200

analogy: add first version of waveform generation

This work is based on Daniele Nicolodi's work. Unfortunately, I could
not include the proprosal as is because it was limited for 16bits
acquisition devices.

So far, this work is not complete.

---

 src/utils/analogy/Makefile.am |6 ++
 src/utils/analogy/signal_generation.c |  157 +
 src/utils/analogy/signal_generation.h |   38 
 3 files changed, 201 insertions(+), 0 deletions(-)

diff --git a/src/utils/analogy/Makefile.am b/src/utils/analogy/Makefile.am
index f82942e..3d8cb5e 100644
--- a/src/utils/analogy/Makefile.am
+++ b/src/utils/analogy/Makefile.am
@@ -9,6 +9,12 @@ CPPFLAGS = \
 LDFLAGS = \
@XENO_USER_LDFLAGS@
 
+lib_LIBRARIES = libwaveform.a
+
+libwaveform_a_SOURCES = signal_generation.c
+
+noinst_HEADERS = signal_generation.h
+
 analogy_config_SOURCES = analogy_config.c
 analogy_config_LDADD = \
../../drvlib/analogy/libanalogy.la \
diff --git a/src/utils/analogy/signal_generation.c 
b/src/utils/analogy/signal_generation.c
new file mode 100644
index 000..2f443c5
--- /dev/null
+++ b/src/utils/analogy/signal_generation.c
@@ -0,0 +1,157 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "signal_generation.h"
+
+#ifndef PI
+#define PI 3.14159265358979323846
+#endif
+
+void a4l_sg_init_sine(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 + 
+   0.5 * config->wf_amplitude * cos(i * 2 * PI * ratio);
+   }
+}
+
+void a4l_sg_init_sawtooth(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+   
+   int period_idx = (int)floor(i * ratio);
+
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 -
+   period_idx * config->wf_amplitude +
+   i * ratio * config->wf_amplitude;
+   }
+}
+
+void a4l_sg_init_triangular(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+
+   int period_idx = (int)floor(i * ratio);
+   int half_period_idx = (int)floor(i * 2 * ratio);
+   int rise = ((half_period_idx % 2) == 0) ? 1 : 0;
+
+   if (rise) {
+   values[i] = config->wf_offset - 
+   config->wf_amplitude / 2 -
+   2 * period_idx * config->wf_amplitude +
+   2 * i * ratio * config->wf_amplitude;
+   } else {
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 +
+   2 * (period_idx + 1) * config->wf_amplitude - 
+   2 * i * ratio * config->wf_amplitude;
+   }
+   }
+}
+
+void a4l_sg_init_steps(struct waveform_config *config, double *values)
+{
+   int i;
+   
+   double ratio = config->wf_frequency / config->spl_frequency;
+   
+   for (i = 0; i < config->spl_count; i++) {
+   int half_period_idx = (int)floor(i * 2 * ratio);
+   int even = (half_period_idx % 2 == 0);
+   
+   values[i] = config->wf_offset - 
+   config->wf_amplitude / 2 + even * config->wf_amplitude;
+   }
+}
+
+void a4l_sg_set_sample_count(struct waveform_config *config)
+{
+   int sample_count = MIN_SAMPLE_COUNT;
+   int best_count = MIN_SAMPLE_COUNT;
+   double lowest_diff = INFINITY;
+
+   while (sample_count < MAX_SAMPLE_COUNT) {
+
+   double ratio = (double)sample_count * 
+   (config->wf_frequency / config->spl_frequency);
+   int ceiling = ceil(ratio);
+   double diff = (double)ceiling - ratio;
+
+   assert(diff >= 0);
+
+   if (diff < lowest_diff) {
+   lowest_diff = diff;
+   best_count = sample_count;
+   }
+
+   if (diff == 0)
+   break;
+
+   sample_count++;
+   }
+
+   if (lowest_diff != 0) {
+   printf("Warning: unable to create a contiguous signal\n");
+   printf("Warning: an approximation is performed\n