[Xenomai-git] Alexis Berlemont : analogy: add missing channel and range descriptors in the loop driver

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 58f12084d460512676f4aeef9122ea43780b0865
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=58f12084d460512676f4aeef9122ea43780b0865

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Wed Dec  9 22:32:35 2009 +0100

analogy: add missing channel and range descriptors in the loop driver

---

 ksrc/drivers/analogy/testing/loop.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/ksrc/drivers/analogy/testing/loop.c 
b/ksrc/drivers/analogy/testing/loop.c
index fae90cb..14d46c5 100644
--- a/ksrc/drivers/analogy/testing/loop.c
+++ b/ksrc/drivers/analogy/testing/loop.c
@@ -191,6 +191,8 @@ void setup_output_subd(a4l_subd_t *subd)
subd-flags = A4L_SUBD_AO;
subd-flags |= A4L_SUBD_CMD;
subd-flags |= A4L_SUBD_MMAP;
+   subd-rng_desc = loop_rngdesc;
+   subd-chan_desc = loop_chandesc;
subd-insn_read = loop_insn_read;
subd-insn_write = loop_insn_write;
 }


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


[Xenomai-git] Alexis Berlemont : analogy: fix potentiel NULL instructions handlers executions

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 258158be50913083a29d17f74f33e46c87f37d69
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=258158be50913083a29d17f74f33e46c87f37d69

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Nov 28 15:51:57 2009 +0100

analogy: fix potentiel NULL instructions handlers executions

The instruction ioctl functions did not properly check that a read /
write / config / bits handler was registered by the low-level
driver. That leaves place for bad accesses to occur.

---

 ksrc/drivers/analogy/instruction.c |   36 +---
 1 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/ksrc/drivers/analogy/instruction.c 
b/ksrc/drivers/analogy/instruction.c
index ecd28be..2ca7305 100644
--- a/ksrc/drivers/analogy/instruction.c
+++ b/ksrc/drivers/analogy/instruction.c
@@ -201,6 +201,8 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc)
int ret;
a4l_subd_t *subd;
a4l_dev_t *dev = a4l_get_dev(cxt);
+   int (*hdlr) (a4l_subd_t *, a4l_kinsn_t *) = NULL;
+
 
/* Checks the subdevice index */
if (dsc-idx_subd = dev-transfer.nb_subd) {
@@ -223,30 +225,42 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc)
if (ret  0)
return ret;
 
-   /* Prevents the subdevice from being used during 
-  the following operations */
-   ret = a4l_reserve_transfer(cxt, dsc-idx_subd);
-   if (ret  0)
-   goto out_do_insn;
-
-   /* Lets the driver-specific code perform the instruction */
+   /* Choose the proper handler, we can check the pointer because
+  the subdevice was memset to 0 at allocation time */
switch (dsc-type) {
case A4L_INSN_READ:
-   ret = subd-insn_read(subd, dsc);
+   hdlr = subd-insn_read;
break;
case A4L_INSN_WRITE:
-   ret = subd-insn_write(subd, dsc);
+   hdlr = subd-insn_write;
break;
case A4L_INSN_BITS:
-   ret = subd-insn_bits(subd, dsc);
+   hdlr = subd-insn_bits;
break;
case A4L_INSN_CONFIG:
-   ret = subd-insn_config(subd, dsc);
+   hdlr = subd-insn_config;
break;
default:
ret = -EINVAL;
}
 
+   /* We check the instruction type */
+   if (ret  0)
+   return ret;
+
+   /* We check whether a handler is available */
+   if (hdlr == NULL)
+   return -ENOSYS;
+
+   /* Prevents the subdevice from being used during 
+  the following operations */
+   ret = a4l_reserve_transfer(cxt, dsc-idx_subd);
+   if (ret  0)
+   goto out_do_insn;
+
+   /* Let's the driver-specific code perform the instruction */
+   ret = hdlr(subd, dsc);
+
 out_do_insn:
 
/* Releases the subdevice from its reserved state */


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


[Xenomai-git] Alexis Berlemont : analogy: in cmd_read, set a higher scan interval

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 7a68b572ab97848ab63cae842cc0992ce8bf2714
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=7a68b572ab97848ab63cae842cc0992ce8bf2714

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Wed Dec  9 22:39:02 2009 +0100

analogy: in cmd_read, set a higher scan interval

In case of wide acquisitions (many channels acquired simultaneously),
the argument scan_begin_arg was too low for the whole scan to
complete.

---

 src/utils/analogy/cmd_read.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c
index 99bdab8..b692fad 100644
--- a/src/utils/analogy/cmd_read.c
+++ b/src/utils/analogy/cmd_read.c
@@ -38,9 +38,7 @@
 #define ID_SUBD 0
 /* For simplicity sake, a maximum channel 
count is defined */
-#define MAX_NB_CHAN 10
-/* Four channels used by default */
-#define NB_CHAN 4
+#define MAX_NB_CHAN 32
 /* One hundred triggered scans by default */
 #define NB_SCAN 100
 
@@ -65,7 +63,7 @@ a4l_cmd_t cmd = {
.start_src = TRIG_NOW,
.start_arg = 0,
.scan_begin_src = TRIG_TIMER,
-   .scan_begin_arg = 200,  /* in ns */
+   .scan_begin_arg = 800,  /* in ns */
.convert_src = TRIG_TIMER,
.convert_arg = 50,  /* in ns */
.scan_end_src = TRIG_COUNT,


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


[Xenomai-git] Alexis Berlemont : analogy: add a kernel error message when a driver rejects a command

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 4a752762318eab4a10d04718185d444a90919b88
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=4a752762318eab4a10d04718185d444a90919b88

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Wed Dec  9 22:31:04 2009 +0100

analogy: add a kernel error message when a driver rejects a command

---

 ksrc/drivers/analogy/command.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c
index 2fb9344..e227b97 100644
--- a/ksrc/drivers/analogy/command.c
+++ b/ksrc/drivers/analogy/command.c
@@ -342,8 +342,10 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg)
ret = dev-transfer.subds[cmd_desc-idx_subd]-
do_cmdtest(dev-transfer.subds[cmd_desc-idx_subd], 
   cmd_desc);
