Re: [PATCH 1/5] [media] rockchip/rga: v4l2 m2m support

2017-07-02 Thread Randy Li



On 06/27/2017 11:49 PM, Nicolas Dufresne wrote:

Le mardi 27 juin 2017 à 23:11 +0800, Jacob Chen a écrit :

Hi Nicolas.

2017-06-26 23:49 GMT+08:00 Nicolas Dufresne :


Le lundi 26 juin 2017 à 22:51 +0800, Jacob Chen a écrit :

Rockchip RGA is a separate 2D raster graphic acceleration unit.
It
accelerates 2D graphics operations, such as point/line drawing,
image
scaling, rotation, BitBLT, alpha blending and image
blur/sharpness.

The drvier is mostly based on s5p-g2d v4l2 m2m driver.
And supports various operations from the rendering pipeline.
  - copy
  - fast solid color fill
  - rotation
  - flip
  - alpha blending

The code in rga-hw.c is used to configure regs accroding to
operations.

The code in rga-buf.c is used to create private mmu table for
RGA.
The tables is stored in a list, and be removed when buffer is
cleanup.

Signed-off-by: Jacob Chen 
---
  drivers/media/platform/Kconfig|  11 +
  drivers/media/platform/Makefile   |   2 +
  drivers/media/platform/rockchip-rga/Makefile  |   3 +
  drivers/media/platform/rockchip-rga/rga-buf.c | 176 +
  drivers/media/platform/rockchip-rga/rga-hw.c  | 456 
  drivers/media/platform/rockchip-rga/rga-hw.h  | 434 
  drivers/media/platform/rockchip-rga/rga.c | 979
++
  drivers/media/platform/rockchip-rga/rga.h | 133 
  8 files changed, 2194 insertions(+)
  create mode 100644 drivers/media/platform/rockchip-rga/Makefile
  create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
  create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
  create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
  create mode 100644 drivers/media/platform/rockchip-rga/rga.c
  create mode 100644 drivers/media/platform/rockchip-rga/rga.h



Could be nice to generalize. We could setup a control and fill the
values base on porter duff operations, then drivers can implement a
subset. Right now, there is no generic way for userspace to know if
a
driver is just doing copies with some transformations, or if it can
actually do alpha blending hence used for composting streams. Note
that
I haven't looked at all possibilities, Freescale IMX.6 seems to
have a
similar driver, which has been wrapped in GStreamer with this
proposed
elements:

https://bugzilla.gnome.org/show_bug.cgi?id=772766



Yeah, i also want it use a generic api.
"porter duff operations" looks good, i will look at it.


+#define V4L2_CID_RGA_ALHPA_REG0 (V4L2_CID_USER_BASE | 0x1002)
+#define V4L2_CID_RGA_ALHPA_REG1 (V4L2_CID_USER_BASE | 0x1003)


It's not obvious why there is two CID, and how this differ from
existing V4L2_CID_ALPHA (the global alpha control).


They are used to calculate factors for below formulas.

 dst alpha = Factor1 * src alpha + Factor2 * dst alpha
 dst color = Factor3 * src color + Factor4 * dst color

I have no idea how to generalize it, and there is no upstream
application need it,
so i just simply exposed the reg.

In my memory, it is is used for convert AYUV to ARGB.


Then maybe it's better to just not expose it in the public API in the
initial patch (nothing forces you to enable everything). The idea is
that it can be added later as needed, taking the time to figure-out a
new API or to figure-out how this matches anything that exist.




+
+/* Operation values */
+#define OP_COPY 0
+#define OP_SOLID_FILL 1
+#define OP_ALPHA_BLEND 2
+
+struct rga_frame *rga_get_frame(struct rga_ctx *ctx, enum
v4l2_buf_type type);
+
+/* RGA Buffers Manage Part */
+extern const struct vb2_ops rga_qops;
+void *rga_buf_find_page(struct vb2_buffer *vb);
+void rga_buf_clean(struct rga_ctx *ctx);
+
+/* RGA Hardware Part */
+void rga_write(struct rockchip_rga *rga, u32 reg, u32 value);
+u32 rga_read(struct rockchip_rga *rga, u32 reg);
+void rga_mod(struct rockchip_rga *rga, u32 reg, u32 val, u32
mask);
+void rga_start(struct rockchip_rga *rga);
+void rga_cmd_set(struct rga_ctx *ctx, void *src_mmu_pages, void
*dst_mmu_pages);
+
+#endif


