Re: [PATCH v2 2/3] rc: Introduce hix5hd2 IR transmitter driver

2014-08-27 Thread Sean Young
On Wed, Aug 27, 2014 at 06:10:28PM +0800, zhangfei wrote:
> On 08/27/2014 05:51 PM, Sean Young wrote:
> >On Wed, Aug 27, 2014 at 04:49:59PM +0800, zhangfei wrote:
> >>On 08/21/2014 06:07 PM, Sean Young wrote:
> >IR. There is be no reason to run lircd if you use this method.
> Do you mean kernel decoder is enough to cover?
> We use user space lircd to cosider more flexibility, even some
> non-standard protocol.

Just out of interest, what flexibility does lircd offer which the kernel
decoders do not? 

> Anyway both method can be supported, depending on whether setting
> the optional property "linux,rc-map-name" or not.

Great, thanks.

Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/3] rc: Introduce hix5hd2 IR transmitter driver

2014-08-27 Thread zhangfei

Hi, Sean

On 08/27/2014 05:51 PM, Sean Young wrote:

On Wed, Aug 27, 2014 at 04:49:59PM +0800, zhangfei wrote:

On 08/21/2014 06:07 PM, Sean Young wrote:

On Thu, Aug 21, 2014 at 05:24:44PM +0800, Zhangfei Gao wrote:
It would be useful is rdev->input_phys, rdev->input_id,
rdev->timeout, rdev->rx_resolution are set correctly.


OK, will set rdev->timeout, rdev->rx_resolution
Not sure the usage of rdev->input_id, why is it required?


This is for the EVIOCGID ioctl on the input device which will be created
for the rc device. This is used for delivering input events from decoded


Find EVIOCGID in drivers/input/evdev.c
Will use same value as sunxi-cir.c & gpio-ir-recv.c, if these value has 
no special requirement.

rcdev->input_id.bustype = BUS_HOST;
rcdev->input_id.vendor = 0x0001;
rcdev->input_id.product = 0x0001;
rcdev->input_id.version = 0x0100;


IR. There is be no reason to run lircd if you use this method.

Do you mean kernel decoder is enough to cover?
We use user space lircd to cosider more flexibility, even some 
non-standard protocol.


Anyway both method can be supported, depending on whether setting the 
optional property "linux,rc-map-name" or not.


Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/3] rc: Introduce hix5hd2 IR transmitter driver

2014-08-27 Thread Sean Young
On Wed, Aug 27, 2014 at 04:49:59PM +0800, zhangfei wrote:
> On 08/21/2014 06:07 PM, Sean Young wrote:
> >On Thu, Aug 21, 2014 at 05:24:44PM +0800, Zhangfei Gao wrote:
> >It would be useful is rdev->input_phys, rdev->input_id,
> >rdev->timeout, rdev->rx_resolution are set correctly.
> 
> OK, will set rdev->timeout, rdev->rx_resolution
> Not sure the usage of rdev->input_id, why is it required?

This is for the EVIOCGID ioctl on the input device which will be created 
for the rc device. This is used for delivering input events from decoded
IR. There is be no reason to run lircd if you use this method.


Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/3] rc: Introduce hix5hd2 IR transmitter driver

2014-08-27 Thread zhangfei



On 08/21/2014 06:07 PM, Sean Young wrote:

On Thu, Aug 21, 2014 at 05:24:44PM +0800, Zhangfei Gao wrote:

From: Guoxiong Yan 



+   rdev->driver_type = RC_DRIVER_IR_RAW;
+   rdev->allowed_protocols = RC_BIT_ALL;
+   rdev->priv = priv;
+   rdev->open = hix5hd2_ir_open;
+   rdev->close = hix5hd2_ir_close;
+   rdev->driver_name = IR_HIX5HD2_NAME;
+   rdev->map_name = RC_MAP_LIRC;


I'm not sure RC_MAP_LIRC is appropriate. If the hardware has no implicit
remote, can this be stored in device tree like the sunxi-cir.c driver does?


