Re: [linux-sunxi] [PATCH v2] sunxi: Add support for consumer infrared devices

2014-04-29 Thread Александр Берсенев
Thank you for comments, fixes will be in the next version of the patch.

About:
#ifdef CONFIG_ARCH_SUN5I 
#define IR_FIFO_SIZE(64)/* 64Bytes */ 
#else 
#define IR_FIFO_SIZE(16)/* 16Bytes */ 
#endif 

In sun5i datasheet 
at 
http://dl.linux-sunxi.org/A13/A13%20User%20Manual%20-%20v1.2%20%282013-01-08%29.pdf
 
said that sun5i and sun4i has 16 bytes fifo each and sun7i has 64 bytes 
fifo. All sunxi'es should work well with 16 bytes fifo, but 64 bytes fifos 
should be little faster on sun7i.

I hit some unexpected behavior of rc-core logic - if I press buttons very 
quickly(about 10 times per seconds) the latest pressing not shows until I 
press any another button. If I set ir-rc-timeout to very low value this 
problem disappears. I set it to 100 msec like in other ir-drivers instead 
120, but this not fixes problem fully. May be it is because I don't use 
keys mapping and keyup events not generated.  

Also there is a small memory leak during module loading/unloading.

вторник, 29 апреля 2014 г., 10:56:32 UTC+6 пользователь Priit Laes написал:

 Ühel kenal päeval, E, 28.04.2014 kell 12:57, kirjutas Александр 
 Берсенев: 
  This patch introduces Consumer IR(CIR) support for sunxi boards. 
  
  
  This is based on Alexsey Shestacov's work based on the original 
  driver 
  supplied by Allwinner. 

 You need to also CC people/lists in charge of certian parts of the 
 kernel tree this patch touches. There's get_maintainer.pl under scripts 
 directory in kernel tree. 

  Changes since version 1: 
   - Fix timer memory leaks 
   - Fix race condition when driver unloads while interrupt handler is 
  active 
   - Support Cubieboard 2(need testing) 
  
  
  Signed-off-by: Alexander Bersenev b...@hackerdom.ru javascript: 
  CC: wing...@linux-sunxi.org javascript: 
  
  
  diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt 
  b/Documentation/devicetree/bindings/media/sunxi-ir.txt 
  new file mode 100644 
  index 000..8181efc 
  --- /dev/null 
  +++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt 
  @@ -0,0 +1,21 @@ 
  +Device-Tree bindings for SUNXI IR controller found in sunXi SoC 
  family 
  + 
  +Required properties: 
  +   - compatible: Should be allwinner,sunxi-ir. 
  +   - clocks: First clock should constain SoC gate for IR clock 
  +   second should constain IR feed clock itself. 
 missing before second. 

  +   - interrupts: Should constain IR IRQ number. 
  +   -reg: Should constain IO map address for IR. 
 s/constain/contain 

  + 
  +Optional properties: 
  +   - linux,rc-map-name: Remote control map name. 
  + 
  +Example: 
  + 
  +   ir0: ir@01c21800 { 
  +compatible = allwinner,sunxi-ir; 
  +clocks = apb0_gates 6, ir0_clk; 
  +interrupts = 0 5 1; 
  +reg = 0x01C21800 0x40; 
  +linux,rc-map-name = rc-rc6-mce; 
  +   }; 
  diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
  b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
  index feeff64..01b519c 100644 
  --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
  +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
  @@ -164,6 +164,13 @@ 
reg = 1; 
}; 
}; 
  + 
  + ir0: ir@01c21800 { 
  + pinctrl-names = default; 
  + pinctrl-0 = ir0_pins_a; 
  + gpios = pio 1 4 0; 
  + status = okay; 
  + }; 
}; 

leds { 
  diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
  b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
  index e288562..683090f 100644 
  --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
  +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
  @@ -232,6 +232,13 @@ 
reg = 1; 
}; 
}; 
  + 
  + ir0: ir@01c21800 { 
  + pinctrl-names = default; 
  + pinctrl-0 = ir0_pins_a; 
  + gpios = pio 1 4 0; 
  + status = okay; 
  + }; 
}; 

