mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
Merge branch 'master' of ssh://github.com/fluxer/kdelibs into devinfo
This commit is contained in:
commit
0dcea9d3bd
5 changed files with 42388 additions and 26131 deletions
|
@ -1,17 +1,27 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
|
||||
# pci.ids can be obtained from:
|
||||
# https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids
|
||||
|
||||
import sys
|
||||
|
||||
def isvalidid(fromid):
|
||||
if len(fromid) == 4:
|
||||
return True
|
||||
return False
|
||||
|
||||
def bytetostr(frombytes):
|
||||
return frombytes.decode('utf-8')
|
||||
|
||||
def splitpciline(fromline):
|
||||
doublespaceindex = fromline.index(b' ')
|
||||
lineid = fromline[:doublespaceindex]
|
||||
linename = fromline[doublespaceindex+2:]
|
||||
linename = linename.replace('"', '\\"')
|
||||
# what is the question? (in 2a15)
|
||||
linename = linename.replace('???', 'Unknown')
|
||||
# nested quotes
|
||||
linename = linename.replace(b'"', b'\\"')
|
||||
# what is the question?
|
||||
linename = linename.replace(b'??', b'Unknown') # 036c
|
||||
linename = linename.replace(b'???', b'Unknown') # 2a15
|
||||
return (lineid, linename)
|
||||
|
||||
vendormap = {}
|
||||
|
@ -29,16 +39,26 @@ with open('./pci.ids', 'rb') as f:
|
|||
ingroupsection = True
|
||||
elif line.startswith(b'\t') and not ingroupsection:
|
||||
deviceid, devicename = splitpciline(sline)
|
||||
|
||||
if b' ' in deviceid:
|
||||
print('ranges are not supported: %s' % deviceid)
|
||||
sys.exit(123)
|
||||
devicemap[deviceid] = devicename
|
||||
if not isvalidid(deviceid):
|
||||
continue
|
||||
|
||||
if not vendorid in devicemap.keys():
|
||||
devicemap[vendorid] = []
|
||||
devicemap[vendorid].append({'deviceid': deviceid, 'devicename': devicename })
|
||||
else:
|
||||
ingroupsection = False
|
||||
vendorid, vendorname = splitpciline(sline)
|
||||
|
||||
if b' ' in vendorid:
|
||||
print('ranges are not supported: %s' % vendorid)
|
||||
sys.exit(123)
|
||||
if not isvalidid(vendorid):
|
||||
continue
|
||||
|
||||
vendormap[vendorid] = vendorname
|
||||
|
||||
print('''static const struct pciVendorTblData {
|
||||
|
@ -46,15 +66,17 @@ print('''static const struct pciVendorTblData {
|
|||
const char* const vendorname;
|
||||
} pciVendorTbl[] = {''')
|
||||
for vendorid in vendormap.keys():
|
||||
print(' { "%s", "%s" },' % (vendorid, vendormap[vendorid]))
|
||||
print(' { "%s", "%s" },' % (bytetostr(vendorid), bytetostr(vendormap[vendorid])))
|
||||
print('};')
|
||||
print('static const size_t pciVendorTblSize = sizeof(pciVendorTbl) / sizeof(pciVendorTblData);')
|
||||
print('')
|
||||
print('''static const struct pciDeviceTblData {
|
||||
const char* const vendorid;
|
||||
const char* const deviceid;
|
||||
const char* const devicename;
|
||||
} pciDeviceTbl[] = {''')
|
||||
for deviceid in devicemap.keys():
|
||||
print(' { "%s", "%s" },' % (deviceid, devicemap[deviceid]))
|
||||
for vendorid in devicemap.keys():
|
||||
for devicedict in devicemap[vendorid]:
|
||||
print(' { "%s", "%s", "%s" },' % (bytetostr(vendorid), bytetostr(devicedict['deviceid']), bytetostr(devicedict['devicename'])))
|
||||
print('};')
|
||||
print('static const size_t pciDeviceTblSize = sizeof(pciDeviceTbl) / sizeof(pciDeviceTblData);')
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
|
||||
# usb.ids can be obtained from:
|
||||
# http://www.linux-usb.org/usb.ids
|
||||
|
||||
import sys
|
||||
|
||||
def isvalidid(fromid):
|
||||
if len(fromid) == 4:
|
||||
return True
|
||||
return False
|
||||
|
||||
def bytetostr(frombytes):
|
||||
return frombytes.decode('utf-8')
|
||||
|
||||
def splitusbline(fromline):
|
||||
doublespaceindex = fromline.index(b' ')
|
||||
lineid = fromline[:doublespaceindex]
|
||||
linename = fromline[doublespaceindex+2:]
|
||||
linename = linename.replace('"', '\\"')
|
||||
# what is the question? (in 1183)
|
||||
linename = linename.replace('??', 'Unknown')
|
||||
# invalid escape sequence in C++
|
||||
linename = linename.replace(b'\\', b'/') # 1400
|
||||
# nested quotes
|
||||
linename = linename.replace(b'"', b'\\"')
|
||||
# what is the question?
|
||||
linename = linename.replace(b'??', b'Unknown') # 1183
|
||||
return (lineid, linename)
|
||||
|
||||
vendormap = {}
|
||||
|
@ -29,16 +40,26 @@ with open('./usb.ids', 'rb') as f:
|
|||
ingroupsection = True
|
||||
elif line.startswith(b'\t') and not ingroupsection:
|
||||
deviceid, devicename = splitusbline(sline)
|
||||
|
||||
if b' ' in deviceid:
|
||||
print('ranges are not supported: %s' % deviceid)
|
||||
sys.exit(123)
|
||||
devicemap[deviceid] = devicename
|
||||
if not isvalidid(deviceid):
|
||||
continue
|
||||
|
||||
if not vendorid in devicemap.keys():
|
||||
devicemap[vendorid] = []
|
||||
devicemap[vendorid].append({'deviceid': deviceid, 'devicename': devicename })
|
||||
else:
|
||||
ingroupsection = False
|
||||
vendorid, vendorname = splitusbline(sline)
|
||||
|
||||
if b' ' in vendorid:
|
||||
print('ranges are not supported: %s' % vendorid)
|
||||
sys.exit(123)
|
||||
if not isvalidid(vendorid):
|
||||
continue
|
||||
|
||||
vendormap[vendorid] = vendorname
|
||||
|
||||
print('''static const struct usbVendorTblData {
|
||||
|
@ -46,15 +67,17 @@ print('''static const struct usbVendorTblData {
|
|||
const char* const vendorname;
|
||||
} usbVendorTbl[] = {''')
|
||||
for vendorid in vendormap.keys():
|
||||
print(' { "%s", "%s" },' % (vendorid, vendormap[vendorid]))
|
||||
print(' { "%s", "%s" },' % (bytetostr(vendorid), bytetostr(vendormap[vendorid])))
|
||||
print('};')
|
||||
print('static const size_t usbVendorTblSize = sizeof(usbVendorTbl) / sizeof(usbVendorTblData);')
|
||||
print('')
|
||||
print('''static const struct usbDeviceTblData {
|
||||
const char* const vendorid;
|
||||
const char* const deviceid;
|
||||
const char* const devicename;
|
||||
} usbDeviceTbl[] = {''')
|
||||
for deviceid in devicemap.keys():
|
||||
print(' { "%s", "%s" },' % (deviceid, devicemap[deviceid]))
|
||||
for vendorid in devicemap.keys():
|
||||
for devicedict in devicemap[vendorid]:
|
||||
print(' { "%s", "%s", "%s" },' % (bytetostr(vendorid), bytetostr(devicedict['deviceid']), bytetostr(devicedict['devicename'])))
|
||||
print('};')
|
||||
print('static const size_t usbDeviceTblSize = sizeof(usbDeviceTbl) / sizeof(usbDeviceTblData);')
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -142,13 +142,14 @@ QString UDevDevice::product() const
|
|||
}
|
||||
|
||||
if (product.isEmpty()) {
|
||||
const QByteArray idvendorid(m_device.deviceProperty("ID_VENDOR_ID").toLatin1());
|
||||
const QByteArray idmodelid(m_device.deviceProperty("ID_MODEL_ID").toLatin1());
|
||||
if (!idmodelid.isEmpty()) {
|
||||
if (!idvendorid.isEmpty() && !idmodelid.isEmpty()) {
|
||||
const QString idbus(m_device.deviceProperty("ID_BUS"));
|
||||
if (idbus == QLatin1String("pci")) {
|
||||
product = lookupPCIDevice(idmodelid.constData());
|
||||
product = lookupPCIDevice(idvendorid.constData(), idmodelid.constData());
|
||||
} else if (idbus == QLatin1String("usb")) {
|
||||
product = lookupUSBDevice(idmodelid.constData());
|
||||
product = lookupUSBDevice(idvendorid.constData(), idmodelid.constData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue