[Xenomai-git] Alexis Berlemont : analogy: fix compilation warnings with gcc-4.4.1

2010-09-20 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 06ee0ab5d339ec13476199bea841312660c45a44
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=06ee0ab5d339ec13476199bea841312660c45a44

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Mon Sep 20 11:36:34 2010 +0200

analogy: fix compilation warnings with gcc-4.4.1

---

 src/drvlib/analogy/sync.c |   44 ++--
 src/utils/analogy/insn_bits.c |9 ++-
 2 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/src/drvlib/analogy/sync.c b/src/drvlib/analogy/sync.c
index 4bcde62..d7c8ba9 100644
--- a/src/drvlib/analogy/sync.c
+++ b/src/drvlib/analogy/sync.c
@@ -296,21 +296,27 @@ int a4l_sync_dio(a4l_desc_t *dsc,
size = a4l_sizeof_subd(subd);
 
switch(size) {
-   case 4:
-   ((uint32_t *)values)[0] = *((uint32_t *)mask);
-   ((uint32_t *)values)[1] = *((uint32_t *)buf);
+   case sizeof(uint32_t): {
+   uint32_t *tmp = (uint32_t *)values;
+   tmp[0] = *((uint32_t *)mask);
+   tmp[1] = *((uint32_t *)buf);
insn.data_size = 2 * sizeof(uint32_t);
break;
-   case 2: 
-   ((uint16_t *)values)[0] = *((uint16_t *)mask);
-   ((uint16_t *)values)[1] = *((uint16_t *)buf);
+   }
+   case sizeof(uint16_t): {
+   uint16_t *tmp = (uint16_t *)values;
+   tmp[0] = *((uint16_t *)mask);
+   tmp[1] = *((uint16_t *)buf);
insn.data_size = 2 * sizeof(uint16_t);
break;
-   case 1: 
-   ((uint8_t *)values)[0] = *((uint8_t *)mask);
-   ((uint8_t *)values)[1] = *((uint8_t *)buf);
+   }
+   case sizeof(uint8_t): {
+   uint8_t *tmp = (uint8_t *)values;
+   tmp[0] = *((uint8_t *)mask);
+   tmp[1] = *((uint8_t *)buf);
insn.data_size = 2 * sizeof(uint8_t);
break;
+   }
default:
return -EINVAL;
}
@@ -320,16 +326,22 @@ int a4l_sync_dio(a4l_desc_t *dsc,
 
/* Update the buffer if need be */
switch(size) {
-   case 4:
-   *((uint32_t *)buf) = ((uint32_t *)values)[1];
+   case sizeof(uint32_t): {
+   uint32_t *tmp = (uint32_t *)buf;
+   *tmp = ((uint32_t *)values)[1];
break;
-   case 2: 
-   *((uint16_t *)buf) = ((uint16_t *)values)[1];
+   }
+   case sizeof(uint16_t): {
+   uint16_t *tmp = (uint16_t *)buf;
+   *tmp = ((uint16_t *)values)[1];
break;
-   case 1: 
-   *((uint8_t *)buf) = ((uint8_t *)values)[1];
+   }
+   case sizeof(uint8_t): {
+   uint8_t *tmp = (uint8_t *)buf;
+   *tmp = ((uint8_t *)values)[1];
break;
-   }   
+   }
+   }

return ret;
 }
diff --git a/src/utils/analogy/insn_bits.c b/src/utils/analogy/insn_bits.c
index 192f897..eb7e43a 100644
--- a/src/utils/analogy/insn_bits.c
+++ b/src/utils/analogy/insn_bits.c
@@ -26,6 +26,7 @@
 #include sys/mman.h
 #include errno.h
 #include getopt.h
+#include string.h
 
 #include analogy/analogy.h
 
@@ -200,10 +201,14 @@ int main(int argc, char *argv[])
}
 
