Loading include/sound/hdmi-codec.h 0 → 100644 +100 −0 Original line number Original line Diff line number Diff line /* * hdmi-codec.h - HDMI Codec driver API * * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com * * Author: Jyri Sarha <jsarha@ti.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ #ifndef __HDMI_CODEC_H__ #define __HDMI_CODEC_H__ #include <linux/hdmi.h> #include <drm/drm_edid.h> #include <sound/asoundef.h> #include <uapi/sound/asound.h> /* * Protocol between ASoC cpu-dai and HDMI-encoder */ struct hdmi_codec_daifmt { enum { HDMI_I2S, HDMI_RIGHT_J, HDMI_LEFT_J, HDMI_DSP_A, HDMI_DSP_B, HDMI_AC97, HDMI_SPDIF, } fmt; int bit_clk_inv:1; int frame_clk_inv:1; int bit_clk_master:1; int frame_clk_master:1; }; /* * HDMI audio parameters */ struct hdmi_codec_params { struct hdmi_audio_infoframe cea; struct snd_aes_iec958 iec; int sample_rate; int sample_width; int channels; }; struct hdmi_codec_ops { /* * Called when ASoC starts an audio stream setup. * Optional */ int (*audio_startup)(struct device *dev); /* * Configures HDMI-encoder for audio stream. * Mandatory */ int (*hw_params)(struct device *dev, struct hdmi_codec_daifmt *fmt, struct hdmi_codec_params *hparms); /* * Shuts down the audio stream. * Mandatory */ void (*audio_shutdown)(struct device *dev); /* * Mute/unmute HDMI audio stream. * Optional */ int (*digital_mute)(struct device *dev, bool enable); /* * Provides EDID-Like-Data from connected HDMI device. * Optional */ int (*get_eld)(struct device *dev, uint8_t *buf, size_t len); }; /* HDMI codec initalization data */ struct hdmi_codec_pdata { const struct hdmi_codec_ops *ops; uint i2s:1; uint spdif:1; int max_i2s_channels; }; #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec" #endif /* __HDMI_CODEC_H__ */ include/sound/pcm_iec958.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -6,4 +6,6 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len); size_t len); int snd_pcm_create_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, u8 *cs, size_t len); #endif #endif sound/core/pcm_iec958.c +48 −17 Original line number Original line Diff line number Diff line Loading @@ -9,30 +9,18 @@ #include <linux/types.h> #include <linux/types.h> #include <sound/asoundef.h> #include <sound/asoundef.h> #include <sound/pcm.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/pcm_iec958.h> #include <sound/pcm_iec958.h> /** static int create_iec958_consumer(uint rate, uint sample_width, * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status u8 *cs, size_t len) * @runtime: pcm runtime structure with ->rate filled in * @cs: channel status buffer, at least four bytes * @len: length of channel status buffer * * Create the consumer format channel status data in @cs of maximum size * @len corresponding to the parameters of the PCM runtime @runtime. * * Drivers may wish to tweak the contents of the buffer after creation. * * Returns: length of buffer, or negative error code if something failed. */ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len) { { unsigned int fs, ws; unsigned int fs, ws; if (len < 4) if (len < 4) return -EINVAL; return -EINVAL; switch (runtime->rate) { switch (rate) { case 32000: case 32000: fs = IEC958_AES3_CON_FS_32000; fs = IEC958_AES3_CON_FS_32000; break; break; Loading @@ -59,7 +47,7 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, } } if (len > 4) { if (len > 4) { switch (snd_pcm_format_width(runtime->format)) { switch (sample_width) { case 16: case 16: ws = IEC958_AES4_CON_WORDLEN_20_16; ws = IEC958_AES4_CON_WORDLEN_20_16; break; break; Loading @@ -71,6 +59,7 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, IEC958_AES4_CON_MAX_WORDLEN_24; IEC958_AES4_CON_MAX_WORDLEN_24; break; break; case 24: case 24: case 32: /* Assume 24-bit width for 32-bit samples. */ ws = IEC958_AES4_CON_WORDLEN_24_20 | ws = IEC958_AES4_CON_WORDLEN_24_20 | IEC958_AES4_CON_MAX_WORDLEN_24; IEC958_AES4_CON_MAX_WORDLEN_24; break; break; Loading @@ -92,4 +81,46 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, return len; return len; } } /** * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status * @runtime: pcm runtime structure with ->rate filled in * @cs: channel status buffer, at least four bytes * @len: length of channel status buffer * * Create the consumer format channel status data in @cs of maximum size * @len corresponding to the parameters of the PCM runtime @runtime. * * Drivers may wish to tweak the contents of the buffer after creation. * * Returns: length of buffer, or negative error code if something failed. */ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len) { return create_iec958_consumer(runtime->rate, snd_pcm_format_width(runtime->format), cs, len); } EXPORT_SYMBOL(snd_pcm_create_iec958_consumer); EXPORT_SYMBOL(snd_pcm_create_iec958_consumer); /** * snd_pcm_create_iec958_consumer_hw_params - create IEC958 channel status * @hw_params: the hw_params instance for extracting rate and sample format * @cs: channel status buffer, at least four bytes * @len: length of channel status buffer * * Create the consumer format channel status data in @cs of maximum size * @len corresponding to the parameters of the PCM runtime @runtime. * * Drivers may wish to tweak the contents of the buffer after creation. * * Returns: length of buffer, or negative error code if something failed. */ int snd_pcm_create_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, u8 *cs, size_t len) { return create_iec958_consumer(params_rate(params), params_width(params), cs, len); } EXPORT_SYMBOL(snd_pcm_create_iec958_consumer_hw_params); sound/hda/local.h +10 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,16 @@ static inline int get_wcaps_type(unsigned int wcaps) return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; } } static inline unsigned int get_wcaps_channels(u32 wcaps) { unsigned int chans; chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13; chans = (chans + 1) * 2; return chans; } extern const struct attribute_group *hdac_dev_attr_groups[]; extern const struct attribute_group *hdac_dev_attr_groups[]; int hda_widget_sysfs_init(struct hdac_device *codec); int hda_widget_sysfs_init(struct hdac_device *codec); void hda_widget_sysfs_exit(struct hdac_device *codec); void hda_widget_sysfs_exit(struct hdac_device *codec); Loading sound/soc/codecs/Kconfig +6 −0 Original line number Original line Diff line number Diff line Loading @@ -88,6 +88,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_MC13783 if MFD_MC13XXX select SND_SOC_MC13783 if MFD_MC13XXX select SND_SOC_ML26124 if I2C select SND_SOC_ML26124 if I2C select SND_SOC_NAU8825 if I2C select SND_SOC_NAU8825 if I2C select SND_SOC_HDMI_CODEC select SND_SOC_PCM1681 if I2C select SND_SOC_PCM1681 if I2C select SND_SOC_PCM179X_I2C if I2C select SND_SOC_PCM179X_I2C if I2C select SND_SOC_PCM179X_SPI if SPI_MASTER select SND_SOC_PCM179X_SPI if SPI_MASTER Loading Loading @@ -478,6 +479,11 @@ config SND_SOC_BT_SCO config SND_SOC_DMIC config SND_SOC_DMIC tristate tristate config SND_SOC_HDMI_CODEC tristate select SND_PCM_ELD select SND_PCM_IEC958 config SND_SOC_ES8328 config SND_SOC_ES8328 tristate "Everest Semi ES8328 CODEC" tristate "Everest Semi ES8328 CODEC" Loading Loading
include/sound/hdmi-codec.h 0 → 100644 +100 −0 Original line number Original line Diff line number Diff line /* * hdmi-codec.h - HDMI Codec driver API * * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com * * Author: Jyri Sarha <jsarha@ti.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ #ifndef __HDMI_CODEC_H__ #define __HDMI_CODEC_H__ #include <linux/hdmi.h> #include <drm/drm_edid.h> #include <sound/asoundef.h> #include <uapi/sound/asound.h> /* * Protocol between ASoC cpu-dai and HDMI-encoder */ struct hdmi_codec_daifmt { enum { HDMI_I2S, HDMI_RIGHT_J, HDMI_LEFT_J, HDMI_DSP_A, HDMI_DSP_B, HDMI_AC97, HDMI_SPDIF, } fmt; int bit_clk_inv:1; int frame_clk_inv:1; int bit_clk_master:1; int frame_clk_master:1; }; /* * HDMI audio parameters */ struct hdmi_codec_params { struct hdmi_audio_infoframe cea; struct snd_aes_iec958 iec; int sample_rate; int sample_width; int channels; }; struct hdmi_codec_ops { /* * Called when ASoC starts an audio stream setup. * Optional */ int (*audio_startup)(struct device *dev); /* * Configures HDMI-encoder for audio stream. * Mandatory */ int (*hw_params)(struct device *dev, struct hdmi_codec_daifmt *fmt, struct hdmi_codec_params *hparms); /* * Shuts down the audio stream. * Mandatory */ void (*audio_shutdown)(struct device *dev); /* * Mute/unmute HDMI audio stream. * Optional */ int (*digital_mute)(struct device *dev, bool enable); /* * Provides EDID-Like-Data from connected HDMI device. * Optional */ int (*get_eld)(struct device *dev, uint8_t *buf, size_t len); }; /* HDMI codec initalization data */ struct hdmi_codec_pdata { const struct hdmi_codec_ops *ops; uint i2s:1; uint spdif:1; int max_i2s_channels; }; #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec" #endif /* __HDMI_CODEC_H__ */
include/sound/pcm_iec958.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -6,4 +6,6 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len); size_t len); int snd_pcm_create_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, u8 *cs, size_t len); #endif #endif
sound/core/pcm_iec958.c +48 −17 Original line number Original line Diff line number Diff line Loading @@ -9,30 +9,18 @@ #include <linux/types.h> #include <linux/types.h> #include <sound/asoundef.h> #include <sound/asoundef.h> #include <sound/pcm.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/pcm_iec958.h> #include <sound/pcm_iec958.h> /** static int create_iec958_consumer(uint rate, uint sample_width, * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status u8 *cs, size_t len) * @runtime: pcm runtime structure with ->rate filled in * @cs: channel status buffer, at least four bytes * @len: length of channel status buffer * * Create the consumer format channel status data in @cs of maximum size * @len corresponding to the parameters of the PCM runtime @runtime. * * Drivers may wish to tweak the contents of the buffer after creation. * * Returns: length of buffer, or negative error code if something failed. */ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len) { { unsigned int fs, ws; unsigned int fs, ws; if (len < 4) if (len < 4) return -EINVAL; return -EINVAL; switch (runtime->rate) { switch (rate) { case 32000: case 32000: fs = IEC958_AES3_CON_FS_32000; fs = IEC958_AES3_CON_FS_32000; break; break; Loading @@ -59,7 +47,7 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, } } if (len > 4) { if (len > 4) { switch (snd_pcm_format_width(runtime->format)) { switch (sample_width) { case 16: case 16: ws = IEC958_AES4_CON_WORDLEN_20_16; ws = IEC958_AES4_CON_WORDLEN_20_16; break; break; Loading @@ -71,6 +59,7 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, IEC958_AES4_CON_MAX_WORDLEN_24; IEC958_AES4_CON_MAX_WORDLEN_24; break; break; case 24: case 24: case 32: /* Assume 24-bit width for 32-bit samples. */ ws = IEC958_AES4_CON_WORDLEN_24_20 | ws = IEC958_AES4_CON_WORDLEN_24_20 | IEC958_AES4_CON_MAX_WORDLEN_24; IEC958_AES4_CON_MAX_WORDLEN_24; break; break; Loading @@ -92,4 +81,46 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, return len; return len; } } /** * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status * @runtime: pcm runtime structure with ->rate filled in * @cs: channel status buffer, at least four bytes * @len: length of channel status buffer * * Create the consumer format channel status data in @cs of maximum size * @len corresponding to the parameters of the PCM runtime @runtime. * * Drivers may wish to tweak the contents of the buffer after creation. * * Returns: length of buffer, or negative error code if something failed. */ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len) { return create_iec958_consumer(runtime->rate, snd_pcm_format_width(runtime->format), cs, len); } EXPORT_SYMBOL(snd_pcm_create_iec958_consumer); EXPORT_SYMBOL(snd_pcm_create_iec958_consumer); /** * snd_pcm_create_iec958_consumer_hw_params - create IEC958 channel status * @hw_params: the hw_params instance for extracting rate and sample format * @cs: channel status buffer, at least four bytes * @len: length of channel status buffer * * Create the consumer format channel status data in @cs of maximum size * @len corresponding to the parameters of the PCM runtime @runtime. * * Drivers may wish to tweak the contents of the buffer after creation. * * Returns: length of buffer, or negative error code if something failed. */ int snd_pcm_create_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, u8 *cs, size_t len) { return create_iec958_consumer(params_rate(params), params_width(params), cs, len); } EXPORT_SYMBOL(snd_pcm_create_iec958_consumer_hw_params);
sound/hda/local.h +10 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,16 @@ static inline int get_wcaps_type(unsigned int wcaps) return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; } } static inline unsigned int get_wcaps_channels(u32 wcaps) { unsigned int chans; chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13; chans = (chans + 1) * 2; return chans; } extern const struct attribute_group *hdac_dev_attr_groups[]; extern const struct attribute_group *hdac_dev_attr_groups[]; int hda_widget_sysfs_init(struct hdac_device *codec); int hda_widget_sysfs_init(struct hdac_device *codec); void hda_widget_sysfs_exit(struct hdac_device *codec); void hda_widget_sysfs_exit(struct hdac_device *codec); Loading
sound/soc/codecs/Kconfig +6 −0 Original line number Original line Diff line number Diff line Loading @@ -88,6 +88,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_MC13783 if MFD_MC13XXX select SND_SOC_MC13783 if MFD_MC13XXX select SND_SOC_ML26124 if I2C select SND_SOC_ML26124 if I2C select SND_SOC_NAU8825 if I2C select SND_SOC_NAU8825 if I2C select SND_SOC_HDMI_CODEC select SND_SOC_PCM1681 if I2C select SND_SOC_PCM1681 if I2C select SND_SOC_PCM179X_I2C if I2C select SND_SOC_PCM179X_I2C if I2C select SND_SOC_PCM179X_SPI if SPI_MASTER select SND_SOC_PCM179X_SPI if SPI_MASTER Loading Loading @@ -478,6 +479,11 @@ config SND_SOC_BT_SCO config SND_SOC_DMIC config SND_SOC_DMIC tristate tristate config SND_SOC_HDMI_CODEC tristate select SND_PCM_ELD select SND_PCM_IEC958 config SND_SOC_ES8328 config SND_SOC_ES8328 tristate "Everest Semi ES8328 CODEC" tristate "Everest Semi ES8328 CODEC" Loading