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 <ddk/debug.h> 8#include <ddk/protocol/i2c.h> 9#include <fbl/unique_ptr.h> 10 11namespace audio { 12namespace gauss { 13 14class Tas57xx : public fbl::unique_ptr<Tas57xx>{ 15public: 16 static fbl::unique_ptr<Tas57xx> Create(i2c_protocol_t *i2c, uint32_t index); 17 bool ValidGain(float gain); 18 zx_status_t SetGain(float gain); 19 zx_status_t GetGain(float *gain); 20 zx_status_t Init(uint8_t slot); 21 zx_status_t Reset(); 22 zx_status_t Standby(); 23 zx_status_t ExitStandby(); 24 25private: 26 friend class fbl::unique_ptr<Tas57xx>; 27 static constexpr float kMaxGain = 24.0; 28 static constexpr float kMinGain = -103.0; 29 Tas57xx(); 30 ~Tas57xx(); 31 32 zx_status_t WriteReg(uint8_t reg, uint8_t value); 33 34 zx_status_t SetStandby(bool stdby); 35 36 i2c_protocol_t i2c_; 37 38 float current_gain_ = 0; 39}; 40} // namespace gauss 41} // namespace audio