OK, got it.
Will set optional property "linux,rc-map-name" for the map_name.
We usually use user space lirc decoder, so this optional property may 
not need to be set in dts.





+   rdev->input_name = "Hisilicon hix5hd2 Remote Control Receiver";


It would be useful is rdev->input_phys, rdev->input_id,
rdev->timeout, rdev->rx_resolution are set correctly.


OK, will set rdev->timeout, rdev->rx_resolution
Not sure the usage of rdev->input_id, why is it required?

Thanks for the suggestion.

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/3] rc: Introduce hix5hd2 IR transmitter driver

2014-08-21 Thread Sean Young
On Thu, Aug 21, 2014 at 05:24:44PM +0800, Zhangfei Gao wrote:
> From: Guoxiong Yan 
> 
> IR transmitter driver for Hisilicon hix5hd2 soc
> 
> Signed-off-by: Guoxiong Yan 
> Signed-off-by: Zhangfei Gao 
> ---
>  drivers/media/rc/Kconfig  |   11 ++
>  drivers/media/rc/Makefile |1 +
>  drivers/media/rc/ir-hix5hd2.c |  347 
> +
>  3 files changed, 359 insertions(+)
>  create mode 100644 drivers/media/rc/ir-hix5hd2.c
> 
> diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
> index 5e626af..64dc8bb 100644
> --- a/drivers/media/rc/Kconfig
> +++ b/drivers/media/rc/Kconfig
> @@ -164,6 +164,17 @@ config IR_ENE
>  To compile this driver as a module, choose M here: the
>  module will be called ene_ir.
>  
> +config IR_HIX5HD2
> + tristate "Hisilicon hix5hd2 IR remote control"
> + depends on RC_CORE
> + help
> +  Say Y here if you want to use hisilicon remote control.
> +  The driver passes raw pulse and space information to the LIRC decoder.
> +  To compile this driver as a module, choose M here: the module will be
> +  called hisi_ir.
> +
> +  If you're not sure, select N here
> +
>  config IR_IMON
>   tristate "SoundGraph iMON Receiver and Display"
>   depends on USB_ARCH_HAS_HCD
> diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
> index 9f9843a1..0989f94 100644
> --- a/drivers/media/rc/Makefile
> +++ b/drivers/media/rc/Makefile
> @@ -17,6 +17,7 @@ obj-$(CONFIG_IR_XMP_DECODER) += ir-xmp-decoder.o
>  
>  # stand-alone IR receivers/transmitters
>  obj-$(CONFIG_RC_ATI_REMOTE) += ati_remote.o
> +obj-$(CONFIG_IR_HIX5HD2) += ir-hix5hd2.o
>  obj-$(CONFIG_IR_IMON) += imon.o
>  obj-$(CONFIG_IR_ITE_CIR) += ite-cir.o
>  obj-$(CONFIG_IR_MCEUSB) += mceusb.o
> diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c
> new file mode 100644
> index 000..543b454
> --- /dev/null
> +++ b/drivers/media/rc/ir-hix5hd2.c
> @@ -0,0 +1,347 @@
> +/*
> + * Copyright (c) 2014 Linaro Ltd.
> + * Copyright (c) 2014 Hisilicon Limited.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define IR_ENABLE0x00
> +#define IR_CONFIG0x04
> +#define CNT_LEADS0x08
> +#define CNT_LEADE0x0c
> +#define CNT_SLEADE   0x10
> +#define CNT0_B   0x14
> +#define CNT1_B   0x18
> +#define IR_BUSY  0x1c
> +#define IR_DATAH 0x20
> +#define IR_DATAL 0x24
> +#define IR_INTM  0x28
> +#define IR_INTS  0x2c
> +#define IR_INTC  0x30
> +#define IR_START 0x34
> +
> +/* interrupt mask */
> +#define INTMS_SYMBRCV(BIT(24) | BIT(8))
> +#define INTMS_TIMEOUT(BIT(25) | BIT(9))
> +#define INTMS_OVERFLOW   (BIT(26) | BIT(10))
> +#define INT_CLR_OVERFLOW BIT(18)
> +#define INT_CLR_TIMEOUT  BIT(17)
> +#define INT_CLR_RCV  BIT(16)
> +#define INT_CLR_RCVTIMEOUT   (BIT(16) | BIT(17))
> +
> +#define IR_CLK   0x48
> +#define IR_CLK_ENABLEBIT(4)
> +#define IR_CLK_RESET BIT(5)
> +
> +#define IR_CFG_WIDTH_MASK0x
> +#define IR_CFG_WIDTH_SHIFT   16
> +#define IR_CFG_FORMAT_MASK   0x3
> +#define IR_CFG_FORMAT_SHIFT  14
> +#define IR_CFG_INT_LEVEL_MASK0x3f
> +#define IR_CFG_INT_LEVEL_SHIFT   8
> +/* only support raw mode */
> +#define IR_CFG_MODE_RAW  BIT(7)
> +#define IR_CFG_FREQ_MASK 0x7f
> +#define IR_CFG_FREQ_SHIFT0
> +#define IR_CFG_INT_THRESHOLD 1
> +/* symbol start from low to high, symbol stream end at high*/
> +#define IR_CFG_SYMBOL_FMT0
> +#define IR_CFG_SYMBOL_MAXWIDTH   0x3e80
> +
> +#define IR_HIX5HD2_NAME  "hix5hd2-ir"
> +
> +struct hix5hd2_ir_priv {
> + int irq;
> + void*base;
> + struct device   *dev;
> + struct rc_dev   *rdev;
> + struct regmap   *regmap;
> + struct clk  *clock;
> + unsigned long   rate;
> +};
> +
> +static void hix5hd2_ir_send_lirc_timeout(struct rc_dev *rdev)
> +{
> + DEFINE_IR_RAW_EVENT(ev);
> +
> + ev.timeout = true;
> + ir_raw_event_store(rdev, &ev);
> +}
> +
> +static irqreturn_t hix5hd2_ir_rx_interrupt(int irq, void *data)
> +{
> + u32 symb_num, symb_val, symb_time;
> + u32 data_l, data_h;
> + u32 irq_sr, i;
> + struct hix5hd2_ir_priv *priv = data;
> +
> + irq_sr = readl_relaxed(priv->base + IR_INTS);
> + if (irq_sr & INTMS_OVERFLOW) {
> + /*
> +  * we must read IR_DATAL 

[PATCH v2 2/3] rc: Introduce hix5hd2 IR transmitter driver

2014-08-21 Thread Zhangfei Gao
From: Guoxiong Yan 

IR transmitter driver for Hisilicon hix5hd2 soc

Signed-off-by: Guoxiong Yan 
Signed-off-by: Zhangfei Gao 
---
 drivers/media/rc/Kconfig  |   11 ++
 drivers/media/rc/Makefile |1 +
 drivers/media/rc/ir-hix5hd2.c |  347 +
 3 files changed, 359 insertions(+)
 create mode 100644 drivers/media/rc/ir-hix5hd2.c

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 5e626af..64dc8bb 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -164,6 +164,17 @@ config IR_ENE
   To compile this driver as a module, choose M here: the
   module will be called ene_ir.
 
+config IR_HIX5HD2
+   tristate "Hisilicon hix5hd2 IR remote control"
+   depends on RC_CORE
+   help
+Say Y here if you want to use hisilicon remote control.
+The driver passes raw pulse and space information to the LIRC decoder.
+To compile this driver as a module, choose M here: the module will be
+called hisi_ir.
+
+If you're not sure, select N here
+
 config IR_IMON
tristate "SoundGraph iMON Receiver and Display"
depends on USB_ARCH_HAS_HCD
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 9f9843a1..0989f94 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_IR_XMP_DECODER) += ir-xmp-decoder.o
 
 # stand-alone IR receivers/transmitters
 obj-$(CONFIG_RC_ATI_REMOTE) += ati_remote.o
+obj-$(CONFIG_IR_HIX5HD2) += ir-hix5hd2.o
 obj-$(CONFIG_IR_IMON) += imon.o
 obj-$(CONFIG_IR_ITE_CIR) += ite-cir.o
 obj-$(CONFIG_IR_MCEUSB) += mceusb.o
diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c
new file mode 100644
index 000..543b454
--- /dev/null
+++ b/drivers/media/rc/ir-hix5hd2.c
@@ -0,0 +1,347 @@
+/*
+ * Copyright (c) 2014 Linaro Ltd.
+ * Copyright (c) 2014 Hisilicon Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define IR_ENABLE  0x00
+#define IR_CONFIG  0x04
+#define CNT_LEADS  0x08
+#define CNT_LEADE  0x0c
+#define CNT_SLEADE 0x10
+#define CNT0_B 0x14
+#define CNT1_B 0x18
+#define IR_BUSY0x1c
+#define IR_DATAH   0x20
+#define IR_DATAL   0x24
+#define IR_INTM0x28
+#define IR_INTS0x2c
+#define IR_INTC0x30
+#define IR_START   0x34
+
+/* interrupt mask */
+#define INTMS_SYMBRCV  (BIT(24) | BIT(8))
+#define INTMS_TIMEOUT  (BIT(25) | BIT(9))
+#define INTMS_OVERFLOW (BIT(26) | BIT(10))
+#define INT_CLR_OVERFLOW   BIT(18)
+#define INT_CLR_TIMEOUTBIT(17)
+#define INT_CLR_RCVBIT(16)
+#define INT_CLR_RCVTIMEOUT (BIT(16) | BIT(17))
+
+#define IR_CLK 0x48
+#define IR_CLK_ENABLE  BIT(4)
+#define IR_CLK_RESET   BIT(5)
+
+#define IR_CFG_WIDTH_MASK  0x
+#define IR_CFG_WIDTH_SHIFT 16
+#define IR_CFG_FORMAT_MASK 0x3
+#define IR_CFG_FORMAT_SHIFT14
+#define IR_CFG_INT_LEVEL_MASK  0x3f
+#define IR_CFG_INT_LEVEL_SHIFT 8
+/* only support raw mode */
+#define IR_CFG_MODE_RAWBIT(7)
+#define IR_CFG_FREQ_MASK   0x7f
+#define IR_CFG_FREQ_SHIFT  0
+#define IR_CFG_INT_THRESHOLD   1
+/* symbol start from low to high, symbol stream end at high*/
+#define IR_CFG_SYMBOL_FMT  0
+#define IR_CFG_SYMBOL_MAXWIDTH 0x3e80
+
+#define IR_HIX5HD2_NAME"hix5hd2-ir"
+
+struct hix5hd2_ir_priv {
+   int irq;
+   void*base;
+   struct device   *dev;
+   struct rc_dev   *rdev;
+   struct regmap   *regmap;
+   struct clk  *clock;
+   unsigned long   rate;
+};
+
+static void hix5hd2_ir_send_lirc_timeout(struct rc_dev *rdev)
+{
+   DEFINE_IR_RAW_EVENT(ev);
+
+   ev.timeout = true;
+   ir_raw_event_store(rdev, &ev);
+}
+
+static irqreturn_t hix5hd2_ir_rx_interrupt(int irq, void *data)
+{
+   u32 symb_num, symb_val, symb_time;
+   u32 data_l, data_h;
+   u32 irq_sr, i;
+   struct hix5hd2_ir_priv *priv = data;
+
+   irq_sr = readl_relaxed(priv->base + IR_INTS);
+   if (irq_sr & INTMS_OVERFLOW) {
+   /*
+* we must read IR_DATAL first, then we can clean up
+* IR_INTS availably since logic would not clear
+* fifo when overflow, drv do the job
+*/
+   ir_raw_event_reset(priv->rdev);
+   symb_num = readl_relaxed(priv->base + IR_DATAH);
+   for (