diff --git a/README.md b/README.md index c5b8fb909..ee192cbab 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Azarton C1 T20X JXF23 RTL8189FS_SDIO NOR_16M done Azarton C1 T31X GC2053 RTL8189FS_SDIO NOR_16M done Babysense See HD IP206 SSC333 GC2053 RTL8188FU_USB NOR_16M done Baolian 11R6W25-HX20Y HI3518EV200 JXH65 MT7601U_USB NOR_8M testing, zoom/focus lens (OpenIPC/firmware#2675) -Botslab C213 T23N SC3332 ATBM6012B_USB NOR_8M **INIT** - frozen +Botslab C213 T23N SC3332 ATBM6012B_USB NOR_8M testing, pan/tilt-ok (TMI8152 SPI), ircut-ok, wifi-ok, eth-ok, video-ok, audio-ok, sd-ok (SC3332 driver: OpenIPC/openingenic sc3332-t23) CCDCAM IM50Q01 SSC377QE IMX335 - NOR_16M done ChinaTelecom DS-YTJ5301 SSC30KD GC2053 RTL8188FU_USB NOR_16M video-ok, wifi-no, motors-no ChinaTelecom Y4H-50 T31L ? ? NOR_16M new diff --git a/devices/t23_lite_botslab-c213/br-ext-chip-ingenic/configs/t23_lite_botslab-c213_defconfig b/devices/t23_lite_botslab-c213/br-ext-chip-ingenic/configs/t23_lite_botslab-c213_defconfig new file mode 100644 index 000000000..8fd7ea667 --- /dev/null +++ b/devices/t23_lite_botslab-c213/br-ext-chip-ingenic/configs/t23_lite_botslab-c213_defconfig @@ -0,0 +1,72 @@ +# Architecture +BR2_mipsel=y +BR2_mips_xburst=y +# BR2_MIPS_SOFT_FLOAT is not set +BR2_MIPS_FP32_MODE_32=y + +# Toolchain +BR2_TOOLCHAIN_EXTERNAL=y +BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y +BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y +BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/openipc/firmware/releases/download/toolchain/toolchain.ingenic-t31.tgz" +BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="mipsel-openipc-linux-musl" +BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y +BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y +BR2_TOOLCHAIN_EXTERNAL_CXX=y + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_TARBALL=y +BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/openipc/linux/archive/ingenic-t23.tar.gz" +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(EXTERNAL_VENDOR)/board/$(OPENIPC_SOC_FAMILY)/t23.generic.config" +BR2_LINUX_KERNEL_LZMA=y + +# Filesystem +BR2_PACKAGE_BUSYBOX_CONFIG="$(BR2_EXTERNAL)/package/busybox/busybox.config" +BR2_PACKAGE_UBOOT_TOOLS=y +BR2_PACKAGE_ZLIB=y +# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set +BR2_PACKAGE_WIREGUARD_LINUX_COMPAT=y +BR2_PACKAGE_WIREGUARD_TOOLS=y +BR2_PACKAGE_WIRELESS_TOOLS=y +BR2_PACKAGE_WPA_SUPPLICANT=y +BR2_PACKAGE_WPA_SUPPLICANT_CLI=y +BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y +BR2_TARGET_ROOTFS_CPIO=y +BR2_TARGET_ROOTFS_SQUASHFS=y +BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y + +# OpenIPC +BR2_OPENIPC_SOC_VENDOR="ingenic" +BR2_OPENIPC_SOC_MODEL="t23" +BR2_OPENIPC_SOC_FAMILY="t23" +BR2_OPENIPC_VARIANT="lite" +BR2_OPENIPC_FLASH_SIZE="8" + +# Packages +BR2_PACKAGE_DROPBEAR_OPENIPC=y +BR2_PACKAGE_INGENIC_OSDRV_T23=y +BR2_PACKAGE_IPCTOOL=y +BR2_PACKAGE_LIBCURL_OPENIPC=y +BR2_PACKAGE_LIBCURL_OPENIPC_CURL=y +# BR2_PACKAGE_LIBCURL_OPENIPC_PROXY_SUPPORT is not set +# BR2_PACKAGE_LIBCURL_OPENIPC_COOKIES_SUPPORT is not set +# BR2_PACKAGE_LIBCURL_OPENIPC_EXTRA_PROTOCOLS_FEATURES is not set +BR2_PACKAGE_LIBEVENT_OPENIPC=y +BR2_PACKAGE_LIBOGG_OPENIPC=y +BR2_PACKAGE_MAJESTIC_FONTS=y +BR2_PACKAGE_MAJESTIC_WEBUI=y +BR2_PACKAGE_MAJESTIC=y +BR2_PACKAGE_MBEDTLS_OPENIPC=y +BR2_PACKAGE_OPUS_OPENIPC=y +BR2_PACKAGE_OPUS_OPENIPC_FIXED_POINT=y +BR2_PACKAGE_VTUND_OPENIPC=y +BR2_PACKAGE_YAML_CLI=y +BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_GENERAL_PATH)/scripts/post-image-split.sh" + +# Botslab C213 (T23N + SC3332 + ATBM6012B USB + TMI8152 SPI) +BR2_PACKAGE_ATBM603X_COMB_OPENIPC=y +BR2_PACKAGE_MOTORS=y +BR2_PACKAGE_TMI8152_C213=y +BR2_PACKAGE_MAJESTIC_WEBUI_PTZ=y diff --git a/devices/t23_lite_botslab-c213/general/overlay/etc/init.d/S36c213 b/devices/t23_lite_botslab-c213/general/overlay/etc/init.d/S36c213 new file mode 100755 index 000000000..431777892 --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/etc/init.d/S36c213 @@ -0,0 +1,72 @@ +#!/bin/sh +# +# Botslab C213: TMI8152 (SPI motor + IR-cut driver) and helper daemons. +# +# fw_printenv knobs (all optional): +# motor_hmaxstep pan range, steps (default 8000 = stock 500 counts x 16) +# motor_vmaxstep tilt range, steps (default 3200 = stock 200 counts x 16) +# motor_xcenter pan home, steps (default 4000 = stock 250 from the stop) +# motor_ycenter tilt home, steps (default 960 = stock 60 from the low stop) +# motor_invert "x", "y" or "xy" (default none) +# motor_xch/ych TMI channel of pan / tilt (default 0 / 1, as stock) +# ircut_day value for day: 0 or 1 (default 1) +# motor_unit WebUI pad step, steps (default 40, see /usr/bin/motor) +# motor_speed WebUI pad speed, 1..900 (default 900) + +getenv() { fw_printenv -n "$1" 2>/dev/null; } + +# WebUI PTZ: the "motor" backend runs /usr/bin/motor . +# Set once, so a camera configured before this existed gets it too. +ptz_env() { + [ -n "$(getenv ptz_control)" ] || fw_setenv ptz_control motor + [ -n "$(getenv ptz_profile)" ] || fw_setenv ptz_profile c213 + [ -n "$(getenv ptz_caps)" ] || fw_setenv ptz_caps "pan tilt" +} + +# majestic used to drive GPIO63 as the speaker pin and so switched the TMI +# power stage off; the amplifier is GPIO53. +speaker_fix() { + [ "$(cli -g .audio.speakerPin 2>/dev/null)" = 63 ] && cli -s .audio.speakerPin 53 + gpio set 63 >/dev/null +} + +start() { + ptz_env + speaker_fix + modprobe tmi8152_spi_dev || { + echo "c213: TMI8152 not found on SPI0" | logger -s -t c213 + return 1 + } + + inv=$(getenv motor_invert) + modprobe tmi8152_motor \ + hmaxstep="$(getenv motor_hmaxstep || echo 8000)" \ + vmaxstep="$(getenv motor_vmaxstep || echo 3200)" \ + center_x_override="$(getenv motor_xcenter || echo 4000)" \ + center_y_override="$(getenv motor_ycenter || echo 960)" \ + invert_x="$(case "$inv" in *x*) echo 1;; *) echo 0;; esac)" \ + invert_y="$(case "$inv" in *y*) echo 1;; *) echo 0;; esac)" \ + x_channel="$(getenv motor_xch || echo 0)" \ + y_channel="$(getenv motor_ych || echo 1)" + + # Homing: the driver waits for MOTOR_RESET with zero limits. + (ingenic-motor -r >/dev/null 2>&1 &) + + start-stop-daemon -S -b -m -p /var/run/ircut-sync.pid -x /usr/sbin/ircut-sync + start-stop-daemon -S -b -m -p /var/run/resetd.pid -x /usr/sbin/resetd.sh +} + +stop() { + start-stop-daemon -K -q -p /var/run/ircut-sync.pid + start-stop-daemon -K -q -p /var/run/resetd.pid + # Shell scripts: the pid file can miss them, the process name does not. + killall -q ircut-sync resetd.sh + rm -f /var/run/ircut-sync.pid /var/run/resetd.pid +} + +case "$1" in + start) start ;; + stop) stop ;; + restart) stop; start ;; + *) echo "Usage: $0 {start|stop|restart}"; exit 1 ;; +esac diff --git a/devices/t23_lite_botslab-c213/general/overlay/etc/modprobe.d/c213.conf b/devices/t23_lite_botslab-c213/general/overlay/etc/modprobe.d/c213.conf new file mode 100644 index 000000000..6416847a5 --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/etc/modprobe.d/c213.conf @@ -0,0 +1,5 @@ +# Botslab C213: the sensor reset is PA17 (stock sensor_sc3332_t23.ko default). +# PA18, the T23 default, is the reset button here: neither the sensor driver +# nor sinfo's probe may drive it. +options sensor_sc3332_t23 reset_gpio=17 +options sinfo reset_gpio=17 diff --git a/devices/t23_lite_botslab-c213/general/overlay/etc/sensor/sc3332-t23.bin b/devices/t23_lite_botslab-c213/general/overlay/etc/sensor/sc3332-t23.bin new file mode 100644 index 000000000..e9dfb02cf Binary files /dev/null and b/devices/t23_lite_botslab-c213/general/overlay/etc/sensor/sc3332-t23.bin differ diff --git a/devices/t23_lite_botslab-c213/general/overlay/etc/sensor/sc3332.yaml b/devices/t23_lite_botslab-c213/general/overlay/etc/sensor/sc3332.yaml new file mode 100644 index 000000000..19c61d5d3 --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/etc/sensor/sc3332.yaml @@ -0,0 +1,6 @@ +sensor: + name: sc3332 + address: 0x30 + width: 2304 + height: 1296 + bus: i2c diff --git a/devices/t23_lite_botslab-c213/general/overlay/usr/bin/motor b/devices/t23_lite_botslab-c213/general/overlay/usr/bin/motor new file mode 100755 index 000000000..d92f629e3 --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/usr/bin/motor @@ -0,0 +1,37 @@ +#!/bin/sh +# +# WebUI "motor" PTZ backend for Botslab C213 (TMI8152 via /dev/motor). +# +# motor +# +# j/ptz.cgi calls this with h, v in -99..99; the pad sends +-5 per press and +# 0 0 for "centre". Each unit is motor_unit steps (fw_setenv motor_unit N, +# default 40: 2.5 counts of the stock 500-count pan). +# +# fw_setenv ptz_invert "x" | "y" | "xy" | "none" - flip the WebUI arrows +# (default "x": the pad's pan runs opposite to the driver's +/- on C213). +# Only the pad is flipped; homing and the driver's own directions stay as stock. + +[ $# -ge 3 ] || { echo "usage: motor " >&2; exit 2; } +h=$2 +v=$3 +case "$h" in ''|*[!0-9-]*) echo "bad h: $h" >&2; exit 2 ;; esac +case "$v" in ''|*[!0-9-]*) echo "bad v: $v" >&2; exit 2 ;; esac + +[ -c /dev/motor ] || { echo "No /dev/motor: tmi8152_motor is not loaded." >&2; exit 1; } + +unit=$(fw_printenv -n motor_unit 2>/dev/null) +case "$unit" in ''|*[!0-9]*) unit=40 ;; esac +speed=$(fw_printenv -n motor_speed 2>/dev/null) +case "$speed" in ''|*[!0-9]*) speed=900 ;; esac + +if [ "$h" -eq 0 ] && [ "$v" -eq 0 ]; then + # Centre: the driver's home (center_x/y_override, stock 250 / 60 counts). + exec ingenic-motor -d b +fi + +inv=$(fw_printenv -n ptz_invert 2>/dev/null) || inv=x +case "$inv" in *x*) h=$((-h)) ;; esac +case "$inv" in *y*) v=$((-v)) ;; esac + +exec ingenic-motor -d g -x $((h * unit)) -y $((v * unit)) -s "$speed" diff --git a/devices/t23_lite_botslab-c213/general/overlay/usr/sbin/ircut-sync b/devices/t23_lite_botslab-c213/general/overlay/usr/sbin/ircut-sync new file mode 100755 index 000000000..5acaa8198 --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/usr/sbin/ircut-sync @@ -0,0 +1,49 @@ +#!/bin/sh +# +# The C213 IR-cut filter hangs off TMI8152 channel 5 (SPI), which majestic +# cannot drive: it only pulses GPIO irCutPin1/2. Follow majestic's own +# day/night state instead (night_enabled in /metrics), so the automatic switch +# and the WebUI's Day/Night buttons (/night/on, /night/off, /night/toggle) +# both move the filter. If /metrics cannot be read, fall back to the IR +# illuminator pin majestic switches with night mode (backlightPin=49). +# +# fw_setenv ircut_day 0|1 - value written for day (default 1) +# fw_setenv ir_led_on 0|1 - level of GPIO49 that means "IR LEDs on" (default 1) + +# Kernel-side parameter first: write() on the char device cannot read the +# user buffer on this kernel ("Error copying data from user"). +DEV=/sys/module/tmi8152_spi_dev/parameters/ircut +[ -w "$DEV" ] || DEV=/dev/tmi8152_ir_cut +PIN=49 +DAY=$(fw_printenv -n ircut_day 2>/dev/null || echo 1) +LED_ON=$(fw_printenv -n ir_led_on 2>/dev/null || echo 1) +NIGHT=$((1 - DAY)) +last="" + +[ -e "$DEV" ] || { echo "ircut-sync: no $DEV" | logger -t ircut; exit 1; } + +# 1 night, 0 day, empty when unknown. +night_state() { + local m + m=$(curl -s -m 2 http://127.0.0.1/metrics 2>/dev/null | sed -n 's/^night_enabled \([01]\)$/\1/p') + if [ -n "$m" ]; then + echo "$m" + return + fi + m=$(cat /sys/class/gpio/gpio$PIN/value 2>/dev/null) || return + [ "$m" = "$LED_ON" ] && echo 1 || echo 0 +} + +# Day position at start, like the stock app. +printf %s "$DAY" > "$DEV" +last=$DAY + +while sleep 2; do + n=$(night_state) + [ -n "$n" ] || continue + if [ "$n" = 1 ]; then want=$NIGHT; else want=$DAY; fi + if [ "$want" != "$last" ]; then + printf %s "$want" > "$DEV" && last=$want + logger -t ircut "filter -> $([ "$want" = "$DAY" ] && echo day || echo night)" + fi +done diff --git a/devices/t23_lite_botslab-c213/general/overlay/usr/sbin/resetd.sh b/devices/t23_lite_botslab-c213/general/overlay/usr/sbin/resetd.sh new file mode 100755 index 000000000..d305b6930 --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/usr/sbin/resetd.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +if [ -e /usr/share/openipc/gpio.conf ]; then + . /usr/share/openipc/gpio.conf +fi + + +[ -z $button ] && echo "GPIO pin for resetd is not set" | logger -t resetd && exit + +# Counter for button press until reset +count=0 + +# prepare the pin +if [ ! -d /sys/class/gpio/gpio${button} ]; then + echo "${button}" > /sys/class/gpio/export + echo "in" > /sys/class/gpio/gpio${button}/direction +fi + +# A pin that cannot be read (e.g. taken by a driver) must not count as pressed. +if [ ! -r /sys/class/gpio/gpio${button}/value ]; then + echo "GPIO${button} is not available, resetd disabled" | logger -t resetd + exit 1 +fi + +# continuously monitor current value of reset switch +while [ true ]; do + # On the C213 the button pin (PA18) is the T23 default sensor reset: + # tx-isp-t23 (vendor, closed) makes it an output driven high when it + # probes, behind gpiolib's back (sysfs still says "in"), and it then + # reads 1 for ever. Make it an input again on every pass. + echo in > /sys/class/gpio/gpio${button}/direction 2>/dev/null + v=; read -r v 2>/dev/null < /sys/class/gpio/gpio${button}/value + if [ "$v" != 0 ]; then + count=0 + else + count=$((count+1)) + # 20 counts =~ 5 seconds @ 0.25 sleep intervals + if [ $count -eq 20 ]; then + #echo 'SET WIFI' | logger -t resetd + #fw_setenv wlanssid WIFI + #fw_setenv wlanpass 12345678 + for a in $(seq 10) ; do (gpio toggle ${led1} ; sleep 0.3 ; gpio toggle ${led1} ; sleep 0.3) ; done >/dev/null 2>&1 + echo 'RESETTING FIRMWARE' | logger -t resetd + firstboot + fi + fi + # Shell builtins only (echo, read): nothing forks in the loop but sleep. + sleep 0.25 +done diff --git a/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/customizer.sh b/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/customizer.sh new file mode 100755 index 000000000..a4dca8f4b --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/customizer.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Botslab C213: one-time settings on first boot (run by S30customizer). +# + +fw_setenv upgrade 'https://github.com/OpenIPC/builder/releases/download/latest/t23_lite_botslab-c213-nor.tgz' + +# SD card detect is PB19 (51). The loader default 59 (PB27) is an SSI0 pin +# used by the TMI8152 motor driver and must not be claimed by jzmmc. +fw_setenv gpio_mmc 51 + +# Wi-Fi: ATBM6012B combo over USB, atbm603x driver (stock: atbm603x_wifi_usb wifi_bt_comb=1) +fw_setenv wlandev atbm603x-generic-usb +#fw_setenv wlanssid Router +#fw_setenv wlanpass 12345678 + +# Memory split for the OpenIPC U-Boot (the stock U-Boot takes it from bootargs). +# Stock used 19.5M rmem with ISP direct_mode; majestic needs 24M for 2304x1296. +fw_setenv osmem 40M@0x0 +fw_setenv rmem 24M@0x2800000 + +# Majestic +cli -s .video0.codec h264 +# Image comes out upside down with the stock sensor driver (shvflip=1); +# the stock app turned it in the ISP. Checked on the camera: both flags. +cli -s .image.flip true +cli -s .image.mirror true +# Sensor gives 2304x1296, but the T23 H.264 encoder rejects a 1296-line NV12 +# buffer ("invalidate input nal buffer align"): height must be a multiple of 32. +cli -s .video0.size 2304x1280 +cli -s .nightMode.lightMonitor true +cli -s .nightMode.backlightPin 49 +cli -s .nightMode.monitorDelay 5 +cli -s .osd.enabled true +cli -s .audio.enabled true +cli -s .audio.codec aac +cli -s .audio.srate 48000 +cli -s .audio.volume 90 +cli -s .audio.gain 26 +cli -s .audio.outputEnabled true +cli -s .audio.outputVolume 80 +cli -s .audio.speakerPin 53 + +(sleep 3; reboot -f) & + +exit 0 diff --git a/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/gpio.conf b/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/gpio.conf new file mode 100644 index 000000000..0605fcc4d --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/gpio.conf @@ -0,0 +1,31 @@ +# Botslab C213 (T23N). GPIO number = bank*32 + pin (PA=0, PB=32). +# Source: stock firmware C213C_v1.0.4.5649 (kernel board data, gpio.config, +# init scripts, audio/sensor module defaults, the stock camera app). +alarm_in=-1 +alarm_out=-1 +# Reset button PA18, active low (stock gpio-keys KEY_F14) +button=18 +# Touch "call" button PB26, active low (stock gpio-keys KEY_F15, wakeup) +button_call=58 +# IR-cut filter is on TMI8152 channel 5 (SPI), not on GPIO +ircut1=-1 +ircut2=-1 +# Status LEDs, active low: PB18 green, PB25 blue +led1=57 +led2=50 +# IR illuminator PB17 (stock gpio.config "ircut_led") +light_ir=49 +light_wl=-1 +light_sensor=-1 +# SD card detect PB19, active low (stock msc0 platform data) +mmc_cd=51 +mmc_pwr=-1 +# Speaker amplifier enable PB21, active high (stock app qhHALAOSetPAOnOrOff) +speaker=53 +# Ethernet PHY reset PB20, active low (stock U-Boot "ethphy reset"); pulsed by muxes.sh +eth_phy_reset=52 +# TMI8152 power stage enable PB31, must stay high (stock audio.ko default spk_gpio) +tmi_en=63 +# PA8: stock qihoo_init.sh sets it, but the pad does not respond on T23N +aux_en=-1 +usb=-1 diff --git a/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/muxes.sh b/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/muxes.sh new file mode 100755 index 000000000..5e4ff565d --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/overlay/usr/share/openipc/muxes.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Botslab C213: GPIO state at every boot (run by S30customizer, before S40network). + +# Ethernet PHY reset: GPIO52 (PB20), active low. Without this pulse the PHY +# answers on MDIO but never brings the link up. Same sequence as the stock +# U-Boot "ethphy reset": high, low for 50 ms, high. +gpio set 52 >/dev/null +usleep 10000 +gpio clear 52 >/dev/null +usleep 50000 +gpio set 52 >/dev/null +usleep 100000 + +# TMI8152 (motors + IR-cut) power stage enable: GPIO63 (PB31), high. +# Stock audio.ko holds it high as its default spk_gpio; on this board the +# speaker amplifier is GPIO53, and without 63 the TMI reports a fault +# (0x02 reads 0x12 instead of 0x03) and drives nothing. +gpio set 63 >/dev/null + +# Status LEDs are active low: high = off. Blue off, green on (power). +gpio set 57 >/dev/null +gpio clear 50 >/dev/null diff --git a/devices/t23_lite_botslab-c213/general/scripts/excludes/t23_lite.list b/devices/t23_lite_botslab-c213/general/scripts/excludes/t23_lite.list new file mode 100644 index 000000000..09af0ad43 --- /dev/null +++ b/devices/t23_lite_botslab-c213/general/scripts/excludes/t23_lite.list @@ -0,0 +1,46 @@ +# Botslab C213: only SC3332 is used; drop other sensors to save NOR space. +# Stale entries are reported by rootfs_script.sh and are harmless. +/etc/sensor/gc2053-t23.bin +/etc/sensor/gc2053.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_gc2053_t23.ko +/etc/sensor/imx327-t23.bin +/etc/sensor/imx327.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_imx327_t23.ko +/etc/sensor/jxf23-t23.bin +/etc/sensor/jxf23.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_jxf23_t23.ko +/etc/sensor/jxf37pa-t23.bin +/etc/sensor/jxf37pa.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_jxf37pa_t23.ko +/etc/sensor/jxf38p-t23.bin +/etc/sensor/jxf38p.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_jxf38p_t23.ko +/etc/sensor/jxh63p-t23.bin +/etc/sensor/jxh63p.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_jxh63p_t23.ko +/etc/sensor/sc1346-t23.bin +/etc/sensor/sc1346.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_sc1346_t23.ko +/etc/sensor/sc1a4t-t23.bin +/etc/sensor/sc1a4t.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_sc1a4t_t23.ko +/etc/sensor/sc200ai-t23.bin +/etc/sensor/sc200ai.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_sc200ai_t23.ko +/etc/sensor/sc2310-t23.bin +/etc/sensor/sc2310.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_sc2310_t23.ko +/etc/sensor/sc2331-t23.bin +/etc/sensor/sc2331.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_sc2331_t23.ko +/etc/sensor/sc2336-t23.bin +/etc/sensor/sc2336.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_sc2336_t23.ko +/etc/sensor/sc301IoT-t23.bin +/etc/sensor/sc301IoT.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_sc301IoT_t23.ko +/etc/sensor/sp140a-t23.bin +/etc/sensor/sp140a.yaml +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/sensor_sp140a_t23.ko +# GPIO stepper driver from openingenic: this board uses TMI8152 over SPI +/lib/modules/3.10.14__isvp_pike_1.0__/ingenic/motor.ko diff --git a/package/tmi8152-c213/0001-tmi8152-openipc-t23.patch b/package/tmi8152-c213/0001-tmi8152-openipc-t23.patch new file mode 100644 index 000000000..5c28cc22c --- /dev/null +++ b/package/tmi8152-c213/0001-tmi8152-openipc-t23.patch @@ -0,0 +1,96 @@ +Subject: [PATCH] tmi8152-spi-dev: OpenIPC Ingenic T23 fixes (Botslab C213) + +Makes the driver work with OpenIPC on the T23 kernel (Botslab C213, TMI8152): + +- write() on /dev/tmi8152_ir_cut fails on this kernel ("Error copying data + from user", while the ioctl paths copy fine), so the IR cut is also + exposed as the "ircut" module parameter in sysfs. +- struct motor_message without inversion_state, the layout OpenIPC's + ingenic-motor uses: MOTOR_GET_STATUS copied 4 bytes past its buffer. +- The motor module is built as tmi8152_motor.ko: openingenic already + installs a motor.ko. + +SPI framing, motion, speed and IR-cut sequences are Thingino's, unchanged. + +diff --git a/Makefile b/Makefile +index 8986dfe..f163fb1 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,5 +1,6 @@ + obj-m += tmi8152_spi_dev.o +-obj-m += motor.o ++obj-m += tmi8152_motor.o ++tmi8152_motor-objs := motor.o + + all: + $(MAKE) -C $(KSRC) M=$(PWD) modules +diff --git a/motor.c b/motor.c +index 7758e56..fbd959f 100644 +--- a/motor.c ++++ b/motor.c +@@ -730,7 +730,6 @@ static long motor_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + msg.speed = motor.speed; + msg.x_max_steps = motor.x_max; + msg.y_max_steps = motor.y_max; +- msg.inversion_state = 0; /* Not implemented yet */ + + /* Copy status to userspace */ + if (copy_to_user((void __user *)arg, &msg, sizeof(msg))) { +diff --git a/motor.h b/motor.h +index 0669e52..c955e0e 100644 +--- a/motor.h ++++ b/motor.h +@@ -50,7 +50,6 @@ struct motor_message { + int speed; + unsigned int x_max_steps; + unsigned int y_max_steps; +- unsigned int inversion_state; + }; + + /** +diff --git a/tmi8152_spi_dev.c b/tmi8152_spi_dev.c +index 2875f08..e1bf42f 100644 +--- a/tmi8152_spi_dev.c ++++ b/tmi8152_spi_dev.c +@@ -120,6 +120,41 @@ static ssize_t tmi8152_cdev_write(struct file *filp, + return count; + } + ++/* ++ * /sys/module/tmi8152_spi_dev/parameters/ircut: write 0 or 1, as to ++ * /dev/tmi8152_ir_cut. write() on the char device still fails to read the ++ * user buffer on the OpenIPC T23 kernel; a module parameter is copied by the ++ * kernel itself. ++ */ ++static int ircut_param_set(const char *val, const struct kernel_param *kp) ++{ ++ int v, ret; ++ ++ if (kstrtoint(val, 0, &v) || (v != 0 && v != 1)) ++ return -EINVAL; ++ if (!sdev) ++ return -ENODEV; ++ ret = set_ir_cut(v); ++ if (ret < 0) ++ return ret; ++ mutex_lock(&tmi8152_spi_lock); ++ dev_buff[0] = '0' + v; ++ mutex_unlock(&tmi8152_spi_lock); ++ return 0; ++} ++ ++static int ircut_param_get(char *buf, const struct kernel_param *kp) ++{ ++ return sprintf(buf, "%c\n", dev_buff[0] ? dev_buff[0] : '?'); ++} ++ ++static struct kernel_param_ops ircut_param_ops = { ++ .set = ircut_param_set, ++ .get = ircut_param_get, ++}; ++module_param_cb(ircut, &ircut_param_ops, NULL, 0644); ++MODULE_PARM_DESC(ircut, "IR-cut filter: write 0 or 1"); ++ + static struct file_operations tmi8152_cdev_fops = { + .owner = THIS_MODULE, + .open = tmi8152_cdev_open, diff --git a/package/tmi8152-c213/Config.in b/package/tmi8152-c213/Config.in new file mode 100644 index 000000000..249f512b1 --- /dev/null +++ b/package/tmi8152-c213/Config.in @@ -0,0 +1,9 @@ +config BR2_PACKAGE_TMI8152_C213 + bool "tmi8152-c213" + depends on BR2_LINUX_KERNEL + help + TMI8152 SPI pan/tilt + IR-cut driver (Botslab C213, Ingenic T23N), + https://github.com/sstepansky/tmi8152-spi-dev with OpenIPC T23 fixes. + Enables CONFIG_SPI/CONFIG_JZ_SPI/CONFIG_JZ_SPI0 (SSI0 on PB27-PB30). + Provides /dev/motor (Ingenic motor ioctl API) and the "ircut" + parameter of tmi8152_spi_dev. diff --git a/package/tmi8152-c213/tmi8152-c213.mk b/package/tmi8152-c213/tmi8152-c213.mk new file mode 100644 index 000000000..bca1a3cd1 --- /dev/null +++ b/package/tmi8152-c213/tmi8152-c213.mk @@ -0,0 +1,27 @@ +################################################################################ +# +# tmi8152-c213 +# +################################################################################ + +TMI8152_C213_SITE = $(call github,sstepansky,tmi8152-spi-dev,$(TMI8152_C213_VERSION)) +TMI8152_C213_VERSION = 4d5a666b77bc2af57cd00af20a088107c60d017e +TMI8152_C213_LICENSE = GPL-2.0 +TMI8152_C213_LICENSE_FILES = LICENSE + +# The chip sits on hardware SSI0 (PB27..PB30, function 2), bus 0, CS0, +# exactly like the stock kernel (ssi0-pb-1). The module creates the SPI +# device itself, so no board-file patch is needed. +define TMI8152_C213_LINUX_CONFIG_FIXUPS + $(call KCONFIG_ENABLE_OPT,CONFIG_SPI) + $(call KCONFIG_ENABLE_OPT,CONFIG_SPI_MASTER) + $(call KCONFIG_ENABLE_OPT,CONFIG_JZ_SPI) + $(call KCONFIG_ENABLE_OPT,CONFIG_JZ_SPI0) + $(call KCONFIG_ENABLE_OPT,CONFIG_JZ_SPI0_PB_1) + $(call KCONFIG_DISABLE_OPT,CONFIG_JZ_SPI0_PB_0) + $(call KCONFIG_DISABLE_OPT,CONFIG_JZ_SPI0_PB_2) + $(call KCONFIG_DISABLE_OPT,CONFIG_JZ_SPI0_PB_3) +endef + +$(eval $(kernel-module)) +$(eval $(generic-package))