summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2019-12-22 18:45:51 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2019-12-23 16:55:11 +0100
commitb908e50023cf0efb6c3fa42059e0c6145b878d98 (patch)
treeb13d0c49191a0010df3a79af32f4446ae457c522
parente71b1668529b2de49fdb77559ead42e153b55829 (diff)
downloadvendor_replicant-scripts-b908e50023cf0efb6c3fa42059e0c6145b878d98.tar.gz
vendor_replicant-scripts-b908e50023cf0efb6c3fa42059e0c6145b878d98.tar.bz2
vendor_replicant-scripts-b908e50023cf0efb6c3fa42059e0c6145b878d98.zip
find_lineageos_devices.py: Improve SOC parsing support
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rwxr-xr-xresearch/find_lineageos_devices.py126
1 files changed, 116 insertions, 10 deletions
diff --git a/research/find_lineageos_devices.py b/research/find_lineageos_devices.py
index 2970b62..cba7785 100755
--- a/research/find_lineageos_devices.py
+++ b/research/find_lineageos_devices.py
@@ -32,6 +32,99 @@ def still_supported(document):
return True
+# In some cases it might be interesting to look if a given device has a modem in
+# the case where the SOC is known not to have any modem, so we can automatically
+# know that the is no shared memory between the modem and the device if there is
+# no modem.
+# Another case would be for SOCs that have optional modems where the device has
+# no modem feature and that we are sure that the modem CPU is not running any code.
+def device_has_modem(vendor, product):
+ if vendor == 'Google' and product == 'Pixel C':
+ return False
+
+ # unknown
+ return None
+
+def soc_has_modem(vendor, product):
+ if vendor == 'HiSilicon':
+ pass
+ elif vendor == 'Intel':
+ pass
+ elif vendor in ['Nvidia', 'NVIDIA'] and re.search("^Tegra 4", product):
+ # The modem could be implemented in software
+ pass
+ elif vendor in ['Nvidia', 'NVIDIA'] and re.search("^Tegra K1", product):
+ pass
+ elif vendor in ['Nvidia', 'NVIDIA'] and re.search("^Tegra X1", product):
+ pass
+ elif vendor == 'Qualcomm' and re.search("^MSM", product):
+ return True
+ elif vendor == 'Qualcomm' and re.search("^APQ", product) or re.search("^Snapdragon 600", product):
+ return False
+ elif vendor == 'Qualcomm' and re.search("^SDM", product):
+ pass
+ elif vendor == 'Qualcomm' and (re.search("^SM", product) or re.search("^sm", product)):
+ pass
+ elif vendor == 'Qualcomm' and re.search("^Snapdragon", product):
+ pass
+ elif vendor == 'Samsung' and re.search("^Exynos", product):
+ # Some exynos modems do exists but they are either standalone
+ # modems or are SOCs where the AP is a Cortex M7 which are very
+ # unlikely to be able to run Android for smartphones or tablets
+ return False
+ elif vendor == 'TI' and product in ['OMAP4430', 'OMAP4460']:
+ # The modem could be implemented in software in the DSP but I never saw
+ # it on any device. It's used like that on the SysmoBTS which are BTS,
+ # not phones or a tablets.
+ return False
+ else:
+ print("<{}|{}>".format(vendor, product))
+ sys.exit(1)
+ # Unknown
+ return None
+
+def parse_soc(soc):
+ soc_vendors = [
+ "HiSilicon",
+ "Intel",
+ "NVIDIA",
+ "Nvidia",
+ "Qualcomm",
+ "Samsung",
+ "TI"]
+
+ soc_vendors_quirks = {
+ # ^Match : Vendor
+ 'Exynos' : 'Samsung',
+ }
+
+ results = {}
+ found = False
+ for vendor in soc_vendors:
+ match = re.search("^{0} (.*)".format(vendor), soc)
+ if match:
+ found = True
+ if vendor == 'NVIDIA':
+ vendor = 'Nvidia'
+ results['vendor'] = vendor
+ results['product'] = match.group(1)
+ results['has_modem'] = soc_has_modem(results['vendor'], results['product'])
+
+ if not found:
+ for match_data, vendor in soc_vendors_quirks.items():
+ match = re.search("^{0} (.*)".format(match_data), soc)
+ if match:
+ found = True
+ results['vendor'] = vendor
+ results['product'] = soc
+ results['has_modem'] = soc_has_modem(results['vendor'], results['product'])
+
+ if not 'vendor' in results:
+ print("TODO: Handle vendor in \"{}\"".format(soc))
+ sys.exit(1)
+
+ return results
+
def battery_is_removable(battery):
# Example: Set top box
if battery == "None" or battery == None:
@@ -100,7 +193,8 @@ def interesting_for_replicant(document):
# For devices without a modem, we would still need to make sure that the
# sound card and the microphone is completely under the control of free
# software and that there aren't too much proprietary libraries to replace
- if re.search("Qualcomm", document['soc']):
+ soc = parse_soc(document['soc'])
+ if soc_has_modem(soc['vendor'], soc['product']) == True:
return False
# Non replaceable batteries causes too much issues for both users
@@ -137,18 +231,30 @@ def store_infos(results, document):
device_dict['removable_battery'] = has_removable_battery(document)
soc = document['soc']
- if not soc in results:
- results[soc] = []
+ soc_data = parse_soc(soc)
+ soc_vendor = None
+ soc_product = None
+
+ if soc_data['vendor'] not in results:
+ results[soc_data['vendor']] = {}
+ soc_vendor = results[soc_data['vendor']]
+
+ if soc_data['product'] not in soc_vendor:
+ soc_vendor[soc_data['product']] = []
+ soc_product = soc_vendor[soc_data['product']]
- results[soc].append(device_dict)
+ soc_product.append(device_dict)
def print_results(results):
- socs = list(results.keys())
- socs.sort()
- for soc in socs:
- print ("{0}:".format(soc))
- for device in results[soc]:
- print ("- {0}:".format(device))
+ soc_vendors = list(results.keys())
+ soc_vendors.sort()
+ for soc_vendor in soc_vendors:
+ print ("{0}:".format(soc_vendor))
+ for soc_product in results[soc_vendor]:
+ print ("- {0}:".format(soc_product))
+ for device in results[soc_vendor][soc_product]:
+ print(" * {0}: {1} ({2})".format(
+ device['vendor'], device['name'], device['type']))
def find_devices(path):
for filename in os.listdir(path + os.sep + basedir):