A2109 Kernel Experiments

Discussion in 'Lenovo IdeaTab A2109 Development' started by PJBrs, Nov 27, 2015.

  1. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    I'm experimenting with the kernel for Lenovo IdeaTab A2109. Here I'm documenting what I'm doing so that others who'd like to do so might join in.

    The kernel sources supplied by Lenovo are one big tarball without any git history and a lot of confusing additions. I succeeded in turning this big blob into a small set of separate patches that apply to a specific commit in Nvidia's kernel repo. This commit is part of the branch l4t/l4t-r16-r2. This work I've uploaded to a specific kernel branch in my own repo, named A2109-l4t-clean.

    I applied my patches to the following commit:
    Code:
    commit 92f2d2099e3411dfa1966e8ead58dc5654f3124c
    Author: Nikesh Oswal <noswal@nvidia.com>
    Date:   Tue Aug 28 19:51:04 2012 +0530
    
        enterprise pinmux: set the pinmux for audio ports
      
        Bug: 1039342
      
        Change-Id: Ic1f0e9fa8c8d9e69b7fb9cd35d2cbbf578c579e5
        Signed-off-by: Nikesh Oswal <noswal@nvidia.com>
        Reviewed-on: http://git-master/r/127868
        Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
        Reviewed-by: Scott Peterson <speterson@nvidia.com>
    
    Separate patches can be found here:
    b2b7383 Add tegra camera drivers mt9m114 and s5k5cag
    f240d22 Add ft5x06 touchscreen driver
    a17df64 Add Solteam JSA1127 Ambient Light Sensor Driver from Lenovo sources
    f238e38 Add driver for LIS3DH Accelerometer of ST Microelectronics
    c8a6793 Fix a few permissions
    ea0743b Add support for batteries with BQ27541 (I2C/HDQ) chips
    706cfec Add gpio drivers for power button and Gensor rotation lock switch
    b52503b Add changes in kai board files from Lenovo for A2109
    1b59410 Enable the inclusion of tiload kernel driver
    12be434 Switch to Lenovo's driver and codec for aic326x

    To make the kernel, checkout my own branch and do the following to produce a working kernel config:
    Code:
    make tegra_kai_android_defconfig
    
    I have several challenges:
    • Switch from Lenovo's driver for aic326x to the one in the l4t/l4t-r16-r2 branch by Nvidia
    • Rebase my patches so that they produce a working kernel on top of the l4t/l4t-r16-r2 branch
    • Rebase my patches so that they produce a working kernel on top of an Nvidia 3.4 branch
    Currently, a "git rebase l4t/l4t-r16-r2" produces a kernel that boots, runs very shortly with many graphic artifacts, and then hard hangs. I'm trying to git bisect until I find the offending commit.

    I really hope that other people want to join me. I'll either succeed or fail, but I first want to try this, before moving to lollipop-5.1. I hope people would like to join me!
     
    • Like Like x 2
  2. jam97

    jam97 Senior Member

    Joined:
    Mar 26, 2013
    Messages:
    71
    Likes Received:
    11
    Trophy Points:
    180
    Great news, thank you.

    Sent from my SPH-L720 using Tapatalk
     
  3. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    Thanks! Hope it'll get us somewhere :)

    If anyone would like to test some future experiments, let me know, and post the contents of
    Code:
    /proc/board_version
    
    My tablets both say D00.
     
  4. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    Finished my experiment, my latest kernel branch is here, based on tegra-l4t-r16-16.5. I reverted four commits, and that made it all work.

    Next step will be that I add the patches that I used in kitkat to fix wifi-direct, and copy some more from grouper lollipop, to make a kernel that is a perfect preparation for both lollipop and perhaps even going from 3.1 to 3.4.

    Incidentally, this branch also contains a V4L2 version of the tegra camera driver, so, should the need arise, we might be able to copy somebody else's V4L2 camera HAL and make it work on our tablet.
     
    • Like Like x 1
  5. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    Not yet finished after all, I stumbled upon an opengl performance regression, so I'm bisecting again. Also, I think I need to address the charger changes from Lenovo as well. In the meantime, I've started working on my device tree for Lollipop.
     
    • Like Like x 2
  6. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    Well, that turned out to be two opengl regressions, but I _think_ I've now bisected out all remaining issues in Nvidia's l4t-16.5 kernel branch. For the record, here's my notes on the reverts I did:

    To prevent tearing:
    Code:
    commit 7df7b716a5f8ba1877a9b2f89da819cba70dc29b
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Sun Dec 13 21:29:35 2015 +0100
    
        Revert "video: tegra: dc: Add timestamp support"
    
        This reverts commit e4e2e776a3d4bf1adf37fc061cfdfb92281f3ace.
    
        Conflicts:
            drivers/video/tegra/dc/dc.c
            drivers/video/tegra/dc/mode.c
    
    The following fixes an opengl performance regression (~ 300 points on an Antutu opengl benchmark):
    Code:
    commit 8f871df23e8dbe17ccf36e4aa1b7c1e7bf37fa29
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Sat Dec 12 21:53:31 2015 +0100
    
        Revert "video: tegra: host: add idle time estimate in 3dfs"
    
        This reverts commit 8aecb2c96834197427737ea4d06700a9eeda532b.
    
    The following two reverts actually revert the same change?!? These reverts fix a complete hang soon after android starts:
    Code:
    commit cefb9b44bb7a537a9396b0612cc864a500eedb2d
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Fri Dec 4 23:07:13 2015 +0100
    
        Revert "media: nvmap: Allow access to videobuf2-dma-nvmap"
    
        This reverts commit d283f029d9b971f93f6f4b0e62d3cacb2571a204.
    
    commit d84befb56b24e702296d5b465105f18047f74627
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Fri Dec 4 21:28:32 2015 +0100
    
        Revert "media: nvmap: Few tweaks in nvmap"
    
        This reverts commit 2fb9cd0d92979598e3aa5319babdbe6be4c6df22.
    
    The following revert is necessary because of a hard-coded filename in one of the EGL blobs:
    Code:
    commit c2ef31636c5eabeb099aab63c2d6edac4df04b6b
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Sun Nov 29 00:16:28 2015 +0100
    
        Revert "ARM: tegra: rename fuse driver"
    
        This reverts commit b0935d3914c6a01349eaacce08d28620e7b78f6f.
    
    The following revert fixes a very early hang (IIRC, before android starts):
    Code:
    commit 6e00c0a104656c7fe36a8ce0f406d28b61a8af9b
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Sun Nov 29 00:16:10 2015 +0100
    
        Revert "arm: tegra: secureos: disable L2 as part of sleep CPU SMC"
    
        This reverts commit 3bdf9371b4e75e3dc9612360ab55924587714155.
    
    Also, I ended up copying Lenovo's changes to the charger, regulator and usb-otg drivers, to fix charger issues:

    2d1d5a1 Adopt Lenovo's version for smb349-charger, and associated changes

    I'm now cherry-picking changes from the grouper kernel branch in preparation for Lollipop, but it might still have some issues...

    Let me know if you're interested in porting my tree to 3.4 :)
     
    Last edited: Dec 14, 2015
  7. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    I finished working on the kernel, adding in many Google patches from the grouper kernel. See here for the git log.

    Next up I'm trying to compile Lollipop. First result--I seem to have issues with my build environment...
     
    • Like Like x 2
  8. joebine

    joebine Senior Member

    Joined:
    Jan 14, 2015
    Messages:
    100
    Likes Received:
    21
    Trophy Points:
    120
    I am here to help but I don't know about programming. These Kernel things, I don't now nothing about that.

    Anyway, If I can help for somethig, I am in.
     
  9. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    If you want to help, please join the compiling lollipop thread, I've put up an initial build for testing. Do you have any programming skills? I hardly do, unfortunately...
     
  10. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    I've picked up some kernel work. I overwrote my previous branch with a new one, with several additional patches that simplify the a2109 board files, so that they may be more easy to port to 3.4 (I included all previous security fixes from my lollipop branch):

    Code:
    commit 58d670b6e23be76dabf97379940cd1ba677ae93c
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Sat May 28 13:57:08 2016 +0200
    
        A2109: Remove function to raise lowest CPU freq when panel on from panel code
    
    Code:
    commit 5a15657bc8e3d8f6ef487e0522ee5bb05040aef4
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Fri May 27 10:21:39 2016 +0200
    
        Remove all CAM_MCLK_EN_GPIO activity from camera init, power on and power off
    
        Calls to set or disable CAM_MCLK_EN_GPIO gave some unnecessary log spam
        and /or stood in the way of removing the last references to
        tegra_gpio_enable and tegra_gpio_disable.
    
    Code:
    commit 85377ab37bfed5a5d004e70c301a65b0a2417da5
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Thu May 26 21:00:01 2016 +0200
    
        Redo arm: tegra: kai: Fix panel power on/off sequence
    
        This tries to change to power on and power off sequence of the panel
        to reflect changes to the original kai panel configuration.
    
        The original commit:
            commit 81a8d469a7e9d70d0a2cc0345ddf509038bb620a
            Author: Ken Chang <kenc@nvidia.com>
            Date:   Tue May 15 18:02:04 2012 +0800
    
            arm: tegra: kai: Fix panel power on/off sequence
    
            Panel power on/off sequence should meet the panel spec as below.
    
            power on:
            1. EN_VDD_PNL
            2. PCLK
            3. LVDS_EN
            4. LCD_BL_PWN
    
            power off:
            1. LCD_BL_PWN
            2. LVDS_EN
            3. PCLK
            4. EN_VDD_PNL
    
            Pixel clock on/off is controlled by dc driver, we need to separate the
            setting of panel enable/disable into two parts. The first, i.e., before
            pclk on/off, is done in kai_panel_enable()/kai_panel_prepoweroff().
            And the second part, i.e., after pclk on/off, is done in
            kai_panel_postpoweron()/kai_panel_disable().
    
            bug 976081
    
            Signed-off-by: Ken Chang <kenc@nvidia.com>
            Reviewed-on: http://git-master/r/102555
            Reviewed-by: Artiste Hsu <chhsu@nvidia.com>
            Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
            (cherry picked from commit 8149532e20729c359eb1680297f19a8f46343054)
    
            Change-Id: Ifc0d60c2caabf60f4186179e64756a4caabf9af6
            Reviewed-on: http://git-master/r/110297
            Tested-by: Ken Chang <kenc@nvidia.com>
            Reviewed-by: Automatic_Commit_Validation_User
            Reviewed-by: Artiste Hsu <chhsu@nvidia.com>
            Reviewed-by: Jon Mayo <jmayo@nvidia.com>
    
    Code:
    commit 2aaa74208a2a543c5ed94fdf459775e8392ce0c0
    Author: PJBrs <pjbrs@floorenpj.xs4all.nl>
    Date:   Thu May 26 20:55:44 2016 +0200
    
        Redo ARM: tegra: kai: Remove tegra_gpio_enable/disable
    
        This basically is redoing an older commit.
    
        Original commit:
    
            commit 430c036f68ad783b332f8eb6c679862d795a7d30
            Author: Ashwini Ghuge <aghuge@nvidia.com>
            Date:   Wed May 16 16:47:53 2012 +0530
    
            ARM: tegra: kai: Remove tegra_gpio_enable/disable
    
            Removing tegra_gpio_enable and disable calls
            from board files as they are supported thorugh
            set direction calls in the driver
    
            Bug 984439
    
            Change-Id: I4ec51c8eb68c373b7cec6903bf52539cd520b227
            Reviewed-on: http://git-master/r/102813
            Reviewed-by: Simone Willett <swillett@nvidia.com>
            Tested-by: Simone Willett <swillett@nvidia.com>
    
     
    Last edited: May 28, 2016
  11. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    ... I JUST BOOTED KERNEL 3.4!!!!!:cool::)

    I mean, I booted it to a level that included /proc/last_kmsg - Then a kernel panic. But still!
     
    Last edited: Jun 6, 2016
    • Like Like x 1
  12. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    I now got as far as booting both CWM and TWRP on kernel 3.4. I don't dare to really do anything with them, but still!!!

    I'm sure that sound as not working and the vibrator doesn't work either. Then again, I see most other device drivers load without problem, touch screen works, etc... :)
     
  13. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    3.4 FIXED EGL!!!!! :p In a sloppy way, I can do better, but hey, I'm booting lollipop right now. Still have a panic when I connect USB, but that doesn't matter too much right now (seems quite fixable anyway). So - AOSP and Marshmallow now are definitely delayed a bit more, now that the prospects of fixing this kernel appear to be so good. Sorry ;)
     
  14. PJBrs

    PJBrs Senior Member Developer

    Joined:
    Dec 29, 2014
    Messages:
    358
    Likes Received:
    290
    Trophy Points:
    225
    WORKING (not tested well)
    • Wifi
    • Light sensor
    • Accellerometer
    • Sound
    • EGL (lots of display artifacts - then again, Antutu 3dRating benchmark never scored so well!!!)
    • Touchscreen
    • Camera (front and back)
    • GPS
    • Bluetooth (I think)
    NOT WORKING
    • Vibrator
    • Some USB related crashes, adb can crash the kernel.

    Yet... WOOOHOOO!!!!!!! Am VERY proud :cool:

    SOURCES

    This will soon need testers!! I'm going to clean up the tree first. Yet, for now -- all drivers that I ported (cameras, sensors, touchscreen, sound) appear to work without issues.
     
    Last edited: Jun 26, 2016
    • Like Like x 1
  15. DBlake

    DBlake Member

    Joined:
    Nov 29, 2013
    Messages:
    88
    Likes Received:
    24
    Trophy Points:
    90
    Location:
    Ithaca, NY USA
    Tablet / Device:
    Lenovo A2109 (kai)
    Imagine if Lenovo didn't just give up on their products after 6 months... We'd be on at least Android 4.3 by now officially. You're doing great work.
     

Share This Page