0001
0002 #ifndef __SOUND_AK4113_H
0003 #define __SOUND_AK4113_H
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #define AK4113_REG_PWRDN 0x00
0014
0015 #define AK4113_REG_FORMAT 0x01
0016
0017 #define AK4113_REG_IO0 0x02
0018
0019 #define AK4113_REG_IO1 0x03
0020
0021 #define AK4113_REG_INT0_MASK 0x04
0022
0023 #define AK4113_REG_INT1_MASK 0x05
0024
0025 #define AK4113_REG_DATDTS 0x06
0026
0027 #define AK4113_REG_RCS0 0x07
0028
0029 #define AK4113_REG_RCS1 0x08
0030
0031 #define AK4113_REG_RCS2 0x09
0032
0033 #define AK4113_REG_RXCSB0 0x0a
0034
0035 #define AK4113_REG_RXCSB1 0x0b
0036
0037 #define AK4113_REG_RXCSB2 0x0c
0038
0039 #define AK4113_REG_RXCSB3 0x0d
0040
0041 #define AK4113_REG_RXCSB4 0x0e
0042
0043 #define AK4113_REG_Pc0 0x0f
0044
0045 #define AK4113_REG_Pc1 0x10
0046
0047 #define AK4113_REG_Pd0 0x11
0048
0049 #define AK4113_REG_Pd1 0x12
0050
0051 #define AK4113_REG_QSUB_ADDR 0x13
0052
0053 #define AK4113_REG_QSUB_TRACK 0x14
0054
0055 #define AK4113_REG_QSUB_INDEX 0x15
0056
0057 #define AK4113_REG_QSUB_MINUTE 0x16
0058
0059 #define AK4113_REG_QSUB_SECOND 0x17
0060
0061 #define AK4113_REG_QSUB_FRAME 0x18
0062
0063 #define AK4113_REG_QSUB_ZERO 0x19
0064
0065 #define AK4113_REG_QSUB_ABSMIN 0x1a
0066
0067 #define AK4113_REG_QSUB_ABSSEC 0x1b
0068
0069 #define AK4113_REG_QSUB_ABSFRM 0x1c
0070
0071
0072 #define AK4113_REG_RXCSB_SIZE ((AK4113_REG_RXCSB4-AK4113_REG_RXCSB0)+1)
0073 #define AK4113_REG_QSUB_SIZE ((AK4113_REG_QSUB_ABSFRM-AK4113_REG_QSUB_ADDR)\
0074 +1)
0075
0076 #define AK4113_WRITABLE_REGS (AK4113_REG_DATDTS + 1)
0077
0078
0079
0080 #define AK4113_CS12 (1<<7)
0081
0082 #define AK4113_BCU (1<<6)
0083
0084 #define AK4113_CM1 (1<<5)
0085
0086 #define AK4113_CM0 (1<<4)
0087
0088 #define AK4113_OCKS1 (1<<3)
0089
0090 #define AK4113_OCKS0 (1<<2)
0091
0092 #define AK4113_PWN (1<<1)
0093
0094 #define AK4113_RST (1<<0)
0095
0096
0097
0098 #define AK4113_VTX (1<<7)
0099
0100 #define AK4113_DIF2 (1<<6)
0101
0102 #define AK4113_DIF1 (1<<5)
0103
0104 #define AK4113_DIF0 (1<<4)
0105
0106 #define AK4113_DEAU (1<<3)
0107
0108 #define AK4113_DEM1 (1<<2)
0109
0110 #define AK4113_DEM0 (1<<1)
0111 #define AK4113_DEM_OFF (AK4113_DEM0)
0112 #define AK4113_DEM_44KHZ (0)
0113 #define AK4113_DEM_48KHZ (AK4113_DEM1)
0114 #define AK4113_DEM_32KHZ (AK4113_DEM0|AK4113_DEM1)
0115
0116 #define AK4113_DIF_16R (0)
0117
0118 #define AK4113_DIF_18R (AK4113_DIF0)
0119
0120 #define AK4113_DIF_20R (AK4113_DIF1)
0121
0122 #define AK4113_DIF_24R (AK4113_DIF1|AK4113_DIF0)
0123
0124 #define AK4113_DIF_24L (AK4113_DIF2)
0125
0126 #define AK4113_DIF_24I2S (AK4113_DIF2|AK4113_DIF0)
0127
0128 #define AK4113_DIF_I24L (AK4113_DIF2|AK4113_DIF1)
0129
0130 #define AK4113_DIF_I24I2S (AK4113_DIF2|AK4113_DIF1|AK4113_DIF0)
0131
0132
0133
0134 #define AK4113_XTL1 (1<<6)
0135
0136 #define AK4113_XTL0 (1<<5)
0137
0138 #define AK4113_UCE (1<<4)
0139
0140 #define AK4113_TXE (1<<3)
0141
0142 #define AK4113_OPS2 (1<<2)
0143
0144 #define AK4113_OPS1 (1<<1)
0145
0146 #define AK4113_OPS0 (1<<0)
0147
0148 #define AK4113_XTL_11_2896M (0)
0149
0150 #define AK4113_XTL_12_288M (AK4113_XTL0)
0151
0152 #define AK4113_XTL_24_576M (AK4113_XTL1)
0153
0154
0155
0156 #define AK4113_EFH1 (1<<7)
0157
0158 #define AK4113_EFH0 (1<<6)
0159 #define AK4113_EFH_512LRCLK (0)
0160 #define AK4113_EFH_1024LRCLK (AK4113_EFH0)
0161 #define AK4113_EFH_2048LRCLK (AK4113_EFH1)
0162 #define AK4113_EFH_4096LRCLK (AK4113_EFH1|AK4113_EFH0)
0163
0164 #define AK4113_FAST (1<<5)
0165
0166 #define AK4113_XMCK (1<<4)
0167
0168 #define AK4113_DIV (1<<3)
0169
0170 #define AK4113_IPS2 (1<<2)
0171
0172 #define AK4113_IPS1 (1<<1)
0173
0174 #define AK4113_IPS0 (1<<0)
0175 #define AK4113_IPS(x) ((x)&7)
0176
0177
0178
0179 #define AK4113_MQI (1<<7)
0180
0181 #define AK4113_MAUT (1<<6)
0182
0183 #define AK4113_MCIT (1<<5)
0184
0185 #define AK4113_MULK (1<<4)
0186
0187 #define AK4113_V (1<<3)
0188
0189 #define AK4113_STC (1<<2)
0190
0191 #define AK4113_MAN (1<<1)
0192
0193 #define AK4113_MPR (1<<0)
0194
0195
0196
0197 #define AK4113_DCNT (1<<4)
0198
0199 #define AK4113_DTS16 (1<<3)
0200
0201 #define AK4113_DTS14 (1<<2)
0202
0203 #define AK4113_MDAT1 (1<<1)
0204
0205 #define AK4113_MDAT0 (1<<0)
0206
0207
0208
0209 #define AK4113_QINT (1<<7)
0210
0211 #define AK4113_AUTO (1<<6)
0212
0213 #define AK4113_CINT (1<<5)
0214
0215 #define AK4113_UNLCK (1<<4)
0216
0217 #define AK4113_V (1<<3)
0218
0219 #define AK4113_STC (1<<2)
0220
0221 #define AK4113_AUDION (1<<1)
0222
0223 #define AK4113_PAR (1<<0)
0224
0225
0226
0227 #define AK4113_FS3 (1<<7)
0228 #define AK4113_FS2 (1<<6)
0229 #define AK4113_FS1 (1<<5)
0230 #define AK4113_FS0 (1<<4)
0231
0232 #define AK4113_PEM (1<<3)
0233
0234 #define AK4113_DAT (1<<2)
0235
0236 #define AK4113_DTSCD (1<<1)
0237
0238 #define AK4113_NPCM (1<<0)
0239 #define AK4113_FS_8000HZ (AK4113_FS3|AK4113_FS0)
0240 #define AK4113_FS_11025HZ (AK4113_FS2|AK4113_FS0)
0241 #define AK4113_FS_16000HZ (AK4113_FS2|AK4113_FS1|AK4113_FS0)
0242 #define AK4113_FS_22050HZ (AK4113_FS2)
0243 #define AK4113_FS_24000HZ (AK4113_FS2|AK4113_FS1)
0244 #define AK4113_FS_32000HZ (AK4113_FS1|AK4113_FS0)
0245 #define AK4113_FS_44100HZ (0)
0246 #define AK4113_FS_48000HZ (AK4113_FS1)
0247 #define AK4113_FS_64000HZ (AK4113_FS3|AK4113_FS1|AK4113_FS0)
0248 #define AK4113_FS_88200HZ (AK4113_FS3)
0249 #define AK4113_FS_96000HZ (AK4113_FS3|AK4113_FS1)
0250 #define AK4113_FS_176400HZ (AK4113_FS3|AK4113_FS2)
0251 #define AK4113_FS_192000HZ (AK4113_FS3|AK4113_FS2|AK4113_FS1)
0252
0253
0254
0255 #define AK4113_QCRC (1<<1)
0256
0257 #define AK4113_CCRC (1<<0)
0258
0259
0260 #define AK4113_CHECK_NO_STAT (1<<0)
0261 #define AK4113_CHECK_NO_RATE (1<<1)
0262
0263 #define AK4113_CONTROLS 13
0264
0265 typedef void (ak4113_write_t)(void *private_data, unsigned char addr,
0266 unsigned char data);
0267 typedef unsigned char (ak4113_read_t)(void *private_data, unsigned char addr);
0268
0269 enum {
0270 AK4113_PARITY_ERRORS,
0271 AK4113_V_BIT_ERRORS,
0272 AK4113_QCRC_ERRORS,
0273 AK4113_CCRC_ERRORS,
0274 AK4113_NUM_ERRORS
0275 };
0276
0277 struct ak4113 {
0278 struct snd_card *card;
0279 ak4113_write_t *write;
0280 ak4113_read_t *read;
0281 void *private_data;
0282 atomic_t wq_processing;
0283 struct mutex reinit_mutex;
0284 spinlock_t lock;
0285 unsigned char regmap[AK4113_WRITABLE_REGS];
0286 struct snd_kcontrol *kctls[AK4113_CONTROLS];
0287 struct snd_pcm_substream *substream;
0288 unsigned long errors[AK4113_NUM_ERRORS];
0289 unsigned char rcs0;
0290 unsigned char rcs1;
0291 unsigned char rcs2;
0292 struct delayed_work work;
0293 unsigned int check_flags;
0294 void *change_callback_private;
0295 void (*change_callback)(struct ak4113 *ak4113, unsigned char c0,
0296 unsigned char c1);
0297 };
0298
0299 int snd_ak4113_create(struct snd_card *card, ak4113_read_t *read,
0300 ak4113_write_t *write,
0301 const unsigned char *pgm,
0302 void *private_data, struct ak4113 **r_ak4113);
0303 void snd_ak4113_reg_write(struct ak4113 *ak4113, unsigned char reg,
0304 unsigned char mask, unsigned char val);
0305 void snd_ak4113_reinit(struct ak4113 *ak4113);
0306 int snd_ak4113_build(struct ak4113 *ak4113,
0307 struct snd_pcm_substream *capture_substream);
0308 int snd_ak4113_external_rate(struct ak4113 *ak4113);
0309 int snd_ak4113_check_rate_and_errors(struct ak4113 *ak4113, unsigned int flags);
0310
0311 #ifdef CONFIG_PM
0312 void snd_ak4113_suspend(struct ak4113 *chip);
0313 void snd_ak4113_resume(struct ak4113 *chip);
0314 #else
0315 static inline void snd_ak4113_suspend(struct ak4113 *chip) {}
0316 static inline void snd_ak4113_resume(struct ak4113 *chip) {}
0317 #endif
0318
0319 #endif
0320