* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#ifndef AUDIO_SAPM_H
#define AUDIO_SAPM_H
#include "audio_core.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
enum AudioSapmType {
AUDIO_SAPM_INPUT = 0,
AUDIO_SAPM_OUTPUT,
AUDIO_SAPM_MUX,
AUDIO_SAPM_DEMUX,
AUDIO_SAPM_VIRT_MUX,
AUDIO_SAPM_VALUE_MUX,
AUDIO_SAPM_MIXER,
AUDIO_SAPM_MIXER_NAMED_CTRL,
AUDIO_SAPM_PGA,
AUDIO_SAPM_OUT_DRV,
AUDIO_SAPM_ADC,
AUDIO_SAPM_DAC,
AUDIO_SAPM_MICBIAS,
AUDIO_SAPM_MIC,
AUDIO_SAPM_HP,
AUDIO_SAPM_SPK,
AUDIO_SAPM_LINE,
AUDIO_SAPM_ANALOG_SWITCH,
AUDIO_SAPM_VMID,
AUDIO_SAPM_PRE,
AUDIO_SAPM_POST,
AUDIO_SAPM_SUPPLY,
AUDIO_SAPM_REGULATOR_SUPPLY,
AUDIO_SAPM_CLOCK_SUPPLY,
AUDIO_SAPM_AIF_IN,
AUDIO_SAPM_AIF_OUT,
AUDIO_SAPM_SIGGEN,
AUDIO_SAPM_SINK,
};
enum AudioBiasLevel {
AUDIO_BIAS_OFF = 0,
AUDIO_BIAS_STANDBY = 1,
AUDIO_BIAS_PREPARE = 2,
AUDIO_BIAS_ON = 3,
};
struct AudioSapmContext {
int32_t componentNum;
enum AudioBiasLevel biasLevel;
enum AudioBiasLevel suspendBiasLevel;
struct CodecDevice *codec;
struct PlatformDevice *platform;
struct AudioCard *card;
enum AudioBiasLevel targetBiasLevel;
struct DListHead list;
};
struct AudioEnumKcontrol {
uint32_t reg;
uint32_t reg2;
uint8_t shiftLeft;
uint8_t shiftRight;
uint32_t max;
uint32_t mask;
const char * const *texts;
const uint32_t *values;
void *sapm;
};
struct AudioSapmpath {
char *name;
struct AudioSapmComponent *source;
struct AudioSapmComponent *sink;
struct AudioKcontrol *kcontrol;
uint8_t connect;
uint8_t walked;
uint8_t weak;
int32_t (*connected)(struct AudioSapmComponent *source, struct AudioSapmComponent *sink);
struct DListHead listSource;
struct DListHead listSink;
struct DListHead list;
};
struct AudioSapmComponent {
enum AudioSapmType sapmType;
char *componentName;
char *streamName;
struct AudioSapmContext *sapm;
struct CodecDevice *codec;
struct PlatformDevice *platform;
uint16_t reg;
uint8_t shift;
uint8_t invert;
uint8_t mask;
uint8_t connected;
uint8_t external;
uint8_t active;
uint8_t newPower;
uint8_t power;
uint8_t newCpt;
uint16_t eventFlags;
int32_t (*Event)(struct AudioSapmComponent*, struct AudioKcontrol *, int32_t);
int32_t (*PowerCheck)(const struct AudioSapmComponent *);
int32_t kcontrolsNum;
struct AudioKcontrol *kcontrolNews;
struct AudioKcontrol **kcontrols;
struct DListHead list;
struct DListHead sources;
struct DListHead sinks;
struct DListHead powerList;
struct DListHead dirty;
int32_t (*PowerClockOp)(struct AudioSapmComponent *);
};
struct AudioSapmRoute {
const char *sink;
const char *control;
const char *source;
uint32_t (*Connected)(struct AudioSapmComponent *source,
struct AudioSapmComponent *sink);
};
int32_t AudioSapmNewComponents(struct AudioCard *audioCard,
const struct AudioSapmComponent *component, int32_t cptMaxNum);
int32_t AudioSapmAddRoutes(struct AudioCard *audioCard,
const struct AudioSapmRoute *route, int32_t routeMaxNum);
int32_t AudioSapmNewControls(struct AudioCard *audioCard);
int32_t AudioSapmSleep(struct AudioCard *audioCard);
int32_t AudioSampPowerUp(const struct AudioCard *card);
int32_t AudioSampSetPowerMonitor(struct AudioCard *card, bool powerMonitorState);
int32_t AudioCodecSapmSetCtrlOps(const struct AudioKcontrol *kcontrol, const struct AudioCtrlElemValue *elemValue);
int32_t AudioCodecSapmGetCtrlOps(const struct AudioKcontrol *kcontrol, struct AudioCtrlElemValue *elemValue);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif