[SOLVED] A13-OLinuXino + LCD-OLinuXino-7 + mainline kernel

Started by Melange, January 19, 2018, 01:42:09 PM

Previous topic - Next topic

Melange

Hi,

I've successfully built an SD image for the A13 using mainline u-boot (v2018.01) and mainline kernel (4.14.13).

I applied the u-boot settings for the LCD as described in http://linux-sunxi.org/LCD (CONFIG_VIDEO_LCD_MODE and CONFIG_VIDEO_LCD_BL_EN), and u-boot initializes the LCD perfectly.

However, as soon as the kernel gets started, the video mode changes (to 1024x768) and the display content is shifted to the right by about 1-2 cm. It improves a little if I add "video=800x480" to the kernel command line, the screem size is then ok but the display content is still shifted to the right (and also vertically it's a bit glitchy).

I do not find any clear information on this combination of hard- and software, yet my results are so close that I believe it should work (it works when using the sunxi-kernel, of course, but I want to use mainline).

It seems that this section is incomplete: http://linux-sunxi.org/LCD#Mainline_Linux_.28simple-panel.29 - I understand how I should create and populate the "struct drm_display_mode", but then what? I believe it belongs into linux/drivers/gpu/drm/panel/panel-simple.c, and I also have a good idea how to declare the corresponding "struct panel_desc" and to insert it into "struct of_device_id platform_of_match", but how would I continue?

I would greatly appreciate if I could get some guidance.

Cheers,
Christian

MarkusP

Hi Christian,

I can assure you it works since we are using this combination on the product which I'm developing at my work. We are currently migrating from the Sunxi kernel to the mainline one. Our problem is more the network stuff  ;)

Taking the values from the Sunxi Wiki for U-Boot is definitly fine. On the kernel command line we don't have any special parameters set which concern the video output. We made some adjustments to the kernel itself, but I don't know if that was just for network or for display, too. I'd ask my colleague who did this, when he returns from holiday.

Best,
Markus

Melange

Thank you Markus, great news, I'll wait (impatiently) :)

In my case networking works fine with a usb-eth adapter, but support for usb-wlan in my build is still incomplete, I'll let you know once I get it to work.

Melange

It appears I had network issues due to a seeming incompatibility between package network-manager and the kernel's predictable interface naming.

It's a bit odd because this combination works for an usb-eth adapter (tested with a single model) but not for usb-wlan adapters (tested two different kinds).

I switched to classical non-predictable interface names (eth0 and wlan0 etc.) by additionally passing

  • net.ifnames=0
  • biosdevname=0
to the kernel command line, after rebooting all network connections worked flawlessly, I can simply run nmtui from the command line to set up a WPA2 connection.

HolgerK

Hello Christian,

As my colleague mentioned we got the display working. It is only a change in the device tree binding. By default the display tries to use a vga connector. Therefore the kernel tries to find a resolution close to 800x480 and gets 1024x768.
The solution: replace it with your sun5i-display. Here is my diff in device tree (lines could be others)
@@ -103,39 +103,17 @@
};
};

- bridge {
- compatible = "dumb-vga-dac";
+ panel: panel {
+ compatible = "allwinner,sun5i-a13-display-engine";
#address-cells = <1>;
#size-cells = <0>;

- ports {
+ port {
#address-cells = <1>;
#size-cells = <0>;

- port@0 {
- reg = <0>;
-
- vga_bridge_in: endpoint {
- remote-endpoint = <&tcon0_out_vga>;
- };
- };
-
- port@1 {
- reg = <1>;
-
- vga_bridge_out: endpoint {
- remote-endpoint = <&vga_con_in>;
- };
- };
- };
- };
-
- vga {
- compatible = "vga-connector";
-
- port {
- vga_con_in: endpoint {
- remote-endpoint = <&vga_bridge_out>;
+ panel_input: endpoint {
+ remote-endpoint = <&tcon0_out_vga>;
};
};
};
@@ -312,7 +290,7 @@
&tcon0_out {
tcon0_out_vga: endpoint@0 {
reg = <0>;
- remote-endpoint = <&vga_bridge_in>;
+ remote-endpoint = <&panel_input>;
};
};


If you want to add the resistive touch screen you need to add to your tree:

+&rtp {
+ allwinner,ts-attached;
+ #thermal-sensor-cells = <0>;
+ /* sensitive/noisy touch panel */
+ allwinner,tp-sensitive-adjust = <0>;
+ allwinner,filter-type = <3>;
+};
+


I guess you also need to activate the GPADC somewhere in the linux kernel configuration. But I'm not sure what excactly.

Melange

Excellent, that is exactly what I was looking for.

It works like a charme, thank you!

Yes, I also have the touchscreen and I will try to add support for it next. I also have the LCD10" but it is clear that it is supported the same way as is the LCD7".

I keep hitting a wall when trying to get a deeper understanding of the device tree. I understand its function and signifcance, but I do not have a good reference for learing more about it. I see exactly what you did in the .dts, and actually I roughly had the same idea but could not put it into practice at all. Can you give me a pointer where I should look for some good reference material? How did you go about it to get it fixed?

I haven't looked yet, do you know if all the GPIOs are working out of the box? Also, have you tried to add the MALI400 drivers to the board?

Anyways, thanks to both of you again for your top-class support.

Cheers!
Christian

Melange

#6
Never mind the GPIOs and the touchscreen, it all works out of the box (I currently have the two kernel configs CONFIG_SUN4I_GPADC and CONFIG_GPIO_AXP209 set to module, but I do not see them loaded, maybe they aren't even neccessary).

I find all inputs under /dev/input/eventX.

The 5 buttons:


$ sudo evtest /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "1c22800.lradc"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 28 (KEY_ENTER)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
    Event code 139 (KEY_MENU)
    Event code 172 (KEY_HOMEPAGE)
Properties:
Testing ... (interrupt to exit)
Event: time 1517489437.981164, type 1 (EV_KEY), code 172 (KEY_HOMEPAGE), value 1
Event: time 1517489437.981164, -------------- SYN_REPORT ------------
Event: time 1517489438.109217, type 1 (EV_KEY), code 172 (KEY_HOMEPAGE), value 0
Event: time 1517489438.109217, -------------- SYN_REPORT ------------
Event: time 1517489438.902403, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1
Event: time 1517489438.902403, -------------- SYN_REPORT ------------
Event: time 1517489439.034605, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
Event: time 1517489439.034605, -------------- SYN_REPORT ------------
Event: time 1517489439.703875, type 1 (EV_KEY), code 139 (KEY_MENU), value 1
Event: time 1517489439.703875, -------------- SYN_REPORT ------------
Event: time 1517489439.848449, type 1 (EV_KEY), code 139 (KEY_MENU), value 0
Event: time 1517489439.848449, -------------- SYN_REPORT ------------
Event: time 1517489440.525963, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
Event: time 1517489440.525963, -------------- SYN_REPORT ------------
Event: time 1517489440.653988, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
Event: time 1517489440.653988, -------------- SYN_REPORT ------------
Event: time 1517489441.244660, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1
Event: time 1517489441.244660, -------------- SYN_REPORT ------------
Event: time 1517489441.401615, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0
Event: time 1517489441.401615, -------------- SYN_REPORT ------------


Touchscreen:

$ sudo evtest /dev/input/event1
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "1c25000.rtp"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value      0
      Min        0
      Max     4095
    Event code 1 (ABS_Y)
      Value      0
      Min        0
      Max     4095
Properties:
Testing ... (interrupt to exit)
Event: time 1517489489.717111, type 3 (EV_ABS), code 0 (ABS_X), value 2091
Event: time 1517489489.717111, type 3 (EV_ABS), code 1 (ABS_Y), value 2825
Event: time 1517489489.717111, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1517489489.717111, -------------- SYN_REPORT ------------
Event: time 1517489489.749882, type 3 (EV_ABS), code 0 (ABS_X), value 2087
Event: time 1517489489.749882, type 3 (EV_ABS), code 1 (ABS_Y), value 2838
Event: time 1517489489.749882, -------------- SYN_REPORT ------------
Event: time 1517489489.790321, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 1517489489.790321, -------------- SYN_REPORT ------------
Event: time 1517489490.345859, type 3 (EV_ABS), code 0 (ABS_X), value 1460
Event: time 1517489490.345859, type 3 (EV_ABS), code 1 (ABS_Y), value 2006
Event: time 1517489490.345859, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1517489490.345859, -------------- SYN_REPORT ------------
Event: time 1517489490.378627, type 3 (EV_ABS), code 0 (ABS_X), value 1456
Event: time 1517489490.378627, type 3 (EV_ABS), code 1 (ABS_Y), value 1998
Event: time 1517489490.378627, -------------- SYN_REPORT ------------
Event: time 1517489490.411401, type 3 (EV_ABS), code 0 (ABS_X), value 1462
Event: time 1517489490.411401, type 3 (EV_ABS), code 1 (ABS_Y), value 2013
Event: time 1517489490.411401, -------------- SYN_REPORT ------------
Event: time 1517489490.427253, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 1517489490.427253, -------------- SYN_REPORT ------------
Event: time 1517489491.257228, type 3 (EV_ABS), code 0 (ABS_X), value 1610
Event: time 1517489491.257228, type 3 (EV_ABS), code 1 (ABS_Y), value 2189
Event: time 1517489491.257228, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1


Power button (slightly pointless as it is, would need to be rededicated to some user function):

$ sudo evtest /dev/input/event2
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "axp20x-pek"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 116 (KEY_POWER)
Properties:
Testing ... (interrupt to exit)


Christian

HolgerK

Considering the Devicetree. It took me several days to figure out how this works. The solution came after a log to debugging output placed inside the kernel. I found that the kernal loaded a resolution of 1024x768 by default, since it is close to 800x480 requested. The resolution somehow came from a vga adapter.
Here I got the idea to have a closer look on the device tree, found a vga adpater and just replaced it with the sunxi version.

Basically it was a lot of trying and coping examples from the kernel documentation.

codefrog

I've been also building a mainline image for A13 (4.9.22 based on CLFS.org) and it's working!
But - I need ALSA to work - but it doesn't see the soundcard.
During bootup I get this message:

[    1.364838] ALSA device list:
[    1.367799]   No soundcards found.

Is sound working for you? Do I need kernel config options, modules, external drivers, or what?
Thanks

Melange

Quote from: codefrog on February 13, 2018, 07:18:12 PM
I've been also building a mainline image for A13 (4.9.22 based on CLFS.org) and it's working!
But - I need ALSA to work - but it doesn't see the soundcard.
During bootup I get this message:

[    1.364838] ALSA device list:
[    1.367799]   No soundcards found.

Is sound working for you? Do I need kernel config options, modules, external drivers, or what?
Thanks

The sound device (called "codec") is correctly declared in the device tree but disabled by default in Kernel 4.15. It will be activated by default in the 4.16 kernel, see here: http://linux-sunxi.org/Linux_mainlining_effort#Merged_into_4.16

If you activate it you'll have to run alsamixer and:
- unmute Power Amplifier DAC Playback Switch (you toggle mute/unmute by pressing 'm'),
- unmute Power Amplifier Mute Switch and
- pull up Power Amplifier Volume (I set it to -20db IIRC)

The settings will be saved permanently by alsamixer in /var/lib/alsa/asound.state.

I just saw that 4.16-rc1 has been released, here is the new device tree with activated sound;

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/sun5i-a13-olinuxino.dts?h=v4.16-rc1

Here's my bootlog:

[    1.889114] ALSA device list:
[    1.894912]   #0: sun4i-codec


Christian

codefrog

Awesome thanks to hear back. Your clues about the mixer and amp will be helpful.
I had reached the 4.16-rc1 kernel solution myself in the last day or two. Great timing!

Now I'm on to the next step: looking at the OpenGL instructions from
https://bootlin.com/blog/mali-opengl-support-on-allwinner-platforms-with-mainline-linux/

...and scratching my head about generating a sun5i-a13-olinuxino.dtb that has the mali device listed.

If anybody out there has made OpenGL ES work on mainline a13 olinuxino, could you post the DTS / DTB?