~emersion/drmdb

31ca651fb79e19bcb3c79b2d70eca9c53b6fb807 — Simon Ser 21 days ago aea2c3a master
drmtree: handle USB devices

References: https://github.com/ascent12/drm_info/pull/49
1 files changed, 13 insertions(+), 0 deletions(-)

M drmtree/drmtree.go
M drmtree/drmtree.go => drmtree/drmtree.go +13 -0
@@ 118,6 118,11 @@ type DevicePlatform struct {
	Compatible []string `json:"compatible"`
}

type DeviceUSB struct {
	Vendor  uint16 `json:"vendor"`
	Product uint16 `json:"product"`
}

type Device struct {
	BusType    drm.BusType `json:"bus_type"`
	DeviceData interface{} `json:"device_data,omitempty"`


@@ 145,6 150,12 @@ func (dev *Device) UnmarshalJSON(b []byte) error {
			return err
		}
		rawDev.DeviceData = &devPlatform
	case drm.BusUSB:
		var devUSB DeviceUSB
		if err := json.Unmarshal(deviceData, &devUSB); err != nil {
			return err
		}
		rawDev.DeviceData = &devUSB
	default:
		rawDev.DeviceData = nil
	}


@@ 159,6 170,8 @@ func (dev *Device) BusID() string {
		return fmt.Sprintf("%04X:%04X", dev.Vendor, dev.Device)
	case *DevicePlatform:
		return strings.Join(dev.Compatible, "+")
	case *DeviceUSB:
		return fmt.Sprintf("%04X:%04X", dev.Vendor, dev.Product)
	default:
		return ""
	}