|
@@ -1,180 +1,129 @@
|
|
|
-# Linux port
|
|
|
|
|
|
|
+# s1d13700-tca: S1D13700 LCD behind a TCA9539 I²C expander
|
|
|
|
|
|
|
|
-Replaces the LPC1114 firmware: the panel and keys hang off I²C expanders on the
|
|
|
|
|
-Linux board. The panel runs on real hardware through `radio-ui i2c` and
|
|
|
|
|
-`radio-ui drm`. All 13 keys read correctly through the key expander on the test
|
|
|
|
|
-rig. The overlay has not run.
|
|
|
|
|
|
|
+A Linux DRM driver for an Epson S1D13700 (SED1335 family) graphic LCD whose
|
|
|
|
|
+8080-style parallel bus is driven through a TI TCA9539 16-bit I²C GPIO
|
|
|
|
|
+expander, plus the parts that make it testable without hardware:
|
|
|
|
|
+
|
|
|
|
|
+- an OS-independent **panel core** (`driver/s1d13700_core.*`) that the
|
|
|
|
|
+ driver uses and userspace can link as well,
|
|
|
|
|
+- a **simulator** (`sim/`) that decodes the I²C byte stream as a TCA9539 and
|
|
|
|
|
+ S1D13700 would and flags bus protocol faults,
|
|
|
|
|
+- **tests** for the core, run against the simulator,
|
|
|
|
|
+- **device tree** examples: an overlay and a board DT fragment.
|
|
|
|
|
+
|
|
|
|
|
+It was written for a 240×160 panel at 2 bpp on an Orange Pi Zero (Allwinner
|
|
|
|
|
+H2+, 400 kHz I²C) and runs there, built into the kernel, with fbcon on the
|
|
|
|
|
+panel. The radio-ui application (sibling repository `radio-ui`) uses the
|
|
|
|
|
+same core from userspace, over i2c-dev or through this driver.
|
|
|
|
|
|
|
|
| Path | What |
|
|
| Path | What |
|
|
|
|---|---|
|
|
|---|---|
|
|
|
-| `driver/s1d13700_core.*` | Panel core, used by everything: init, 2 bpp conversion, write planner, TCA9539 stream |
|
|
|
|
|
-| `driver/s1d13700_drm.c` | DRM driver (6.x kernels) |
|
|
|
|
|
-| `sim/` | Model of the TCA9539 and S1D13700: decodes the I²C bytes and flags bus faults |
|
|
|
|
|
-| `radio/` | The application, in Python: UI, MPD client, I²C key polling and the `sim`, `i2c`, `drm` and `keytest` frontends |
|
|
|
|
|
-| `radio/libpanel.c` | The panel core and simulator as a library for the application |
|
|
|
|
|
-| `radio-ui` | Starts the application |
|
|
|
|
|
-| `dts/radio-panel.dts` | Overlay for the keys, backlight and panel |
|
|
|
|
|
-| `tests/` | Panel core tests, application tests, a fake MPD server and `hw_test.sh` |
|
|
|
|
|
|
|
+| `driver/s1d13700_core.*` | Panel core: init, XRGB8888 to 1/2/4 bpp, write planner, TCA9539 stream encoder |
|
|
|
|
|
+| `driver/s1d13700_drm.c` | Atomic KMS driver with fbdev emulation and a backlight device |
|
|
|
|
|
+| `driver/Kbuild` | Out-of-tree build |
|
|
|
|
|
+| `sim/` | Model of the TCA9539 and S1D13700 interface, with fault counters |
|
|
|
|
|
+| `tests/test_panel.c` | Core tests against the simulator |
|
|
|
|
|
+| `dts/radio-panel.dts` | Overlay: panel, key expander, `gpio-keys` |
|
|
|
|
|
+| `dts/examples/orangepi-zero-i2c1.dtsi` | The same for a board DT, as used on the Orange Pi Zero |
|
|
|
|
|
+| `docs/s1d13700-recommendations.md` | Review of the core and driver, applied |
|
|
|
|
|
|
|
|
## Building
|
|
## Building
|
|
|
|
|
|
|
|
- make test # panel core tests, no hardware or libraries
|
|
|
|
|
- make lib # build/libradiopanel.so, needed by the application
|
|
|
|
|
- make pytest # application tests, no hardware or display
|
|
|
|
|
- make dtbo
|
|
|
|
|
|
|
+ make test # core tests, no hardware or libraries
|
|
|
|
|
+ make asan # the same under ASan and UBSan
|
|
|
make module KDIR=/path/to/kernel
|
|
make module KDIR=/path/to/kernel
|
|
|
-
|
|
|
|
|
-The application runs on Python 3.7.3 (Debian buster) to 3.14 and needs
|
|
|
|
|
-PyGObject with GLib, Pango and PangoCairo, pycairo and its PyGObject bridge;
|
|
|
|
|
-GTK 3 for `sim` and `--window-keys`; libdrm for `drm`. On Debian:
|
|
|
|
|
-
|
|
|
|
|
- apt install python3-gi python3-gi-cairo gir1.2-pango-1.0 gir1.2-gtk-3.0
|
|
|
|
|
-
|
|
|
|
|
-`RADIO_PANEL_LIB` points it at the library if it is not in `build/`.
|
|
|
|
|
-
|
|
|
|
|
-Volume is set through MPD (`volume ±1`), so MPD needs a working mixer. The
|
|
|
|
|
-default hardware mixer looks for a `PCM` control, which the H3 codec does not
|
|
|
|
|
-have; the firmware's old `volup`/`voldown` scripts used `DAC`, so the ALSA
|
|
|
|
|
-output in `/etc/mpd.conf` needs:
|
|
|
|
|
-
|
|
|
|
|
- mixer_type "hardware"
|
|
|
|
|
- mixer_device "default"
|
|
|
|
|
- mixer_control "DAC"
|
|
|
|
|
-
|
|
|
|
|
-Without it MPD's status has no `volume:` line and the volume keys do nothing.
|
|
|
|
|
-
|
|
|
|
|
-## Running
|
|
|
|
|
-
|
|
|
|
|
-Window with the simulated panel, using a real MPD:
|
|
|
|
|
-
|
|
|
|
|
- ./radio-ui sim --host radio.lo
|
|
|
|
|
-
|
|
|
|
|
-The window shows the simulator's display memory, and the traffic each update
|
|
|
|
|
-costs. Keys: `Z X C V B` for prev/play/pause/stop/next, arrows, `Enter`, `Esc`,
|
|
|
|
|
-`M`, `L`, `Space` for pause, and a multimedia keyboard's media keys.
|
|
|
|
|
-
|
|
|
|
|
-Real panel through i2c-dev, for bring-up or on a kernel too old for the driver,
|
|
|
|
|
-or through the DRM driver:
|
|
|
|
|
-
|
|
|
|
|
- ./radio-ui i2c --bus N --pattern geometry
|
|
|
|
|
- ./radio-ui i2c --bus N --pattern gray
|
|
|
|
|
- ./radio-ui i2c --bus N --host radio.lo
|
|
|
|
|
- ./radio-ui drm --host radio.lo
|
|
|
|
|
-
|
|
|
|
|
-On the main screen the keys are prev/play/pause/stop/next, up/down for the
|
|
|
|
|
-volume and Esc to refresh. List opens the playlist: the whole MPD queue, the
|
|
|
|
|
-current song centered and selected. Up/down move the selection, OK plays it,
|
|
|
|
|
-and Menu, Esc, List or 30 s without a key go back. With more than 1 bpp the
|
|
|
|
|
-selection is a gray bar, otherwise inverted. The transport keys keep working
|
|
|
|
|
-there.
|
|
|
|
|
-
|
|
|
|
|
-`--bus` must name a known adapter; motherboard and display buses are always
|
|
|
|
|
-refused. Only use the bus number of the adapter the panel is wired to.
|
|
|
|
|
-`./radio-ui FRONTEND --help` lists all options.
|
|
|
|
|
-
|
|
|
|
|
-### Hardware test: panel and keys
|
|
|
|
|
-
|
|
|
|
|
-`tests/hw_test.sh` finds the i2c-tiny-usb bus, checks that no kernel driver
|
|
|
|
|
-holds 0x74 or 0x76, builds the library if needed and runs:
|
|
|
|
|
-
|
|
|
|
|
- tests/hw_test.sh # panel shows the 13 keys; pressed ones inverted
|
|
|
|
|
- tests/hw_test.sh keys-only # keys printed to the terminal, panel untouched
|
|
|
|
|
- tests/hw_test.sh pattern # geometry and gray patterns, then the keys
|
|
|
|
|
- tests/hw_test.sh ui # full UI with the I2C keys, against the fake MPD
|
|
|
|
|
- tests/hw_test.sh init # panel and U2 set up over i2c-dev, left on
|
|
|
|
|
- tests/hw_test.sh drm # sudo: bind the DRM driver to 0x74, pattern,
|
|
|
|
|
- # backlight on, U2 set up; left active
|
|
|
|
|
- tests/hw_test.sh release # sudo: unbind the DRM driver again
|
|
|
|
|
- tests/hw_test.sh -b 11 keys # a given bus
|
|
|
|
|
-
|
|
|
|
|
-The key screen (`radio-ui keytest --bus N`) also shows the raw input ports,
|
|
|
|
|
-press and repeat counts and read errors; each event is printed too. Ctrl-C
|
|
|
|
|
-quits and switches the panel off. The i2c-dev modes refuse to run while a
|
|
|
|
|
-kernel driver holds 0x74 or 0x76; `release` frees 0x74 after `drm`.
|
|
|
|
|
-
|
|
|
|
|
-After `drm`, `./radio-ui drm --host radio.lo` drives the panel through the
|
|
|
|
|
-driver and reads the keys from U2 on the same bus.
|
|
|
|
|
-
|
|
|
|
|
-### Keys over I²C
|
|
|
|
|
-
|
|
|
|
|
-`radio-ui i2c` polls U2 at 0x76 on its own bus every 20 ms (`--keys-addr`,
|
|
|
|
|
-`--keys-poll`; `--no-i2c-keys` falls back to evdev). `radio-ui drm` uses the
|
|
|
|
|
-evdev device `radio-keys` if it exists (the overlay on the target), otherwise
|
|
|
|
|
-U2 on the bus the DRM panel is on; `--keys-bus N` names another bus and
|
|
|
|
|
-`--no-i2c-keys` disables this. The polling reads debounce over two samples and
|
|
|
|
|
-autorepeat like gpio-keys (250 ms, then every 33 ms; the app's 300 ms lockout
|
|
|
|
|
-applies). Keys held at start are ignored until released, and a reading with
|
|
|
|
|
-more than 3 keys down is taken as a bus fault, so a fault cannot send player
|
|
|
|
|
-commands. Do not load the overlay's U2 node while doing this.
|
|
|
|
|
-
|
|
|
|
|
-### Test mode: real panel, PC keyboard
|
|
|
|
|
-
|
|
|
|
|
-`--window-keys` opens a small window on the X display; keys typed into it (the
|
|
|
|
|
-same as in `sim`) go to the app, which drives the real panel and the real MPD:
|
|
|
|
|
-
|
|
|
|
|
- ./radio-ui i2c --bus 11 --host radio.lo --window-keys
|
|
|
|
|
- ./radio-ui drm --host radio.lo --window-keys
|
|
|
|
|
-
|
|
|
|
|
-It also has a button per key. Closing the window quits. Evdev is not read in
|
|
|
|
|
-this mode unless `--input` is given as well.
|
|
|
|
|
-
|
|
|
|
|
-Text uses Verdana and Andale Mono (Microsoft core fonts) if installed, otherwise
|
|
|
|
|
-Liberation Sans and Mono, drawn without antialiasing.
|
|
|
|
|
-
|
|
|
|
|
-### Test rig on the development PC
|
|
|
|
|
-
|
|
|
|
|
-The panel hangs off an ATmega8U2 i2c-tiny-usb bridge. Load the driver for
|
|
|
|
|
-400 kHz (its default, `delay=10`, is only 50 kHz), then find the bus number:
|
|
|
|
|
-
|
|
|
|
|
- sudo modprobe -r i2c_tiny_usb; sudo modprobe i2c_tiny_usb delay=1
|
|
|
|
|
- grep -l i2c-tiny-usb /sys/bus/i2c/devices/i2c-*/name
|
|
|
|
|
-
|
|
|
|
|
-To try the keys without touching the real player, run the fake MPD and point
|
|
|
|
|
-the panel at it:
|
|
|
|
|
-
|
|
|
|
|
- tests/fake_mpd.py 6601 build/mpd-commands.log 5 &
|
|
|
|
|
- ./radio-ui i2c --bus 11 --host localhost --port 6601 --window-keys
|
|
|
|
|
-
|
|
|
|
|
-Never scan or use the other buses on this PC: some reach the CPU regulators.
|
|
|
|
|
-
|
|
|
|
|
-### Simulating keys
|
|
|
|
|
-
|
|
|
|
|
-The panel frontends read keys from evdev: the device named `radio-keys`, or
|
|
|
|
|
-whatever `--input` names. On the PC without the U2 keypad:
|
|
|
|
|
-
|
|
|
|
|
-- **PC keyboard:** `--input /dev/input/by-id/<keyboard>-event-kbd` (needs read
|
|
|
|
|
- access, group `input`). Arrows and Esc map directly; the media keys of a
|
|
|
|
|
- multimedia keyboard map to Prev/Next/Stop if they send `KEY_PREVIOUSSONG`,
|
|
|
|
|
- `KEY_NEXTSONG`, `KEY_STOPCD`. Play, Pause, OK, Menu and List have no
|
|
|
|
|
- ordinary key. The keyboard keeps typing into the focused window too.
|
|
|
|
|
-- **Virtual device:** with `CONFIG_INPUT_UINPUT`, create a device named
|
|
|
|
|
- `radio-keys` (for example `evemu-device` or python-evdev's `UInput`) and send
|
|
|
|
|
- the codes in `radio/platform.py`. `radio-ui` finds it without `--input`.
|
|
|
|
|
- The development kernel has uinput disabled.
|
|
|
|
|
-- **Window:** `--window-keys` (above), or `radio-ui sim`, which draws on the
|
|
|
|
|
- simulated panel only.
|
|
|
|
|
|
|
+ make dtbo # build/*.dtbo from dts/*.dts
|
|
|
|
|
+
|
|
|
|
|
+The driver needs a 6.x kernel with damage helpers, `drm_fbdev_shmem` and the
|
|
|
|
|
+DRM client setup (built against 6.18 and 7.3). It does not build on 4.19;
|
|
|
|
|
+there the panel can still be driven from userspace through i2c-dev with the
|
|
|
|
|
+core.
|
|
|
|
|
+
|
|
|
|
|
+### In the kernel tree
|
|
|
|
|
+
|
|
|
|
|
+Copy `driver/s1d13700_drm.c`, `s1d13700_core.c` and `s1d13700_core.h` into
|
|
|
|
|
+e.g. `drivers/gpu/drm/tiny/s1d13700-tca/` and add:
|
|
|
|
|
+
|
|
|
|
|
+ # Kconfig
|
|
|
|
|
+ config DRM_S1D13700_TCA
|
|
|
|
|
+ tristate "S1D13700 panel behind a TCA9539 I2C expander"
|
|
|
|
|
+ depends on DRM && I2C
|
|
|
|
|
+ select DRM_CLIENT_SELECTION
|
|
|
|
|
+ select DRM_KMS_HELPER
|
|
|
|
|
+ select DRM_GEM_SHMEM_HELPER
|
|
|
|
|
+ select BACKLIGHT_CLASS_DEVICE
|
|
|
|
|
+
|
|
|
|
|
+ # Makefile
|
|
|
|
|
+ obj-$(CONFIG_DRM_S1D13700_TCA) += s1d13700-tca.o
|
|
|
|
|
+ s1d13700-tca-y := s1d13700_drm.o s1d13700_core.o
|
|
|
|
|
+
|
|
|
|
|
+The Orange Pi Zero build scripts (`build-kernel.sh` in the OPi0 project) do
|
|
|
|
|
+this on every build and set it to built-in, so fbcon shows the boot log on
|
|
|
|
|
+the panel. Linux 7.3 renamed `struct drm_atomic_state` to
|
|
|
|
|
+`struct drm_atomic_commit`; that script force-includes a small compatibility
|
|
|
|
|
+header into `s1d13700_drm.c` rather than changing the source.
|
|
|
|
|
+
|
|
|
|
|
+## Driver
|
|
|
|
|
+
|
|
|
|
|
+- **Binding:** I²C client, `compatible = "k4be,s1d13700-tca9539"` (`k4be` is
|
|
|
|
|
+ not a registered vendor prefix, so `dtbs_check` warns), or I²C id
|
|
|
|
|
+ `s1d13700-tca9539` for `new_device`:
|
|
|
|
|
+
|
|
|
|
|
+ echo s1d13700-tca9539 0x74 > /sys/bus/i2c/devices/i2c-N/new_device
|
|
|
|
|
+
|
|
|
|
|
+- **Module parameters** (read-only, so kernel arguments when built in, e.g.
|
|
|
|
|
+ `s1d13700_tca.tcr=162`):
|
|
|
|
|
+
|
|
|
|
|
+ | Parameter | Default | |
|
|
|
|
|
+ |---|---|---|
|
|
|
|
|
+ | `width`, `height` | 240, 160 | panel size in pixels |
|
|
|
|
|
+ | `bpp` | 2 | 1, 2 or 4 bits per pixel |
|
|
|
|
|
+ | `tcr` | 162 | SYSTEM SET TC/R, sets the frame rate |
|
|
|
|
|
+
|
|
|
|
|
+- **Format:** XRGB8888, converted to gray with a plain threshold (no
|
|
|
|
|
+ dithering). White maps to "pixel off", the light background of the LCD.
|
|
|
|
|
+- **Updates:** plane updates turn damage into a pending frame; a worker sends
|
|
|
|
|
+ it and merges whatever arrives meanwhile. Messages are capped at 1025 bytes
|
|
|
|
|
+ (about 23 ms at 400 kHz) so other devices on the bus get a turn, and the
|
|
|
|
|
+ adapter's `max_write_len` is honoured. A failed transfer makes the next
|
|
|
|
|
+ update rewrite the frame; a failed init is retried.
|
|
|
|
|
+- **Backlight:** expander pin P1.0 is registered as
|
|
|
|
|
+ `/sys/class/backlight/radio-backlight` (brightness 0 or 1, on at probe).
|
|
|
|
|
+ The sysfs file is `root:root 0644`; a udev rule can open it to a group:
|
|
|
|
|
+
|
|
|
|
|
+ ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="radio-backlight", RUN+="/bin/chgrp video /sys%p/brightness", RUN+="/bin/chmod g+w /sys%p/brightness"
|
|
|
|
|
+
|
|
|
|
|
+- **Statistics** in debugfs, under the I²C client's directory:
|
|
|
|
|
+ `lcd_writes`, `data_bytes`, `seeks`, `dir_changes`, `i2c_msgs`, `i2c_bytes`.
|
|
|
|
|
+- Blanking is display off only; the controller's `SLEEP` is not used.
|
|
|
|
|
+
|
|
|
|
|
+Only one driver can own an I²C address: U1 must not be bound to
|
|
|
|
|
+`gpio-pca953x`. The driver needs one continuous write that alternates both
|
|
|
|
|
+expander ports, which the GPIO API cannot express (going through it would
|
|
|
|
|
+cost roughly 2.5-3× more bus time per LCD byte).
|
|
|
|
|
|
|
|
## Wiring
|
|
## Wiring
|
|
|
|
|
|
|
|
-**U1, TCA9539 at 0x74** (A1=L, A0=L), raw I²C client of the panel code
|
|
|
|
|
|
|
+**U1, TCA9539 at 0x74** (A1=L, A0=L), the driver's I²C client:
|
|
|
|
|
|
|
|
| Pin | Signal | Module pin |
|
|
| Pin | Signal | Module pin |
|
|
|
|---|---|---|
|
|
|---|---|---|
|
|
|
| P0.0-7 | D0-D7 | D0-D7 |
|
|
| P0.0-7 | D0-D7 | D0-D7 |
|
|
|
-| P1.0 | Backlight enable (active high, assumed) | |
|
|
|
|
|
|
|
+| P1.0 | Backlight enable (active high) | |
|
|
|
| P1.1 | RES# | RST |
|
|
| P1.1 | RES# | RST |
|
|
|
| P1.2 | A0 | A15 |
|
|
| P1.2 | A0 | A15 |
|
|
|
| P1.3 | WR# | WE |
|
|
| P1.3 | WR# | WE |
|
|
|
| P1.4 | RD# | RE |
|
|
| P1.4 | RD# | RE |
|
|
|
-| P1.5 | CS# (held low after reset; was hardwired low on the old board) | CS0 |
|
|
|
|
|
|
|
+| P1.5 | CS# (held low after reset) | CS0 |
|
|
|
| P1.6-7 | spare | |
|
|
| P1.6-7 | spare | |
|
|
|
|
|
|
|
|
-**U2, TCA9539 at 0x76** (A1=H, A0=L): polled by `radio-ui i2c`, or stock
|
|
|
|
|
-`gpio-pca953x` with the overlay
|
|
|
|
|
|
|
+The pin assignment is fixed in `s1d13700_core.h`.
|
|
|
|
|
|
|
|
-Keys are active high: each pin has a pull-down (the TCA9539 has no internal
|
|
|
|
|
-ones) and its key connects it to the supply. `INT` is not connected on the USB
|
|
|
|
|
-test board, so the keys are polled; the final board wires it to a host GPIO.
|
|
|
|
|
|
|
+**U2, TCA9539 at 0x76** (A1=H, A0=L), optional, for keys: stock
|
|
|
|
|
+`gpio-pca953x` plus `gpio-keys`, as in the device tree examples. Keys are
|
|
|
|
|
+active high, each pin with an external pull-down (the TCA9539 has none) and
|
|
|
|
|
+its key to the supply. `INT` (open drain, active low) goes to a host GPIO;
|
|
|
|
|
+without it, use `gpio-keys-polled`.
|
|
|
|
|
|
|
|
| Pin | Key | Pin | Key |
|
|
| Pin | Key | Pin | Key |
|
|
|
|---|---|---|---|
|
|
|---|---|---|---|
|
|
@@ -187,8 +136,88 @@ test board, so the keys are polled; the final board wires it to a host GPIO.
|
|
|
| | | P1.6 | Play |
|
|
| | | P1.6 | Play |
|
|
|
| | | P1.7 | Prev |
|
|
| | | P1.7 | Prev |
|
|
|
|
|
|
|
|
-## To confirm on hardware
|
|
|
|
|
|
|
+## Device tree
|
|
|
|
|
+
|
|
|
|
|
+`dts/radio-panel.dts` is an overlay written with plain numbers instead of
|
|
|
|
|
+`#include`, so it also works with `armbian-add-overlay`. It targets `i2c0`
|
|
|
|
|
+and puts U2's INT on PA6; check both against the board. For the i2c-dev
|
|
|
|
|
+userspace path, remove its `panel@74` node; with keys polled over i2c-dev,
|
|
|
|
|
+do not load the U2 node either.
|
|
|
|
|
+
|
|
|
|
|
+`dts/examples/orangepi-zero-i2c1.dtsi` is the version in use on the Orange Pi
|
|
|
|
|
+Zero, for inclusion in a board DTS: i2c1 at 400 kHz, panel, U2 with INT on
|
|
|
|
|
+PA6 and the `radio-keys` input device. The two key tables must stay the
|
|
|
|
|
+same; the OPi0 build compares the overlay's with its board DTB.
|
|
|
|
|
+
|
|
|
|
|
+## How it works
|
|
|
|
|
+
|
|
|
|
|
+### Panel core
|
|
|
|
|
+
|
|
|
|
|
+- **Stream encoder.** One write message starts with command byte `0x02`, then
|
|
|
|
|
+ alternates P0 (data) and P1 (control). Each LCD cycle is
|
|
|
|
|
+ `data, WR=0, data, WR=1`. A0 changes get their own P0/P1 pair with WR# high,
|
|
|
|
|
+ because A0 needs setup time before the WR# edge and shares a port with it. A
|
|
|
|
|
+ cycle is never split across messages, so WR# is not left low when the bus is
|
|
|
|
|
+ released.
|
|
|
|
|
+- **Init.** Programs the expander outputs before the directions, holds reset
|
|
|
|
|
+ 20 ms, then configures the controller: `FX=7` and `HDOT=0` (required above
|
|
|
|
|
+ 1 bpp), `CM=1` (required in graphics mode), grayscale value 1. VRAM is
|
|
|
|
|
+ cleared before the display is turned on.
|
|
|
|
|
+- **Planner.** Compares each frame with a shadow of VRAM at byte level, so even
|
|
|
|
|
+ a client that redraws everything costs only what changed. Rows with changes
|
|
|
|
|
+ form bands, each written horizontally or vertically (`CSRDIR` down),
|
|
|
|
|
+ whichever is cheaper. Unchanged gaps up to 6 bytes (the cost of a seek) are
|
|
|
|
|
+ rewritten rather than skipped.
|
|
|
|
|
+- **Cursor.** A memory write turns the controller's cursor on even when the
|
|
|
|
|
+ DISP ON attributes say off (REG[0Ah] note in the hardware specification).
|
|
|
|
|
+ After any update that wrote VRAM while the display is on, the core re-sends
|
|
|
|
|
+ DISP ON (12 I²C bytes).
|
|
|
|
|
+- **Transport.** The caller supplies a send function: `i2c_master_send()` in
|
|
|
|
|
+ the driver, `I2C_RDWR` on i2c-dev, or the simulator.
|
|
|
|
|
+
|
|
|
|
|
+### Simulator
|
|
|
|
|
+
|
|
|
|
|
+Models the TCA9539 register pairs and the S1D13700 indirect interface from the
|
|
|
|
|
+I²C bytes alone. It counts faults: A0 changing with a WR# edge, parameters
|
|
|
|
|
+with no command or too many, unknown commands, bad registers, messages ending
|
|
|
|
|
+between P0 and P1, inconsistent SYSTEM SET, and writes during reset. It also
|
|
|
|
|
+models the cursor behaviour above.
|
|
|
|
|
+
|
|
|
|
|
+### Bus cost
|
|
|
|
|
+
|
|
|
|
|
+| Update (240×160, 2 bpp, 400 kHz) | I²C bytes | Bus time |
|
|
|
|
|
+|---|---|---|
|
|
|
|
|
+| One 8×13 digit | 169 | 3.8 ms |
|
|
|
|
|
+| Full frame | 38 474 (38 messages) | 867 ms |
|
|
|
|
|
+| Typical small UI update | 113-177 | 2.6-4.0 ms |
|
|
|
|
|
+
|
|
|
|
|
+Calculated from the bytes sent on an ideal bus; real timing is slower. The
|
|
|
|
|
+Allwinner `i2c-mv64xxx` takes about one interrupt per byte.
|
|
|
|
|
+
|
|
|
|
|
+## Tests
|
|
|
|
|
+
|
|
|
|
|
+`make test` covers: init values, invalid configurations, no change means no
|
|
|
|
|
+traffic, direction choice, gap merging, 2000 random update rounds at 1/2/4 bpp
|
|
|
|
|
+and message sizes 7/61/1025, transport and backlight failure recovery, lost
|
|
|
|
|
+direction recovery, pixel conversion, the simulator's renderer and its fault
|
|
|
|
|
+detector. They also pass under ASan and UBSan.
|
|
|
|
|
+
|
|
|
|
|
+## Not settled
|
|
|
|
|
+
|
|
|
|
|
+- TC/R and the frame rate: 162 comes from a working AVR 2 bpp setup.
|
|
|
|
|
+- Flicker: the datasheet recommends VRAM access during blanking, which cannot
|
|
|
|
|
+ be synchronised over I²C.
|
|
|
|
|
+- The extra cycle for A0 setup may be removable, saving about a third of the
|
|
|
|
|
+ seek cost.
|
|
|
|
|
+- Only XRGB8888 is exposed; R1/R2 formats could be added.
|
|
|
|
|
+- The backlight name and the U1 pin assignment are fixed in the source.
|
|
|
|
|
+
|
|
|
|
|
+## References
|
|
|
|
|
+
|
|
|
|
|
+- [S1D13700F01 hardware specification, Rev. 4.07](https://global-origin.epson.com/products_and_drivers/semicon/pdf/id003161.pdf)
|
|
|
|
|
+- [TCA9539 datasheet (SCPS202C)](https://www.ti.com/lit/ds/symlink/tca9539.pdf)
|
|
|
|
|
+- In-tree template: `drivers/gpu/drm/sitronix/st7571-i2c.c`
|
|
|
|
|
+
|
|
|
|
|
+## License
|
|
|
|
|
|
|
|
-- TC/R (`--tcr`) for frame rate; 162 comes from the AVR project's 2 bpp setup
|
|
|
|
|
-- Key autorepeat on Up/Down; then the overlay (`evtest`)
|
|
|
|
|
-- The application on the target's Python 3.7.3
|
|
|
|
|
|
|
+GPL-2.0-only (see `LICENSE` and the SPDX headers).
|