From: Kent Gibson <warthog618@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Robert Baumgartner <rbaumgar@redhat.com>,
Thierry Reding <thierry.reding@gmail.com>,
Thierry Reding <treding@nvidia.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Bartosz Golaszewski <brgl@bgdev.pl>
Subject: Re: [libgpiod] How can I use PWM
Date: Sat, 6 Aug 2022 21:40:52 +0800 [thread overview]
Message-ID: <20220806134052.GA26217@sol> (raw)
In-Reply-To: <CAHp75Vd2dh5QDxAY-9N0xu6D0ywBcYnRL6FF5ZoKdqnnkBtAyg@mail.gmail.com>
On Sat, Aug 06, 2022 at 12:12:31PM +0200, Andy Shevchenko wrote:
> On Fri, Aug 5, 2022 at 1:17 PM Robert Baumgartner <rbaumgar@redhat.com> wrote:
> >
> > Hi team,
> >
> > I try to migrate some python scripts for my Raspberry from RPi.GPIO to
> > libgpiod,
>
> This is great and everyone should be encouraged to follow your example!
>
> > but I miss PWM features.
> > Do I miss something? Or is it not available?
>
> No, you haven't missed anything except Unix ideology. That ideology is
> telling us that one tool for one thing, and in very featurable mode.
> That said, lingpiod is exclusively for GPIO ABI between kernel and
> user space. For PWM you need to access the PWM ABI in a way how it's
> represented by the Linux kernel. I believe there are plenty of
> libraries more or less okayish for that purpose, but I never heard
> about any official library and/or Python bindings for it.
>
I'm assuming Robert is refering to software PWM. AFAIAA Rpi.GPIO doesn't
support hardware PWM, and the referenced article also refers to software
PWM for the Python case.
libgpiod doesn't directly support software PWM, but it is fairly
straight forward to implement yourself using libgpiod.
Separate from Andy's point on Unix ideology, adding it to libgpiod would
involve threading or async, which in C would open cans of worms that are
best left to the specific application to decide on. So I don't see it
ever going into the core libgpiod.
Not such an issue for Python with its included batteries, so I would
personally consider adding something along those lines to the Python
bindings, and possibly the Rust as well. OTOH I suspect Bart's
preference is for the bindings to idiomatically wrap, not extend, the
libgpiod API.
Cheers,
Kent.
next prev parent reply other threads:[~2022-08-06 13:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-05 11:14 [libgpiod] How can I use PWM Robert Baumgartner
2022-08-06 10:12 ` Andy Shevchenko
2022-08-06 13:40 ` Kent Gibson [this message]
2022-08-06 14:04 ` Andy Shevchenko
2022-08-07 13:20 ` Robert Baumgartner
2022-08-07 14:41 ` Kent Gibson
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=20220806134052.GA26217@sol \
--to=warthog618@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=brgl@bgdev.pl \
--cc=linux-gpio@vger.kernel.org \
--cc=rbaumgar@redhat.com \
--cc=thierry.reding@gmail.com \
--cc=treding@nvidia.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).