-   if (ret != 0)
+   if (ret != 0) {
+   __a4l_err(a4l_ioctl_cmd: driver's cmd_test failed\n);
goto out_ioctl_cmd;
+   }
 
__a4l_dbg(1, core_dbg, 
  a4l_ioctl_cmd: driver's cmd checks passed\n);


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


[Xenomai-git] Alexis Berlemont : analogy: properly manage cancel operations on synchronous subdevices

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 30f6b6f4439847f1f9ec01431cbed057eafe5787
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=30f6b6f4439847f1f9ec01431cbed057eafe5787

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Mon Dec  7 00:12:40 2009 +0100

analogy: properly manage cancel operations on synchronous subdevices

---

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

diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c
index c6306d9..598cb9e 100644
--- a/ksrc/drivers/analogy/transfer.c
+++ b/ksrc/drivers/analogy/transfer.c
@@ -286,9 +286,10 @@ int a4l_cancel_transfer(a4l_cxt_t * cxt, int idx_subd)
clear_bit(A4L_TSF_BUSY, (dev-transfer.status[idx_subd]));
 
/* If the subdevice is command capable and 
-  if there is a command is under progress, 
+  if a command is under progress, 
   disable it and free it... */
if (dev-transfer.bufs != NULL 
+   dev-transfer.bufs[idx_subd] != NULL 
dev-transfer.bufs[idx_subd]-cur_cmd != NULL) {
 
a4l_free_cmddesc(dev-transfer.bufs[idx_subd]-cur_cmd);


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


[Xenomai-git] Alexis Berlemont : analogy: fix a bug in the conversion routines

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 72999d2c02f06fd3e89dc59679fd2f61b4fc5c89
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=72999d2c02f06fd3e89dc59679fd2f61b4fc5c89

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Fri Dec 11 13:31:38 2009 +0100

analogy: fix a bug in the conversion routines 

If the acquisition bit width is different from 8, 16 and 32 bits, the
access methods on the physical values was not properly set.

---

 src/drvlib/analogy/range.c |   38 --
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/src/drvlib/analogy/range.c b/src/drvlib/analogy/range.c
index 72293b9..1965e57 100644
--- a/src/drvlib/analogy/range.c
+++ b/src/drvlib/analogy/range.c
@@ -166,6 +166,11 @@ int a4l_from_phys(a4l_chinfo_t * chan,
int i = 0, j = 0;
lsampl_t tmp;
 
+   /* Bytes count used for conversion; the bit width may be
+  different from the acquisition bits size:
+  Ex.: acq_size = 12 bits = conv_size = 16 bits */
+   int conv_size;
+
/* Temporary values used for conversion
   (phys = a * src + b) */
double a, b;
@@ -176,16 +181,20 @@ int a4l_from_phys(a4l_chinfo_t * chan,
if (rng == NULL || chan == NULL)
return 0;
 
+   /* Computes the conversion width */
+   conv_size = (chan-nb_bits % 8 == 0) ? 
+   chan-nb_bits / 8 : (chan-nb_bits / 8) + 1;
+
/* This converting function only works 
   if acquired data width is 8, 16 or 32 */
-   switch (chan-nb_bits) {
-   case 32:
+   switch (conv_size) {
+   case 4:
datax_get = data32_get;
break;
-   case 16:
+   case 2:
datax_get = data16_get;
break;
-   case 8:
+   case 1:
datax_get = data8_get;
break;
default:
@@ -206,7 +215,7 @@ int a4l_from_phys(a4l_chinfo_t * chan,
dst[j] = a * tmp + b;
 
/* Updates the counters */
-   i += chan-nb_bits / 8;
+   i += conv_size;
j++;
}
 
@@ -236,6 +245,11 @@ int a4l_to_phys(a4l_chinfo_t * chan,
 {
int i = 0, j = 0;
 
+   /* Bytes count used for conversion; the bit width may be
+  different from the acquisition bits size:
+  Ex.: acq_size = 12 bits = conv_size = 16 bits */
+   int conv_size;
+
/* Temporary values used for conversion
   (dst = a * phys - b) */
double a, b;
@@ -246,16 +260,20 @@ int a4l_to_phys(a4l_chinfo_t * chan,
if (rng == NULL || chan == NULL)
return 0;
 
+   /* Computes the conversion width */
+   conv_size = (chan-nb_bits % 8 == 0) ? 
+   chan-nb_bits / 8 : (chan-nb_bits / 8) + 1;
+
/* This converting function only works 
   if acquired data width is 8, 16 or 32 */
-   switch (chan-nb_bits) {
-   case 32:
+   switch (conv_size) {
+   case 4:
datax_set = data32_set;
break;
-   case 16:
+   case 2:
datax_set = data16_set;
break;
-   case 8:
+   case 1:
datax_set = data8_set;
break;
default:
@@ -274,7 +292,7 @@ int a4l_to_phys(a4l_chinfo_t * chan,
datax_set(dst + i, (lsampl_t) (a * src[j] - b));
 
/* Updates the counters */
-   i += chan-nb_bits / 8;
+   i += conv_size;
j++;
}
 


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


[Xenomai-git] Alexis Berlemont : analogy: minor change in the driver description

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 555e67b1d308b7fe729788d55aa9b8f284769435
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=555e67b1d308b7fe729788d55aa9b8f284769435

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sun Dec 13 23:29:20 2009 +0100

analogy: minor change in the driver description

---

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

diff --git a/ksrc/drivers/analogy/intel/parport.c 
b/ksrc/drivers/analogy/intel/parport.c
index 72b25c5..aca04ce 100644
--- a/ksrc/drivers/analogy/intel/parport.c
+++ b/ksrc/drivers/analogy/intel/parport.c
@@ -23,7 +23,7 @@
additional parallel ports from old computers or your neighbors'
computers.
 
-   Option list:
+   Attach options list:
0: I/O port base for the parallel port.
1: IRQ
 


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


[Xenomai-git] Alexis Berlemont : analogy: fix Doxygen documentation (a4l_sync_read, a4l_sync_write)

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 86a3e25b256c79c0fe44b462a29bb5e3af672fc0
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=86a3e25b256c79c0fe44b462a29bb5e3af672fc0

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Dec 19 20:47:39 2009 +0100

analogy: fix Doxygen documentation (a4l_sync_read, a4l_sync_write)

---

 src/drvlib/analogy/sync.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/drvlib/analogy/sync.c b/src/drvlib/analogy/sync.c
index 55d56d3..1a4b007 100644
--- a/src/drvlib/analogy/sync.c
+++ b/src/drvlib/analogy/sync.c
@@ -121,7 +121,7 @@ int a4l_snd_insn(a4l_desc_t * dsc, a4l_insn_t * arg)
  * @param[in] buf Output buffer
  * @param[in] nbyte Number of bytes to write
  *
- * @return 0 on success. Otherwise:
+ * @return Number of bytes written, otherwise negative error code:
  *
  * - -EINVAL is returned if some argument is missing or wrong (Please,
  *type dmesg for more info)
@@ -194,7 +194,7 @@ int a4l_sync_write(a4l_desc_t * dsc,
  * @param[in] buf Input buffer
  * @param[in] nbyte Number of bytes to read
  *
- * @return 0 on success. Otherwise:
+ * @return Number of bytes read, otherwise negative error code:
  *
  * - -EINVAL is returned if some argument is missing or wrong (Please,
  *type dmesg for more info)


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


[Xenomai-git] Alexis Berlemont : analogy: fix wrong names of conversion functions

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 65ed1492fb89eed23fe9b023fe57da6c34864633
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=65ed1492fb89eed23fe9b023fe57da6c34864633

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Wed Dec  9 22:40:30 2009 +0100

analogy: fix wrong names of conversion functions

---

 include/analogy/analogy.h |   10 --
 src/drvlib/analogy/range.c|   14 +++---
 src/utils/analogy/insn_read.c |2 +-
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/include/analogy/analogy.h b/include/analogy/analogy.h
index 8d11047..21c7e59 100644
--- a/include/analogy/analogy.h
+++ b/include/analogy/analogy.h
@@ -136,13 +136,11 @@ int a4l_find_range(a4l_desc_t * dsc,
   unsigned long unit,
   double min, double max, a4l_rnginfo_t ** rng);
 
-int a4l_to_phys(a4l_chinfo_t * chan,
-   a4l_rnginfo_t * rng, double *dst, void *src,
-   int cnt);
-
 int a4l_from_phys(a4l_chinfo_t * chan,
- a4l_rnginfo_t * rng, void *dst, double *src,
- int cnt);
+ a4l_rnginfo_t * rng, double *dst, void *src, int cnt);
+
+int a4l_to_phys(a4l_chinfo_t * chan,
+   a4l_rnginfo_t * rng, void *dst, double *src, int cnt);
 
 #endif /* !DOXYGEN_CPP */
 
diff --git a/src/drvlib/analogy/range.c b/src/drvlib/analogy/range.c
index ab41f1e..72293b9 100644
--- a/src/drvlib/analogy/range.c
+++ b/src/drvlib/analogy/range.c
@@ -143,7 +143,7 @@ out_get_range:
 }
 
 /**
- * @brief Convert samples to physical units
+ * @brief Convert physical units to samples
  *
  * @param[in] chan Channel descriptor
  * @param[in] rng Range descriptor
@@ -160,8 +160,8 @@ out_get_range:
  *before using a4l_to_phys()
  *
  */
-int a4l_to_phys(a4l_chinfo_t * chan,
-   a4l_rnginfo_t * rng, double *dst, void *src, int cnt)
+int a4l_from_phys(a4l_chinfo_t * chan,
+ a4l_rnginfo_t * rng, double *dst, void *src, int cnt)
 {
int i = 0, j = 0;
lsampl_t tmp;
@@ -197,7 +197,7 @@ int a4l_to_phys(a4l_chinfo_t * chan,
(((1ULL  chan-nb_bits) - 1) * A4L_RNG_FACTOR);
b = (double)rng-min / A4L_RNG_FACTOR;
 
-   while (i  cnt) {
+   while (j  cnt) {
 
/* Properly retrieves the data */
tmp = datax_get(src + i);
@@ -214,7 +214,7 @@ int a4l_to_phys(a4l_chinfo_t * chan,
 }
 
 /**
- * @brief Convert physical units to samples
+ * @brief Convert samples to physical units
  *
  * @param[in] chan Channel descriptor
  * @param[in] rng Range descriptor
@@ -231,7 +231,7 @@ int a4l_to_phys(a4l_chinfo_t * chan,
  *before using a4l_from_phys()
  *
  */
-int a4l_from_phys(a4l_chinfo_t * chan,
+int a4l_to_phys(a4l_chinfo_t * chan,
  a4l_rnginfo_t * rng, void *dst, double *src, int cnt)
 {
int i = 0, j = 0;
@@ -268,7 +268,7 @@ int a4l_from_phys(a4l_chinfo_t * chan,
b = ((double)(rng-min) / (rng-max - rng-min)) *
((1ULL  chan-nb_bits) - 1);
 
-   while (i  cnt) {
+   while (j  cnt) {
 
/* Performs the conversion */
datax_set(dst + i, (lsampl_t) (a * src[j] - b));
diff --git a/src/utils/analogy/insn_read.c b/src/utils/analogy/insn_read.c
index 50f2c98..d5e025d 100644
--- a/src/utils/analogy/insn_read.c
+++ b/src/utils/analogy/insn_read.c
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
 
/* If a range was selected, converts the samples */
if (idx_rng = 0) {
-   if (a4l_to_phys(chinfo, rnginfo, dbuf, buf, ret)  0) {
+   if (a4l_from_phys(chinfo, rnginfo, dbuf, buf, ret)  0) 
{
fprintf(stderr,
insn_read: data conversion failed 
(ret=%d)\n,
ret);


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


[Xenomai-git] Alexis Berlemont : analogy: slight change in a kernel error message

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 32f17d302a0d9fc929247afb7b5d2ba292a991c9
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=32f17d302a0d9fc929247afb7b5d2ba292a991c9

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Dec 19 20:44:14 2009 +0100

analogy: slight change in a kernel error message

---

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

diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c
index e227b97..509d73d 100644
--- a/ksrc/drivers/analogy/command.c
+++ b/ksrc/drivers/analogy/command.c
@@ -98,8 +98,8 @@ int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc)
 
if (desc-idx_subd = dev-transfer.nb_subd) {
__a4l_err(a4l_check_cmddesc: 
- subdevice index out of range (%u = %u)\n,
- desc-idx_subd, dev-transfer.nb_subd);
+ subdevice index out of range (idx=%u)\n,
+ desc-idx_subd);
return -EINVAL;
}
 


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


[Xenomai-git] Alexis Berlemont : analogy: add a simple helper function

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 2c8eb888d943bcbc2498bfc6d55771b139a4a4cd
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=2c8eb888d943bcbc2498bfc6d55771b139a4a4cd

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Tue Dec 15 15:25:54 2009 +0100

analogy: add a simple helper function 

The added function displays the size taken in memory for an element
acquired from (/ sent to) a specific channel.

---

 include/analogy/analogy.h  |4 +++-
 src/drvlib/analogy/range.c |   34 +-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/include/analogy/analogy.h b/include/analogy/analogy.h
index 21c7e59..79bd69c 100644
--- a/include/analogy/analogy.h
+++ b/include/analogy/analogy.h
@@ -129,7 +129,9 @@ int a4l_sync_read(a4l_desc_t * dsc,
  unsigned int idx_subd,
  unsigned int chan_desc,
  unsigned int delay, void *buf, size_t nbyte);
-   
+
+int a4l_sizeof_chan(a4l_chinfo_t * chan);
+
 int a4l_find_range(a4l_desc_t * dsc,
   unsigned int idx_subd,
   unsigned int idx_chan,
diff --git a/src/drvlib/analogy/range.c b/src/drvlib/analogy/range.c
index 1965e57..05615bd 100644
--- a/src/drvlib/analogy/range.c
+++ b/src/drvlib/analogy/range.c
@@ -66,6 +66,38 @@ void data8_set(void *dst, lsampl_t val)
  */
 
 /**
+ * @brief Get the size in memory of an acquired element
+ *
+ * According to the board, the channels have various acquisition
+ * widths. With values like 8, 16 or 32, there is no problem finding
+ * out the size in memory (1, 2, 4); however with widths like 12 or
+ * 24, this function might be helpful to guess the size needed in RAM
+ * for a single acquired element.
+ *
+ * @param[in] chan Channel descriptor
+ *
+ * @return the size in memory of an acquired element, otherwise a negative
+ * error code:
+ *
+ * - -EINVAL is returned if the argument chan is NULL
+ *
+ */
+int a4l_sizeof_chan(a4l_chinfo_t * chan)
+{
+   /* So far, it seems there is no 64 bit acquistion stuff */
+   int i = 0, sizes[3] = {8, 16, 32};
+
+   if (chan == NULL)
+   return -EINVAL;
+
+   while (i  3  sizes[i]  chan-nb_bits)
+   i++;
+
+   return (i == 3) ? -EINVAL : sizes[i] / 8;
+}
+
+
+/**
  * @brief Find the must suitable range
  *
  * @param[in] dsc Device descriptor filled by a4l_open() and
@@ -241,7 +273,7 @@ int a4l_from_phys(a4l_chinfo_t * chan,
  *
  */
 int a4l_to_phys(a4l_chinfo_t * chan,
- a4l_rnginfo_t * rng, void *dst, double *src, int cnt)
+   a4l_rnginfo_t * rng, void *dst, double *src, int cnt)
 {
int i = 0, j = 0;
 


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


[Xenomai-git] Alexis Berlemont : analogy: improve the test program cmd_read

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: a1d23f6e98f1d7c7fe7ba193fe229ebf3794f5ab
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a1d23f6e98f1d7c7fe7ba193fe229ebf3794f5ab

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Dec 19 22:52:15 2009 +0100

analogy: improve the test program cmd_read

Like insn_read, cmd_read can now dump data into a file in raw format.
The text display has been prettified (WARNING: so far, it is not
optimized).

---

 src/utils/analogy/cmd_read.c |  132 +-
 1 files changed, 105 insertions(+), 27 deletions(-)

diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c
index b692fad..77ef4f8 100644
--- a/src/utils/analogy/cmd_read.c
+++ b/src/utils/analogy/cmd_read.c
@@ -22,6 +22,7 @@
 
 #include stdio.h
 #include stdlib.h
+#include unistd.h
 #include sys/mman.h
 #include errno.h
 #include getopt.h
@@ -82,6 +83,7 @@ struct option cmd_read_opts[] = {
{scan-count, required_argument, NULL, 'S'},
{channels, required_argument, NULL, 'c'},
{mmap, no_argument, NULL, 'm'},
+   {raw, no_argument, NULL, 'w'},
{help, no_argument, NULL, 'h'},
{0},
 };
@@ -98,9 +100,83 @@ void do_print_usage(void)
fprintf(stdout, \t\t -S, --scan-count: count of scan to perform\n);
fprintf(stdout, \t\t -c, --channels: channels to use (ex.: -c 0,1)\n);
fprintf(stdout, \t\t -m, --mmap: mmap the buffer\n);
+   fprintf(stdout, \t\t -w, --raw: dump data in raw format\n);
fprintf(stdout, \t\t -h, --help: print this help\n);
 }
 
+int dump_raw(a4l_desc_t *dsc, a4l_cmd_t *cmd, unsigned char *buf, int size)
+{
+   return fwrite(buf, size, 1, stdout);
+}
+
+int dump_text(a4l_desc_t *dsc, a4l_cmd_t *cmd, unsigned char *buf, int size)
+{
+   static int cur_chan;
+
+   int i, err = 0, tmp_size = 0;
+   char *fmts[MAX_NB_CHAN];
+   a4l_chinfo_t *chans[MAX_NB_CHAN];
+
+   for (i = 0; i  cmd-nb_chan; i++) {
+   int width;
+
+   err = a4l_get_chinfo(dsc,
+cmd-idx_subd, 
+cmd-chan_descs[i], chans[i]);
+   if (err  0) {
+   fprintf(stderr,
+   cmd_read: a4l_get_chinfo failed (ret=%d)\n,
+   err);
+   goto out;
+   }
+
+   width = a4l_sizeof_chan(chans[i]);
+   if (width  0) {
+   fprintf(stderr,
+   cmd_read: incoherent info for channel %d\n,
+   cmd-chan_descs[i]);
+   err = width;
+   goto out;
+   }
+
+   switch(width) {
+   case 1:
+   fmts[i] = 0x%02x ;
+   break;
+   case 2:
+   fmts[i] = 0x%04x ;
+   break;
+   case 4:
+   default:
+   fmts[i] = 0x%08x ;
+   break;
+   }
+   }
+
+   while (tmp_size  size) {
+   unsigned long value;
+
+   err = a4l_rawtoul(chans[cur_chan], value, buf + tmp_size, 1);
+   if (err  0)
+   goto out;
+
+   fprintf(stdout, fmts[cur_chan], value);
+
+   /* We assume a4l_sizeof_chan() cannot return because
+  we already called it on the very same channel
+  descriptor */
+   tmp_size += a4l_sizeof_chan(chans[cur_chan]);
+   
+   if(++cur_chan == cmd-nb_chan) {
+   fprintf(stdout, \n);
+   cur_chan = 0;
+   }
+   }
+
+out:
+   return err;
+}
+
 int main(int argc, char *argv[])
 {
int ret = 0, len, ofs;
@@ -109,10 +185,13 @@ int main(int argc, char *argv[])
void *map = NULL;
a4l_desc_t dsc = { .sbdata = NULL };
 
+   int (*dump_function) (a4l_desc_t *, a4l_cmd_t*, unsigned char *, int) = 
+   dump_text;
+
/* Compute arguments */
while ((ret = getopt_long(argc,
  argv,
- vrd:s:S:c:mh, cmd_read_opts, NULL)) = 0) {
+ vrd:s:S:c:mwh, cmd_read_opts, NULL)) = 0) {
switch (ret) {
case 'v':
verbose = 1;
@@ -135,6 +214,9 @@ int main(int argc, char *argv[])
case 'm':
use_mmap = 1;
break;
+   case 'w':
+   dump_function = dump_raw;
+   break;
case 'h':
default:
do_print_usage();
@@ -142,6 +224,12 @@ int main(int argc, char *argv[])
}
}
 
+   if (isatty(STDOUT_FILENO) 

[Xenomai-git] Alexis Berlemont : analogy: minor Doxygen change

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: cd23c3279506ac7ed59b6a55b8700760531a7be9
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=cd23c3279506ac7ed59b6a55b8700760531a7be9

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Mon Dec 21 01:40:09 2009 +0100

analogy: minor Doxygen change

Minor change in the Doxygen header of the test program cmd_write.

---

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

diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c
index 9fe536e..2e152ed 100644
--- a/src/utils/analogy/cmd_write.c
+++ b/src/utils/analogy/cmd_write.c
@@ -2,8 +2,8 @@
  * @file
  * Analogy for Linux, output command test program
  *
- * Copyright (C) 1997-2000 David A. Schleef d...@schleef.org
- * Copyright (C) 2008 Alexis Berlemont alexis.berlem...@free.fr
+ * @note Copyright (C) 1997-2000 David A. Schleef d...@schleef.org
+ * @note Copyright (C) 2008 Alexis Berlemont alexis.berlem...@free.fr
  *
  * Xenomai is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by


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


[Xenomai-git] Alexis Berlemont : analogy: fix a first part of the compilation issues when mite is disabled

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: fa18c182b4dd4eca6207da6973713d689d0d6e44
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=fa18c182b4dd4eca6207da6973713d689d0d6e44

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Thu Dec 24 09:35:01 2009 +0100

analogy: fix a first part of the compilation issues when mite is disabled

---

 .../analogy/national_instruments/mio_common.c  |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c 
b/ksrc/drivers/analogy/national_instruments/mio_common.c
index 532d6db..edd8e5a 100644
--- a/ksrc/drivers/analogy/national_instruments/mio_common.c
+++ b/ksrc/drivers/analogy/national_instruments/mio_common.c
@@ -1007,10 +1007,10 @@ int ni_E_interrupt(unsigned int irq, void *d)
 
 static void ni_ao_fifo_load(a4l_subd_t *subd, int n)
 {
-   int i;
+   a4l_dev_t *dev = subd-dev;
sampl_t d;
u32 packed_data;
-   int err = 1;
+   int i, err = 1;
 
for (i = 0; i  n; i++) {
err = a4l_buf_get(subd, d, sizeof(sampl_t));
@@ -1055,6 +1055,7 @@ static void ni_ao_fifo_load(a4l_subd_t *subd, int n)
  */
 static int ni_ao_fifo_half_empty(a4l_subd_t *subd)
 {
+   a4l_dev_t *dev = subd-dev;
int n;
 
n = a4l_buf_count(subd);
@@ -1098,6 +1099,7 @@ static int ni_ao_prep_fifo(a4l_subd_t *subd)
 
 static void ni_ai_fifo_read(a4l_dev_t *subd, int n)
 {
+   a4l_dev_t *dev = subd-dev;
int i;
 
if (boardtype.reg_type == ni_reg_611x) {


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


[Xenomai-git] Alexis Berlemont : analogy: replace EXPORT_SYMBOL() by EXPORT_SYMBOL_GPL()

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 6ce44e3eedb88c7512968e64ecbc47002ba5bc69
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=6ce44e3eedb88c7512968e64ecbc47002ba5bc69

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Thu Dec 24 15:05:04 2009 +0100

analogy: replace EXPORT_SYMBOL() by EXPORT_SYMBOL_GPL()

---

 ksrc/drivers/analogy/driver_facilities.c   |   58 ++--
 ksrc/drivers/analogy/intel/8255.c  |4 +-
 .../analogy/national_instruments/mio_common.c  |   22 
 ksrc/drivers/analogy/national_instruments/mite.c   |   42 +++---
 4 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/ksrc/drivers/analogy/driver_facilities.c 
b/ksrc/drivers/analogy/driver_facilities.c
index b350a46..1008c98 100644
--- a/ksrc/drivers/analogy/driver_facilities.c
+++ b/ksrc/drivers/analogy/driver_facilities.c
@@ -78,7 +78,7 @@
  *
  */
 int a4l_register_drv(a4l_drv_t * drv);
-EXPORT_SYMBOL(a4l_register_drv);
+EXPORT_SYMBOL_GPL(a4l_register_drv);
 
 /**
  * @brief Unregister an Analogy driver
@@ -92,7 +92,7 @@ EXPORT_SYMBOL(a4l_register_drv);
  *
  */
 int a4l_unregister_drv(a4l_drv_t * drv);
-EXPORT_SYMBOL(a4l_unregister_drv);
+EXPORT_SYMBOL_GPL(a4l_unregister_drv);
 
 /** @} */
 
@@ -134,12 +134,12 @@ EXPORT_SYMBOL(a4l_unregister_drv);
  * @{
  */
 
-EXPORT_SYMBOL(range_bipolar10);
-EXPORT_SYMBOL(range_bipolar5);
-EXPORT_SYMBOL(range_unipolar10);
-EXPORT_SYMBOL(range_unipolar5);
-EXPORT_SYMBOL(range_unknown);
-EXPORT_SYMBOL(range_fake);
+EXPORT_SYMBOL_GPL(range_bipolar10);
+EXPORT_SYMBOL_GPL(range_bipolar5);
+EXPORT_SYMBOL_GPL(range_unipolar10);
+EXPORT_SYMBOL_GPL(range_unipolar5);
+EXPORT_SYMBOL_GPL(range_unknown);
+EXPORT_SYMBOL_GPL(range_fake);
 
 /**
  * @brief Allocate a subdevice descriptor
@@ -156,7 +156,7 @@ EXPORT_SYMBOL(range_fake);
  */
 a4l_subd_t * a4l_alloc_subd(int sizeof_priv,
  void (*setup)(a4l_subd_t *));
-EXPORT_SYMBOL(a4l_alloc_subd);
+EXPORT_SYMBOL_GPL(a4l_alloc_subd);
 
 /**
  * @brief Add a subdevice to the driver descriptor
@@ -173,7 +173,7 @@ EXPORT_SYMBOL(a4l_alloc_subd);
  *
  */
 int a4l_add_subd(a4l_dev_t *dev, a4l_subd_t *subd);
-EXPORT_SYMBOL(a4l_add_subd);
+EXPORT_SYMBOL_GPL(a4l_add_subd);
 
 /**
  * @brief Get a pointer to the subdevice descriptor referenced by its
@@ -192,7 +192,7 @@ EXPORT_SYMBOL(a4l_add_subd);
  *
  */
 a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx);
-EXPORT_SYMBOL(a4l_get_subd);
+EXPORT_SYMBOL_GPL(a4l_get_subd);
 
 /** @} */
 
@@ -273,7 +273,7 @@ EXPORT_SYMBOL(a4l_get_subd);
  *
  */
 int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_prepare_absput);
+EXPORT_SYMBOL_GPL(a4l_buf_prepare_absput);
 
 /**
  * @brief Set the absolute count of data which was sent from the
@@ -298,7 +298,7 @@ EXPORT_SYMBOL(a4l_buf_prepare_absput);
  *
  */
 int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_commit_absput);
+EXPORT_SYMBOL_GPL(a4l_buf_commit_absput);
 
 /**
  * @brief Set the count of data which is to be sent to the buffer at
@@ -320,7 +320,7 @@ EXPORT_SYMBOL(a4l_buf_commit_absput);
  *
  */
 int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_prepare_put);
+EXPORT_SYMBOL_GPL(a4l_buf_prepare_put);
 
 /**
  * @brief Set the count of data sent to the buffer during the last
@@ -342,7 +342,7 @@ EXPORT_SYMBOL(a4l_buf_prepare_put);
  *
  */
 int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_commit_put);
+EXPORT_SYMBOL_GPL(a4l_buf_commit_put);
 
 /**
  * @brief Copy some data from the device driver to the buffer
@@ -360,7 +360,7 @@ EXPORT_SYMBOL(a4l_buf_commit_put);
  *
  */
 int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_put);
+EXPORT_SYMBOL_GPL(a4l_buf_put);
 
 /**
  * @brief Update the absolute count of data sent from the buffer to
@@ -385,7 +385,7 @@ EXPORT_SYMBOL(a4l_buf_put);
  *
  */
 int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_prepare_absget);
+EXPORT_SYMBOL_GPL(a4l_buf_prepare_absget);
 
 /**
  * @brief Set the absolute count of data which was sent from the
@@ -410,7 +410,7 @@ EXPORT_SYMBOL(a4l_buf_prepare_absget);
  *
  */
 int a4l_buf_commit_absget(a4l_subd_t *subd, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_commit_absget);
+EXPORT_SYMBOL_GPL(a4l_buf_commit_absget);
 
 /**
  * @brief Set the count of data which is to be sent from the buffer to
@@ -432,7 +432,7 @@ EXPORT_SYMBOL(a4l_buf_commit_absget);
  *
  */
 int a4l_buf_prepare_get(a4l_subd_t *subd, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_prepare_get);
+EXPORT_SYMBOL_GPL(a4l_buf_prepare_get);
 
 /**
  * @brief Set the count of data sent from the buffer to the device
@@ -454,7 +454,7 @@ EXPORT_SYMBOL(a4l_buf_prepare_get);
  *
  */
 int a4l_buf_commit_get(a4l_subd_t *subd, unsigned long count);
-EXPORT_SYMBOL(a4l_buf_commit_get);

[Xenomai-git] Alexis Berlemont : analogy: fix the default writing subdevice.

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: c0b8b050422d920c7e831ba9a73f50100cb97fe1
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=c0b8b050422d920c7e831ba9a73f50100cb97fe1

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Nov 28 15:56:22 2009 +0100

analogy: fix the default writing subdevice.

The subdevice index changed from zero to one (the writing subdevice on
most of the drivers). This is a temporary fix because we are able to
find out the suitable subdevice to use.

---

 src/utils/analogy/insn_write.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/utils/analogy/insn_write.c b/src/utils/analogy/insn_write.c
index 6da24da..d54a5c2 100644
--- a/src/utils/analogy/insn_write.c
+++ b/src/utils/analogy/insn_write.c
@@ -30,16 +30,23 @@
 
 #include analogy/analogy.h
 
+/* For write operation, we consider 
+   the default subdevice index is 1 */
+#define ID_SUBD 1
+
+/* Ten triggered scans by default */
+#define SCAN_CNT 10
+
 #define FILENAME analogy0
+
 #define BUF_SIZE 1
-#define SCAN_CNT 10
 
 static unsigned char buf[BUF_SIZE]= {[0 ... BUF_SIZE - 1] = 0x5a};
 static double dbuf[BUF_SIZE] = {[0 ... BUF_SIZE - 1] = 0};
 static char *filename = FILENAME;
 static int verbose;
 static int real_time;
-static int idx_subd;
+static int idx_subd = ID_SUBD;
 static int idx_chan;
 static int idx_rng = -1;
 static unsigned int scan_size = SCAN_CNT;


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


[Xenomai-git] Alexis Berlemont : analogy: fix bad error handling path in test programs

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: e305035eb6adc4220fe179477f3e300ad944f85c
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=e305035eb6adc4220fe179477f3e300ad944f85c

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Wed Nov 25 13:48:52 2009 +0100

analogy: fix bad error handling path in test programs

---

 src/utils/analogy/cmd_read.c   |5 +++--
 src/utils/analogy/cmd_write.c  |5 +++--
 src/utils/analogy/insn_read.c  |2 +-
 src/utils/analogy/insn_write.c |2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c
index f665ccd..99bdab8 100644
--- a/src/utils/analogy/cmd_read.c
+++ b/src/utils/analogy/cmd_read.c
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
unsigned int i, scan_size = 0, cnt = 0;
unsigned long buf_size;
void *map = NULL;
-   a4l_desc_t dsc;
+   a4l_desc_t dsc = { .sbdata = NULL };
 
/* Compute arguments */
while ((ret = getopt_long(argc,
@@ -411,7 +411,8 @@ out_main:
munmap(map, buf_size);
 
/* Free the buffer used as device descriptor */
-   free(dsc.sbdata);
+   if (dsc.sbdata != NULL)
+   free(dsc.sbdata);
 
/* Release the file descriptor */
a4l_close(dsc);
diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c
index 05b648a..9fe536e 100644
--- a/src/utils/analogy/cmd_write.c
+++ b/src/utils/analogy/cmd_write.c
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
unsigned int i, scan_size = 0, cnt = 0;
unsigned long buf_size;
void *map = NULL;
-   a4l_desc_t dsc;
+   a4l_desc_t dsc = { .sbdata = NULL };
 
/* Compute arguments */
while ((ret = getopt_long(argc,
@@ -405,7 +405,8 @@ int main(int argc, char *argv[])
 out_main:
 
/* Free the buffer used as device descriptor */
-   free(dsc.sbdata);
+   if (dsc.sbdata != NULL)
+   free(dsc.sbdata);
 
/* Release the file descriptor */
a4l_close(dsc);
diff --git a/src/utils/analogy/insn_read.c b/src/utils/analogy/insn_read.c
index f4029be..50f2c98 100644
--- a/src/utils/analogy/insn_read.c
+++ b/src/utils/analogy/insn_read.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
 {
int ret = 0, i;
unsigned int cnt = 0;
-   a4l_desc_t dsc;
+   a4l_desc_t dsc = { .sbdata = NULL };
a4l_chinfo_t *chinfo;
a4l_rnginfo_t *rnginfo;
 
diff --git a/src/utils/analogy/insn_write.c b/src/utils/analogy/insn_write.c
index f5bda70..6da24da 100644
--- a/src/utils/analogy/insn_write.c
+++ b/src/utils/analogy/insn_write.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
 {
int ret = 0;
unsigned int cnt = 0;
-   a4l_desc_t dsc;
+   a4l_desc_t dsc = { .sbdata = NULL };
a4l_chinfo_t *chinfo;
a4l_rnginfo_t *rnginfo;
 


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


[Xenomai-git] Alexis Berlemont : analogy: properly manage cancel operations on synchronous subdevices

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 30f6b6f4439847f1f9ec01431cbed057eafe5787
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=30f6b6f4439847f1f9ec01431cbed057eafe5787

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Mon Dec  7 00:12:40 2009 +0100

analogy: properly manage cancel operations on synchronous subdevices

---

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

diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c
index c6306d9..598cb9e 100644
--- a/ksrc/drivers/analogy/transfer.c
+++ b/ksrc/drivers/analogy/transfer.c
@@ -286,9 +286,10 @@ int a4l_cancel_transfer(a4l_cxt_t * cxt, int idx_subd)
clear_bit(A4L_TSF_BUSY, (dev-transfer.status[idx_subd]));
 
/* If the subdevice is command capable and 
-  if there is a command is under progress, 
+  if a command is under progress, 
   disable it and free it... */
if (dev-transfer.bufs != NULL 
+   dev-transfer.bufs[idx_subd] != NULL 
dev-transfer.bufs[idx_subd]-cur_cmd != NULL) {
 
a4l_free_cmddesc(dev-transfer.bufs[idx_subd]-cur_cmd);


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


[Xenomai-git] Alexis Berlemont : analogy: fix wrong names of conversion functions

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 65ed1492fb89eed23fe9b023fe57da6c34864633
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=65ed1492fb89eed23fe9b023fe57da6c34864633

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Wed Dec  9 22:40:30 2009 +0100

analogy: fix wrong names of conversion functions

---

 include/analogy/analogy.h |   10 --
 src/drvlib/analogy/range.c|   14 +++---
 src/utils/analogy/insn_read.c |2 +-
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/include/analogy/analogy.h b/include/analogy/analogy.h
index 8d11047..21c7e59 100644
--- a/include/analogy/analogy.h
+++ b/include/analogy/analogy.h
@@ -136,13 +136,11 @@ int a4l_find_range(a4l_desc_t * dsc,
   unsigned long unit,
   double min, double max, a4l_rnginfo_t ** rng);
 
-int a4l_to_phys(a4l_chinfo_t * chan,
-   a4l_rnginfo_t * rng, double *dst, void *src,
-   int cnt);
-
 int a4l_from_phys(a4l_chinfo_t * chan,
- a4l_rnginfo_t * rng, void *dst, double *src,
- int cnt);
+ a4l_rnginfo_t * rng, double *dst, void *src, int cnt);
+
+int a4l_to_phys(a4l_chinfo_t * chan,
+   a4l_rnginfo_t * rng, void *dst, double *src, int cnt);
 
 #endif /* !DOXYGEN_CPP */
 
diff --git a/src/drvlib/analogy/range.c b/src/drvlib/analogy/range.c
index ab41f1e..72293b9 100644
--- a/src/drvlib/analogy/range.c
+++ b/src/drvlib/analogy/range.c
@@ -143,7 +143,7 @@ out_get_range:
 }
 
 /**
- * @brief Convert samples to physical units
+ * @brief Convert physical units to samples
  *
  * @param[in] chan Channel descriptor
  * @param[in] rng Range descriptor
@@ -160,8 +160,8 @@ out_get_range:
  *before using a4l_to_phys()
  *
  */
-int a4l_to_phys(a4l_chinfo_t * chan,
-   a4l_rnginfo_t * rng, double *dst, void *src, int cnt)
+int a4l_from_phys(a4l_chinfo_t * chan,
+ a4l_rnginfo_t * rng, double *dst, void *src, int cnt)
 {
int i = 0, j = 0;
lsampl_t tmp;
@@ -197,7 +197,7 @@ int a4l_to_phys(a4l_chinfo_t * chan,
(((1ULL  chan-nb_bits) - 1) * A4L_RNG_FACTOR);
b = (double)rng-min / A4L_RNG_FACTOR;
 
-   while (i  cnt) {
+   while (j  cnt) {
 
/* Properly retrieves the data */
tmp = datax_get(src + i);
@@ -214,7 +214,7 @@ int a4l_to_phys(a4l_chinfo_t * chan,
 }
 
 /**
- * @brief Convert physical units to samples
+ * @brief Convert samples to physical units
  *
  * @param[in] chan Channel descriptor
  * @param[in] rng Range descriptor
@@ -231,7 +231,7 @@ int a4l_to_phys(a4l_chinfo_t * chan,
  *before using a4l_from_phys()
  *
  */
-int a4l_from_phys(a4l_chinfo_t * chan,
+int a4l_to_phys(a4l_chinfo_t * chan,
  a4l_rnginfo_t * rng, void *dst, double *src, int cnt)
 {
int i = 0, j = 0;
@@ -268,7 +268,7 @@ int a4l_from_phys(a4l_chinfo_t * chan,
b = ((double)(rng-min) / (rng-max - rng-min)) *
((1ULL  chan-nb_bits) - 1);
 
-   while (i  cnt) {
+   while (j  cnt) {
 
/* Performs the conversion */
datax_set(dst + i, (lsampl_t) (a * src[j] - b));
diff --git a/src/utils/analogy/insn_read.c b/src/utils/analogy/insn_read.c
index 50f2c98..d5e025d 100644
--- a/src/utils/analogy/insn_read.c
+++ b/src/utils/analogy/insn_read.c
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
 
/* If a range was selected, converts the samples */
if (idx_rng = 0) {
-   if (a4l_to_phys(chinfo, rnginfo, dbuf, buf, ret)  0) {
+   if (a4l_from_phys(chinfo, rnginfo, dbuf, buf, ret)  0) 
{
fprintf(stderr,
insn_read: data conversion failed 
(ret=%d)\n,
ret);


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


[Xenomai-git] Alexis Berlemont : analogy: add a simple helper function

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 2c8eb888d943bcbc2498bfc6d55771b139a4a4cd
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=2c8eb888d943bcbc2498bfc6d55771b139a4a4cd

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Tue Dec 15 15:25:54 2009 +0100

analogy: add a simple helper function 

The added function displays the size taken in memory for an element
acquired from (/ sent to) a specific channel.

---

 include/analogy/analogy.h  |4 +++-
 src/drvlib/analogy/range.c |   34 +-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/include/analogy/analogy.h b/include/analogy/analogy.h
index 21c7e59..79bd69c 100644
--- a/include/analogy/analogy.h
+++ b/include/analogy/analogy.h
@@ -129,7 +129,9 @@ int a4l_sync_read(a4l_desc_t * dsc,
  unsigned int idx_subd,
  unsigned int chan_desc,
  unsigned int delay, void *buf, size_t nbyte);
-   
+
+int a4l_sizeof_chan(a4l_chinfo_t * chan);
+
 int a4l_find_range(a4l_desc_t * dsc,
   unsigned int idx_subd,
   unsigned int idx_chan,
diff --git a/src/drvlib/analogy/range.c b/src/drvlib/analogy/range.c
index 1965e57..05615bd 100644
--- a/src/drvlib/analogy/range.c
+++ b/src/drvlib/analogy/range.c
@@ -66,6 +66,38 @@ void data8_set(void *dst, lsampl_t val)
  */
 
 /**
+ * @brief Get the size in memory of an acquired element
+ *
+ * According to the board, the channels have various acquisition
+ * widths. With values like 8, 16 or 32, there is no problem finding
+ * out the size in memory (1, 2, 4); however with widths like 12 or
+ * 24, this function might be helpful to guess the size needed in RAM
+ * for a single acquired element.
+ *
+ * @param[in] chan Channel descriptor
+ *
+ * @return the size in memory of an acquired element, otherwise a negative
+ * error code:
+ *
+ * - -EINVAL is returned if the argument chan is NULL
+ *
+ */
+int a4l_sizeof_chan(a4l_chinfo_t * chan)
+{
+   /* So far, it seems there is no 64 bit acquistion stuff */
+   int i = 0, sizes[3] = {8, 16, 32};
+
+   if (chan == NULL)
+   return -EINVAL;
+
+   while (i  3  sizes[i]  chan-nb_bits)
+   i++;
+
+   return (i == 3) ? -EINVAL : sizes[i] / 8;
+}
+
+
+/**
  * @brief Find the must suitable range
  *
  * @param[in] dsc Device descriptor filled by a4l_open() and
@@ -241,7 +273,7 @@ int a4l_from_phys(a4l_chinfo_t * chan,
  *
  */
 int a4l_to_phys(a4l_chinfo_t * chan,
- a4l_rnginfo_t * rng, void *dst, double *src, int cnt)
+   a4l_rnginfo_t * rng, void *dst, double *src, int cnt)
 {
int i = 0, j = 0;
 


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


[Xenomai-git] Alexis Berlemont : analogy: minor change in the driver description

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 555e67b1d308b7fe729788d55aa9b8f284769435
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=555e67b1d308b7fe729788d55aa9b8f284769435

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sun Dec 13 23:29:20 2009 +0100

analogy: minor change in the driver description

---

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

diff --git a/ksrc/drivers/analogy/intel/parport.c 
b/ksrc/drivers/analogy/intel/parport.c
index 72b25c5..aca04ce 100644
--- a/ksrc/drivers/analogy/intel/parport.c
+++ b/ksrc/drivers/analogy/intel/parport.c
@@ -23,7 +23,7 @@
additional parallel ports from old computers or your neighbors'
computers.
 
-   Option list:
+   Attach options list:
0: I/O port base for the parallel port.
1: IRQ
 


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


[Xenomai-git] Alexis Berlemont : analogy: fix Doxygen documentation (a4l_sync_read, a4l_sync_write)

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 86a3e25b256c79c0fe44b462a29bb5e3af672fc0
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=86a3e25b256c79c0fe44b462a29bb5e3af672fc0

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Dec 19 20:47:39 2009 +0100

analogy: fix Doxygen documentation (a4l_sync_read, a4l_sync_write)

---

 src/drvlib/analogy/sync.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/drvlib/analogy/sync.c b/src/drvlib/analogy/sync.c
index 55d56d3..1a4b007 100644
--- a/src/drvlib/analogy/sync.c
+++ b/src/drvlib/analogy/sync.c
@@ -121,7 +121,7 @@ int a4l_snd_insn(a4l_desc_t * dsc, a4l_insn_t * arg)
  * @param[in] buf Output buffer
  * @param[in] nbyte Number of bytes to write
  *
- * @return 0 on success. Otherwise:
+ * @return Number of bytes written, otherwise negative error code:
  *
  * - -EINVAL is returned if some argument is missing or wrong (Please,
  *type dmesg for more info)
@@ -194,7 +194,7 @@ int a4l_sync_write(a4l_desc_t * dsc,
  * @param[in] buf Input buffer
  * @param[in] nbyte Number of bytes to read
  *
- * @return 0 on success. Otherwise:
+ * @return Number of bytes read, otherwise negative error code:
  *
  * - -EINVAL is returned if some argument is missing or wrong (Please,
  *type dmesg for more info)


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


[Xenomai-git] Alexis Berlemont : analogy: slight change in a kernel error message

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 32f17d302a0d9fc929247afb7b5d2ba292a991c9
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=32f17d302a0d9fc929247afb7b5d2ba292a991c9

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Dec 19 20:44:14 2009 +0100

analogy: slight change in a kernel error message

---

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

diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c
index e227b97..509d73d 100644
--- a/ksrc/drivers/analogy/command.c
+++ b/ksrc/drivers/analogy/command.c
@@ -98,8 +98,8 @@ int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc)
 
if (desc-idx_subd = dev-transfer.nb_subd) {
__a4l_err(a4l_check_cmddesc: 
- subdevice index out of range (%u = %u)\n,
- desc-idx_subd, dev-transfer.nb_subd);
+ subdevice index out of range (idx=%u)\n,
+ desc-idx_subd);
return -EINVAL;
}
 


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


[Xenomai-git] Alexis Berlemont : analogy: improve the test program cmd_read

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: a1d23f6e98f1d7c7fe7ba193fe229ebf3794f5ab
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=a1d23f6e98f1d7c7fe7ba193fe229ebf3794f5ab

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Dec 19 22:52:15 2009 +0100

analogy: improve the test program cmd_read

Like insn_read, cmd_read can now dump data into a file in raw format.
The text display has been prettified (WARNING: so far, it is not
optimized).

---

 src/utils/analogy/cmd_read.c |  132 +-
 1 files changed, 105 insertions(+), 27 deletions(-)

diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c
index b692fad..77ef4f8 100644
--- a/src/utils/analogy/cmd_read.c
+++ b/src/utils/analogy/cmd_read.c
@@ -22,6 +22,7 @@
 
 #include stdio.h
 #include stdlib.h
+#include unistd.h
 #include sys/mman.h
 #include errno.h
 #include getopt.h
@@ -82,6 +83,7 @@ struct option cmd_read_opts[] = {
{scan-count, required_argument, NULL, 'S'},
{channels, required_argument, NULL, 'c'},
{mmap, no_argument, NULL, 'm'},
+   {raw, no_argument, NULL, 'w'},
{help, no_argument, NULL, 'h'},
{0},
 };
@@ -98,9 +100,83 @@ void do_print_usage(void)
fprintf(stdout, \t\t -S, --scan-count: count of scan to perform\n);
fprintf(stdout, \t\t -c, --channels: channels to use (ex.: -c 0,1)\n);
fprintf(stdout, \t\t -m, --mmap: mmap the buffer\n);
+   fprintf(stdout, \t\t -w, --raw: dump data in raw format\n);
fprintf(stdout, \t\t -h, --help: print this help\n);
 }
 
+int dump_raw(a4l_desc_t *dsc, a4l_cmd_t *cmd, unsigned char *buf, int size)
+{
+   return fwrite(buf, size, 1, stdout);
+}
+
+int dump_text(a4l_desc_t *dsc, a4l_cmd_t *cmd, unsigned char *buf, int size)
+{
+   static int cur_chan;
+
+   int i, err = 0, tmp_size = 0;
+   char *fmts[MAX_NB_CHAN];
+   a4l_chinfo_t *chans[MAX_NB_CHAN];
+
+   for (i = 0; i  cmd-nb_chan; i++) {
+   int width;
+
+   err = a4l_get_chinfo(dsc,
+cmd-idx_subd, 
+cmd-chan_descs[i], chans[i]);
+   if (err  0) {
+   fprintf(stderr,
+   cmd_read: a4l_get_chinfo failed (ret=%d)\n,
+   err);
+   goto out;
+   }
+
+   width = a4l_sizeof_chan(chans[i]);
+   if (width  0) {
+   fprintf(stderr,
+   cmd_read: incoherent info for channel %d\n,
+   cmd-chan_descs[i]);
+   err = width;
+   goto out;
+   }
+
+   switch(width) {
+   case 1:
+   fmts[i] = 0x%02x ;
+   break;
+   case 2:
+   fmts[i] = 0x%04x ;
+   break;
+   case 4:
+   default:
+   fmts[i] = 0x%08x ;
+   break;
+   }
+   }
+
+   while (tmp_size  size) {
+   unsigned long value;
+
+   err = a4l_rawtoul(chans[cur_chan], value, buf + tmp_size, 1);
+   if (err  0)
+   goto out;
+
+   fprintf(stdout, fmts[cur_chan], value);
+
+   /* We assume a4l_sizeof_chan() cannot return because
+  we already called it on the very same channel
+  descriptor */
+   tmp_size += a4l_sizeof_chan(chans[cur_chan]);
+   
+   if(++cur_chan == cmd-nb_chan) {
+   fprintf(stdout, \n);
+   cur_chan = 0;
+   }
+   }
+
+out:
+   return err;
+}
+
 int main(int argc, char *argv[])
 {
int ret = 0, len, ofs;
@@ -109,10 +185,13 @@ int main(int argc, char *argv[])
void *map = NULL;
a4l_desc_t dsc = { .sbdata = NULL };
 
+   int (*dump_function) (a4l_desc_t *, a4l_cmd_t*, unsigned char *, int) = 
+   dump_text;
+
/* Compute arguments */
while ((ret = getopt_long(argc,
  argv,
- vrd:s:S:c:mh, cmd_read_opts, NULL)) = 0) {
+ vrd:s:S:c:mwh, cmd_read_opts, NULL)) = 0) {
switch (ret) {
case 'v':
verbose = 1;
@@ -135,6 +214,9 @@ int main(int argc, char *argv[])
case 'm':
use_mmap = 1;
break;
+   case 'w':
+   dump_function = dump_raw;
+   break;
case 'h':
default:
do_print_usage();
@@ -142,6 +224,12 @@ int main(int argc, char *argv[])
}
}
 
+   if 

[Xenomai-git] Alexis Berlemont : analogy: minor Doxygen change

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: cd23c3279506ac7ed59b6a55b8700760531a7be9
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=cd23c3279506ac7ed59b6a55b8700760531a7be9

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Mon Dec 21 01:40:09 2009 +0100

analogy: minor Doxygen change

Minor change in the Doxygen header of the test program cmd_write.

---

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

diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c
index 9fe536e..2e152ed 100644
--- a/src/utils/analogy/cmd_write.c
+++ b/src/utils/analogy/cmd_write.c
@@ -2,8 +2,8 @@
  * @file
  * Analogy for Linux, output command test program
  *
- * Copyright (C) 1997-2000 David A. Schleef d...@schleef.org
- * Copyright (C) 2008 Alexis Berlemont alexis.berlem...@free.fr
+ * @note Copyright (C) 1997-2000 David A. Schleef d...@schleef.org
+ * @note Copyright (C) 2008 Alexis Berlemont alexis.berlem...@free.fr
  *
  * Xenomai is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by


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


[Xenomai-git] Alexis Berlemont : analogy: fix wrong use of the type unsigned long long in time retrieval

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 9431818fd4f0641e8176137c0b44cdc3efcb4109
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=9431818fd4f0641e8176137c0b44cdc3efcb4109

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Wed Dec 23 00:21:18 2009 +0100

analogy: fix wrong use of the type unsigned long long in time retrieval

---

 include/analogy/os_facilities.h  |4 ++--
 ksrc/drivers/analogy/instruction.c   |   14 +-
 ksrc/drivers/analogy/os_facilities.c |   10 +-
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/include/analogy/os_facilities.h b/include/analogy/os_facilities.h
index 2d882e2..efaacbd 100644
--- a/include/analogy/os_facilities.h
+++ b/include/analogy/os_facilities.h
@@ -123,13 +123,13 @@ static inline void a4l_udelay(unsigned int us)
rtdm_task_busy_sleep(((nanosecs_rel_t) us) * 1000);
 }
 
-static inline unsigned long long a4l_get_rawtime(void)
+static inline nanosecs_abs_t a4l_get_rawtime(void)
 {
return rtdm_clock_read();
 }
 
 /* Function which gives absolute time */
-unsigned long long a4l_get_time(void);
+nanosecs_abs_t a4l_get_time(void);
 
 /* Function for setting up the absolute time recovery */
 void a4l_init_time(void);
diff --git a/ksrc/drivers/analogy/instruction.c 
b/ksrc/drivers/analogy/instruction.c
index 5ecb366..a2fb4ce 100644
--- a/ksrc/drivers/analogy/instruction.c
+++ b/ksrc/drivers/analogy/instruction.c
@@ -35,20 +35,24 @@
 
 int a4l_do_insn_gettime(a4l_kinsn_t * dsc)
 {
-   unsigned long long ns;
-   unsigned long ns2;
+   nanosecs_abs_t ns;
+   uint32_t ns2;
+
+   uint32_t *data = (uint32_t *)dsc-data;
 
/* Basic checkings */
-   if (dsc-data_size != 2) {
+   if (dsc-data_size != 2 * sizeof(uint32_t)) {
__a4l_err(a4l_do_insn_gettime: data size should be 2\n);
return -EINVAL;
}
 
+   /* Get a timestamp */
ns = a4l_get_time();
 
+   /* Perform the conversion */
ns2 = do_div(ns, 10);
-   dsc-data[0] = (lsampl_t) ns;
-   dsc-data[1] = (lsampl_t) ns2 / 1000;
+   data[0] = (uint32_t) ns;
+   data[1] = (uint32_t) ns2 / 1000;
 
return 0;
 }
diff --git a/ksrc/drivers/analogy/os_facilities.c 
b/ksrc/drivers/analogy/os_facilities.c
index 1b6c554..620906e 100644
--- a/ksrc/drivers/analogy/os_facilities.c
+++ b/ksrc/drivers/analogy/os_facilities.c
@@ -31,20 +31,20 @@
 
 /* --- Time section --- */
 
-static unsigned long long a4l_clkofs;
+static nanosecs_abs_t a4l_clkofs;
 
 void a4l_init_time(void)
 {
-   unsigned long long t1, t2;
+   nanosecs_abs_t t1, t2;
struct timeval tv;
t1 = a4l_get_rawtime();
do_gettimeofday(tv);
-   t2 = 10 * ((unsigned long long)tv.tv_sec) +
-   100 * ((unsigned long long)tv.tv_usec);
+   t2 = 10 * ((nanosecs_abs_t)tv.tv_sec) +
+   100 * ((nanosecs_abs_t)tv.tv_usec);
a4l_clkofs = t2 - t1;
 }
 
-unsigned long long a4l_get_time(void)
+nanosecs_abs_t a4l_get_time(void)
 {
return a4l_clkofs + a4l_get_rawtime();
 }


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


[Xenomai-git] Alexis Berlemont : analogy: fix a bug in the user/ kernel copy of the instruction's data

2009-12-25 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 64dda2abf9650aea4a782ab5b932b60ea72a7470
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=64dda2abf9650aea4a782ab5b932b60ea72a7470

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Thu Dec 24 09:24:32 2009 +0100

analogy: fix a bug in the user/kernel copy of the instruction's data

libanalogy allows the user application to find out the bit width of
any channel; however, the instruction structure, which is the
synchronous interface between user and kernel space, used by default
unsigned int typed values to send data. This issue was fixed.

---

 include/analogy/instruction.h  |6 +-
 ksrc/drivers/analogy/instruction.c |   20 +-
 ksrc/drivers/analogy/intel/8255.c  |   24 +-
 ksrc/drivers/analogy/intel/parport.c   |   36 ++-
 .../analogy/national_instruments/mio_common.c  |  360 
 ksrc/drivers/analogy/national_instruments/pcimio.c |2 +
 .../analogy/national_instruments/tio_common.c  |   74 +++--
 ksrc/drivers/analogy/testing/fake.c|   19 +-
 ksrc/drivers/analogy/testing/loop.c|   18 +-
 9 files changed, 322 insertions(+), 237 deletions(-)

diff --git a/include/analogy/instruction.h b/include/analogy/instruction.h
index b1564d7..fb902cb 100644
--- a/include/analogy/instruction.h
+++ b/include/analogy/instruction.h
@@ -175,7 +175,7 @@ struct a4l_instruction {
/** Channel descriptor */
unsigned int data_size;
/** Size of the intruction data */
-   lsampl_t *data;
+   void *data;
/** Instruction data */
 };
 typedef struct a4l_instruction a4l_insn_t;
@@ -202,8 +202,8 @@ struct a4l_kernel_instruction {
unsigned int idx_subd;
unsigned int chan_desc;
unsigned int data_size;
-   lsampl_t *data;
-   lsampl_t *__udata;
+   void *data;
+   void *__udata;
 };
 typedef struct a4l_kernel_instruction a4l_kinsn_t;
 
diff --git a/ksrc/drivers/analogy/instruction.c 
b/ksrc/drivers/analogy/instruction.c
index a2fb4ce..ed56367 100644
--- a/ksrc/drivers/analogy/instruction.c
+++ b/ksrc/drivers/analogy/instruction.c
@@ -38,10 +38,10 @@ int a4l_do_insn_gettime(a4l_kinsn_t * dsc)
nanosecs_abs_t ns;
uint32_t ns2;
 
-   uint32_t *data = (uint32_t *)dsc-data;
+   unsigned int *data = (unsigned int *)dsc-data;
 
/* Basic checkings */
-   if (dsc-data_size != 2 * sizeof(uint32_t)) {
+   if (dsc-data_size != 2 * sizeof(unsigned int)) {
__a4l_err(a4l_do_insn_gettime: data size should be 2\n);
return -EINVAL;
}
@@ -51,8 +51,8 @@ int a4l_do_insn_gettime(a4l_kinsn_t * dsc)
 
/* Perform the conversion */
ns2 = do_div(ns, 10);
-   data[0] = (uint32_t) ns;
-   data[1] = (uint32_t) ns2 / 1000;
+   data[0] = (unsigned int) ns;
+   data[1] = (unsigned int) ns2 / 1000;
 
return 0;
 }
@@ -60,21 +60,22 @@ int a4l_do_insn_gettime(a4l_kinsn_t * dsc)
 int a4l_do_insn_wait(a4l_kinsn_t * dsc)
 {
unsigned int us;
+   unsigned int *data = (unsigned int *)dsc-data;
 
/* Basic checkings */
-   if (dsc-data_size != 1) {
+   if (dsc-data_size != sizeof(unsigned int)) {
__a4l_err(a4l_do_insn_wait: data size should be 1\n);
return -EINVAL;
}
 
-   if (dsc-data[0]  A4L_INSN_WAIT_MAX) {
+   if (data[0]  A4L_INSN_WAIT_MAX) {
__a4l_err(a4l_do_insn_wait: wait duration is out of range\n);
return -EINVAL;
}
 
/* As we use (a4l_)udelay, we have to convert the delay into
   microseconds */
-   us = dsc-data[0] / 1000;
+   us = data[0] / 1000;
 
/* At least, the delay is rounded up to 1 microsecond */
if (us == 0)
@@ -90,7 +91,8 @@ int a4l_do_insn_trig(a4l_cxt_t * cxt, a4l_kinsn_t * dsc)
 {
a4l_subd_t *subd;
a4l_dev_t *dev = a4l_get_dev(cxt);
-   lsampl_t trignum;
+   unsigned int trignum;
+   unsigned int *data = (unsigned int*)dsc-data;
 
/* Basic checkings */
if (dsc-data_size  1) {
@@ -98,7 +100,7 @@ int a4l_do_insn_trig(a4l_cxt_t * cxt, a4l_kinsn_t * dsc)
return -EINVAL;
}

-   trignum = (dsc-data_size == 1) ? dsc-data[0] : 0;
+   trignum = (dsc-data_size == sizeof(unsigned int)) ? data[0] : 0;

if (dsc-idx_subd = dev-transfer.nb_subd) {
__a4l_err(a4l_do_insn_trig: 
diff --git a/ksrc/drivers/analogy/intel/8255.c 
b/ksrc/drivers/analogy/intel/8255.c
index cf369bb..c43df78 100644
--- a/ksrc/drivers/analogy/intel/8255.c
+++ b/ksrc/drivers/analogy/intel/8255.c
@@ -132,28 +132,29 @@ int subd_8255_cancel(a4l_subd_t *subd)
 int subd_8255_insn_bits(a4l_subd_t *subd, a4l_kinsn_t *insn)
 {
subd_8255_t *subd_8255 = (subd_8255_t *)subd-priv;
+   

[Xenomai-git] Alexis Berlemont : analogy: make the MITE option depends on the PCI option

2009-12-25 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: eecb6ee65712a8b412be455344f84fc13ced555b
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=eecb6ee65712a8b412be455344f84fc13ced555b

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Dec 26 00:47:31 2009 +0100

analogy: make the MITE option depends on the PCI option

---

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

diff --git a/ksrc/drivers/analogy/national_instruments/Kconfig 
b/ksrc/drivers/analogy/national_instruments/Kconfig
index ec3fce4..0e142b7 100644
--- a/ksrc/drivers/analogy/national_instruments/Kconfig
+++ b/ksrc/drivers/analogy/national_instruments/Kconfig
@@ -1,6 +1,6 @@
 
 config XENO_DRIVERS_ANALOGY_NI_MITE
-   depends on XENO_DRIVERS_ANALOGY
+   depends on XENO_DRIVERS_ANALOGY  PCI
tristate NI MITE driver
default n
 


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