--
Randy Li



[PATCH] [media] rc-core: do not depend on MEDIA_SUPPORT

2017-07-02 Thread Sean Young
There is no dependency between the two, so remove the dependency in
Kconfig files.

Signed-off-by: Sean Young 
---
 arch/arm/configs/imx_v6_v7_defconfig  |  2 +-
 arch/arm/configs/omap2plus_defconfig  |  2 +-
 arch/arm/configs/sunxi_defconfig  |  2 +-
 arch/mips/configs/pistachio_defconfig |  4 ++--
 drivers/media/Kconfig | 17 ++---
 drivers/media/rc/Kconfig  | 19 ---
 6 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index bb6fa56..2392824 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -222,7 +222,7 @@ CONFIG_REGULATOR_MC13892=y
 CONFIG_REGULATOR_PFUZE100=y
 CONFIG_MEDIA_SUPPORT=y
 CONFIG_MEDIA_CAMERA_SUPPORT=y
-CONFIG_MEDIA_RC_SUPPORT=y
+CONFIG_RC_CORE=y
 CONFIG_RC_DEVICES=y
 CONFIG_IR_GPIO_CIR=y
 CONFIG_MEDIA_USB_SUPPORT=y
diff --git a/arch/arm/configs/omap2plus_defconfig 
b/arch/arm/configs/omap2plus_defconfig
index a120ae8..0414acf 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -304,7 +304,7 @@ CONFIG_REGULATOR_TPS65910=y
 CONFIG_REGULATOR_TWL4030=y
 CONFIG_MEDIA_SUPPORT=m
 CONFIG_MEDIA_CAMERA_SUPPORT=y
-CONFIG_MEDIA_RC_SUPPORT=y
+CONFIG_RC_CORE=m
 CONFIG_MEDIA_CONTROLLER=y
 CONFIG_VIDEO_V4L2_SUBDEV_API=y
 CONFIG_LIRC=m
diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig
index 5cd5dd70..6a0920c 100644
--- a/arch/arm/configs/sunxi_defconfig
+++ b/arch/arm/configs/sunxi_defconfig
@@ -96,7 +96,7 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_AXP20X=y
 CONFIG_REGULATOR_GPIO=y
 CONFIG_MEDIA_SUPPORT=y
-CONFIG_MEDIA_RC_SUPPORT=y
+CONFIG_RC_CORE=y
 CONFIG_RC_DEVICES=y
 CONFIG_IR_SUNXI=y
 CONFIG_DRM=y
diff --git a/arch/mips/configs/pistachio_defconfig 
b/arch/mips/configs/pistachio_defconfig
index 7d32fbb..f4c57d1 100644
--- a/arch/mips/configs/pistachio_defconfig
+++ b/arch/mips/configs/pistachio_defconfig
@@ -11,7 +11,7 @@ CONFIG_DEFAULT_HOSTNAME="localhost"
 CONFIG_SYSVIPC=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
-CONFIG_IKCONFIG=m
+CONFIG_IKCONFIGRC_CORE=m
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=18
 CONFIG_CGROUPS=y
@@ -207,7 +207,7 @@ CONFIG_IMGPDC_WDT=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_GPIO=y
 CONFIG_MEDIA_SUPPORT=y
-CONFIG_MEDIA_RC_SUPPORT=y
+CONFIG_RC_CORE=y
 # CONFIG_RC_DECODERS is not set
 CONFIG_RC_DEVICES=y
 CONFIG_IR_IMG=y
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 55d9c2b..421999b 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -8,6 +8,8 @@ config CEC_CORE
 config CEC_NOTIFIER
bool
 
+source "drivers/media/rc/Kconfig"
+
 menuconfig MEDIA_SUPPORT
