Created
April 11, 2025 19:54
-
-
Save Demon000/5e2575e5f3b49b1dfe987658888193a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the clock frequencies | |
# From printing the tbl variable inside geni_se_clk_freq_match | |
clock_frequencies = [ | |
19200000, | |
32000000, | |
48000000, | |
64000000, | |
96000000, | |
100000000, | |
120000000, | |
] | |
# Maximum divisor (inclusive) | |
# From include/linux/soc/qcom/geni-se.h | |
# CLK_DIV_MSK = GENMASK(15, 4), which is 12 bits, 0 to 4095 | |
max_divisor = 4095 | |
# Maximum SPI frequency from dts | |
SPI_MAX_FREQ = 5000000 | |
# Calculate the available IR frequencies | |
ir_frequencies = set() | |
for clock in clock_frequencies: | |
for divisor in range(1, max_divisor + 1): | |
if clock // divisor <= SPI_MAX_FREQ: | |
ir_frequencies.add(clock // (divisor * 16)) | |
# Sort the IR frequencies | |
sorted_ir_frequencies = sorted(ir_frequencies) | |
# List to store the fully covered ranges | |
covered_ranges = [] | |
VALID_ERROR = 0.02 | |
# Check the ranges of each frequency | |
for freq in sorted_ir_frequencies: | |
lower_bound = freq * (1 - VALID_ERROR) | |
upper_bound = freq * (1 + VALID_ERROR) | |
if len(covered_ranges) and lower_bound <= covered_ranges[-1][1]: | |
print(f"Extend {covered_ranges[-1][1]} to {upper_bound}") | |
covered_ranges[-1][1] = upper_bound | |
continue | |
covered_ranges.append([lower_bound, upper_bound]) | |
# Output the fully covered ranges | |
print("Fully covered ranges:", covered_ranges) | |
# # Plot the filtered IR frequencies | |
# import matplotlib.pyplot as plt | |
# # Prepare the plot | |
# plt.figure(figsize=(10, 6)) | |
# # For each frequency, plot a horizontal line with 2% tolerance | |
# for freq in filtered_ir_frequencies: | |
# plt.plot([freq * (1 - VALID_ERROR), freq * (1 + VALID_ERROR)], [freq, freq], color='b') | |
# # Set plot details | |
# plt.title("IR Frequencies with ±1% Tolerance") | |
# plt.xlabel("Frequency Range (Hz)") | |
# plt.ylabel("Frequency (Hz)") | |
# plt.grid(True) | |
# plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment