// SPDX-License-Identifier: GPL-2.0-only
/**
* Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
*
* @File ctmixer.c
*
* @Brief
* This file contains the implementation of alsa mixer device functions.
*
* @Author Liu Chun
* @Date May 28 2008
*/
#include "ctmixer.h"
#include "ctamixer.h"
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/control.h>
#include <sound/asoundef.h>
#include <sound/pcm.h>
#include <sound/tlv.h>
enum CT_SUM_CTL {
SUM_IN_F,
SUM_IN_R,
SUM_IN_C,
SUM_IN_S,
SUM_IN_F_C,
NUM_CT_SUMS
};
enum CT_AMIXER_CTL {
/* volume control mixers */
AMIXER_MASTER_F,
AMIXER_MASTER_R,
AMIXER_MASTER_C,
AMIXER_MASTER_S,
AMIXER_PCM_F,
AMIXER_PCM_R,
AMIXER_PCM_C,
AMIXER_PCM_S,
AMIXER_SPDIFI,
AMIXER_LINEIN,
AMIXER_MIC,
AMIXER_SPDIFO,
AMIXER_WAVE_F,
AMIXER_WAVE_R,
AMIXER_WAVE_C,
AMIXER_WAVE_S,
AMIXER_MASTER_F_C,
AMIXER_PCM_F_C,
AMIXER_SPDIFI_C,
AMIXER_LINEIN_C,
AMIXER_MIC_C,
/* this should always be the last one */
NUM_CT_AMIXERS
};
enum CTALSA_MIXER_CTL {
/* volume control mixers */
MIXER_MASTER_P,
MIXER_PCM_P,
MIXER_LINEIN_P,
MIXER_MIC_P,
MIXER_SPDIFI_P,
MIXER_SPDIFO_P,
MIXER_WAVEF_P,
MIXER_WAVER_P,
MIXER_WAVEC_P,
MIXER_WAVES_P,
MIXER_MASTER_C,
MIXER_PCM_C,
MIXER_LINEIN_C,
MIXER_MIC_C,
MIXER_SPDIFI_C,
/* switch control mixers */
MIXER_PCM_C_S,
MIXER_LINEIN_C_S,
MIXER_MIC_C_S,
MIXER_SPDIFI_C_S,
MIXER_SPDIFO_P_S,
MIXER_WAVEF_P_S,
MIXER_WAVER_P_S,
MIXER_WAVEC_P_S,
MIXER_WAVES_P_S,
MIXER_DIGITAL_IO_S,
MIXER_IEC958_MASK,
MIXER_IEC958_DEFAULT,
MIXER_IEC958_STREAM,
/* this should always be the last one */
NUM_CTALSA_MIXERS
};
#define VOL_MIXER_START MIXER_MASTER_P
#define VOL_MIXER_END MIXER_SPDIFI_C
#define VOL_MIXER_NUM (VOL_MIXER_END - VOL_MIXER_START + 1)
#define SWH_MIXER_START MIXER_PCM_C_S
#define SWH_MIXER_END MIXER_DIGITAL_IO_S
#define SWH_CAPTURE_START MIXER_PCM_C_S
#define SWH_CAPTURE_END MIXER_SPDIFI_C_S
#define CHN_NUM 2
struct ct_kcontrol_init {
unsigned char ctl;
char *name;
};
static struct ct_kcontrol_init
ct_kcontrol_init_table[NUM_CTALSA_MIXERS] = {
[MIXER_MASTER_P] = {
.ctl = 1,
.name = "Master Playback Volume",
},
[MIXER_MASTER_C] = {
.ctl = 1,
.name = "Master Capture Volume",
},
[MIXER_PCM_P] = {
.ctl = 1,
.name = "PCM Playback Volume",
},
[MIXER_PCM_C] = {
.ctl = 1,
.name = "PCM Capture Volume",
},
[MIXER_LINEIN_P] = {
.ctl = 1,
.name = "Line Playback Volume",
},
[MIXER_LINEIN_C] = {
.ctl = 1,
.name = "Line Capture Volume",
},
[MIXER_MIC_P] = {
.ctl = 1,
.name = "Mic Playback Volume",
},
[MIXER_MIC_C] = {
.ctl = 1,
.name = "Mic Capture Volume",
},
[MIXER_SPDIFI_P] = {
.ctl = 1,
.name = "IEC958 Playback Volume",
},
[