Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Nov 2020 15:05:02 -0700
From:      Ian Lepore <ian@freebsd.org>
To:        freebsd-arm@freebsd.org
Subject:   Re: User Space GPIO Interrupt programming - GSoC-2018
Message-ID:  <d3d830aed6b4323ccdfbb85e5ea0849a2009faa4.camel@freebsd.org>
In-Reply-To: <1e6993d43d22d6ce1aa2860a61745356688d1e53.camel@freebsd.org>
References:  <2B01780F-D367-48A3-A827-B479030A496D@obsigna.com> <c55d7f332631b69c3241a60538a6a7b5475d93b9.camel@freebsd.org> <FBEF19B1-0504-4CDF-976C-C50707E06584@obsigna.com> <8d806302-479c-ca34-3fdb-96d27f40e212@viruzzz.org> <8655AF30-273B-48E7-98CD-007AA1D265F5@obsigna.com> <54ffe2d2-01a2-8b43-94fa-aee4a3f89861@viruzzz.org> <08649892ca2ab434c261d36e0e13ba051086de6f.camel@freebsd.org> <1e6993d43d22d6ce1aa2860a61745356688d1e53.camel@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 2020-11-27 at 11:04 -0700, Ian Lepore wrote:
> > I think we need a way for the app to choose whether it wants simple
> > reporting of pin number (like the original code) perhaps along with
> > a count, versus requesting detailed per-event data.  I'm going to
> > propose something more detailed about this as soon as I get my
> > thoughts all organized.

Okay, here's my current thinking on this (with tabs compressed down to
just a couple spaces to prevent line-wrap in email).  This is a snippet
from gpio.h...

/*
 * Reporting gpio pin-change per-event details to userland.
 *
 * When configured for detail reporting, each call to read(2) will
 * return one or more of these structures (or will return
 * EWOULDBLOCK in non-blocking IO mode when there are no new events
 * to report).
 */
struct gpio_event_detail {
  struct timespec gp_time;        /* Time of event */
  uint16_t        gp_pin;         /* Pin number */
  bool            gp_pinstate;    /* Pin state at time of event */
};

/*
 * Reporting gpio pin-change summary data to userland.
 *
 * When configured for summary reporting (the default), each call to
 * read(2) will return one or more of these structures (or will
 * return EWOULDBLOCK in non-blocking IO mode when there are no new
 * events to report).
 */
struct gpio_event_summary {
  struct timespec gp_first_time;  /* Time of first event */
  struct timespec gp_last_time;   /* Time of last event */
  uint16_t        gp_pin;         /* Pin number */
  uint16_t        gp_count;       /* Event count */
  bool            gp_first_state; /* Pin state at first event */
  bool            gp_last_state;  /* Pin state at last event */
};

/*
 * Configuring event reporting to userland.
 *
 * The default is to deliver gpio_event_summary reporting.  To
 * change it, you must use the GPIOCONFIGEVENTS ioctl to set the
 * event fifo size before using GPIOSETCONFIG to configure reporting
 * interrupt events on any pins.  This config is tracked on a
 * per-open-descriptor basis.  Once it has been set, it cannot be
 * changed without closing and re-opening the file descriptor.
 */
struct gpio_event_config {
  uint32_t        gp_fifo_size;   /* Zero for summary reporting. */
};

#define	GPIOCONFIGEVENTS	_IOW('G', 9, struct gpio_event_config)

I haven't written the implementation of all this yet, but I have a
pretty good idea of how to do so.

-- Ian





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d3d830aed6b4323ccdfbb85e5ea0849a2009faa4.camel>