tristate "Multimedia support"
depends on HAS_IOMEM
@@ -72,20 +74,6 @@ config MEDIA_SDR_SUPPORT
 
  Say Y when you have a software defined radio device.
 
-config MEDIA_RC_SUPPORT
-   bool "Remote Controller support"
-   depends on INPUT
-   ---help---
- Enable support for Remote Controllers on Linux. This is
- needed in order to support several video capture adapters,
- standalone IR receivers/transmitters, and RF receivers.
-
- Enable this option if you have a video capture board even
- if you don't need IR, as otherwise, you may not be able to
- compile the driver for your adapter.
-
- Say Y when you have a TV or an IR device.
-
 config MEDIA_CEC_SUPPORT
bool "HDMI CEC support"
---help---
@@ -175,7 +163,6 @@ config TTPCI_EEPROM
 source "drivers/media/dvb-core/Kconfig"
 
 comment "Media drivers"
-source "drivers/media/rc/Kconfig"
 
 #
 # V4L platform/mem2mem drivers
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index c5338e3..bca77f0 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -1,9 +1,20 @@
-config RC_CORE
-   tristate
-   depends on MEDIA_RC_SUPPORT
+
+menuconfig RC_CORE
+   tristate "Remote Controller support"
depends on INPUT
default y
+   ---help---
+ Enable support for Remote Controllers on Linux. This is
+ needed in order to support several video capture adapters,
+ standalone IR receivers/transmitters, and RF receivers.
+
+ Enable this option if you have a video capture board even
+ if you don't need IR, as otherwise, you may not be able to
+ compile the driver for your adapter.
 
+ Say Y when you have a TV or an IR device.
+
+if RC_CORE
 source "drivers/media/rc/keymaps/Kconfig"
 
 menuconfig RC_DECODERS
@@ -459,3 +470,5 @@ config IR_SIR
   be called sir-ir.
 
 endif #RC_DEVICES
+
+endif #RC_CORE
-- 
2.9.4



Re: [PATCH v1.1 2/2] drm: rcar-du: Repair vblank for DRM page flips using the VSP1

2017-07-02 Thread Laurent Pinchart
Hi Morimoto-san,

On Friday 30 Jun 2017 08:32:04 Kuninori Morimoto wrote:
> Hi Kieran
> 
> > -static void rcar_du_vsp_complete(void *private)
> > +static void rcar_du_vsp_complete(void *private, bool completed)
> >  {
> > struct rcar_du_crtc *crtc = private;
> > 
> > -   rcar_du_crtc_finish_page_flip(crtc);
> > +   if (crtc->vblank_enable)
> > +   drm_crtc_handle_vblank(&crtc->crtc);
> > +
> > +   if (completed)
> > +   rcar_du_crtc_finish_page_flip(crtc);
> >  }
> 
> Here, this "vblank_enable" flag, timestamp will be update on
> drm_crtc_handle_vblank().
> 
> For example modetest Flip test, if we stop it by Ctrl+C, then, vblank_enable
> will be false, Then, vblank timestamp isn't updated on waiting method on
> drm_atomic_helper_wait_for_vblanks(). Thus we will have timeout error.

I've noticed this issue as well when testing Kieran's patch, and I will fix 
it.

> And, print complete is now indicated on VSP Frame End,
> in interlace input case, print complete will be indicated to user
> on each ODD, EVEN timing.
> 
> Before this patch, for example 1080i@60Hz, print complete indication
> happen in 30Hz.
> After this patch, in interlace case, indication coming 60Hz

Isn't this to be expected ? In 1080i@60Hz the frame rate is 60 frames per 
second, so shouldn't vertical blanking be reported at 60Hz ?

-- 
Regards,

Laurent Pinchart



[PATCH 4/4] [media] rc: pwm-ir-tx: add new driver

2017-07-02 Thread Sean Young
This is new driver which uses pwm, so it is more power-efficient
than the bit banging gpio-ir-tx driver.

Signed-off-by: Sean Young 
---
 .../devicetree/bindings/leds/irled/pwm-ir-tx.txt   |  13 ++
 drivers/media/rc/Kconfig   |  12 ++
 drivers/media/rc/Makefile  |   1 +
 drivers/media/rc/pwm-ir-tx.c   | 165 +
 4 files changed, 191 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt
 create mode 100644 drivers/media/rc/pwm-ir-tx.c

