~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/meson/aiu-codec-ctrl.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/soc/meson/aiu-codec-ctrl.c (Version linux-6.12-rc7) and /sound/soc/meson/aiu-codec-ctrl.c (Version linux-6.8.12)


  1 // SPDX-License-Identifier: GPL-2.0                 1 // SPDX-License-Identifier: GPL-2.0
  2 //                                                  2 //
  3 // Copyright (c) 2020 BayLibre, SAS.                3 // Copyright (c) 2020 BayLibre, SAS.
  4 // Author: Jerome Brunet <jbrunet@baylibre.com      4 // Author: Jerome Brunet <jbrunet@baylibre.com>
  5                                                     5 
  6 #include <linux/bitfield.h>                         6 #include <linux/bitfield.h>
  7 #include <sound/pcm_params.h>                       7 #include <sound/pcm_params.h>
  8 #include <sound/soc.h>                              8 #include <sound/soc.h>
  9 #include <sound/soc-dai.h>                          9 #include <sound/soc-dai.h>
 10                                                    10 
 11 #include <dt-bindings/sound/meson-aiu.h>           11 #include <dt-bindings/sound/meson-aiu.h>
 12 #include "aiu.h"                                   12 #include "aiu.h"
 13 #include "meson-codec-glue.h"                      13 #include "meson-codec-glue.h"
 14                                                    14 
 15 #define CTRL_CLK_SEL            GENMASK(1, 0)      15 #define CTRL_CLK_SEL            GENMASK(1, 0)
 16 #define CTRL_DATA_SEL_SHIFT     4                  16 #define CTRL_DATA_SEL_SHIFT     4
 17 #define CTRL_DATA_SEL           (0x3 << CTRL_D     17 #define CTRL_DATA_SEL           (0x3 << CTRL_DATA_SEL_SHIFT)
 18                                                    18 
 19 static const char * const aiu_codec_ctrl_mux_t     19 static const char * const aiu_codec_ctrl_mux_texts[] = {
 20         "DISABLED", "PCM", "I2S",                  20         "DISABLED", "PCM", "I2S",
 21 };                                                 21 };
 22                                                    22 
 23 static int aiu_codec_ctrl_mux_put_enum(struct      23 static int aiu_codec_ctrl_mux_put_enum(struct snd_kcontrol *kcontrol,
 24                                        struct      24                                        struct snd_ctl_elem_value *ucontrol)
 25 {                                                  25 {
 26         struct snd_soc_component *component =      26         struct snd_soc_component *component =
 27                 snd_soc_dapm_kcontrol_componen     27                 snd_soc_dapm_kcontrol_component(kcontrol);
 28         struct snd_soc_dapm_context *dapm =        28         struct snd_soc_dapm_context *dapm =
 29                 snd_soc_dapm_kcontrol_dapm(kco     29                 snd_soc_dapm_kcontrol_dapm(kcontrol);
 30         struct soc_enum *e = (struct soc_enum      30         struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 31         unsigned int mux, changed;                 31         unsigned int mux, changed;
 32                                                    32 
 33         mux = snd_soc_enum_item_to_val(e, ucon     33         mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]);
 34         changed = snd_soc_component_test_bits(     34         changed = snd_soc_component_test_bits(component, e->reg,
 35                                                    35                                               CTRL_DATA_SEL,
 36                                                    36                                               FIELD_PREP(CTRL_DATA_SEL, mux));
 37                                                    37 
 38         if (!changed)                              38         if (!changed)
 39                 return 0;                          39                 return 0;
 40                                                    40 
 41         /* Force disconnect of the mux while u     41         /* Force disconnect of the mux while updating */
 42         snd_soc_dapm_mux_update_power(dapm, kc     42         snd_soc_dapm_mux_update_power(dapm, kcontrol, 0, NULL, NULL);
 43                                                    43 
 44         /* Reset the source first */               44         /* Reset the source first */
 45         snd_soc_component_update_bits(componen     45         snd_soc_component_update_bits(component, e->reg,
 46                                       CTRL_CLK     46                                       CTRL_CLK_SEL |
 47                                       CTRL_DAT     47                                       CTRL_DATA_SEL,
 48                                       FIELD_PR     48                                       FIELD_PREP(CTRL_CLK_SEL, 0) |
 49                                       FIELD_PR     49                                       FIELD_PREP(CTRL_DATA_SEL, 0));
 50                                                    50 
 51         /* Set the appropriate source */           51         /* Set the appropriate source */
 52         snd_soc_component_update_bits(componen     52         snd_soc_component_update_bits(component, e->reg,
 53                                       CTRL_CLK     53                                       CTRL_CLK_SEL |
 54                                       CTRL_DAT     54                                       CTRL_DATA_SEL,
 55                                       FIELD_PR     55                                       FIELD_PREP(CTRL_CLK_SEL, mux) |
 56                                       FIELD_PR     56                                       FIELD_PREP(CTRL_DATA_SEL, mux));
 57                                                    57 
 58         snd_soc_dapm_mux_update_power(dapm, kc     58         snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL);
 59                                                    59 
 60         return 1;                                  60         return 1;
 61 }                                                  61 }
 62                                                    62 
 63 static SOC_ENUM_SINGLE_DECL(aiu_hdmi_ctrl_mux_     63 static SOC_ENUM_SINGLE_DECL(aiu_hdmi_ctrl_mux_enum, AIU_HDMI_CLK_DATA_CTRL,
 64                             CTRL_DATA_SEL_SHIF     64                             CTRL_DATA_SEL_SHIFT,
 65                             aiu_codec_ctrl_mux     65                             aiu_codec_ctrl_mux_texts);
 66                                                    66 
 67 static const struct snd_kcontrol_new aiu_hdmi_     67 static const struct snd_kcontrol_new aiu_hdmi_ctrl_mux =
 68         SOC_DAPM_ENUM_EXT("HDMI Source", aiu_h     68         SOC_DAPM_ENUM_EXT("HDMI Source", aiu_hdmi_ctrl_mux_enum,
 69                           snd_soc_dapm_get_enu     69                           snd_soc_dapm_get_enum_double,
 70                           aiu_codec_ctrl_mux_p     70                           aiu_codec_ctrl_mux_put_enum);
 71                                                    71 
 72 static const struct snd_soc_dapm_widget aiu_hd     72 static const struct snd_soc_dapm_widget aiu_hdmi_ctrl_widgets[] = {
 73         SND_SOC_DAPM_MUX("HDMI CTRL SRC", SND_     73         SND_SOC_DAPM_MUX("HDMI CTRL SRC", SND_SOC_NOPM, 0, 0,
 74                          &aiu_hdmi_ctrl_mux),      74                          &aiu_hdmi_ctrl_mux),
 75 };                                                 75 };
 76                                                    76 
 77 static const struct snd_soc_dai_ops aiu_codec_     77 static const struct snd_soc_dai_ops aiu_codec_ctrl_input_ops = {
 78         .probe          = meson_codec_glue_inp     78         .probe          = meson_codec_glue_input_dai_probe,
 79         .remove         = meson_codec_glue_inp     79         .remove         = meson_codec_glue_input_dai_remove,
 80         .hw_params      = meson_codec_glue_inp     80         .hw_params      = meson_codec_glue_input_hw_params,
 81         .set_fmt        = meson_codec_glue_inp     81         .set_fmt        = meson_codec_glue_input_set_fmt,
 82 };                                                 82 };
 83                                                    83 
 84 static const struct snd_soc_dai_ops aiu_codec_     84 static const struct snd_soc_dai_ops aiu_codec_ctrl_output_ops = {
 85         .startup        = meson_codec_glue_out     85         .startup        = meson_codec_glue_output_startup,
 86 };                                                 86 };
 87                                                    87 
 88 #define AIU_CODEC_CTRL_FORMATS                     88 #define AIU_CODEC_CTRL_FORMATS                                  \
 89         (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_F     89         (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |   \
 90          SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_     90          SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE |   \
 91          SNDRV_PCM_FMTBIT_S32_LE)                  91          SNDRV_PCM_FMTBIT_S32_LE)
 92                                                    92 
 93 #define AIU_CODEC_CTRL_STREAM(xname, xsuffix)      93 #define AIU_CODEC_CTRL_STREAM(xname, xsuffix)                   \
 94 {                                                  94 {                                                               \
 95         .stream_name    = xname " " xsuffix,       95         .stream_name    = xname " " xsuffix,                    \
 96         .channels_min   = 1,                       96         .channels_min   = 1,                                    \
 97         .channels_max   = 8,                       97         .channels_max   = 8,                                    \
 98         .rate_min       = 5512,                    98         .rate_min       = 5512,                                 \
 99         .rate_max       = 192000,                  99         .rate_max       = 192000,                               \
100         .formats        = AIU_CODEC_CTRL_FORMA    100         .formats        = AIU_CODEC_CTRL_FORMATS,               \
101 }                                                 101 }
102                                                   102 
103 #define AIU_CODEC_CTRL_INPUT(xname) {             103 #define AIU_CODEC_CTRL_INPUT(xname) {                           \
104         .name = "CODEC CTRL " xname,              104         .name = "CODEC CTRL " xname,                            \
105         .playback = AIU_CODEC_CTRL_STREAM(xnam    105         .playback = AIU_CODEC_CTRL_STREAM(xname, "Playback"),   \
106         .ops = &aiu_codec_ctrl_input_ops,         106         .ops = &aiu_codec_ctrl_input_ops,                       \
107 }                                                 107 }
108                                                   108 
109 #define AIU_CODEC_CTRL_OUTPUT(xname) {            109 #define AIU_CODEC_CTRL_OUTPUT(xname) {                          \
110         .name = "CODEC CTRL " xname,              110         .name = "CODEC CTRL " xname,                            \
111         .capture = AIU_CODEC_CTRL_STREAM(xname    111         .capture = AIU_CODEC_CTRL_STREAM(xname, "Capture"),     \
112         .ops = &aiu_codec_ctrl_output_ops,        112         .ops = &aiu_codec_ctrl_output_ops,                      \
113 }                                                 113 }
114                                                   114 
115 static struct snd_soc_dai_driver aiu_hdmi_ctrl    115 static struct snd_soc_dai_driver aiu_hdmi_ctrl_dai_drv[] = {
116         [CTRL_I2S] = AIU_CODEC_CTRL_INPUT("HDM    116         [CTRL_I2S] = AIU_CODEC_CTRL_INPUT("HDMI I2S IN"),
117         [CTRL_PCM] = AIU_CODEC_CTRL_INPUT("HDM    117         [CTRL_PCM] = AIU_CODEC_CTRL_INPUT("HDMI PCM IN"),
118         [CTRL_OUT] = AIU_CODEC_CTRL_OUTPUT("HD    118         [CTRL_OUT] = AIU_CODEC_CTRL_OUTPUT("HDMI OUT"),
119 };                                                119 };
120                                                   120 
121 static const struct snd_soc_dapm_route aiu_hdm    121 static const struct snd_soc_dapm_route aiu_hdmi_ctrl_routes[] = {
122         { "HDMI CTRL SRC", "I2S", "HDMI I2S IN    122         { "HDMI CTRL SRC", "I2S", "HDMI I2S IN Playback" },
123         { "HDMI CTRL SRC", "PCM", "HDMI PCM IN    123         { "HDMI CTRL SRC", "PCM", "HDMI PCM IN Playback" },
124         { "HDMI OUT Capture", NULL, "HDMI CTRL    124         { "HDMI OUT Capture", NULL, "HDMI CTRL SRC" },
125 };                                                125 };
126                                                   126 
127 static int aiu_hdmi_of_xlate_dai_name(struct s    127 static int aiu_hdmi_of_xlate_dai_name(struct snd_soc_component *component,
128                                       const st    128                                       const struct of_phandle_args *args,
129                                       const ch    129                                       const char **dai_name)
130 {                                                 130 {
131         return aiu_of_xlate_dai_name(component    131         return aiu_of_xlate_dai_name(component, args, dai_name, AIU_HDMI);
132 }                                                 132 }
133                                                   133 
134 static const struct snd_soc_component_driver a    134 static const struct snd_soc_component_driver aiu_hdmi_ctrl_component = {
135         .name                   = "AIU HDMI Co    135         .name                   = "AIU HDMI Codec Control",
136         .dapm_widgets           = aiu_hdmi_ctr    136         .dapm_widgets           = aiu_hdmi_ctrl_widgets,
137         .num_dapm_widgets       = ARRAY_SIZE(a    137         .num_dapm_widgets       = ARRAY_SIZE(aiu_hdmi_ctrl_widgets),
138         .dapm_routes            = aiu_hdmi_ctr    138         .dapm_routes            = aiu_hdmi_ctrl_routes,
139         .num_dapm_routes        = ARRAY_SIZE(a    139         .num_dapm_routes        = ARRAY_SIZE(aiu_hdmi_ctrl_routes),
140         .of_xlate_dai_name      = aiu_hdmi_of_    140         .of_xlate_dai_name      = aiu_hdmi_of_xlate_dai_name,
141         .endianness             = 1,              141         .endianness             = 1,
142 #ifdef CONFIG_DEBUG_FS                            142 #ifdef CONFIG_DEBUG_FS
143         .debugfs_prefix         = "hdmi",         143         .debugfs_prefix         = "hdmi",
144 #endif                                            144 #endif
145 };                                                145 };
146                                                   146 
147 int aiu_hdmi_ctrl_register_component(struct de    147 int aiu_hdmi_ctrl_register_component(struct device *dev)
148 {                                                 148 {
149         return snd_soc_register_component(dev,    149         return snd_soc_register_component(dev, &aiu_hdmi_ctrl_component,
150                                           aiu_    150                                           aiu_hdmi_ctrl_dai_drv,
151                                           ARRA    151                                           ARRAY_SIZE(aiu_hdmi_ctrl_dai_drv));
152 }                                                 152 }
153                                                   153 
154                                                   154 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php