summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/audio.h
blob: 5dec00d63e275e86837f30ae5688b28636bf67d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Greybus audio driver
 * Copyright 2015 Google Inc.
 * Copyright 2015 Linaro Ltd.
 *
 * Released under the GPLv2 only.
 */

#ifndef __LINUX_GBAUDIO_H
#define __LINUX_GBAUDIO_H

#ifdef __KERNEL__

#include <sound/soc.h>

#define NAME_SIZE	32

enum {
	APB1_PCM = 0,
	APB2_PCM,
	NUM_CODEC_DAIS,
};

enum gbcodec_reg_index {
	GBCODEC_CTL_REG,
	GBCODEC_MUTE_REG,
	GBCODEC_PB_LVOL_REG,
	GBCODEC_PB_RVOL_REG,
	GBCODEC_CAP_LVOL_REG,
	GBCODEC_CAP_RVOL_REG,
	GBCODEC_APB1_MUX_REG,
	GBCODEC_APB2_MUX_REG,
	GBCODEC_REG_COUNT
};

/* bit 0-SPK, 1-HP, 2-DAC,
 * 4-MIC, 5-HSMIC, 6-MIC2
 */
#define GBCODEC_CTL_REG_DEFAULT		0x00

/* bit 0,1 - APB1-PB-L/R
 * bit 2,3 - APB2-PB-L/R
 * bit 4,5 - APB1-Cap-L/R
 * bit 6,7 - APB2-Cap-L/R
 */
#define	GBCODEC_MUTE_REG_DEFAULT	0x00

/* 0-127 steps */
#define	GBCODEC_PB_VOL_REG_DEFAULT	0x00
#define	GBCODEC_CAP_VOL_REG_DEFAULT	0x00

/* bit 0,1,2 - PB stereo, left, right
 * bit 8,9,10 - Cap stereo, left, right
 */
#define GBCODEC_APB1_MUX_REG_DEFAULT	0x00
#define GBCODEC_APB2_MUX_REG_DEFAULT	0x00

static const u8 gbcodec_reg_defaults[GBCODEC_REG_COUNT] = {
	GBCODEC_CTL_REG_DEFAULT,
	GBCODEC_MUTE_REG_DEFAULT,
	GBCODEC_PB_VOL_REG_DEFAULT,
	GBCODEC_PB_VOL_REG_DEFAULT,
	GBCODEC_CAP_VOL_REG_DEFAULT,
	GBCODEC_CAP_VOL_REG_DEFAULT,
	GBCODEC_APB1_MUX_REG_DEFAULT,
	GBCODEC_APB2_MUX_REG_DEFAULT,
};

struct gbaudio_codec_info {
	struct snd_soc_codec *codec;

	bool usable;
	u8 reg[GBCODEC_REG_COUNT];
	int registered;

	int num_kcontrols;
	int num_dapm_widgets;
	int num_dapm_routes;
	struct snd_kcontrol_new *kctls;
	struct snd_soc_dapm_widget *widgets;
	struct snd_soc_dapm_route *routes;
	struct mutex lock;
};

#endif /* __KERNEL__ */
#endif /* __LINUX_GBAUDIO_H */
OpenPOWER on IntegriCloud