Re: [PATCH v3 17/19] [media] lirc: implement reading scancode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux