Module: xenomai-abe Branch: analogy Commit: 44b31ad7b1b9b13104fc98c3ff616a1539398f11 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=44b31ad7b1b9b13104fc98c3ff616a1539398f11
Author: Alexis Berlemont <alexis.berlem...@gmail.com> Date: Tue Oct 19 23:52:20 2010 +0200 analogy: implement configuration of buffer default size --- include/analogy/buffer.h | 8 ++++++++ include/analogy/transfer.h | 3 +++ include/analogy/types.h | 4 +--- ksrc/drivers/analogy/buffer.c | 17 +++++++++++------ ksrc/drivers/analogy/rtdm_interface.c | 10 +++++----- ksrc/drivers/analogy/transfer.c | 4 ++++ 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index b5be3f0..86d0a64 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -456,9 +456,17 @@ typedef struct a4l_mmap_arg a4l_mmap_t; (might be used with BUFCFG ioctl) */ #define A4L_BUF_MAXSIZE 0x1000000 #define A4L_BUF_DEFSIZE 0x10000 +#define A4L_BUF_DEFMAGIC 0xffaaff55 /* BUFCFG ioctl argument structure */ struct a4l_buffer_config { + /* NOTE: with the last buffer implementation, the field + idx_subd became useless; the buffer are now + per-context. So, the buffer size configuration is specific + to an opened device. There is a little exception: we can + define a default buffer size for a device. + So far, a hack is used to implement the configuration of + the default buffer size */ unsigned int idx_subd; unsigned long buf_size; }; diff --git a/include/analogy/transfer.h b/include/analogy/transfer.h index 929022b..2850834 100644 --- a/include/analogy/transfer.h +++ b/include/analogy/transfer.h @@ -57,6 +57,9 @@ struct a4l_transfer { unsigned int nb_subd; a4l_subd_t **subds; + /* Buffer stuff: the default size */ + unsigned int default_bufsize; + /* IRQ in use */ /* TODO: irq_desc should vanish */ a4l_irq_desc_t irq_desc; diff --git a/include/analogy/types.h b/include/analogy/types.h index e3974eb..89dbb8a 100644 --- a/include/analogy/types.h +++ b/include/analogy/types.h @@ -25,9 +25,7 @@ #ifndef DOXYGEN_CPP -/* --- Misc precompilation constants --- */ - -#define A4L_DEFAULT_BFSIZE 0x10000 +/* --- Misc precompilation constant --- */ #define A4L_NAMELEN 20 /* --- Common Analogy types --- */ diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 8bd7d38..7623674 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -117,7 +117,7 @@ static void a4l_reinit_buffer(a4l_buf_t *buf_desc) void a4l_init_buffer(a4l_buf_t *buf_desc) { - + memset(buf_desc, 0, sizeof(a4l_buf_t)); a4l_init_sync(&buf_desc->sync); a4l_reinit_buffer(buf_desc); } @@ -598,16 +598,21 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) arg, sizeof(a4l_bufcfg_t)) != 0) return -EFAULT; - if (subd && test_bit(A4L_SUBD_BUSY_NR, &subd->status)) { - __a4l_err("a4l_ioctl_bufcfg: acquisition in progress\n"); - return -EBUSY; - } - if (buf_cfg.buf_size > A4L_BUF_MAXSIZE) { __a4l_err("a4l_ioctl_bufcfg: buffer size too big (<=16MB)\n"); return -EINVAL; } + if (buf_cfg.idx_subd == A4L_BUF_DEFMAGIC) { + cxt->dev->transfer.default_bufsize = buf_cfg.buf_size; + return 0; + } + + if (subd && test_bit(A4L_SUBD_BUSY_NR, &subd->status)) { + __a4l_err("a4l_ioctl_bufcfg: acquisition in progress\n"); + return -EBUSY; + } + if (test_bit(A4L_BUF_MAP, &buf->flags)) { __a4l_err("a4l_ioctl_bufcfg: please unmap before " "configuring buffer\n"); diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index 65acc86..906a20f 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -136,11 +136,11 @@ int a4l_open(struct rtdm_dev_context *context, /* Allocate the asynchronous buffer NOTE: it should be interesting to allocate the buffer only - on demand especially if the system is short of memory - NOTE2: the default buffer size could be configured via - kernel config*/ - a4l_alloc_buffer(cxt->buffer, A4L_DEFAULT_BFSIZE); - + on demand especially if the system is short of memory */ + if (cxt->dev->transfer.default_bufsize) + a4l_alloc_buffer(cxt->buffer, + cxt->dev->transfer.default_bufsize); + return 0; } diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c index dc34997..c0f2945 100644 --- a/ksrc/drivers/analogy/transfer.c +++ b/ksrc/drivers/analogy/transfer.c @@ -92,6 +92,8 @@ int a4l_cleanup_transfer(a4l_cxt_t * cxt) rtdm_free(tsf->subds); } + memset(tsf, 0, sizeof(a4l_trf_t)); + return 0; } @@ -106,6 +108,8 @@ void a4l_presetup_transfer(a4l_cxt_t *cxt) /* Clear the structure */ memset(tsf, 0, sizeof(a4l_trf_t)); + tsf->default_bufsize = A4L_BUF_DEFSIZE; + /* 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; _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git