Skip to content

Commit 86f5ab4

Browse files
committed
Initial support of 64bit userspace on ARM
1 parent 83c03ed commit 86f5ab4

File tree

8 files changed

+59
-31
lines changed

8 files changed

+59
-31
lines changed

lib/inputstreamhelper/__init__.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .kodiutils import (addon_version, browsesingle, delete, exists, get_proxies, get_setting, get_setting_bool, get_setting_float, get_setting_int, jsonrpc,
1010
kodi_to_ascii, kodi_version, listdir, localize, log, notification, ok_dialog, progress_dialog, select_dialog,
1111
set_setting, set_setting_bool, textviewer, translate_path, yesno_dialog)
12-
from .utils import arch, http_download, parse_version, remove_tree, store, system_os, temp_path, unzip
12+
from .utils import arch, http_download, parse_version, remove_tree, store, system_os, temp_path, unzip, userspace64
1313
from .widevine.arm import dl_extract_widevine, extract_widevine, install_widevine_arm
1414
from .widevine.widevine import (backup_path, has_widevinecdm, ia_cdm_path, install_cdm_from_backup, latest_available_widevine_from_repo,
1515
latest_widevine_version, load_widevine_config, missing_widevine_libs, widevine_config_path, widevine_eula, widevinecdm_path)
@@ -135,19 +135,24 @@ def _enable_inputstream(self):
135135
return False
136136
return True
137137

138-
@staticmethod
139-
def _supports_widevine():
138+
def _supports_widevine(self):
140139
"""Checks if Widevine is supported on the architecture/operating system/Kodi version."""
141140
if arch() not in config.WIDEVINE_SUPPORTED_ARCHS:
142141
log(4, 'Unsupported Widevine architecture found: {arch}', arch=arch())
143142
ok_dialog(localize(30004), localize(30007, arch=arch())) # Widevine not available on this architecture
144143
return False
145144

146-
if arch() == 'arm64' and system_os() != 'Android':
147-
import struct
148-
if struct.calcsize('P') * 8 == 64:
149-
log(4, 'Unsupported 64-bit userspace found. User needs 32-bit userspace on {arch}', arch=arch())
150-
ok_dialog(localize(30004), localize(30039)) # Widevine not available on ARM64
145+
if arch() == 'arm64' and system_os() != 'Android' and userspace64():
146+
is_version = parse_version(addon_version(self.inputstream_addon))
147+
try:
148+
compat_version = parse_version(config.MINIMUM_INPUTSTREAM_VERSION_ARM64[self.inputstream_addon])
149+
except KeyError:
150+
log(4, 'Minimum version of {addon} for 64bit support unknown. Continuing into the unknown...'.format(addon=self.inputstream_addon))
151+
compat_version = parse_version("0.0.0")
152+
153+
if is_version < compat_version:
154+
log(4, 'Unsupported 64bit userspace found. Needs 32bit or newer ISA (currently {v}) on {arch}', arch=arch(), v=is_version)
155+
ok_dialog(localize(30004), localize(30068, addon=self.inputstream_addon, version=compat_version)) # Need newer ISA or 32bit userspace
151156
return False
152157

153158
if system_os() not in config.WIDEVINE_SUPPORTED_OS:

lib/inputstreamhelper/config.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979

8080
CHROMEOS_RECOVERY_URL = 'https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.json'
8181

82-
# To keep the Chrome OS ARM hardware ID list up to date, the following resources can be used:
82+
# To keep the Chrome OS ARM(64) hardware ID list up to date, the following resources can be used:
8383
# https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices
8484
# https://chromiumdash.appspot.com/serving-builds?deviceCategory=Chrome%20OS
85-
# Last updated: 2022-11-17
85+
# Last updated: 2023-03-24
8686
CHROMEOS_RECOVERY_ARM_HWIDS = [
8787
'BOB',
8888
'BURNET',
@@ -106,16 +106,10 @@
106106
'KATSU',
107107
'KENZO-IGRW',
108108
'KEVIN',
109-
'KINGOFTOWN-KDDA',
110109
'KODAMA',
111110
'KRANE-ZDKS',
112-
'LAZOR',
113-
'LIMOZEEN',
114111
'MAKOMO-UTTX',
115-
'PAZQUEL-HGNV',
116-
'PAZQUEL-OPNA',
117112
'PICO-EXEM',
118-
'POMPOM-MZVS',
119113
'QUACKINGSTICK',
120114
'SCARLET',
121115
'SPHERION',
@@ -124,6 +118,19 @@
124118
'WORMDINGLER-JQAO',
125119
]
126120

121+
CHROMEOS_RECOVERY_ARM64_HWIDS = [
122+
'KINGOFTOWN-KDDA',
123+
'LAZOR',
124+
'LIMOZEEN',
125+
'PAZQUEL-HGNV',
126+
'PAZQUEL-OPNA',
127+
'POMPOM-MZVS',
128+
]
129+
130+
MINIMUM_INPUTSTREAM_VERSION_ARM64 = {
131+
'inputstream.adaptive': '20.3.5',
132+
}
133+
127134
CHROMEOS_BLOCK_SIZE = 512
128135

129136
HLS_MINIMUM_IA_VERSION = '2.0.10'

lib/inputstreamhelper/kodiutils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def translate_path(path):
8080
return to_unicode(translatePath(from_unicode(path)))
8181

8282

83-
def get_addon_info(key):
83+
def get_addon_info(key, addon=ADDON):
8484
"""Return addon information"""
85-
return to_unicode(ADDON.getAddonInfo(key))
85+
return to_unicode(addon.getAddonInfo(key))
8686

