Browse Source

Merge remote-tracking branch 'upstream/develop' into xap

Nick Brassel 2 years ago
parent
commit
8fa6fd6d64

+ 7 - 6
docs/feature_backlight.md

@@ -40,7 +40,6 @@ Add the following to your `config.h`:
 |`BACKLIGHT_DEFAULT_ON`       |`true`            |Enable backlight upon clearing the EEPROM                                                                        |
 |`BACKLIGHT_DEFAULT_BREATHING`|`false`           |Whether to enable backlight breathing upon clearing the EEPROM                                                   |
 |`BACKLIGHT_DEFAULT_LEVEL`    |`BACKLIGHT_LEVELS`|The default backlight level to use upon clearing the EEPROM                                                      |
-|`BACKLIGHT_PWM_PERIOD`       |2048Hz            |Defaults to `BACKLIGHT_PWM_COUNTER_FREQUENCY / 2048`, which results in a PWM frequency of 2048Hz.                |
 
 Unless you are designing your own keyboard, you generally should not need to change the `BACKLIGHT_PIN` or `BACKLIGHT_ON_STATE`.
 
@@ -174,11 +173,13 @@ Depending on the ChibiOS board configuration, you may need to enable PWM at the
 
 The following `#define`s apply only to the `pwm` driver:
 
-|Define                 |Default |Description                        |
-|-----------------------|--------|-----------------------------------|
-|`BACKLIGHT_PWM_DRIVER` |`PWMD4` |The PWM driver to use              |
-|`BACKLIGHT_PWM_CHANNEL`|`3`     |The PWM channel to use             |
-|`BACKLIGHT_PAL_MODE`   |`2`     |The pin alternative function to use|
+|Define                 |Default      |Description                                                    |
+|-----------------------|-------------|---------------------------------------------------------------|
+|`BACKLIGHT_PWM_DRIVER` |`PWMD4`      |The PWM driver to use                                          |
+|`BACKLIGHT_PWM_CHANNEL`|`3`          |The PWM channel to use                                         |
+|`BACKLIGHT_PAL_MODE`   |`2`          |The pin alternative function to use                            |
+|`BACKLIGHT_PWM_PERIOD` |*Not defined*|The PWM period in counter ticks - Default is platform dependent|
+
 
 Refer to the ST datasheet for your particular MCU to determine these values. For example, these defaults are set up for pin `B8` on a Proton-C (STM32F303) using `TIM4_CH3` on AF2. Unless you are designing your own keyboard, you generally should not need to change them.
 

+ 11 - 0
lib/python/qmk/build_targets.py

@@ -31,6 +31,17 @@ class BuildTarget:
     def __repr__(self):
         return f'BuildTarget(keyboard={self.keyboard}, keymap={self.keymap})'
 
+    def __eq__(self, __value: object) -> bool:
+        if not isinstance(__value, BuildTarget):
+            return False
+        return self.__repr__() == __value.__repr__()
+
+    def __ne__(self, __value: object) -> bool:
+        return not self.__eq__(__value)
+
+    def __hash__(self) -> int:
+        return self.__repr__().__hash__()
+
     def configure(self, parallel: int = None, clean: bool = None, compiledb: bool = None) -> None:
         if parallel is not None:
             self._parallel = parallel

+ 2 - 5
lib/python/qmk/cli/ci/validate_aliases.py

@@ -1,11 +1,8 @@
 """Validates the list of keyboard aliases.
 """
-from pathlib import Path
-
 from milc import cli
 
-from qmk.json_schema import json_load
-from qmk.keyboard import resolve_keyboard, keyboard_folder
+from qmk.keyboard import resolve_keyboard, keyboard_folder, keyboard_alias_definitions
 
 
 def _safe_keyboard_folder(target):
@@ -34,7 +31,7 @@ def _target_keyboard_exists(target):
 
 @cli.subcommand('Validates the list of keyboard aliases.', hidden=True)
 def ci_validate_aliases(cli):
-    aliases = json_load(Path('data/mappings/keyboard_aliases.hjson'))
+    aliases = keyboard_alias_definitions()
 
     success = True
     for alias in aliases.keys():

+ 2 - 2
lib/python/qmk/cli/generate/api.py

@@ -11,7 +11,7 @@ from qmk.datetime import current_datetime
 from qmk.info import info_json
 from qmk.json_schema import json_load
 from qmk.keymap import list_keymaps
-from qmk.keyboard import find_readme, list_keyboards
+from qmk.keyboard import find_readme, list_keyboards, keyboard_alias_definitions
 from qmk.keycodes import load_spec, list_versions, list_languages
 from qmk.xap.common import get_xap_definition_files, update_xap_definitions
 
@@ -184,7 +184,7 @@ def generate_api(cli):
 
     # Generate data for the global files
     keyboard_list = sorted(kb_all)
