avafinger / orangepi-h6-ubuntu-base-minimal

Mainline kernel 5.1 5.2 5.3 5.4 H6 (Orange Pi One Plus)
19 stars 5 forks source link

Adding IR receiver ? #2

Closed clementperon closed 5 years ago

clementperon commented 5 years ago

Hi @avafinger,

Could you try to add the IR receiver on the OrangePi H6 please.

In the H6.dtsi https://github.com/clementperon/linux/commit/ad77a6818e7cc74cf4c7c99dd074466d5abc1a21

and in the dts. https://github.com/clementperon/linux/blob/beelink_gs1/arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts#L108

You should also enable SUNXI_IR in the Kernel

Thanks,

avafinger commented 5 years ago

@clementperon Thanks for mentioning it. I am not sure there is support for SUNXI_IR in mainline 5.1-rc3 but I will take a look at your kernel and see what I can do. BTW, Do you have the "reboot" working on your beelink-gs1?

avafinger commented 5 years ago

@clementperon Ooos, i see it now, it is IR_SUNXI in 5.1... will try it.

clementperon commented 5 years ago

No reboot is not ok for me :(.

Welcome to Beelink GS1
buildroot login: Stopping dropbear sshd: OK
Stopping network: [  686.297639] dwmac-sun8i 5020000.ethernet eth0: Link is Down
OK
Saving random seed... done.
Stopping klogd: OK
Stopping syslogd: OK
umount: devpts busy - remounted read-only
umount: devtmpfs busy - remounted read-only
[  686.457409] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
Sent SIGKILL to all processes
Requesting system reboot
[  688.469175] kvm: exiting hardware virtualization
[  688.501422] reboot: Restarting system
***** STUCK HERE *****
clementperon commented 5 years ago

maybe the wdog ? let's speak about this on armbian : https://forum.armbian.com/topic/9833-h6-famous-reboot-problem/?page=2

avafinger commented 5 years ago

IR is enabled, but i am not able to do a real test.

[    4.301760] Registered IR keymap rc-empty
[    4.302617] rc rc0: sunxi-ir as /devices/platform/soc/7040000.ir/rc/rc0
[    4.302761] input: sunxi-ir as /devices/platform/soc/7040000.ir/rc/rc0/input5
[    4.302995] rc rc0: lirc_dev: driver sunxi-ir registered at minor = 0, raw IR receiver, no transmitter
[    4.305507] sunxi-ir 7040000.ir: initialized sunXi IR driver
[    4.339849] sunxi_cedrus: module is from the staging directory, the quality is unknown, you have been warned.

I tried to enable sound but got this:

[    0.764594]   No soundcards found.
[    4.915463] asoc-simple-card sound: i2s-hifi <-> 5091000.i2s mapping o
Module                  Size  Used by
fuse                   98304  3
zram                   24576  4
snd_soc_hdmi_codec     16384  1
dw_hdmi_cec            16384  0
dw_hdmi_i2s_audio      16384  0
sun8i_drm_hdmi         24576  0
sunxi_cedrus           32768  0
crct10dif_ce           16384  1
dw_hdmi                28672  2 sun8i_drm_hdmi,dw_hdmi_i2s_audio
snd_soc_simple_card    20480  0
sunxi_cir              16384  0
snd_soc_simple_card_utils    16384  1 snd_soc_simple_card
cec                    49152  2 dw_hdmi_cec,dw_hdmi
rc_core                32768  2 sunxi_cir
videobuf2_dma_contig    20480  1 sunxi_cedrus
videobuf2_memops       16384  1 videobuf2_dma_contig
v4l2_mem2mem           20480  1 sunxi_cedrus
videobuf2_v4l2         24576  2 sunxi_cedrus,v4l2_mem2mem
videobuf2_common       49152  3 sunxi_cedrus,videobuf2_v4l2,v4l2_mem2mem
videodev              192512  4 sunxi_cedrus,videobuf2_v4l2,videobuf2_common,v4l2_mem2mem
sun4i_drm              20480  2
sun4i_frontend         16384  1 sun4i_drm
media                  32768  5 sunxi_cedrus,videodev,videobuf2_v4l2,videobuf2_common,v4l2_mem2mem
sun4i_tcon             28672  1 sun4i_drm
sun8i_tcon_top         16384  4 sun8i_drm_hdmi,sun4i_tcon,sun4i_drm
sun8i_mixer            40960  0
ip_tables              32768  0
x_tables               28672  1 ip_tables
ipv6                  360448  38
clementperon commented 5 years ago

Jernejsk is working on it. https://github.com/jernejsk/linux-1/commits/h6_i2s

Upstream will come really soon...

avafinger commented 5 years ago

allwinner-hdmi sound kind of works... There is sound output but "wrong frequency?". The annoying thing is that hdmi randomly gets the wrong video modeset and it is not the readout EDID issue. Let-s see what happens next...

clementperon commented 5 years ago

There is also a jerneskj branch for Edid/CEC issue.

avafinger commented 5 years ago

I applied all jernej's fix, Enabled the following:

https://github.com/avafinger/orangepi-h6-ubuntu-base-minimal/releases/tag/v1.6 I would like to test cedrus and mali, do you have any suggestion to build kodi to check if is working?

clementperon commented 5 years ago

I think I will go for testing a player + then use a kodi add-on (i have a little knowledge about Kodi)

Check this (still jernejsk ;) ) https://github.com/jernejsk/LibreELEC.tv/commit/5906238eba8ee923fd337e550f7bf0beccddcf5e

