Name: uke-camera-lens-shading Version: 1.0.1 Release: 1%{?dist} Summary: Generate fitted Uke front-camera lens shading for libcamera License: MIT URL: https://github.com/MCC45TR/uke-linux-hardware-support Source0: %{name}-%{version}.tar.xz BuildRequires: gcc-c++ BuildRequires: binutils %description Generate a libcamera SoftISP lens-shading profile from the validated module section supplied on standard input. The helper does not access the camera, write EEPROM, or change libcamera configuration. Profiles remain local to the fitted tablet. %prep %autosetup %build %{__cxx} -std=c++20 %{optflags} %{build_ldflags} -Wall -Wextra -Werror \ generate-lsc-tuning.cpp -o generate-lsc-tuning %install install -Dm755 generate-lsc-tuning \ "%{buildroot}%{_libexecdir}/%{name}/generate-lsc-tuning" %check generator="%{buildroot}%{_libexecdir}/%{name}/generate-lsc-tuning" if [ "%{_arch}" = aarch64 ]; then readelf -h "$generator" | grep -E 'Machine:[[:space:]]+AArch64' fi LC_ALL=C awk 'BEGIN { for (i = 0; i < 1870; i++) { byte = 0 if (i == 96) byte = 1 if (i >= 101 && i < 1869 && i %% 2) byte = 4 if (i == 1869) byte = sum %% 255 + 1 if (i > 96 && i < 1869) sum += byte printf "%%c", byte } }' > synthetic.bin test "$(stat -c '%%s' synthetic.bin)" = 1870 "$generator" < synthetic.bin > tuning.yaml grep -Fx ' - ct: 5000' tuning.yaml test "$(grep -Fo '1.000000' tuning.yaml | wc -l)" = 867 # The corner needs 8x gain. Uniform normalization maps its value to # 255/64 and the original 1x reference to 255/512 for every channel. make_gain_fixture() { LC_ALL=C awk -v outside_range="$1" 'BEGIN { bytes[96] = 1 for (cell = 0; cell < 221; cell++) { sample = (cell == 0) ? 128 : 1024 if (outside_range && cell == 0) sample = 1 if (outside_range && cell == 1) sample = 65535 for (channel = 0; channel < 4; channel++) { offset = 101 + 8 * cell + 2 * channel bytes[offset] = int(sample / 256) bytes[offset + 1] = sample %% 256 } } for (i = 97; i < 1869; i++) sum += bytes[i] bytes[1869] = sum %% 255 + 1 for (i = 0; i < 1870; i++) printf "%%c", bytes[i] + 0 }' } make_gain_fixture 0 > normalized.bin "$generator" < normalized.bin > normalized.yaml test "$(grep -Fo '3.984375' normalized.yaml | wc -l)" = 3 test "$(grep -Fo '0.498047' normalized.yaml | wc -l)" = 861 make_gain_fixture 1 > unrepresentable.bin head -c 1869 synthetic.bin > truncated.bin cp synthetic.bin corrupted.bin printf '\000' | dd of=corrupted.bin bs=1 seek=1869 conv=notrunc status=none (cat synthetic.bin; printf '\000') > oversized.bin for input in truncated.bin corrupted.bin oversized.bin unrepresentable.bin; do code=0 "$generator" < "$input" > rejected.yaml || code=$? test "$code" = 65 test ! -s rejected.yaml done %files %license LICENSE %dir %{_libexecdir}/%{name} %{_libexecdir}/%{name}/generate-lsc-tuning %changelog * Mon Nov 30 2026 Uke Linux Maintainers - 1.0.1-1 - Fit the relative lens-shading gains into the stock SoftISP fixed-point range. * Mon Nov 30 2026 Uke Linux Maintainers - 1.0.0-1 - Package the fitted front lens-shading helper for stock libcamera.