2017-01-06 20:04:04 +01:00
|
|
|
#!/usr/bin/env python3
|
2022-05-10 12:06:48 +02:00
|
|
|
# Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
|
|
|
|
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2017-01-06 20:04:04 +01:00
|
|
|
|
|
|
|
import urllib.request
|
2024-12-18 22:51:57 +01:00
|
|
|
import sys
|
2017-01-06 20:04:04 +01:00
|
|
|
|
2018-08-01 22:40:22 +02:00
|
|
|
# The original source for this data used to be
|
|
|
|
# 'https://git.fedorahosted.org/cgit/hwdata.git/plain/pnp.ids'
|
|
|
|
# which is discontinued. For now there seems to be a fork at:
|
|
|
|
url = 'https://github.com/vcrhonek/hwdata/raw/master/pnp.ids'
|
2024-05-14 12:24:08 +02:00
|
|
|
# REUSE-IgnoreStart
|
2024-12-18 22:51:57 +01:00
|
|
|
copyright = """// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
|
2022-05-10 12:06:48 +02:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
2017-01-06 20:04:04 +01:00
|
|
|
"""
|
2024-05-14 12:24:08 +02:00
|
|
|
# REUSE-IgnoreEnd
|
2017-01-06 20:04:04 +01:00
|
|
|
notice = """/*
|
|
|
|
* This lookup table was generated from {}
|
|
|
|
*
|
2018-08-01 22:40:58 +02:00
|
|
|
* Do not change this file directly, instead edit the
|
2017-01-06 20:04:04 +01:00
|
|
|
* qtbase/util/edid/qedidvendortable.py script and regenerate this file.
|
|
|
|
*/""".format(url)
|
|
|
|
|
|
|
|
header = """
|
|
|
|
#ifndef QEDIDVENDORTABLE_P_H
|
|
|
|
#define QEDIDVENDORTABLE_P_H
|
|
|
|
|
2017-09-07 13:46:15 +02:00
|
|
|
//
|
|
|
|
// W A R N I N G
|
|
|
|
// -------------
|
|
|
|
//
|
2018-01-30 13:52:05 +01:00
|
|
|
// This file is not part of the Qt API. It exists purely as an
|
|
|
|
// implementation detail. This header file may change from version to
|
2017-09-07 13:46:15 +02:00
|
|
|
// version without notice, or even be removed.
|
|
|
|
//
|
2018-01-30 13:52:05 +01:00
|
|
|
// We mean it.
|
|
|
|
//
|
2017-09-07 13:46:15 +02:00
|
|
|
|
2022-02-21 08:03:34 -08:00
|
|
|
#include <QtCore/private/qglobal_p.h>
|
2024-12-18 22:51:57 +01:00
|
|
|
#include <QtCore/qtypes.h>
|
|
|
|
|
|
|
|
#include <iterator>
|
2022-02-21 08:03:34 -08:00
|
|
|
|
2017-01-06 20:04:04 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
2024-12-18 22:51:57 +01:00
|
|
|
"""
|
2017-01-06 20:04:04 +01:00
|
|
|
|
2024-12-18 22:51:57 +01:00
|
|
|
vendorIdHeader = """struct QEdidVendorId {
|
2017-01-06 20:04:04 +01:00
|
|
|
const char id[4];
|
2021-04-20 10:44:48 +02:00
|
|
|
};
|
2017-01-06 20:04:04 +01:00
|
|
|
|
2024-12-18 22:51:57 +01:00
|
|
|
static constexpr QEdidVendorId q_edidVendorIds[] = {"""
|
|
|
|
|
|
|
|
vendorIdFooter = """};
|
|
|
|
"""
|
|
|
|
|
|
|
|
vendorNameHeader = """static constexpr char q_edidVendorNames[] = {"""
|
|
|
|
|
|
|
|
vendorNameFooter = """};
|
|
|
|
"""
|
|
|
|
|
|
|
|
vendorNameOffsetHeader = """static constexpr %s q_edidVendorNamesOffsets[] = {"""
|
|
|
|
|
|
|
|
vendorNameOffsetFooter = """};
|
|
|
|
"""
|
2017-01-06 20:04:04 +01:00
|
|
|
|
2024-12-18 22:51:57 +01:00
|
|
|
footer = """static_assert(std::size(q_edidVendorIds) == std::size(q_edidVendorNamesOffsets));
|
2017-01-06 20:04:04 +01:00
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
#endif // QEDIDVENDORTABLE_P_H"""
|
|
|
|
|
|
|
|
|
2024-12-18 22:51:57 +01:00
|
|
|
# Actual script begins here
|
2017-01-06 20:04:04 +01:00
|
|
|
|
2024-12-18 22:51:57 +01:00
|
|
|
vendors = {}
|
|
|
|
|
|
|
|
vendorNameTotalLength = 0
|
2017-01-06 20:04:04 +01:00
|
|
|
response = urllib.request.urlopen(url)
|
|
|
|
data = response.read().decode('utf-8')
|
|
|
|
for line in data.split('\n'):
|
|
|
|
if line.startswith('#'):
|
|
|
|
continue
|
2024-12-18 22:51:57 +01:00
|
|
|
elif len(line) == 0:
|
|
|
|
continue
|
|
|
|
|
|
|
|
l = line.split('\t', 1)
|
|
|
|
if len(l) == 0:
|
2017-01-06 20:04:04 +01:00
|
|
|
continue
|
2024-12-18 22:51:57 +01:00
|
|
|
|
|
|
|
pnp_id = l[0].upper()
|
|
|
|
if len(pnp_id) != 3:
|
|
|
|
sys.exit("Id '%s' is non-conforming" % pnp_id)
|
|
|
|
vendors[pnp_id] = l[1]
|
|
|
|
vendorNameTotalLength += len(l[1]) + 1
|
|
|
|
|
|
|
|
sortedVendorKeys = sorted(vendors.keys())
|
2017-01-06 20:04:04 +01:00
|
|
|
|
|
|
|
print(copyright)
|
|
|
|
print(notice)
|
2024-12-18 22:51:57 +01:00
|
|
|
print(header)
|
|
|
|
|
|
|
|
print(vendorIdHeader)
|
|
|
|
print(*[(' { "%s" }' % pnp_id) for pnp_id in sortedVendorKeys], sep=",\n")
|
|
|
|
print(vendorIdFooter)
|
|
|
|
|
|
|
|
print(vendorNameHeader)
|
|
|
|
print(*[(' "%s\\0"' % vendors[pnp_id]) for pnp_id in sortedVendorKeys], sep="\n")
|
|
|
|
print(vendorNameFooter)
|
|
|
|
|
|
|
|
if vendorNameTotalLength < 2**16:
|
|
|
|
print(vendorNameOffsetHeader % "quint16")
|
|
|
|
elif vendorNameTotalLength < 2**32:
|
|
|
|
print(vendorNameOffsetHeader % "quint32")
|
|
|
|
else:
|
|
|
|
sys.exit("Vendor name table is too big")
|
|
|
|
|
|
|
|
currentOffset = 0
|
|
|
|
for pnp_id in sortedVendorKeys:
|
|
|
|
vendor = vendors[pnp_id]
|
|
|
|
print(' %d,' % currentOffset)
|
|
|
|
currentOffset += len(vendor) + 1
|
|
|
|
|
|
|
|
print(vendorNameOffsetFooter)
|
|
|
|
|
2017-01-06 20:04:04 +01:00
|
|
|
print(footer)
|