clementperon commented 5 years ago

Using the R_WDOG in ATF instead of WDOG fix the reboot issue for me.

But I can't make the IR works, the device is probed but can't receive any input from an IR remote.

avafinger commented 5 years ago

Thanks for the info about the reboot issue, will rebuild with your patch.

I spent a whole night trying to trim the hdmi-sound, i got a better sound output but far from perfect compared to what jernej described quite good on his side. At least i could barely understand "Front_Center" with aplay test.

So i went further and applied all hdmi sound and cec patches from jmc (hdmi and cec) but things went downhill. I am doing all things manually a not using git, what a waste of time.... I have to start again from rc2.

Regarding IR, maybe could be related to IR protocol?

avafinger commented 5 years ago

Here is my DT if you would like to review or improve it. h6-opi-one-plus.tar.gz

avafinger commented 5 years ago

@clementperon I think you would like to know. Today I tested your r_WDOC patch and it does the reboot fine, however, the next boot put Opi1+ in a stand by trying to read something, possibly my randomly EDID read error. I will try to investigate. Maybe you use a newer u-boot than mine.

avafinger commented 5 years ago

I compiled all IR protocols in RC4, maybe you should load all and check it it works:

[  524.746051] IR NEC protocol handler initialized
[  590.849977] IR RC6 protocol handler initialized
[  595.140805] IR RC5(x/sz) protocol handler initialized
[  650.204793] IR SANYO protocol handler initialized
clementperon commented 5 years ago

Yes i have load the protocol decoder but nothing seems detected at the low level stage.

avafinger commented 5 years ago

I can see you have:

compatible = "allwinner,sun50i-a64-ir",
             "allwinner,sun5i-a13-ir";

And have:

compatible = "allwinner,sun5i-a13-ir";

avafinger commented 5 years ago

FYI, tested IR with PL9 on BSP and it works using LG TV controller. tested compatible = "allwinner,sun4i-a10-ir"; and compatible = "allwinner,sun5i-a13-ir"; and does not work. I have not touched IR code on mainline 5.1.y...

clementperon commented 5 years ago

So A10 is working but not a13 ?

avafinger commented 5 years ago

BSP 3.x works only.

clementperon commented 5 years ago

Ok thanks

clementperon commented 5 years ago

If you have devmem can you read these adresses ? 0x7040000 0x7040010 0x704002C 0x7040030 0x7040034

avafinger commented 5 years ago

I nee to build this devmem for BSP, where i find the code?

clementperon commented 5 years ago

https://bootlin.com/pub/mirror/devmem2.c

clementperon commented 5 years ago

If you are using buildroot the package is already present

avafinger commented 5 years ago

Sorry, it is BSP 4.9 and there is no /dev/mem available even with CONFIG_DEMEM=y defined. I need to dig a bit further.

avafinger commented 5 years ago

Recompiled BSP kernel:

0x7040000 => 0x73 0x7040010 => 0x04 0x704002C => bus error 0x7040030 => 0x00 0x7040034 => bus error

clementperon commented 5 years ago

Thanks a lot ! bus error is strange :/ did you try several times ? The important one is 0x7040034

Maybe you try access in 8bits instead of 32bits

If you use devmem v1 you should do something like: devmem w ADDR

avafinger commented 5 years ago

I used devmem2.c you pointed. I tried only once in each address.

