From: Alexandru Ardelean <ardeleanalex@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Alexandru Ardelean" <alexandru.ardelean@analog.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-iio <linux-iio@vger.kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Bogdan, Dragos" <dragos.bogdan@analog.com>
Subject: Re: [PATCH v2 2/5] iio: Add output buffer support
Date: Fri, 19 Feb 2021 10:45:39 +0200 [thread overview]
Message-ID: <CA+U=DsqhDYgs-HYnC3-T0d0ubvkG8eZQifx1XLzvUa5K-Ru+bg@mail.gmail.com> (raw)
In-Reply-To: <20210218134240.2dd1feb2@archlinux>
On Thu, Feb 18, 2021 at 5:30 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Wed, 17 Feb 2021 10:34:35 +0200
> Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
>
> > From: Lars-Peter Clausen <lars@metafoo.de>
> >
> > Currently IIO only supports buffer mode for capture devices like ADCs. Add
> > support for buffered mode for output devices like DACs.
> >
> > The output buffer implementation is analogous to the input buffer
> > implementation. Instead of using read() to get data from the buffer write()
> > is used to copy data into the buffer.
> >
> > poll() with POLLOUT will wakeup if there is space available for more or
> > equal to the configured watermark of samples.
> >
> > Drivers can remove data from a buffer using iio_buffer_remove_sample(), the
> > function can e.g. called from a trigger handler to write the data to
> > hardware.
> >
> > A buffer can only be either a output buffer or an input, but not both. So,
> > for a device that has an ADC and DAC path, this will mean 2 IIO buffers
> > (one for each direction).
> >
> > The direction of the buffer is decided by the new direction field of the
> > iio_buffer struct and should be set after allocating and before registering
> > it.
> >
> > Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
>
> Just one question on this, otherwise looks good to me.
>
> Jonathan
>
> > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> > index 5d641f8adfbd..b9970c68005d 100644
> > --- a/drivers/iio/industrialio-buffer.c
> > +++ b/drivers/iio/industrialio-buffer.c
> > @@ -162,6 +162,69 @@ static ssize_t iio_buffer_read(struct file *filp, char __user *buf,
> > return ret;
> > }
> >
> ...
>
> > /**
> > * iio_buffer_poll() - poll the buffer to find out if it has data
> > * @filp: File structure pointer for device access
> > @@ -182,8 +245,19 @@ static __poll_t iio_buffer_poll(struct file *filp,
> > return 0;
> >
> > poll_wait(filp, &rb->pollq, wait);
> > - if (iio_buffer_ready(indio_dev, rb, rb->watermark, 0))
> > - return EPOLLIN | EPOLLRDNORM;
> > +
> > + switch (rb->direction) {
> > + case IIO_BUFFER_DIRECTION_IN:
> > + if (iio_buffer_ready(indio_dev, rb, rb->watermark, 0))
> > + return EPOLLIN | EPOLLRDNORM;
> > + break;
> > + case IIO_BUFFER_DIRECTION_OUT:
> > + if (iio_buffer_space_available(rb) >= rb->watermark)
> > + return EPOLLOUT | EPOLLWRNORM;
> > + break;
> > + }
> > +
> > + /* need a way of knowing if there may be enough data... */
>
> Curious on what this comment is referring to?
I'm also a bit curious about what this comment is referring to.
I can remove it.
Maybe Lars can give some insight.
>
> > return 0;
> > }
> >
> > @@ -232,6 +306,16 @@ void iio_buffer_wakeup_poll(struct iio_dev *indio_dev)
> > }
> > }
> ...
next prev parent reply other threads:[~2021-02-19 8:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-17 8:34 [PATCH v2 0/5] iio: Add output buffer support Alexandru Ardelean
2021-02-17 8:34 ` [PATCH v2 1/5] iio: Documentation: update definitions for bufferY and scan_elements Alexandru Ardelean
2021-02-18 12:19 ` Jonathan Cameron
2021-02-18 13:36 ` Jonathan Cameron
2021-04-01 13:44 ` Mauro Carvalho Chehab
2021-04-01 15:00 ` Jonathan Cameron
2021-02-17 8:34 ` [PATCH v2 2/5] iio: Add output buffer support Alexandru Ardelean
2021-02-18 13:42 ` Jonathan Cameron
2021-02-19 8:45 ` Alexandru Ardelean [this message]
2021-02-17 8:34 ` [PATCH v2 3/5] iio: kfifo-buffer: " Alexandru Ardelean
2021-02-17 8:34 ` [PATCH v2 4/5] iio: triggered-buffer: extend support to configure output buffers Alexandru Ardelean
2021-02-17 8:34 ` [PATCH v2 5/5] iio: dac: ad5686: Add PWM as a trigger source Alexandru Ardelean
2021-02-18 14:05 ` Jonathan Cameron
2021-02-18 14:35 ` Rob Herring
2021-02-19 8:49 ` Alexandru Ardelean
2021-02-23 16:37 ` Lars-Peter Clausen
2021-02-27 15:45 ` Jonathan Cameron
2021-02-18 13:38 ` [PATCH v2 0/5] iio: Add output buffer support Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+U=DsqhDYgs-HYnC3-T0d0ubvkG8eZQifx1XLzvUa5K-Ru+bg@mail.gmail.com' \
--to=ardeleanalex@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.ardelean@analog.com \
--cc=dragos.bogdan@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).