--- /dev/null
+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: [media] ir-spi: Fix issues with lirc API
+
+From: Anton Blanchard <anton@samba.org>
+
+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 <anton@samba.org>
+Signed-off-by: Sean Young <sean@mess.org>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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;
+
--- /dev/null
+From 9f5039ba440e499d85c29b1ddbc3cbc9dc90e44b Mon Sep 17 00:00:00 2001
+From: Sean Young <sean@mess.org>
+Date: Fri, 7 Jul 2017 18:49:18 -0300
+Subject: media: lirc: LIRC_GET_REC_RESOLUTION should return microseconds
+
+From: Sean Young <sean@mess.org>
+
+commit 9f5039ba440e499d85c29b1ddbc3cbc9dc90e44b upstream.
+
+Since commit e8f4818895b3 ("[media] lirc: advertise
+LIRC_CAN_GET_REC_RESOLUTION and improve") lircd uses the ioctl
+LIRC_GET_REC_RESOLUTION to determine the shortest pulse or space that
+the hardware can detect. This breaks decoding in lirc because lircd
+expects the answer in microseconds, but nanoseconds is returned.
+
+Reported-by: Derek <user.vdr@gmail.com>
+Tested-by: Derek <user.vdr@gmail.com>
+Signed-off-by: Sean Young <sean@mess.org>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/rc/ir-lirc-codec.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/media/rc/ir-lirc-codec.c
++++ b/drivers/media/rc/ir-lirc-codec.c
+@@ -266,7 +266,7 @@ static long ir_lirc_ioctl(struct file *f
+ if (!dev->rx_resolution)
+ return -ENOTTY;
+
+- val = dev->rx_resolution;
++ val = dev->rx_resolution / 1000;
+ break;
+
+ case LIRC_SET_WIDEBAND_RECEIVER:
--- /dev/null
+From da05d52d2f0f6bd61094a0cd045fed94bf7d673a Mon Sep 17 00:00:00 2001
+From: Prabhakar Lad <prabhakar.csengg@gmail.com>
+Date: Thu, 20 Jul 2017 08:02:09 -0400
+Subject: media: platform: davinci: return -EINVAL for VPFE_CMD_S_CCDC_RAW_PARAMS ioctl
+
+From: Prabhakar Lad <prabhakar.csengg@gmail.com>
+
+commit da05d52d2f0f6bd61094a0cd045fed94bf7d673a upstream.
+
+this patch makes sure VPFE_CMD_S_CCDC_RAW_PARAMS ioctl no longer works
+for vpfe_capture driver with a minimal patch suitable for backporting.
+
+- This ioctl was never in public api and was only defined in kernel header.
+- The function set_params constantly mixes up pointers and phys_addr_t
+ numbers.
+- This is part of a 'VPFE_CMD_S_CCDC_RAW_PARAMS' ioctl command that is
+ described as an 'experimental ioctl that will change in future kernels'.
+- The code to allocate the table never gets called after we copy_from_user
+ the user input over the kernel settings, and then compare them
+ for inequality.
+- We then go on to use an address provided by user space as both the
+ __user pointer for input and pass it through phys_to_virt to come up
+ with a kernel pointer to copy the data to. This looks like a trivially
+ exploitable root hole.
+
+Due to these reasons we make sure this ioctl now returns -EINVAL and backport
+this patch as far as possible.
+
+Fixes: 5f15fbb68fd7 ("V4L/DVB (12251): v4l: dm644x ccdc module for vpfe capture driver")
+
+Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
+Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/platform/davinci/vpfe_capture.c | 22 ++--------------------
+ 1 file changed, 2 insertions(+), 20 deletions(-)
+
+--- a/drivers/media/platform/davinci/vpfe_capture.c
++++ b/drivers/media/platform/davinci/vpfe_capture.c
+@@ -1719,27 +1719,9 @@ static long vpfe_param_handler(struct fi
+
+ switch (cmd) {
+ case VPFE_CMD_S_CCDC_RAW_PARAMS:
++ ret = -EINVAL;
+ v4l2_warn(&vpfe_dev->v4l2_dev,
+- "VPFE_CMD_S_CCDC_RAW_PARAMS: experimental ioctl\n");
+- if (ccdc_dev->hw_ops.set_params) {
+- ret = ccdc_dev->hw_ops.set_params(param);
+- if (ret) {
+- v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
+- "Error setting parameters in CCDC\n");
+- goto unlock_out;
+- }
+- ret = vpfe_get_ccdc_image_format(vpfe_dev,
+- &vpfe_dev->fmt);
+- if (ret < 0) {
+- v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
+- "Invalid image format at CCDC\n");
+- goto unlock_out;
+- }
+- } else {
+- ret = -EINVAL;
+- v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
+- "VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
+- }
++ "VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
+ break;
+ default:
+ ret = -ENOTTY;
--- /dev/null
+From 9b7c0c476f66ee212925c801c4141fdd83b7336d Mon Sep 17 00:00:00 2001
+From: Hans Verkuil <hverkuil@xs4all.nl>
+Date: Sun, 16 Jul 2017 05:15:47 -0300
+Subject: media: pulse8-cec: persistent_config should be off by default
+
+From: Hans Verkuil <hverkuil@xs4all.nl>
+
+commit 9b7c0c476f66ee212925c801c4141fdd83b7336d upstream.
+
+The persistent_config option is used to make the CEC settings persistent by using
+the eeprom inside the device to store this information. This was on by default, which
+caused confusion since this device now behaves differently from other CEC devices
+which all come up unconfigured.
+
+Another reason for doing this now is that I hope a more standard way of selecting
+persistent configuration will be created in the future. And for that to work all
+CEC drivers should behave the same and come up unconfigured by default.
+
+None of the open source CEC applications are using this CEC framework at the moment
+so change this behavior before it is too late.
+
+Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/media/usb/pulse8-cec/pulse8-cec.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/media/usb/pulse8-cec/pulse8-cec.c
++++ b/drivers/media/usb/pulse8-cec/pulse8-cec.c
+@@ -51,7 +51,7 @@ MODULE_DESCRIPTION("Pulse Eight HDMI CEC
+ MODULE_LICENSE("GPL");
+
+ static int debug;
+-static int persistent_config = 1;
++static int persistent_config;
+ module_param(debug, int, 0644);
+ module_param(persistent_config, int, 0644);
+ MODULE_PARM_DESC(debug, "debug level (0-1)");
arm-mvebu-use-__pa_symbol-in-the-mv98dx3236-platform-smp-code.patch
arm-dts-armada-38x-fix-irq-type-for-pca955.patch
arm-dts-tango4-request-rgmii-rx-and-tx-clock-delays.patch
+media-pulse8-cec-persistent_config-should-be-off-by-default.patch
+media-lirc-lirc_get_rec_resolution-should-return-microseconds.patch
+media-platform-davinci-return-einval-for-vpfe_cmd_s_ccdc_raw_params-ioctl.patch
+ir-spi-fix-issues-with-lirc-api.patch