if (scan_size == sizeof(uint8_t)) {
-   value = *((uint8_t *)value);
+   uint8_t tmp;
+   memcpy(tmp, value, sizeof(uint8_t));
+   value = (int)tmp;
}
else if (scan_size == sizeof(uint16_t)) {
-   value = *((uint16_t *)value);
+   uint16_t tmp;
+   memcpy(tmp, value, sizeof(uint16_t)); 
+   value = (int)tmp;
}
 
if ((sbinfo-flags  A4L_SUBD_TYPES) != A4L_SUBD_DO)


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


[Xenomai-git] Alexis Berlemont : analogy: add comments in the buffer management code

2010-09-20 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: ab1559329229069ba7eb2dcf859b76dd16a4d738
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=ab1559329229069ba7eb2dcf859b76dd16a4d738

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Wed Jul 21 00:22:46 2010 +0200

analogy: add comments in the buffer management code

---

 include/analogy/buffer.h  |   52 
 ksrc/drivers/analogy/buffer.c |   23 +-
 2 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h
index 9e5ae8a..b5be3f0 100644
--- a/include/analogy/buffer.h
+++ b/include/analogy/buffer.h
@@ -90,9 +90,12 @@ struct a4l_buffer {
 };
 typedef struct a4l_buffer a4l_buf_t;
 
-/* Static inline Buffer related functions */
+/* --- Static inline functions related with 
+   user-kernel data transfers --- */
 
