[Xenomai-git] Alexis Berlemont : analogy: update a4l_set_dev() declaration (broken)
Module: xenomai-abe Branch: analogy Commit: cd2dcbca86c340054fb4fd02b0ae379554980710 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=cd2dcbca86c340054fb4fd02b0ae379554980710 Author: Alexis Berlemont Date: Sun May 16 23:56:48 2010 +0200 analogy: update a4l_set_dev() declaration (broken) --- include/analogy/device.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 27a3bd0..51b99b5 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -91,7 +91,7 @@ int a4l_rdproc_devs(char *page, off_t off, int count, int *eof, void *data); /* --- Context related function / macro --- */ -void a4l_set_dev(a4l_cxt_t * cxt); +void a4l_set_dev(struct rtdm_dev_context *context); #define a4l_get_dev(x) ((x)->dev) /* --- Upper layer functions --- */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: first draft of buffer initialization functions (broken)
Module: xenomai-abe Branch: analogy Commit: fa386f45c9e7242355d22d06b06d631cb8de38e0 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=fa386f45c9e7242355d22d06b06d631cb8de38e0 Author: Alexis Berlemont Date: Sun May 16 23:23:16 2010 +0200 analogy: first draft of buffer initialization functions (broken) --- ksrc/drivers/analogy/buffer.c | 69 1 files changed, 62 insertions(+), 7 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index ecbc379..a27a1d6 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -33,7 +33,7 @@ #include #include -/* --- Buffer allocation / free functions --- */ +/* --- Initialization functions (init, alloc, free) --- */ void a4l_free_buffer(a4l_buf_t * buf_desc) { @@ -52,18 +52,15 @@ void a4l_free_buffer(a4l_buf_t * buf_desc) } } -int a4l_alloc_buffer(a4l_buf_t * buf_desc) +int a4l_alloc_buffer(a4l_buf_t * buf_desc, int buf_size) { int ret = 0; char *vaddr, *vabase; - if (buf_desc->size == 0) - buf_desc->size = A4L_BUF_DEFSIZE; - + buf_desc->size = buf_size; buf_desc->size = PAGE_ALIGN(buf_desc->size); buf_desc->buf = vmalloc(buf_desc->size); - if (buf_desc->buf == NULL) { ret = -ENOMEM; goto out_virt_contig_alloc; @@ -94,7 +91,65 @@ out_virt_contig_alloc: return ret; } -/* --- Current Command management function --- */ +int a4l_init_buffer(a4l_buf_t * buf_desc) +{ + int err; + + /* No command to process yet */ + buf_desc->cur_cmd = NULL; + + /* No more (or not yet) linked with a subdevice */ + buf_desc->subd = NULL; + + /* Initializes counts and flags */ + buf_desc->end_count = 0; + buf_desc->prd_count = 0; + buf_desc->cns_count = 0; + buf_desc->tmp_count = 0; + buf_desc->mng_count = 0; + + /* Flush pending events */ + buf_desc->flags = 0; + a4l_flush_sync(&buf_desc->sync); + + return err; +} + +int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) +{ + a4l_buf_t * buf_desc = cxt->buffer; + int i; + + /* Retrieve the related subdevice */ + buf_desc->subd = a4l_get_subd(cxt->dev, cmd->idx_subd); + if (buf_desc->subd == NULL) { + __a4l_err("a4l_setup_buffer: subdevice index " + "out of range (%d)\n", cmd->idx_subd); + goto -EINVAL; + } + + /* Checks if the transfer system has to work in bulk mode */ + if (cmd->flags & A4L_CMD_BULK) + set_bit(A4L_BUF_BULK_NR, &buf_desc->flags); + + /* Sets the working command */ + buf_desc->cur_cmd = cmd; + + /* Computes the count to reach, if need be */ + if (cmd->stop_src == TRIG_COUNT) { + for (i = 0; i < cmd->nb_chan; i++) { + a4l_chan_t *chft; + chft = a4l_get_chfeat(buf_desc->subd, + CR_CHAN(cmd->chan_descs[i])); + buf_desc->end_count += chft->nb_bits / 8; + } + buf_desc->end_count *= cmd->stop_arg; + } + + return 0; +} + +/* --- current Command management function --- */ a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) { ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update comments on a4l_context (broken)
Module: xenomai-abe Branch: analogy Commit: 83c79e3d5f94fb66fdc432dd9054c86641481d8e URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=83c79e3d5f94fb66fdc432dd9054c86641481d8e Author: Alexis Berlemont Date: Sun May 16 23:57:19 2010 +0200 analogy: update comments on a4l_context (broken) --- include/analogy/context.h | 15 +-- 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index d30bbba..e0cf01c 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -29,15 +29,18 @@ struct a4l_device; struct a4l_buffer; struct a4l_device_context { - /* No need to hold user_info, thanks to container_of, we could - get it back */ + + /* Needed to call rtdm_*_copy_from/to_user functions */ rtdm_user_info_t *user_info; - struct a4l_device *dev; /* Which is retrieved thanks to minor - at open time */ + /* The adequate device pointer + (retrieved thanks to minor at open time) */ + struct a4l_device *dev; - struct buffer buffer; /* The buffer field is extracted from -the transfer structure */ + /* The buffer structure contains everything to transfer data + from asynchronous acquisition operations on a specific + subdevice */ + struct buffer buffer; }; #endif /* __KERNEL__ && !DOXYGEN_CPP */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: changes related with subdevice's status field ( broken)
Module: xenomai-abe Branch: analogy Commit: c72b3cda90049db3a3e11a7e4f08319916366711 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=c72b3cda90049db3a3e11a7e4f08319916366711 Author: Alexis Berlemont Date: Mon May 17 00:08:40 2010 +0200 analogy: changes related with subdevice's status field (broken) --- include/analogy/subdevice.h |8 ksrc/drivers/analogy/subdevice.c |2 +- ksrc/drivers/analogy/transfer.c | 73 -- 3 files changed, 16 insertions(+), 67 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 11a345e..0f9e1c5 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -155,6 +155,14 @@ #define A4L_SUBD_BUSY_NR 0 #define A4L_SUBD_BUSY (1 << A4L_SUBD_BUSY_NR) +/** + * The subdevice is about to be cleaned in the middle of the detach + * procedure + */ +#define A4L_SUBD_CLEAN_NR 1 +#define A4L_SUBD_CLEAN (1 << A4L_SUBD_CLEAN_NR) + + /*! @} ANALOGY_SUBD_ST_xxx */ #ifdef __KERNEL__ diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 28aa4a0..1278081 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -201,7 +201,7 @@ int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg) for (i = 0; i < dev->transfer.nb_subd; i++) { subd_info[i].flags = dev->transfer.subds[i]->flags; - subd_info[i].status = dev->transfer.status[i]; + subd_info[i].status = dev->transfer.subds[i]->status; subd_info[i].nb_chan = (dev->transfer.subds[i]->chan_desc != NULL) ? dev->transfer.subds[i]->chan_desc->length : 0; diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index c8a7d43..b1e511d 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -53,31 +53,26 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) } for (i = 0; i < tsf->nb_subd; i++) { + unsigned long *status = &tsf->subds[i]->status; - if (test_bit(A4L_TSF_MMAP, &(tsf->status[i]))) { - __a4l_err("a4l_precleanup_transfer: " - "device busy, buffer must be unmapped\n"); - err = -EPERM; - goto out_error; - } - - if (test_and_set_bit(A4L_TSF_BUSY, &(tsf->status[i]))) { + if (test_and_set_bit(A4L_SUBD_BUSY, status)) { __a4l_err("a4l_precleanup_transfer: " "device busy, acquisition occuring\n"); err = -EBUSY; goto out_error; } else - set_bit(A4L_TSF_CLEAN, &(tsf->status[i])); + set_bit(A4L_SUBD_CLEAN, status); } return 0; out_error: for (i = 0; i < tsf->nb_subd; i++) { + unsigned long *status = &tsf->subds[i]->status; - if (test_bit(A4L_TSF_CLEAN, &(tsf->status[i]))){ - clear_bit(A4L_TSF_BUSY, &(tsf->status[i])); - clear_bit(A4L_TSF_CLEAN, &(tsf->status[i])); + if (test_bit(A4L_TSF_CLEAN, status)){ + clear_bit(A4L_SUBD_BUSY, status); + clear_bit(A4L_SUBD_CLEAN, status); } } @@ -97,21 +92,6 @@ int a4l_cleanup_transfer(a4l_cxt_t * cxt) dev = a4l_get_dev(cxt); tsf = &dev->transfer; - /* Releases the various buffers */ - if (tsf->status != NULL) - rtdm_free(tsf->status); - - if (tsf->bufs != NULL) { - for (i = 0; i < tsf->nb_subd; i++) { - if (tsf->bufs[i] != NULL) { - a4l_free_buffer(tsf->bufs[i]); - a4l_cleanup_sync(&tsf->bufs[i]->sync); - rtdm_free(tsf->bufs[i]); - } - } - rtdm_free(tsf->bufs); - } - /* Releases the pointers tab, if need be */ if (tsf->subds != NULL) { rtdm_free(tsf->subds); @@ -135,10 +115,6 @@ void a4l_presetup_transfer(a4l_cxt_t *cxt) /* Clear the structure */ memset(tsf, 0, sizeof(a4l_trf_t)); - /* We consider 0 can be valid index */ - tsf->idx_read_subd = A4L_IDX_UNUSED; - tsf->idx_write_subd = A4L_IDX_UNUSED; - /* 0 is also considered as a valid IRQ, then the IRQ number must be initialized with another value */ tsf->irq_desc.irq = A4L_IRQ_UNUSED; @@ -186,41 +162,6 @@ int a4l_setup_transfer(a4l_cxt_t * cxt) tsf->subds[i++] = subd; } - /* Allocates various buffers */ - tsf->bufs = rtdm_malloc(tsf->nb_subd * sizeof(a4l_buf_t *)); - if (tsf->bufs == NULL) { - __a4l_er
[Xenomai-git] Alexis Berlemont : analogy: adapt a4l_set_dev() after a4l_context' s overhaul (broken)
Module: xenomai-abe Branch: analogy Commit: e4c0bf113e52a91a2d156d69d1f9cd7e273295b0 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=e4c0bf113e52a91a2d156d69d1f9cd7e273295b0 Author: Alexis Berlemont Date: Sun May 16 23:55:48 2010 +0200 analogy: adapt a4l_set_dev() after a4l_context's overhaul (broken) --- ksrc/drivers/analogy/device.c | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index b3ef9bf..4a3c879 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -59,9 +59,15 @@ int a4l_check_cleanup_devs(void) return ret; } -void a4l_set_dev(a4l_cxt_t * cxt) +void a4l_set_dev(struct rtdm_dev_context *context) { - cxt->dev = &(a4l_devs[a4l_get_minor(cxt)]); + /* Get the context's private structure */ + a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + /* Retrive the minor index */ + static int minor = context->device->device_id; + + /* Fill the dev fields accordingly */ + cxt->dev = &(a4l_devs[minor]); } /* --- Device tab proc section --- */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: the subdevice structure got a new status field (broken)
Module: xenomai-abe Branch: analogy Commit: d4536f71d39d81bf2228bff161faafbab131deea URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=d4536f71d39d81bf2228bff161faafbab131deea Author: Alexis Berlemont Date: Sun May 16 23:20:51 2010 +0200 analogy: the subdevice structure got a new status field (broken) --- include/analogy/subdevice.h | 26 +- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 1c3bcd4..11a345e 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -141,12 +141,28 @@ /*! @} ANALOGY_SUBD_FT_xxx */ +/*! + * @anchor ANALOGY_SUBD_ST_xxx @name Subdevice status + * @brief Flags to define the subdevice's status + * @{ + */ + +/* Subdevice status flag(s) */ +/** + * The subdevice is busy, a synchronous or an asynchronous acquisition + * is occuring + */ +#define A4L_SUBD_BUSY_NR 0 +#define A4L_SUBD_BUSY (1 << A4L_SUBD_BUSY_NR) + + /*! @} ANALOGY_SUBD_ST_xxx */ + #ifdef __KERNEL__ /* --- Subdevice descriptor structure --- */ struct a4l_device; -struct a4l_driver; +struct a4l_buffer; /*! * @brief Structure describing the subdevice @@ -160,9 +176,17 @@ struct a4l_subdevice { struct a4l_device *dev; /**< Containing device */ + unsigned int idx; /**< Subdevice index */ + struct a4l_buffer *buf; + /**< Linked buffer */ + + /* Subdevice's status (busy, linked?) */ + unsigned long status; +/**< Subdevice's status */ + /* Descriptors stuff */ unsigned long flags; /**< Type flags */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: adapt open, r/w, select and ioctl functions ( broken)
Module: xenomai-abe Branch: analogy Commit: 9799c5cdbbc4caa7a5f2ad2a22e9ac8436ed5aae URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=9799c5cdbbc4caa7a5f2ad2a22e9ac8436ed5aae Author: Alexis Berlemont Date: Sun May 16 23:25:49 2010 +0200 analogy: adapt open, r/w, select and ioctl functions (broken) --- ksrc/drivers/analogy/rtdm_interface.c | 130 +++- 1 files changed, 61 insertions(+), 69 deletions(-) diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index cbc3ca6..d37ce4c 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -121,125 +121,117 @@ void a4l_cleanup_proc(void) #endif /* CONFIG_PROC_FS */ -int a4l_rt_open(struct rtdm_dev_context *context, - rtdm_user_info_t * user_info, int flags) +int a4l_open(struct rtdm_dev_context *context, +rtdm_user_info_t * user_info, int flags) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; - a4l_init_cxt(context, user_info, &cxt); - a4l_set_dev(&cxt); - __a4l_dbg(1, core_dbg, - "a4l_rt_open: minor=%d\n", a4l_get_minor(&cxt)); + /* Get a pointer on the selected device + (thanks to minor index) */ + a4l_set_dev(context); + + /* Initialize the buffer structure */ + a4l_init_buffer(&cxt->buffer); + + /* Allocate the asynchronous buffer + NOTE: it should be interesting to allocate the buffer only + on demand especially if the system is short of memory + NOTE2: the default buffer size could be configured via + kernel config*/ + a4l_alloc_buffer(&cxt->buffer, A4L_DEFAULT_BFSIZE); return 0; } -int a4l_rt_close(struct rtdm_dev_context *context, -rtdm_user_info_t * user_info) +int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) { - a4l_cxt_t cxt; + int err; + a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + + /* Cancel the maybe occuring asynchronous transfer */ + err = a4l_cancel_buffer(&cxt->buffer); + if (err < 0) { + __a4l_err("close: unable to stop the asynchronous transfer\n"); + return err; + } - a4l_init_cxt(context, user_info, &cxt); - a4l_set_dev(&cxt); - __a4l_dbg(1, core_dbg, - "a4l_rt_close: minor=%d\n", a4l_get_minor(&cxt)); + /* Free the buffer which was linked with this context */ + err = a4l_free_buffer(&cxt->buffer); - return a4l_cancel_transfers(&cxt);; + return err; } -ssize_t a4l_rt_read(struct rtdm_dev_context * context, - rtdm_user_info_t * user_info, void *buf, size_t nbytes) +ssize_t a4l_read(struct rtdm_dev_context * context, +rtdm_user_info_t * user_info, void *buf, size_t nbytes) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() && rtdm_rt_capable(user_info)) return -ENOSYS; - a4l_init_cxt(context, user_info, &cxt); - a4l_set_dev(&cxt); - - __a4l_dbg(1, core_dbg, - "a4l_rt_read: minor=%d\n", a4l_get_minor(&cxt)); - if (nbytes == 0) return 0; - return a4l_read(&cxt, buf, nbytes); + cxt->user_info = user_info; + + return a4l_read(cxt, buf, nbytes); } -ssize_t a4l_rt_write(struct rtdm_dev_context * context, -rtdm_user_info_t * user_info, const void *buf, -size_t nbytes) +ssize_t a4l_write(struct rtdm_dev_context * context, + rtdm_user_info_t *user_info, const void *buf, size_t nbytes) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() && rtdm_rt_capable(user_info)) return -ENOSYS; - a4l_init_cxt(context, user_info, &cxt); - a4l_set_dev(&cxt); - - __a4l_dbg(1, core_dbg, "a4l_rt_write: minor=%d\n", a4l_get_minor(&cxt)); - if (nbytes == 0) return 0; - return a4l_write(&cxt, buf, nbytes); + cxt->user_info = user_info; + + return a4l_write(cxt, buf, nbytes); } -int a4l_rt_ioctl(struct rtdm_dev_context *context, -rtdm_user_info_t * user_info, -unsigned int request, void *arg) +int a4l_ioctl(struct rtdm_dev_context *context, + rtdm_user_info_t *user_info, unsigned int request, void *arg) { - a4l_cxt_t cxt; + a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; - a4l_init_cxt(context, user_info, &cxt); - a4l_set_dev(&cxt); - __a4l_dbg(1, core_dbg, - "a4l_rt_ioctl: minor=%d\n", a4l_get_minor(&cxt)); + cxt->user_info = user_info; -
[Xenomai-git] Alexis Berlemont : analogy: the buffer structure is now the central field of a4l_context (broken)
Module: xenomai-abe Branch: analogy Commit: c0cd754d4edaa68f44c48e4d927594215b8dc970 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=c0cd754d4edaa68f44c48e4d927594215b8dc970 Author: Alexis Berlemont Date: Sun May 16 23:19:52 2010 +0200 analogy: the buffer structure is now the central field of a4l_context (broken) --- include/analogy/buffer.h | 14 -- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 007f01e..49d2a9f 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -43,11 +43,21 @@ #define A4L_BUF_ERROR (1 << A4L_BUF_ERROR_NR) #define A4L_BUF_EOA (1 << A4L_BUF_EOA_NR) +/* Status bits */ +#define A4L_BUF_BULK_NR 8 +#define A4L_BUF_MAP_NR 8 +/* Status flags */ +#define A4L_BUF_BULK (1 << A4L_BUF_BULK_NR) +#define A4L_BUF_MAP (1 << A4L_BUF_MAP_NR) + struct a4l_subdevice; /* Buffer descriptor structure */ struct a4l_buffer { + /* Added by the structure update */ + a4l_subd_t *subd; + /* Buffer's first virtual page pointer */ void *buf; @@ -65,8 +75,8 @@ struct a4l_buffer { unsigned long cns_count; unsigned long tmp_count; - /* Events occuring during transfer */ - unsigned long evt_flags; + /* Status + events occuring during transfer */ + unsigned long flags; /* Command on progress */ a4l_cmd_t *cur_cmd; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: the transfer structure is left with a minimal role (broken)
Module: xenomai-abe Branch: analogy Commit: 417d1ba03a521ca7d91bf84c01a3f4cc2b4a9039 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=417d1ba03a521ca7d91bf84c01a3f4cc2b4a9039 Author: Alexis Berlemont Date: Sun May 16 23:22:36 2010 +0200 analogy: the transfer structure is left with a minimal role (broken) This structure should be renamed. --- include/analogy/transfer.h | 17 - 1 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/analogy/transfer.h b/include/analogy/transfer.h index e6bdc3c..929022b 100644 --- a/include/analogy/transfer.h +++ b/include/analogy/transfer.h @@ -30,15 +30,14 @@ #include /* Status flags / bits */ -#define A4L_TSF_BUSY 0 -#define A4L_TSF_BULK 1 -#define A4L_TSF_MMAP 2 -#define A4L_TSF_CLEAN 3 +#define A4L_TSF_CLEAN 0 /* Fields init values */ #define A4L_IRQ_UNUSED (unsigned int)((unsigned short)(~0)) #define A4L_IDX_UNUSED (unsigned int)(~0) +/* TODO: IRQ handling must leave transfer for os_facilities */ + /* IRQ types */ #define A4L_IRQ_SHARED RTDM_IRQTYPE_SHARED #define A4L_IRQ_EDGE RTDM_IRQTYPE_EDGE @@ -51,24 +50,16 @@ #ifdef __KERNEL__ struct a4l_device; - /* Analogy transfer descriptor */ struct a4l_transfer { /* Subdevices desc */ unsigned int nb_subd; a4l_subd_t **subds; - int idx_read_subd; - int idx_write_subd; - - /* Buffer desc */ - a4l_buf_t **bufs; /* IRQ in use */ + /* TODO: irq_desc should vanish */ a4l_irq_desc_t irq_desc; - - /* Events/status desc */ - unsigned long *status; }; typedef struct a4l_transfer a4l_trf_t; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: change the context's role (broken)
Module: xenomai-abe Branch: analogy Commit: e1e19708538fed4b2d105db7300ac6822dfae3e4 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=e1e19708538fed4b2d105db7300ac6822dfae3e4 Author: Alexis Berlemont Date: Sun May 16 23:11:47 2010 +0200 analogy: change the context's role (broken) --- include/analogy/context.h | 27 +-- 1 files changed, 9 insertions(+), 18 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index 7bd225a..d30bbba 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -25,29 +25,20 @@ #if defined(__KERNEL__) && !defined(DOXYGEN_CPP) -#include - struct a4l_device; +struct a4l_buffer; -struct a4l_context { - - /* This field is redundant with the following parameters; - setting it at the head of the structure may save - useless operations */ - struct a4l_device *dev; +struct a4l_device_context { + /* No need to hold user_info, thanks to container_of, we could + get it back */ rtdm_user_info_t *user_info; - struct rtdm_dev_context *rtdm_cxt; -}; -typedef struct a4l_context a4l_cxt_t; -#define a4l_get_minor(x) ((x)->rtdm_cxt->device->device_id) + struct a4l_device *dev; /* Which is retrieved thanks to minor + at open time */ -#define a4l_init_cxt(c, u, x) \ -{ \ - (x)->rtdm_cxt = c; \ - (x)->user_info = u; \ - (x)->dev = NULL;\ -} + struct buffer buffer; /* The buffer field is extracted from +the transfer structure */ +}; #endif /* __KERNEL__ && !DOXYGEN_CPP */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: replace transfer setup functions with buffer setup ones (broken)
Module: xenomai-abe Branch: analogy Commit: 5ffbfff63c660ab048c560b9695b110d6471478e URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=5ffbfff63c660ab048c560b9695b110d6471478e Author: Alexis Berlemont Date: Mon May 17 23:31:20 2010 +0200 analogy: replace transfer setup functions with buffer setup ones (broken) --- ksrc/drivers/analogy/buffer.c |3 + ksrc/drivers/analogy/command.c | 19 +++ ksrc/drivers/analogy/instruction.c |2 +- ksrc/drivers/analogy/transfer.c| 98 +++ 4 files changed, 22 insertions(+), 100 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index a27a1d6..92f1f4e 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -145,6 +145,9 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) } buf_desc->end_count *= cmd->stop_arg; } + + __a4l_dbg(1, core_dbg, + "a4l_setup_buffer: end_count=%lu\n", buf_desc->end_count); return 0; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index a6c1dec..b300d9a 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -299,7 +299,8 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) { int ret = 0, simul_flag = 0; a4l_cmd_t *cmd_desc = NULL; - a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_subd_t *subd; + a4l_dev_t *dev = a4l_get_dev(cxt); __a4l_dbg(1, core_dbg, "a4l_ioctl_cmd: minor=%d\n", a4l_get_minor(cxt)); @@ -344,11 +345,11 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) __a4l_dbg(1, core_dbg, "a4l_ioctl_cmd: 1st cmd checks passed\n"); + subd = dev->transfer.subds[cmd_desc->idx_subd]; + /* Tests the command with the cmdtest function */ - if (dev->transfer.subds[cmd_desc->idx_subd]->do_cmdtest != NULL) - ret = dev->transfer.subds[cmd_desc->idx_subd]-> - do_cmdtest(dev->transfer.subds[cmd_desc->idx_subd], - cmd_desc); + if (subd->do_cmdtest != NULL) + ret = subd->do_cmdtest(subd, cmd_desc); if (ret != 0) { __a4l_err("a4l_ioctl_cmd: driver's cmd_test failed\n"); goto out_ioctl_cmd; @@ -363,17 +364,15 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) } /* Sets the concerned subdevice as busy */ - ret = a4l_reserve_transfer(cxt, cmd_desc->idx_subd); + ret = a4l_reserve_subd(subd); if (ret < 0) goto out_ioctl_cmd; /* Gets the transfer system ready */ - a4l_init_transfer(cxt, cmd_desc); + a4l_setup_buffer(cxt, cmd_desc); /* Eventually launches the command */ - ret = dev->transfer.subds[cmd_desc->idx_subd]-> - do_cmd(dev->transfer.subds[cmd_desc->idx_subd], - cmd_desc); + ret = subd->do_cmd(subd, cmd_desc); if (ret != 0) { a4l_cancel_transfer(cxt, cmd_desc->idx_subd); diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 64c7a04..941fa69 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -266,7 +266,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) /* Prevents the subdevice from being used during the following operations */ - ret = a4l_reserve_transfer(cxt, dsc->idx_subd); + ret = a4l_reserve_subd(subd); if (ret < 0) goto out_do_insn; diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index b1e511d..9fc279a 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -39,10 +39,6 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) a4l_trf_t *tsf; int i, err = 0; - __a4l_dbg(1, core_dbg, - "a4l_precleanup_transfer: minor=%d\n", - a4l_get_minor(cxt)); - dev = a4l_get_dev(cxt); tsf = &dev->transfer; @@ -55,6 +51,10 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt) for (i = 0; i < tsf->nb_subd; i++) { unsigned long *status = &tsf->subds[i]->status; + __a4l_dbg(1, core_dbg, + "a4l_precleanup_transfer: " + "subd[%d]->status=0x%08x\n", *status); + if (test_and_set_bit(A4L_SUBD_BUSY, status)) { __a4l_err("a4l_precleanup_transfer: " "device busy, acquisition occuring\n"); @@ -70,7 +70,7 @@ out_error: for (i = 0; i < tsf->nb_subd; i++) { unsigned long *status = &tsf->subds[i]->status; - if (test_bit(A4L_TSF_CLEAN, status)){ + if (test_bit(A4L_SUBD_CLEAN, status)){ clear_bit(A4L_SUBD_BUSY, status);
[Xenomai-git] Alexis Berlemont : analogy: update cancel functions (broken)
Module: xenomai-abe Branch: analogy Commit: 97b5574733c566b1538385aa06a8b1dedeeff736 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=97b5574733c566b1538385aa06a8b1dedeeff736 Author: Alexis Berlemont Date: Mon May 17 23:58:52 2010 +0200 analogy: update cancel functions (broken) --- ksrc/drivers/analogy/buffer.c | 58 - ksrc/drivers/analogy/transfer.c | 61 --- 2 files changed, 44 insertions(+), 75 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 92f1f4e..cb4beb7 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -91,10 +91,8 @@ out_virt_contig_alloc: return ret; } -int a4l_init_buffer(a4l_buf_t * buf_desc) +void a4l_init_buffer(a4l_buf_t * buf_desc) { - int err; - /* No command to process yet */ buf_desc->cur_cmd = NULL; @@ -111,13 +109,11 @@ int a4l_init_buffer(a4l_buf_t * buf_desc) /* Flush pending events */ buf_desc->flags = 0; a4l_flush_sync(&buf_desc->sync); - - return err; } int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) { - a4l_buf_t * buf_desc = cxt->buffer; + a4l_buf_t *buf_desc = cxt->buffer; int i; /* Retrieve the related subdevice */ @@ -152,6 +148,40 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return 0; } +int a4l_cancel_buffer(a4l_cxt_t *cxt) +{ + a4l_buf_t *buf_desc = cxt->buffer; + a4l_subd_t *subd = buf_desc->subd; + + int err = 0; + + if (!subd !! !a4l_check_subd(subd)) + return 0; + + /* If a "cancel" function is registered, call it + (Note: this function is called before having checked + if a command is under progress; we consider that + the "cancel" function can be used as as to (re)initialize + some component) */ + if (subd->cancel != NULL && (err = subd->cancel(subd)) < 0) { + __a4l_err("a4l_cancel: " + "subdevice %d cancel handler failed (err=%d)\n", + idx_subd, err); + } + + a4l_release_subd(subd); + + if (buf_desc->cur_cmd != NULL) { + a4l_free_cmddesc(buf_desc->cur_cmd); + rtdm_free(buf_desc->cur_cmd); + buf_desc->cur_cmd = NULL; + } + + a4l_init_buffer(buf_desc); + + return err; +} + /* --- current Command management function --- */ a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) @@ -646,13 +676,13 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) if ((ret < 0 && ret != -ENOENT) || (ret == -ENOENT && tmp_cnt == 0)) { - a4l_cancel_transfer(cxt, info.idx_subd); + a4l_cancel_buffer(cxt); return ret; } } else if (info.idx_subd == dev->transfer.idx_write_subd) { if (ret < 0) { - a4l_cancel_transfer(cxt, info.idx_subd); + a4l_cancel_buffer(cxt); if (info.rw_count != 0) return ret; } @@ -744,14 +774,14 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* We check whether there is an error */ if (ret < 0 && ret != -ENOENT) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = ret; goto out_a4l_read; } /* We check whether the acquisition is over */ if (ret == -ENOENT && tmp_cnt == 0) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = 0; goto out_a4l_read; } @@ -846,7 +876,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, tmp_cnt = nbytes - count; if (ret < 0) { - a4l_cancel_transfer(cxt, idx_subd); + a4l_cancel_buffer(cxt); count = (ret == -ENOENT) ? -EINVAL : ret; goto out_a4l_write; } @@ -993,20 +1023,20 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) /* Check if some error occured */ if (ret < 0 && ret != -ENOENT) { - a4l_cancel_transfer(cxt, poll.idx_subd); + a4l_cancel_buffer(cxt); return ret; } /* Check whether the acquisition is over */ if (ret == -ENOENT && tmp_cnt == 0) { - a4l_cancel_transfer(cxt, poll.idx_subd); + a4l_cancel_buffer(cxt); return
[Xenomai-git] Alexis Berlemont : analogy: rewrite the cancel ioctl handler (broken)
Module: xenomai-abe Branch: analogy Commit: 0c5e65bb66cc368965c76e62f01a61bc24470ae0 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=0c5e65bb66cc368965c76e62f01a61bc24470ae0 Author: Alexis Berlemont Date: Tue May 18 23:53:11 2010 +0200 analogy: rewrite the cancel ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 38 - ksrc/drivers/analogy/transfer.c | 45 --- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index cb4beb7..bc162d3 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd !! !a4l_check_subd(subd)) + if (!subd || !a4l_check_subd(subd)) return 0; /* If a "cancel" function is registered, call it @@ -547,6 +547,42 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) /* --- IOCTL / FOPS functions --- */ +int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) +{ + unsigned int idx_subd = (unsigned long)arg; + a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_subd_t *subd; + + /* Basically check the device */ + if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + __a4l_err("a4l_ioctl_cancel: operation not supported on " + "an unattached device\n"); + return -EINVAL; + } + + if (cxt->buffer->subd == NULL) { + __a4l_err("a4l_ioctl_cancel: " + "no acquisition to cancel on this context\n"); + return -EINVAL; + } + + if (idx_subd >= dev->transfer.nb_subd) { + __a4l_err("a4l_ioctl_cancel: bad subdevice index\n"); + return -EINVAL; + } + + subd = dev->transfer.subds[idx_subd]; + + if (subd != cxt->buffer.subd) { + __a4l_err("a4l_ioctl_cancel: " + "current context works on another subdevice " + "(%d!=%d)\n", cxt->buffer.subd->idx, subd->idx); + return -EINVAL; + } + + return a4l_cancel_buffer(cxt); +} + int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) { a4l_dev_t *dev = a4l_get_dev(cxt); diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index aa0ae82..945402f 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -290,49 +290,4 @@ int a4l_rdproc_transfer(char *page, #endif /* CONFIG_PROC_FS */ -/* --- IOCTL / FOPS functions --- */ - -int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) -{ - unsigned int idx_subd = (unsigned long)arg; - a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_subd_t *subd; - - __a4l_dbg(1, core_dbg, - "a4l_ioctl_cancel: minor=%d\n", a4l_get_minor(cxt)); - - /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { - __a4l_err("a4l_ioctl_cancel: operation not supported on " - "an unattached device\n"); - return -EINVAL; - } - - if (idx_subd >= dev->transfer.nb_subd) { - __a4l_err("a4l_ioctl_cancel: bad subdevice index\n"); - return -EINVAL; - } - - if ((dev->transfer.subds[idx_subd]->flags & A4L_SUBD_TYPES) == - A4L_SUBD_UNUSED) { - __a4l_err("a4l_ioctl_cancel: non functional subdevice\n"); - return -EIO; - } - - if (!(dev->transfer.subds[idx_subd]->flags & A4L_SUBD_CMD)) { - __a4l_err("a4l_ioctl_cancel: operation not supported, " - "synchronous only subdevice\n"); - return -EIO; - } - - subd = dev->transfer.subds[idx_subd]; - - if (!test_bit(A4L_TSF_BUSY, &(dev->transfer.status[idx_subd]))) { - __a4l_err("a4l_ioctl_cancel: subdevice currently idle\n"); - return -EINVAL; - } - - return a4l_cancel_transfer(cxt, idx_subd); -} - #endif /* !DOXYGEN_CPP */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix bulk flag declaration in buffer.h (broken)
Module: xenomai-abe Branch: analogy Commit: adb96dc6af6ebd10eab4e0e09c91e7fc3a3c0750 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=adb96dc6af6ebd10eab4e0e09c91e7fc3a3c0750 Author: Alexis Berlemont Date: Wed May 19 00:13:36 2010 +0200 analogy: fix bulk flag declaration in buffer.h (broken) --- include/analogy/buffer.h | 10 +- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 49d2a9f..786c8e1 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -45,7 +45,7 @@ /* Status bits */ #define A4L_BUF_BULK_NR 8 -#define A4L_BUF_MAP_NR 8 +#define A4L_BUF_MAP_NR 9 /* Status flags */ #define A4L_BUF_BULK (1 << A4L_BUF_BULK_NR) #define A4L_BUF_MAP (1 << A4L_BUF_MAP_NR) @@ -89,8 +89,8 @@ typedef struct a4l_buffer a4l_buf_t; /* Static inline Buffer related functions */ /* Produce memcpy function */ -static inline int __produce(a4l_cxt_t * cxt, - a4l_buf_t * buf, void *pin, unsigned long count) +static inline int __produce(a4l_cxt_t *cxt, + a4l_buf_t *buf, void *pin, unsigned long count) { unsigned long start_ptr = (buf->prd_count % buf->size); unsigned long tmp_cnt = count; @@ -119,8 +119,8 @@ static inline int __produce(a4l_cxt_t * cxt, } /* Consume memcpy function */ -static inline int __consume(a4l_cxt_t * cxt, - a4l_buf_t * buf, void *pout, unsigned long count) +static inline int __consume(a4l_cxt_t *cxt, + a4l_buf_t *buf, void *pout, unsigned long count) { unsigned long start_ptr = (buf->cns_count % buf->size); unsigned long tmp_cnt = count; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_read and a4l_write (broken)
Module: xenomai-abe Branch: analogy Commit: 1d0b89ad0e11f1fb631fdf2534ea81a42a2098f6 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=1d0b89ad0e11f1fb631fdf2534ea81a42a2098f6 Author: Alexis Berlemont Date: Wed May 19 00:15:00 2010 +0200 analogy: update a4l_read and a4l_write (broken) --- ksrc/drivers/analogy/buffer.c | 50 +--- 1 files changed, 16 insertions(+), 34 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index bc162d3..9bd9829 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -773,28 +773,21 @@ a4l_ioctl_bufinfo_out: ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - int idx_subd = dev->transfer.idx_read_subd; - a4l_buf_t *buf = dev->transfer.bufs[idx_subd]; + a4l_buf_t *buf = &cxt->buffer; ssize_t count = 0; /* Basic checkings */ + if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { __a4l_err("a4l_read: unattached device\n"); return -EINVAL; } - if (!test_bit(A4L_TSF_BUSY, &(dev->transfer.status[idx_subd]))) { - __a4l_err("a4l_read: idle subdevice\n"); + if (!buf->subd || !test_bit(A4L_SUBD_BUSY, &buf->subd->status)) { + __a4l_err("a4l_read: idle subdevice on this context\n"); return -ENOENT; } - /* TODO: to be removed - Check the subdevice capabilities */ - if ((dev->transfer.subds[idx_subd]->flags & A4L_SUBD_CMD) == 0) { - __a4l_err("a4l_read: incoherent state\n"); - return -EINVAL; - } - while (count < nbytes) { /* Check the events */ @@ -825,10 +818,9 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) if (tmp_cnt > 0) { /* Performs the munge if need be */ - if (dev->transfer.subds[idx_subd]->munge != NULL) { - __munge(dev->transfer.subds[idx_subd], - dev->transfer.subds[idx_subd]->munge, - buf, tmp_cnt); + if (buf->subd->munge != NULL) { + __munge(buf->subd, + buf->subd->munge, buf, tmp_cnt); /* Updates munge count */ buf->mng_count += tmp_cnt; @@ -850,8 +842,7 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* If the driver does not work in bulk mode, we must leave this function */ - if (!test_bit(A4L_TSF_BULK, - &(dev->transfer.status[idx_subd]))) + if (!test_bit(A4L_BUF_BULK, &buf->flags)) goto out_a4l_read; } /* If the acquisition is not over, we must not @@ -876,28 +867,21 @@ ssize_t a4l_write(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - int idx_subd = dev->transfer.idx_write_subd; - a4l_buf_t *buf = dev->transfer.bufs[idx_subd]; + a4l_buf_t *buf = &cxt->buffer; ssize_t count = 0; /* Basic checkings */ + if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { __a4l_err("a4l_write: unattached device\n"); return -EINVAL; } - if (!test_bit(A4L_TSF_BUSY, &(dev->transfer.status[idx_subd]))) { - __a4l_err("a4l_write: idle subdevice\n"); + if (!buf->subd || !test_bit(A4L_SUBD_BUSY, &buf->subd->status)) { + __a4l_err("a4l_read: idle subdevice on this context\n"); return -ENOENT; } - /* TODO: to be removed - Check the subdevice capabilities */ - if ((dev->transfer.subds[idx_subd]->flags & A4L_SUBD_CMD) == 0) { - __a4l_err("a4l_write: incoherent state\n"); - return -EINVAL; - } - while (count < nbytes) { /* Check the events */ @@ -928,10 +912,9 @@ ssize_t a4l_write(a4l_cxt_t *cxt, } /* Performs the munge if need be */ - if (dev->transfer.subds[idx_subd]->munge != NULL) { - __munge(dev->transfer.subds[idx_subd], - dev->transfer.subds[idx_subd]->munge, - buf, tmp_cnt); + if (buf->subd->munge != NULL) { + __munge(buf->subd, + buf->subd->munge, buf, tmp_cnt); /* Updates munge count */ buf->mng_c
[Xenomai-git] Alexis Berlemont : analogy: update all a4l_buf_* functions (broken)
Module: xenomai-abe Branch: analogy Commit: 57686246885bc39ae775ea013b8d2bd361e512fd URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=57686246885bc39ae775ea013b8d2bd361e512fd Author: Alexis Berlemont Date: Wed May 19 23:29:59 2010 +0200 analogy: update all a4l_buf_* functions (broken) --- include/analogy/buffer.h | 11 ++- ksrc/drivers/analogy/buffer.c| 157 -- ksrc/drivers/analogy/driver_facilities.c |4 +- 3 files changed, 51 insertions(+), 121 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 786c8e1..cf82811 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -329,9 +329,11 @@ static inline unsigned long __count_to_get(a4l_buf_t * buf) /* --- Buffer internal functions --- */ -int a4l_alloc_buffer(a4l_buf_t * buf_desc); +void a4l_init_buffer(a4l_buf_t * buf_desc); -void a4l_free_buffer(a4l_buf_t * buf_desc); +int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd); + +int a4l_cancel_buffer(a4l_cxt_t *cxt); int a4l_buf_prepare_absput(struct a4l_subdevice *subd, unsigned long count); @@ -369,7 +371,10 @@ unsigned long a4l_buf_count(struct a4l_subdevice *subd); /* --- Current Command management function --- */ -a4l_cmd_t *a4l_get_cmd(struct a4l_subdevice *subd); +static inline a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) +{ + return (subd->buf) ? subd->buf->cur_cmd : NULL; +} /* --- Munge related function --- */ diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 9bd9829..c9b1682 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -182,38 +182,17 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) return err; } -/* --- current Command management function --- */ - -a4l_cmd_t *a4l_get_cmd(a4l_subd_t *subd) -{ - a4l_dev_t *dev = subd->dev; - - /* Check that subdevice supports commands */ - if (dev->transfer.bufs == NULL) - return NULL; - - return dev->transfer.bufs[subd->idx]->cur_cmd; -} - /* --- Munge related function --- */ int a4l_get_chan(a4l_subd_t *subd) { - a4l_dev_t *dev = subd->dev; int i, j, tmp_count, tmp_size = 0; a4l_cmd_t *cmd; - /* Check that subdevice supports commands */ - if (dev->transfer.bufs == NULL) - return -EINVAL; - - /* Check a command is executed */ - if (dev->transfer.bufs[subd->idx]->cur_cmd == NULL) + cmd = a4l_get_cmd(subd); + if (!cmd) return -EINVAL; - /* Retrieve the proper command descriptor */ - cmd = dev->transfer.bufs[subd->idx]->cur_cmd; - /* There is no need to check the channel idx, it has already been controlled in command_test */ @@ -252,185 +231,128 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd->flags & A4L_SUBD_MASK_READ) == 0) + if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) return -EINVAL; - dev = subd->dev; - buf = dev->transfer.bufs[subd->idx]; - - return __pre_abs_put(buf, count); + return __pre_abs_put(subd->buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd->flags & A4L_SUBD_MASK_READ) == 0) + if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) return -EINVAL; - dev = subd->dev; - buf = dev->transfer.bufs[subd->idx]; - - return __abs_put(buf, count); + return __abs_put(subd->buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd->flags & A4L_SUBD_MASK_READ) == 0) + if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) return -EINVAL; - dev = subd->dev; - buf = dev->transfer.bufs[subd->idx]; - - return __pre_put(buf, count); + return __pre_put(subd->buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd->flags & A4L_SUBD_MASK_READ) == 0) + if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) return -EINVAL; - dev = subd->dev; - buf = dev->transfer.bufs[subd->idx]; - - return __put(buf, count); + return __put(subd->buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { int err; - a4l_dev_t *dev; - a4l_buf_t *buf; - - if ((subd->flags & A4L_SUBD_MASK_READ) == 0) - return -EINVAL; - dev = subd->dev; - buf = dev->transfer.bufs[subd->idx]; - - if (__count_to_put(buf) < c
[Xenomai-git] Alexis Berlemont : analogy: last updates in the buffer part (broken)
Module: xenomai-abe Branch: analogy Commit: f9ba3a5c1bff489f7515dd7269a160fab57d250c URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=f9ba3a5c1bff489f7515dd7269a160fab57d250c Author: Alexis Berlemont Date: Wed May 19 23:35:12 2010 +0200 analogy: last updates in the buffer part (broken) --- ksrc/drivers/analogy/buffer.c | 13 ++--- 1 files changed, 2 insertions(+), 11 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index c9b1682..011753a 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -387,8 +387,8 @@ void a4l_unmap(struct vm_area_struct *area) } static struct vm_operations_struct a4l_vm_ops = { -open:a4l_map, -close:a4l_unmap, + .open = a4l_map, + .close = a4l_unmap, }; int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) @@ -397,9 +397,6 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) a4l_dev_t *dev; int ret; - __a4l_dbg(1, core_dbg, - "a4l_ioctl_mmap: minor=%d\n", a4l_get_minor(cxt)); - /* The mmap operation cannot be performed in a real-time context */ if (rtdm_in_rt_context()) { @@ -511,9 +508,6 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) a4l_dev_t *dev = a4l_get_dev(cxt); a4l_bufcfg_t buf_cfg; - __a4l_dbg(1, core_dbg, - "a4l_ioctl_bufcfg: minor=%d\n", a4l_get_minor(cxt)); - /* As Linux API is used to allocate a virtual buffer, the calling process must not be in primary mode */ if (rtdm_in_rt_context()) { @@ -580,9 +574,6 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) unsigned long tmp_cnt; int ret; - __a4l_dbg(1, core_dbg, - "a4l_ioctl_bufinfo: minor=%d\n", a4l_get_minor(cxt)); - if (!rtdm_in_rt_context() && rtdm_rt_capable(cxt->user_info)) return -ENOSYS; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_get_minor function (broken)
Module: xenomai-abe Branch: analogy Commit: c01e2c73b3a7cd0b7e4fd70531f57895c43edc47 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=c01e2c73b3a7cd0b7e4fd70531f57895c43edc47 Author: Alexis Berlemont Date: Mon May 24 23:33:13 2010 +0200 analogy: update a4l_get_minor function (broken) --- include/analogy/context.h | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index e0cf01c..2442b6c 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -25,6 +25,8 @@ #if defined(__KERNEL__) && !defined(DOXYGEN_CPP) +#include + struct a4l_device; struct a4l_buffer; @@ -43,6 +45,14 @@ struct a4l_device_context { struct buffer buffer; }; +static inline int a4l_get_minor(a4l_cxt_t *cxt) +{ + /* Get a pointer on the container structure */ + struct rtdm_dev_context * rtdm_cxt = rtdm_private_to_context(cxt); + /* Get the minor index */ + return rtdm_cxt->device->device_id; +} + #endif /* __KERNEL__ && !DOXYGEN_CPP */ #endif /* __ANALOGY_CONTEXT__ */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: cosmetic changes (broken)
Module: xenomai-abe Branch: analogy Commit: 6a938fc4aca54a01ed2ec8cfa68c076138186f36 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=6a938fc4aca54a01ed2ec8cfa68c076138186f36 Author: Alexis Berlemont Date: Mon May 24 16:44:03 2010 +0200 analogy: cosmetic changes (broken) --- ksrc/drivers/analogy/buffer.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 011753a..0ca1b4c 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -35,7 +35,7 @@ /* --- Initialization functions (init, alloc, free) --- */ -void a4l_free_buffer(a4l_buf_t * buf_desc) +void a4l_free_buffer(a4l_buf_t *buf_desc) { if (buf_desc->pg_list != NULL) { rtdm_free(buf_desc->pg_list); @@ -52,7 +52,7 @@ void a4l_free_buffer(a4l_buf_t * buf_desc) } } -int a4l_alloc_buffer(a4l_buf_t * buf_desc, int buf_size) +int a4l_alloc_buffer(a4l_buf_t *buf_desc, int buf_size) { int ret = 0; char *vaddr, *vabase; @@ -91,7 +91,7 @@ out_virt_contig_alloc: return ret; } -void a4l_init_buffer(a4l_buf_t * buf_desc) +void a4l_init_buffer(a4l_buf_t *buf_desc) { /* No command to process yet */ buf_desc->cur_cmd = NULL; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: declare the reserve / release functions at the subd level (broken)
Module: xenomai-abe Branch: analogy Commit: 7f58510b4748a25aef03e17b1d4ded1f6bf4d96d URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=7f58510b4748a25aef03e17b1d4ded1f6bf4d96d Author: Alexis Berlemont Date: Mon May 24 16:46:31 2010 +0200 analogy: declare the reserve / release functions at the subd level (broken) --- include/analogy/subdevice.h|2 ++ ksrc/drivers/analogy/command.c | 33 - ksrc/drivers/analogy/instruction.c |2 +- ksrc/drivers/analogy/subdevice.c | 15 +++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 0f9e1c5..ded82f3 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -290,6 +290,8 @@ a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd); +int a4l_reserve_subd(a4l_subd_t *subd); +void a4l_release_subd(a4l_subd_t *subd); int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg); diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index b300d9a..94d6137 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -90,11 +90,8 @@ void a4l_free_cmddesc(a4l_cmd_t * desc) int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc) { - int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - - __a4l_dbg(1, core_dbg, -"a4l_check_cmddesc: minor=%d\n", a4l_get_minor(cxt)); + a4l_subd_t *subd; if (desc->idx_subd >= dev->transfer.nb_subd) { __a4l_err("a4l_check_cmddesc: " @@ -103,25 +100,23 @@ int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc) return -EINVAL; } - if ((dev->transfer.subds[desc->idx_subd]->flags & A4L_SUBD_TYPES) == - A4L_SUBD_UNUSED) { + subd = dev->transfer.subds[desc->idx_subd]; + + if ((subd->flags & A4L_SUBD_TYPES) == A4L_SUBD_UNUSED) { __a4l_err("a4l_check_cmddesc: " "subdevice type incoherent\n"); return -EIO; } - if (!(dev->transfer.subds[desc->idx_subd]->flags & A4L_SUBD_CMD)) { + if (!(subd->flags & A4L_SUBD_CMD)) { __a4l_err("a4l_check_cmddesc: operation not supported, " "synchronous only subdevice\n"); return -EIO; } - if (test_bit(A4L_TSF_BUSY, &(dev->transfer.status[desc->idx_subd]))) - return -EBUSY; - - if (ret != 0) { + if (test_bit(A4L_SUBD_BUSY, &subd->status)) { __a4l_err("a4l_check_cmddesc: subdevice busy\n"); - return ret; + return -EBUSY; } return a4l_check_chanlist(dev->transfer.subds[desc->idx_subd], @@ -299,17 +294,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) { int ret = 0, simul_flag = 0; a4l_cmd_t *cmd_desc = NULL; - a4l_subd_t *subd; a4l_dev_t *dev = a4l_get_dev(cxt); - - __a4l_dbg(1, core_dbg, - "a4l_ioctl_cmd: minor=%d\n", a4l_get_minor(cxt)); + a4l_subd_t *subd; /* The command launching cannot be done in real-time because of some possible buffer allocations in the drivers */ - if (rtdm_in_rt_context()) { + if (rtdm_in_rt_context()) return -ENOSYS; - } /* Basically check the device */ if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { @@ -373,13 +364,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) /* Eventually launches the command */ ret = subd->do_cmd(subd, cmd_desc); - + if (ret != 0) { - a4l_cancel_transfer(cxt, cmd_desc->idx_subd); + a4l_cancel_buffer(cxt); goto out_ioctl_cmd; } - out_ioctl_cmd: +out_ioctl_cmd: if (ret != 0 || simul_flag == 1) { a4l_free_cmddesc(cmd_desc); rtdm_free(cmd_desc); diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 941fa69..413c0d2 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -281,7 +281,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) out_do_insn: /* Releases the subdevice from its reserved state */ - a4l_cancel_transfer(cxt, dsc->idx_subd); + a4l_release_subd(subd); return ret; } diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 1278081..506b742 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -180,6 +180,21 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx) return s
[Xenomai-git] Alexis Berlemont : analogy: update a4l_set_dev and remove useless info traces (broken)
Module: xenomai-abe Branch: analogy Commit: 3015e49c2210d440ffbc44e5b00131b374a41146 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=3015e49c2210d440ffbc44e5b00131b374a41146 Author: Alexis Berlemont Date: Mon May 24 23:34:19 2010 +0200 analogy: update a4l_set_dev and remove useless info traces (broken) --- include/analogy/device.h |2 +- ksrc/drivers/analogy/device.c | 39 +-- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 51b99b5..6930a38 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -91,7 +91,7 @@ int a4l_rdproc_devs(char *page, off_t off, int count, int *eof, void *data); /* --- Context related function / macro --- */ -void a4l_set_dev(struct rtdm_dev_context *context); +void a4l_set_dev(a4l_cxt_t *cxt); #define a4l_get_dev(x) ((x)->dev) /* --- Upper layer functions --- */ diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index 4a3c879..a2d23c8 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -43,8 +43,6 @@ void a4l_init_devs(void) for (i = 0; i < A4L_NB_DEVICES; i++) { a4l_lock_init(&a4l_devs[i].lock); a4l_devs[i].transfer.irq_desc.irq = A4L_IRQ_UNUSED; - a4l_devs[i].transfer.idx_read_subd = A4L_IDX_UNUSED; - a4l_devs[i].transfer.idx_write_subd = A4L_IDX_UNUSED; } } @@ -59,13 +57,10 @@ int a4l_check_cleanup_devs(void) return ret; } -void a4l_set_dev(struct rtdm_dev_context *context) +void a4l_set_dev(a4l_cxt_t *cxt) { - /* Get the context's private structure */ - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; - /* Retrive the minor index */ - static int minor = context->device->device_id; - + /* Retrieve the minor index */ + static int minor = a4l_get_minor(cxt); /* Fill the dev fields accordingly */ cxt->dev = &(a4l_devs[minor]); } @@ -208,9 +203,6 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt, char *tmpname = NULL; void *tmpopts = NULL; - __a4l_dbg(1, core_dbg, - "a4l_fill_lnkdesc: minor=%d\n", a4l_get_minor(cxt)); - ret = rtdm_safe_copy_from_user(cxt->user_info, link_arg, arg, sizeof(a4l_lnkdesc_t)); if (ret != 0) { @@ -285,9 +277,6 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt, void a4l_free_lnkdesc(a4l_cxt_t * cxt, a4l_lnkdesc_t * link_arg) { - __a4l_dbg(1, core_dbg, - "a4l_free_lnkdesc: minor=%d\n", a4l_get_minor(cxt)); - if (link_arg->bname != NULL) rtdm_free(link_arg->bname); @@ -301,9 +290,6 @@ int a4l_assign_driver(a4l_cxt_t * cxt, int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - "a4l_assign_driver: minor=%d\n", a4l_get_minor(cxt)); - dev->driver = drv; if (drv->privdata_size == 0) @@ -355,9 +341,6 @@ int a4l_release_driver(a4l_cxt_t * cxt) int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - "a4l_release_driver: minor=%d\n", a4l_get_minor(cxt)); - if ((ret = dev->driver->detach(dev)) != 0) goto out_release_driver; @@ -388,9 +371,6 @@ int a4l_device_attach(a4l_cxt_t * cxt, void *arg) a4l_lnkdesc_t link_arg; a4l_drv_t *drv = NULL; - __a4l_dbg(1, core_dbg, - "a4l_device_attach: minor=%d\n", a4l_get_minor(cxt)); - if ((ret = a4l_fill_lnkdesc(cxt, &link_arg, arg)) != 0) goto out_attach; @@ -412,9 +392,6 @@ int a4l_device_detach(a4l_cxt_t * cxt) { a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - "a4l_device_detach: minor=%d\n", a4l_get_minor(cxt)); - if (dev->driver == NULL) { __a4l_err("a4l_device_detach: " "incoherent state, driver not reachable\n"); @@ -430,9 +407,6 @@ int a4l_ioctl_devcfg(a4l_cxt_t * cxt, void *arg) { int ret = 0; - __a4l_dbg(1, core_dbg, - "a4l_ioctl_devcfg: minor=%d\n", a4l_get_minor(cxt)); - if (rtdm_in_rt_context()) return -ENOSYS; @@ -487,9 +461,6 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg) a4l_dvinfo_t info; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - "a4l_ioctl_devinfo: minor=%d\n", a4l_get_minor(cxt)); - memset(&info, 0, sizeof(a4l_dvinfo_t)); if (test_bit(A4L_DEV_ATTACHED, &dev->flags)) { @@ -498,8 +469,8 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg) memcpy(info.board_name, dev->driver->board_name, len); info.nb_subd = dev->transfer.nb_subd; - info.idx_read_subd = dev->transfer.idx_read_sub
[Xenomai-git] Alexis Berlemont : analogy: use rtdm_context_to_private (broken)
Module: xenomai-abe Branch: analogy Commit: 01339f596e71dd9262b4b8b8d5901d4a8fac2cb3 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=01339f596e71dd9262b4b8b8d5901d4a8fac2cb3 Author: Alexis Berlemont Date: Mon May 24 23:35:47 2010 +0200 analogy: use rtdm_context_to_private (broken) --- ksrc/drivers/analogy/rtdm_interface.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index d37ce4c..6525425 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -124,11 +124,11 @@ void a4l_cleanup_proc(void) int a4l_open(struct rtdm_dev_context *context, rtdm_user_info_t * user_info, int flags) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Get a pointer on the selected device (thanks to minor index) */ - a4l_set_dev(context); + a4l_set_dev(cxt); /* Initialize the buffer structure */ a4l_init_buffer(&cxt->buffer); @@ -146,7 +146,7 @@ int a4l_open(struct rtdm_dev_context *context, int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) { int err; - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ err = a4l_cancel_buffer(&cxt->buffer); @@ -164,7 +164,7 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) ssize_t a4l_read(struct rtdm_dev_context * context, rtdm_user_info_t * user_info, void *buf, size_t nbytes) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() && rtdm_rt_capable(user_info)) @@ -181,7 +181,7 @@ ssize_t a4l_read(struct rtdm_dev_context * context, ssize_t a4l_write(struct rtdm_dev_context * context, rtdm_user_info_t *user_info, const void *buf, size_t nbytes) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() && rtdm_rt_capable(user_info)) @@ -198,7 +198,7 @@ ssize_t a4l_write(struct rtdm_dev_context * context, int a4l_ioctl(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, unsigned int request, void *arg) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); cxt->user_info = user_info; @@ -209,7 +209,7 @@ int a4l_rt_select(struct rtdm_dev_context *context, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); return a4l_select(cxt, selector, type, fd_index); } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: minor fix in the subdevice structure declaration
Module: xenomai-abe Branch: analogy Commit: 90e8bc069d31a4b4dbdd3e7e0089b0bb884c7f04 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=90e8bc069d31a4b4dbdd3e7e0089b0bb884c7f04 Author: Alexis Berlemont Date: Fri Jun 4 00:04:41 2010 +0200 analogy: minor fix in the subdevice structure declaration --- include/analogy/buffer.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index cf82811..4846a4e 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -56,7 +56,7 @@ struct a4l_subdevice; struct a4l_buffer { /* Added by the structure update */ - a4l_subd_t *subd; + struct a4l_subdevice *subd; /* Buffer's first virtual page pointer */ void *buf; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: add some helper macros to test the subdevice' s characteristics
Module: xenomai-abe Branch: analogy Commit: 9f9df2ba10763c08f48f802bef32fb7f5854faa8 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=9f9df2ba10763c08f48f802bef32fb7f5854faa8 Author: Alexis Berlemont Date: Fri Jun 4 00:06:05 2010 +0200 analogy: add some helper macros to test the subdevice's characteristics --- include/analogy/subdevice.h | 16 ++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index ded82f3..0337092 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -286,12 +286,24 @@ int a4l_check_chanlist(a4l_subd_t * subd, /* --- Upper layer functions --- */ +static inline int a4l_reserve_subd(a4l_subd_t *subd) +{ +return test_and_set_bit(A4L_SUBD_BUSY, &subd->status) ? -EBUSY : 0; +} +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, &(x)->status)) +#define a4l_subd_is_busy(x) test_bit(A4L_SUBD_BUSY, &(x)->status)) + +#define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0) +/* The following macro considers that a DIO subdevice is firstly an + output subdevice */ +#define a4l_subd_is_output(x) \ + ((A4L_SUBD_MASK_WRITE & (x)->flags) != 0 || \ +(A4L_SUBD_DIO & (x)->flags) != 0) + a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd); -int a4l_reserve_subd(a4l_subd_t *subd); -void a4l_release_subd(a4l_subd_t *subd); int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the buffer syscalls (ioctl + r/w) after buffer review (broken)
Module: xenomai-abe Branch: analogy Commit: c76fc97b5493a8779f94233a01cdc8221633b7bb URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=c76fc97b5493a8779f94233a01cdc8221633b7bb Author: Alexis Berlemont Date: Fri Jun 4 00:09:04 2010 +0200 analogy: fix the buffer syscalls (ioctl + r/w) after buffer review (broken) --- ksrc/drivers/analogy/buffer.c | 173 + 1 files changed, 73 insertions(+), 100 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 0ca1b4c..d3db892 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -506,6 +506,8 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) { a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_buf_t *buf = cxt->buf; + a4l_subd_t *subd = buf->subd; a4l_bufcfg_t buf_cfg; /* As Linux API is used to allocate a virtual buffer, @@ -525,17 +527,9 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) arg, sizeof(a4l_bufcfg_t)) != 0) return -EFAULT; - /* Check the subdevice */ - if (buf_cfg.idx_subd >= dev->transfer.nb_subd) { - __a4l_err("a4l_ioctl_bufcfg: subdevice index " - "out of range (idx=%d)\n", buf_cfg.idx_subd); - return -EINVAL; - } - - if ((dev->transfer.subds[buf_cfg.idx_subd]->flags & A4L_SUBD_CMD) == 0) { - __a4l_err("a4l_ioctl_bufcfg: operation not supported, " - "synchronous only subdevice\n"); - return -EINVAL; + if (subd && a4l_subd_is_busy(subd)) { + __a4l_err("a4l_ioctl_bufcfg: acquisition in progress\n"); + return -EBUSY; } if (buf_cfg.buf_size > A4L_BUF_MAXSIZE) { @@ -543,34 +537,26 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) return -EINVAL; } - /* If a transfer is occuring or if the buffer is mmapped, - no buffer size change is allowed */ - if (test_bit(A4L_TSF_BUSY, -&(dev->transfer.status[buf_cfg.idx_subd]))) { - __a4l_err("a4l_ioctl_bufcfg: acquisition in progress\n"); - return -EBUSY; - } - - if (test_bit(A4L_TSF_MMAP, -&(dev->transfer.status[buf_cfg.idx_subd]))) { + if (test_bit(A4L_BUF_MAP, &buf->flags)) { __a4l_err("a4l_ioctl_bufcfg: please unmap before " "configuring buffer\n"); return -EPERM; } - /* Performs the re-allocation */ - a4l_free_buffer(dev->transfer.bufs[buf_cfg.idx_subd]); + /* Free the buffer... */ + a4l_free_buffer(buf); - dev->transfer.bufs[buf_cfg.idx_subd]->size = buf_cfg.buf_size; - - return a4l_alloc_buffer(dev->transfer.bufs[buf_cfg.idx_subd]); + /* ...to reallocate it */ + return a4l_alloc_buffer(buf, buf_cfg.buf_size); } int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) { a4l_dev_t *dev = a4l_get_dev(cxt); + a4l_buf_t *buf = cxt->buffer; + a4l_buf_t *subd = buf->subd; a4l_bufinfo_t info; - a4l_buf_t *buf; + unsigned long tmp_cnt; int ret; @@ -587,32 +573,17 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) &info, arg, sizeof(a4l_bufinfo_t)) != 0) return -EFAULT; - /* Check the subdevice */ - if (info.idx_subd >= dev->transfer.nb_subd) { - __a4l_err("a4l_ioctl_bufinfo: subdevice index " - "out of range (idx=%d)\n", info.idx_subd); - return -EINVAL; - } - - if ((dev->transfer.subds[info.idx_subd]->flags & A4L_SUBD_CMD) == 0) { - __a4l_err("a4l_ioctl_bufinfo: operation not supported, " - "synchronous only subdevice\n"); - return -EINVAL; - } - - buf = dev->transfer.bufs[info.idx_subd]; /* If a transfer is not occuring, simply return buffer informations, otherwise make the transfer progress */ - if (!test_bit(A4L_TSF_BUSY, - &(dev->transfer.status[info.idx_subd]))) { + if (!subd || !a4l_subd_is_busy(subd)) { info.rw_count = 0; goto a4l_ioctl_bufinfo_out; } ret = __handle_event(buf); - if (info.idx_subd == dev->transfer.idx_read_subd) { + if (a4l_subd_is_input(sudb)) { /* Updates consume count if rw_count is not null */ if (info.rw_count != 0) @@ -629,7 +600,7 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) a4l_cancel_buffer(cxt); return ret; } - } else if (info.idx_subd == dev->transfer.idx_write_subd) { + } else if (a4l_subd_is_output(sudb)) {
[Xenomai-git] Alexis Berlemont : analogy: remove useless functions in the subdevice part
Module: xenomai-abe Branch: analogy Commit: 8f71f45062332d9e8e9ead64b458f25c243dc4f6 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=8f71f45062332d9e8e9ead64b458f25c243dc4f6 Author: Alexis Berlemont Date: Fri Jun 4 00:06:49 2010 +0200 analogy: remove useless functions in the subdevice part --- ksrc/drivers/analogy/subdevice.c | 15 --- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 506b742..1278081 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -180,21 +180,6 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx) return subd; } -int a4l_reserve_subd(a4l_subd_t *subd) -{ -if (test_and_set_bit(A4L_SUBD_BUSY, &subd->status)) { -__a4l_err("a4l_reserve_subd: subdevice currently busy\n"); -return -EBUSY; -} - -return 0; -} - -void a4l_release_subd(a4l_subd_t *subd) -{ - clear_bit(A4L_SUBD_BUSY, &subd->status)); -} - /* --- IOCTL / FOPS functions --- */ int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg) ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the declaration of the structure a4l_context (broken)
Module: xenomai-abe Branch: analogy Commit: 58ebd5b7efe0cc0ac1e82991d12125ce34dfeee3 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=58ebd5b7efe0cc0ac1e82991d12125ce34dfeee3 Author: Alexis Berlemont Date: Sun Jun 6 16:21:44 2010 +0200 analogy: fix the declaration of the structure a4l_context (broken) In the structure a4l_context, replace the field buffer by a pointer to the structure a4l_buffer (a4l_buf_t -> a4l_buf_t *). That fixes a bug in the headers dependencies. --- include/analogy/context.h |3 ++- ksrc/drivers/analogy/buffer.c | 12 ++-- ksrc/drivers/analogy/rtdm_interface.c | 14 ++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index 2442b6c..3e61697 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -42,8 +42,9 @@ struct a4l_device_context { /* The buffer structure contains everything to transfer data from asynchronous acquisition operations on a specific subdevice */ - struct buffer buffer; + struct a4l_buffer *buffer; }; +typedef struct a4l_device_context a4l_cxt_t; static inline int a4l_get_minor(a4l_cxt_t *cxt) { diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index d3db892..1b413cc 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -493,10 +493,10 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) subd = dev->transfer.subds[idx_subd]; - if (subd != cxt->buffer.subd) { + if (subd != cxt->buffer->subd) { __a4l_err("a4l_ioctl_cancel: " "current context works on another subdevice " - "(%d!=%d)\n", cxt->buffer.subd->idx, subd->idx); + "(%d!=%d)\n", cxt->buffer->subd->idx, subd->idx); return -EINVAL; } @@ -658,7 +658,7 @@ a4l_ioctl_bufinfo_out: ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_buf_t *subd = buf->subd; ssize_t count = 0; @@ -758,7 +758,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_subd_t *subd = buf->subd; ssize_t count = 0; @@ -849,7 +849,7 @@ int a4l_select(a4l_cxt_t *cxt, enum rtdm_selecttype type, unsigned fd_index) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_subd_t *subd = buf->subd; /* Basic checkings */ @@ -894,7 +894,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) int ret = 0; unsigned long tmp_cnt = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_buf_t *subd = buf->subd; a4l_poll_t poll; diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index 6525425..8cfdf04 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -131,14 +131,15 @@ int a4l_open(struct rtdm_dev_context *context, a4l_set_dev(cxt); /* Initialize the buffer structure */ - a4l_init_buffer(&cxt->buffer); + cxt->buffer = rtdm_malloc(sizeof(a4l_buf_t)); + a4l_init_buffer(cxt->buffer); /* Allocate the asynchronous buffer NOTE: it should be interesting to allocate the buffer only on demand especially if the system is short of memory NOTE2: the default buffer size could be configured via kernel config*/ - a4l_alloc_buffer(&cxt->buffer, A4L_DEFAULT_BFSIZE); + a4l_alloc_buffer(cxt->buffer, A4L_DEFAULT_BFSIZE); return 0; } @@ -149,15 +150,20 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ - err = a4l_cancel_buffer(&cxt->buffer); + err = a4l_cancel_buffer(cxt->buffer); if (err < 0) { __a4l_err("close: unable to stop the asynchronous transfer\n"); return err; } /* Free the buffer which was linked with this context */ - err = a4l_free_buffer(&cxt->buffer); + err = a4l_free_buffer(cxt->buffer); + if (err < 0) + goto out; + rtdm_free(cxt->buffer); + +out: return err; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: analogy Commit: c8f4e5434c2310d870ceb8f53cf74c73c0610762 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=c8f4e5434c2310d870ceb8f53cf74c73c0610762 Author: Alexis Berlemont Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc->subd == NULL) { __a4l_err("a4l_setup_buffer: subdevice index " "out of range (%d)\n", cmd->idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a "cancel" function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the "cancel" function can be used as as to (re)initialize some component) */ if (subd->cancel != NULL && (err = subd->cancel(subd)) < 0) { - __a4l_err("a4l_cancel: " - "subdevice %d cancel handler failed (err=%d)\n", - idx_subd, err); + __a4l_err("a4l_cancel: cancel handler failed (err=%d)\n", err); } a4l_release_subd(subd); + subd->buf = NULL; if (buf_desc->cur_cmd != NULL) { a4l_free_cmddesc(buf_desc->cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits -> bytes */ tmp_size /= 8; - tmp_count = dev->transfer.bufs[subd->idx]->mng_count % tmp_size; + tmp_count = subd->buf->mng_count % tmp_size; /* Translation bytes -> bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd->buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd->buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd->buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd->buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd->buf; int err; - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd->buf) < count) + if (__count_to_put(buf) < count) return -EAGAIN; - err = __produce(NULL, subd->buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err < 0) return err; - err = __put(subd->buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_WRITE) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd))
[Xenomai-git] Alexis Berlemont : analogy: fix buffer's compilation issues (broken)
Module: xenomai-abe Branch: analogy Commit: d085550405bbd0b20d4b8bfa218e1f16194ba7ea URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=d085550405bbd0b20d4b8bfa218e1f16194ba7ea Author: Alexis Berlemont Date: Thu Jun 10 22:42:40 2010 +0200 analogy: fix buffer's compilation issues (broken) --- include/analogy/buffer.h | 21 + 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 4846a4e..4bd5db0 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -32,6 +32,7 @@ #include +#include #include /* Events bits */ @@ -179,11 +180,11 @@ static inline int __handle_event(a4l_buf_t * buf) /* The event "End of acquisition" must not be cleaned before the complete flush of the buffer */ - if (test_bit(A4L_BUF_EOA_NR, &buf->evt_flags)) { + if (test_bit(A4L_BUF_EOA_NR, &buf->flags)) { ret = -ENOENT; } - if (test_bit(A4L_BUF_ERROR_NR, &buf->evt_flags)) { + if (test_bit(A4L_BUF_ERROR_NR, &buf->flags)) { ret = -EPIPE; } @@ -195,7 +196,7 @@ static inline int __handle_event(a4l_buf_t * buf) static inline int __pre_abs_put(a4l_buf_t * buf, unsigned long count) { if (count - buf->tmp_count > buf->size) { - set_bit(A4L_BUF_ERROR_NR, &buf->evt_flags); + set_bit(A4L_BUF_ERROR_NR, &buf->flags); return -EPIPE; } @@ -235,7 +236,7 @@ static inline int __pre_abs_get(a4l_buf_t * buf, unsigned long count) was not greater a few cycles before; in such case, the DMA channel would have retrieved the wrong data */ if ((long)(count - buf->tmp_count) > 0) { - set_bit(A4L_BUF_ERROR_NR, &buf->evt_flags); + set_bit(A4L_BUF_ERROR_NR, &buf->flags); return -EPIPE; } @@ -260,10 +261,10 @@ static inline int __abs_put(a4l_buf_t * buf, unsigned long count) buf->prd_count = count; if ((old / buf->size) != (count / buf->size)) - set_bit(A4L_BUF_EOBUF_NR, &buf->evt_flags); + set_bit(A4L_BUF_EOBUF_NR, &buf->flags); if (buf->end_count != 0 && (long)(count - buf->end_count) >= 0) - set_bit(A4L_BUF_EOA_NR, &buf->evt_flags); + set_bit(A4L_BUF_EOA_NR, &buf->flags); return 0; } @@ -283,10 +284,10 @@ static inline int __abs_get(a4l_buf_t * buf, unsigned long count) buf->cns_count = count; if ((old / buf->size) != count / buf->size) - set_bit(A4L_BUF_EOBUF_NR, &buf->evt_flags); + set_bit(A4L_BUF_EOBUF_NR, &buf->flags); if (buf->end_count != 0 && (long)(count - buf->end_count) >= 0) - set_bit(A4L_BUF_EOA_NR, &buf->evt_flags); + set_bit(A4L_BUF_EOA_NR, &buf->flags); return 0; } @@ -329,6 +330,10 @@ static inline unsigned long __count_to_get(a4l_buf_t * buf) /* --- Buffer internal functions --- */ +int a4l_alloc_buffer(a4l_buf_t *buf_desc, int buf_size); + +void a4l_free_buffer(a4l_buf_t *buf_desc); + void a4l_init_buffer(a4l_buf_t * buf_desc); int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [pcimio] fix a huge hack in the mite initialization (broken)
Module: xenomai-abe Branch: analogy Commit: 5595f80f055fdc8c3a41339a9a2cfae698c3d161 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=5595f80f055fdc8c3a41339a9a2cfae698c3d161 Author: Alexis Berlemont Date: Thu Jun 10 23:59:00 2010 +0200 analogy: [pcimio] fix a huge hack in the mite initialization (broken) --- .../analogy/national_instruments/mio_common.c | 28 +-- ksrc/drivers/analogy/national_instruments/mite.c | 10 +++--- ksrc/drivers/analogy/national_instruments/mite.h |2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index 46efd03..ead64b8 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -511,7 +511,7 @@ static int ni_ao_wait_for_dma_load(a4l_subd_t *subd) static const int timeout = 1; a4l_dev_t *dev = subd->dev; - a4l_buf_t *buf = dev->transfer.bufs[subd->idx]; + a4l_buf_t *buf = subd->buf; int i; @@ -522,7 +522,7 @@ static int ni_ao_wait_for_dma_load(a4l_subd_t *subd) b_status = devpriv->stc_readw(dev, AO_Status_1_Register); - buffer_filled = test_bit(A4L_BUF_EOA_NR, &buf->evt_flags); + buffer_filled = test_bit(A4L_BUF_EOA_NR, &buf->flags); buffer_filled |= (b_status & AO_FIFO_Half_Full_St); if (buffer_filled) @@ -727,10 +727,9 @@ static void ni_handle_eos(a4l_subd_t *subd) static void ni_event(a4l_subd_t * subd) { /* Temporary hack */ - a4l_dev_t *dev = subd->dev; - a4l_buf_t *buf = dev->transfer.bufs[subd->idx]; + a4l_buf_t *buf = subd->buf; - if(test_bit(A4L_BUF_ERROR_NR, &buf->evt_flags)) { + if(test_bit(A4L_BUF_ERROR_NR, &buf->flags)) { if (subd->cancel != NULL) subd->cancel(subd); } @@ -1426,17 +1425,16 @@ static void ni_ai_munge32(a4l_subd_t *subd, void *buf, unsigned long size) #if (defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE) || \ defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE_MODULE)) -static int ni_ai_setup_MITE_dma(a4l_dev_t *dev) +static int ni_ai_setup_MITE_dma(a4l_subd_t *subd) { + a4l_dev_t *dev = subd->dev; int retval; retval = ni_request_ai_mite_channel(dev); if (retval) return retval; - /* Huge hack */ - mite_buf_change(devpriv->ai_mite_chan->ring, - dev->transfer.bufs[NI_AI_SUBDEV]); + mite_buf_change(devpriv->ai_mite_chan->ring, subd); switch (boardtype.reg_type) { case ni_reg_611x: @@ -1457,8 +1455,10 @@ static int ni_ai_setup_MITE_dma(a4l_dev_t *dev) return 0; } -static int ni_ao_setup_MITE_dma(a4l_dev_t *dev) +static int ni_ao_setup_MITE_dma(a4l_subd_t *subd) { + a4l_dev_t *dev = subd->dev; + int retval; unsigned long flags; @@ -1466,9 +1466,7 @@ static int ni_ao_setup_MITE_dma(a4l_dev_t *dev) if (retval) return retval; - /* Huge hack */ - mite_buf_change(devpriv->ao_mite_chan->ring, - dev->transfer.bufs[NI_AO_SUBDEV]); + mite_buf_change(devpriv->ao_mite_chan->ring, subd); a4l_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ao_mite_chan) { @@ -2436,7 +2434,7 @@ static int ni_ai_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) #if (defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE) || \ defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE_MODULE)) { - int retval = ni_ai_setup_MITE_dma(dev); + int retval = ni_ai_setup_MITE_dma(subd); if (retval) return retval; } @@ -2846,7 +2844,7 @@ int ni_ao_inttrig(a4l_subd_t *subd, lsampl_t trignum) devpriv->stc_writew(dev, 1, DAC_FIFO_Clear); if (boardtype.reg_type & ni_reg_6xxx_mask) ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); - ret = ni_ao_setup_MITE_dma(dev); + ret = ni_ao_setup_MITE_dma(subd); if (ret) return ret; ret = ni_ao_wait_for_dma_load(subd); diff --git a/ksrc/drivers/analogy/national_instruments/mite.c b/ksrc/drivers/analogy/national_instruments/mite.c index d1a7813..da1f6a5 100644 --- a/ksrc/drivers/analogy/national_instruments/mite.c +++ b/ksrc/drivers/analogy/national_instruments/mite.c @@ -379,8 +379,9 @@ void mite_dma_disarm(struct mite_channel *mite_chan) writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); } -int mite_buf_change(struct mite_dma_descriptor_ring *ring, a4l_buf_t *buf) +int mite_buf_change(struct mite_dma_descriptor_ring *ring, a4l_subd_t *subd) { + a4l_buf_t *buf = subd->buf; unsigned int n_links; int i; @@ -587,10 +588,9 @@ int mite_sync_input_dma(struct mite_channel
[Xenomai-git] Alexis Berlemont : analogy: cosmetic change (broken)
Module: xenomai-abe Branch: analogy Commit: 7d50569e3a16f0d912463cebc8522da69700cb32 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=7d50569e3a16f0d912463cebc8522da69700cb32 Author: Alexis Berlemont Date: Thu Jun 10 22:41:53 2010 +0200 analogy: cosmetic change (broken) --- include/analogy/device.h |4 ++-- ksrc/drivers/analogy/buffer.c | 14 +++--- ksrc/drivers/analogy/command.c |2 +- ksrc/drivers/analogy/device.c | 16 ksrc/drivers/analogy/instruction.c |4 ++-- .../analogy/national_instruments/mio_common.c |2 +- ksrc/drivers/analogy/subdevice.c | 10 +- ksrc/drivers/analogy/testing/loop.c|2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 6930a38..fca40cc 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -33,7 +33,7 @@ #define A4L_NB_DEVICES 10 -#define A4L_DEV_ATTACHED 0 +#define A4L_DEV_ATTACHED_NR 0 struct a4l_device { @@ -81,7 +81,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t; #ifdef __KERNEL__ /* --- Device related macro --- */ -#define a4l_check_dev(x) test_bit(A4L_DEV_ATTACHED, &(x->flags)) +#define a4l_dev_is_attached(x) test_bit(A4L_DEV_ATTACHED_NR, &(x->flags)) /* --- Devices tab related functions --- */ void a4l_init_devs(void); diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 0826a93..ac1abce 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -513,7 +513,7 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) a4l_subd_t *subd; /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_ioctl_cancel: operation not supported on " "an unattached device\n"); return -EINVAL; @@ -556,7 +556,7 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) } /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_ioctl_bufcfg: unattached device\n"); return -EINVAL; } @@ -603,7 +603,7 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) return -ENOSYS; /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_ioctl_bufinfo: unattached device\n"); return -EINVAL; } @@ -703,7 +703,7 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_read: unattached device\n"); return -EINVAL; } @@ -803,7 +803,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_write: unattached device\n"); return -EINVAL; } @@ -893,7 +893,7 @@ int a4l_select(a4l_cxt_t *cxt, /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_select: unattached device\n"); return -EINVAL; } @@ -942,7 +942,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_poll: unattached device\n"); return -EINVAL; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index 94d6137..51aad35 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -303,7 +303,7 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) return -ENOSYS; /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_ioctl_cmd: cannot command " "an unattached device\n"); return -EINVAL; diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index a2d23c8..99b9098 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -51,7 +51,7 @@ int a4l_check_cleanup_devs(void) int i, ret = 0; for (i = 0; i < A4L_NB_DEVICES && ret == 0; i++) - if (test_bit(A4L_DEV_ATTACHED, &a4l_devs[
[Xenomai-git] Alexis Berlemont : analogy: prettify some subdevice tests (broken)
Module: xenomai-abe Branch: analogy Commit: 966d4516f3716a53fcbc4cd54cac9149a3800c3c URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=966d4516f3716a53fcbc4cd54cac9149a3800c3c Author: Alexis Berlemont Date: Thu Jun 10 22:44:21 2010 +0200 analogy: prettify some subdevice tests (broken) --- include/analogy/subdevice.h | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 0337092..8649c8a 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -277,21 +277,19 @@ typedef struct a4l_rng_info_arg a4l_rnginfo_arg_t; #ifdef __KERNEL__ -/* --- Subdevice related functions --- */ +/* --- Subdevice related functions and macros --- */ + a4l_chan_t *a4l_get_chfeat(a4l_subd_t * sb, int idx); -a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, - int chidx, int rngidx); +a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx); int a4l_check_chanlist(a4l_subd_t * subd, unsigned char nb_chan, unsigned int *chans); -/* --- Upper layer functions --- */ - static inline int a4l_reserve_subd(a4l_subd_t *subd) { return test_and_set_bit(A4L_SUBD_BUSY, &subd->status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, &(x)->status)) -#define a4l_subd_is_busy(x) test_bit(A4L_SUBD_BUSY, &(x)->status)) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, &((x)->status)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY, &((x)->status))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0) /* The following macro considers that a DIO subdevice is firstly an @@ -300,6 +298,8 @@ static inline int a4l_reserve_subd(a4l_subd_t *subd) ((A4L_SUBD_MASK_WRITE & (x)->flags) != 0 || \ (A4L_SUBD_DIO & (x)->flags) != 0) +/* --- Upper layer functions --- */ + a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the last compilation problems
Module: xenomai-abe Branch: analogy Commit: 957779281f73c60d68e6d9895c2fa3876795db0e URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=957779281f73c60d68e6d9895c2fa3876795db0e Author: Alexis Berlemont Date: Fri Jun 11 00:01:01 2010 +0200 analogy: fix the last compilation problems --- include/analogy/buffer.h | 22 -- include/analogy/subdevice.h |6 +++--- ksrc/drivers/analogy/buffer.c | 25 - ksrc/drivers/analogy/rtdm_interface.c | 13 + ksrc/drivers/analogy/transfer.c |3 +-- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 4bd5db0..148c07f 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -35,20 +35,23 @@ #include #include -/* Events bits */ +/* --- Events bits / flags --- */ + #define A4L_BUF_EOBUF_NR 0 -#define A4L_BUF_ERROR_NR 1 -#define A4L_BUF_EOA_NR 2 -/* Events flags */ #define A4L_BUF_EOBUF (1 << A4L_BUF_EOBUF_NR) + +#define A4L_BUF_ERROR_NR 1 #define A4L_BUF_ERROR (1 << A4L_BUF_ERROR_NR) + +#define A4L_BUF_EOA_NR 2 #define A4L_BUF_EOA (1 << A4L_BUF_EOA_NR) -/* Status bits */ +/* --- Status bits / flags --- */ + #define A4L_BUF_BULK_NR 8 -#define A4L_BUF_MAP_NR 9 -/* Status flags */ #define A4L_BUF_BULK (1 << A4L_BUF_BULK_NR) + +#define A4L_BUF_MAP_NR 9 #define A4L_BUF_MAP (1 << A4L_BUF_MAP_NR) struct a4l_subdevice; @@ -391,9 +394,8 @@ int a4l_ioctl_mmap(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg); -ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes); -ssize_t a4l_write(a4l_cxt_t * cxt, - const void *bufdata, size_t nbytes); +ssize_t a4l_read_buffer(a4l_cxt_t * cxt, void *bufdata, size_t nbytes); +ssize_t a4l_write_buffer(a4l_cxt_t * cxt, const void *bufdata, size_t nbytes); int a4l_select(a4l_cxt_t *cxt, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index); diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 8649c8a..4223748 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -286,10 +286,10 @@ int a4l_check_chanlist(a4l_subd_t * subd, static inline int a4l_reserve_subd(a4l_subd_t *subd) { -return test_and_set_bit(A4L_SUBD_BUSY, &subd->status) ? -EBUSY : 0; +return test_and_set_bit(A4L_SUBD_BUSY_NR, &subd->status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, &((x)->status)) -#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY, &((x)->status))) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, &((x)->flags)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, &((x)->flags))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0) /* The following macro considers that a DIO subdevice is firstly an diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index ac1abce..a72b4ad 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -436,13 +436,13 @@ unsigned long a4l_buf_count(a4l_subd_t *subd) void a4l_map(struct vm_area_struct *area) { unsigned long *status = (unsigned long *)area->vm_private_data; - set_bit(A4L_TSF_MMAP, status); + set_bit(A4L_BUF_MAP_NR, status); } void a4l_unmap(struct vm_area_struct *area) { unsigned long *status = (unsigned long *)area->vm_private_data; - clear_bit(A4L_TSF_MMAP, status); + clear_bit(A4L_BUF_MAP_NR, status); } static struct vm_operations_struct a4l_vm_ops = { @@ -454,6 +454,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) { a4l_mmap_t map_cfg; a4l_dev_t *dev; + a4l_buf_t *buf; int ret; /* The mmap operation cannot be performed in a @@ -463,6 +464,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) } dev = a4l_get_dev(cxt); + buf = cxt->buffer; /* Basic checkings */ @@ -487,12 +489,10 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) /* All the magic is here */ ret = rtdm_mmap_to_user(cxt->user_info, - dev->transfer.bufs[map_cfg.idx_subd]->buf, + buf->buf, map_cfg.size, PROT_READ | PROT_WRITE, - &map_cfg.ptr, - &a4l_vm_ops, - &(dev->transfer.status[map_cfg.idx_subd])); + &map_cfg.ptr, &a4l_vm_ops, &buf->flags); if (ret < 0) { __a4l_err("a4l_ioctl_mmap: internal error, " @@ -545,7 +545,7 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) { a4l_dev_t *dev = a4l_get_dev(cxt); -
[Xenomai-git] Alexis Berlemont : analogy: fix a missing setting of the buf field in subdevice (broken)
Module: xenomai-abe Branch: analogy Commit: 96a2611d16cca49a87d5a5bb9d36cd82e741b78a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=96a2611d16cca49a87d5a5bb9d36cd82e741b78a Author: Alexis Berlemont Date: Sat Jun 12 01:34:12 2010 +0200 analogy: fix a missing setting of the buf field in subdevice (broken) --- ksrc/drivers/analogy/buffer.c | 15 --- ksrc/drivers/analogy/command.c |7 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index a72b4ad..1134b8e 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -124,6 +124,12 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return -EINVAL; } + if (a4l_reserve_subd(buf_desc->subd) < 0) { + __a4l_err("a4l_setup_buffer: subdevice %d already busy\n", + cmd->idx_subd); + return -EBUSY; + } + /* Checks if the transfer system has to work in bulk mode */ if (cmd->flags & A4L_CMD_BULK) set_bit(A4L_BUF_BULK_NR, &buf_desc->flags); @@ -131,6 +137,9 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) /* Sets the working command */ buf_desc->cur_cmd = cmd; + /* Link the subdevice with the context's buffer */ + buf_desc->subd->buf = buf_desc; + /* Computes the count to reach, if need be */ if (cmd->stop_src == TRIG_COUNT) { for (i = 0; i < cmd->nb_chan; i++) { @@ -167,9 +176,6 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) __a4l_err("a4l_cancel: cancel handler failed (err=%d)\n", err); } - a4l_release_subd(subd); - subd->buf = NULL; - if (buf_desc->cur_cmd != NULL) { a4l_free_cmddesc(buf_desc->cur_cmd); rtdm_free(buf_desc->cur_cmd); @@ -178,6 +184,9 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_init_buffer(buf_desc); + a4l_release_subd(subd); + subd->buf = NULL; + return err; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index 51aad35..da89c9a 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -354,14 +354,11 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) goto out_ioctl_cmd; } - /* Sets the concerned subdevice as busy */ - ret = a4l_reserve_subd(subd); + /* Gets the transfer system ready */ + ret = a4l_setup_buffer(cxt, cmd_desc); if (ret < 0) goto out_ioctl_cmd; - /* Gets the transfer system ready */ - a4l_setup_buffer(cxt, cmd_desc); - /* Eventually launches the command */ ret = subd->do_cmd(subd, cmd_desc); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the subdevice status management
Module: xenomai-abe Branch: analogy Commit: 32ac40ae6991c01d8ffeb1da789cb68127635b1e URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=32ac40ae6991c01d8ffeb1da789cb68127635b1e Author: Alexis Berlemont Date: Sun Jun 13 00:39:13 2010 +0200 analogy: fix the subdevice status management --- include/analogy/subdevice.h |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 4223748..5be036b 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -288,8 +288,8 @@ static inline int a4l_reserve_subd(a4l_subd_t *subd) { return test_and_set_bit(A4L_SUBD_BUSY_NR, &subd->status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, &((x)->flags)) -#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, &((x)->flags))) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, &((x)->status)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, &((x)->status))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0) /* The following macro considers that a DIO subdevice is firstly an ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix buffer initialization/cleanup calls at open /close times
Module: xenomai-abe Branch: analogy Commit: 71b31cfcfd305af88130ffae71714af89eec61a2 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=71b31cfcfd305af88130ffae71714af89eec61a2 Author: Alexis Berlemont Date: Sun Jun 13 00:42:00 2010 +0200 analogy: fix buffer initialization/cleanup calls at open/close times --- include/analogy/buffer.h |2 ++ ksrc/drivers/analogy/buffer.c | 16 ++-- ksrc/drivers/analogy/rtdm_interface.c |6 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 148c07f..9e5ae8a 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -339,6 +339,8 @@ void a4l_free_buffer(a4l_buf_t *buf_desc); void a4l_init_buffer(a4l_buf_t * buf_desc); +void a4l_cleanup_buffer(a4l_buf_t * buf_desc); + int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd); int a4l_cancel_buffer(a4l_cxt_t *cxt); diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1134b8e..04922be 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -91,7 +91,7 @@ out_virt_contig_alloc: return ret; } -void a4l_init_buffer(a4l_buf_t *buf_desc) +static void a4l_reinit_buffer(a4l_buf_t *buf_desc) { /* No command to process yet */ buf_desc->cur_cmd = NULL; @@ -111,6 +111,18 @@ void a4l_init_buffer(a4l_buf_t *buf_desc) a4l_flush_sync(&buf_desc->sync); } +void a4l_init_buffer(a4l_buf_t *buf_desc) +{ + + a4l_init_sync(&buf_desc->sync); + a4l_reinit_buffer(buf_desc); +} + +void a4l_cleanup_buffer(a4l_buf_t *buf_desc) +{ + a4l_cleanup_sync(&buf_desc->sync); +} + int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) { a4l_buf_t *buf_desc = cxt->buffer; @@ -182,7 +194,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) buf_desc->cur_cmd = NULL; } - a4l_init_buffer(buf_desc); + a4l_reinit_buffer(buf_desc); a4l_release_subd(subd); subd->buf = NULL; diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index 4eaada0..65acc86 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -156,9 +156,13 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) return err; } - /* Free the buffer which was linked with this context */ + /* Free the buffer which was linked with this context and... */ a4l_free_buffer(cxt->buffer); + /* ...free the other buffer resources (sync) and... */ + a4l_cleanup_buffer(cxt->buffer); + + /* ...free the structure */ rtdm_free(cxt->buffer); return 0; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [loop] add a debug trace when trigger is called
Module: xenomai-abe Branch: analogy Commit: f3b62df756e1eff269796de4e90b0032adf03e59 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=f3b62df756e1eff269796de4e90b0032adf03e59 Author: Alexis Berlemont Date: Wed Jun 16 00:34:20 2010 +0200 analogy: [loop] add a debug trace when trigger is called --- ksrc/drivers/analogy/testing/loop.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/ksrc/drivers/analogy/testing/loop.c b/ksrc/drivers/analogy/testing/loop.c index f73ad09..72748d8 100644 --- a/ksrc/drivers/analogy/testing/loop.c +++ b/ksrc/drivers/analogy/testing/loop.c @@ -124,6 +124,9 @@ int loop_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) int loop_trigger(a4l_subd_t *subd, lsampl_t trignum) { lpprv_t *priv = (lpprv_t *)subd->dev->priv; + + a4l_info(subd->dev, "loop_trigger: (subd=%d)\n", subd->idx); + priv->loop_running = 1; return 0; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix test of subdevice status in a4l_write
Module: xenomai-abe Branch: analogy Commit: 7b3d7424fd130f7daef6311f657d06caf246d327 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=7b3d7424fd130f7daef6311f657d06caf246d327 Author: Alexis Berlemont Date: Wed Jun 16 00:35:03 2010 +0200 analogy: fix test of subdevice status in a4l_write --- ksrc/drivers/analogy/buffer.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 04922be..12b8b9b 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -828,7 +828,7 @@ ssize_t a4l_write_buffer(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) return -EINVAL; } - if (!subd || !test_bit(A4L_SUBD_BUSY, &subd->status)) { + if (!subd || !a4l_subd_is_busy(subd)) { __a4l_err("a4l_write: idle subdevice on this context\n"); return -ENOENT; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [fake - loop] remove volatile keywords
Module: xenomai-abe Branch: analogy Commit: fd94953ecc91fde7ec1e9bf1605bd6b209bbfd73 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=fd94953ecc91fde7ec1e9bf1605bd6b209bbfd73 Author: Alexis Berlemont Date: Sat Jun 19 00:33:01 2010 +0200 analogy: [fake - loop] remove volatile keywords Remove the volatile keyword in front of concurrently accessed variables and use, instead, RTDM_EXECUTE_ATOMICALLY. Maybe it is a bit nicer even for some testing drivers. --- ksrc/drivers/analogy/testing/fake.c | 12 ksrc/drivers/analogy/testing/loop.c | 16 +++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ksrc/drivers/analogy/testing/fake.c b/ksrc/drivers/analogy/testing/fake.c index 27d6d88..878a28f 100644 --- a/ksrc/drivers/analogy/testing/fake.c +++ b/ksrc/drivers/analogy/testing/fake.c @@ -29,7 +29,7 @@ struct ai_priv { /* Misc fields */ unsigned long amplitude_div; unsigned long quanta_cnt; - volatile int timer_running; + int timer_running; }; @@ -115,7 +115,11 @@ static void ai_task_proc(void *arg) uint64_t now_ns, elapsed_ns=0; while(1) { - if(priv->timer_running != 0) + int running; + + RTDM_EXECUTE_ATOMICALLY(running = priv->timer_running); + + if(running) { int i = 0; @@ -168,7 +172,7 @@ static int ai_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) priv->current_ns = ((unsigned long)priv->last_ns); priv->reminder_ns = 0; - priv->timer_running = 1; + RTDM_EXECUTE_ATOMICALLY(priv->timer_running = 1); return 0; @@ -193,7 +197,7 @@ static int ai_cancel(a4l_subd_t *subd) { struct ai_priv *priv = (struct ai_priv *)subd->priv; - priv->timer_running = 0; + RTDM_EXECUTE_ATOMICALLY(priv->timer_running = 0); return 0; } diff --git a/ksrc/drivers/analogy/testing/loop.c b/ksrc/drivers/analogy/testing/loop.c index 72748d8..f9c4bf8 100644 --- a/ksrc/drivers/analogy/testing/loop.c +++ b/ksrc/drivers/analogy/testing/loop.c @@ -44,7 +44,7 @@ struct loop_priv { a4l_task_t loop_task; /* Misc fields */ - volatile int loop_running:1; + int loop_running; uint16_t loop_insn_value; }; typedef struct loop_priv lpprv_t; @@ -78,8 +78,12 @@ static void loop_task_proc(void *arg) } while (1) { + + int running; + + RTDM_EXECUTE_ATOMICALLY(running = priv->loop_running); - if (priv->loop_running) { + if (running) { uint16_t value; int ret=0; @@ -87,7 +91,6 @@ static void loop_task_proc(void *arg) ret = a4l_buf_get(output_subd, &value, sizeof(uint16_t)); - if (ret == 0) { a4l_info(dev, @@ -116,6 +119,7 @@ static void loop_task_proc(void *arg) int loop_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) { a4l_info(subd->dev, "loop_cmd: (subd=%d)\n", subd->idx); + return 0; } @@ -127,7 +131,8 @@ int loop_trigger(a4l_subd_t *subd, lsampl_t trignum) a4l_info(subd->dev, "loop_trigger: (subd=%d)\n", subd->idx); - priv->loop_running = 1; + RTDM_EXECUTE_ATOMICALLY(priv->loop_running = 1); + return 0; } @@ -138,7 +143,7 @@ int loop_cancel(a4l_subd_t *subd) a4l_info(subd->dev, "loop_cancel: (subd=%d)\n", subd->idx); - priv->loop_running = 0; + RTDM_EXECUTE_ATOMICALLY(priv->loop_running = 0); return 0; } @@ -201,6 +206,7 @@ void setup_output_subd(a4l_subd_t *subd) subd->rng_desc = &loop_rngdesc; subd->chan_desc = &loop_chandesc; subd->do_cmd = loop_cmd; + subd->cancel = loop_cancel; subd->trigger = loop_trigger; subd->cmd_mask = &loop_cmd_mask; subd->insn_read = loop_insn_read; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: add a detail in a4l_close doxygen doc
Module: xenomai-abe Branch: analogy Commit: 129ae85977bbf4c9dbcdeab055ee3a406b11bf3b URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=129ae85977bbf4c9dbcdeab055ee3a406b11bf3b Author: Alexis Berlemont Date: Sat Jun 19 00:39:42 2010 +0200 analogy: add a detail in a4l_close doxygen doc --- src/drvlib/analogy/descriptor.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/src/drvlib/analogy/descriptor.c b/src/drvlib/analogy/descriptor.c index c5bb0bc..a7addc0 100644 --- a/src/drvlib/analogy/descriptor.c +++ b/src/drvlib/analogy/descriptor.c @@ -315,6 +315,11 @@ int a4l_open(a4l_desc_t * dsc, const char *fname) /** * @brief Close the Analogy device related with the descriptor * + * The file descriptor is associated with a context. The context is + * one of the enabler of asynchronous transfers. So, by closing the + * file descriptor, the programer must keep in mind that the currently + * occuring asynchronous transfer will cancelled. + * * @param[in] dsc Device descriptor * * @return 0 on success. Otherwise: ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: add an arbitrary sleep in cmd_write before closing the device
Module: xenomai-abe Branch: analogy Commit: 615c874b584149bfb230b2ae57fec36040b69c17 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=615c874b584149bfb230b2ae57fec36040b69c17 Author: Alexis Berlemont Date: Sat Jun 19 00:45:16 2010 +0200 analogy: add an arbitrary sleep in cmd_write before closing the device --- src/utils/analogy/cmd_write.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c index 5ce9218..b65b8f6 100644 --- a/src/utils/analogy/cmd_write.c +++ b/src/utils/analogy/cmd_write.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -397,6 +398,8 @@ out_main: if (dsc.sbdata != NULL) free(dsc.sbdata); + sleep(1); + /* Release the file descriptor */ a4l_close(&dsc); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [ni_pcimio] really minor changes
Module: xenomai-abe Branch: analogy Commit: 0de5f272ff9ae900efce328539b2c7bc9f1968ac URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=0de5f272ff9ae900efce328539b2c7bc9f1968ac Author: Alexis Berlemont Date: Mon Jun 21 00:36:44 2010 +0200 analogy: [ni_pcimio] really minor changes --- .../analogy/national_instruments/mio_common.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index ead64b8..de1c570 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -3413,6 +3413,7 @@ int ni_cdio_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) if (cmd->scan_begin_arg & CR_INVERT) cdo_mode_bits |= CDO_Polarity_Bit; ni_writel(cdo_mode_bits, M_Offset_CDO_Mode); + if (devpriv->io_bits) { ni_writel(devpriv->dio_state, M_Offset_CDO_FIFO_Data); ni_writel(CDO_SW_Update_Bit, M_Offset_CDIO_Command); @@ -3423,10 +3424,10 @@ int ni_cdio_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) "output command with no lines configured as outputs"); return -EIO; } + retval = ni_request_cdo_mite_channel(dev); - if (retval < 0) { + if (retval < 0) return retval; - } return 0; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [ni_pcimio] add the missing allocation of the digital ring
Module: xenomai-abe Branch: analogy Commit: b95be3691aa0c0525df0110e60bd434e3132f384 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=b95be3691aa0c0525df0110e60bd434e3132f384 Author: Alexis Berlemont Date: Mon Jun 21 00:37:54 2010 +0200 analogy: [ni_pcimio] add the missing allocation of the digital ring --- ksrc/drivers/analogy/national_instruments/pcimio.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/pcimio.c b/ksrc/drivers/analogy/national_instruments/pcimio.c index 2df47a7..7e2e87e 100644 --- a/ksrc/drivers/analogy/national_instruments/pcimio.c +++ b/ksrc/drivers/analogy/national_instruments/pcimio.c @@ -1497,11 +1497,13 @@ static int pcimio_attach(a4l_dev_t *dev, a4l_lnkdesc_t *arg) devpriv->ai_mite_ring = mite_alloc_ring(mite); devpriv->ao_mite_ring = mite_alloc_ring(mite); + devpriv->cdo_mite_ring = mite_alloc_ring(mite); devpriv->gpct_mite_ring[0] = mite_alloc_ring(mite); devpriv->gpct_mite_ring[1] = mite_alloc_ring(mite); if(devpriv->ai_mite_ring == NULL || devpriv->ao_mite_ring == NULL || + devpriv->cdo_mite_ring == NULL || devpriv->gpct_mite_ring[0] == NULL || devpriv->gpct_mite_ring[1] == NULL) return -ENOMEM; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [ni_pcimio] fix timeout value in digital trigger
Module: xenomai-abe Branch: analogy Commit: 8de2e01ba900f415129e1fafe95cee8416639033 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=8de2e01ba900f415129e1fafe95cee8416639033 Author: Alexis Berlemont Date: Tue Jun 22 00:25:51 2010 +0200 analogy: [ni_pcimio] fix timeout value in digital trigger --- .../analogy/national_instruments/mio_common.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index de1c570..55e0bc2 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -3451,7 +3451,7 @@ int ni_cdo_inttrig(a4l_subd_t *subd, lsampl_t trignum) unsigned long flags; int retval = 0; unsigned i; - const unsigned timeout = 100; + const unsigned timeout = 1000; /* TODO: disable trigger until a command is recorded. Null trig at beginning prevent ao start trigger from executing @@ -3476,6 +3476,7 @@ int ni_cdo_inttrig(a4l_subd_t *subd, lsampl_t trignum) break; a4l_udelay(10); } + if (i == timeout) { a4l_err(dev, "ni_cdo_inttrig: dma failed to fill cdo fifo!"); ni_cdio_cancel(subd); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: remove calls of a4l_release/ reserve_subd in the core
Module: xenomai-abe Branch: analogy Commit: bec9c5072c671afc1468d87c6dcaeb0c4405314a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=bec9c5072c671afc1468d87c6dcaeb0c4405314a Author: Alexis Berlemont Date: Wed Jun 23 21:11:31 2010 +0200 analogy: remove calls of a4l_release/reserve_subd in the core --- include/analogy/subdevice.h|7 --- ksrc/drivers/analogy/buffer.c |4 ++-- ksrc/drivers/analogy/instruction.c |7 --- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 5be036b..a81fcb9 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -284,13 +284,6 @@ a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx); int a4l_check_chanlist(a4l_subd_t * subd, unsigned char nb_chan, unsigned int *chans); -static inline int a4l_reserve_subd(a4l_subd_t *subd) -{ -return test_and_set_bit(A4L_SUBD_BUSY_NR, &subd->status) ? -EBUSY : 0; -} -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, &((x)->status)) -#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, &((x)->status))) - #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0) /* The following macro considers that a DIO subdevice is firstly an output subdevice */ diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index b8b01d3..f9bcad7 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -136,7 +136,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return -EINVAL; } - if (a4l_reserve_subd(buf_desc->subd) < 0) { + if (test_and_set_bit(A4L_SUBD_BUSY_NR, &buf_desc->subd->status)) { __a4l_err("a4l_setup_buffer: subdevice %d already busy\n", cmd->idx_subd); return -EBUSY; @@ -196,7 +196,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_reinit_buffer(buf_desc); - a4l_release_subd(subd); + clear_bit(A4L_SUBD_BUSY_NR, &subd->status); subd->buf = NULL; return err; diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 644c40c..1050753 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -266,9 +266,10 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) /* Prevents the subdevice from being used during the following operations */ - ret = a4l_reserve_subd(subd); - if (ret < 0) + if (test_and_set_bit(A4L_SUBD_BUSY_NR, &subd->status)) { + ret = -EBUSY; goto out_do_insn; + } /* Let's the driver-specific code perform the instruction */ ret = hdlr(subd, dsc); @@ -281,7 +282,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) out_do_insn: /* Releases the subdevice from its reserved state */ - a4l_release_subd(subd); + clear_bit(A4L_SUBD_BUSY_NR, &subd->status); return ret; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: remove a4l_subd_is_busy calls in analogy core
Module: xenomai-abe Branch: analogy Commit: 66b3928db8b1736b350c351fcfe6ae5525e19e78 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=66b3928db8b1736b350c351fcfe6ae5525e19e78 Author: Alexis Berlemont Date: Wed Jun 23 21:01:46 2010 +0200 analogy: remove a4l_subd_is_busy calls in analogy core --- ksrc/drivers/analogy/buffer.c | 42 1 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 12b8b9b..b8b01d3 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -175,8 +175,8 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_subd_t *subd = buf_desc->subd; int err = 0; - - if (!subd || !a4l_subd_is_busy(subd)) + + if (!subd || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return 0; /* If a "cancel" function is registered, call it @@ -253,7 +253,7 @@ int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd->buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -267,7 +267,7 @@ int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd->buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -280,7 +280,7 @@ int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd->buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -293,7 +293,7 @@ int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd->buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -307,7 +307,7 @@ int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) a4l_buf_t *buf = subd->buf; int err; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_input(subd)) @@ -329,7 +329,7 @@ int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd->buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_output(subd)) @@ -342,7 +342,7 @@ int a4l_buf_commit_absget(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd->buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_output(subd)) @@ -355,7 +355,7 @@ int a4l_buf_prepare_get(a4l_subd_t *subd, unsigned long count) { a4l_buf_t *buf = subd->buf; - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_output(subd)) @@ -370,7 +370,7 @@ int a4l_buf_commit_get(a4l_subd_t *subd, unsigned long count) /* Basic checkings */ - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (!a4l_subd_is_output(subd)) @@ -386,12 +386,12 @@ int a4l_buf_get(a4l_subd_t *subd, void *bufdata, unsigned long count) /* Basic checkings */ + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) + return -ENOENT; + if (!a4l_subd_is_output(subd)) return -EINVAL; - if (!buf || !a4l_subd_is_busy(subd)) - return -ENOENT; - if (__count_to_get(buf) < count) return -EAGAIN; @@ -418,7 +418,7 @@ int a4l_buf_evt(a4l_subd_t *subd, unsigned long evts) race conditions, not the framework */ /* Basic checking */ - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; /* Even if it is a little more complex, @@ -441,7 +441,7 @@ unsigned long a4l_buf_count(a4l_subd_t *subd) unsigned long ret = 0; /* Basic checking */ - if (!buf || !a4l_subd_is_busy(subd)) + if (!buf || !test_bit(A4L_SUBD_BUSY_NR, &subd->status)) return -ENOENT; if (a4l_subd_is_input(subd)) @@ -587,7 +587,7 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) arg, sizeof(a4l_bufcfg_t)) != 0)
[Xenomai-git] Alexis Berlemont : analogy: remove some tests which become with the buffer overhaul
Module: xenomai-abe Branch: analogy Commit: 569dd4582f7e5c7610757b560233f9fc0e465f4f URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=569dd4582f7e5c7610757b560233f9fc0e465f4f Author: Alexis Berlemont Date: Fri Jun 25 00:14:37 2010 +0200 analogy: remove some tests which become with the buffer overhaul --- include/analogy/device.h |3 --- .../analogy/national_instruments/mio_common.c |3 --- ksrc/drivers/analogy/testing/loop.c|3 --- 3 files changed, 0 insertions(+), 9 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index fca40cc..76aca28 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -80,9 +80,6 @@ typedef struct a4l_dev_info a4l_dvinfo_t; #ifdef __KERNEL__ -/* --- Device related macro --- */ -#define a4l_dev_is_attached(x) test_bit(A4L_DEV_ATTACHED_NR, &(x->flags)) - /* --- Devices tab related functions --- */ void a4l_init_devs(void); int a4l_check_cleanup_devs(void); diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index 55e0bc2..67c278e 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -1027,9 +1027,6 @@ int ni_E_interrupt(unsigned int irq, void *d) unsigned long flags; struct mite_struct *mite = devpriv->mite; - if(!a4l_dev_is_attached(dev)) - return IRQ_NONE; - /* Make sure dev->attached is checked before handler does anything else. */ smp_mb(); diff --git a/ksrc/drivers/analogy/testing/loop.c b/ksrc/drivers/analogy/testing/loop.c index f9c4bf8..e304ebc 100644 --- a/ksrc/drivers/analogy/testing/loop.c +++ b/ksrc/drivers/analogy/testing/loop.c @@ -65,9 +65,6 @@ 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; - - while (!a4l_dev_is_attached(dev)) - a4l_task_sleep(LOOP_TASK_PERIOD); input_subd = a4l_get_subd(dev, LOOP_INPUT_SUBD); output_subd = a4l_get_subd(dev, LOOP_OUTPUT_SUBD); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix a bug in a4l_fill_desc() when called on an idle device
Module: xenomai-abe Branch: analogy Commit: 89c98166b1fe4c62f043c8c795dcad6f020c451a URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=89c98166b1fe4c62f043c8c795dcad6f020c451a Author: Alexis Berlemont Date: Mon Jun 28 00:35:30 2010 +0200 analogy: fix a bug in a4l_fill_desc() when called on an idle device If we open an unattached device (thanks to a4l_open), the descriptor field "sbsize" is worth 0. Before calling a4l_fill_desc, we need to allocate a memory area so as to hold the device info data. According to the manual page, malloc(0) does not have to return NULL. It can return a pointer. So, we call a4l_fill_desc without any allocated memory area. As there was no proper checking test in a4l_fill_desc, there was a memory corruption bug. --- src/drvlib/analogy/descriptor.c |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/src/drvlib/analogy/descriptor.c b/src/drvlib/analogy/descriptor.c index a7addc0..6737265 100644 --- a/src/drvlib/analogy/descriptor.c +++ b/src/drvlib/analogy/descriptor.c @@ -229,6 +229,8 @@ static int __a4l_fill_desc(int fd, a4l_desc_t * dsc) *pass argument should be checked; check also the kernel log *("dmesg") * - -EFAULT is returned if a user <-> kernel transfer went wrong + * - -ENODEV is returned if the descriptor is incoherent (the device + *may be unattached) * */ @@ -251,6 +253,11 @@ int a4l_sys_desc(int fd, a4l_desc_t * dsc, int pass) dsc->magic = MAGIC_BSC_DESC; } else { + if (!dsc->sbsize) { + ret = -ENODEV; + goto out_a4l_sys_desc; + } + ret = __a4l_fill_desc(fd, dsc); if (ret < 0) goto out_a4l_sys_desc; @@ -350,6 +357,8 @@ int a4l_close(a4l_desc_t * dsc) *the dsc pointer should be checked; check also the kernel log *("dmesg") * - -EFAULT is returned if a user <-> kernel transfer went wrong + * - -ENODEV is returned if the descriptor is incoherent (the device + *may be unattached) * */ int a4l_fill_desc(a4l_desc_t * dsc) ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git