[Xenomai-git] Philippe Gerum : powerpc: upgrade I-pipe support to 3.0.4-powerpc-2.13-01
Module: xenomai-head Branch: master Commit: 3a2462426a8849945b2cc69bab1a52bac7fb81c1 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=3a2462426a8849945b2cc69bab1a52bac7fb81c1 Author: Philippe Gerum Date: Tue Sep 6 22:57:17 2011 +0200 powerpc: upgrade I-pipe support to 3.0.4-powerpc-2.13-01 --- ...tch => adeos-ipipe-3.0.4-powerpc-2.13-01.patch} | 10 +- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ksrc/arch/powerpc/patches/adeos-ipipe-3.0.4-powerpc-2.13-00.patch b/ksrc/arch/powerpc/patches/adeos-ipipe-3.0.4-powerpc-2.13-01.patch similarity index 99% rename from ksrc/arch/powerpc/patches/adeos-ipipe-3.0.4-powerpc-2.13-00.patch rename to ksrc/arch/powerpc/patches/adeos-ipipe-3.0.4-powerpc-2.13-01.patch index 62074c6..10a05ea 100644 --- a/ksrc/arch/powerpc/patches/adeos-ipipe-3.0.4-powerpc-2.13-00.patch +++ b/ksrc/arch/powerpc/patches/adeos-ipipe-3.0.4-powerpc-2.13-01.patch @@ -265,7 +265,7 @@ index bb712c9..8885e9b 100644 * or should we not care like we do now ? --BenH. diff --git a/arch/powerpc/include/asm/ipipe.h b/arch/powerpc/include/asm/ipipe.h new file mode 100644 -index 000..3497961 +index 000..013e213 --- /dev/null +++ b/arch/powerpc/include/asm/ipipe.h @@ -0,0 +1,249 @@ @@ -316,10 +316,10 @@ index 000..3497961 +#include +#endif + -+#define IPIPE_ARCH_STRING "2.13-00" ++#define IPIPE_ARCH_STRING "2.13-01" +#define IPIPE_MAJOR_NUMBER2 +#define IPIPE_MINOR_NUMBER13 -+#define IPIPE_PATCH_NUMBER0 ++#define IPIPE_PATCH_NUMBER1 + +#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH + @@ -2369,7 +2369,7 @@ index ba31954..d0a9b16 100644 sync diff --git a/arch/powerpc/kernel/ipipe.c b/arch/powerpc/kernel/ipipe.c new file mode 100644 -index 000..707c3ae +index 000..7252c78 --- /dev/null +++ b/arch/powerpc/kernel/ipipe.c @@ -0,0 +1,710 @@ @@ -2458,7 +2458,7 @@ index 000..707c3ae + __ipipe_ipi_irq = irq; + mb(); +#ifndef CONFIG_DEBUGGER -+ irq_to_desc(irq)->chip->startup(irq); ++ irq_get_chip(irq)->irq_startup(irq_get_irq_data(irq)); +#endif +} + ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : native: silence warning w/ fastsynch disabled
Module: xenomai-head Branch: master Commit: dda9a37b2492b3963624b945ea2582591743c0f3 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=dda9a37b2492b3963624b945ea2582591743c0f3 Author: Philippe Gerum Date: Tue Sep 6 22:13:49 2011 +0200 native: silence warning w/ fastsynch disabled --- ksrc/skins/native/syscall.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/ksrc/skins/native/syscall.c b/ksrc/skins/native/syscall.c index 71396e1..acf0375 100644 --- a/ksrc/skins/native/syscall.c +++ b/ksrc/skins/native/syscall.c @@ -1872,6 +1872,7 @@ static int __rt_cond_wait_prologue(struct pt_regs *regs) plockcnt = &dummy; #else /* !CONFIG_XENO_FASTSYNCH */ plockcnt = &d.lockcnt; + (void)dummy; #endif /* !CONFIG_XENO_FASTSYNCH */ err = rt_cond_wait_prologue(cond, mutex, plockcnt, timeout_mode, timeout); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : powerpc: use mmu_has_feature() predicate with v3.x kernels
Module: xenomai-head Branch: master Commit: c5241a229b559e77eb004b6367a7df6e8c6b2a7c URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=c5241a229b559e77eb004b6367a7df6e8c6b2a7c Author: Philippe Gerum Date: Tue Sep 6 22:13:18 2011 +0200 powerpc: use mmu_has_feature() predicate with v3.x kernels --- include/asm-powerpc/bits/pod.h | 13 - ksrc/arch/powerpc/switch_64.S |1 + 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/include/asm-powerpc/bits/pod.h b/include/asm-powerpc/bits/pod.h index 6269907..e80fea6 100644 --- a/include/asm-powerpc/bits/pod.h +++ b/include/asm-powerpc/bits/pod.h @@ -55,7 +55,11 @@ unsigned long get_stack_vsid(unsigned long ksp) #else /* LINUX_VERSION_CODE >= 2.6.24 */ unsigned long llp = mmu_psize_defs[mmu_linear_psize].sllp; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) if (cpu_has_feature(CPU_FTR_1T_SEGMENT)) +#else + if (mmu_has_feature(MMU_FTR_1T_SEGMENT)) +#endif vsid = get_kernel_vsid(ksp, MMU_SEGSIZE_1T) << SLB_VSID_SHIFT_1T; else @@ -130,8 +134,11 @@ static inline void xnarch_switch_to(xnarchtcb_t *out_tcb, #ifdef CONFIG_PPC64 if (likely(next_mm)) { cpu_set(rthal_processor_id(), next_mm->cpu_vm_mask); - +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) if (cpu_has_feature(CPU_FTR_SLB)) +#else + if (mmu_has_feature(MMU_FTR_SLB)) +#endif switch_slb(next, next_mm); else switch_stab(next, next_mm); @@ -203,7 +210,11 @@ static inline void xnarch_init_thread(xnarchtcb_t * tcb, childregs->gpr[22] = (unsigned long)tcb; childregs->gpr[23] = ((unsigned long *)xnarch_thread_trampoline)[0]; /* lr = entry addr. */ childregs->gpr[24] = ((unsigned long *)xnarch_thread_trampoline)[1]; /* r2 = TOC base. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) if (cpu_has_feature(CPU_FTR_SLB)) +#else + if (mmu_has_feature(MMU_FTR_SLB)) +#endif tcb->ts.ksp_vsid = get_stack_vsid(tcb->ts.ksp); #else /* !CONFIG_PPC64 */ childregs->nip = (unsigned long)rthal_thread_trampoline; diff --git a/ksrc/arch/powerpc/switch_64.S b/ksrc/arch/powerpc/switch_64.S index aaafaee..9409b24 100644 --- a/ksrc/arch/powerpc/switch_64.S +++ b/ksrc/arch/powerpc/switch_64.S @@ -33,6 +33,7 @@ #include #include #include +#include /* * void rthal_thread_switch(struct thread_struct *prev, struct thread_struct *next, int kthreadp) ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : Merge branch 'master' of ssh+git://xenomai.org/ xenomai-head
Module: xenomai-head Branch: master Commit: bdea13fba74622da3939d73161e1e0aa82f64417 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=bdea13fba74622da3939d73161e1e0aa82f64417 Author: Philippe Gerum Date: Tue Sep 6 16:50:01 2011 +0200 Merge branch 'master' of ssh+git://xenomai.org/xenomai-head --- ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : rtdm: fix build for linux 2.4
Module: xenomai-head Branch: master Commit: 834d68d2cc6de0400d22fad8a15b57d929c2e121 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=834d68d2cc6de0400d22fad8a15b57d929c2e121 Author: Philippe Gerum Date: Tue Sep 6 16:40:50 2011 +0200 rtdm: fix build for linux 2.4 --- ksrc/skins/rtdm/core.c |4 ++-- ksrc/skins/rtdm/internal.h |6 +++--- ksrc/skins/rtdm/proc.c |2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ksrc/skins/rtdm/core.c b/ksrc/skins/rtdm/core.c index 22a45a5..edf8494 100644 --- a/ksrc/skins/rtdm/core.c +++ b/ksrc/skins/rtdm/core.c @@ -26,8 +26,6 @@ * @{ */ -#include - #include #include #include @@ -35,6 +33,8 @@ #include "rtdm/internal.h" +#include + #define CLOSURE_RETRY_PERIOD_MS100 #define FD_BITMAP_SIZE ((RTDM_FD_MAX + BITS_PER_LONG-1) / BITS_PER_LONG) diff --git a/ksrc/skins/rtdm/internal.h b/ksrc/skins/rtdm/internal.h index ef43c25..2c73b3e 100644 --- a/ksrc/skins/rtdm/internal.h +++ b/ksrc/skins/rtdm/internal.h @@ -20,13 +20,13 @@ #ifndef _RTDM_INTERNAL_H #define _RTDM_INTERNAL_H -#include -#include - #include #include #include +#include +#include + #ifndef CONFIG_XENO_OPT_DEBUG_RTDM_APPL #define CONFIG_XENO_OPT_DEBUG_RTDM_APPL0 #endif diff --git a/ksrc/skins/rtdm/proc.c b/ksrc/skins/rtdm/proc.c index b88b8ce..37883d4 100644 --- a/ksrc/skins/rtdm/proc.c +++ b/ksrc/skins/rtdm/proc.c @@ -17,8 +17,8 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include "rtdm/internal.h" +#include struct xnvfile_directory rtdm_vfroot; /* /proc/xenomai/rtdm */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : hal/generic: missing bits to support vfiles over linux 2.4
Module: xenomai-head Branch: master Commit: e3c13f0685c2edf2a2ce30cd239b3f2a4858e8ae URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=e3c13f0685c2edf2a2ce30cd239b3f2a4858e8ae Author: Philippe Gerum Date: Tue Sep 6 16:40:47 2011 +0200 hal/generic: missing bits to support vfiles over linux 2.4 --- include/asm-generic/wrappers.h |8 ++-- ksrc/nucleus/Config.in |5 - ksrc/nucleus/heap.c|2 +- ksrc/nucleus/pipe.c|2 +- ksrc/nucleus/shadow.c | 11 +-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/asm-generic/wrappers.h b/include/asm-generic/wrappers.h index 9c44042..ebfc343 100644 --- a/include/asm-generic/wrappers.h +++ b/include/asm-generic/wrappers.h @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include /* Use the backport. */ #include @@ -90,6 +92,7 @@ /* Seqfiles */ #define SEQ_START_TOKEN ((void *)1) +#define SEQ_SKIP 0 /* not implemented. */ /* Sched and process flags */ #define MAX_RT_PRIO 100 @@ -295,6 +298,7 @@ void show_stack(struct task_struct *task, #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) #endif +#define GFP_DMA32 GFP_DMA #define __GFP_BITS_SHIFT 20 #define pgprot_noncached(p) (p) @@ -624,11 +628,11 @@ static inline void wrap_proc_dir_entry_owner(struct proc_dir_entry *entry) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) #define unlocked_ioctl ioctl #define DECLARE_IOCTL_HANDLER(name, filp, cmd, arg)\ - name(struct inode *__inode__, struct file *filp,\ + int name(struct inode *__inode__, struct file *filp,\ unsigned int cmd, unsigned long arg) #else #define DECLARE_IOCTL_HANDLER(name, filp, cmd, arg)\ - name(struct file *filp, unsigned int cmd, unsigned long arg) + long name(struct file *filp, unsigned int cmd, unsigned long arg) #endif #ifndef DEFINE_SEMAPHORE diff --git a/ksrc/nucleus/Config.in b/ksrc/nucleus/Config.in index c0a94f5..fcf1abd 100644 --- a/ksrc/nucleus/Config.in +++ b/ksrc/nucleus/Config.in @@ -7,6 +7,9 @@ if [ "$CONFIG_XENOMAI" = "y" ]; then dep_tristate 'Nucleus' CONFIG_XENO_OPT_NUCLEUS $CONFIG_XENOMAI if [ "$CONFIG_XENO_OPT_NUCLEUS" != "n" ]; then + if [ "$CONFIG_PROC_FS" != "n" ]; then +define_bool CONFIG_XENO_OPT_VFILE y + fi mainmenu_option next_comment comment 'Nucleus options' bool 'Pervasive real-time support in user-space' CONFIG_XENO_OPT_PERVASIVE @@ -41,7 +44,7 @@ if [ "$CONFIG_XENO_OPT_NUCLEUS" != "n" ]; then int 'Maximum number of pending replenishments' CONFIG_XENO_OPT_SCHED_SPORADIC_MAXREPL 8 fi fi - bool 'Statistics collection' CONFIG_XENO_OPT_STATS + dep_bool 'Statistics collection' CONFIG_XENO_OPT_STATS $CONFIG_XENO_OPT_VFILE int 'Size of private semaphores heap (Kb)' CONFIG_XENO_OPT_SEM_HEAPSZ 12 int 'Size of global semaphores heap (Kb)' CONFIG_XENO_OPT_GLOBAL_SEM_HEAPSZ 12 bool 'Debug support' CONFIG_XENO_OPT_DEBUG diff --git a/ksrc/nucleus/heap.c b/ksrc/nucleus/heap.c index 0c1ceeb..e0715d6 100644 --- a/ksrc/nucleus/heap.c +++ b/ksrc/nucleus/heap.c @@ -1215,7 +1215,7 @@ static inline struct xnheap *__validate_heap_addr(void *addr) return NULL; } -static long DECLARE_IOCTL_HANDLER(xnheap_ioctl, file, cmd, arg) +static DECLARE_IOCTL_HANDLER(xnheap_ioctl, file, cmd, arg) { file->private_data = (void *)arg; return 0; diff --git a/ksrc/nucleus/pipe.c b/ksrc/nucleus/pipe.c index b6d0a23..1e6bcf2 100644 --- a/ksrc/nucleus/pipe.c +++ b/ksrc/nucleus/pipe.c @@ -917,7 +917,7 @@ static ssize_t xnpipe_write(struct file *file, return (ssize_t)count; } -static long DECLARE_IOCTL_HANDLER(xnpipe_ioctl, file, cmd, arg) +static DECLARE_IOCTL_HANDLER(xnpipe_ioctl, file, cmd, arg) { struct xnpipe_state *state = file->private_data; int ret = 0; diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c index bd0096f..21cc191 100644 --- a/ksrc/nucleus/shadow.c +++ b/ksrc/nucleus/shadow.c @@ -2170,8 +2170,10 @@ static void *xnshadow_sys_event(int event, void *data) err = xnheap_init_mapped(&p->sem_heap, CONFIG_XENO_OPT_SEM_HEAPSZ * 1024, XNARCH_SHARED_HEAP_FLAGS); - if (err) - goto err_free_host_mem; + if (err) { + xnarch_free_host_mem(p, sizeof(*p)); + return ERR_PTR(err); + } xnheap_set_label(&p->sem_heap, "private sem heap [%d]", current->pid); @@ -2182,11 +2184,8 @@ static void *xnshadow_sys_event(int event, void *data) printk(KERN_WARNING "Xenomai: %s[%d] cannot map MAYDAY page\n",
[Xenomai-git] Gilles Chanteperdrix : Merge remote branch 'alex/analogy'
Module: xenomai-head Branch: master Commit: 7a42a7b85278fbc0fab2f97027fe8f76c3d9f57f URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=7a42a7b85278fbc0fab2f97027fe8f76c3d9f57f Author: Gilles Chanteperdrix Date: Tue Sep 6 12:52:11 2011 +0200 Merge remote branch 'alex/analogy' --- ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [ni_660x] review coding style and traces
Module: xenomai-head Branch: master Commit: 0c35e0878a84d13310e1599df7ade251fdfa366b URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=0c35e0878a84d13310e1599df7ade251fdfa366b Author: Alexis Berlemont Date: Wed Aug 31 23:56:14 2011 +0200 analogy: [ni_660x] review coding style and traces Next time someone says that he does not know the kernel coding guidelines, I will kindly ask him to read the doc... I am so fed up with wasting my time. --- .../drivers/analogy/national_instruments/ni_660x.c | 405 +--- 1 files changed, 177 insertions(+), 228 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/ni_660x.c b/ksrc/drivers/analogy/national_instruments/ni_660x.c index 58b8da7..9288574 100644 --- a/ksrc/drivers/analogy/national_instruments/ni_660x.c +++ b/ksrc/drivers/analogy/national_instruments/ni_660x.c @@ -58,9 +58,6 @@ #include "ni_tio.h" #include "mite.h" -/* TODO: replace printk */ - - enum io_direction { DIRECTION_INPUT = 0, DIRECTION_OUTPUT = 1, @@ -761,8 +758,8 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg) ni_660x_register = G3InterruptEnable; break; default: - printk("%s: unhandled register 0x%x in switch.\n", - __func__, reg); + __a4l_err("%s: unhandled register 0x%x in switch.\n", + __FUNCTION__, reg); BUG(); return 0; break; @@ -786,8 +783,8 @@ static inline void ni_660x_write_register(a4l_dev_t *dev, writel(bits, write_address); break; default: - printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n", - __FILE__, __func__, reg); + __a4l_err("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n", + __FILE__, __FUNCTION__, reg); BUG(); break; } @@ -809,8 +806,8 @@ static inline unsigned ni_660x_read_register(a4l_dev_t *dev, return readl(read_address); break; default: - printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n", - __FILE__, __func__, reg); + __a4l_err("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n", + __FILE__, __FUNCTION__, reg); BUG(); break; } @@ -898,7 +895,9 @@ static int ni_660x_request_mite_channel(a4l_dev_t *dev, mite_ring(private(dev), counter)); if (mite_chan == NULL) { a4l_unlock_irqrestore(&private(dev)->mite_channel_lock, flags); - printk("failed to reserve mite dma channel for counter.\n"); + a4l_err(dev, + "%s: failed to reserve mite dma channel for counter.\n", + __FUNCTION__); return -EBUSY; } mite_chan->dir = direction; @@ -932,9 +931,12 @@ static int ni_660x_cmd(a4l_subd_t *s, a4l_cmd_t* cmd) retval = ni_660x_request_mite_channel(s->dev, counter, A4L_INPUT); if (retval) { - printk("no dma channel available for use by counter"); + a4l_err(s->dev, + "%s: no dma channel available for use by counter", + __FUNCTION__); return retval; } + a4l_ni_tio_acknowledge_and_confirm (counter, NULL, NULL, NULL, NULL); retval = a4l_ni_tio_cmd(counter, cmd); @@ -1047,62 +1049,53 @@ static void __exit driver_ni_660x_cleanup_module(void) a4l_unregister_drv (&ni_660x_drv); } - - module_init(driver_ni_660x_init_module); module_exit(driver_ni_660x_cleanup_module); - -static int ni_660x_attach(a4l_dev_t *dev, -a4l_lnkdesc_t *arg) +static int ni_660x_attach(a4l_dev_t *dev, a4l_lnkdesc_t *arg) { a4l_subd_t *s; int ret; - int err; - int bus, slot; + int err; + int bus, slot; unsigned i; - int nsubdev = 0; + int nsubdev = 0; unsigned global_interrupt_config_bits; - struct mite_struct *mitedev; + struct mite_struct *mitedev; struct ni_660x_board* boardptr = NULL; - ret = 0; - bus = slot = 0; - mitedev = NULL; - nsubdev = 0; + ret = 0; + bus = slot = 0; + mitedev = NULL; + nsubdev = 0; if(arg->opts == NULL || arg->opts_size == 0) - { bus = slot = 0; - } - else - { + else { bus = arg->opts_size >= sizeof(unsigned long) ? ((unsigned long *)arg->opts)[0] : 0; slot = arg->opts_size >= sizeof(unsigned long) * 2 ? ((unsigned long *)arg->opts)[1] : 0; } - for (i = 0; ( i < n_ni_660x_boards ) && ( mitedev == NULL ); i++) { - -
[Xenomai-git] Alexis Berlemont : analogy: [ni_670x] replace printk calls by a4l_[err, info ] calls
Module: xenomai-head Branch: master Commit: 65a0f6fc8a4594baa7b7a63e82a2140d82225cab URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=65a0f6fc8a4594baa7b7a63e82a2140d82225cab Author: Alexis Berlemont Date: Thu Sep 1 23:43:32 2011 +0200 analogy: [ni_670x] replace printk calls by a4l_[err,info] calls --- .../drivers/analogy/national_instruments/ni_670x.c | 39 +--- 1 files changed, 25 insertions(+), 14 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/ni_670x.c b/ksrc/drivers/analogy/national_instruments/ni_670x.c index c4c4f76..336c27d 100644 --- a/ksrc/drivers/analogy/national_instruments/ni_670x.c +++ b/ksrc/drivers/analogy/national_instruments/ni_670x.c @@ -270,21 +270,26 @@ static int ni_670x_attach (a4l_dev_t *dev, a4l_lnkdesc_t *arg) ((unsigned long *)arg->opts)[1] : 0; } - printk(KERN_INFO "[ANALOGY] [NI_670x]: Will try to attach ni670x device (bus=%d/slot=%d)...", bus, slot); + a4l_info(dev, +"%s: ni670x attach procedure started(bus=%d/slot=%d)...\n", +__FUNCTION__, bus, slot); mite = NULL; for(i = 0; i < n_ni_670x_boards && mite == NULL; i++) { - mite = a4l_mite_find_device(bus, slot, ni_670x_boards[i].device_id); + mite = a4l_mite_find_device(bus, + slot, ni_670x_boards[i].device_id); board = (struct ni_670x_board*) &ni_670x_boards[i]; } if(mite == NULL) { - printk(KERN_WARNING "[ANALOGY] [NI_670x]: cannot find the MITE device\n"); + a4l_err(dev, "%s: cannot find the MITE device\n", __FUNCTION__); return -ENOENT; } - printk(KERN_INFO "[ANALOGY] [NI_670x]: Found device %d %s\n", i , ni_670x_boards[i].name); + a4l_info(dev, +"%s: Found device %d %s\n", +__FUNCTION__, i , ni_670x_boards[i].name); devpriv->irq_polarity = PCIMIO_IRQ_POLARITY; devpriv->irq_pin = 0; @@ -294,26 +299,31 @@ static int ni_670x_attach (a4l_dev_t *dev, a4l_lnkdesc_t *arg) ret = a4l_mite_setup(devpriv->mite, 0); if (ret < 0) { - printk(KERN_WARNING "[ANALOGY] [NI_670x]: error setting up mite\n"); + a4l_err(dev, "%s: error setting up mite\n", __FUNCTION__); return ret; } irq = mite_irq(devpriv->mite); devpriv->irq = irq; - + a4l_info(dev, "ni670x attach: found %s board\n", board->name); for (i = 0; i < 2; i++) { - a4l_subd_t *subd = a4l_alloc_subd(setup_subds[i].sizeof_priv, NULL); + a4l_subd_t *subd = + a4l_alloc_subd(setup_subds[i].sizeof_priv, NULL); if (subd == NULL) { - printk(KERN_WARNING "[ANALOGY] [NI_670x]: cannot allocate subdevice\n"); - return -ENOMEM; + a4l_err(dev, + "%s: cannot allocate subdevice\n", + __FUNCTION__); + return -ENOMEM; } err = a4l_add_subd(dev, subd); if (err != i) { - printk(KERN_WARNING "[ANALOGY] [NI_670x]: cannot add subdevice\n"); + a4l_err(dev, + "%s: cannot add subdevice\n", + __FUNCTION__); return err; } @@ -325,19 +335,20 @@ static int ni_670x_attach (a4l_dev_t *dev, a4l_lnkdesc_t *arg) /* Config of ao registers */ writel(0x00, devpriv->mite->daq_io_addr + AO_CONTROL_OFFSET); - printk(KERN_INFO "[ANALOGY] [NI_670x]: ni670x attached\n"); + a4l_info(dev, "%s: ni670x attached\n", __FUNCTION__); return 0; } static int ni_670x_detach(a4l_dev_t *dev) { - printk(KERN_INFO "[ANALOGY] [NI_670x]: try to remove the board ... "); + a4l_info(dev, "%s: ni670x detach procedure started...\n", __FUNCTION__); if(dev->priv != NULL && devpriv->mite != NULL) a4l_mite_unsetup(devpriv->mite); - printk(KERN_INFO "[ANALOGY] [NI_670x]: Board removed!\n"); + a4l_info(dev, +"%s: ni670x detach procedure succeeded...\n", __FUNCTION__); return 0; } @@ -392,7 +403,7 @@ static int ni_670x_ao_winsn(a4l_subd_t *subd, a4l_kinsn_t *insn) .: . | . . .: . | . . .: . | . . - vch(15) : 30 | ich(31) : 31 */ + vch(15) : 30 | ich(31) : 31 */ for (i = 0; i < insn->data_size / sizeof(unsigned int); i++) {
[Xenomai-git] Alexis Berlemont : analogy: [ni_670x] review coding style
Module: xenomai-head Branch: master Commit: 4c66797c7ed64a7bb8b7e88cd2e9a31b6c8e18f2 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=4c66797c7ed64a7bb8b7e88cd2e9a31b6c8e18f2 Author: Alexis Berlemont Date: Thu Sep 1 00:18:25 2011 +0200 analogy: [ni_670x] review coding style --- .../drivers/analogy/national_instruments/ni_670x.c | 397 +--- 1 files changed, 175 insertions(+), 222 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/ni_670x.c b/ksrc/drivers/analogy/national_instruments/ni_670x.c index e431a37..c4c4f76 100644 --- a/ksrc/drivers/analogy/national_instruments/ni_670x.c +++ b/ksrc/drivers/analogy/national_instruments/ni_670x.c @@ -46,12 +46,9 @@ Commands are not supported. * Julien Delange */ - #include #include #include -#include -#include #include "../intel/8255.h" #include "ni_mio.h" @@ -72,7 +69,6 @@ Commands are not supported. /* Board description*/ - struct ni_670x_board { unsigned short device_id; const char *name; @@ -82,25 +78,23 @@ struct ni_670x_board { #define thisboard ((struct ni_670x_board *)dev->board_ptr) - - struct ni_670x_private { struct mite_struct *mite; int boardtype; int dio; unsigned int ao_readback[32]; -/* - * Added when porting to xenomai - */ - int irq_polarity; - int irq_pin; - int irq; - struct ni_670x_board *board_ptr; - /* -* END OF ADDED when porting to xenomai - */ -}; + /* +* Added when porting to xenomai +*/ + int irq_polarity; + int irq_pin; + int irq; + struct ni_670x_board *board_ptr; + /* +* END OF ADDED when porting to xenomai +*/ +}; struct ni_670x_subd_priv { int io_bits; @@ -110,94 +104,75 @@ struct ni_670x_subd_priv { void* counter; }; - -static int ni_670x_ao_winsn - (a4l_subd_t *subd, - a4l_kinsn_t *insn); - -static int ni_670x_ao_rinsn - (a4l_subd_t *subd, - a4l_kinsn_t *insn); - -static int ni_670x_dio_insn_bits - (a4l_subd_t *subd, -a4l_kinsn_t *insn); - -static int ni_670x_dio_insn_config -(a4l_subd_t *subd, - a4l_kinsn_t *insn); +static int ni_670x_ao_winsn(a4l_subd_t *subd, a4l_kinsn_t *insn); +static int ni_670x_ao_rinsn(a4l_subd_t *subd, a4l_kinsn_t *insn); +static int ni_670x_dio_insn_bits(a4l_subd_t *subd, a4l_kinsn_t *insn); +static int ni_670x_dio_insn_config(a4l_subd_t *subd, a4l_kinsn_t *insn); static a4l_chdesc_t ni_670x_desc_dio = { - .mode = A4L_CHAN_GLOBAL_CHANDESC, - .length = 8, - .chans = { - {A4L_CHAN_AREF_GROUND, 1}, - }, + .mode = A4L_CHAN_GLOBAL_CHANDESC, + .length = 8, + .chans = { + {A4L_CHAN_AREF_GROUND, 1}, + }, }; static a4l_chdesc_t ni_670x_desc_ao = { - .mode = A4L_CHAN_GLOBAL_CHANDESC, - .length = 0, /* initialized later according to the board found */ - .chans = { - {A4L_CHAN_AREF_GROUND, 16}, - }, + .mode = A4L_CHAN_GLOBAL_CHANDESC, + .length = 0, /* initialized later according to the board found */ + .chans = { + {A4L_CHAN_AREF_GROUND, 16}, + }, }; static a4l_rngtab_t range_0_20mA = { 1, {RANGE_mA(0, 20)} }; -static a4l_rngtab_t rng_bipolar10 = { 1, { - RANGE_V(-10, 10), - }}; - - +static a4l_rngtab_t rng_bipolar10 = { 1, {RANGE_V(-10, 10) }}; a4l_rngtab_t *range_table_list[32] = { -&rng_bipolar10, &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, -&rng_bipolar10, &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, -&rng_bipolar10, &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, -&rng_bipolar10, &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, -&range_0_20mA, &range_0_20mA, &range_0_20mA, &range_0_20mA, -&range_0_20mA, &range_0_20mA, &range_0_20mA, &range_0_20mA, -&range_0_20mA, &range_0_20mA, &range_0_20mA, &range_0_20mA, -&range_0_20mA, &range_0_20mA, &range_0_20mA, &range_0_20mA}; + &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, + &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, + &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, + &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, &rng_bipolar10, + &range_0_20mA, &range_0_20mA, &range_0_20mA, &range_0_20mA, + &range_0_20mA, &range_0_20mA, &range_0_20mA, &range_0_20mA, + &range_0_20mA, &range_0_20mA, &range_0_20mA, &range_0_20mA, + &range_0_20mA, &range_0_20mA, &range_0_20mA, &range_0_20mA}; static A4L_RNGDESC(32) ni670x_ao_desc; static void setup_subd_ao(a4l_subd_t *subd) { - int i; - int nchans; - - nchans = ((struct ni_670x_private*)(subd->dev->priv))->board_ptr->ao_chans; + int i; + int nchans; + + nchans = ((struct ni_670x_private*)(subd->dev->priv))->board_p
[Xenomai-git] Alexis Berlemont : analogy: [ni_660x] remove useless headers
Module: xenomai-head Branch: master Commit: 152571dd42572c1367555a27fa4bba341835c897 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=152571dd42572c1367555a27fa4bba341835c897 Author: Alexis Berlemont Date: Thu Sep 1 00:20:51 2011 +0200 analogy: [ni_660x] remove useless headers --- .../drivers/analogy/national_instruments/ni_660x.c |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/ni_660x.c b/ksrc/drivers/analogy/national_instruments/ni_660x.c index 9288574..a9d607c 100644 --- a/ksrc/drivers/analogy/national_instruments/ni_660x.c +++ b/ksrc/drivers/analogy/national_instruments/ni_660x.c @@ -49,8 +49,6 @@ #include #include -#include -#include #include "../intel/8255.h" #include "ni_stc.h" ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [ni_660x] review indentation
Module: xenomai-head Branch: master Commit: 1996895b67b436e77b68e4ec125eb27ebfdc URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=1996895b67b436e77b68e4ec125eb27ebfdc Author: Alexis Berlemont Date: Tue Aug 30 00:41:57 2011 +0200 analogy: [ni_660x] review indentation --- .../drivers/analogy/national_instruments/ni_660x.c | 180 1 files changed, 72 insertions(+), 108 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/ni_660x.c b/ksrc/drivers/analogy/national_instruments/ni_660x.c index dec59dc..58b8da7 100644 --- a/ksrc/drivers/analogy/national_instruments/ni_660x.c +++ b/ksrc/drivers/analogy/national_instruments/ni_660x.c @@ -58,6 +58,8 @@ #include "ni_tio.h" #include "mite.h" +/* TODO: replace printk */ + enum io_direction { DIRECTION_INPUT = 0, @@ -228,6 +230,7 @@ enum ni_660x_subdevices { NI_660X_DIO_SUBDEV = 1, NI_660X_GPCT_SUBDEV_0 = 2 }; + static inline unsigned NI_660X_GPCT_SUBDEV(unsigned index) { return NI_660X_GPCT_SUBDEV_0 + index; @@ -378,7 +381,7 @@ static inline unsigned pfi_input_select_bits(unsigned pfi_channel, return (input_select & 0x7) << (4 + ioconfig_bitshift(pfi_channel)); } -/* dma configuration register bits */ +/* Dma configuration register bits */ static inline unsigned dma_select_mask(unsigned dma_channel) { BUG_ON(dma_channel >= MAX_DMA_CHANNEL); @@ -388,6 +391,7 @@ static inline unsigned dma_select_mask(unsigned dma_channel) enum dma_selection { dma_selection_none = 0x1f, }; + static inline unsigned dma_selection_counter(unsigned counter_index) { BUG_ON(counter_index >= counters_per_chip); @@ -421,11 +425,11 @@ enum global_interrupt_config_register_bits { Global_Int_Enable_Bit = 0x8000 }; -/* Offset of the GPCT chips from the base-adress of the card */ -static const unsigned GPCT_OFFSET[2] = { 0x0, 0x800 }; /* First chip is at base-address + - 0x00, etc. */ +/* Offset of the GPCT chips from the base-adress of the card: + First chip is at base-address +0x00, etc. */ +static const unsigned GPCT_OFFSET[2] = { 0x0, 0x800 }; -/* Board description*/ +/* Board description */ struct ni_660x_board { unsigned short dev_id; /* `lspci` will show you this */ const char *name; @@ -470,19 +474,22 @@ static DEFINE_PCI_DEVICE_TABLE(ni_660x_pci_table) = { MODULE_DEVICE_TABLE(pci, ni_660x_pci_table); struct ni_660x_private { - struct mite_struct *mite; - struct ni_gpct_device *counter_dev; - uint64_t pfi_direction_bits; - struct mite_dma_descriptor_ring - *mite_rings[NI_660X_MAX_NUM_CHIPS][counters_per_chip]; - a4l_lock_t mite_channel_lock; - /* interrupt_lock prevents races between interrupt and comedi_poll */ - a4l_lock_t interrupt_lock; - unsigned dma_configuration_soft_copies[NI_660X_MAX_NUM_CHIPS]; - a4l_lock_t soft_reg_copy_lock; - unsigned short pfi_output_selects[NUM_PFI_CHANNELS]; - - struct ni_660x_board *board_ptr; + struct mite_struct *mite; + struct ni_gpct_device *counter_dev; + uint64_t pfi_direction_bits; + + struct mite_dma_descriptor_ring + *mite_rings[NI_660X_MAX_NUM_CHIPS][counters_per_chip]; + + a4l_lock_t mite_channel_lock; + /* Interrupt_lock prevents races between interrupt and + comedi_poll */ + a4l_lock_t interrupt_lock; + unsigned int dma_configuration_soft_copies[NI_660X_MAX_NUM_CHIPS]; + a4l_lock_t soft_reg_copy_lock; + unsigned short pfi_output_selects[NUM_PFI_CHANNELS]; + + struct ni_660x_board *board_ptr; }; #undef devpriv @@ -493,7 +500,7 @@ static inline struct ni_660x_private *private(a4l_dev_t *dev) return (struct ni_660x_private*) dev->priv; } -/* initialized in ni_660x_find_device() */ +/* Initialized in ni_660x_find_device() */ static inline const struct ni_660x_board *board(a4l_dev_t *dev) { return ((struct ni_660x_private*)dev->priv)->board_ptr; @@ -534,10 +541,10 @@ static int ni_660x_GPCT_winsn( /* Possible instructions for Digital IO */ static int ni_660x_dio_insn_config( a4l_subd_t *s, - a4l_kinsn_t *insn); + a4l_kinsn_t *insn); static int ni_660x_dio_insn_bits( a4l_subd_t *s, -a4l_kinsn_t *insn); +a4l_kinsn_t *insn); static inline unsigned ni_660x_num_counters(a4l_dev_t *dev) { @@ -810,8 +817,8 @@ static inline unsigned ni_660x_read_register(a4l_dev_t *dev, return 0; } -static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits, - enum ni_gpct_register reg) +static void ni_gpct_write_register(struct ni_gpct *
[Xenomai-git] Alexis Berlemont : analogy: [ni_660x] replace spin_lock_* calls by al4_lock_* calls
Module: xenomai-head Branch: master Commit: d77eb4b661979010db0462b302ea8529a2877be8 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=d77eb4b661979010db0462b302ea8529a2877be8 Author: Alexis Berlemont Date: Tue Aug 30 00:22:58 2011 +0200 analogy: [ni_660x] replace spin_lock_* calls by al4_lock_* calls --- .../drivers/analogy/national_instruments/ni_660x.c | 82 ++-- 1 files changed, 25 insertions(+), 57 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/ni_660x.c b/ksrc/drivers/analogy/national_instruments/ni_660x.c index 777ce59..dec59dc 100644 --- a/ksrc/drivers/analogy/national_instruments/ni_660x.c +++ b/ksrc/drivers/analogy/national_instruments/ni_660x.c @@ -80,22 +80,11 @@ struct ni_660x_subd_priv { struct ni_gpct* counter; }; -#if 0 /* TODO: to be removed */ -static a4l_chdesc_t ni_660x_default_chan_desc = { - .mode = A4L_CHAN_GLOBAL_CHANDESC, - .length = 8, - .chans = { - {A4L_CHAN_AREF_GROUND, 1}, - }, -}; -#endif /* TODO: to be removed */ - - #define NUM_PFI_CHANNELS 40 -/* really there are only up to 3 dma channels, but the register layout allows for 4 */ +/* Really there are only up to 3 dma channels, but the register layout + allows for 4 */ #define MAX_DMA_CHANNEL 4 - static a4l_chdesc_t chandesc_ni660x = { .mode = A4L_CHAN_GLOBAL_CHANDESC, .length = NUM_PFI_CHANNELS, @@ -246,10 +235,10 @@ static inline unsigned NI_660X_GPCT_SUBDEV(unsigned index) struct NI_660xRegisterData { - const char *name; /* Register Name */ - int offset; /* Offset from base address from GPCT chip */ + const char *name; /* Register Name */ + int offset; /* Offset from base address from GPCT chip */ enum ni_660x_register_direction direction; - enum ni_660x_register_width size; /* 1 byte, 2 bytes, or 4 bytes */ + enum ni_660x_register_width size; /* 1 byte, 2 bytes, or 4 bytes */ }; static const struct NI_660xRegisterData registerData[NumRegisters] = { @@ -358,22 +347,6 @@ enum clock_config_register_bits { CounterSwap = 0x1 << 21 }; -static inline void set_hw_dev(a4l_dev_t *dev, - struct device *hw_dev) -{ - /* -* Is it REALLY needed ? -if (dev->hw_dev) -put_device(dev->hw_dev); - -dev->hw_dev = hw_dev; -if (dev->hw_dev) { -dev->hw_dev = get_device(dev->hw_dev); -BUG_ON(dev->hw_dev == NULL); -} -*/ -} - /* ioconfigreg */ static inline unsigned ioconfig_bitshift(unsigned pfi_channel) { @@ -496,19 +469,17 @@ static DEFINE_PCI_DEVICE_TABLE(ni_660x_pci_table) = { MODULE_DEVICE_TABLE(pci, ni_660x_pci_table); -/* TODO: replace spinlock_t by a4l_lock_t */ - struct ni_660x_private { struct mite_struct *mite; struct ni_gpct_device *counter_dev; uint64_t pfi_direction_bits; struct mite_dma_descriptor_ring *mite_rings[NI_660X_MAX_NUM_CHIPS][counters_per_chip]; - spinlock_t mite_channel_lock; + a4l_lock_t mite_channel_lock; /* interrupt_lock prevents races between interrupt and comedi_poll */ - spinlock_t interrupt_lock; + a4l_lock_t interrupt_lock; unsigned dma_configuration_soft_copies[NI_660X_MAX_NUM_CHIPS]; - spinlock_t soft_reg_copy_lock; + a4l_lock_t soft_reg_copy_lock; unsigned short pfi_output_selects[NUM_PFI_CHANNELS]; struct ni_660x_board *board_ptr; @@ -874,7 +845,7 @@ static inline void ni_660x_set_dma_channel(a4l_dev_t *dev, { unsigned long flags; - spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags); + a4l_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags); private(dev)->dma_configuration_soft_copies[counter->chip_index] &= ~dma_select_mask(mite_channel); private(dev)->dma_configuration_soft_copies[counter->chip_index] |= @@ -886,7 +857,7 @@ static inline void ni_660x_set_dma_channel(a4l_dev_t *dev, [counter->chip_index] | dma_reset_bit(mite_channel), DMAConfigRegister); mmiowb(); - spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags); + a4l_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags); } static inline void ni_660x_unset_dma_channel(a4l_dev_t *dev, @@ -894,7 +865,7 @@ static inline void ni_660x_unset_dma_channel(a4l_dev_t *dev, struct ni_gpct *counter) { unsigned long flags; - spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags); + a4l_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags); private(dev)->dma_configuration_soft_copies[counter->chip_in
[Xenomai-git] Alexis Berlemont : analogy: [pcimio] minor cosmetic change
Module: xenomai-head Branch: master Commit: 1c75fbe869db27b83bd09b93379d2fe6ff2d25bd URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=1c75fbe869db27b83bd09b93379d2fe6ff2d25bd Author: Alexis Berlemont Date: Tue Aug 30 00:23:33 2011 +0200 analogy: [pcimio] minor cosmetic change --- ksrc/drivers/analogy/national_instruments/pcimio.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/pcimio.c b/ksrc/drivers/analogy/national_instruments/pcimio.c index 24b5584..becc0a4 100644 --- a/ksrc/drivers/analogy/national_instruments/pcimio.c +++ b/ksrc/drivers/analogy/national_instruments/pcimio.c @@ -1543,8 +1543,8 @@ static int pcimio_attach(a4l_dev_t *dev, a4l_lnkdesc_t *arg) }else{ a4l_info(dev, "pcimio_attach: found irq %u\n", irq); ret = a4l_request_irq(dev, -irq, -a4l_ni_E_interrupt, A4L_IRQ_SHARED, dev); + irq, + a4l_ni_E_interrupt, A4L_IRQ_SHARED, dev); if(ret < 0) a4l_err(dev, "pcimio_attach: irq not available\n"); } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Anders Blomdell : analogy: [pcimio] fix wrong IRQ setup after reboot
Module: xenomai-head Branch: master Commit: 1d2d631a531568d3228ba6e642602f3d1cc10635 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=1d2d631a531568d3228ba6e642602f3d1cc10635 Author: Anders Blomdell Date: Tue Jun 28 23:56:27 2011 +0200 analogy: [pcimio] fix wrong IRQ setup after reboot --- ksrc/drivers/analogy/national_instruments/mite.c | 20 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mite.c b/ksrc/drivers/analogy/national_instruments/mite.c index d3969b0..a28295a 100644 --- a/ksrc/drivers/analogy/national_instruments/mite.c +++ b/ksrc/drivers/analogy/national_instruments/mite.c @@ -61,7 +61,7 @@ static struct pci_device_id mite_id[] = { static int mite_probe(struct pci_dev *dev, const struct pci_device_id *id) { - int i; + int i, err = 0; struct mite_struct *mite; mite = kmalloc(sizeof(struct mite_struct), GFP_KERNEL); @@ -71,7 +71,13 @@ static int mite_probe(struct pci_dev *dev, const struct pci_device_id *id) memset(mite, 0, sizeof(struct mite_struct)); a4l_lock_init(&mite->lock); + mite->pcidev = dev; + if (pci_enable_device(dev) < 0) { + __a4l_err("error enabling mite\n"); + err = -EIO; + goto out; + } for(i = 0; i < MAX_MITE_DMA_CHANNELS; i++) { mite->channels[i].mite = mite; @@ -81,7 +87,11 @@ static int mite_probe(struct pci_dev *dev, const struct pci_device_id *id) list_add(&mite->list, &mite_devices); - return 0; +out: + if (err < 0) + kfree(mite); + + return err; } static void mite_remove(struct pci_dev *dev) @@ -117,11 +127,6 @@ int a4l_mite_setup(struct mite_struct *mite, int use_iodwbsr_1) __a4l_dbg(1, drv_dbg, "mite: starting setup...\n"); - if(pci_enable_device(mite->pcidev)){ - __a4l_err("error enabling mite\n"); - return -EIO; - } - pci_set_master(mite->pcidev); if (pci_request_regions( mite->pcidev, "mite")) { @@ -129,7 +134,6 @@ int a4l_mite_setup(struct mite_struct *mite, int use_iodwbsr_1) return -EIO; }; - /* The PCI BAR0 is the Mite */ addr = pci_resource_start(mite->pcidev, 0); length = pci_resource_len(mite->pcidev, 0); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update cmd_read and cmd_write with a wake-count option
Module: xenomai-head Branch: master Commit: 94240ab0d426d359d73caa64e41802a8b4697130 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=94240ab0d426d359d73caa64e41802a8b4697130 Author: Alexis Berlemont Date: Tue May 10 23:55:29 2011 +0200 analogy: update cmd_read and cmd_write with a wake-count option --- src/utils/analogy/cmd_read.c | 22 +- src/utils/analogy/cmd_write.c | 32 +--- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c index e23bf9b..ff8bb48 100644 --- a/src/utils/analogy/cmd_read.c +++ b/src/utils/analogy/cmd_read.c @@ -54,6 +54,7 @@ static unsigned int chans[MAX_NB_CHAN]; static int verbose = 0; static int real_time = 0; static int use_mmap = 0; +static unsigned long wake_count = 0; static RT_TASK rt_task_desc; @@ -84,6 +85,7 @@ struct option cmd_read_opts[] = { {"channels", required_argument, NULL, 'c'}, {"mmap", no_argument, NULL, 'm'}, {"raw", no_argument, NULL, 'w'}, + {"wake-count", required_argument, NULL, 'k'}, {"help", no_argument, NULL, 'h'}, {0}, }; @@ -101,6 +103,9 @@ void do_print_usage(void) 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 -k, --wake-count: " + "space available before waking up the process\n"); fprintf(stdout, "\t\t -h, --help: print this help\n"); } @@ -193,7 +198,8 @@ int main(int argc, char *argv[]) /* Compute arguments */ while ((ret = getopt_long(argc, argv, - "vrd:s:S:c:mwh", cmd_read_opts, NULL)) >= 0) { + "vrd:s:S:c:mwk:h", + cmd_read_opts, NULL)) >= 0) { switch (ret) { case 'v': verbose = 1; @@ -219,6 +225,9 @@ int main(int argc, char *argv[]) case 'w': dump_function = dump_raw; break; + case 'k': + wake_count = strtoul(optarg, NULL, 0); + break; case 'h': default: do_print_usage(); @@ -368,6 +377,17 @@ int main(int argc, char *argv[]) map); } + ret = a4l_set_wakesize(&dsc, wake_count); + if (ret < 0) { + fprintf(stderr, + "cmd_read: a4l_set_wakesize failed (ret=%d)\n", ret); + goto out_main; + } + + if (verbose != 0) + printf("cmd_read: wake size successfully set (%lu)\n", + wake_count); + /* Send the command to the input device */ ret = a4l_snd_command(&dsc, &cmd); if (ret < 0) { diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c index 43926fd..453c033 100644 --- a/src/utils/analogy/cmd_write.c +++ b/src/utils/analogy/cmd_write.c @@ -44,7 +44,8 @@ struct config { unsigned int *chans; int chans_count; char *str_ranges; - int scans_count; + unsigned long scans_count; + unsigned long wake_count; char *filename; FILE *input; @@ -70,6 +71,7 @@ struct option options[] = { {"scans-count", required_argument, NULL, 'S'}, {"channels", required_argument, NULL, 'c'}, {"range", required_argument, NULL, 'c'}, + {"wake-count", required_argument, NULL, 'k'}, {"help", no_argument, NULL, 'h'}, {0}, }; @@ -84,11 +86,15 @@ void print_usage(void) fprintf(stdout, "\t\t -s, --subdevice: subdevice index\n"); fprintf(stdout, "\t\t -S, --scans-count: count of scan to perform\n"); fprintf(stdout, - "\t\t -c, --channels: channels to use " - " (ex.: -c 0,1)\n"); + "\t\t -c, --channels: " + "channels to use (ex.: -c 0,1)\n"); fprintf(stdout, - "\t\t -R, --range: range to use " - " (ex.: -R 0,1,V)\n"); + "\t\t -R, --range: " + "range to use (ex.: -R 0,1,V)\n"); + fprintf(stdout, + "\t\t -k, --wake-count: " + "space available before waking up the process\n"); + fprintf(stdout, "\t\t -h, --help: print this help\n"); } @@ -242,7 +248,8 @@ void print_config(struct config *cfg) printf("\tSubdevice index: %d\n", cfg->subd); printf("\tSelected channels: %s\n", cfg->str_chans); printf("\tSelected range: %s\n", cfg->str_ranges); - printf("\tScans count: %d\n", cfg->scans_count); + printf("\tScans count: %lu\n", cfg->scans_count); + printf("\tWake count:
[Xenomai-git] Alexis Berlemont : analogy: add signal injection in the cmd_write tool
Module: xenomai-head Branch: master Commit: 4dc31cbcfd8f426644112ec566f5a928488fa58c URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=4dc31cbcfd8f426644112ec566f5a928488fa58c Author: Alexis Berlemont Date: Sun Apr 24 19:41:56 2011 +0200 analogy: add signal injection in the cmd_write tool --- src/utils/analogy/Makefile.am|7 - src/utils/analogy/cmd_write.c| 707 +- src/utils/analogy/wf_cmd_write.c | 501 --- src/utils/analogy/wf_generate.c |3 +- 4 files changed, 401 insertions(+), 817 deletions(-) diff --git a/src/utils/analogy/Makefile.am b/src/utils/analogy/Makefile.am index a2c3e96..8e7734f 100644 --- a/src/utils/analogy/Makefile.am +++ b/src/utils/analogy/Makefile.am @@ -3,7 +3,6 @@ sbin_PROGRAMS = analogy_config bin_PROGRAMS = \ cmd_read \ cmd_write \ - wf_cmd_write \ cmd_bits \ insn_read \ insn_write \ @@ -43,12 +42,6 @@ cmd_write_LDADD = \ ../../skins/rtdm/librtdm.la \ ../../skins/common/libxenomai.la -wf_cmd_write_SOURCES = wf_cmd_write.c -wf_cmd_write_LDADD = \ - ../../drvlib/analogy/libanalogy.la \ - ../../skins/rtdm/librtdm.la \ - ../../skins/common/libxenomai.la - cmd_bits_SOURCES = cmd_bits.c cmd_bits_LDADD = \ ../../drvlib/analogy/libanalogy.la \ diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c index 3b3f1ab..43926fd 100644 --- a/src/utils/analogy/cmd_write.c +++ b/src/utils/analogy/cmd_write.c @@ -28,74 +28,53 @@ #include #include -#include - #include -/* Default command's parameters */ - -/* For write operation, we consider - the default subdevice index is 1 */ -#define ID_SUBD 1 -/* For simplicity sake, a maximum channel - count is defined */ -#define MAX_NB_CHAN 10 -/* Four channels used by default */ -#define NB_CHAN 4 -/* One hundred triggered scans by default */ -#define NB_SCAN 100 - -#define FILENAME "analogy0" - -#define BUF_SIZE 1 - -static unsigned char buf[BUF_SIZE]; -static char *filename = FILENAME; -static char *str_chans = "0,1"; -static unsigned int chans[MAX_NB_CHAN]; -static int verbose = 0; -static int real_time = 0; -static int use_mmap = 0; - -static RT_TASK rt_task_desc; - -/* The command to send by default */ -a4l_cmd_t cmd = { - .idx_subd = ID_SUBD, - .flags = 0, - .start_src = TRIG_INT, - .start_arg = 0, - .scan_begin_src = TRIG_TIMER, - .scan_begin_arg = 200, /* in ns */ - .convert_src = TRIG_NOW, - .convert_arg = 0, /* in ns */ - .scan_end_src = TRIG_COUNT, - .scan_end_arg = 0, - .stop_src = TRIG_COUNT, - .stop_arg = NB_SCAN, - .nb_chan = 0, - .chan_descs = chans, -}; +#define BUFFER_DEPTH 1024 + +struct config { + + /* Configuration parameters + TODO: add real_time and use_mmap*/ + + int verbose; + + int subd; + char *str_chans; + unsigned int *chans; + int chans_count; + char *str_ranges; + int scans_count; + + char *filename; + FILE *input; + + /* Analogy stuff */ + + a4l_desc_t dsc; + a4l_chinfo_t *cinfo; + a4l_rnginfo_t *rinfo; + + /* Buffer stuff + TODO: add buffer depth / size (useful for mmap) */ + void *buffer; -a4l_insn_t insn = { - .type = A4L_INSN_INTTRIG, - .idx_subd = ID_SUBD, - .data_size = 0, }; -struct option cmd_write_opts[] = { +/* --- Options / arguments part --- */ + +struct option options[] = { {"verbose", no_argument, NULL, 'v'}, - {"real-time", no_argument, NULL, 'r'}, {"device", required_argument, NULL, 'd'}, {"subdevice", required_argument, NULL, 's'}, - {"scan-count", required_argument, NULL, 'S'}, + {"scans-count", required_argument, NULL, 'S'}, {"channels", required_argument, NULL, 'c'}, - {"mmap", no_argument, NULL, 'm'}, + {"range", required_argument, NULL, 'c'}, {"help", no_argument, NULL, 'h'}, {0}, }; -void do_print_usage(void) +void print_usage(void) { fprintf(stdout, "usage:\tcmd_write [OPTS]\n"); fprintf(stdout, "\tOPTS:\t -v, --verbose: verbose output\n"); @@ -103,305 +82,419 @@ void do_print_usage(void) "\t\t -d, --device: " "device filename (analogy0, analogy1, ...)\n"); fprintf(stdout, "\t\t -s, --subdevice: subdevice index\n"); - 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 -S, --scans-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 -R, --range: range to use " +
[Xenomai-git] Alexis Berlemont : analogy: implement the configuration of a wake-up threshold
Module: xenomai-head Branch: master Commit: 8bf74e38c75947251ca95c6f53958c8e4a9b49af URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=8bf74e38c75947251ca95c6f53958c8e4a9b49af Author: Alexis Berlemont Date: Tue May 10 23:54:25 2011 +0200 analogy: implement the configuration of a wake-up threshold Two functions are now available to define a wake-up threshold. a4l_set/get_wakesize() allows the developer to define the minimal data amount needed to wake-up a sleeping process (waiting for an event during an asynchronous acquisition). --- include/analogy/analogy.h | 80 -- include/analogy/buffer.h | 23 + include/analogy/ioctl.h |7 ++- ksrc/drivers/analogy/buffer.c | 86 +--- ksrc/drivers/analogy/rtdm_interface.c |8 ++- src/drvlib/analogy/async.c| 31 6 files changed, 185 insertions(+), 50 deletions(-) diff --git a/include/analogy/analogy.h b/include/analogy/analogy.h index 15736a8..6a81674 100644 --- a/include/analogy/analogy.h +++ b/include/analogy/analogy.h @@ -43,22 +43,22 @@ int a4l_sys_read(int fd, void *buf, size_t nbyte); int a4l_sys_write(int fd, void *buf, size_t nbyte); -int a4l_sys_attach(int fd, a4l_lnkdesc_t * arg); +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_desc(int fd, a4l_desc_t *dsc, int pass); -int a4l_sys_devinfo(int fd, a4l_dvinfo_t * info); +int a4l_sys_devinfo(int fd, a4l_dvinfo_t *info); -int a4l_sys_subdinfo(int fd, a4l_sbinfo_t * info); +int a4l_sys_subdinfo(int fd, a4l_sbinfo_t *info); int a4l_sys_nbchaninfo(int fd, unsigned int idx_subd, unsigned int *nb); -int a4l_sys_chaninfo(int fd, -unsigned int idx_subd, a4l_chinfo_t * info); +int a4l_sys_chaninfo(int fd, +unsigned int idx_subd, a4l_chinfo_t *info); int a4l_sys_nbrnginfo(int fd, unsigned int idx_subd, @@ -66,7 +66,7 @@ int a4l_sys_nbrnginfo(int fd, int a4l_sys_rnginfo(int fd, unsigned int idx_subd, - unsigned int idx_chan, a4l_rnginfo_t * info); + unsigned int idx_chan, a4l_rnginfo_t *info); /* --- Level 1 API (supposed to be used) --- */ @@ -92,83 +92,87 @@ int a4l_get_chinfo(a4l_desc_t *dsc, int a4l_get_rnginfo(a4l_desc_t *dsc, unsigned int subd, unsigned int chan, - unsigned int rng, a4l_rnginfo_t ** info); + unsigned int rng, a4l_rnginfo_t **info); #define a4l_is_rng_global(x) ((x)->flags & A4L_RNG_GLOBAL) -int a4l_snd_command(a4l_desc_t * dsc, a4l_cmd_t *cmd); +int a4l_snd_command(a4l_desc_t *dsc, a4l_cmd_t *cmd); + +int a4l_snd_cancel(a4l_desc_t *dsc, unsigned int idx_subd); -int a4l_snd_cancel(a4l_desc_t * dsc, unsigned int idx_subd); - -int a4l_set_bufsize(a4l_desc_t * dsc, +int a4l_set_bufsize(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long size); -int a4l_get_bufsize(a4l_desc_t * dsc, +int a4l_get_bufsize(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long *size); -int a4l_mark_bufrw(a4l_desc_t * dsc, +int a4l_set_wakesize(a4l_desc_t *dsc, unsigned long size); + +int a4l_get_wakesize(a4l_desc_t *dsc, unsigned long *size); + +int a4l_mark_bufrw(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long cur, unsigned long *newp); -int a4l_poll(a4l_desc_t * dsc, +int a4l_poll(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long ms_timeout); - -int a4l_mmap(a4l_desc_t * dsc, + +int a4l_mmap(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long size, void **ptr); -int a4l_async_read(a4l_desc_t * dsc, +int a4l_async_read(a4l_desc_t *dsc, void *buf, size_t nbyte, unsigned long ms_timeout); -int a4l_async_write(a4l_desc_t * dsc, +int a4l_async_write(a4l_desc_t *dsc, void *buf, size_t nbyte, unsigned long ms_timeout); -int a4l_snd_insnlist(a4l_desc_t * dsc, a4l_insnlst_t * arg); +int a4l_snd_insnlist(a4l_desc_t *dsc, a4l_insnlst_t *arg); -int a4l_snd_insn(a4l_desc_t * dsc, a4l_insn_t *arg); +int a4l_snd_insn(a4l_desc_t *dsc, a4l_insn_t *arg); /* --- Level 2 API (supposed to be used) --- */ -int a4l_sync_write(a4l_desc_t * dsc, +int a4l_sync_write(a4l_desc_t *dsc, unsigned int idx_subd, unsigned int chan_desc, unsigned int delay, void *buf, size_t nbyte); - -int a4l_sync_read(a4l_desc_t * dsc, + +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_config_subd(a4l_desc_t * dsc, +int a
[Xenomai-git] Alexis Berlemont : analogy: minor change in the test program wf_cmd_write
Module: xenomai-head Branch: master Commit: 5fb511b4947e61f42cc1d260695d99bdc0ee2d96 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=5fb511b4947e61f42cc1d260695d99bdc0ee2d96 Author: Alexis Berlemont Date: Fri Apr 22 22:02:43 2011 +0200 analogy: minor change in the test program wf_cmd_write --- src/utils/analogy/wf_cmd_write.c | 58 ++--- 1 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/utils/analogy/wf_cmd_write.c b/src/utils/analogy/wf_cmd_write.c index 6a4d507..05ac08a 100644 --- a/src/utils/analogy/wf_cmd_write.c +++ b/src/utils/analogy/wf_cmd_write.c @@ -296,13 +296,6 @@ int init_config(struct config *cfg, int argc, char *argv[]) }; } - /* If stdin is a terminal, we will not be able to read binary - data from it */ - if (isatty(fileno(cfg->input))) { - fprintf(stderr, "cmd_write: stdin cannot be a terminal\n"); - return -EINVAL; - } - /* Open the analogy device and retrieve pointers on the info structures */ err = init_dsc_config(cfg); @@ -336,6 +329,14 @@ int init_config(struct config *cfg, int argc, char *argv[]) fprintf(stderr, "cmd_write: malloc failed\n"); goto out; } + + /* If stdin is a terminal, we will not be able to read binary + data from it */ + if (isatty(fileno(cfg->input))) { + memset(cfg->buffer, 0, BUFFER_DEPTH * scan_size); + cfg->input = NULL; + } else + cfg->input = stdin; out: @@ -345,9 +346,9 @@ out: return err; } -/* --- Processing functions --- */ +/* --- Input management part --- */ -int process_stdin(struct config *cfg) +int process_input(struct config *cfg) { int err = 0, filled = 0; @@ -357,7 +358,6 @@ int process_stdin(struct config *cfg) int scan_size = cfg->chans_count * chan_size; while (filled < BUFFER_DEPTH) { - int i; double value; char tmp[128]; @@ -395,18 +395,29 @@ int process_stdin(struct config *cfg) out: - if (err >= 0 && filled) { + return err < 0 ? err : filled; +} + +/* --- Acquisition related stuff --- */ +int run_acquisition(struct config *cfg) +{ + int err = 0; + + /* The return value of a4l_sizeof_chan() was already + controlled in init_config so no need to do it twice */ + int chan_size = a4l_sizeof_chan(cfg->cinfo); + int scan_size = cfg->chans_count * chan_size; + + + err = cfg->input ? process_input(cfg) : BUFFER_DEPTH; + if (err > 0) err = a4l_async_write(&cfg->dsc, cfg->buffer, - filled * scan_size, A4L_INFINITE); - if (err < 0) - fprintf(stderr, - "cmd_write: a4l_async_write failed (err=%d)\n", - err); - } else if (err >= 0 && !filled) + err * scan_size, A4L_INFINITE); + else if (err == 0) err = -ENOENT; - + return err < 0 ? err : 0; } @@ -425,7 +436,7 @@ int init_acquisition(struct config *cfg) .convert_arg = 0, .scan_end_src = TRIG_COUNT, .scan_end_arg = cfg->chans_count, - .stop_src = TRIG_COUNT, + .stop_src = cfg->scans_count ? TRIG_COUNT : TRIG_NONE, .stop_arg = cfg->scans_count, .nb_chan = cfg->chans_count, .chan_descs = cfg->chans @@ -449,13 +460,12 @@ int init_acquisition(struct config *cfg) goto out; } - /* Fill the asynchronous buffer with data - TODO: the amount of data to be prefilled should be configured */ - err = process_stdin(cfg); + /* Fill the asynchronous buffer with data... */ + err = run_acquisition(cfg); if (err < 0) goto out; - /* Trigger the start of the output device feeding */ + /* ...before triggering the start of the output device feeding */ err = a4l_snd_insn(&cfg->dsc, &insn); out: @@ -478,7 +488,7 @@ int main(int argc, char *argv[]) if (err < 0) goto out; - while ((err = process_stdin(&cfg)) == 0); + while ((err = run_acquisition(&cfg)) == 0); err = (err == -ENOENT) ? 0 : err; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: minor cosmetic changes in wf_facilities.c
Module: xenomai-head Branch: master Commit: eb7814cf5aa9c1fb07ed7b7fcc8049d5dc67cc42 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=eb7814cf5aa9c1fb07ed7b7fcc8049d5dc67cc42 Author: Alexis Berlemont Date: Sun Mar 6 00:53:03 2011 +0100 analogy: minor cosmetic changes in wf_facilities.c --- src/utils/analogy/wf_facilities.c | 15 +-- 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils/analogy/wf_facilities.c b/src/utils/analogy/wf_facilities.c index 08d105e..dd2d29f 100644 --- a/src/utils/analogy/wf_facilities.c +++ b/src/utils/analogy/wf_facilities.c @@ -109,8 +109,9 @@ void a4l_wf_set_sample_count(struct waveform_config *config) } if (lowest_diff != 0) { - printf("Warning: unable to create a contiguous signal\n"); - printf("Warning: an approximation is performed\n"); + fprintf(stderr, + "Warning: unable to create a contiguous signal\n"); + fprintf(stderr, "Warning: an approximation is performed\n"); } config->spl_count = best_count; @@ -120,11 +121,13 @@ int a4l_wf_check_config(struct waveform_config *config) { if (config->wf_amplitude == 0) - printf("Warning: the signal will be constant\n"); + fprintf(stderr, "Warning: the signal will be constant\n"); if (config->wf_frequency * 2 > config->spl_frequency) { - printf("Error: the sampling frequency is not correct\n"); - printf("Error: sampling frequency >= 2 * signal frequency\n"); + fprintf(stderr, + "Error: the sampling frequency is not correct\n"); + fprintf(stderr, + "Error: sampling frequency >= 2 * signal frequency\n"); return -EINVAL; } @@ -150,6 +153,6 @@ void a4l_wf_dump_values(struct waveform_config *config, double *values) int i; for (i = 0; i < config->spl_count; i++) - printf("%f\n", values[i]); + fprintf(stderr, "%f\n", values[i]); } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: various basic bug fixes in wf_cmd_write
Module: xenomai-head Branch: master Commit: 3dcd59977e502b01cc81c363e49ee751d2f00603 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=3dcd59977e502b01cc81c363e49ee751d2f00603 Author: Alexis Berlemont Date: Sun Mar 6 00:51:46 2011 +0100 analogy: various basic bug fixes in wf_cmd_write - Properly set the default ranges values - Fix return code after reading stdin data - Wait 1s after writing the data and before leaving --- src/utils/analogy/wf_cmd_write.c | 22 +++--- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/utils/analogy/wf_cmd_write.c b/src/utils/analogy/wf_cmd_write.c index 38e0c29..6a4d507 100644 --- a/src/utils/analogy/wf_cmd_write.c +++ b/src/utils/analogy/wf_cmd_write.c @@ -263,7 +263,7 @@ int init_config(struct config *cfg, int argc, char *argv[]) memset(cfg, 0, sizeof(struct config)); cfg->str_chans = "0,1"; - cfg->str_chans = "0,5,V"; + cfg->str_ranges = "0,5,V"; cfg->filename = "analogy0"; cfg->input = stdin; cfg->dsc.fd = -1; @@ -364,8 +364,9 @@ int process_stdin(struct config *cfg) /* Data from stdin are supposed to be double values coming from wf_generate... */ + err = fread(&value, sizeof(double), 1, cfg->input); - if (err != 0 && !feof(cfg->input)) { + if (err != 1 && !feof(cfg->input)) { err = -errno; fprintf(stderr, "cmd_write: stdin IO error (err=%d)\n", err); @@ -392,7 +393,10 @@ int process_stdin(struct config *cfg) filled ++; } - if (filled) { +out: + + if (err >= 0 && filled) { + err = a4l_async_write(&cfg->dsc, cfg->buffer, filled * scan_size, A4L_INFINITE); @@ -400,10 +404,10 @@ int process_stdin(struct config *cfg) fprintf(stderr, "cmd_write: a4l_async_write failed (err=%d)\n", err); - } + } else if (err >= 0 && !filled) + err = -ENOENT; -out: - return err; + return err < 0 ? err : 0; } int init_acquisition(struct config *cfg) @@ -476,8 +480,12 @@ int main(int argc, char *argv[]) while ((err = process_stdin(&cfg)) == 0); + err = (err == -ENOENT) ? 0 : err; + + sleep(1); + out: cleanup_config(&cfg); - return err; + return err < 0 ? 1 : 0; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [fake] fix synchronization bugs at cancel time
Module: xenomai-head Branch: master Commit: b609f26fda1eb43ba2af0e3e41f979cb9e4fa1bc URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=b609f26fda1eb43ba2af0e3e41f979cb9e4fa1bc Author: Alexis Berlemont Date: Fri Apr 22 22:01:27 2011 +0200 analogy: [fake] fix synchronization bugs at cancel time --- ksrc/drivers/analogy/testing/fake.c | 40 +++--- 1 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ksrc/drivers/analogy/testing/fake.c b/ksrc/drivers/analogy/testing/fake.c index d82abb0..8d613db 100644 --- a/ksrc/drivers/analogy/testing/fake.c +++ b/ksrc/drivers/analogy/testing/fake.c @@ -91,9 +91,9 @@ static a4l_cmd_t ai_cmd_mask = { .idx_subd = 0, .start_src = TRIG_NOW, .scan_begin_src = TRIG_TIMER, - .convert_src = TRIG_NOW|TRIG_TIMER, + .convert_src = TRIG_NOW | TRIG_TIMER, .scan_end_src = TRIG_COUNT, - .stop_src = TRIG_COUNT|TRIG_NONE, + .stop_src = TRIG_COUNT | TRIG_NONE, }; static a4l_cmd_t ao_cmd_mask = { @@ -102,7 +102,7 @@ static a4l_cmd_t ao_cmd_mask = { .scan_begin_src = TRIG_TIMER, .convert_src = TRIG_NOW | TRIG_TIMER, .scan_end_src = TRIG_COUNT, - .stop_src = TRIG_COUNT| TRIG_NONE, + .stop_src = TRIG_COUNT | TRIG_NONE, }; /* --- Analog input simulation --- */ @@ -203,16 +203,21 @@ int ai2_push_values(a4l_subd_t *subd) int err = 0; if (priv->count) { + err = a4l_buf_put(subd, priv->buffer, priv->count); + + /* If there is no more place in the asynchronous + buffer, data are likely to be dropped; it is just a + test driver so no need to implement trickier mechanism */ + err = (err == -EAGAIN) ? 0 : err; + priv->count = 0; + if (err < 0) a4l_err(subd->dev, "ai2_push_values: " "a4l_buf_put failed (err=%d)\n", err); - else { - priv->count = 0; + else a4l_buf_evt(subd, 0); - } - } return err; @@ -244,7 +249,6 @@ static void task_proc(void *arg) if (running && ao_pull_values(ao_subd) < 0) break; - RTDM_EXECUTE_ATOMICALLY(running = priv->ai2_running); if (running && ai2_push_values(ai2_subd) < 0) break; @@ -253,7 +257,6 @@ static void task_proc(void *arg) } } - /* --- Asynchronous AI functions --- */ static int ai_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) @@ -332,6 +335,7 @@ int ao_trigger(a4l_subd_t *subd, lsampl_t trignum) int ao_cancel(a4l_subd_t *subd) { struct fake_priv *priv = (struct fake_priv *)subd->dev->priv; + struct ao_ai2_priv *ao_priv = (struct ao_ai2_priv *)subd->priv; int running; a4l_info(subd->dev, "ao_cancel: (subd=%d)\n", subd->idx); @@ -344,6 +348,8 @@ int ao_cancel(a4l_subd_t *subd) /* Here, we have not saved the required amount of data; so, we cannot know whether or not, it is the end of the acquisition; that is why we force it */ + RTDM_EXECUTE_ATOMICALLY(priv->ai2_running = 0); + RTDM_EXECUTE_ATOMICALLY(ao_priv->count = 0); a4l_buf_evt(ai2_subd, A4L_BUF_EOA); } @@ -364,9 +370,25 @@ int ai2_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) int ai2_cancel(a4l_subd_t *subd) { struct fake_priv *priv = (struct fake_priv *)subd->dev->priv; + struct ao_ai2_priv *ai2_priv = *((struct ao_ai2_priv **)subd->priv); + + int running; a4l_info(subd->dev, "ai2_cancel: (subd=%d)\n", subd->idx); RTDM_EXECUTE_ATOMICALLY(priv->ai2_running = 0); + + RTDM_EXECUTE_ATOMICALLY(running = priv->ao_running); + if (running) { + a4l_subd_t *ao_subd = + (a4l_subd_t *)a4l_get_subd(subd->dev, AO_SUBD); + /* Here, we have not saved the required amount of + data; so, we cannot know whether or not, it is the + end of the acquisition; that is why we force it */ + RTDM_EXECUTE_ATOMICALLY(priv->ao_running = 0); + RTDM_EXECUTE_ATOMICALLY(ai2_priv->count = 0); + a4l_buf_evt(ao_subd, A4L_BUF_EOA); + } + return 0; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: minor change in cmd_read.c
Module: xenomai-head Branch: master Commit: d27c4dc74bf5a3bb20dc4c0a6e62e621778623af URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=d27c4dc74bf5a3bb20dc4c0a6e62e621778623af Author: Alexis Berlemont Date: Sun Mar 6 00:46:37 2011 +0100 analogy: minor change in cmd_read.c Flush log traces of acquired data --- src/utils/analogy/cmd_read.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c index 2d2060a..e23bf9b 100644 --- a/src/utils/analogy/cmd_read.c +++ b/src/utils/analogy/cmd_read.c @@ -173,6 +173,8 @@ int dump_text(a4l_desc_t *dsc, a4l_cmd_t *cmd, unsigned char *buf, int size) } } + fflush(stdout); + out: return err; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [fake] correctly manage EOA events for loop subdevices
Module: xenomai-head Branch: master Commit: 6cb7b46bd08ac5488e96970b0a2918c1f3c72ddc URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=6cb7b46bd08ac5488e96970b0a2918c1f3c72ddc Author: Alexis Berlemont Date: Sun Mar 6 00:44:39 2011 +0100 analogy: [fake] correctly manage EOA events for loop subdevices --- ksrc/drivers/analogy/testing/fake.c | 20 +--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ksrc/drivers/analogy/testing/fake.c b/ksrc/drivers/analogy/testing/fake.c index d8f8cda..d82abb0 100644 --- a/ksrc/drivers/analogy/testing/fake.c +++ b/ksrc/drivers/analogy/testing/fake.c @@ -208,10 +208,12 @@ int ai2_push_values(a4l_subd_t *subd) a4l_err(subd->dev, "ai2_push_values: " "a4l_buf_put failed (err=%d)\n", err); - } + else { + priv->count = 0; + a4l_buf_evt(subd, 0); + } - if (priv->count) - a4l_buf_evt(subd, 0); + } return err; } @@ -330,9 +332,21 @@ int ao_trigger(a4l_subd_t *subd, lsampl_t trignum) int ao_cancel(a4l_subd_t *subd) { struct fake_priv *priv = (struct fake_priv *)subd->dev->priv; + int running; a4l_info(subd->dev, "ao_cancel: (subd=%d)\n", subd->idx); RTDM_EXECUTE_ATOMICALLY(priv->ao_running = 0); + + RTDM_EXECUTE_ATOMICALLY(running = priv->ai2_running); + if (running) { + a4l_subd_t *ai2_subd = + (a4l_subd_t *)a4l_get_subd(subd->dev, AI2_SUBD); + /* Here, we have not saved the required amount of + data; so, we cannot know whether or not, it is the + end of the acquisition; that is why we force it */ + a4l_buf_evt(ai2_subd, A4L_BUF_EOA); + } + return 0; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [loop] remove the driver
Module: xenomai-head Branch: master Commit: 4f0946ee8abc2396ee950528c2e03ba487ec53bc URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=4f0946ee8abc2396ee950528c2e03ba487ec53bc Author: Alexis Berlemont Date: Sun Jan 30 23:38:03 2011 +0100 analogy: [loop] remove the driver The loop subdevices (what is written into the output subdevice is read from the input subdevice) have been added into the fake driver. --- ksrc/drivers/analogy/testing/Config.in |1 - ksrc/drivers/analogy/testing/Kconfig | 11 +- ksrc/drivers/analogy/testing/Makefile | 11 +- ksrc/drivers/analogy/testing/loop.c| 287 4 files changed, 8 insertions(+), 302 deletions(-) diff --git a/ksrc/drivers/analogy/testing/Config.in b/ksrc/drivers/analogy/testing/Config.in index f4abecf..db5acf4 100644 --- a/ksrc/drivers/analogy/testing/Config.in +++ b/ksrc/drivers/analogy/testing/Config.in @@ -5,4 +5,3 @@ dep_tristate 'Fake driver' CONFIG_XENO_DRIVERS_ANALOGY_FAKE $CONFIG_XENO_DRIVERS_ANALOGY -dep_tristate 'Loop driver' CONFIG_XENO_DRIVERS_ANALOGY_LOOP $CONFIG_XENO_DRIVERS_ANALOGY diff --git a/ksrc/drivers/analogy/testing/Kconfig b/ksrc/drivers/analogy/testing/Kconfig index fd1e73a..15db782 100644 --- a/ksrc/drivers/analogy/testing/Kconfig +++ b/ksrc/drivers/analogy/testing/Kconfig @@ -3,8 +3,11 @@ config XENO_DRIVERS_ANALOGY_FAKE depends on XENO_DRIVERS_ANALOGY tristate "Fake driver" default n + help -config XENO_DRIVERS_ANALOGY_LOOP - depends on XENO_DRIVERS_ANALOGY - tristate "Loop driver" - default n + The fake driver displays many subdevices: + - 0: analog input; + - 1: digital input / output; + - 2: analog output; + - 3: analog input; data written into the subdevice 2 can be + read here. diff --git a/ksrc/drivers/analogy/testing/Makefile b/ksrc/drivers/analogy/testing/Makefile index cb38daa..311256a 100644 --- a/ksrc/drivers/analogy/testing/Makefile +++ b/ksrc/drivers/analogy/testing/Makefile @@ -5,12 +5,9 @@ ifeq ($(PATCHLEVEL),6) EXTRA_CFLAGS += -D__IN_XENOMAI__ -Iinclude/xenomai obj-$(CONFIG_XENO_DRIVERS_ANALOGY_FAKE) += analogy_fake.o -obj-$(CONFIG_XENO_DRIVERS_ANALOGY_LOOP) += analogy_loop.o analogy_fake-y := fake.o -analogy_loop-y := loop.o - else # Makefile frag for Linux v2.4 @@ -18,13 +15,10 @@ else O_TARGET := built-in.o obj-$(CONFIG_XENO_DRIVERS_ANALOGY_FAKE) += analogy_fake.o -obj-$(CONFIG_XENO_DRIVERS_ANALOGY_LOOP) += analogy_loop.o analogy_fake-objs := fake.o -analogy_loop-objs := loop.o - -export-objs := $(analogy_fake-objs) $(analogy_loop-objs) +export-objs := $(analogy_fake-objs) EXTRA_CFLAGS += -D__IN_XENOMAI__ -I$(TOPDIR)/include/xenomai -I$(TOPDIR)/include/xenomai/compat @@ -33,7 +27,4 @@ include $(TOPDIR)/Rules.make analogy_fake.o: $(analogy_fake-objs) $(LD) -r -o $@ $(analogy_fake-objs) -analogy_loop.o: $(analogy_loop-objs) - $(LD) -r -o $@ $(analogy_loop-objs) - endif diff --git a/ksrc/drivers/analogy/testing/loop.c b/ksrc/drivers/analogy/testing/loop.c deleted file mode 100644 index 709f0cf..000 --- a/ksrc/drivers/analogy/testing/loop.c +++ /dev/null @@ -1,287 +0,0 @@ -#include -#include - -#define LOOP_TASK_PERIOD 100 -#define LOOP_NB_BITS 16 - -#define LOOP_INPUT_SUBD 0 -#define LOOP_OUTPUT_SUBD 1 - -/* Channels descriptor */ -static a4l_chdesc_t loop_chandesc = { - .mode = A4L_CHAN_GLOBAL_CHANDESC, - .length = 8, - .chans = { - {A4L_CHAN_AREF_GROUND, LOOP_NB_BITS}, - }, -}; - -/* Ranges tab */ -static a4l_rngtab_t loop_rngtab = { - .length = 2, - .rngs = { - RANGE_V(-5,5), - RANGE_V(-10,10), - }, -}; -/* Ranges descriptor */ -a4l_rngdesc_t loop_rngdesc = RNG_GLOBAL(loop_rngtab); - -/* Command options mask */ -static a4l_cmd_t loop_cmd_mask = { - .idx_subd = 0, - .start_src = TRIG_NOW | TRIG_INT, - .scan_begin_src = TRIG_TIMER, - .convert_src = TRIG_NOW | TRIG_TIMER, - .scan_end_src = TRIG_COUNT, - .stop_src = TRIG_COUNT| TRIG_NONE, -}; - -/* Private data organization */ -struct loop_priv { - - /* Task descriptor */ - a4l_task_t loop_task; - - /* Misc fields */ - int loop_running; - uint16_t loop_insn_value; -}; -typedef struct loop_priv lpprv_t; - -/* Attach arguments contents */ -struct loop_attach_arg { - unsigned long period; -}; -typedef struct loop_attach_arg lpattr_t; - -static void loop_task_proc(void *arg); - -/* --- Task part --- */ - -/* Timer task routine */ -static void loop_task_proc(void *arg) -{ - a4l_dev_t *dev = (a4l_dev_t*)arg; - a4l_subd_t *input_subd, *output_subd; - lpprv_t *priv = (lpprv_t *)dev->priv; - - input_subd = a4l_get_subd(dev, LOOP_INPUT_SUBD); - output_subd = a4l_get_subd(dev, LOOP_OUTPUT_SUBD); - - if (input_subd == NULL || output_subd == NULL) { - a4l_err(dev
[Xenomai-git] Alexis Berlemont : analogy: [fake] add instruction callbacks for the loop subdevices
Module: xenomai-head Branch: master Commit: dfb1bd25c5311e8f5a1fc30fc98531631006e945 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=dfb1bd25c5311e8f5a1fc30fc98531631006e945 Author: Alexis Berlemont Date: Sun Jan 30 22:59:10 2011 +0100 analogy: [fake] add instruction callbacks for the loop subdevices --- ksrc/drivers/analogy/testing/fake.c | 37 +++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/ksrc/drivers/analogy/testing/fake.c b/ksrc/drivers/analogy/testing/fake.c index 4a8ce5a..d8f8cda 100644 --- a/ksrc/drivers/analogy/testing/fake.c +++ b/ksrc/drivers/analogy/testing/fake.c @@ -42,8 +42,11 @@ struct ai_priv { }; struct ao_ai2_priv { + /* Asynchronous loop stuff */ uint8_t buffer[TRANSFER_SIZE]; int count; + /* Synchronous loop stuff */ + uint16_t insn_value; }; struct dio_priv { @@ -388,6 +391,38 @@ static int dio_insn_bits(a4l_subd_t *subd, a4l_kinsn_t *insn) return 0; } +/* --- Synchronous AO + AI2 functions --- */ + +int ao_insn_write(a4l_subd_t *subd, a4l_kinsn_t *insn) +{ + struct ao_ai2_priv *priv = (struct ao_ai2_priv *)subd->priv; + uint16_t *data = (uint16_t *)insn->data; + + /* Checks the buffer size */ + if (insn->data_size != sizeof(uint16_t)) + return -EINVAL; + + /* Retrieves the value to memorize */ + priv->insn_value = data[0]; + + return 0; +} + +int ai2_insn_read(a4l_subd_t *subd, a4l_kinsn_t *insn) +{ + struct ao_ai2_priv *priv = *((struct ao_ai2_priv **)subd->priv); + uint16_t *data = (uint16_t *)insn->data; + + /* Checks the buffer size */ + if (insn->data_size != sizeof(uint16_t)) + return -EINVAL; + + /* Sets the memorized value */ + data[0] = priv->insn_value; + + return 0; +} + /* --- Initialization functions --- */ void setup_ai_subd(a4l_subd_t *subd) @@ -427,6 +462,7 @@ void setup_ao_subd(a4l_subd_t *subd) subd->cancel = ao_cancel; subd->trigger = ao_trigger; subd->cmd_mask = &ao_cmd_mask; + subd->insn_write = ao_insn_write; } void setup_ai2_subd(a4l_subd_t *subd) @@ -440,6 +476,7 @@ void setup_ai2_subd(a4l_subd_t *subd) subd->do_cmd = ai2_cmd; subd->cancel = ai2_cancel; subd->cmd_mask = &ai_cmd_mask; + subd->insn_read = ai2_insn_read; } /* --- Attach / detach functions --- */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: minor fix in wf_generate
Module: xenomai-head Branch: master Commit: 68949f38ef2449ca30d34ab55c90d8d96407ae22 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=68949f38ef2449ca30d34ab55c90d8d96407ae22 Author: Alexis Berlemont Date: Fri Jan 28 21:04:51 2011 +0100 analogy: minor fix in wf_generate --- src/utils/analogy/wf_generate.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/utils/analogy/wf_generate.c b/src/utils/analogy/wf_generate.c index 97b19c9..0d311b8 100644 --- a/src/utils/analogy/wf_generate.c +++ b/src/utils/analogy/wf_generate.c @@ -199,9 +199,10 @@ int main(int argc, char *argv[]) int err = 0; struct config cfg; double *values = NULL; - err = init_config(&cfg, argc, argv); + if (err < 0) + goto out; err = a4l_wf_check_config(&cfg.wf); if (err < 0) ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [fake] validate the looping feature
Module: xenomai-head Branch: master Commit: ef4145e8c91eaf39da9a6028f1aa8d5d6c7d7859 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=ef4145e8c91eaf39da9a6028f1aa8d5d6c7d7859 Author: Alexis Berlemont Date: Fri Jan 14 20:53:36 2011 +0100 analogy: [fake] validate the looping feature Two subdevices have been added: an asynchronous output subdevice (idx=2) and an asynchronous input subdevice (idx=3). All the values sent from userspace to the output subdevice is redirected into the input subdevice. --- ksrc/drivers/analogy/testing/fake.c | 22 -- 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ksrc/drivers/analogy/testing/fake.c b/ksrc/drivers/analogy/testing/fake.c index 269981c..4a8ce5a 100644 --- a/ksrc/drivers/analogy/testing/fake.c +++ b/ksrc/drivers/analogy/testing/fake.c @@ -175,6 +175,9 @@ int ao_pull_values(a4l_subd_t *subd) /* Let's have a look at how many samples are available */ priv->count = a4l_buf_count(subd) < TRANSFER_SIZE ? a4l_buf_count(subd) : TRANSFER_SIZE; + + if (!priv->count) + return 0; err = a4l_buf_get(subd, priv->buffer, priv->count); if (err < 0) { @@ -183,6 +186,9 @@ int ao_pull_values(a4l_subd_t *subd) "ao_get_values: a4l_buf_get failed (err=%d)\n", err); } + if (priv->count) + a4l_buf_evt(subd, 0); + return err; } @@ -195,11 +201,15 @@ int ai2_push_values(a4l_subd_t *subd) if (priv->count) { err = a4l_buf_put(subd, priv->buffer, priv->count); - a4l_err(subd->dev, - "ao_redirect_values: " - "a4l_buf_get failed (err=%d)\n", err); + if (err < 0) + a4l_err(subd->dev, + "ai2_push_values: " + "a4l_buf_put failed (err=%d)\n", err); } + if (priv->count) + a4l_buf_evt(subd, 0); + return err; } @@ -329,7 +339,7 @@ int ai2_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) { struct fake_priv *priv = (struct fake_priv *)subd->dev->priv; - a4l_info(subd->dev, "ao_cmd: (subd=%d)\n", subd->idx); + a4l_info(subd->dev, "ai2_cmd: (subd=%d)\n", subd->idx); RTDM_EXECUTE_ATOMICALLY(priv->ai2_running = 1); return 0; } @@ -338,13 +348,12 @@ int ai2_cancel(a4l_subd_t *subd) { struct fake_priv *priv = (struct fake_priv *)subd->dev->priv; - a4l_info(subd->dev, "ao_cancel: (subd=%d)\n", subd->idx); + a4l_info(subd->dev, "ai2_cancel: (subd=%d)\n", subd->idx); RTDM_EXECUTE_ATOMICALLY(priv->ai2_running = 0); return 0; } - /* --- Synchronous AI functions --- */ static int ai_insn_read(a4l_subd_t *subd, a4l_kinsn_t *insn) @@ -416,6 +425,7 @@ void setup_ao_subd(a4l_subd_t *subd) subd->chan_desc = &analog_chandesc; subd->do_cmd = ao_cmd; subd->cancel = ao_cancel; + subd->trigger = ao_trigger; subd->cmd_mask = &ao_cmd_mask; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [fake] minor fix in attach parameters handling
Module: xenomai-head Branch: master Commit: 25c7e887cefeafa7bf5274e3c51d11078e21cd10 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=25c7e887cefeafa7bf5274e3c51d11078e21cd10 Author: Alexis Berlemont Date: Fri Jan 7 00:39:53 2011 +0100 analogy: [fake] minor fix in attach parameters handling --- ksrc/drivers/analogy/testing/fake.c |9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ksrc/drivers/analogy/testing/fake.c b/ksrc/drivers/analogy/testing/fake.c index 803ff00..269981c 100644 --- a/ksrc/drivers/analogy/testing/fake.c +++ b/ksrc/drivers/analogy/testing/fake.c @@ -444,10 +444,11 @@ int test_attach(a4l_dev_t *dev, a4l_lnkdesc_t *arg) a4l_dbg(1, drv_dbg, dev, "starting attach procedure...\n"); - if (arg->opts_size < sizeof(unsigned long)) { - priv->amplitude_div = 1; - priv->quanta_cnt = 1; - } else { + /* Set default values for attach parameters */ + priv->amplitude_div = 1; + priv->quanta_cnt = 1; + + if (arg->opts_size >= sizeof(unsigned long)) { unsigned long *args = (unsigned long *)arg->opts; priv->amplitude_div = args[0]; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: 1st rework of fake driver
Module: xenomai-head Branch: master Commit: f32e5bf61dbe956845d0d21c2cca802ea41892de URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=f32e5bf61dbe956845d0d21c2cca802ea41892de Author: Alexis Berlemont Date: Thu Jan 6 00:37:11 2011 +0100 analogy: 1st rework of fake driver The goal is to remove loop testing driver; fake integrates now three subdevices to reproduce the loop behaviour. The implementation is cleaner and that will help validate the waveform tools. --- ksrc/drivers/analogy/testing/fake.c | 331 +++ 1 files changed, 260 insertions(+), 71 deletions(-) diff --git a/ksrc/drivers/analogy/testing/fake.c b/ksrc/drivers/analogy/testing/fake.c index c8e8682..803ff00 100644 --- a/ksrc/drivers/analogy/testing/fake.c +++ b/ksrc/drivers/analogy/testing/fake.c @@ -1,24 +1,34 @@ #include #include -#define AI_TASK_PERIOD 100 +#define TASK_PERIOD 100 #define AI_SUBD 0 #define DIO_SUBD 1 +#define AO_SUBD 2 +#define AI2_SUBD 3 + +#define TRANSFER_SIZE 0x1000 /* --- Driver related structures --- */ struct fake_priv { - /* Configuration parameters */ + /* Attach configuration parameters + (they should be relocated in ai_priv) */ unsigned long amplitude_div; unsigned long quanta_cnt; -}; - -struct ai_priv { /* Task descriptor */ - a4l_task_t timer_task; + a4l_task_t task; + /* Statuses of the asynchronous subdevices */ + int ai_running; + int ao_running; + int ai2_running; +}; + +struct ai_priv { + /* Specific timing fields */ unsigned long scan_period_ns; unsigned long convert_period_ns; @@ -29,8 +39,11 @@ struct ai_priv { /* Misc fields */ unsigned long amplitude_div; unsigned long quanta_cnt; - int timer_running; +}; +struct ao_ai2_priv { + uint8_t buffer[TRANSFER_SIZE]; + int count; }; struct dio_priv { @@ -40,8 +53,9 @@ struct dio_priv { /* --- Channels / ranges part --- */ -/* Channels descriptor */ -static a4l_chdesc_t ai_chandesc = { +/* Channels descriptors */ + +static a4l_chdesc_t analog_chandesc = { .mode = A4L_CHAN_GLOBAL_CHANDESC, .length = 8, .chans = { @@ -58,7 +72,7 @@ static a4l_chdesc_t dio_chandesc = { }; /* Ranges tab */ -static a4l_rngtab_t ai_rngtab = { +static a4l_rngtab_t analog_rngtab = { .length = 2, .rngs = { RANGE_V(-5,5), @@ -66,10 +80,11 @@ static a4l_rngtab_t ai_rngtab = { }, }; /* Ranges descriptor */ -static a4l_rngdesc_t ai_rngdesc = RNG_GLOBAL(ai_rngtab); +static a4l_rngdesc_t analog_rngdesc = RNG_GLOBAL(analog_rngtab); + +/* Command options masks */ -/* Command options mask */ -static a4l_cmd_t test_cmd_mask = { +static a4l_cmd_t ai_cmd_mask = { .idx_subd = 0, .start_src = TRIG_NOW, .scan_begin_src = TRIG_TIMER, @@ -78,9 +93,20 @@ static a4l_cmd_t test_cmd_mask = { .stop_src = TRIG_COUNT|TRIG_NONE, }; +static a4l_cmd_t ao_cmd_mask = { + .idx_subd = 0, + .start_src = TRIG_NOW | TRIG_INT, + .scan_begin_src = TRIG_TIMER, + .convert_src = TRIG_NOW | TRIG_TIMER, + .scan_end_src = TRIG_COUNT, + .stop_src = TRIG_COUNT| TRIG_NONE, +}; + /* --- Analog input simulation --- */ -static uint16_t ai_value_output(struct ai_priv *priv) +/* --- Values generation for 1st AI --- */ + +static inline uint16_t ai_value_output(struct ai_priv *priv) { static uint16_t output_tab[8] = { 0x0001, 0x2000, 0x4000, 0x6000, @@ -104,76 +130,137 @@ static uint16_t ai_value_output(struct ai_priv *priv) return output_tab[idx] / priv->amplitude_div; } -/* --- Task part --- */ - -/* Timer task routine */ -static void ai_task_proc(void *arg) +int ai_push_values(a4l_subd_t *subd) { - a4l_subd_t *subd = (a4l_subd_t *)arg; struct ai_priv *priv = (struct ai_priv *)subd->priv; - a4l_cmd_t *cmd = NULL; - uint64_t now_ns, elapsed_ns=0; + a4l_cmd_t *cmd = a4l_get_cmd(subd); + uint64_t now_ns, elapsed_ns = 0; + int i = 0; + + if (!cmd) + return -EPIPE; + + now_ns = a4l_get_time(); + elapsed_ns += now_ns - priv->last_ns + priv->reminder_ns; + priv->last_ns = now_ns; + + while(elapsed_ns >= priv->scan_period_ns) { + int j; + + for(j = 0; j < cmd->nb_chan; j++) { + uint16_t value = ai_value_output(priv); + a4l_buf_put(subd, &value, sizeof(uint16_t)); + } + + elapsed_ns -= priv->scan_period_ns; + i++; + } - while(1) { - int running; + priv->current_ns += i * priv->scan_period_ns; + priv->reminder_ns = elapsed_ns; + + if (i != 0) + a4l_buf_evt(subd, 0); + +
[Xenomai-git] Alexis Berlemont : analogy: minor changes
Module: xenomai-head Branch: master Commit: 076b749aa22632e528dc9c46354451f9a8ac5e75 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=076b749aa22632e528dc9c46354451f9a8ac5e75 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 a 1st version of wf_cmd_write
Module: xenomai-head Branch: master Commit: 9426be27db84fbe909e0d7375f5b811d1a2a9ae3 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=9426be27db84fbe909e0d7375f5b811d1a2a9ae3 Author: Alexis Berlemont Date: Thu Dec 2 01:00:55 2010 +0100 analogy: add a 1st version of wf_cmd_write This program takes the waveforms created by wf_generate as standard input. So we are able to inject specific waveforms into the output subdevice of a board. Warning: more parameters needs to be added Warning: it should not be used as is --- src/utils/analogy/Makefile.am|7 + src/utils/analogy/wf_cmd_write.c | 483 ++ 2 files changed, 490 insertions(+), 0 deletions(-) diff --git a/src/utils/analogy/Makefile.am b/src/utils/analogy/Makefile.am index 8e7734f..a2c3e96 100644 --- a/src/utils/analogy/Makefile.am +++ b/src/utils/analogy/Makefile.am @@ -3,6 +3,7 @@ sbin_PROGRAMS = analogy_config bin_PROGRAMS = \ cmd_read \ cmd_write \ + wf_cmd_write \ cmd_bits \ insn_read \ insn_write \ @@ -42,6 +43,12 @@ cmd_write_LDADD = \ ../../skins/rtdm/librtdm.la \ ../../skins/common/libxenomai.la +wf_cmd_write_SOURCES = wf_cmd_write.c +wf_cmd_write_LDADD = \ + ../../drvlib/analogy/libanalogy.la \ + ../../skins/rtdm/librtdm.la \ + ../../skins/common/libxenomai.la + cmd_bits_SOURCES = cmd_bits.c cmd_bits_LDADD = \ ../../drvlib/analogy/libanalogy.la \ diff --git a/src/utils/analogy/wf_cmd_write.c b/src/utils/analogy/wf_cmd_write.c new file mode 100644 index 000..38e0c29 --- /dev/null +++ b/src/utils/analogy/wf_cmd_write.c @@ -0,0 +1,483 @@ +/** + * @file + * Analogy for Linux, output command test program + * + * @note Copyright (C) 1997-2000 David A. Schleef + * @note Copyright (C) 2008 Alexis Berlemont + * + * Xenomai is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Xenomai is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xenomai; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define BUFFER_DEPTH 1024 + +struct config { + + /* Configuration parameters + TODO: add real_time and use_mmap*/ + + int verbose; + + int subd; + char *str_chans; + unsigned int *chans; + int chans_count; + char *str_ranges; + int scans_count; + + char *filename; + FILE *input; + + /* Analogy stuff */ + + a4l_desc_t dsc; + a4l_chinfo_t *cinfo; + a4l_rnginfo_t *rinfo; + + /* Buffer stuff + TODO: add buffer depth / size (useful for mmap) */ + void *buffer; + +}; + +/* --- Options / arguments part --- */ + +struct option options[] = { + {"verbose", no_argument, NULL, 'v'}, + {"device", required_argument, NULL, 'd'}, + {"subdevice", required_argument, NULL, 's'}, + {"scans-count", required_argument, NULL, 'S'}, + {"channels", required_argument, NULL, 'c'}, + {"range", required_argument, NULL, 'c'}, + {"help", no_argument, NULL, 'h'}, + {0}, +}; + +void print_usage(void) +{ + fprintf(stdout, "usage:\tcmd_write [OPTS]\n"); + fprintf(stdout, "\tOPTS:\t -v, --verbose: verbose output\n"); + fprintf(stdout, + "\t\t -d, --device: " + "device filename (analogy0, analogy1, ...)\n"); + fprintf(stdout, "\t\t -s, --subdevice: subdevice index\n"); + fprintf(stdout, "\t\t -S, --scans-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 -R, --range: range to use " + " (ex.: -R 0,1,V)\n"); + fprintf(stdout, "\t\t -h, --help: print this help\n"); +} + +/* --- Configuration related stuff --- */ + +int init_dsc_config(struct config *cfg) +{ + int err = 0; + + /* Here we have to open the Analogy device file */ + err = a4l_open(&cfg->dsc, cfg->filename); + if (err < 0) { + fprintf(stderr, + "cmd_write: a4l_open %s failed (ret=%d)\n", + cfg->filename, err); + goto out; + } + + /* Allocate a buffer so as to get more info (subd, chan, rng) */ + cfg->dsc.sbdata = malloc(cfg->dsc.sbsize); + if (!cfg->dsc.sbdata
[Xenomai-git] Alexis Berlemont : analogy: add wf_generate tool
Module: xenomai-head Branch: master Commit: 22c200d62e97670c6940ba337c66e6f1f5758882 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=22c200d62e97670c6940ba337c66e6f1f5758882 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 *confi
[Xenomai-git] Alexis Berlemont : analogy: add verbose output in wf_generate tool
Module: xenomai-head Branch: master Commit: bc5d3f5059d03c96aa783006e84b884279f717ee URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=bc5d3f5059d03c96aa783006e84b884279f717ee Author: Alexis Berlemont Date: Thu Dec 2 00:54:37 2010 +0100 analogy: add verbose output in wf_generate tool --- src/utils/analogy/wf_generate.c | 20 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/src/utils/analogy/wf_generate.c b/src/utils/analogy/wf_generate.c index 40e518b..97b19c9 100644 --- a/src/utils/analogy/wf_generate.c +++ b/src/utils/analogy/wf_generate.c @@ -208,6 +208,18 @@ int main(int argc, char *argv[]) goto out; a4l_wf_set_sample_count(&cfg.wf); + + if (cfg.verbose) { + char *types[] = {"sine", "sawtooth", "triangular", "steps"}; + fprintf(stderr, "Waveform type: %s\n", types[cfg.wf.wf_kind]); + fprintf(stderr, "Amplitude: %F\n", cfg.wf.wf_amplitude); + fprintf(stderr, "Frequency: %F\n", cfg.wf.wf_frequency); + fprintf(stderr, "Offset: %F\n", cfg.wf.wf_offset); + fprintf(stderr, + "Sampling frequency: %F\n", cfg.wf.spl_frequency); + fprintf(stderr, "Samples count: %d\n", cfg.wf.spl_count); + fprintf(stderr, "Output file: %s\n", cfg.filename); + } values = malloc(cfg.wf.spl_count * sizeof(double)); if (!values) { @@ -225,6 +237,14 @@ int main(int argc, char *argv[]) goto out; } + if (cfg.verbose) { + int i; + + fprintf(stderr, "Dumping values:\n"); + for (i = 0; i < cfg.wf.spl_count; i++) + fprintf(stderr, "[%d]: %F\n", i, values[i]); + } + out: cleanup_config(&cfg); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: rename waveform files
Module: xenomai-head Branch: master Commit: c3074206c048644ee204a4eb32fbf0e664277cf4 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=c3074206c048644ee204a4eb32fbf0e664277cf4 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: add first version of waveform generation
Module: xenomai-head Branch: master Commit: bee38acc8bed264547102a3013c76408235485e7 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=bee38acc8bed264547102a3013c76408235485e7 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\
[Xenomai-git] Philippe Gerum : powerpc: upgrade I-pipe support to 3.0.4-powerpc-2.13-00
Module: xenomai-head Branch: master Commit: f5de62ccdc1788c7715a169a51fcd32ab6686407 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=f5de62ccdc1788c7715a169a51fcd32ab6686407 Author: Philippe Gerum Date: Tue Sep 6 12:08:25 2011 +0200 powerpc: upgrade I-pipe support to 3.0.4-powerpc-2.13-00 --- ksrc/arch/powerpc/patches/README | 10 +- ...tch => adeos-ipipe-3.0.4-powerpc-2.13-00.patch} | 3285 +++- 2 files changed, 1825 insertions(+), 1470 deletions(-) Diff: http://git.xenomai.org/?p=xenomai-head.git;a=commitdiff;h=f5de62ccdc1788c7715a169a51fcd32ab6686407 ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : hal/generic: remove useless rthal_irq_affinity()
Module: xenomai-head Branch: master Commit: 66b60080472142359105a8f2aeb8c2f5d5cecab1 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=66b60080472142359105a8f2aeb8c2f5d5cecab1 Author: Philippe Gerum Date: Tue Sep 6 11:32:49 2011 +0200 hal/generic: remove useless rthal_irq_affinity() --- include/asm-generic/hal.h |4 --- ksrc/arch/generic/hal.c | 62 - 2 files changed, 0 insertions(+), 66 deletions(-) diff --git a/include/asm-generic/hal.h b/include/asm-generic/hal.h index efb0ef8..940320d 100644 --- a/include/asm-generic/hal.h +++ b/include/asm-generic/hal.h @@ -539,10 +539,6 @@ static inline void rthal_apc_schedule(int apc) rthal_local_irq_restore(flags); } -int rthal_irq_affinity(unsigned irq, - cpumask_t cpumask, - cpumask_t *oldmask); - rthal_trap_handler_t rthal_trap_catch(rthal_trap_handler_t handler); unsigned long rthal_timer_calibrate(void); diff --git a/ksrc/arch/generic/hal.c b/ksrc/arch/generic/hal.c index f7c5ddb..79466f8 100644 --- a/ksrc/arch/generic/hal.c +++ b/ksrc/arch/generic/hal.c @@ -295,67 +295,6 @@ int rthal_irq_release(unsigned irq) */ /** - * @fn int rthal_irq_affinity (unsigned irq,cpumask_t cpumask,cpumask_t *oldmask) - * - * @brief Set/Get processor affinity for external interrupt. - * - * On SMP systems, this service ensures that the given interrupt is - * preferably dispatched to the specified set of processors. The - * previous affinity mask is returned by this service. - * - * @param irq The interrupt source whose processor affinity is - * affected by the operation. Only external interrupts can have their - * affinity changed/queried, thus virtual interrupt numbers allocated - * by rthal_alloc_virq() are invalid values for this parameter. - * - * @param cpumask A list of CPU identifiers passed as a bitmask - * representing the new affinity for this interrupt. A zero value - * cause this service to return the current affinity mask without - * changing it. - * - * @param oldmask If non-NULL, a pointer to a memory area which will - * bve overwritten by the previous affinity mask used for this - * interrupt source, or a zeroed mask if an error occurred. This - * service always returns a zeroed mask on uniprocessor systems. - * - * @return 0 is returned upon success. Otherwise: - * - * - -EINVAL is returned if @a irq is invalid. - * - * Environments: - * - * This service can be called from: - * - * - Linux domain context. - */ - -#ifdef CONFIG_SMP - -int rthal_irq_affinity(unsigned irq, cpumask_t cpumask, cpumask_t *oldmask) -{ -cpumask_t _oldmask; - -if (irq >= IPIPE_NR_XIRQS) - return -EINVAL; - -_oldmask = rthal_set_irq_affinity(irq, cpumask); - -if (oldmask) - *oldmask = _oldmask; - -return cpus_empty(_oldmask) ? -EINVAL : 0; -} - -#else /* !CONFIG_SMP */ - -int rthal_irq_affinity(unsigned irq, cpumask_t cpumask, cpumask_t *oldmask) -{ -return 0; -} - -#endif /* CONFIG_SMP */ - -/** * @fn int rthal_trap_catch (rthal_trap_handler_t handler) * * @brief Installs a fault handler. @@ -845,7 +784,6 @@ EXPORT_SYMBOL_GPL(rthal_irq_disable); EXPORT_SYMBOL_GPL(rthal_irq_end); EXPORT_SYMBOL_GPL(rthal_irq_host_request); EXPORT_SYMBOL_GPL(rthal_irq_host_release); -EXPORT_SYMBOL_GPL(rthal_irq_affinity); EXPORT_SYMBOL_GPL(rthal_trap_catch); EXPORT_SYMBOL_GPL(rthal_timer_request); EXPORT_SYMBOL_GPL(rthal_timer_release); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : hal/generic: do not return previous IRQ affinity mask
Module: xenomai-head Branch: master Commit: 37faac2b1aa92cb975f0a34b2f042259562aa39c URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=37faac2b1aa92cb975f0a34b2f042259562aa39c Author: Philippe Gerum Date: Tue Sep 6 11:33:39 2011 +0200 hal/generic: do not return previous IRQ affinity mask No in-tree code ever used the previous affinity mask returned after the IRQ affinity was changed, and getting this information became painfully harder with post-2.6.38 kernels. Let's get rid of this requirement. --- include/asm-generic/bits/intr.h |6 +++--- include/asm-sim/bits/intr.h |5 ++--- include/nucleus/intr.h |8 +--- ksrc/nucleus/intr.c |4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/asm-generic/bits/intr.h b/include/asm-generic/bits/intr.h index 68f0bd4..26f7aa1 100644 --- a/include/asm-generic/bits/intr.h +++ b/include/asm-generic/bits/intr.h @@ -57,10 +57,10 @@ static inline void xnarch_chain_irq (unsigned irq) rthal_irq_host_pend(irq); } -static inline xnarch_cpumask_t xnarch_set_irq_affinity (unsigned irq, - xnarch_cpumask_t affinity) +static inline void xnarch_set_irq_affinity (unsigned irq, + xnarch_cpumask_t affinity) { -return rthal_set_irq_affinity(irq,affinity); +rthal_set_irq_affinity(irq,affinity); } static inline void *xnarch_get_irq_cookie(unsigned irq) diff --git a/include/asm-sim/bits/intr.h b/include/asm-sim/bits/intr.h index 2cf0ddf..3978a74 100644 --- a/include/asm-sim/bits/intr.h +++ b/include/asm-sim/bits/intr.h @@ -56,10 +56,9 @@ static inline void xnarch_chain_irq (unsigned irq) /* empty */ } -static inline unsigned long xnarch_set_irq_affinity (unsigned irq, -unsigned long affinity) +static inline void xnarch_set_irq_affinity (unsigned irq, + unsigned long affinity) { - return 0; } static inline void xnarch_relay_tick(void) diff --git a/include/nucleus/intr.h b/include/nucleus/intr.h index 5cef8a1..20a625d 100644 --- a/include/nucleus/intr.h +++ b/include/nucleus/intr.h @@ -126,11 +126,13 @@ int xnintr_enable(xnintr_t *intr); int xnintr_disable(xnintr_t *intr); -xnarch_cpumask_t xnintr_affinity(xnintr_t *intr, -xnarch_cpumask_t cpumask); +void xnintr_affinity(xnintr_t *intr, +xnarch_cpumask_t cpumask); int xnintr_query_init(xnintr_iterator_t *iterator); -int xnintr_query_next(int irq, xnintr_iterator_t *iterator, char *name_buf); + +int xnintr_query_next(int irq, xnintr_iterator_t *iterator, + char *name_buf); #ifdef __cplusplus } diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c index 4a42513..370e71e 100644 --- a/ksrc/nucleus/intr.c +++ b/ksrc/nucleus/intr.c @@ -884,12 +884,12 @@ EXPORT_SYMBOL_GPL(xnintr_disable); * cpumask could be meaningless. */ -xnarch_cpumask_t xnintr_affinity(xnintr_t *intr, xnarch_cpumask_t cpumask) +void xnintr_affinity(xnintr_t *intr, xnarch_cpumask_t cpumask) { trace_mark(xn_nucleus, irq_affinity, "irq %u %lu", intr->irq, *(unsigned long *)&cpumask); - return xnarch_set_irq_affinity(intr->irq, cpumask); + xnarch_set_irq_affinity(intr->irq, cpumask); } EXPORT_SYMBOL_GPL(xnintr_affinity); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git