-    keyboard_aliases = json_load(Path('data/mappings/keyboard_aliases.hjson'))
+    keyboard_aliases = keyboard_alias_definitions()
     keyboard_metadata = {
         'last_updated': current_datetime(),
         'keyboards': keyboard_list,

+ 2 - 2
lib/python/qmk/commands.py

@@ -4,12 +4,12 @@ import os
 import sys
 import shutil
 from itertools import islice
-from pathlib import Path
 
 from milc import cli
 import jsonschema
 
 from qmk.json_schema import json_load, validate
+from qmk.keyboard import keyboard_alias_definitions
 
 
 def find_make():
@@ -54,7 +54,7 @@ def parse_configurator_json(configurator_file):
         exit(1)
 
     keyboard = user_keymap['keyboard']
-    aliases = json_load(Path('data/mappings/keyboard_aliases.hjson'))
+    aliases = keyboard_alias_definitions()
 
     while keyboard in aliases:
         last_keyboard = keyboard

+ 6 - 1
lib/python/qmk/keyboard.py

@@ -72,6 +72,11 @@ class AllKeyboards:
 base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep
 
 
+@lru_cache(maxsize=1)
+def keyboard_alias_definitions():
+    return json_load(Path('data/mappings/keyboard_aliases.hjson'))
+
+
 def is_all_keyboards(keyboard):
     """Returns True if the keyboard is an AllKeyboards object.
     """
@@ -114,7 +119,7 @@ def keyboard_folder(keyboard):
 
     This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard.
     """
-    aliases = json_load(Path('data/mappings/keyboard_aliases.hjson'))
+    aliases = keyboard_alias_definitions()
 
     while keyboard in aliases:
         last_keyboard = keyboard

+ 14 - 3
lib/python/qmk/search.py

@@ -6,7 +6,7 @@ import fnmatch
 import logging
 import re
 from typing import List, Tuple
-from dotty_dict import dotty
+from dotty_dict import dotty, Dotty
 from milc import cli
 
 from qmk.util import parallel_map
@@ -107,13 +107,22 @@ def expand_keymap_targets(targets: List[Tuple[str, str]]) -> List[Tuple[str, str
     return list(sorted(set(overall_targets)))
 
 
+def _construct_build_target_kb_km(e):
+    return KeyboardKeymapBuildTarget(keyboard=e[0], keymap=e[1])
+
+
+def _construct_build_target_kb_km_json(e):
+    return KeyboardKeymapBuildTarget(keyboard=e[0], keymap=e[1], json=e[2])
+
+
 def _filter_keymap_targets(target_list: List[Tuple[str, str]], filters: List[str] = []) -> List[BuildTarget]:
     """Filter a list of (keyboard, keymap) tuples based on the supplied filters.
 
     Optionally includes the values of the queried info.json keys.
     """
     if len(filters) == 0:
-        targets = [KeyboardKeymapBuildTarget(keyboard=kb, keymap=km) for kb, km in target_list]
+        cli.log.info('Preparing target list...')
+        targets = list(set(parallel_map(_construct_build_target_kb_km, target_list)))
     else:
         cli.log.info('Parsing data for all matching keyboard/keymap combinations...')
         valid_keymaps = [(e[0], e[1], dotty(e[2])) for e in parallel_map(_load_keymap_info, target_list)]
@@ -172,7 +181,9 @@ def _filter_keymap_targets(target_list: List[Tuple[str, str]], filters: List[str
                 cli.log.warning(f'Unrecognized filter expression: {filter_expr}')
                 continue
 
-        targets = [KeyboardKeymapBuildTarget(keyboard=e[0], keymap=e[1], json=e[2]) for e in valid_keymaps]
+        cli.log.info('Preparing target list...')
+        valid_keymaps = [(e[0], e[1], e[2].to_dict() if isinstance(e[2], Dotty) else e[2]) for e in valid_keymaps]  # need to convert dotty_dict back to dict because it doesn't survive parallelisation
+        targets = list(set(parallel_map(_construct_build_target_kb_km_json, list(valid_keymaps))))
 
     return targets
 

+ 9 - 0
platforms/arm_atsam/_util.h

@@ -0,0 +1,9 @@
+// Copyright 2023 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#define RESIDENT_IN_RAM(funcname) __attribute__((section(".ramfunc." #funcname), noinline)) funcname
+
+#if __has_include_next("_util.h")
+#    include_next "_util.h"
+#endif

+ 10 - 0
platforms/avr/_util.h

@@ -0,0 +1,10 @@
+// Copyright 2023 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+// AVR can't actually run anything from RAM, so just no-op the define.
+#define RESIDENT_IN_RAM(funcname) funcname
+
+#if __has_include_next("_util.h")
+#    include_next "_util.h"
+#endif

+ 9 - 0
platforms/chibios/_util.h

@@ -0,0 +1,9 @@
+// Copyright 2023 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#define RESIDENT_IN_RAM(funcname) __attribute__((section(".ram0_init." #funcname), noinline)) funcname
+
+#if __has_include_next("_util.h")
+#    include_next "_util.h"
+#endif

+ 4 - 0
quantum/util.h

@@ -50,3 +50,7 @@
 #if !defined(PACKED)
 #    define PACKED __attribute__((__packed__))
 #endif
+
+#if __has_include("_util.h")
+#    include "_util.h" /* Include the platform's _util.h */
+#endif