Initial commit
[kernel/linux-3.0.git] / sound / soc / codecs / mc1n2 / mc1n2.h
1 /*
2  * MC-1N2 ASoC codec driver
3  *
4  * Copyright (c) 2010-2011 Yamaha Corporation
5  *
6  * This software is provided 'as-is', without any express or implied
7  * warranty.  In no event will the authors be held liable for any damages
8  * arising from the use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not
15  *    claim that you wrote the original software. If you use this software
16  *    in a product, an acknowledgment in the product documentation would be
17  *    appreciated but is not required.
18  * 2. Altered source versions must be plainly marked as such, and must not be
19  *    misrepresented as being the original software.
20  * 3. This notice may not be removed or altered from any source distribution.
21  */
22
23 #ifndef MC1N2_H
24 #define MC1N2_H
25
26 #include "mcdriver.h"
27 #include <linux/mfd/mc1n2_pdata.h>
28
29 /*
30  * dai: set_sysclk
31  */
32 /* clk_id */
33 #define MC1N2_CLKI              0
34
35 /* default freq for MC1N2_CLKI */
36 #define MC1N2_DEFAULT_CLKI      19200000
37
38 /*
39  * dai: set_clkdiv
40  */
41 /* div_id */
42 #define MC1N2_CKSEL             0
43 #define MC1N2_DIVR0             1
44 #define MC1N2_DIVF0             2
45 #define MC1N2_DIVR1             3
46 #define MC1N2_DIVF1             4
47 #define MC1N2_BCLK_MULT         5
48
49 /* div for MC1N2_BCLK_MULT */
50 #define MC1N2_LRCK_X8           0
51 #define MC1N2_LRCK_X16          1
52 #define MC1N2_LRCK_X24          2
53 #define MC1N2_LRCK_X32          3
54 #define MC1N2_LRCK_X48          4
55 #define MC1N2_LRCK_X64          5
56 #define MC1N2_LRCK_X128         6
57 #define MC1N2_LRCK_X256         7
58 #define MC1N2_LRCK_X512         8
59
60 /*
61  * hwdep: ioctl
62  */
63 #define MC1N2_MAGIC             'N'
64 #define MC1N2_IOCTL_NR_GET      1
65 #define MC1N2_IOCTL_NR_SET      2
66 #define MC1N2_IOCTL_NR_BOTH     3
67 #define MC1N2_IOCTL_NR_NOTIFY   4
68
69 #define MC1N2_IOCTL_GET_CTRL \
70         _IOR(MC1N2_MAGIC, MC1N2_IOCTL_NR_GET, struct mc1n2_ctrl_args)
71 #define MC1N2_IOCTL_SET_CTRL \
72         _IOW(MC1N2_MAGIC, MC1N2_IOCTL_NR_SET, struct mc1n2_ctrl_args)
73
74 #define MC1N2_IOCTL_READ_REG \
75         _IOWR(MC1N2_MAGIC, MC1N2_IOCTL_NR_BOTH, struct mc1n2_ctrl_args)
76
77 #define MC1N2_IOCTL_NOTIFY \
78         _IOW(MC1N2_MAGIC, MC1N2_IOCTL_NR_NOTIFY, struct mc1n2_ctrl_args)
79
80 struct mc1n2_ctrl_args {
81         unsigned long dCmd;
82         void *pvPrm;
83         unsigned long dPrm;
84 };
85
86 /*
87  * MC1N2_IOCTL_NOTIFY dCmd definitions
88  */
89 #define MCDRV_NOTIFY_CALL_START         0x00000000
90 #define MCDRV_NOTIFY_CALL_STOP          0x00000001
91 #define MCDRV_NOTIFY_MEDIA_PLAY_START   0x00000002
92 #define MCDRV_NOTIFY_MEDIA_PLAY_STOP    0x00000003
93 #define MCDRV_NOTIFY_FM_PLAY_START      0x00000004
94 #define MCDRV_NOTIFY_FM_PLAY_STOP       0x00000005
95 #define MCDRV_NOTIFY_BT_SCO_ENABLE      0x00000006
96 #define MCDRV_NOTIFY_BT_SCO_DISABLE     0x00000007
97 #define MCDRV_NOTIFY_VOICE_REC_START    0x00000008
98 #define MCDRV_NOTIFY_VOICE_REC_STOP     0x00000009
99 #define MCDRV_NOTIFY_HDMI_START         0x0000000A
100 #define MCDRV_NOTIFY_HDMI_STOP          0x0000000B
101 #define MCDRV_NOTIFY_RECOVER            0x0000000C
102 #define MCDRV_NOTIFY_2MIC_CALL_START    0x0000000D
103 #define MCDRV_NOTIFY_LINEOUT_START      0x00000010
104 #define MCDRV_NOTIFY_LINEOUT_STOP       0x00000011
105
106 #define MC1N2_MODE_IDLE                 (0x00)
107 #define MC1N2_MODE_CALL_ON              (0x1<<0)
108 #define MC1N2_MODE_FM_ON                (0x1<<1)
109
110 /*
111  * Setup parameters
112  */
113 struct mc1n2_setup {
114         MCDRV_INIT_INFO init;
115         unsigned char pcm_extend[IOPORT_NUM];
116         unsigned char pcm_hiz_redge[IOPORT_NUM];
117         unsigned char pcm_hperiod[IOPORT_NUM];
118         unsigned char slot[IOPORT_NUM][SNDRV_PCM_STREAM_LAST+1][DIO_CHANNELS];
119 };
120
121 /*
122  * Codec Status definitions (for backward compatibility)
123  */
124 #define CMD_CODEC_EMERGENCY_RECOVERY 9 // Emergency recovery for Error like -EIO, -ESTRPIPE, and etc.
125
126 #endif