diff --git a/devices/motorola-surfna/kernel/0001-mobile-nixos-Adds-and-sets-BGRA-as-default.patch b/devices/motorola-surfna/kernel/0001-mobile-nixos-Adds-and-sets-BGRA-as-default.patch new file mode 100644 index 00000000..d3863714 --- /dev/null +++ b/devices/motorola-surfna/kernel/0001-mobile-nixos-Adds-and-sets-BGRA-as-default.patch @@ -0,0 +1,53 @@ +From 2d34c641091e8bff9771db85448165274187ea26 Mon Sep 17 00:00:00 2001 +From: Samuel Dionne-Riel +Date: Sat, 5 Oct 2019 15:06:17 -0400 +Subject: [PATCH] [mobile-nixos]: Adds and sets BGRA as default + +This fixes the issue of Red and Blue channels being mixed up from the +expected. +--- + drivers/video/fbdev/msm/mdss_fb.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +diff --git a/drivers/video/fbdev/msm/mdss_fb.c b/drivers/video/fbdev/msm/mdss_fb.c +index e0b5ad5b110e..94515e9d26ab 100644 +--- a/drivers/video/fbdev/msm/mdss_fb.c ++++ b/drivers/video/fbdev/msm/mdss_fb.c +@@ -1297,7 +1297,7 @@ static int mdss_fb_probe(struct platform_device *pdev) + + mfd->bl_scale = 1024; + mfd->ad_bl_level = 0; +- mfd->fb_imgType = MDP_RGBA_8888; ++ mfd->fb_imgType = MDP_BGRA_8888; + mfd->calib_mode_bl = 0; + mfd->unset_bl_level = U32_MAX; + mfd->bl_extn_level = -1; +@@ -2691,6 +2691,25 @@ static int mdss_fb_register(struct msm_fb_data_type *mfd) + bpp = 4; + break; + ++ case MDP_BGRA_8888: ++ fix->type = FB_TYPE_PACKED_PIXELS; ++ fix->xpanstep = 1; ++ fix->ypanstep = 1; ++ var->vmode = FB_VMODE_NONINTERLACED; ++ var->blue.offset = 0; ++ var->green.offset = 8; ++ var->red.offset = 16; ++ var->blue.length = 8; ++ var->green.length = 8; ++ var->red.length = 8; ++ var->blue.msb_right = 0; ++ var->green.msb_right = 0; ++ var->red.msb_right = 0; ++ var->transp.offset = 24; ++ var->transp.length = 8; ++ bpp = 4; ++ break; ++ + case MDP_YCRYCB_H2V1: + fix->type = FB_TYPE_INTERLEAVED_PLANES; + fix->xpanstep = 2; +-- +2.23.0 + diff --git a/devices/motorola-surfna/kernel/0001-mobile-nixos-Workaround-selected-processor-does-not-.patch b/devices/motorola-surfna/kernel/0001-mobile-nixos-Workaround-selected-processor-does-not-.patch new file mode 100644 index 00000000..3ce1afa5 --- /dev/null +++ b/devices/motorola-surfna/kernel/0001-mobile-nixos-Workaround-selected-processor-does-not-.patch @@ -0,0 +1,29 @@ +From 834fd7cb1eac09da44ac79d939c41eac54a4da93 Mon Sep 17 00:00:00 2001 +From: Samuel Dionne-Riel +Date: Sun, 29 Sep 2019 14:42:50 -0400 +Subject: [PATCH] [mobile-nixos]: Workaround "selected processor does not + support" + +See: + + * https://github.com/NixOS/nixpkgs/issues/64916 +--- + arch/arm64/crypto/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile +index 28a71246e0a3..3d5a44121565 100644 +--- a/arch/arm64/crypto/Makefile ++++ b/arch/arm64/crypto/Makefile +@@ -42,7 +42,7 @@ CFLAGS_aes-glue-ce.o := -DUSE_V8_CRYPTO_EXTENSIONS + + obj-$(CONFIG_CRYPTO_CRC32_ARM64) += crc32-arm64.o + +-CFLAGS_crc32-arm64.o := -mcpu=generic+crc ++CFLAGS_crc32-arm64.o := -march=armv8-a+crc + + $(obj)/aes-glue-%.o: $(src)/aes-glue.c FORCE + $(call if_changed_rule,cc_o_c) +-- +2.23.0 + diff --git a/devices/motorola-surfna/kernel/0003-arch-arm64-Add-config-option-to-fix-bootloader-cmdli.patch b/devices/motorola-surfna/kernel/0003-arch-arm64-Add-config-option-to-fix-bootloader-cmdli.patch new file mode 100644 index 00000000..d3282465 --- /dev/null +++ b/devices/motorola-surfna/kernel/0003-arch-arm64-Add-config-option-to-fix-bootloader-cmdli.patch @@ -0,0 +1,79 @@ +From 5ce717535e07b8904a598dc93bc362abfe7453e6 Mon Sep 17 00:00:00 2001 +From: Alexey Min +Date: Wed, 11 Sep 2019 21:51:40 +0300 +Subject: [PATCH 3/3] arch: arm64: Add config option to fix bootloader cmdline + args + +Android bootloader passes some arguments in kernel command +line, that make booting custom OSes harder: + + * skip_initramfs + * root=PARTUUID=... + * init=/init + +Those parameters override default boot partition to hardcoded, +set init binary to /init, disable booting from initramfs. + +If enabled, those parameters will be erased from bootloader's +command line, and custom OS can boot the way it likes. +--- + arch/arm64/Kconfig | 17 +++++++++++++++++ + drivers/of/fdt.c | 14 ++++++++++++++ + 2 files changed, 31 insertions(+) + +diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig +index 2829edba6aa5..bd9f05f83c7e 100644 +--- a/arch/arm64/Kconfig ++++ b/arch/arm64/Kconfig +@@ -1125,6 +1125,23 @@ config CMDLINE_FORCE + command-line options your boot loader passes to the kernel. + endchoice + ++config CMDLINE_DROP_DANGEROUS_ANDROID_OPTIONS ++ bool "Drop certain dangerous options from cmdline" ++ default n ++ help ++ Android bootloader passes some arguments in kernel command ++ line, that make booting custom OSes harder: ++ ++ * skip_initramfs ++ * root=PARTUUID=... ++ * init=/init ++ ++ Those parameters override default boot partition to hardcoded, ++ set init binary to /init, disable booting from initramfs. ++ ++ If enabled, those parameters will be erased from bootloader's ++ command line, and custom OS can boot the way it likes. ++ + config EFI_STUB + bool + +diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c +index ca175710c4c8..fd8257589648 100644 +--- a/drivers/of/fdt.c ++++ b/drivers/of/fdt.c +@@ -1012,6 +1012,20 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, + + pr_debug("Command line is: %s\n", (char*)data); + ++#ifdef CONFIG_CMDLINE_DROP_DANGEROUS_ANDROID_OPTIONS ++ pr_err("Replacing dangerous cmdline options..."); ++ cmdline = strstr((const char *)data, "skip_initramfs"); ++ if (cmdline) ++ *cmdline = '_'; ++ cmdline = strstr((const char *)data, "root="); ++ if (cmdline) ++ *cmdline = '_'; ++ cmdline = strstr((const char *)data, "init="); ++ if (cmdline) ++ *cmdline = '_'; ++ pr_err("Command line now is: %s\n", (char*)data); ++#endif ++ + /* break now */ + return 1; + } +-- +2.21.0 + diff --git a/devices/motorola-surfna/kernel/default.nix b/devices/motorola-surfna/kernel/default.nix new file mode 100644 index 00000000..88ef0380 --- /dev/null +++ b/devices/motorola-surfna/kernel/default.nix @@ -0,0 +1,26 @@ +{ + mobile-nixos +, fetchFromGitHub +}: + +mobile-nixos.kernel-builder-gcc49 { + version = "4.9.112"; + configfile = ./config.aarch64; + + src = fetchFromGitHub { + owner = "mobile-nixos"; + repo = "linux"; + rev = "f94feb0d419573e219bb15e9f4a7c839e1f1543a"; # mobile-nixos/motorola-surfna + sha256 = "09bn08g0qcsp0b134lsd0kvcx7mlcs2cckix7bqq23m6bzrnxy54"; + }; + + patches = [ + ./0001-mobile-nixos-Workaround-selected-processor-does-not-.patch + ./0001-mobile-nixos-Adds-and-sets-BGRA-as-default.patch + ./0003-arch-arm64-Add-config-option-to-fix-bootloader-cmdli.patch + ]; + + enableRemovingWerror = true; + isImageGzDtb = true; + isModular = false; +}