~emersion/drmdb

2edb80c4907cdd37f206cc25a41e2fddb4cd229a — Simon Ser a month ago 8d22079
Print device vendor/name in device page
3 files changed, 22 insertions(+), 13 deletions(-)

M public/device.html
M server.go
M template.go
M public/device.html => public/device.html +1 -1
@@ 155,7 155,7 @@

	{{with .Device}}
	<li id="device">Device:
		{{.BusType}} {{.BusID}}
		{{.BusType}} {{.BusID}} {{$.DeviceVendor}} {{$.DeviceName}}
	</li>
	{{end}}


M server.go => server.go +18 -9
@@ 13,7 13,6 @@ import (
	"git.sr.ht/~emersion/drmdb/database"
	"git.sr.ht/~emersion/drmdb/drmdoc"
	"git.sr.ht/~emersion/drmdb/drmtree"
	"git.sr.ht/~emersion/drmdb/treefmt"
	"git.sr.ht/~emersion/go-drm"
	"git.sr.ht/~emersion/go-hwids"
	"github.com/labstack/echo/v4"


@@ 249,20 248,30 @@ func New() *echo.Echo {
				return err
			}

			var devVendor, devName string
			if dev, ok := n.Device.DeviceData.(*drmtree.DevicePCI); ok {
				devVendor = pciVendors[uint16(dev.Vendor)]
				devName = pciDevices[dev.Vendor<<16|dev.Device]
			}

			sort.Slice(altDevices, func(i, j int) bool {
				a, b := altDevices[i], altDevices[j]
				return !driverLess(a.Driver, b.Driver)
			})

			tf := treefmt.NewMemoryFormatter()
			n.FormatTree(tf)

			return c.Render(http.StatusOK, "device.html", struct {
				Key        string
				Node       *drmtree.Node
				Tree       []treefmt.Memory
				AltDevices []altDeviceData
			}{key, n, tf.Tree(), altDevices})
				Key          string
				Node         *drmtree.Node
				AltDevices   []altDeviceData
				DeviceVendor string
				DeviceName   string
			}{
				Key:          key,
				Node:         n,
				AltDevices:   altDevices,
				DeviceVendor: devVendor,
				DeviceName:   devName,
			})
		}
	})


M template.go => template.go +3 -3
@@ 6,8 6,8 @@ import (
	"io"
	"strings"

	"github.com/labstack/echo/v4"
	"git.sr.ht/~emersion/go-drm"
	"github.com/labstack/echo/v4"
)

type tmpl struct {


@@ 37,10 37,10 @@ func loadTemplates() (*tmpl, error) {
		"drmModifierHex": func(mod drm.Modifier) string {
			return fmt.Sprintf("0x%X", uint64(mod))
		},
		"bits": func(mask uint32) []int{
		"bits": func(mask uint32) []int {
			var l []int
			for i := 0; i < 32; i++ {
				if mask & (uint32(1) << uint(i)) != 0 {
				if mask&(uint32(1)<<uint(i)) != 0 {
					l = append(l, i)
				}
			}