Skip to content

Conversation

@Jakko3
Copy link

@Jakko3 Jakko3 commented Oct 2, 2024

This pull request adds brightness control and horizontal flip to the msm8916-generated panel samsung-s6e88a0-ams427ap24 of device samsung-serranove. The PR is based on branch wip/msm8916/6.11 but the commits can easily be rebased or cherry-picked.

Within postmarketOS flipping the display is currnetly done in software by kernel cmdline. In case these changes at some point make it to postmarketOS, in the cmdline of deviceinfo samsung-serranove the "video=540x960,reflect_x" needs to be removed.

I'll also try to upstream the panel driver and the devicetree panel snippet. This will take some time, I'll update here. If the driver will be accepted upstream and reaches msm8916-mainline repository, the driver in msm8916-generated would need to be removed.

@Jakko3 Jakko3 force-pushed the serranove_panel_pr_brightness_and_flip branch from d8bdcaf to a8558c2 Compare October 2, 2024 22:19
@Jakko3 Jakko3 force-pushed the serranove_panel_pr_brightness_and_flip branch from a8558c2 to 6afd2cd Compare October 4, 2024 17:45
@Jakko3
Copy link
Author

Jakko3 commented Oct 4, 2024

Adressed the comments above.

config DRM_PANEL_SAMSUNG_S6E88A0_AMS427AP24
tristate "Samsung S6E88A0 AMS427AP24"
default DRM_PANEL_MSM8916_GENERATED
depends on BACKLIGHT_CLASS_DEVICE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of this a bit: It makes sense if it was updating a dedicated driver but with generated one, this file is also generated by linux-panel-driver scripts, so I'm not sure if it can cause conflicts down the line if we regenerate the base drivers... You may notice l-p-d actually never sets the backlight dependency in this file and we just assume one of already-upstream panels or other driver pulls it in.

Would you mind dropping this change?

Alternative course I guess would be if you already prepare an "upstream-ready" dedicated commit with the whole panel driver and a new Kconfig outside of the generated dir, then we can drop it from the generator and apply as it's own thing for you to upstream.

Other than that, the changes look good to me, though I'd appreciate this rebased on top of 6.12-rc1 (which should also include the latest version of the zinitix patch). This would allow me to merge it in and rebase on -rc2 next monday a bit more easily

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind dropping this change?

That's fine. I had a try without it and it works too. Therefore I removed it.

if you already prepare an "upstream-ready"

I'm working on it but for now I'd prefer to stay on top of msm8916-generated.

on top of 6.12-rc1 (which should also include the latest version of the zinitix patch)

Ah, I hadn't noticed the zinitix patch is there as well. I looked at the very last commit like on branch wip/msm8916/6.11 and didn't see it there. Now I realize in branch wip/msm8916/6.12-r1 it's just further down the list.

I rebased the patchset to branch wip/msm8916/6.12-r1.

Unfortunately I first force-pushed and thereafter changed the base in the GitHub GUI. This stopped the build test. I don't know how to trigger it manually .

Jakko3 added 3 commits October 5, 2024 15:32
The tables for brightness to candela, aid and elvss were taken from downstream
kernel file "dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi" [1][2][3].

The gamma table gets generated in "ss_dsi_smart_dimming_S6E88A0_AMS427AP24.c" [4]
with hard-coded starting values. The function smart_dimming_init() [5] goes
through the v{*}_adjustments, generate_gray_scale and gamma_init procedure.
Instead of calculating it manually, it's easier to compile a custom downstream
kernel with SMART_DIMMING_DEBUG enabled and read out dmesg early at boot.

Selection of the values for aid and elvss are again according to downstream
file "dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi" [6][7].

The set of write commands is guided by downstream file "ss_dsi_panel_common.c" [8]
followed by "ss_dsi_panel_S6E88A0_AMS427AP24.c" [9].

The dsi mode flag MIPI_DSI_MODE_VIDEO_NO_HFP prevents screen flickering while
changing the brightness.

- [1] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi#L341-L397
- [2] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi#L214-L254
- [3] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi#L301-L320
- [4] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/ss_dsi_smart_dimming_S6E88A0_AMS427AP24.c
- [5] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/ss_dsi_smart_dimming_S6E88A0_AMS427AP24.c#L1816-L1900
- [6] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi#L256-L268
- [7] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi#L322-L334
- [8] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/ss_dsi_panel_common.c#L1389-L1517
- [9] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/ss_dsi_panel_S6E88A0_AMS427AP24.c#L666-L678