8787

8888
def addon_id():
@@ -95,9 +95,14 @@ def addon_profile():
9595
return translate_path(get_addon_info('profile'))
9696

9797

98-
def addon_version():
98+
def addon_version(addon_name=None):
9999
"""Cache and return add-on version"""
100-
return get_addon_info('version')
100+
if not addon_name:
101+
addon = ADDON
102+
else:
103+
addon = xbmcaddon.Addon(addon_name)
104+
105+
return get_addon_info('version', addon)
101106

102107

103108
def browsesingle(type, heading, shares='', mask='', useThumbs=False, treatAsFolder=False, defaultt=None): # pylint: disable=invalid-name,redefined-builtin

lib/inputstreamhelper/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from time import time
88
from socket import timeout
99
from ssl import SSLError
10+
import struct
11+
1012

1113
try: # Python 3
1214
from urllib.error import HTTPError, URLError
@@ -311,6 +313,11 @@ def arch():
311313
return sys_arch
312314

313315

316+
def userspace64():
317+
"""To check if userspace is 64bit or 32bit"""
318+
return struct.calcsize('P') * 8 == 64
319+
320+
314321
def hardlink(src, dest):
315322
"""Hardlink a file when possible, copy when needed"""
316323
if exists(dest):

lib/inputstreamhelper/widevine/arm.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88

99
from .. import config
1010
from ..kodiutils import browsesingle, localize, log, ok_dialog, open_file, progress_dialog, yesno_dialog
11-
from ..utils import diskspace, http_download, http_get, parse_version, sizeof_fmt, store, system_os, update_temp_path
11+
from ..utils import diskspace, http_download, http_get, parse_version, sizeof_fmt, store, system_os, update_temp_path, userspace64
1212
from .arm_chromeos import ChromeOSImage
1313

1414

1515
def select_best_chromeos_image(devices):
1616
"""Finds the newest and smallest of the ChromeOS images given"""
1717
log(0, 'Find best ARM image to use from the Chrome OS recovery.json')
1818

19-
arm_hwids = [h for arm_hwid in config.CHROMEOS_RECOVERY_ARM_HWIDS
20-
for h in ['^{} '.format(arm_hwid), '^{}-.*'.format(arm_hwid), '^{}.*'.format(arm_hwid)]]
19+
if userspace64():
20+
arm_hwids = config.CHROMEOS_RECOVERY_ARM64_HWIDS
21+
else:
22+
arm_hwids = config.CHROMEOS_RECOVERY_ARM_HWIDS
23+
24+
arm_hwids = [h for arm_hwid in arm_hwids for h in ['^{} '.format(arm_hwid), '^{}-.*'.format(arm_hwid), '^{}.*'.format(arm_hwid)]]
2125
best = None
2226
for device in devices:
2327
# Select ARM hardware only

resources/language/resource.language.en_gb/strings.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ msgctxt "#30038"
153153
msgid "Install Widevine"
154154
msgstr ""
155155

156-
msgctxt "#30039"
157-
msgid "[B]Widevine CDM[/B] is currently not available natively on ARM64. Please switch to a 32-bit userspace for [B]Widevine CDM[/B] support."
158-
msgstr ""
159-
160156
msgctxt "#30040"
161157
msgid "Update available"
162158
msgstr ""
@@ -265,6 +261,10 @@ msgctxt "#30067"
265261
msgid "Specify the resource Widevine should be extracted from."
266262
msgstr ""
267263

264+
msgctxt "#30068"
265+
msgid "On ARM64 with 64bit userspace, a newer version of {addon} is needed to use [B]Widevine CDM[/B] natively. Please either switch to a 32-bit userspace or install {addon} in version {version} or later."
266+
msgstr ""
267+
268268

269269
### INFORMATION DIALOG
270270
msgctxt "#30800"

tests/checkchromeos.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from __future__ import absolute_import, division, print_function, unicode_literals
55
from xml.etree import ElementTree as ET
66
import requests
7-
from lib.inputstreamhelper.config import CHROMEOS_RECOVERY_ARM_HWIDS
7+
from lib.inputstreamhelper.config import CHROMEOS_RECOVERY_ARM_HWIDS, CHROMEOS_RECOVERY_ARM64_HWIDS
88

99

1010
class OutdatedException(Exception):
@@ -108,11 +108,11 @@ def check_hwids():
108108
if hwid not in hwids:
109109
hwids.append(hwid)
110110

111-
for item in CHROMEOS_RECOVERY_ARM_HWIDS:
111+
for item in CHROMEOS_RECOVERY_ARM_HWIDS + CHROMEOS_RECOVERY_ARM64_HWIDS:
112112
if item not in hwids:
113113
messages.append('{} is end-of-life, consider removing it from inputstreamhelper config'.format(item))
114114
for item in hwids:
115-
if item not in CHROMEOS_RECOVERY_ARM_HWIDS:
115+
if item not in CHROMEOS_RECOVERY_ARM_HWIDS + CHROMEOS_RECOVERY_ARM64_HWIDS:
116116
messages.append('{} is missing, please add it to inputstreamhelper config'.format(item))
117117
if messages:
118118
raise OutdatedException(messages)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ deps =
1414
[flake8]
1515
builtins = func
1616
max-line-length = 160
17-
ignore = E127,E129,FI13,FI50,FI51,FI53,FI54,W503
17+
ignore = E129,FI13,FI50,FI51,FI53,FI54,W503
1818
require-code = True
1919
min-version = 2.7
2020
exclude = .tox,experiment

0 commit comments

Comments
 (0)