1808db4a4SRichard Purdie /* 2808db4a4SRichard Purdie * linux/sound/soc.h -- ALSA SoC Layer 3808db4a4SRichard Purdie * 4808db4a4SRichard Purdie * Author: Liam Girdwood 5808db4a4SRichard Purdie * Created: Aug 11th 2005 6808db4a4SRichard Purdie * Copyright: Wolfson Microelectronics. PLC. 7808db4a4SRichard Purdie * 8808db4a4SRichard Purdie * This program is free software; you can redistribute it and/or modify 9808db4a4SRichard Purdie * it under the terms of the GNU General Public License version 2 as 10808db4a4SRichard Purdie * published by the Free Software Foundation. 11808db4a4SRichard Purdie */ 12808db4a4SRichard Purdie 13808db4a4SRichard Purdie #ifndef __LINUX_SND_SOC_H 14808db4a4SRichard Purdie #define __LINUX_SND_SOC_H 15808db4a4SRichard Purdie 16808db4a4SRichard Purdie #include <linux/platform_device.h> 17808db4a4SRichard Purdie #include <linux/types.h> 18d5021ec9SMark Brown #include <linux/notifier.h> 194484bb2eSAndrew Morton #include <linux/workqueue.h> 20ec67624dSLopez Cruz, Misael #include <linux/interrupt.h> 21ec67624dSLopez Cruz, Misael #include <linux/kernel.h> 22808db4a4SRichard Purdie #include <sound/core.h> 23808db4a4SRichard Purdie #include <sound/pcm.h> 24808db4a4SRichard Purdie #include <sound/control.h> 25808db4a4SRichard Purdie #include <sound/ac97_codec.h> 26808db4a4SRichard Purdie 27808db4a4SRichard Purdie /* 28808db4a4SRichard Purdie * Convenience kcontrol builders 29808db4a4SRichard Purdie */ 304eaa9819SJon Smirl #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \ 314eaa9819SJon Smirl ((unsigned long)&(struct soc_mixer_control) \ 32762b8df7SMark Brown {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \ 33d11bb4a9SPeter Ujfalusi .platform_max = xmax, .invert = xinvert}) 344eaa9819SJon Smirl #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \ 354eaa9819SJon Smirl ((unsigned long)&(struct soc_mixer_control) \ 36d11bb4a9SPeter Ujfalusi {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert}) 37a7a4ac86SPhilipp Zabel #define SOC_SINGLE(xname, reg, shift, max, invert) \ 38808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 39808db4a4SRichard Purdie .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ 40808db4a4SRichard Purdie .put = snd_soc_put_volsw, \ 41a7a4ac86SPhilipp Zabel .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } 42a7a4ac86SPhilipp Zabel #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ 43a7a4ac86SPhilipp Zabel { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 44a7a4ac86SPhilipp Zabel .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 45a7a4ac86SPhilipp Zabel SNDRV_CTL_ELEM_ACCESS_READWRITE,\ 46a7a4ac86SPhilipp Zabel .tlv.p = (tlv_array), \ 47a7a4ac86SPhilipp Zabel .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ 48a7a4ac86SPhilipp Zabel .put = snd_soc_put_volsw, \ 49a7a4ac86SPhilipp Zabel .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } 504eaa9819SJon Smirl #define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \ 51808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ 52808db4a4SRichard Purdie .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ 53808db4a4SRichard Purdie .put = snd_soc_put_volsw, \ 544eaa9819SJon Smirl .private_value = (unsigned long)&(struct soc_mixer_control) \ 554eaa9819SJon Smirl {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ 56d11bb4a9SPeter Ujfalusi .max = xmax, .platform_max = xmax, .invert = xinvert} } 574eaa9819SJon Smirl #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ 58808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 59808db4a4SRichard Purdie .info = snd_soc_info_volsw_2r, \ 60808db4a4SRichard Purdie .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ 614eaa9819SJon Smirl .private_value = (unsigned long)&(struct soc_mixer_control) \ 624eaa9819SJon Smirl {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ 63d11bb4a9SPeter Ujfalusi .max = xmax, .platform_max = xmax, .invert = xinvert} } 644eaa9819SJon Smirl #define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \ 65a7a4ac86SPhilipp Zabel { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ 66a7a4ac86SPhilipp Zabel .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 67a7a4ac86SPhilipp Zabel SNDRV_CTL_ELEM_ACCESS_READWRITE,\ 68a7a4ac86SPhilipp Zabel .tlv.p = (tlv_array), \ 69a7a4ac86SPhilipp Zabel .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ 70a7a4ac86SPhilipp Zabel .put = snd_soc_put_volsw, \ 714eaa9819SJon Smirl .private_value = (unsigned long)&(struct soc_mixer_control) \ 724eaa9819SJon Smirl {.reg = xreg, .shift = shift_left, .rshift = shift_right,\ 73d11bb4a9SPeter Ujfalusi .max = xmax, .platform_max = xmax, .invert = xinvert} } 744eaa9819SJon Smirl #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \ 75a7a4ac86SPhilipp Zabel { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ 76a7a4ac86SPhilipp Zabel .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 77a7a4ac86SPhilipp Zabel SNDRV_CTL_ELEM_ACCESS_READWRITE,\ 78a7a4ac86SPhilipp Zabel .tlv.p = (tlv_array), \ 79a7a4ac86SPhilipp Zabel .info = snd_soc_info_volsw_2r, \ 80a7a4ac86SPhilipp Zabel .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ 814eaa9819SJon Smirl .private_value = (unsigned long)&(struct soc_mixer_control) \ 824eaa9819SJon Smirl {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ 83d11bb4a9SPeter Ujfalusi .max = xmax, .platform_max = xmax, .invert = xinvert} } 844eaa9819SJon Smirl #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ 85e13ac2e9SMark Brown { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 86e13ac2e9SMark Brown .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 87e13ac2e9SMark Brown SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 88e13ac2e9SMark Brown .tlv.p = (tlv_array), \ 89e13ac2e9SMark Brown .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \ 90e13ac2e9SMark Brown .put = snd_soc_put_volsw_s8, \ 914eaa9819SJon Smirl .private_value = (unsigned long)&(struct soc_mixer_control) \ 92d11bb4a9SPeter Ujfalusi {.reg = xreg, .min = xmin, .max = xmax, \ 93d11bb4a9SPeter Ujfalusi .platform_max = xmax} } 94f8ba0b7bSJon Smirl #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \ 95808db4a4SRichard Purdie { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ 96f8ba0b7bSJon Smirl .max = xmax, .texts = xtexts } 97f8ba0b7bSJon Smirl #define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \ 98f8ba0b7bSJon Smirl SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts) 99f8ba0b7bSJon Smirl #define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \ 100f8ba0b7bSJon Smirl { .max = xmax, .texts = xtexts } 1012e72f8e3SPeter Ujfalusi #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xmax, xtexts, xvalues) \ 1022e72f8e3SPeter Ujfalusi { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ 1032e72f8e3SPeter Ujfalusi .mask = xmask, .max = xmax, .texts = xtexts, .values = xvalues} 1042e72f8e3SPeter Ujfalusi #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xmax, xtexts, xvalues) \ 1052e72f8e3SPeter Ujfalusi SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xmax, xtexts, xvalues) 106808db4a4SRichard Purdie #define SOC_ENUM(xname, xenum) \ 107808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ 108808db4a4SRichard Purdie .info = snd_soc_info_enum_double, \ 109808db4a4SRichard Purdie .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ 110808db4a4SRichard Purdie .private_value = (unsigned long)&xenum } 1112e72f8e3SPeter Ujfalusi #define SOC_VALUE_ENUM(xname, xenum) \ 1122e72f8e3SPeter Ujfalusi { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ 11374155556SPeter Ujfalusi .info = snd_soc_info_enum_double, \ 1142e72f8e3SPeter Ujfalusi .get = snd_soc_get_value_enum_double, \ 1152e72f8e3SPeter Ujfalusi .put = snd_soc_put_value_enum_double, \ 1162e72f8e3SPeter Ujfalusi .private_value = (unsigned long)&xenum } 117f8ba0b7bSJon Smirl #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\ 118808db4a4SRichard Purdie xhandler_get, xhandler_put) \ 119808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 1201c433fbdSGraeme Gregory .info = snd_soc_info_volsw, \ 121808db4a4SRichard Purdie .get = xhandler_get, .put = xhandler_put, \ 122f8ba0b7bSJon Smirl .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } 1237629ad24SDaniel Mack #define SOC_DOUBLE_EXT(xname, xreg, shift_left, shift_right, xmax, xinvert,\ 1247629ad24SDaniel Mack xhandler_get, xhandler_put) \ 1257629ad24SDaniel Mack { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ 1267629ad24SDaniel Mack .info = snd_soc_info_volsw, \ 1277629ad24SDaniel Mack .get = xhandler_get, .put = xhandler_put, \ 1287629ad24SDaniel Mack .private_value = (unsigned long)&(struct soc_mixer_control) \ 1297629ad24SDaniel Mack {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ 130d11bb4a9SPeter Ujfalusi .max = xmax, .platform_max = xmax, .invert = xinvert} } 131f8ba0b7bSJon Smirl #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ 13210144c09SMike Montour xhandler_get, xhandler_put, tlv_array) \ 13310144c09SMike Montour { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 13410144c09SMike Montour .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 13510144c09SMike Montour SNDRV_CTL_ELEM_ACCESS_READWRITE,\ 13610144c09SMike Montour .tlv.p = (tlv_array), \ 13710144c09SMike Montour .info = snd_soc_info_volsw, \ 13810144c09SMike Montour .get = xhandler_get, .put = xhandler_put, \ 139f8ba0b7bSJon Smirl .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } 140d0af93dbSJoonyoung Shim #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\ 141d0af93dbSJoonyoung Shim xhandler_get, xhandler_put, tlv_array) \ 142d0af93dbSJoonyoung Shim { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 143d0af93dbSJoonyoung Shim .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 144d0af93dbSJoonyoung Shim SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 145d0af93dbSJoonyoung Shim .tlv.p = (tlv_array), \ 146d0af93dbSJoonyoung Shim .info = snd_soc_info_volsw, \ 147d0af93dbSJoonyoung Shim .get = xhandler_get, .put = xhandler_put, \ 148d0af93dbSJoonyoung Shim .private_value = (unsigned long)&(struct soc_mixer_control) \ 149d0af93dbSJoonyoung Shim {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ 150d11bb4a9SPeter Ujfalusi .max = xmax, .platform_max = xmax, .invert = xinvert} } 1513ce91d5aSJoonyoung Shim #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\ 1523ce91d5aSJoonyoung Shim xhandler_get, xhandler_put, tlv_array) \ 1533ce91d5aSJoonyoung Shim { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 1543ce91d5aSJoonyoung Shim .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 1553ce91d5aSJoonyoung Shim SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 1563ce91d5aSJoonyoung Shim .tlv.p = (tlv_array), \ 1573ce91d5aSJoonyoung Shim .info = snd_soc_info_volsw_2r, \ 1583ce91d5aSJoonyoung Shim .get = xhandler_get, .put = xhandler_put, \ 1593ce91d5aSJoonyoung Shim .private_value = (unsigned long)&(struct soc_mixer_control) \ 1603ce91d5aSJoonyoung Shim {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ 161d11bb4a9SPeter Ujfalusi .max = xmax, .platform_max = xmax, .invert = xinvert} } 162808db4a4SRichard Purdie #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ 163808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 164808db4a4SRichard Purdie .info = snd_soc_info_bool_ext, \ 165808db4a4SRichard Purdie .get = xhandler_get, .put = xhandler_put, \ 166808db4a4SRichard Purdie .private_value = xdata } 167808db4a4SRichard Purdie #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \ 168808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 169808db4a4SRichard Purdie .info = snd_soc_info_enum_ext, \ 170808db4a4SRichard Purdie .get = xhandler_get, .put = xhandler_put, \ 171808db4a4SRichard Purdie .private_value = (unsigned long)&xenum } 172808db4a4SRichard Purdie 173b6f4bb38Sapatard@mandriva.com #define SOC_DOUBLE_R_SX_TLV(xname, xreg_left, xreg_right, xshift,\ 174b6f4bb38Sapatard@mandriva.com xmin, xmax, tlv_array) \ 175b6f4bb38Sapatard@mandriva.com { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 176b6f4bb38Sapatard@mandriva.com .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 177b6f4bb38Sapatard@mandriva.com SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 178b6f4bb38Sapatard@mandriva.com .tlv.p = (tlv_array), \ 179b6f4bb38Sapatard@mandriva.com .info = snd_soc_info_volsw_2r_sx, \ 180b6f4bb38Sapatard@mandriva.com .get = snd_soc_get_volsw_2r_sx, \ 181b6f4bb38Sapatard@mandriva.com .put = snd_soc_put_volsw_2r_sx, \ 182b6f4bb38Sapatard@mandriva.com .private_value = (unsigned long)&(struct soc_mixer_control) \ 183b6f4bb38Sapatard@mandriva.com {.reg = xreg_left, \ 184b6f4bb38Sapatard@mandriva.com .rreg = xreg_right, .shift = xshift, \ 185b6f4bb38Sapatard@mandriva.com .min = xmin, .max = xmax} } 186b6f4bb38Sapatard@mandriva.com 187b6f4bb38Sapatard@mandriva.com 188808db4a4SRichard Purdie /* 1896c2fb6a8SGuennadi Liakhovetski * Simplified versions of above macros, declaring a struct and calculating 1906c2fb6a8SGuennadi Liakhovetski * ARRAY_SIZE internally 1916c2fb6a8SGuennadi Liakhovetski */ 1926c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \ 1936c2fb6a8SGuennadi Liakhovetski struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \ 1946c2fb6a8SGuennadi Liakhovetski ARRAY_SIZE(xtexts), xtexts) 1956c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \ 1966c2fb6a8SGuennadi Liakhovetski SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts) 1976c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \ 1986c2fb6a8SGuennadi Liakhovetski struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts) 1996c2fb6a8SGuennadi Liakhovetski #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \ 2006c2fb6a8SGuennadi Liakhovetski struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \ 2016c2fb6a8SGuennadi Liakhovetski ARRAY_SIZE(xtexts), xtexts, xvalues) 2026c2fb6a8SGuennadi Liakhovetski #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \ 2036c2fb6a8SGuennadi Liakhovetski SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues) 2046c2fb6a8SGuennadi Liakhovetski 2056c2fb6a8SGuennadi Liakhovetski /* 2060168bf0dSLiam Girdwood * Component probe and remove ordering levels for components with runtime 2070168bf0dSLiam Girdwood * dependencies. 2080168bf0dSLiam Girdwood */ 2090168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_FIRST -2 2100168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_EARLY -1 2110168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_NORMAL 0 2120168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_LATE 1 2130168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_LAST 2 2140168bf0dSLiam Girdwood 2150168bf0dSLiam Girdwood /* 2160be9898aSMark Brown * Bias levels 2170be9898aSMark Brown * 2180be9898aSMark Brown * @ON: Bias is fully on for audio playback and capture operations. 2190be9898aSMark Brown * @PREPARE: Prepare for audio operations. Called before DAPM switching for 2200be9898aSMark Brown * stream start and stop operations. 2210be9898aSMark Brown * @STANDBY: Low power standby state when no playback/capture operations are 2220be9898aSMark Brown * in progress. NOTE: The transition time between STANDBY and ON 2230be9898aSMark Brown * should be as fast as possible and no longer than 10ms. 2240be9898aSMark Brown * @OFF: Power Off. No restrictions on transition times. 2250be9898aSMark Brown */ 2260be9898aSMark Brown enum snd_soc_bias_level { 22756fba41fSMark Brown SND_SOC_BIAS_OFF = 0, 22856fba41fSMark Brown SND_SOC_BIAS_STANDBY = 1, 22956fba41fSMark Brown SND_SOC_BIAS_PREPARE = 2, 23056fba41fSMark Brown SND_SOC_BIAS_ON = 3, 2310be9898aSMark Brown }; 2320be9898aSMark Brown 2338a2cd618SMark Brown struct snd_jack; 2348a2cd618SMark Brown struct snd_soc_card; 235808db4a4SRichard Purdie struct snd_soc_pcm_stream; 236808db4a4SRichard Purdie struct snd_soc_ops; 237808db4a4SRichard Purdie struct snd_soc_pcm_runtime; 2383c4b266fSLiam Girdwood struct snd_soc_dai; 239f0fba2adSLiam Girdwood struct snd_soc_dai_driver; 24012a48a8cSMark Brown struct snd_soc_platform; 241d273ebe7Sjassi brar struct snd_soc_dai_link; 242f0fba2adSLiam Girdwood struct snd_soc_platform_driver; 243808db4a4SRichard Purdie struct snd_soc_codec; 244f0fba2adSLiam Girdwood struct snd_soc_codec_driver; 245808db4a4SRichard Purdie struct soc_enum; 2468a2cd618SMark Brown struct snd_soc_jack; 247fa9879edSVinod Koul struct snd_soc_jack_zone; 2488a2cd618SMark Brown struct snd_soc_jack_pin; 2497a30a3dbSDimitris Papastamos struct snd_soc_cache_ops; 250ce6120ccSLiam Girdwood #include <sound/soc-dapm.h> 251f0fba2adSLiam Girdwood 252ec67624dSLopez Cruz, Misael #ifdef CONFIG_GPIOLIB 253ec67624dSLopez Cruz, Misael struct snd_soc_jack_gpio; 254ec67624dSLopez Cruz, Misael #endif 255808db4a4SRichard Purdie 256808db4a4SRichard Purdie typedef int (*hw_write_t)(void *,const char* ,int); 257808db4a4SRichard Purdie 258808db4a4SRichard Purdie extern struct snd_ac97_bus_ops soc_ac97_ops; 259808db4a4SRichard Purdie 2607084a42bSMark Brown enum snd_soc_control_type { 261e9c03905SMark Brown SND_SOC_I2C = 1, 2627084a42bSMark Brown SND_SOC_SPI, 2637084a42bSMark Brown }; 2647084a42bSMark Brown 2657a30a3dbSDimitris Papastamos enum snd_soc_compress_type { 266119bd789SDimitris Papastamos SND_SOC_FLAT_COMPRESSION = 1, 267a7f387d5SDimitris Papastamos SND_SOC_LZO_COMPRESSION, 268a7f387d5SDimitris Papastamos SND_SOC_RBTREE_COMPRESSION 2697a30a3dbSDimitris Papastamos }; 2707a30a3dbSDimitris Papastamos 271b8c0dab9SLiam Girdwood enum snd_soc_pcm_subclass { 272b8c0dab9SLiam Girdwood SND_SOC_PCM_CLASS_PCM = 0, 273b8c0dab9SLiam Girdwood SND_SOC_PCM_CLASS_BE = 1, 274b8c0dab9SLiam Girdwood }; 275b8c0dab9SLiam Girdwood 276ec4ee52aSMark Brown int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, 277ec4ee52aSMark Brown unsigned int freq, int dir); 278ec4ee52aSMark Brown int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, 279ec4ee52aSMark Brown unsigned int freq_in, unsigned int freq_out); 280ec4ee52aSMark Brown 28170a7ca34SVinod Koul int snd_soc_register_card(struct snd_soc_card *card); 28270a7ca34SVinod Koul int snd_soc_unregister_card(struct snd_soc_card *card); 2836f8ab4acSMark Brown int snd_soc_suspend(struct device *dev); 2846f8ab4acSMark Brown int snd_soc_resume(struct device *dev); 2856f8ab4acSMark Brown int snd_soc_poweroff(struct device *dev); 286f0fba2adSLiam Girdwood int snd_soc_register_platform(struct device *dev, 287f0fba2adSLiam Girdwood struct snd_soc_platform_driver *platform_drv); 288f0fba2adSLiam Girdwood void snd_soc_unregister_platform(struct device *dev); 289f0fba2adSLiam Girdwood int snd_soc_register_codec(struct device *dev, 290001ae4c0SMark Brown const struct snd_soc_codec_driver *codec_drv, 291f0fba2adSLiam Girdwood struct snd_soc_dai_driver *dai_drv, int num_dai); 292f0fba2adSLiam Girdwood void snd_soc_unregister_codec(struct device *dev); 293181e055eSMark Brown int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, 294181e055eSMark Brown unsigned int reg); 295239c9706SDimitris Papastamos int snd_soc_codec_readable_register(struct snd_soc_codec *codec, 296239c9706SDimitris Papastamos unsigned int reg); 297239c9706SDimitris Papastamos int snd_soc_codec_writable_register(struct snd_soc_codec *codec, 298239c9706SDimitris Papastamos unsigned int reg); 29917a52fd6SMark Brown int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, 3007084a42bSMark Brown int addr_bits, int data_bits, 3017084a42bSMark Brown enum snd_soc_control_type control); 3027a30a3dbSDimitris Papastamos int snd_soc_cache_sync(struct snd_soc_codec *codec); 3037a30a3dbSDimitris Papastamos int snd_soc_cache_init(struct snd_soc_codec *codec); 3047a30a3dbSDimitris Papastamos int snd_soc_cache_exit(struct snd_soc_codec *codec); 3057a30a3dbSDimitris Papastamos int snd_soc_cache_write(struct snd_soc_codec *codec, 3067a30a3dbSDimitris Papastamos unsigned int reg, unsigned int value); 3077a30a3dbSDimitris Papastamos int snd_soc_cache_read(struct snd_soc_codec *codec, 3087a30a3dbSDimitris Papastamos unsigned int reg, unsigned int *value); 309066d16c3SDimitris Papastamos int snd_soc_default_volatile_register(struct snd_soc_codec *codec, 310066d16c3SDimitris Papastamos unsigned int reg); 311066d16c3SDimitris Papastamos int snd_soc_default_readable_register(struct snd_soc_codec *codec, 312066d16c3SDimitris Papastamos unsigned int reg); 3138020454cSDimitris Papastamos int snd_soc_default_writable_register(struct snd_soc_codec *codec, 3148020454cSDimitris Papastamos unsigned int reg); 315f1442bc1SLiam Girdwood int snd_soc_platform_read(struct snd_soc_platform *platform, 316f1442bc1SLiam Girdwood unsigned int reg); 317f1442bc1SLiam Girdwood int snd_soc_platform_write(struct snd_soc_platform *platform, 318f1442bc1SLiam Girdwood unsigned int reg, unsigned int val); 31912a48a8cSMark Brown 3207aae816dSMark Brown /* Utility functions to get clock rates from various things */ 3217aae816dSMark Brown int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); 3227aae816dSMark Brown int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); 323c0fa59dfSMark Brown int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots); 3247aae816dSMark Brown int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms); 3257aae816dSMark Brown 326808db4a4SRichard Purdie /* set runtime hw params */ 327808db4a4SRichard Purdie int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, 328808db4a4SRichard Purdie const struct snd_pcm_hardware *hw); 329808db4a4SRichard Purdie 3308a2cd618SMark Brown /* Jack reporting */ 331f0fba2adSLiam Girdwood int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, 3328a2cd618SMark Brown struct snd_soc_jack *jack); 3338a2cd618SMark Brown void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); 3348a2cd618SMark Brown int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, 3358a2cd618SMark Brown struct snd_soc_jack_pin *pins); 336d5021ec9SMark Brown void snd_soc_jack_notifier_register(struct snd_soc_jack *jack, 337d5021ec9SMark Brown struct notifier_block *nb); 338d5021ec9SMark Brown void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, 339d5021ec9SMark Brown struct notifier_block *nb); 340fa9879edSVinod Koul int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count, 341fa9879edSVinod Koul struct snd_soc_jack_zone *zones); 342fa9879edSVinod Koul int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage); 343ec67624dSLopez Cruz, Misael #ifdef CONFIG_GPIOLIB 344ec67624dSLopez Cruz, Misael int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, 345ec67624dSLopez Cruz, Misael struct snd_soc_jack_gpio *gpios); 346ec67624dSLopez Cruz, Misael void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, 347ec67624dSLopez Cruz, Misael struct snd_soc_jack_gpio *gpios); 348ec67624dSLopez Cruz, Misael #endif 3498a2cd618SMark Brown 350808db4a4SRichard Purdie /* codec register bit access */ 351808db4a4SRichard Purdie int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, 35246f5822fSDaniel Ribeiro unsigned int mask, unsigned int value); 353dd1b3d53SMark Brown int snd_soc_update_bits_locked(struct snd_soc_codec *codec, 354dd1b3d53SMark Brown unsigned short reg, unsigned int mask, 355dd1b3d53SMark Brown unsigned int value); 356808db4a4SRichard Purdie int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, 35746f5822fSDaniel Ribeiro unsigned int mask, unsigned int value); 358808db4a4SRichard Purdie 359808db4a4SRichard Purdie int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, 360808db4a4SRichard Purdie struct snd_ac97_bus_ops *ops, int num); 361808db4a4SRichard Purdie void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); 362808db4a4SRichard Purdie 363808db4a4SRichard Purdie /* 364808db4a4SRichard Purdie *Controls 365808db4a4SRichard Purdie */ 366808db4a4SRichard Purdie struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, 367efb7ac3fSMark Brown void *data, char *long_name, 368efb7ac3fSMark Brown const char *prefix); 3693e8e1952SIan Molton int snd_soc_add_controls(struct snd_soc_codec *codec, 3703e8e1952SIan Molton const struct snd_kcontrol_new *controls, int num_controls); 371a491a5c8SLiam Girdwood int snd_soc_add_platform_controls(struct snd_soc_platform *platform, 372a491a5c8SLiam Girdwood const struct snd_kcontrol_new *controls, int num_controls); 373808db4a4SRichard Purdie int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, 374808db4a4SRichard Purdie struct snd_ctl_elem_info *uinfo); 375808db4a4SRichard Purdie int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, 376808db4a4SRichard Purdie struct snd_ctl_elem_info *uinfo); 377808db4a4SRichard Purdie int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, 378808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol); 379808db4a4SRichard Purdie int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, 380808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol); 3812e72f8e3SPeter Ujfalusi int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol, 3822e72f8e3SPeter Ujfalusi struct snd_ctl_elem_value *ucontrol); 3832e72f8e3SPeter Ujfalusi int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol, 3842e72f8e3SPeter Ujfalusi struct snd_ctl_elem_value *ucontrol); 385808db4a4SRichard Purdie int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, 386808db4a4SRichard Purdie struct snd_ctl_elem_info *uinfo); 387808db4a4SRichard Purdie int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, 388808db4a4SRichard Purdie struct snd_ctl_elem_info *uinfo); 389392abe9cSPhilipp Zabel #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info 390808db4a4SRichard Purdie int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, 391808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol); 392808db4a4SRichard Purdie int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, 393808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol); 394808db4a4SRichard Purdie int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, 395808db4a4SRichard Purdie struct snd_ctl_elem_info *uinfo); 396808db4a4SRichard Purdie int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, 397808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol); 398808db4a4SRichard Purdie int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, 399808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol); 400e13ac2e9SMark Brown int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, 401e13ac2e9SMark Brown struct snd_ctl_elem_info *uinfo); 402e13ac2e9SMark Brown int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, 403e13ac2e9SMark Brown struct snd_ctl_elem_value *ucontrol); 404e13ac2e9SMark Brown int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, 405e13ac2e9SMark Brown struct snd_ctl_elem_value *ucontrol); 406637d3847SPeter Ujfalusi int snd_soc_limit_volume(struct snd_soc_codec *codec, 407637d3847SPeter Ujfalusi const char *name, int max); 408b6f4bb38Sapatard@mandriva.com int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol, 409b6f4bb38Sapatard@mandriva.com struct snd_ctl_elem_info *uinfo); 410b6f4bb38Sapatard@mandriva.com int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol, 411b6f4bb38Sapatard@mandriva.com struct snd_ctl_elem_value *ucontrol); 412b6f4bb38Sapatard@mandriva.com int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, 413b6f4bb38Sapatard@mandriva.com struct snd_ctl_elem_value *ucontrol); 414808db4a4SRichard Purdie 4158a2cd618SMark Brown /** 416066d16c3SDimitris Papastamos * struct snd_soc_reg_access - Describes whether a given register is 417066d16c3SDimitris Papastamos * readable, writable or volatile. 418066d16c3SDimitris Papastamos * 419066d16c3SDimitris Papastamos * @reg: the register number 420066d16c3SDimitris Papastamos * @read: whether this register is readable 421066d16c3SDimitris Papastamos * @write: whether this register is writable 422066d16c3SDimitris Papastamos * @vol: whether this register is volatile 423066d16c3SDimitris Papastamos */ 424066d16c3SDimitris Papastamos struct snd_soc_reg_access { 425066d16c3SDimitris Papastamos u16 reg; 426066d16c3SDimitris Papastamos u16 read; 427066d16c3SDimitris Papastamos u16 write; 428066d16c3SDimitris Papastamos u16 vol; 429066d16c3SDimitris Papastamos }; 430066d16c3SDimitris Papastamos 431066d16c3SDimitris Papastamos /** 4328a2cd618SMark Brown * struct snd_soc_jack_pin - Describes a pin to update based on jack detection 4338a2cd618SMark Brown * 4348a2cd618SMark Brown * @pin: name of the pin to update 4358a2cd618SMark Brown * @mask: bits to check for in reported jack status 4368a2cd618SMark Brown * @invert: if non-zero then pin is enabled when status is not reported 4378a2cd618SMark Brown */ 4388a2cd618SMark Brown struct snd_soc_jack_pin { 4398a2cd618SMark Brown struct list_head list; 4408a2cd618SMark Brown const char *pin; 4418a2cd618SMark Brown int mask; 4428a2cd618SMark Brown bool invert; 4438a2cd618SMark Brown }; 4448a2cd618SMark Brown 445ec67624dSLopez Cruz, Misael /** 446fa9879edSVinod Koul * struct snd_soc_jack_zone - Describes voltage zones of jack detection 447fa9879edSVinod Koul * 448fa9879edSVinod Koul * @min_mv: start voltage in mv 449fa9879edSVinod Koul * @max_mv: end voltage in mv 450fa9879edSVinod Koul * @jack_type: type of jack that is expected for this voltage 451fa9879edSVinod Koul * @debounce_time: debounce_time for jack, codec driver should wait for this 452fa9879edSVinod Koul * duration before reading the adc for voltages 453fa9879edSVinod Koul * @:list: list container 454fa9879edSVinod Koul */ 455fa9879edSVinod Koul struct snd_soc_jack_zone { 456fa9879edSVinod Koul unsigned int min_mv; 457fa9879edSVinod Koul unsigned int max_mv; 458fa9879edSVinod Koul unsigned int jack_type; 459fa9879edSVinod Koul unsigned int debounce_time; 460fa9879edSVinod Koul struct list_head list; 461fa9879edSVinod Koul }; 462fa9879edSVinod Koul 463fa9879edSVinod Koul /** 464ec67624dSLopez Cruz, Misael * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection 465ec67624dSLopez Cruz, Misael * 466ec67624dSLopez Cruz, Misael * @gpio: gpio number 467ec67624dSLopez Cruz, Misael * @name: gpio name 468ec67624dSLopez Cruz, Misael * @report: value to report when jack detected 469ec67624dSLopez Cruz, Misael * @invert: report presence in low state 470ec67624dSLopez Cruz, Misael * @debouce_time: debouce time in ms 4717887ab3aSMark Brown * @wake: enable as wake source 472fadddc87SMark Brown * @jack_status_check: callback function which overrides the detection 473fadddc87SMark Brown * to provide more complex checks (eg, reading an 474fadddc87SMark Brown * ADC). 475ec67624dSLopez Cruz, Misael */ 476ec67624dSLopez Cruz, Misael #ifdef CONFIG_GPIOLIB 477ec67624dSLopez Cruz, Misael struct snd_soc_jack_gpio { 478ec67624dSLopez Cruz, Misael unsigned int gpio; 479ec67624dSLopez Cruz, Misael const char *name; 480ec67624dSLopez Cruz, Misael int report; 481ec67624dSLopez Cruz, Misael int invert; 482ec67624dSLopez Cruz, Misael int debounce_time; 4837887ab3aSMark Brown bool wake; 4847887ab3aSMark Brown 485ec67624dSLopez Cruz, Misael struct snd_soc_jack *jack; 4864c14d78eSMark Brown struct delayed_work work; 487c871a053SJoonyoung Shim 488c871a053SJoonyoung Shim int (*jack_status_check)(void); 489ec67624dSLopez Cruz, Misael }; 490ec67624dSLopez Cruz, Misael #endif 491ec67624dSLopez Cruz, Misael 4928a2cd618SMark Brown struct snd_soc_jack { 4938a2cd618SMark Brown struct snd_jack *jack; 494f0fba2adSLiam Girdwood struct snd_soc_codec *codec; 4958a2cd618SMark Brown struct list_head pins; 4968a2cd618SMark Brown int status; 497d5021ec9SMark Brown struct blocking_notifier_head notifier; 498fa9879edSVinod Koul struct list_head jack_zones; 4998a2cd618SMark Brown }; 5008a2cd618SMark Brown 501808db4a4SRichard Purdie /* SoC PCM stream information */ 502808db4a4SRichard Purdie struct snd_soc_pcm_stream { 503f0fba2adSLiam Girdwood const char *stream_name; 5041c433fbdSGraeme Gregory u64 formats; /* SNDRV_PCM_FMTBIT_* */ 5051c433fbdSGraeme Gregory unsigned int rates; /* SNDRV_PCM_RATE_* */ 506808db4a4SRichard Purdie unsigned int rate_min; /* min rate */ 507808db4a4SRichard Purdie unsigned int rate_max; /* max rate */ 508808db4a4SRichard Purdie unsigned int channels_min; /* min channels */ 509808db4a4SRichard Purdie unsigned int channels_max; /* max channels */ 510808db4a4SRichard Purdie }; 511808db4a4SRichard Purdie 512808db4a4SRichard Purdie /* SoC audio ops */ 513808db4a4SRichard Purdie struct snd_soc_ops { 514808db4a4SRichard Purdie int (*startup)(struct snd_pcm_substream *); 515808db4a4SRichard Purdie void (*shutdown)(struct snd_pcm_substream *); 516808db4a4SRichard Purdie int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); 517808db4a4SRichard Purdie int (*hw_free)(struct snd_pcm_substream *); 518808db4a4SRichard Purdie int (*prepare)(struct snd_pcm_substream *); 519808db4a4SRichard Purdie int (*trigger)(struct snd_pcm_substream *, int); 520808db4a4SRichard Purdie }; 521808db4a4SRichard Purdie 5227a30a3dbSDimitris Papastamos /* SoC cache ops */ 5237a30a3dbSDimitris Papastamos struct snd_soc_cache_ops { 5240d735eaaSDimitris Papastamos const char *name; 5257a30a3dbSDimitris Papastamos enum snd_soc_compress_type id; 5267a30a3dbSDimitris Papastamos int (*init)(struct snd_soc_codec *codec); 5277a30a3dbSDimitris Papastamos int (*exit)(struct snd_soc_codec *codec); 5287a30a3dbSDimitris Papastamos int (*read)(struct snd_soc_codec *codec, unsigned int reg, 5297a30a3dbSDimitris Papastamos unsigned int *value); 5307a30a3dbSDimitris Papastamos int (*write)(struct snd_soc_codec *codec, unsigned int reg, 5317a30a3dbSDimitris Papastamos unsigned int value); 5327a30a3dbSDimitris Papastamos int (*sync)(struct snd_soc_codec *codec); 5337a30a3dbSDimitris Papastamos }; 5347a30a3dbSDimitris Papastamos 535f0fba2adSLiam Girdwood /* SoC Audio Codec device */ 536808db4a4SRichard Purdie struct snd_soc_codec { 537f0fba2adSLiam Girdwood const char *name; 538ead9b919SJarkko Nikula const char *name_prefix; 539f0fba2adSLiam Girdwood int id; 5400d0cf00aSMark Brown struct device *dev; 541001ae4c0SMark Brown const struct snd_soc_codec_driver *driver; 5420d0cf00aSMark Brown 543f0fba2adSLiam Girdwood struct mutex mutex; 544f0fba2adSLiam Girdwood struct snd_soc_card *card; 5450d0cf00aSMark Brown struct list_head list; 546f0fba2adSLiam Girdwood struct list_head card_list; 547f0fba2adSLiam Girdwood int num_dai; 54823bbce34SDimitris Papastamos enum snd_soc_compress_type compress_type; 549aea170a0SDimitris Papastamos size_t reg_size; /* reg_cache_size * reg_word_size */ 5501500b7b5SDimitris Papastamos int (*volatile_register)(struct snd_soc_codec *, unsigned int); 5511500b7b5SDimitris Papastamos int (*readable_register)(struct snd_soc_codec *, unsigned int); 5528020454cSDimitris Papastamos int (*writable_register)(struct snd_soc_codec *, unsigned int); 553808db4a4SRichard Purdie 554808db4a4SRichard Purdie /* runtime */ 555808db4a4SRichard Purdie struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ 556808db4a4SRichard Purdie unsigned int active; 557dad8e7aeSDimitris Papastamos unsigned int cache_bypass:1; /* Suppress access to the cache */ 558f0fba2adSLiam Girdwood unsigned int suspended:1; /* Codec is in suspend PM state */ 559f0fba2adSLiam Girdwood unsigned int probed:1; /* Codec has been probed */ 560f0fba2adSLiam Girdwood unsigned int ac97_registered:1; /* Codec has been AC97 registered */ 5610562f788SMika Westerberg unsigned int ac97_created:1; /* Codec has been created by SoC */ 562f0fba2adSLiam Girdwood unsigned int sysfs_registered:1; /* codec has been sysfs registered */ 563fdf0f54dSDimitris Papastamos unsigned int cache_init:1; /* codec cache has been initialized */ 564aaee8ef1SMark Brown u32 cache_only; /* Suppress writes to hardware */ 565aaee8ef1SMark Brown u32 cache_sync; /* Cache needs to be synced to hardware */ 566f0fba2adSLiam Girdwood 567f0fba2adSLiam Girdwood /* codec IO */ 568f0fba2adSLiam Girdwood void *control_data; /* codec control (i2c/3wire) data */ 56967850a89SDimitris Papastamos enum snd_soc_control_type control_type; 570f0fba2adSLiam Girdwood hw_write_t hw_write; 571f0fba2adSLiam Girdwood unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); 572c3acec26SMark Brown unsigned int (*read)(struct snd_soc_codec *, unsigned int); 573c3acec26SMark Brown int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); 5745fb609d4SDimitris Papastamos int (*bulk_write_raw)(struct snd_soc_codec *, unsigned int, const void *, size_t); 575f0fba2adSLiam Girdwood void *reg_cache; 5763335ddcaSDimitris Papastamos const void *reg_def_copy; 5777a30a3dbSDimitris Papastamos const struct snd_soc_cache_ops *cache_ops; 5787a30a3dbSDimitris Papastamos struct mutex cache_rw_mutex; 579a96ca338SMark Brown 580808db4a4SRichard Purdie /* dapm */ 581ce6120ccSLiam Girdwood struct snd_soc_dapm_context dapm; 582808db4a4SRichard Purdie 583384c89e2SMark Brown #ifdef CONFIG_DEBUG_FS 58488439ac7SPeter Ujfalusi struct dentry *debugfs_codec_root; 585384c89e2SMark Brown struct dentry *debugfs_reg; 58679fb9387SMark Brown struct dentry *debugfs_dapm; 587384c89e2SMark Brown #endif 588808db4a4SRichard Purdie }; 589808db4a4SRichard Purdie 590f0fba2adSLiam Girdwood /* codec driver */ 591f0fba2adSLiam Girdwood struct snd_soc_codec_driver { 592f0fba2adSLiam Girdwood 593f0fba2adSLiam Girdwood /* driver ops */ 594f0fba2adSLiam Girdwood int (*probe)(struct snd_soc_codec *); 595f0fba2adSLiam Girdwood int (*remove)(struct snd_soc_codec *); 596f0fba2adSLiam Girdwood int (*suspend)(struct snd_soc_codec *, 597f0fba2adSLiam Girdwood pm_message_t state); 598f0fba2adSLiam Girdwood int (*resume)(struct snd_soc_codec *); 599f0fba2adSLiam Girdwood 600b7af1dafSMark Brown /* Default control and setup, added after probe() is run */ 601b7af1dafSMark Brown const struct snd_kcontrol_new *controls; 602b7af1dafSMark Brown int num_controls; 60389b95ac0SMark Brown const struct snd_soc_dapm_widget *dapm_widgets; 60489b95ac0SMark Brown int num_dapm_widgets; 60589b95ac0SMark Brown const struct snd_soc_dapm_route *dapm_routes; 60689b95ac0SMark Brown int num_dapm_routes; 60789b95ac0SMark Brown 608ec4ee52aSMark Brown /* codec wide operations */ 609ec4ee52aSMark Brown int (*set_sysclk)(struct snd_soc_codec *codec, 610ec4ee52aSMark Brown int clk_id, unsigned int freq, int dir); 611ec4ee52aSMark Brown int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, 612ec4ee52aSMark Brown unsigned int freq_in, unsigned int freq_out); 613ec4ee52aSMark Brown 614f0fba2adSLiam Girdwood /* codec IO */ 615f0fba2adSLiam Girdwood unsigned int (*read)(struct snd_soc_codec *, unsigned int); 616f0fba2adSLiam Girdwood int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); 617f0fba2adSLiam Girdwood int (*display_register)(struct snd_soc_codec *, char *, 618f0fba2adSLiam Girdwood size_t, unsigned int); 619d4754ec9SDimitris Papastamos int (*volatile_register)(struct snd_soc_codec *, unsigned int); 620d4754ec9SDimitris Papastamos int (*readable_register)(struct snd_soc_codec *, unsigned int); 6218020454cSDimitris Papastamos int (*writable_register)(struct snd_soc_codec *, unsigned int); 622f0fba2adSLiam Girdwood short reg_cache_size; 623f0fba2adSLiam Girdwood short reg_cache_step; 624f0fba2adSLiam Girdwood short reg_word_size; 625f0fba2adSLiam Girdwood const void *reg_cache_default; 626066d16c3SDimitris Papastamos short reg_access_size; 627066d16c3SDimitris Papastamos const struct snd_soc_reg_access *reg_access_default; 6287a30a3dbSDimitris Papastamos enum snd_soc_compress_type compress_type; 629f0fba2adSLiam Girdwood 630f0fba2adSLiam Girdwood /* codec bias level */ 631f0fba2adSLiam Girdwood int (*set_bias_level)(struct snd_soc_codec *, 632f0fba2adSLiam Girdwood enum snd_soc_bias_level level); 633474b62d6SMark Brown 634474b62d6SMark Brown void (*seq_notifier)(struct snd_soc_dapm_context *, 635f85a9e0dSMark Brown enum snd_soc_dapm_type, int); 6360168bf0dSLiam Girdwood 6370168bf0dSLiam Girdwood /* probe ordering - for components with runtime dependencies */ 6380168bf0dSLiam Girdwood int probe_order; 6390168bf0dSLiam Girdwood int remove_order; 640808db4a4SRichard Purdie }; 641808db4a4SRichard Purdie 642808db4a4SRichard Purdie /* SoC platform interface */ 643f0fba2adSLiam Girdwood struct snd_soc_platform_driver { 644808db4a4SRichard Purdie 645f0fba2adSLiam Girdwood int (*probe)(struct snd_soc_platform *); 646f0fba2adSLiam Girdwood int (*remove)(struct snd_soc_platform *); 647f0fba2adSLiam Girdwood int (*suspend)(struct snd_soc_dai *dai); 648f0fba2adSLiam Girdwood int (*resume)(struct snd_soc_dai *dai); 649808db4a4SRichard Purdie 650808db4a4SRichard Purdie /* pcm creation and destruction */ 651552d1ef6SLiam Girdwood int (*pcm_new)(struct snd_soc_pcm_runtime *); 652808db4a4SRichard Purdie void (*pcm_free)(struct snd_pcm *); 653808db4a4SRichard Purdie 654*cb2cf612SLiam Girdwood /* Default control and setup, added after probe() is run */ 655*cb2cf612SLiam Girdwood const struct snd_kcontrol_new *controls; 656*cb2cf612SLiam Girdwood int num_controls; 657*cb2cf612SLiam Girdwood const struct snd_soc_dapm_widget *dapm_widgets; 658*cb2cf612SLiam Girdwood int num_dapm_widgets; 659*cb2cf612SLiam Girdwood const struct snd_soc_dapm_route *dapm_routes; 660*cb2cf612SLiam Girdwood int num_dapm_routes; 661*cb2cf612SLiam Girdwood 662258020d0SPeter Ujfalusi /* 663258020d0SPeter Ujfalusi * For platform caused delay reporting. 664258020d0SPeter Ujfalusi * Optional. 665258020d0SPeter Ujfalusi */ 666258020d0SPeter Ujfalusi snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *, 667258020d0SPeter Ujfalusi struct snd_soc_dai *); 668258020d0SPeter Ujfalusi 669808db4a4SRichard Purdie /* platform stream ops */ 670f0fba2adSLiam Girdwood struct snd_pcm_ops *ops; 6710168bf0dSLiam Girdwood 6720168bf0dSLiam Girdwood /* probe ordering - for components with runtime dependencies */ 6730168bf0dSLiam Girdwood int probe_order; 6740168bf0dSLiam Girdwood int remove_order; 675f1442bc1SLiam Girdwood 676f1442bc1SLiam Girdwood /* platform IO - used for platform DAPM */ 677f1442bc1SLiam Girdwood unsigned int (*read)(struct snd_soc_platform *, unsigned int); 678f1442bc1SLiam Girdwood int (*write)(struct snd_soc_platform *, unsigned int, unsigned int); 679808db4a4SRichard Purdie }; 680808db4a4SRichard Purdie 681f0fba2adSLiam Girdwood struct snd_soc_platform { 682f0fba2adSLiam Girdwood const char *name; 683f0fba2adSLiam Girdwood int id; 684f0fba2adSLiam Girdwood struct device *dev; 685f0fba2adSLiam Girdwood struct snd_soc_platform_driver *driver; 686f0fba2adSLiam Girdwood 687f0fba2adSLiam Girdwood unsigned int suspended:1; /* platform is suspended */ 688f0fba2adSLiam Girdwood unsigned int probed:1; 689f0fba2adSLiam Girdwood 690f0fba2adSLiam Girdwood struct snd_soc_card *card; 691f0fba2adSLiam Girdwood struct list_head list; 692f0fba2adSLiam Girdwood struct list_head card_list; 693b7950641SLiam Girdwood 694b7950641SLiam Girdwood struct snd_soc_dapm_context dapm; 695f0fba2adSLiam Girdwood }; 696f0fba2adSLiam Girdwood 697808db4a4SRichard Purdie struct snd_soc_dai_link { 698f0fba2adSLiam Girdwood /* config - must be set by machine driver */ 699f0fba2adSLiam Girdwood const char *name; /* Codec name */ 700f0fba2adSLiam Girdwood const char *stream_name; /* Stream name */ 701f0fba2adSLiam Girdwood const char *codec_name; /* for multi-codec */ 702f0fba2adSLiam Girdwood const char *platform_name; /* for multi-platform */ 703f0fba2adSLiam Girdwood const char *cpu_dai_name; 704f0fba2adSLiam Girdwood const char *codec_dai_name; 7054ccab3e7SLiam Girdwood 7063efab7dcSMark Brown /* Keep DAI active over suspend */ 7073efab7dcSMark Brown unsigned int ignore_suspend:1; 7083efab7dcSMark Brown 70906f409d7SMark Brown /* Symmetry requirements */ 71006f409d7SMark Brown unsigned int symmetric_rates:1; 71106f409d7SMark Brown 712f0fba2adSLiam Girdwood /* codec/machine specific init - e.g. add machine controls */ 713f0fba2adSLiam Girdwood int (*init)(struct snd_soc_pcm_runtime *rtd); 71406f409d7SMark Brown 715f0fba2adSLiam Girdwood /* machine stream operations */ 716f0fba2adSLiam Girdwood struct snd_soc_ops *ops; 717808db4a4SRichard Purdie }; 718808db4a4SRichard Purdie 719ff819b83SDimitris Papastamos struct snd_soc_codec_conf { 720ead9b919SJarkko Nikula const char *dev_name; 721ff819b83SDimitris Papastamos 722ff819b83SDimitris Papastamos /* 723ff819b83SDimitris Papastamos * optional map of kcontrol, widget and path name prefixes that are 724ff819b83SDimitris Papastamos * associated per device 725ff819b83SDimitris Papastamos */ 726ead9b919SJarkko Nikula const char *name_prefix; 727ff819b83SDimitris Papastamos 728ff819b83SDimitris Papastamos /* 729ff819b83SDimitris Papastamos * set this to the desired compression type if you want to 730ff819b83SDimitris Papastamos * override the one supplied in codec->driver->compress_type 731ff819b83SDimitris Papastamos */ 732ff819b83SDimitris Papastamos enum snd_soc_compress_type compress_type; 733ead9b919SJarkko Nikula }; 734ead9b919SJarkko Nikula 7352eea392dSJarkko Nikula struct snd_soc_aux_dev { 7362eea392dSJarkko Nikula const char *name; /* Codec name */ 7372eea392dSJarkko Nikula const char *codec_name; /* for multi-codec */ 7382eea392dSJarkko Nikula 7392eea392dSJarkko Nikula /* codec/machine specific init - e.g. add machine controls */ 7402eea392dSJarkko Nikula int (*init)(struct snd_soc_dapm_context *dapm); 7412eea392dSJarkko Nikula }; 7422eea392dSJarkko Nikula 74387506549SMark Brown /* SoC card */ 74487506549SMark Brown struct snd_soc_card { 745f0fba2adSLiam Girdwood const char *name; 74622de71baSLiam Girdwood const char *long_name; 74722de71baSLiam Girdwood const char *driver_name; 748c5af3a2eSMark Brown struct device *dev; 749f0fba2adSLiam Girdwood struct snd_card *snd_card; 750f0fba2adSLiam Girdwood struct module *owner; 751c5af3a2eSMark Brown 752c5af3a2eSMark Brown struct list_head list; 753f0fba2adSLiam Girdwood struct mutex mutex; 754c5af3a2eSMark Brown 755f0fba2adSLiam Girdwood bool instantiated; 756808db4a4SRichard Purdie 757e7361ec4SMark Brown int (*probe)(struct snd_soc_card *card); 75828e9ad92SMark Brown int (*late_probe)(struct snd_soc_card *card); 759e7361ec4SMark Brown int (*remove)(struct snd_soc_card *card); 760808db4a4SRichard Purdie 761808db4a4SRichard Purdie /* the pre and post PM functions are used to do any PM work before and 762808db4a4SRichard Purdie * after the codec and DAI's do any PM work. */ 76370b2ac12SMark Brown int (*suspend_pre)(struct snd_soc_card *card); 76470b2ac12SMark Brown int (*suspend_post)(struct snd_soc_card *card); 76570b2ac12SMark Brown int (*resume_pre)(struct snd_soc_card *card); 76670b2ac12SMark Brown int (*resume_post)(struct snd_soc_card *card); 767808db4a4SRichard Purdie 7680b4d221bSLiam Girdwood /* callbacks */ 76987506549SMark Brown int (*set_bias_level)(struct snd_soc_card *, 770d4c6005fSMark Brown struct snd_soc_dapm_context *dapm, 7710be9898aSMark Brown enum snd_soc_bias_level level); 7721badabd9SMark Brown int (*set_bias_level_post)(struct snd_soc_card *, 773d4c6005fSMark Brown struct snd_soc_dapm_context *dapm, 7741badabd9SMark Brown enum snd_soc_bias_level level); 7750b4d221bSLiam Girdwood 7766c5f1fedSMark Brown long pmdown_time; 77796dd3622SMark Brown 778808db4a4SRichard Purdie /* CPU <--> Codec DAI links */ 779808db4a4SRichard Purdie struct snd_soc_dai_link *dai_link; 780808db4a4SRichard Purdie int num_links; 781f0fba2adSLiam Girdwood struct snd_soc_pcm_runtime *rtd; 782f0fba2adSLiam Girdwood int num_rtd; 7836308419aSMark Brown 784ff819b83SDimitris Papastamos /* optional codec specific configuration */ 785ff819b83SDimitris Papastamos struct snd_soc_codec_conf *codec_conf; 786ff819b83SDimitris Papastamos int num_configs; 787ead9b919SJarkko Nikula 7882eea392dSJarkko Nikula /* 7892eea392dSJarkko Nikula * optional auxiliary devices such as amplifiers or codecs with DAI 7902eea392dSJarkko Nikula * link unused 7912eea392dSJarkko Nikula */ 7922eea392dSJarkko Nikula struct snd_soc_aux_dev *aux_dev; 7932eea392dSJarkko Nikula int num_aux_devs; 7942eea392dSJarkko Nikula struct snd_soc_pcm_runtime *rtd_aux; 7952eea392dSJarkko Nikula int num_aux_rtd; 7962eea392dSJarkko Nikula 797b7af1dafSMark Brown const struct snd_kcontrol_new *controls; 798b7af1dafSMark Brown int num_controls; 799b7af1dafSMark Brown 800b8ad29deSMark Brown /* 801b8ad29deSMark Brown * Card-specific routes and widgets. 802b8ad29deSMark Brown */ 803d06e48dbSLars-Peter Clausen const struct snd_soc_dapm_widget *dapm_widgets; 804b8ad29deSMark Brown int num_dapm_widgets; 805d06e48dbSLars-Peter Clausen const struct snd_soc_dapm_route *dapm_routes; 806b8ad29deSMark Brown int num_dapm_routes; 807b8ad29deSMark Brown 8086308419aSMark Brown struct work_struct deferred_resume_work; 809f0fba2adSLiam Girdwood 810f0fba2adSLiam Girdwood /* lists of probed devices belonging to this card */ 811f0fba2adSLiam Girdwood struct list_head codec_dev_list; 812f0fba2adSLiam Girdwood struct list_head platform_dev_list; 813f0fba2adSLiam Girdwood struct list_head dai_dev_list; 814a6052154SJarkko Nikula 81597c866deSJarkko Nikula struct list_head widgets; 8168ddab3f5SJarkko Nikula struct list_head paths; 8177be31be8SJarkko Nikula struct list_head dapm_list; 8188ddab3f5SJarkko Nikula 819e37a4970SMark Brown /* Generic DAPM context for the card */ 820e37a4970SMark Brown struct snd_soc_dapm_context dapm; 821e37a4970SMark Brown 822a6052154SJarkko Nikula #ifdef CONFIG_DEBUG_FS 823a6052154SJarkko Nikula struct dentry *debugfs_card_root; 8243a45b867SJarkko Nikula struct dentry *debugfs_pop_time; 825a6052154SJarkko Nikula #endif 8263a45b867SJarkko Nikula u32 pop_time; 827dddf3e4cSMark Brown 828dddf3e4cSMark Brown void *drvdata; 829808db4a4SRichard Purdie }; 830808db4a4SRichard Purdie 831f0fba2adSLiam Girdwood /* SoC machine DAI configuration, glues a codec and cpu DAI together */ 832808db4a4SRichard Purdie struct snd_soc_pcm_runtime { 833f0fba2adSLiam Girdwood struct device dev; 834f0fba2adSLiam Girdwood struct snd_soc_card *card; 835f0fba2adSLiam Girdwood struct snd_soc_dai_link *dai_link; 836b8c0dab9SLiam Girdwood struct mutex pcm_mutex; 837b8c0dab9SLiam Girdwood enum snd_soc_pcm_subclass pcm_subclass; 838b8c0dab9SLiam Girdwood struct snd_pcm_ops ops; 839f0fba2adSLiam Girdwood 840f0fba2adSLiam Girdwood unsigned int complete:1; 841f0fba2adSLiam Girdwood unsigned int dev_registered:1; 842f0fba2adSLiam Girdwood 843f0fba2adSLiam Girdwood /* Symmetry data - only valid if symmetry is being enforced */ 844f0fba2adSLiam Girdwood unsigned int rate; 845f0fba2adSLiam Girdwood long pmdown_time; 846f0fba2adSLiam Girdwood 847f0fba2adSLiam Girdwood /* runtime devices */ 848f0fba2adSLiam Girdwood struct snd_pcm *pcm; 849f0fba2adSLiam Girdwood struct snd_soc_codec *codec; 850f0fba2adSLiam Girdwood struct snd_soc_platform *platform; 851f0fba2adSLiam Girdwood struct snd_soc_dai *codec_dai; 852f0fba2adSLiam Girdwood struct snd_soc_dai *cpu_dai; 853f0fba2adSLiam Girdwood 854f0fba2adSLiam Girdwood struct delayed_work delayed_work; 855808db4a4SRichard Purdie }; 856808db4a4SRichard Purdie 8574eaa9819SJon Smirl /* mixer control */ 8584eaa9819SJon Smirl struct soc_mixer_control { 859d11bb4a9SPeter Ujfalusi int min, max, platform_max; 860815ecf8dSJon Smirl unsigned int reg, rreg, shift, rshift, invert; 8614eaa9819SJon Smirl }; 8624eaa9819SJon Smirl 863808db4a4SRichard Purdie /* enumerated kcontrol */ 864808db4a4SRichard Purdie struct soc_enum { 865808db4a4SRichard Purdie unsigned short reg; 866808db4a4SRichard Purdie unsigned short reg2; 867808db4a4SRichard Purdie unsigned char shift_l; 868808db4a4SRichard Purdie unsigned char shift_r; 869f8ba0b7bSJon Smirl unsigned int max; 8702e72f8e3SPeter Ujfalusi unsigned int mask; 87187023ff7STakashi Iwai const char * const *texts; 8722e72f8e3SPeter Ujfalusi const unsigned int *values; 8732e72f8e3SPeter Ujfalusi void *dapm; 8742e72f8e3SPeter Ujfalusi }; 8752e72f8e3SPeter Ujfalusi 8765c82f567SMark Brown /* codec IO */ 877c3753707SMark Brown unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); 878c3753707SMark Brown unsigned int snd_soc_write(struct snd_soc_codec *codec, 879c3753707SMark Brown unsigned int reg, unsigned int val); 8805fb609d4SDimitris Papastamos unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec, 8815fb609d4SDimitris Papastamos unsigned int reg, const void *data, size_t len); 8825c82f567SMark Brown 883f0fba2adSLiam Girdwood /* device driver data */ 884f0fba2adSLiam Girdwood 885dddf3e4cSMark Brown static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, 886dddf3e4cSMark Brown void *data) 887dddf3e4cSMark Brown { 888dddf3e4cSMark Brown card->drvdata = data; 889dddf3e4cSMark Brown } 890dddf3e4cSMark Brown 891dddf3e4cSMark Brown static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card) 892dddf3e4cSMark Brown { 893dddf3e4cSMark Brown return card->drvdata; 894dddf3e4cSMark Brown } 895dddf3e4cSMark Brown 896b2c812e2SMark Brown static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, 897b2c812e2SMark Brown void *data) 898b2c812e2SMark Brown { 899f0fba2adSLiam Girdwood dev_set_drvdata(codec->dev, data); 900b2c812e2SMark Brown } 901b2c812e2SMark Brown 902b2c812e2SMark Brown static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) 903b2c812e2SMark Brown { 904f0fba2adSLiam Girdwood return dev_get_drvdata(codec->dev); 905f0fba2adSLiam Girdwood } 906f0fba2adSLiam Girdwood 907f0fba2adSLiam Girdwood static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform, 908f0fba2adSLiam Girdwood void *data) 909f0fba2adSLiam Girdwood { 910f0fba2adSLiam Girdwood dev_set_drvdata(platform->dev, data); 911f0fba2adSLiam Girdwood } 912f0fba2adSLiam Girdwood 913f0fba2adSLiam Girdwood static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform) 914f0fba2adSLiam Girdwood { 915f0fba2adSLiam Girdwood return dev_get_drvdata(platform->dev); 916f0fba2adSLiam Girdwood } 917f0fba2adSLiam Girdwood 918f0fba2adSLiam Girdwood static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd, 919f0fba2adSLiam Girdwood void *data) 920f0fba2adSLiam Girdwood { 921f0fba2adSLiam Girdwood dev_set_drvdata(&rtd->dev, data); 922f0fba2adSLiam Girdwood } 923f0fba2adSLiam Girdwood 924f0fba2adSLiam Girdwood static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd) 925f0fba2adSLiam Girdwood { 926f0fba2adSLiam Girdwood return dev_get_drvdata(&rtd->dev); 927b2c812e2SMark Brown } 928b2c812e2SMark Brown 9294e10bda0SVinod Koul static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) 9304e10bda0SVinod Koul { 9314e10bda0SVinod Koul INIT_LIST_HEAD(&card->dai_dev_list); 9324e10bda0SVinod Koul INIT_LIST_HEAD(&card->codec_dev_list); 9334e10bda0SVinod Koul INIT_LIST_HEAD(&card->platform_dev_list); 9344e10bda0SVinod Koul INIT_LIST_HEAD(&card->widgets); 9354e10bda0SVinod Koul INIT_LIST_HEAD(&card->paths); 9364e10bda0SVinod Koul INIT_LIST_HEAD(&card->dapm_list); 9374e10bda0SVinod Koul } 9384e10bda0SVinod Koul 939fb257897SMark Brown int snd_soc_util_init(void); 940fb257897SMark Brown void snd_soc_util_exit(void); 941fb257897SMark Brown 942a47cbe72SMark Brown #include <sound/soc-dai.h> 943a47cbe72SMark Brown 944faff4bb0SStephen Warren #ifdef CONFIG_DEBUG_FS 9458a9dab1aSMark Brown extern struct dentry *snd_soc_debugfs_root; 946faff4bb0SStephen Warren #endif 947faff4bb0SStephen Warren 9486f8ab4acSMark Brown extern const struct dev_pm_ops snd_soc_pm_ops; 9496f8ab4acSMark Brown 950808db4a4SRichard Purdie #endif 951