-/* Produce memcpy function */
+/* The function __produce is an inline function which copies data into
+   the asynchronous buffer and takes care of the non-contiguous issue
+   when looping. This function is used in read and write operations */
 static inline int __produce(a4l_cxt_t *cxt,
a4l_buf_t *buf, void *pin, unsigned long count)
 {
@@ -122,7 +125,9 @@ static inline int __produce(a4l_cxt_t *cxt,
return ret;
 }
 
-/* Consume memcpy function */
+/* The function __consume is an inline function which copies data from
+   the asynchronous buffer and takes care of the non-contiguous issue
+   when looping. This function is used in read and write operations */
 static inline int __consume(a4l_cxt_t *cxt,
a4l_buf_t *buf, void *pout, unsigned long count)
 {
@@ -153,7 +158,9 @@ static inline int __consume(a4l_cxt_t *cxt,
return ret;
 }
 
-/* Munge procedure */
+/* The function __munge is an inline function which calls the
+   subdevice specific munge callback on contiguous windows within the
+   whole buffer. This function is used in read and write operations */
 static inline void __munge(struct a4l_subdevice * subd,
   void (*munge) (struct a4l_subdevice *, 
  void *, unsigned long),
@@ -176,7 +183,9 @@ static inline void __munge(struct a4l_subdevice * subd,
}
 }
 
-/* Event consumption function */
+/* The function __handle_event can only be called from process context
+   (not interrupt service routine). It allows the client process to
+   retrieve the buffer status which has been updated by the driver */
 static inline int __handle_event(a4l_buf_t * buf)
 {
int ret = 0;
@@ -194,7 +203,38 @@ static inline int __handle_event(a4l_buf_t * buf)
return ret;
 }
 
-/* Counters management functions */
+/* --- Counters management functions --- */
+
+/* Here, we may wonder why we need more than two counters / pointers.
+
+   Theoretically, we only need two counters (or two pointers):
+   - one which tells where the reader should be within the buffer
+   - one which tells where the writer should be within the buffer
+
+   With these two counters (or pointers), we just have to check that
+   the writer does not overtake the reader inside the ring buffer
+   BEFORE any read / write operations.
+
+   However, if one element is a DMA controller, we have to be more
+   careful. Generally a DMA transfer occurs like this:
+   DMA shot 
+  |- then DMA interrupt 
+ |- then DMA soft handler which checks the counter
+
+   So, the checkings occur AFTER the write operations.
+
+   Let's take an example: the reader is a software task and the writer
+   is a DMA controller. At the end of the DMA shot, the write counter
+   is higher than the read counter. Unfortunately, a read operation
+   occurs between the DMA shot and the DMA interrupt, so the handler
+   will not notice that an overflow occured.
+
+   That is why tmp_count comes into play: tmp_count records the
+   read/consumer current counter before the next DMA shot and once the
+   next DMA shot is done, we check that the updated writer/producer
+   counter is not higher than tmp_count. Thus we are sure that the DMA
+   writer has not overtaken the reader because it was not able to
+   overtake the n-1 value. */
 
 static inline int __pre_abs_put(a4l_buf_t * buf, unsigned long count)
 {
diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c
index f9bcad7..8bd7d38 100644
--- a/ksrc/drivers/analogy/buffer.c
+++ b/ksrc/drivers/analogy/buffer.c
@@ -35,7 +35,11 @@
 
 /* --- Initialization functions (init, alloc, free) --- */
 
-void a4l_free_buffer(a4l_buf_t *buf_desc)
+/* The buffer charactistic is very close to the Comedi one: it is
+   allocated with vmalloc() and all physical addresses of the pages which
+   compose the virtual buffer are hold in a table */
+
+void a4l_free_buffer(a4l_buf_t * buf_desc)
 {
if (buf_desc-pg_list != NULL) {
rtdm_free(buf_desc-pg_list);
@@ -249,6 

[Xenomai-git] Alexis Berlemont : analogy: minor change in analogy Kconfig text

2010-09-20 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: a2a4a8dea6e81f830232f19884bcd3b677d1854b
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=a2a4a8dea6e81f830232f19884bcd3b677d1854b

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Tue Jul 20 00:07:04 2010 +0200

analogy: minor change in analogy Kconfig text

---

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

diff --git a/ksrc/drivers/analogy/Kconfig b/ksrc/drivers/analogy/Kconfig
index b33fd67..7bc5ff2 100644
--- a/ksrc/drivers/analogy/Kconfig
+++ b/ksrc/drivers/analogy/Kconfig
@@ -6,7 +6,7 @@ config XENO_DRIVERS_ANALOGY
help
 
ANALOGY is a framework aimed at supporting data acquisition
-   drivers.
+   devices.
 
 config XENO_DRIVERS_ANALOGY_DEBUG
depends on XENO_DRIVERS_ANALOGY


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


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

2010-09-20 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: 51d69ef9393dbc183e21ab8adc58d55d6f11ea7f
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=51d69ef9393dbc183e21ab8adc58d55d6f11ea7f

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Tue Aug 24 00:52:36 2010 +0200

analogy: minor changes in cmd_bits

---

 src/utils/analogy/cmd_bits.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/utils/analogy/cmd_bits.c b/src/utils/analogy/cmd_bits.c
index aa0e082..966e278 100644
--- a/src/utils/analogy/cmd_bits.c
+++ b/src/utils/analogy/cmd_bits.c
@@ -45,7 +45,7 @@ a4l_cmd_t cmd = {
.start_src = TRIG_INT,
.start_arg = 0,
.scan_begin_src = TRIG_EXT,
-   .scan_begin_arg = 0, /* in ns */
+   .scan_begin_arg = 28, /* in ns */
.convert_src = TRIG_NOW,
.convert_arg = 0, /* in ns */
.scan_end_src = TRIG_COUNT,
@@ -270,6 +270,10 @@ out_cmd_bits:
if (dsc.sbdata != NULL)
free(dsc.sbdata);
 
+   /* The fd closure will automatically trigger a cancel; so,
+  wait a little bit for the end of the transfer */
+   sleep(1);
+
/* Release the file descriptor */
a4l_close(dsc);
 


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


[Xenomai-git] Alexis Berlemont : analogy: [pcimio] fix a forgotten warning

2010-09-20 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: b10d17463982202d703ba24da8300f22f749a767
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=b10d17463982202d703ba24da8300f22f749a767

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Sep  4 01:06:59 2010 +0200

analogy: [pcimio] fix a forgotten warning

---

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

diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c 
b/ksrc/drivers/analogy/national_instruments/mio_common.c
index a1a50dc..17aa1f5 100644
--- a/ksrc/drivers/analogy/national_instruments/mio_common.c
+++ b/ksrc/drivers/analogy/national_instruments/mio_common.c
@@ -3441,7 +3441,6 @@ int ni_cdio_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd)
 {
a4l_dev_t *dev = subd-dev;
unsigned cdo_mode_bits = CDO_FIFO_Mode_Bit | CDO_Halt_On_Error_Bit;
-   int retval;
 
ni_writel(CDO_Reset_Bit, M_Offset_CDIO_Command);
switch (cmd-scan_begin_src) {


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


[Xenomai-git] Alexis Berlemont : analogy: comsetic change in mite.c

2010-09-20 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: a301772cf408165481fd3d6a7bfb0d3af40545c2
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=a301772cf408165481fd3d6a7bfb0d3af40545c2

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Sep  4 00:30:10 2010 +0200

analogy: comsetic change in mite.c

---

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

diff --git a/ksrc/drivers/analogy/national_instruments/mite.c 
b/ksrc/drivers/analogy/national_instruments/mite.c
index da1f6a5..9b0394a 100644
--- a/ksrc/drivers/analogy/national_instruments/mite.c
+++ b/ksrc/drivers/analogy/national_instruments/mite.c
@@ -332,10 +332,10 @@ void mite_release_channel(struct mite_channel *mite_chan)
struct mite_struct *mite = mite_chan-mite;
unsigned long flags;
 
-   // spin lock to prevent races with mite_request_channel
+   /* Spin lock to prevent races with mite_request_channel */
a4l_lock_irqsave(mite-lock, flags);
if (mite-channel_allocated[mite_chan-channel]) {
-   // disable all channel's interrupts
+   /* disable all channel's interrupts */
writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
   CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
   CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |


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


[Xenomai-git] Alexis Berlemont : analogy: [pcimio] add the initialization of the ring for gpct subd

2010-09-20 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: dba6c40fa35a10482a0c00bf54a8b839209579e3
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=dba6c40fa35a10482a0c00bf54a8b839209579e3

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Sat Sep  4 17:42:49 2010 +0200

analogy: [pcimio] add the initialization of the ring for gpct subd

---

 .../analogy/national_instruments/mio_common.c  |   14 +-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c 
b/ksrc/drivers/analogy/national_instruments/mio_common.c
index 17aa1f5..be10312 100644
--- a/ksrc/drivers/analogy/national_instruments/mio_common.c
+++ b/ksrc/drivers/analogy/national_instruments/mio_common.c
@@ -4486,6 +4486,7 @@ static int ni_gpct_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd)
int retval;
a4l_dev_t *dev = subd-dev;
struct ni_gpct *counter = (struct ni_gpct *)subd-priv;
+   struct mite_dma_descriptor_ring *ring;
 
retval = ni_request_gpct_mite_channel(dev, 
  counter-counter_index,
@@ -4493,9 +4494,20 @@ static int ni_gpct_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd)
if (retval) {
a4l_err(dev,
ni_gpct_cmd: 
-   no dma channel available for use by counter);
+   no dma channel available for use by counter\n);
return retval;
}
+
+   ring = devpriv-gpct_mite_ring[counter-counter_index];
+   retval = mite_buf_change(ring, subd);
+   if (retval) {
+   a4l_err(dev,
+   ni_gpct_cmd: 
+   dma ring configuration failed\n);
+   return retval;
+
+   }
+
ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL, NULL);
ni_e_series_enable_second_irq(dev, counter-counter_index, 1);
retval = ni_tio_cmd(counter, cmd);


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


[Xenomai-git] Alexis Berlemont : analogy: fix compilation warnings with gcc-4.4.1

2010-09-20 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: 06ee0ab5d339ec13476199bea841312660c45a44
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=06ee0ab5d339ec13476199bea841312660c45a44

Author: Alexis Berlemont alexis.berlem...@gmail.com
Date:   Mon Sep 20 11:36:34 2010 +0200

analogy: fix compilation warnings with gcc-4.4.1

---

 src/drvlib/analogy/sync.c |   44 ++--
 src/utils/analogy/insn_bits.c |9 ++-
 2 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/src/drvlib/analogy/sync.c b/src/drvlib/analogy/sync.c
index 4bcde62..d7c8ba9 100644
--- a/src/drvlib/analogy/sync.c
+++ b/src/drvlib/analogy/sync.c
@@ -296,21 +296,27 @@ int a4l_sync_dio(a4l_desc_t *dsc,
size = a4l_sizeof_subd(subd);
 
switch(size) {
-   case 4:
-   ((uint32_t *)values)[0] = *((uint32_t *)mask);
-   ((uint32_t *)values)[1] = *((uint32_t *)buf);
+   case sizeof(uint32_t): {
+   uint32_t *tmp = (uint32_t *)values;
+   tmp[0] = *((uint32_t *)mask);
+   tmp[1] = *((uint32_t *)buf);
insn.data_size = 2 * sizeof(uint32_t);
break;
-   case 2: 
-   ((uint16_t *)values)[0] = *((uint16_t *)mask);
-   ((uint16_t *)values)[1] = *((uint16_t *)buf);
+   }
+   case sizeof(uint16_t): {
+   uint16_t *tmp = (uint16_t *)values;
+   tmp[0] = *((uint16_t *)mask);
+   tmp[1] = *((uint16_t *)buf);
insn.data_size = 2 * sizeof(uint16_t);
break;
-   case 1: 
-   ((uint8_t *)values)[0] = *((uint8_t *)mask);
-   ((uint8_t *)values)[1] = *((uint8_t *)buf);
+   }
+   case sizeof(uint8_t): {
+   uint8_t *tmp = (uint8_t *)values;
+   tmp[0] = *((uint8_t *)mask);
+   tmp[1] = *((uint8_t *)buf);
insn.data_size = 2 * sizeof(uint8_t);
break;
+   }
default:
return -EINVAL;
}
@@ -320,16 +326,22 @@ int a4l_sync_dio(a4l_desc_t *dsc,
 
/* Update the buffer if need be */
switch(size) {
-   case 4:
-   *((uint32_t *)buf) = ((uint32_t *)values)[1];
+   case sizeof(uint32_t): {
+   uint32_t *tmp = (uint32_t *)buf;
+   *tmp = ((uint32_t *)values)[1];
break;
-   case 2: 
-   *((uint16_t *)buf) = ((uint16_t *)values)[1];
+   }
+   case sizeof(uint16_t): {
+   uint16_t *tmp = (uint16_t *)buf;
+   *tmp = ((uint16_t *)values)[1];
break;
-   case 1: 
-   *((uint8_t *)buf) = ((uint8_t *)values)[1];
+   }
+   case sizeof(uint8_t): {
+   uint8_t *tmp = (uint8_t *)buf;
+   *tmp = ((uint8_t *)values)[1];
break;
-   }   
+   }
+   }

return ret;
 }
diff --git a/src/utils/analogy/insn_bits.c b/src/utils/analogy/insn_bits.c
index 192f897..eb7e43a 100644
--- a/src/utils/analogy/insn_bits.c
+++ b/src/utils/analogy/insn_bits.c
@@ -26,6 +26,7 @@
 #include sys/mman.h
 #include errno.h
 #include getopt.h
+#include string.h
 
 #include analogy/analogy.h
 
@@ -200,10 +201,14 @@ int main(int argc, char *argv[])
}
 
if (scan_size == sizeof(uint8_t)) {
-   value = *((uint8_t *)value);
+   uint8_t tmp;
+   memcpy(tmp, value, sizeof(uint8_t));
+   value = (int)tmp;
}
else if (scan_size == sizeof(uint16_t)) {
-   value = *((uint16_t *)value);
+   uint16_t tmp;
+   memcpy(tmp, value, sizeof(uint16_t)); 
+   value = (int)tmp;
}
 
if ((sbinfo-flags  A4L_SUBD_TYPES) != A4L_SUBD_DO)


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