Signed-off-by: Jakob Hauser <[email protected]>
The way of implementing a flip option follows the existing
panel-samsung-s6e8aa0.c [1][2][3].

The value to flip the screen is taken from a downstream kernel panel
file of a simular but older device. The downstream code is rather
confusing. The mipi clock [4] for the panel is 461 MHz and a hardware
read-out of the 0xcb values corresponds to revision R01 [5], although
in non-flipped state. Further up there is a hint [6] basically saying
for revision R01 to change the first word of the 0xcb command from 0x06
to 0x0e, which is actually setting BIT(3) of that word. This causes a
horizontal flip.

- [1] https://github.com/torvalds/linux/blob/v6.11/drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c#L103
- [2] https://github.com/torvalds/linux/blob/v6.11/drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c#L207-L211
- [3] https://github.com/torvalds/linux/blob/v6.11/drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c#L954-L974
- [4] https://github.com/LineageOS/android_kernel_samsung_msm8930-common/blob/lineage-15.1/drivers/video/msm/mipi_samsung_oled_video_qhd_pt-8930.c#L2027-L2028
- [5] https://github.com/LineageOS/android_kernel_samsung_msm8930-common/blob/lineage-15.1/drivers/video/msm/mipi_samsung_oled_video_qhd_pt-8930.c#L137-L151
- [6] https://github.com/LineageOS/android_kernel_samsung_msm8930-common/blob/lineage-15.1/drivers/video/msm/mipi_samsung_oled_video_qhd_pt-8930.c#L66-L74

Signed-off-by: Jakob Hauser <[email protected]>
…l (v3)

v4: Add flip-horizontal;

Signed-off-by: Jakob Hauser <[email protected]>
@Jakko3 Jakko3 force-pushed the serranove_panel_pr_brightness_and_flip branch from 6afd2cd to a6cbf6d Compare October 5, 2024 14:58
@Jakko3 Jakko3 changed the base branch from wip/msm8916/6.11 to wip/msm8916/6.12-rc1 October 5, 2024 15:00
@TravMurav TravMurav merged commit 0c1d4db into msm8916-mainline:wip/msm8916/6.12-rc1 Oct 5, 2024
@TravMurav
Copy link
Member

Merged and squashed, thanks!

@Jakko3 Jakko3 deleted the serranove_panel_pr_brightness_and_flip branch October 5, 2024 23:45
@Jakko3
Copy link
Author

Jakko3 commented Oct 5, 2024

Great, many thanks!

@Jakko3
Copy link
Author

Jakko3 commented Oct 11, 2024

The first patchset for upstreaming the driver is out. Possibly it will take some iterations until it gets accepted. I'll update here.

@Jakko3
Copy link
Author

Jakko3 commented Nov 14, 2024

Patchset v4 was accepted end of October:
https://lore.kernel.org/dri-devel/[email protected]/T/#t

The driver shows up in linux-next since beginning of November:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams427ap24.c?h=next-20241101

It's expected to make it into kernel 6.13-rc1. In msm8916-mainline it would then need to be removed from the msm8916-generated panels.

Next step was submitting the devicetree snippet adding the panel to samsung-serranove. That patch went out today:
https://lore.kernel.org/linux-arm-msm/[email protected]/T/#u

@TravMurav
Copy link
Member

This is amazing to see! I will try to remember to pick up those on monday so we can include them a bit earlier

@Jakko3
Copy link
Author

Jakko3 commented Nov 27, 2024

On the patch for the devicetree snippet there is no progress yet. This definitively won't make it into 6.13-rc1.

Independent from that, whenever that patch gets implemented into msm8916-mainline, there will likely be a small merge conflict because the msm8916-samsung-serranove dts patches "Add display panel" and "Add audio jack detection" change order while they have neighboring changes.

@Jakko3
Copy link
Author

Jakko3 commented Jan 9, 2025

Finally, the samsung-serranove devicetree patch was applied.
https://lore.kernel.org/linux-arm-msm/[email protected]/T/#t

It has been added to the branch "arm64-for-6.14" of linux-arm-msm https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git, thus it should go into mainline 6.14-rc1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants