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
13namespace audio {
14namespace intel_hda {
15
16class IntelHDAController : public IntelHDADevice,
17                           public fbl::WAVLTreeContainable<fbl::unique_ptr<IntelHDAController>> {
18public:
19    using ControllerTree = fbl::WAVLTree<uint32_t, fbl::unique_ptr<IntelHDAController>>;
20
21    zx_status_t DumpRegs(int argc, const char** argv);
22
23    uint32_t id()     const { return id_; }
24    uint32_t GetKey() const { return id(); }
25
26    static zx_status_t Enumerate();
27    static ControllerTree& controllers() { return controllers_; }
28
29private:
30    friend class fbl::unique_ptr<IntelHDAController>;
31
32    IntelHDAController(uint32_t id, const char* const dev_name)
33        : IntelHDADevice(dev_name),
34          id_(id) { }
35
36    ~IntelHDAController() { }
37
38    const uint32_t id_;
39    static ControllerTree controllers_;
40};
41
42}  // namespace audio
43}  // namespace intel_hda
44