Skip to content

Commit 550619e

Browse files
authored
Populate TC358743 EDID file without Ansible (#1616)
Related #1598 In continuing our elimination of Ansible, this reimplements the logic to populate the TC358743 EDID file (at `/home/ustreamer/edids/tc358743-edid.hex`) without Ansible. We preserve the existing behavior that if the user has overridden the desired EDID by specifying a different value for `ustreamer_edid`, then we use that value when we populate `/home/ustreamer/edids/tc358743-edid.hex` on the next install. The output of our `decode_edid` step changes because we're using a different version of the Docker image which seems to pull down a different version of the `decode-edid` which uses slightly different output formatting, but the values are all the same. I was originally bundling this with #1604, but that PR is pretty large since it eliminates Ansible entirely, so I'm pulling out a small piece here. ## Peer testing To test this bundle run: ```bash curl \ --silent \ --show-error \ --location \ https://raw.githubusercontent.com/tiny-pilot/tinypilot/master/scripts/install-bundle | \ sudo bash -s -- \ https://output.circle-artifacts.com/output/job/4a10bf35-34f1-4924-8af3-52f3dea7217a/artifacts/0/bundler/dist/tinypilot-community-20230901T1402Z-1.9.0-77+4903bc6.tgz ``` <a data-ca-tag href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1616"><img src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review on CodeApprove" /></a>
1 parent ed0d1fa commit 550619e

9 files changed

Lines changed: 71 additions & 77 deletions

File tree

.circleci/continue_config.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,22 @@ jobs:
5353
command: ./dev-scripts/check-style
5454
decode_edid:
5555
docker:
56-
- image: cimg/base:2022.02
56+
- image: cimg/python:3.9.17
5757
resource_class: small
5858
steps:
5959
- checkout
6060
- run:
6161
name: Install edid-decode
6262
command: sudo apt-get update && sudo apt-get install --yes edid-decode
6363
- run:
64-
name: Decode the EDID
65-
command: ./dev-scripts/decode-edid
64+
name: Create virtual environment
65+
command: python3 -m venv venv
66+
- run:
67+
name: Install requirements and decode the EDID
68+
command: |
69+
. venv/bin/activate
70+
pip install --requirement requirements.txt
71+
./dev-scripts/decode-edid
6672
build_python:
6773
docker:
6874
- image: cimg/python:3.9.17

ansible-role-ustreamer/defaults/main.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

ansible-role-ustreamer/tasks/provision_tc358743.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
---
2-
- name: create EDIDs folder
3-
file:
4-
path: "{{ ustreamer_edids_dir }}"
5-
state: directory
6-
owner: root
7-
group: root
8-
9-
- name: copy TC358743 EDID file
10-
copy:
11-
content: "{{ ustreamer_edid }}"
12-
dest: "{{ ustreamer_edids_dir }}/tc358743-edid.hex"
13-
owner: "{{ ustreamer_user }}"
14-
group: "{{ ustreamer_group }}"
15-
mode: "0644"
16-
172
- name: install TC358743 initializer service
183
template:
194
src: load-tc358743-edid.systemd.j2

ansible-role-ustreamer/templates/load-tc358743-edid.systemd.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ StartLimitBurst=20
99
Type=oneshot
1010
User=root
1111
ExecStart=v4l2-ctl \
12-
--set-edid=file={{ ustreamer_edids_dir }}/tc358743-edid.hex \
12+
--set-edid=file=/home/ustreamer/edids/tc358743-edid.hex \
1313
--fix-edid-checksums
1414
Restart=on-failure
1515
RestartSec=2

ansible-role-ustreamer/vars/main.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/update/settings.py

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""Manages a TinyPilot update settings file.
22
3-
TinyPilot currently manages most settings through Ansible. When TinyPilot
4-
launches ansible, it passes an extra YAML file that controls properties of the
5-
install and configuration. This module is a wrapper around the YAML file that
6-
allows TinyPilot code to modify it cleanly.
3+
TinyPilot currently manages some of its settings in a database and some of its
4+
settings in a YAML settings file. This module is a wrapper around the YAML
5+
settings file that allows TinyPilot code to modify it cleanly.
76
87
Typical usage example:
98
@@ -19,13 +18,49 @@
1918

2019
_SETTINGS_FILE_PATH = env.abs_path_in_home_dir('settings.yml')
2120

21+
# To create a new EDID:
22+
# 1. Convert the existing EDID to binary using "edid2bin".
23+
# 2. Edit the binary using "AW EDID Editor v.02.00.13".
24+
# 3. Save the new EDID in binary format.
25+
# 4. Convert the binary EDID to a hex EDID using "make-edid".
26+
# - Use the "--yaml" option if required.
27+
28+
# Note: You may need to perform a few extra steps in order for the EDID
29+
# to conform to edid-decode's check - but only if the "Display Range Limits"
30+
# block changes. This is due to a bug in AW EDID Editor v.02.00.13 that doesn't
31+
# set the correct bytes.
32+
# To work around this:
33+
# 1. Open the new EDID in "AW EDID Editor v.3.0.10".
34+
# 2. Save the EDID to set correct bytes in the "Display Range Limits" block
35+
# 3. Re-open the EDID in "AW EDID Editor v.02.00.13" and re-set
36+
# the screen size dimensions to 0 (both vertical and horizontal)
37+
_DEFAULT_TC358743_EDID = '''
38+
00ffffffffffff005262769800888888
39+
2d1e0103800000781aee91a3544c9926
40+
0f50547fef8081c08140810081809500
41+
a9c081406140271f80f07138164038c0
42+
350000000000001eec2c80a070381a40
43+
3020350000000000001e000000fc0054
44+
696e7950696c6f740a202020000000fd
45+
00185a125010000a20202020202001aa
46+
02031ef14b010204131f2021223c3d3e
47+
2309070766030c00300080e2007f0000
48+
00000000000000000000000000000000
49+
00000000000000000000000000000000
50+
00000000000000000000000000000000
51+
00000000000000000000000000000000
52+
00000000000000000000000000000000
53+
0000000000000000000000000000008e
54+
'''.strip()
55+
2256
# Define default values for user-configurable TinyPilot settings. The YAML data
2357
# in _SETTINGS_FILE_PATH take precedence over these defaults.
2458
_DEFAULTS = {
2559
'tinypilot_keyboard_interface': '/dev/hidg0',
2660
'tinypilot_mouse_interface': '/dev/hidg1',
2761
'tinypilot_external_port': 80,
2862
'ustreamer_desired_fps': video_service.DEFAULT_FRAME_RATE,
63+
'ustreamer_edid': _DEFAULT_TC358743_EDID,
2964
'ustreamer_quality': video_service.DEFAULT_MJPEG_QUALITY,
3065
'ustreamer_h264_bitrate': video_service.DEFAULT_H264_BITRATE,
3166
}

app/update/settings_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_as_dict_returns_default_settings_if_no_settings_file_exists(self):
3939
settings_dict = update.settings.load().as_dict()
4040
self.assertEqual('/dev/hidg0',
4141
settings_dict['tinypilot_keyboard_interface'])
42-
self.assertEqual(6, len(settings_dict))
42+
self.assertEqual(7, len(settings_dict))
4343

4444
def test_populates_empty_file_with_blank_settings(self):
4545
self.make_mock_settings_file('')

debian-pkg/debian/tinypilot.postinst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ if grep --silent '^dtoverlay=tc358743$' "${BOOT_CONFIG_PATH}" ; then
106106
else
107107
echo 'gpu_mem=256' | tee --append "${BOOT_CONFIG_PATH}"
108108
fi
109+
110+
# Populate TinyPilot's EDID.
111+
mkdir -p /home/ustreamer/edids
112+
pushd /opt/tinypilot
113+
. venv/bin/activate && \
114+
PYTHONPATH=/opt/tinypilot/app \
115+
./scripts/render-template \
116+
<<< '{{ ustreamer_edid }}' \
117+
> /home/ustreamer/edids/tc358743-edid.hex && \
118+
deactivate
119+
chmod 0644 /home/ustreamer/edids/tc358743-edid.hex
120+
popd
109121
fi
110122

111123
# Populate TinyPilot's Janus settings file.

dev-scripts/decode-edid

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Decode the EDID from the ansible-role-ustreamer defaults.
3+
# Decode the EDID from the TinyPilot install defaults.
44

55
# This script facilitates debugging the EDID and creates helpful logs of EDID
66
# changes in CI.
@@ -14,10 +14,12 @@ set -x
1414
# Exit on unset variable.
1515
set -u
1616

17-
# Extract the EDID from the inline YAML definition.
18-
grep "ustreamer_edid:" -A16 ansible-role-ustreamer/defaults/main.yml | \
19-
`# Strip the line with ustreamer_edid` \
20-
tail --lines=+2 | \
21-
`# Strip whitespace` \
22-
tr --delete "[:blank:]" | \
17+
# Change directory to repository root.
18+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
19+
readonly SCRIPT_DIR
20+
cd "${SCRIPT_DIR}/.."
21+
22+
PYTHONPATH=./app \
23+
./scripts/render-template \
24+
<<< '{{ ustreamer_edid }}' | \
2325
edid-decode --check

0 commit comments

Comments
 (0)