Several times: ./dev/mem2 0x7040034 give bus error.

I will try peekpoke.

avafinger commented 5 years ago

peekpoke seems to get better results anytime:

0x7040000 => 0x73 0x7040010 => 0x04 0x704002C => 0x4f 0x7040030 => 0x00 0x7040034 => 0x43

avafinger commented 5 years ago

just in time, correction:

0x704002C => ox13 and not 0x4f

avafinger commented 5 years ago

Do you want to read a byte or a word?

avafinger commented 5 years ago

word

0x7040034 => 0x100543

avafinger commented 5 years ago

I used you u-boot and now i have hdmi-sound working quite fine. Used you ATF patch but the reboot loses ethernet or some times waits for the ethernet which lost PHY.

What could possibly cause this, any idea?

clementperon commented 5 years ago

Yes i would like to have word for all these registers, thanks.

There has been a patch merged recently. https://github.com/clementperon/u-boot/commit/1feed358ed15d795929cd6618b2f450719dbe416

For the ethernet I don't know.

avafinger commented 5 years ago

Regarding ethernet after reboot, test showed that:

[ 4.388248] platform 5020000.ethernet eth0: device MAC address c6:70:90:27:15:44 [ 4.388263] platform 5020000.ethernet eth0: Could not attach to PHY [ 4.394739] platform 5020000.ethernet eth0: stmmac_open: Cannot attach to PHY (error: -19)


* Subsequent reboot works as expected
avafinger commented 5 years ago

I changed the timeout to 200ms (from 100 ms) but did not help.

avafinger commented 5 years ago

@clementperon Here is results (word) by peekpoke in the following order:

0x7040000 0x7040010 0x704002C 0x7040030 0x7040034

results: 0x73 0x4 0x1313 0x0 0x100543

clementperon commented 5 years ago

Thanks a lot, will have a look at it.

avafinger commented 5 years ago

@clementperon Any news on this? I have seen there is a property "clock-frequency" , would that be the case here? What is the standard frequency for a common TV controller? I just tried the A64 IR and have the same behavior.

clementperon commented 5 years ago

OK THAAANKSS ! Was searching a diff between A64 and H6 (Considering A64 working was a bad idea) I'm not an expert with the clock in the kernel. But this should be the frequency of the module clk. The driver is expecting something at 8MHz. I will check the diff between A64 and A13 and see if there a new param to configure.

avafinger commented 5 years ago

clock-frequency : IR Receiver clock frequency, in Hertz. Defaults to 8 MHz

I have seen something like: clock-frequency = <3000000>;

I don't know which frequency should be or if that is the case. My try was on kernel 4.20 on A64, just because it is known to work or at least no one complained... :)

clementperon commented 5 years ago

Yes on the sun8i-a83t-bananapi-m3.dts

But there is no explanation -_-

avafinger commented 5 years ago

38kHz modulated IR data is the most common

clementperon commented 5 years ago

This is the base_clock of the IP, then this clock is divided by 64 to have samples_clk. Then this samples are processed by ir_decoder.

clementperon commented 5 years ago

I think the issue here is the base_clock is linked to the 24M_clk and not the bus_clk

clementperon commented 5 years ago
                r_ir: ir@1f02000 {
                        compatible = "allwinner,sun50i-a64-ir",
                                     "allwinner,sun5i-a13-ir";
                        reg = <0x01f02000 0x400>;
                        clocks = <&osc24M>, <&r_ccu CLK_IR>;
                        clock-names = "apb", "ir";
                        resets = <&r_ccu RST_APB0_IR>;
                        interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&r_ir_rx_pin>;
                        status = "disabled";
                };
avafinger commented 5 years ago

I will try...

clementperon commented 5 years ago

The guy who post the patch for A64 should work ..

https://patchwork.kernel.org/patch/10772129/

clementperon commented 5 years ago

@avafinger Ok i found the error -_-.

                r_ir: ir@7040000 {
                                compatible = "allwinner,sun50i-a64-ir",
                                             "allwinner,sun5i-a13-ir";
                                reg = <0x07040000 0x400>;
                                interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&r_ccu CLK_R_APB1_IR>,
                                         <&r_ccu CLK_IR>;
                                clock-names = "apb", "ir";
                                resets = <&r_ccu RST_R_APB1_IR>;
                                pinctrl-names = "default";
                                pinctrl-0 = <&r_ir_rx_pin>;
                                status = "disabled";
                };