linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org
Cc: linux-api@vger.kernel.org
Subject: Re: [PATCH v3 17/19] [media] lirc: implement reading scancode
Date: Thu, 2 Mar 2017 13:31:16 +0000	[thread overview]
Message-ID: <20170302133116.GA29616@gofer.mess.org> (raw)
In-Reply-To: <b9722d41efc7dd75ddbab78a62f654aa56d9a0a3.1488023302.git.sean@mess.org>

On Sat, Feb 25, 2017 at 11:51:32AM +0000, Sean Young wrote:
> @@ -362,10 +394,15 @@ static unsigned int ir_lirc_poll(struct file *filep,
>  
>  	poll_wait(filep, &lirc->wait_poll, wait);
>  
> -	if (!lirc->drv.attached)
> +	if (!lirc->drv.attached) {
>  		events = POLLHUP;
> -	else if (!kfifo_is_empty(&lirc->rawir))
> -		events = POLLIN | POLLRDNORM;
> +	} else if (lirc->rec_mode == LIRC_MODE_SCANCODE) {
> +		if (!kfifo_is_empty(&lirc->rawir))
> +			events = POLLIN | POLLRDNORM;
> +	} else if (lirc->rec_mode == LIRC_MODE_MODE2) {
> +		if (!kfifo_is_empty(&lirc->scancodes))
> +			events = POLLIN | POLLRDNORM;
> +	}
>  
>  	return events;
>  }

So one issue with with this API change is if you want to poll for both
raw IR and decoded scancodes. If poll were to return ready on raw IR and 
scancodes, existing code would not read the scancodes and end up in an
infinite loop.

So poll only returns ready for the current mode (either raw IR or scancodes).

If you want to read for both scancodes and raw IR, either:

1) Poll in scancode mode for 200ms, Poll in rawir for 200ms. Repeat.

2) Allow multiple fds to be opened on /dev/lircN device and open two
   file descriptors, one in each mode (I want to add this to rc-core anyway).

3) Add an ioctl in which you can set the "poll" mask, e.g.:

   unsigned mask = LIRC_MODE_MODE2 | LIRC_MODE_SCANCODE;
   ioctl(fd, LIRC_SET_POLL_MASK, &mask);
   

Sean

  reply	other threads:[~2017-03-02 13:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25 11:51 [PATCH v3 00/19] Teach lirc how to send and receive scancodes Sean Young
2017-02-25 11:51 ` [PATCH v3 01/19] [media] lirc: document lirc modes better Sean Young
2017-02-25 11:51 ` [PATCH v3 02/19] [media] lirc: return ENOTTY when ioctl is not supported Sean Young
2017-02-25 11:51 ` [PATCH v3 03/19] [media] lirc: return ENOTTY when device does support ioctl Sean Young
2017-02-25 11:51 ` [PATCH v3 04/19] [media] winbond: allow timeout to be set Sean Young
2017-02-25 11:51 ` [PATCH v3 05/19] [media] gpio-ir: do not allow a timeout of 0 Sean Young
2017-02-25 11:51 ` [PATCH v3 06/19] [media] rc: lirc keymap no longer makes any sense Sean Young
2017-02-25 11:51 ` [PATCH v3 07/19] [media] lirc: advertise LIRC_CAN_GET_REC_RESOLUTION and improve Sean Young
2017-02-25 11:51 ` [PATCH v3 08/19] [media] mce_kbd: add encoder Sean Young
2017-02-25 11:51 ` [PATCH v3 09/19] [media] serial_ir: iommap is a memory address, not bool Sean Young
2017-02-25 11:51 ` [PATCH v3 10/19] [media] lirc: use refcounting for lirc devices Sean Young
2017-02-25 11:51 ` [PATCH v3 11/19] [media] lirc: lirc interface should not be a raw decoder Sean Young
2017-02-25 11:51 ` [PATCH v3 12/19] [media] lirc: exorcise struct irctl Sean Young
2017-02-25 11:51 ` [PATCH v3 13/19] [media] lirc: use plain kfifo rather than lirc_buffer Sean Young
2017-02-25 11:51 ` [PATCH v3 14/19] [media] lirc: implement scancode sending Sean Young
2017-02-25 11:51 ` [PATCH v3 15/19] [media] rc: use the correct carrier for scancode transmit Sean Young
2017-02-25 11:51 ` [PATCH v3 16/19] [media] rc: auto load encoder if necessary Sean Young
2017-02-25 11:51 ` [PATCH v3 17/19] [media] lirc: implement reading scancode Sean Young
2017-03-02 13:31   ` Sean Young [this message]
2017-03-06 16:16     ` [PATCH] [media] lirc: introduce LIRC_SET_POLL_MODE Sean Young
2017-02-25 11:51 ` [PATCH v3 18/19] [media] lirc: scancode rc devices should have a lirc device too Sean Young
2017-02-25 11:51 ` [PATCH v3 19/19] [media] lirc: document LIRC_MODE_SCANCODE Sean Young

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=20170302133116.GA29616@gofer.mess.org \
    --to=sean@mess.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    /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).