diff --git a/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt 
b/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt
new file mode 100644
index 000..6887a71
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt
@@ -0,0 +1,13 @@
+Device tree bindings for IR LED connected through pwm pin which is used as
+IR transmitter.
+
+Required properties:
+- compatible: should be "pwm-ir-tx".
+- pwms : PWM property to point to the PWM device (phandle)/port (id) and to
+  specify the period time to be used: <&phandle id period_ns>;
+
+Example:
+   irled {
+   compatible = "pwm-ir-tx";
+   pwms = <&pwm0 0 1000>;
+   };
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index ad54011..c5338e3 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -399,6 +399,18 @@ config IR_GPIO_TX
   To compile this driver as a module, choose M here: the module will
   be called gpio-ir-tx.
 
+config IR_PWM_TX
+   tristate "PWM IR transmitter"
+   depends on RC_CORE
+   depends on LIRC
+   depends on PWM
+   ---help---
+  Say Y if you want to use a PWM based IR transmitter. This is
+  more power efficient than the bit banging gpio driver.
+
+  To compile this driver as a module, choose M here: the module will
+  be called pwm-ir-tx.
+
 config RC_ST
tristate "ST remote control receiver"
depends on RC_CORE
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 3e64a4e..466c402 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o
 obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o
 obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
 obj-$(CONFIG_IR_GPIO_TX) += gpio-ir-tx.o
+obj-$(CONFIG_IR_PWM_TX) += pwm-ir-tx.o
 obj-$(CONFIG_IR_IGORPLUGUSB) += igorplugusb.o
 obj-$(CONFIG_IR_IGUANA) += iguanair.o
 obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c
new file mode 100644
index 000..1ab10b4
--- /dev/null
+++ b/drivers/media/rc/pwm-ir-tx.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2017 Sean Young 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_NAME"pwm-ir-tx"
+#define DEVICE_NAME"PWM IR Transmitter"
+
+struct pwm_ir {
+   struct pwm_device *pwm;
+   unsigned int carrier;
+   unsigned int duty_cycle;
+   /* One transmission at a time */
+   struct mutex lock;
+};
+
+static const struct of_device_id pwm_ir_of_match[] = {
+   { .compatible = "pwm-ir-tx", },
+   { },
+};
+MODULE_DEVICE_TABLE(of, pwm_ir_of_match);
+
+static int pwm_ir_set_duty_cycle(struct rc_dev *dev, u32 duty_cycle)
+{
+   struct pwm_ir *pwm_ir = dev->priv;
+
+   pwm_ir->duty_cycle = duty_cycle;
+
+   return 0;
+}
+
+static int pwm_ir_set_carrier(struct rc_dev *dev, u32 carrier)
+{
+   struct pwm_ir *pwm_ir = dev->priv;
+
+   if (!carrier)
+   return -EINVAL;
+
+   pwm_ir->carrier = carrier;
+
+   return 0;
+}
+
+static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
+unsigned int count)
+{
+   struct pwm_ir *pwm_ir = dev->priv;
+   struct pwm_device *pwm = pwm_ir->pwm;
+   int i, duty, period;
+   ktime_t edge;
+   s64 delta;
+
+   if (mutex_lock_interruptible(&pwm_ir->lock))
+   return -ERESTARTSYS;
+
+   period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
+   duty = DIV_ROUND_CLOSEST(pwm_ir->duty_cycle * period, 100);
+
+   pwm_config(pwm, duty, period);
+
+   edge = ktime_get();
+
+   for (i = 0; i < count; i++) {
+   if (i % 2) // space
+   pwm_disable(pwm);
+   else
+   pwm_enable(pwm);
+
+   edge = ktime_add_us(edge, txbuf[i]);
+   delta

[PATCH 1/4] [media] rc-core: rename input_name to device_name

2017-07-02 Thread Sean Young
When an ir-spi is registered, you get this message.

rc rc0: Unspecified device as 
/devices/platform/soc/3f215080.spi/spi_master/spi32766/spi32766.128/rc/rc0

"Unspecified device" refers to input_name, which makes no sense for IR
TX only devices. So, rename to device_name.

Also make driver_name const char* so that no casts are needed anywhere.

Now ir-spi reports:

rc rc0: IR SPI as 
/devices/platform/soc/3f215080.spi/spi_master/spi32766/spi32766.128/rc/rc0

Signed-off-by: Sean Young 
---
 drivers/media/cec/cec-core.c|  4 ++--
 drivers/media/common/siano/smsir.c  |  4 ++--
 drivers/media/i2c/ir-kbd-i2c.c  |  2 +-
 drivers/media/pci/bt8xx/bttv-input.c|  2 +-
 drivers/media/pci/cx23885/cx23885-input.c   |  2 +-
 drivers/media/pci/cx88/cx88-input.c |  2 +-
 drivers/media/pci/dm1105/dm1105.c   |  2 +-
 drivers/media/pci/mantis/mantis_common.h|  2 +-
 drivers/media/pci/mantis/mantis_input.c |  4 ++--
 drivers/media/pci/saa7134/saa7134-input.c   |  2 +-
 drivers/media/pci/smipcie/smipcie-ir.c  |  4 ++--
 drivers/media/pci/smipcie/smipcie.h |  2 +-
 drivers/media/pci/ttpci/budget-ci.c |  2 +-
 drivers/media/rc/ati_remote.c   |  2 +-
 drivers/media/rc/ene_ir.c   |  4 ++--
 drivers/media/rc/fintek-cir.c   |  2 +-
 drivers/media/rc/gpio-ir-recv.c |  2 +-
 drivers/media/rc/igorplugusb.c  |  2 +-
 drivers/media/rc/iguanair.c |  2 +-
 drivers/media/rc/img-ir/img-ir-hw.c |  2 +-
 drivers/media/rc/img-ir/img-ir-raw.c|  2 +-
 drivers/media/rc/imon.c |  2 +-
 drivers/media/rc/ir-hix5hd2.c   |  2 +-
 drivers/media/rc/ir-spi.c   |  1 +
 drivers/media/rc/ite-cir.c  |  2 +-
 drivers/media/rc/mceusb.c   |  2 +-
 drivers/media/rc/meson-ir.c |  2 +-
 drivers/media/rc/mtk-cir.c  |  2 +-
 drivers/media/rc/nuvoton-cir.c  |  2 +-
 drivers/media/rc/rc-loopback.c  |  2 +-
 drivers/media/rc/rc-main.c  |  8 
 drivers/media/rc/redrat3.c  |  2 +-
 drivers/media/rc/serial_ir.c| 10 +-
 drivers/media/rc/sir_ir.c   |  2 +-
 drivers/media/rc/st_rc.c|  2 +-
 drivers/media/rc/streamzap.c|  2 +-
 drivers/media/rc/sunxi-cir.c|  2 +-
 drivers/media/rc/ttusbir.c  |  2 +-
 drivers/media/rc/winbond-cir.c  |  2 +-
 drivers/media/usb/au0828/au0828-input.c |  2 +-
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c |  5 ++---
 drivers/media/usb/dvb-usb/dvb-usb-remote.c  |  2 +-
 drivers/media/usb/em28xx/em28xx-input.c |  2 +-
 drivers/media/usb/tm6000/tm6000-input.c |  2 +-
 include/media/cec.h |  2 +-
 include/media/rc-core.h |  6 +++---
 46 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
index b516d59..1d5087f 100644
--- a/drivers/media/cec/cec-core.c
+++ b/drivers/media/cec/cec-core.c
@@ -263,12 +263,12 @@ struct cec_adapter *cec_allocate_adapter(const struct 
cec_adap_ops *ops,
return ERR_PTR(-ENOMEM);
}
 
-   snprintf(adap->input_name, sizeof(adap->input_name),
+   snprintf(adap->device_name, sizeof(adap->device_name),
 "RC for %s", name);
snprintf(adap->input_phys, sizeof(adap->input_phys),
 "%s/input0", name);
 
-   adap->rc->input_name = adap->input_name;
+   adap->rc->device_name = adap->device_name;
adap->rc->input_phys = adap->input_phys;
adap->rc->input_id.bustype = BUS_CEC;
adap->rc->input_id.vendor = 0;
diff --git a/drivers/media/common/siano/smsir.c 
b/drivers/media/common/siano/smsir.c
index 7c898b0..941c342 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -73,7 +73,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys));
strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys));
 
