All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] [media] ir-spi: Fix issues with lirc API" failed to apply to 4.12-stable tree
@ 2017-07-22 13:22 gregkh
  2017-07-29 11:24 ` Sean Young
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2017-07-22 13:22 UTC (permalink / raw)
  To: anton, mchehab, sean; +Cc: stable


The patch below does not apply to the 4.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From cc20ba4ed8576abfa10a17e81cb4521f474624f0 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
Date: Sat, 6 May 2017 22:00:11 -0300
Subject: [PATCH] [media] ir-spi: Fix issues with lirc API

The ir-spi driver has 2 issues which prevents it from working with
lirc:

1. The ir-spi driver uses 16 bits of SPI data to create one cycle of
the waveform. As such our SPI clock needs to be 16x faster than the
carrier frequency.

The driver is inconsistent in how it currently handles this. It
initializes it to the carrier frequency:

But the commit message has some example code which initialises it
to 16x the carrier frequency:

	val = 608000;
	ret = ioctl(fd, LIRC_SET_SEND_CARRIER, &val);

To maintain compatibility with lirc, always do the frequency adjustment
in the driver.

2. lirc presents pulses in microseconds, but the ir-spi driver treats
them as cycles of the carrier. Similar to other lirc drivers, do the
conversion with DIV_ROUND_CLOSEST().

Fixes: fe052da49201 ("[media] rc: add support for IR LEDs driven through SPI")

Cc: stable@vger.kernel.org
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
index 4ca43383a8e8..7e383b3fedd5 100644
--- a/drivers/media/rc/ir-spi.c
+++ b/drivers/media/rc/ir-spi.c
@@ -57,10 +57,13 @@ static int ir_spi_tx(struct rc_dev *dev,
 
 	/* convert the pulse/space signal to raw binary signal */
 	for (i = 0; i < count; i++) {
+		unsigned int periods;
 		int j;
 		u16 val;
 
-		if (len + buffer[i] >= IR_SPI_MAX_BUFSIZE)
+		periods = DIV_ROUND_CLOSEST(buffer[i] * idata->freq, 1000000);
+
+		if (len + periods >= IR_SPI_MAX_BUFSIZE)
 			return -EINVAL;
 
 		/*
@@ -69,13 +72,13 @@ static int ir_spi_tx(struct rc_dev *dev,
 		 * contain a space duration.
 		 */
 		val = (i % 2) ? idata->space : idata->pulse;
-		for (j = 0; j < buffer[i]; j++)
+		for (j = 0; j < periods; j++)
 			idata->tx_buf[len++] = val;
 	}
 
 	memset(&xfer, 0, sizeof(xfer));
 
-	xfer.speed_hz = idata->freq;
+	xfer.speed_hz = idata->freq * 16;
 	xfer.len = len * sizeof(*idata->tx_buf);
 	xfer.tx_buf = idata->tx_buf;
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: FAILED: patch "[PATCH] [media] ir-spi: Fix issues with lirc API" failed to apply to 4.12-stable tree
  2017-07-22 13:22 FAILED: patch "[PATCH] [media] ir-spi: Fix issues with lirc API" failed to apply to 4.12-stable tree gregkh
@ 2017-07-29 11:24 ` Sean Young
  2017-08-07 22:16   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Young @ 2017-07-29 11:24 UTC (permalink / raw)
  To: gregkh; +Cc: anton, mchehab, stable


From: Anton Blanchard <anton@samba.org>
Subject: [PATCH] [media] ir-spi: Fix issues with lirc API

The ir-spi driver has 2 issues which prevents it from working with
lirc:

1. The ir-spi driver uses 16 bits of SPI data to create one cycle of
the waveform. As such our SPI clock needs to be 16x faster than the
carrier frequency.

The driver is inconsistent in how it currently handles this. It
initializes it to the carrier frequency:

But the commit message has some example code which initialises it
to 16x the carrier frequency:

	val = 608000;
	ret = ioctl(fd, LIRC_SET_SEND_CARRIER, &val);

To maintain compatibility with lirc, always do the frequency adjustment
in the driver.

2. lirc presents pulses in microseconds, but the ir-spi driver treats
them as cycles of the carrier. Similar to other lirc drivers, do the
conversion with DIV_ROUND_CLOSEST().

Fixes: fe052da49201 ("[media] rc: add support for IR LEDs driven through SPI")

Cc: stable@vger.kernel.org
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/rc/ir-spi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
index c8863f36686a..f39cf8cb639f 100644
--- a/drivers/media/rc/ir-spi.c
+++ b/drivers/media/rc/ir-spi.c
@@ -57,10 +57,13 @@ static int ir_spi_tx(struct rc_dev *dev,
 
 	/* convert the pulse/space signal to raw binary signal */
 	for (i = 0; i < count; i++) {
+		unsigned int periods;
 		int j;
 		u16 val = ((i + 1) % 2) ? idata->pulse : idata->space;
 
-		if (len + buffer[i] >= IR_SPI_MAX_BUFSIZE)
+		periods = DIV_ROUND_CLOSEST(buffer[i] * idata->freq, 1000000);
+
+		if (len + periods >= IR_SPI_MAX_BUFSIZE)
 			return -EINVAL;
 
 		/*
@@ -69,13 +72,13 @@ static int ir_spi_tx(struct rc_dev *dev,
 		 * contain a space duration.
 		 */
 		val = (i % 2) ? idata->space : idata->pulse;
-		for (j = 0; j < buffer[i]; j++)
+		for (j = 0; j < periods; j++)
 			idata->tx_buf[len++] = val;
 	}
 
 	memset(&xfer, 0, sizeof(xfer));
 
-	xfer.speed_hz = idata->freq;
+	xfer.speed_hz = idata->freq * 16;
 	xfer.len = len * sizeof(*idata->tx_buf);
 	xfer.tx_buf = idata->tx_buf;
 
-- 
2.11.0

On Sat, Jul 22, 2017 at 03:22:02PM +0200, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 4.12-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> >From cc20ba4ed8576abfa10a17e81cb4521f474624f0 Mon Sep 17 00:00:00 2001
> From: Anton Blanchard <anton@samba.org>
> Date: Sat, 6 May 2017 22:00:11 -0300
> Subject: [PATCH] [media] ir-spi: Fix issues with lirc API
> 
> The ir-spi driver has 2 issues which prevents it from working with
> lirc:
> 
> 1. The ir-spi driver uses 16 bits of SPI data to create one cycle of
> the waveform. As such our SPI clock needs to be 16x faster than the
> carrier frequency.
> 
> The driver is inconsistent in how it currently handles this. It
> initializes it to the carrier frequency:
> 
> But the commit message has some example code which initialises it
> to 16x the carrier frequency:
> 
> 	val = 608000;
> 	ret = ioctl(fd, LIRC_SET_SEND_CARRIER, &val);
> 
> To maintain compatibility with lirc, always do the frequency adjustment
> in the driver.
> 
> 2. lirc presents pulses in microseconds, but the ir-spi driver treats
> them as cycles of the carrier. Similar to other lirc drivers, do the
> conversion with DIV_ROUND_CLOSEST().
> 
> Fixes: fe052da49201 ("[media] rc: add support for IR LEDs driven through SPI")
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Anton Blanchard <anton@samba.org>
> Signed-off-by: Sean Young <sean@mess.org>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> 
> diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
> index 4ca43383a8e8..7e383b3fedd5 100644
> --- a/drivers/media/rc/ir-spi.c
> +++ b/drivers/media/rc/ir-spi.c
> @@ -57,10 +57,13 @@ static int ir_spi_tx(struct rc_dev *dev,
>  
>  	/* convert the pulse/space signal to raw binary signal */
>  	for (i = 0; i < count; i++) {
> +		unsigned int periods;
>  		int j;
>  		u16 val;
>  
> -		if (len + buffer[i] >= IR_SPI_MAX_BUFSIZE)
> +		periods = DIV_ROUND_CLOSEST(buffer[i] * idata->freq, 1000000);
> +
> +		if (len + periods >= IR_SPI_MAX_BUFSIZE)
>  			return -EINVAL;
>  
>  		/*
> @@ -69,13 +72,13 @@ static int ir_spi_tx(struct rc_dev *dev,
>  		 * contain a space duration.
>  		 */
>  		val = (i % 2) ? idata->space : idata->pulse;
> -		for (j = 0; j < buffer[i]; j++)
> +		for (j = 0; j < periods; j++)
>  			idata->tx_buf[len++] = val;
>  	}
>  
>  	memset(&xfer, 0, sizeof(xfer));
>  
> -	xfer.speed_hz = idata->freq;
> +	xfer.speed_hz = idata->freq * 16;
>  	xfer.len = len * sizeof(*idata->tx_buf);
>  	xfer.tx_buf = idata->tx_buf;
>  

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: FAILED: patch "[PATCH] [media] ir-spi: Fix issues with lirc API" failed to apply to 4.12-stable tree
  2017-07-29 11:24 ` Sean Young
@ 2017-08-07 22:16   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2017-08-07 22:16 UTC (permalink / raw)
  To: Sean Young; +Cc: anton, mchehab, stable

On Sat, Jul 29, 2017 at 12:24:45PM +0100, Sean Young wrote:
> 
> From: Anton Blanchard <anton@samba.org>
> Subject: [PATCH] [media] ir-spi: Fix issues with lirc API
> 
> The ir-spi driver has 2 issues which prevents it from working with
> lirc:
> 
> 1. The ir-spi driver uses 16 bits of SPI data to create one cycle of
> the waveform. As such our SPI clock needs to be 16x faster than the
> carrier frequency.
> 
> The driver is inconsistent in how it currently handles this. It
> initializes it to the carrier frequency:
> 
> But the commit message has some example code which initialises it
> to 16x the carrier frequency:
> 
> 	val = 608000;
> 	ret = ioctl(fd, LIRC_SET_SEND_CARRIER, &val);
> 
> To maintain compatibility with lirc, always do the frequency adjustment
> in the driver.
> 
> 2. lirc presents pulses in microseconds, but the ir-spi driver treats
> them as cycles of the carrier. Similar to other lirc drivers, do the
> conversion with DIV_ROUND_CLOSEST().
> 
> Fixes: fe052da49201 ("[media] rc: add support for IR LEDs driven through SPI")
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Anton Blanchard <anton@samba.org>
> Signed-off-by: Sean Young <sean@mess.org>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/rc/ir-spi.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Thanks for the backport.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-07 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-22 13:22 FAILED: patch "[PATCH] [media] ir-spi: Fix issues with lirc API" failed to apply to 4.12-stable tree gregkh
2017-07-29 11:24 ` Sean Young
2017-08-07 22:16   ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.