From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:42480 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751743AbdHGWQn (ORCPT ); Mon, 7 Aug 2017 18:16:43 -0400 Subject: Patch "[media] ir-spi: Fix issues with lirc API" has been added to the 4.12-stable tree To: anton@samba.org, gregkh@linuxfoundation.org, mchehab@s-opensource.com, sean@mess.org Cc: , From: Date: Mon, 07 Aug 2017 15:16:42 -0700 Message-ID: <1502144202230118@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled [media] ir-spi: Fix issues with lirc API to the 4.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ir-spi-fix-issues-with-lirc-api.patch and it can be found in the queue-4.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From cc20ba4ed8576abfa10a17e81cb4521f474624f0 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sat, 6 May 2017 22:00:11 -0300 Subject: [media] ir-spi: Fix issues with lirc API From: Anton Blanchard commit cc20ba4ed8576abfa10a17e81cb4521f474624f0 upstream. 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") Signed-off-by: Anton Blanchard Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/rc/ir-spi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- 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; Patches currently in stable-queue which might be from anton@samba.org are queue-4.12/ir-spi-fix-issues-with-lirc-api.patch