leds { 
  diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi 
  b/arch/arm/boot/dts/sun7i-a20.dtsi 
  index 0ae2b77..4597731 100644 
  --- a/arch/arm/boot/dts/sun7i-a20.dtsi 
  +++ b/arch/arm/boot/dts/sun7i-a20.dtsi 
  @@ -724,6 +724,19 @@ 
allwinner,drive = 2; 
allwinner,pull = 0; 
}; 
  + 
  + ir0_pins_a: ir0@0 { 
  +allwinner,pins = PB3,PB4; 
  +allwinner,function = ir0; 
  +allwinner,drive = 0; 
  +allwinner,pull = 0; 
  + }; 
  + ir1_pins_a: ir1@0 { 
  +allwinner,pins = PB22,PB23; 
  +allwinner,function = ir1; 
  +allwinner,drive = 0; 
  +allwinner,pull = 0; 
  + }; 
}; 

timer@01c20c00 { 
  @@ -937,5 +950,21 @@ 
#interrupt-cells = 3; 
interrupts = 1 9 0xf04; 
}; 
  + 
  +   ir0: ir@01c21800 { 
  + compatible = allwinner,sunxi-ir; 
  + clocks = apb0_gates 6, ir0_clk; 
  + interrupts = 0 5 4; 
  + reg = 0x01C21800 0x40; 
  + status = disabled; 
  + }; 
  + 
  +   ir1: ir@01c21c00 { 
  + compatible = allwinner,sunxi-ir; 
  + clocks = apb0_gates 7, ir1_clk; 
  + interrupts = 0 6 4; 
  + reg = 0x01C21c00 0x40; 
  + status = disabled; 
  + }; 
}; 
   }; 
  diff --git 

Re: [linux-sunxi] [PATCH v2] sunxi: Add support for consumer infrared devices

2014-04-29 Thread Александр Берсенев
The problem with timeouts is with the 
function ir_raw_event_store_with_filter which automerges samples of same 
type. When the packet ends, there is 21504us space(no pulse) in it and this 
function waits for more data to merge. New data arives only when next 
button pressed on ir remote. Function ir_raw_event_store_with_filter has a 
timeout for waiting, but this timeout checked on each call of this 
function(on each interrupt), if user doesn't press buttons, the 
ir-interrups don't occur. 

среда, 30 апреля 2014 г., 0:42:25 UTC+6 пользователь Александр Берсенев 
написал:

 Thank you for comments, fixes will be in the next version of the patch.

 About:
 #ifdef CONFIG_ARCH_SUN5I 
 #define IR_FIFO_SIZE(64)/* 64Bytes */ 
 #else 
 #define IR_FIFO_SIZE(16)/* 16Bytes */ 
 #endif 

 In sun5i datasheet at 
 http://dl.linux-sunxi.org/A13/A13%20User%20Manual%20-%20v1.2%20%282013-01-08%29.pdfsaid
  that sun5i and sun4i has 16 bytes fifo each and sun7i has 64 bytes 
 fifo. All sunxi'es should work well with 16 bytes fifo, but 64 bytes fifos 
 should be little faster on sun7i.

 I hit some unexpected behavior of rc-core logic - if I press buttons very 
 quickly(about 10 times per seconds) the latest pressing not shows until I 
 press any another button. If I set ir-rc-timeout to very low value this 
 problem disappears. I set it to 100 msec like in other ir-drivers instead 
 120, but this not fixes problem fully. May be it is because I don't use 
 keys mapping and keyup events not generated.  

 Also there is a small memory leak during module loading/unloading.

 вторник, 29 апреля 2014 г., 10:56:32 UTC+6 пользователь Priit Laes написал:

 Ühel kenal päeval, E, 28.04.2014 kell 12:57, kirjutas Александр 
 Берсенев: 
  This patch introduces Consumer IR(CIR) support for sunxi boards. 
  
  
  This is based on Alexsey Shestacov's work based on the original 
  driver 
  supplied by Allwinner. 

 You need to also CC people/lists in charge of certian parts of the 
 kernel tree this patch touches. There's get_maintainer.pl under scripts 
 directory in kernel tree. 

  Changes since version 1: 
   - Fix timer memory leaks 
   - Fix race condition when driver unloads while interrupt handler is 
  active 
   - Support Cubieboard 2(need testing) 
  
  
  Signed-off-by: Alexander Bersenev b...@hackerdom.ru 
  CC: wing...@linux-sunxi.org 
  
  
  diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt 
  b/Documentation/devicetree/bindings/media/sunxi-ir.txt 
  new file mode 100644 
  index 000..8181efc 
  --- /dev/null 
  +++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt 
  @@ -0,0 +1,21 @@ 
  +Device-Tree bindings for SUNXI IR controller found in sunXi SoC 
  family 
  + 
  +Required properties: 
  +   - compatible: Should be allwinner,sunxi-ir. 
  +   - clocks: First clock should constain SoC gate for IR clock 
  +   second should constain IR feed clock itself. 
 missing before second. 

  +   - interrupts: Should constain IR IRQ number. 
  +   -reg: Should constain IO map address for IR. 
 s/constain/contain 

  + 
  +Optional properties: 
  +   - linux,rc-map-name: Remote control map name. 
  + 
  +Example: 
  + 
  +   ir0: ir@01c21800 { 
  +compatible = allwinner,sunxi-ir; 
  +clocks = apb0_gates 6, ir0_clk; 
  +interrupts = 0 5 1; 
  +reg = 0x01C21800 0x40; 
  +linux,rc-map-name = rc-rc6-mce; 
  +   }; 
  diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
  b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
  index feeff64..01b519c 100644 
  --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
  +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
  @@ -164,6 +164,13 @@ 