-   dev->input_name = coredev->ir.name;
+   dev->device_name = coredev->ir.name;
dev->input_phys = coredev->ir.phys;
dev->dev.parent = coredev->device;
 
@@ -91,7 +91,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
dev->driver_name = MODULE_NAME;
 
pr_debug("Input device (IR) %s is set for key events\n",
-dev->input_name);
+dev->device_name);
 
err = rc_register_device(dev);
if (err < 0) {
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index cee7fd9..af909bf 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -452,7 +452,7 @@ static int ir_probe(struct i2c_client *client, const struct

[PATCH 2/4] [media] rc: mce kbd decoder not needed for IR TX drivers

2017-07-02 Thread Sean Young
Without this patch, an input device is created which is not necessary.

Signed-off-by: Sean Young 
---
 drivers/media/rc/ir-mce_kbd-decoder.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c 
b/drivers/media/rc/ir-mce_kbd-decoder.c
index 6a4d58b..0e07442 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -358,6 +358,9 @@ static int ir_mce_kbd_register(struct rc_dev *dev)
struct input_dev *idev;
int i, ret;
 
+   if (dev->driver_type == RC_DRIVER_IR_RAW_TX)
+   return 0;
+
idev = input_allocate_device();
if (!idev)
return -ENOMEM;
-- 
2.9.4



[PATCH 0/4] Generic Raspberry Pi IR transmitters

2017-07-02 Thread Sean Young
These drivers are generic, but they've been tested on Raspberry Pi.

Note that the gpio-ir-recv is a separate driver, so you will end up
with two /dev/lircN devices if you want a receiver and a transmitter,
whilst with the lirc_rpi driver you have one /dev/lircN device. I'm
not sure this is either a problem or how it could be solved.

With this in place, there is no reason to use the lirc_rpi any more.

Also note that it might be possible for the Nokia N900 to use the
pwm-ir-tx driver, making ir-rx51 obsolete. The pwm-ir-tx driver is
shorter and simpler.

Sean Young (4):
  [media] rc-core: rename input_name to device_name
  [media] rc: mce kbd decoder not needed for IR TX drivers
  [media] rc: gpio-ir-tx: add new driver
  [media] rc: pwm-ir-tx: add new driver

 .../devicetree/bindings/leds/irled/gpio-ir-tx.txt  |  11 ++
 .../devicetree/bindings/leds/irled/pwm-ir-tx.txt   |  13 ++
 drivers/media/cec/cec-core.c   |   4 +-
 drivers/media/common/siano/smsir.c |   4 +-
 drivers/media/i2c/ir-kbd-i2c.c |   2 +-
 drivers/media/pci/bt8xx/bttv-input.c   |   2 +-
 drivers/media/pci/cx23885/cx23885-input.c  |   2 +-
 drivers/media/pci/cx88/cx88-input.c|   2 +-
 drivers/media/pci/dm1105/dm1105.c  |   2 +-
 drivers/media/pci/mantis/mantis_common.h   |   2 +-
 drivers/media/pci/mantis/mantis_input.c|   4 +-
 drivers/media/pci/saa7134/saa7134-input.c  |   2 +-
 drivers/media/pci/smipcie/smipcie-ir.c |   4 +-
 drivers/media/pci/smipcie/smipcie.h|   2 +-
 drivers/media/pci/ttpci/budget-ci.c|   2 +-
 drivers/media/rc/Kconfig   |  23 +++
 drivers/media/rc/Makefile  |   2 +
 drivers/media/rc/ati_remote.c  |   2 +-
 drivers/media/rc/ene_ir.c  |   4 +-
 drivers/media/rc/fintek-cir.c  |   2 +-
 drivers/media/rc/gpio-ir-recv.c|   2 +-
 drivers/media/rc/gpio-ir-tx.c  | 189 +
 drivers/media/rc/igorplugusb.c |   2 +-
 drivers/media/rc/iguanair.c|   2 +-
 drivers/media/rc/img-ir/img-ir-hw.c|   2 +-
 drivers/media/rc/img-ir/img-ir-raw.c   |   2 +-
 drivers/media/rc/imon.c|   2 +-
 drivers/media/rc/ir-hix5hd2.c  |   2 +-
 drivers/media/rc/ir-mce_kbd-decoder.c  |   3 +
 drivers/media/rc/ir-spi.c  |   1 +
 drivers/media/rc/ite-cir.c |   2 +-
 drivers/media/rc/mceusb.c  |   2 +-
 drivers/media/rc/meson-ir.c|   2 +-
 drivers/media/rc/mtk-cir.c |   2 +-
 drivers/media/rc/nuvoton-cir.c |   2 +-
 drivers/media/rc/pwm-ir-tx.c   | 165 ++
 drivers/media/rc/rc-loopback.c |   2 +-
 drivers/media/rc/rc-main.c |   8 +-
 drivers/media/rc/redrat3.c |   2 +-
 drivers/media/rc/serial_ir.c   |  10 +-
 drivers/media/rc/sir_ir.c  |   2 +-
 drivers/media/rc/st_rc.c   |   2 +-
 drivers/media/rc/streamzap.c   |   2 +-
 drivers/media/rc/sunxi-cir.c   |   2 +-
 drivers/media/rc/ttusbir.c |   2 +-
 drivers/media/rc/winbond-cir.c |   2 +-
 drivers/media/usb/au0828/au0828-input.c|   2 +-
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c|   5 +-
 drivers/media/usb/dvb-usb/dvb-usb-remote.c |   2 +-
 drivers/media/usb/em28xx/em28xx-input.c|   2 +-
 drivers/media/usb/tm6000/tm6000-input.c|   2 +-
 include/media/cec.h|   2 +-
 include/media/rc-core.h|   6 +-
 53 files changed, 467 insertions(+), 61 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt
 create mode 100644 Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt
 create mode 100644 drivers/media/rc/gpio-ir-tx.c
 create mode 100644 drivers/media/rc/pwm-ir-tx.c

-- 
2.9.4



[PATCH 3/4] [media] rc: gpio-ir-tx: add new driver

2017-07-02 Thread Sean Young
This is a simple bit-banging GPIO IR TX driver.

Signed-off-by: Sean Young 
---
 .../devicetree/bindings/leds/irled/gpio-ir-tx.txt  |  11 ++
 drivers/media/rc/Kconfig   |  11 ++
 drivers/media/rc/Makefile  |   1 +
 drivers/media/rc/gpio-ir-tx.c  | 189 +
 4 files changed, 212 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt
 create mode 100644 drivers/media/rc/gpio-ir-tx.c

diff --git a/Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt 
b/Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt
new file mode 100644
index 000..bf4d4fb
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt
@@ -0,0 +1,11 @@
+Device tree bindings for IR LED connected through gpio pin which is used as
+IR transmitter.
+
+Required properties:
+   - compatible: should be "gpio-ir-tx".
+
+Example:
+   irled@0 {
+   compatible = "gpio-ir-tx";
+   gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
+   };
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 5e83b76..ad54011 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -388,6 +388,17 @@ config IR_GPIO_CIR
   To compile this driver as a module, choose M here: the module will
   be called gpio-ir-recv.
 
+config IR_GPIO_TX
+   tristate "GPIO IR bit banging transmitter"
+   depends on RC_CORE
+   depends on LIRC
+   ---help---
+  Say Y if you want to a GPIO based IR transmitter. This is a
+  bit banging driver.
+
+  To compile this driver as a module, choose M here: the module will
+  be called gpio-ir-tx.
+
 config RC_ST
tristate "ST remote control receiver"
depends on RC_CORE
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 245e2c2..3e64a4e 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_IR_STREAMZAP) += streamzap.o
 obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o
 obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o
 obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
+obj-$(CONFIG_IR_GPIO_TX) += gpio-ir-tx.o
 obj-$(CONFIG_IR_IGORPLUGUSB) += igorplugusb.o
 obj-$(CONFIG_IR_IGUANA) += iguanair.o
 obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
diff --git a/drivers/media/rc/gpio-ir-tx.c b/drivers/media/rc/gpio-ir-tx.c
new file mode 100644
index 000..c2ea002
--- /dev/null
+++ b/drivers/media/rc/gpio-ir-tx.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2017 Sean Young 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_NAME"gpio-ir-tx"
+#define DEVICE_NAME"GPIO IR Bit Banging Transmitter"
+
+struct gpio_rc_dev {
+   int gpio_nr;
+   unsigned int carrier;
+   unsigned int duty_cycle;
+   bool active_low;
+   /* we need a spinlock to hold the cpu while transmitting */
+   spinlock_t lock;
+};
+
+static const struct of_device_id gpio_ir_tx_of_match[] = {
+   { .compatible = "gpio-ir-tx", },
+   { },
+};
+MODULE_DEVICE_TABLE(of, gpio_ir_tx_of_match);
+
+static int gpio_ir_tx_set_duty_cycle(struct rc_dev *dev, u32 duty_cycle)
+{
+   struct gpio_rc_dev *gpio_dev = dev->priv;
+
+   gpio_dev->duty_cycle = duty_cycle;
+
+   return 0;
+}
+
+static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier)
+{
+   struct gpio_rc_dev *gpio_dev = dev->priv;
+
+   if (!carrier)
+   return -EINVAL;
+
+   gpio_dev->carrier = carrier;
+
+   return 0;
+}
+
+static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
+ unsigned int count)
+{
+   struct gpio_rc_dev *gpio_dev = dev->priv;
+   unsigned long flags;
+   ktime_t edge;
+   s64 delta;
+   int i;
+   unsigned int pulse, space;
+
+   /* Ensure the dividend fits into 32 bit */
+   pulse = DIV_ROUND_CLOSEST(gpio_dev->duty_cycle * (NSEC_PER_SEC / 100),
+ gpio_dev->carrier);
+   space = DIV_ROUND_CLOSEST((100l - gpio_dev->duty_cycle) *
+ (NSEC_PER_SEC / 100), gpio_dev->carrier);
+
+   spin_lock_irqsave(&gpio_dev->lock, flags);
+
+   edge = ktime_get();
+
+   for (i = 0; i < count; i++) {
+   if (i % 2) {
+   // space
+   edge = ktime_add_us(edge, txbuf[i]);
+   delta = ktime_us_delta(edge, ktime_get());
+   

Re: [PATCH] [media] staging/imx: remove confusing IS_ERR_OR_NULL usage

2017-07-02 Thread kbuild test robot
Hi Arnd,

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on next-20170630]
[cannot apply to v4.12-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Arnd-Bergmann/staging-imx-remove-confusing-IS_ERR_OR_NULL-usage/20170701-095942
base:   git://linuxtv.org/media_tree.git master
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/staging/media/imx/imx-media-csi.c: In function 
'csi_idmac_get_ipu_resources':
>> drivers/staging/media/imx/imx-media-csi.c:149:11: error: assignment from 
>> incompatible pointer type [-Werror=incompatible-pointer-types]
 idmac_ch = ipu_idmac_get(priv->ipu, ch_num);
  ^
   drivers/staging/media/imx/imx-media-csi.c:156:17: error: assignment from 
incompatible pointer type [-Werror=incompatible-pointer-types]
 priv->idmac_ch = idmac_ch;
^
   cc1: some warnings being treated as errors

vim +149 drivers/staging/media/imx/imx-media-csi.c

   143  v4l2_err(&priv->sd, "failed to get SMFC\n");
   144  ret = PTR_ERR(smfc);
   145  goto out;
   146  }
   147  priv->smfc = smfc;
   148  
 > 149  idmac_ch = ipu_idmac_get(priv->ipu, ch_num);
   150  if (IS_ERR(idmac_ch)) {
   151  v4l2_err(&priv->sd, "could not get IDMAC channel %u\n",
   152   ch_num);

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip