xref: /freebsd/sys/dev/sound/fdt/audio_dai.h (revision b633e08c705fe43180567eae26923d6f6f98c8d9)
1 /*-
2  * Copyright (c) 2019 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  * $FreeBSD$
25  */
26 
27 #ifndef __DAI_H__
28 #define __DAI_H__
29 
30 #define	AUDIO_DAI_FORMAT_I2S		0
31 #define	AUDIO_DAI_FORMAT_RJ		1
32 #define	AUDIO_DAI_FORMAT_LJ		2
33 #define	AUDIO_DAI_FORMAT_DSPA		3
34 #define	AUDIO_DAI_FORMAT_DSPB		4
35 #define	AUDIO_DAI_FORMAT_AC97		5
36 #define	AUDIO_DAI_FORMAT_PDM		6
37 
38 /*
39  * Polarity: Normal/Inverted BCLK/Frame
40  */
41 #define	AUDIO_DAI_POLARITY_NB_NF	0
42 #define	AUDIO_DAI_POLARITY_NB_IF	1
43 #define	AUDIO_DAI_POLARITY_IB_NF	2
44 #define	AUDIO_DAI_POLARITY_IB_IF	3
45 #define	AUDIO_DAI_POLARITY_INVERTED_FRAME(n)	((n) & 0x01)
46 #define	AUDIO_DAI_POLARITY_INVERTED_BCLK(n)	((n) & 0x2)
47 
48 #define	AUDIO_DAI_CLOCK_CBM_CFM		0
49 #define	AUDIO_DAI_CLOCK_CBS_CFM		1
50 #define	AUDIO_DAI_CLOCK_CBM_CFS		2
51 #define	AUDIO_DAI_CLOCK_CBS_CFS		3
52 
53 #define	AUDIO_DAI_CLOCK_IN		0
54 #define	AUDIO_DAI_CLOCK_OUT		1
55 
56 #define	AUDIO_DAI_JACK_HP		0
57 #define	AUDIO_DAI_JACK_MIC		1
58 
59 /*
60  * Signal to audio_soc that chn_intr required
61  * for either recording or playback
62  */
63 #define	AUDIO_DAI_REC_INTR		(1 << 1)
64 #define	AUDIO_DAI_PLAY_INTR		(1 << 0)
65 
66 #define	AUDIO_DAI_FORMAT(fmt, pol, clk)		(((fmt) << 16) | ((pol) << 8) | (clk))
67 #define	AUDIO_DAI_FORMAT_FORMAT(format)		(((format) >> 16) & 0xff)
68 #define	AUDIO_DAI_FORMAT_POLARITY(format)	(((format) >> 8) & 0xff)
69 #define	AUDIO_DAI_FORMAT_CLOCK(format)		(((format) >> 0) & 0xff)
70 
71 
72 #endif /* __DAI_H__ */
73