blob: 7f62ca16addbe2654eb482616a1c608922d1b484 [file] [log] [blame]
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package device
// Hardware describes the physical configuration of a computing device.
type Hardware struct {
// The product name for this hardware.
Name string
// The chipset used for this hardware.
Chipset
}
var (
UnknownHardware = product("unknown", "unknown", UnknownChipset)
productsByCodename = map[string]Hardware{}
productsByName = map[string]Hardware{}
)
func product(codename string, name string, chipset Chipset) Hardware {
product := Hardware{
Name: name,
Chipset: chipset,
}
productsByCodename[codename] = product
productsByName[name] = product
return product
}
// HardwareByName looks up a hardware description by product name.
// If the product is not known, then a hardware object with no cores an an UnknownGPU will be returned.
func HardwareByName(name string) Hardware {
h, ok := productsByCodename[name]
if !ok {
h, ok = productsByName[name]
}
if !ok {
h = Hardware{
Name: name,
Chipset: UnknownChipset,
}
}
return h
}