reg = 1; 
}; 
}; 
  + 
  + ir0: ir@01c21800 { 
  + pinctrl-names = default; 
  + pinctrl-0 = ir0_pins_a; 
  + gpios = pio 1 4 0; 
  + status = okay; 
  + }; 
}; 

leds { 
  diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
  b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
  index e288562..683090f 100644 
  --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
  +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
  @@ -232,6 +232,13 @@ 
reg = 1; 
}; 
}; 
  + 
  + ir0: ir@01c21800 { 
  + pinctrl-names = default; 
  + pinctrl-0 = ir0_pins_a; 
  + gpios = pio 1 4 0; 
  + status = okay; 
  + }; 
}; 

leds { 
  diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi 
  b/arch/arm/boot/dts/sun7i-a20.dtsi 
  index 0ae2b77..4597731 100644 
  --- a/arch/arm/boot/dts/sun7i-a20.dtsi 
  +++ b/arch/arm/boot/dts/sun7i-a20.dtsi 
  @@ -724,6 +724,19 @@ 
allwinner,drive = 2; 
allwinner,pull = 0; 
}; 
  + 
  + ir0_pins_a: ir0@0 { 
  +allwinner,pins = PB3,PB4; 
  +allwinner,function = ir0; 
  +allwinner,drive = 0; 
  +allwinner,pull = 0; 
  + }; 
  + ir1_pins_a: ir1@0 { 
  +allwinner,pins = PB22,PB23; 
  +allwinner,function = ir1; 
  +allwinner,drive = 0; 
  +

Re: [linux-sunxi] [PATCH v2] sunxi: Add support for consumer infrared devices

2014-04-28 Thread Priit Laes
Ühel kenal päeval, E, 28.04.2014 kell 12:57, kirjutas Александр
Берсенев:
 This patch introduces Consumer IR(CIR) support for sunxi boards.
 
 
 This is based on Alexsey Shestacov's work based on the original
 driver 
 supplied by Allwinner. 

You need to also CC people/lists in charge of certian parts of the
kernel tree this patch touches. There's get_maintainer.pl under scripts
directory in kernel tree.

 Changes since version 1: 
  - Fix timer memory leaks 
  - Fix race condition when driver unloads while interrupt handler is
 active
  - Support Cubieboard 2(need testing)
 
 
 Signed-off-by: Alexander Bersenev b...@hackerdom.ru
 CC: wingr...@linux-sunxi.org
 
 
 diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt
 b/Documentation/devicetree/bindings/media/sunxi-ir.txt
 new file mode 100644
 index 000..8181efc
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt
 @@ -0,0 +1,21 @@
 +Device-Tree bindings for SUNXI IR controller found in sunXi SoC
 family
 +
 +Required properties:
 +   - compatible: Should be allwinner,sunxi-ir.
 +   - clocks: First clock should constain SoC gate for IR clock
 +   second should constain IR feed clock itself.
missing before second.

 +   - interrupts: Should constain IR IRQ number.
 +   -reg: Should constain IO map address for IR.
s/constain/contain

 +
 +Optional properties:
 +   - linux,rc-map-name: Remote control map name.
 +
 +Example:
 +
 +   ir0: ir@01c21800 {
 +compatible = allwinner,sunxi-ir;
 +clocks = apb0_gates 6, ir0_clk;
 +interrupts = 0 5 1;
 +reg = 0x01C21800 0x40;
 +linux,rc-map-name = rc-rc6-mce;
 +   };
 diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
 b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
 index feeff64..01b519c 100644
 --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
 +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
 @@ -164,6 +164,13 @@
   reg = 1;
   };
   };
 +
 + ir0: ir@01c21800 {
 + pinctrl-names = default;
 + pinctrl-0 = ir0_pins_a;
 + gpios = pio 1 4 0;
 + status = okay;
 + };
   };
  
   leds {
 diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 index e288562..683090f 100644
 --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 @@ -232,6 +232,13 @@
   reg = 1;
   };
   };
 +
 + ir0: ir@01c21800 {
 + pinctrl-names = default;
 + pinctrl-0 = ir0_pins_a;
 + gpios = pio 1 4 0;
 + status = okay;
 + };
   };
  
   leds {
 diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi
 b/arch/arm/boot/dts/sun7i-a20.dtsi
 index 0ae2b77..4597731 100644
 --- a/arch/arm/boot/dts/sun7i-a20.dtsi
 +++ b/arch/arm/boot/dts/sun7i-a20.dtsi
 @@ -724,6 +724,19 @@
   allwinner,drive = 2;
   allwinner,pull = 0;
   };
 +
 + ir0_pins_a: ir0@0 {
 +allwinner,pins = PB3,PB4;
 +allwinner,function = ir0;
 +allwinner,drive = 0;
 +allwinner,pull = 0;
 + };
 + ir1_pins_a: ir1@0 {
 +allwinner,pins = PB22,PB23;
 +allwinner,function = ir1;
 +allwinner,drive = 0;
 +allwinner,pull = 0;
 + };
   };
  
   timer@01c20c00 {
 @@ -937,5 +950,21 @@
   #interrupt-cells = 3;
   interrupts = 1 9 0xf04;
   };
 +
 +   ir0: ir@01c21800 {
 + compatible = allwinner,sunxi-ir;
 + clocks = apb0_gates 6, ir0_clk;
 + interrupts = 0 5 4;
 + reg = 0x01C21800 0x40;
 + status = disabled;
 + };
 +
 +   ir1: ir@01c21c00 {
 + compatible = allwinner,sunxi-ir;
 + clocks = apb0_gates 7, ir1_clk;
 + interrupts = 0 6 4;
 + reg = 0x01C21c00 0x40;
 + status = disabled;
 + };
   };
  };
 diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
 index 8fbd377..9427fad 100644
 --- a/drivers/media/rc/Kconfig
 +++ b/drivers/media/rc/Kconfig
 @@ -343,4 +343,14 @@ config RC_ST
  
   If you're not sure, select N here.
  
 +config IR_SUNXI
 +tristate SUNXI IR remote control
 +depends on RC_CORE
 +depends on ARCH_SUNXI
 +---help---
 +  Say Y if you want to use sunXi internal IR Controller
 +
 +  To compile this driver as a module, choose M here: the module
 will
 +  be called sunxi-ir.
 +
  endif #RC_DEVICES
 diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
 index f8b54ff..93cdbe9 100644
 --- a/drivers/media/rc/Makefile
 +++ b/drivers/media/rc/Makefile
 @@ -32,4 +32,5 @@ obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
  obj-$(CONFIG_IR_IGUANA) += iguanair.o
  obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
  obj-$(CONFIG_RC_ST) += st_rc.o
 +obj-$(CONFIG_IR_SUNXI) += sunxi-ir.o
  obj-$(CONFIG_IR_IMG) += img-ir/
 diff --git a/drivers/media/rc/sunxi-ir.c b/drivers/media/rc/sunxi-ir.c
 new file mode 100644
 index 000..e1f1ab3
 --- /dev/null
 +++ b/drivers/media/rc/sunxi-ir.c
 @@ -0,0 +1,324 @@
 +/*
 + * Driver for Allwinner sunXi IR controller
 + *
 + * Copyright (C) 2014 Alexsey Shestacov wingr...@linux-sunxi.org
 + *
 + * Based on sun5i-ir.c:
 + * Copyright (C) 2007-2012 Daniel Wang
 + * Allwinner Technology