From cc28ac127d558fa68edbc8acb420375bad0bf60a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 24 May 2023 21:57:32 +0200 Subject: [PATCH] Add host1x bus support References: https://gitlab.freedesktop.org/emersion/drm_info/-/commit/c18976c448228c734fc72687a80156f12d52c58c --- database/fs.go | 9 +++++++++ drmtree/drmtree.go | 12 ++++++++++++ server.go | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/database/fs.go b/database/fs.go index a133ec4..b072aad 100644 --- a/database/fs.go +++ b/database/fs.go @@ -48,6 +48,15 @@ func generateKey(n *drmtree.Node) (string, error) { b.WriteByte(0) b.WriteString(compat) } + case *drmtree.DeviceHost1x: + b.WriteString("host1x") + if len(dev.Compatible) == 0 { + return "", fmt.Errorf("host1x device is missing compatibility info") + } + for _, compat := range dev.Compatible { + b.WriteByte(0) + b.WriteString(compat) + } default: return "", fmt.Errorf("device bus type %v not supported", n.Device.BusType) } diff --git a/drmtree/drmtree.go b/drmtree/drmtree.go index 848daff..2698981 100644 --- a/drmtree/drmtree.go +++ b/drmtree/drmtree.go @@ -123,6 +123,10 @@ type DeviceUSB struct { Product uint16 `json:"product"` } +type DeviceHost1x struct { + Compatible []string `json:"compatible"` +} + type Device struct { BusType drm.BusType `json:"bus_type"` DeviceData interface{} `json:"device_data,omitempty"` @@ -156,6 +160,12 @@ func (dev *Device) UnmarshalJSON(b []byte) error { return err } rawDev.DeviceData = &devUSB + case drm.BusHost1x: + var devHost1x DeviceHost1x + if err := json.Unmarshal(deviceData, &devHost1x); err != nil { + return err + } + rawDev.DeviceData = &devHost1x default: rawDev.DeviceData = nil } @@ -172,6 +182,8 @@ func (dev *Device) BusID() string { return strings.Join(dev.Compatible, "+") case *DeviceUSB: return fmt.Sprintf("%04X:%04X", dev.Vendor, dev.Product) + case *DeviceHost1x: + return strings.Join(dev.Compatible, "+") default: return "" } diff --git a/server.go b/server.go index 224f678..c510aa8 100644 --- a/server.go +++ b/server.go @@ -204,7 +204,7 @@ func New() *echo.Echo { case *drmtree.DevicePCI: data.Vendor = pciVendors[uint16(dev.Vendor)] data.Name = pciDevices[dev.Vendor<<16|dev.Device] - case *drmtree.DevicePlatform: + case *drmtree.DevicePlatform, *drmtree.DeviceHost1x: // No-op default: return nil @@ -529,7 +529,7 @@ func New() *echo.Echo { case *drmtree.DevicePCI: data.Vendor = pciVendors[uint16(dev.Vendor)] data.Name = pciDevices[dev.Vendor<<16|dev.Device] - case *drmtree.DevicePlatform: + case *drmtree.DevicePlatform, *drmtree.DeviceHost1x: // No-op default: return nil -- 2.45.2