1 // Copyright 2017 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #include <fbl/intrusive_wavl_tree.h>
8 #include <fbl/unique_ptr.h>
9 
10 #include "intel_hda_codec.h"
11 #include "intel_hda_device.h"
12 
13 namespace audio {
14 namespace intel_hda {
15 
16 class IntelHDAController : public IntelHDADevice,
17                            public fbl::WAVLTreeContainable<fbl::unique_ptr<IntelHDAController>> {
18 public:
19     using ControllerTree = fbl::WAVLTree<uint32_t, fbl::unique_ptr<IntelHDAController>>;
20 
21     zx_status_t DumpRegs(int argc, const char** argv);
22 
id()23     uint32_t id()     const { return id_; }
GetKey()24     uint32_t GetKey() const { return id(); }
25 
26     static zx_status_t Enumerate();
controllers()27     static ControllerTree& controllers() { return controllers_; }
28 
29 private:
30     friend class fbl::unique_ptr<IntelHDAController>;
31 
IntelHDAController(uint32_t id,const char * const dev_name)32     IntelHDAController(uint32_t id, const char* const dev_name)
33         : IntelHDADevice(dev_name),
34           id_(id) { }
35 
~IntelHDAController()36     ~IntelHDAController() { }
37 
38     const uint32_t id_;
39     static ControllerTree controllers_;
40 };
41 
42 }  // namespace audio
43 }  // namespace intel_hda
44