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

TOMOYO Linux Cross Reference
Linux/sound/hda/intel-nhlt.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/hda/intel-nhlt.c (Version linux-6.12-rc7) and /sound/hda/intel-nhlt.c (Version linux-5.5.19)


  1 // SPDX-License-Identifier: GPL-2.0-only       !!   1 // SPDX-License-Identifier: GPL-2.0
  2 // Copyright (c) 2015-2019 Intel Corporation        2 // Copyright (c) 2015-2019 Intel Corporation
  3                                                     3 
  4 #include <linux/acpi.h>                             4 #include <linux/acpi.h>
  5 #include <sound/intel-nhlt.h>                       5 #include <sound/intel-nhlt.h>
  6                                                     6 
                                                   >>   7 #define NHLT_ACPI_HEADER_SIG    "NHLT"
                                                   >>   8 
                                                   >>   9 /* Unique identification for getting NHLT blobs */
                                                   >>  10 static guid_t osc_guid =
                                                   >>  11         GUID_INIT(0xA69F886E, 0x6CEB, 0x4594,
                                                   >>  12                   0xA4, 0x1F, 0x7B, 0x5D, 0xCE, 0x24, 0xC5, 0x53);
                                                   >>  13 
  7 struct nhlt_acpi_table *intel_nhlt_init(struct     14 struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
  8 {                                                  15 {
  9         struct nhlt_acpi_table *nhlt;          !!  16         acpi_handle handle;
 10         acpi_status status;                    !!  17         union acpi_object *obj;
                                                   >>  18         struct nhlt_resource_desc *nhlt_ptr;
                                                   >>  19         struct nhlt_acpi_table *nhlt_table = NULL;
                                                   >>  20 
                                                   >>  21         handle = ACPI_HANDLE(dev);
                                                   >>  22         if (!handle) {
                                                   >>  23                 dev_err(dev, "Didn't find ACPI_HANDLE\n");
                                                   >>  24                 return NULL;
                                                   >>  25         }
                                                   >>  26 
                                                   >>  27         obj = acpi_evaluate_dsm(handle, &osc_guid, 1, 1, NULL);
                                                   >>  28 
                                                   >>  29         if (!obj)
                                                   >>  30                 return NULL;
 11                                                    31 
 12         status = acpi_get_table(ACPI_SIG_NHLT, !!  32         if (obj->type != ACPI_TYPE_BUFFER) {
 13                                 (struct acpi_t !!  33                 dev_dbg(dev, "No NHLT table found\n");
 14         if (ACPI_FAILURE(status)) {            !!  34                 ACPI_FREE(obj);
 15                 dev_warn(dev, "NHLT table not  << 
 16                 return NULL;                       35                 return NULL;
 17         }                                          36         }
 18                                                    37 
 19         return nhlt;                           !!  38         nhlt_ptr = (struct nhlt_resource_desc  *)obj->buffer.pointer;
                                                   >>  39         if (nhlt_ptr->length)
                                                   >>  40                 nhlt_table = (struct nhlt_acpi_table *)
                                                   >>  41                         memremap(nhlt_ptr->min_addr, nhlt_ptr->length,
                                                   >>  42                                  MEMREMAP_WB);
                                                   >>  43         ACPI_FREE(obj);
                                                   >>  44         if (nhlt_table &&
                                                   >>  45             (strncmp(nhlt_table->header.signature,
                                                   >>  46                      NHLT_ACPI_HEADER_SIG,
                                                   >>  47                      strlen(NHLT_ACPI_HEADER_SIG)) != 0)) {
                                                   >>  48                 memunmap(nhlt_table);
                                                   >>  49                 dev_err(dev, "NHLT ACPI header signature incorrect\n");
                                                   >>  50                 return NULL;
                                                   >>  51         }
                                                   >>  52         return nhlt_table;
 20 }                                                  53 }
 21 EXPORT_SYMBOL_GPL(intel_nhlt_init);                54 EXPORT_SYMBOL_GPL(intel_nhlt_init);
 22                                                    55 
 23 void intel_nhlt_free(struct nhlt_acpi_table *n     56 void intel_nhlt_free(struct nhlt_acpi_table *nhlt)
 24 {                                                  57 {
 25         acpi_put_table((struct acpi_table_head !!  58         memunmap((void *)nhlt);
 26 }                                                  59 }
 27 EXPORT_SYMBOL_GPL(intel_nhlt_free);                60 EXPORT_SYMBOL_GPL(intel_nhlt_free);
 28                                                    61 
 29 int intel_nhlt_get_dmic_geo(struct device *dev     62 int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt)
 30 {                                                  63 {
 31         struct nhlt_endpoint *epnt;                64         struct nhlt_endpoint *epnt;
 32         struct nhlt_dmic_array_config *cfg;        65         struct nhlt_dmic_array_config *cfg;
 33         struct nhlt_vendor_dmic_array_config *     66         struct nhlt_vendor_dmic_array_config *cfg_vendor;
 34         struct nhlt_fmt *fmt_configs;          << 
 35         unsigned int dmic_geo = 0;                 67         unsigned int dmic_geo = 0;
 36         u16 max_ch = 0;                        !!  68         u8 j;
 37         u8 i, j;                               << 
 38                                                    69 
 39         if (!nhlt)                                 70         if (!nhlt)
 40                 return 0;                          71                 return 0;
 41                                                    72 
 42         if (nhlt->header.length <= sizeof(stru !!  73         epnt = (struct nhlt_endpoint *)nhlt->desc;
 43                 dev_warn(dev, "Invalid DMIC de << 
 44                 return 0;                      << 
 45         }                                      << 
 46                                                << 
 47         for (j = 0, epnt = nhlt->desc; j < nhl << 
 48              epnt = (struct nhlt_endpoint *)(( << 
 49                                                << 
 50                 if (epnt->linktype != NHLT_LIN << 
 51                         continue;              << 
 52                                                << 
 53                 cfg = (struct nhlt_dmic_array_ << 
 54                 fmt_configs = (struct nhlt_fmt << 
 55                                                << 
 56                 /* find max number of channels << 
 57                 if (fmt_configs->fmt_count) {  << 
 58                         struct nhlt_fmt_cfg *f << 
 59                                                << 
 60                         dev_dbg(dev, "found %d << 
 61                                 fmt_configs->f << 
 62                                                << 
 63                         for (i = 0; i < fmt_co << 
 64                                 struct wav_fmt << 
 65                                                << 
 66                                 fmt_ext = &fmt << 
 67                                                << 
 68                                 if (fmt_ext->f << 
 69                                         max_ch << 
 70                                                << 
 71                                 /* Move to the << 
 72                                 fmt_cfg = (str << 
 73                                                << 
 74                         }                      << 
 75                         dev_dbg(dev, "max chan << 
 76                 } else {                       << 
 77                         dev_dbg(dev, "No forma << 
 78                 }                              << 
 79                                                    74 
 80                 if (cfg->device_config.config_ !!  75         for (j = 0; j < nhlt->endpoint_count; j++) {
 81                         dmic_geo = max_ch;     !!  76                 if (epnt->linktype == NHLT_LINK_DMIC) {
 82                 } else {                       !!  77                         cfg = (struct nhlt_dmic_array_config  *)
                                                   >>  78                                         (epnt->config.caps);
 83                         switch (cfg->array_typ     79                         switch (cfg->array_type) {
 84                         case NHLT_MIC_ARRAY_2C     80                         case NHLT_MIC_ARRAY_2CH_SMALL:
 85                         case NHLT_MIC_ARRAY_2C     81                         case NHLT_MIC_ARRAY_2CH_BIG:
 86                                 dmic_geo = MIC     82                                 dmic_geo = MIC_ARRAY_2CH;
 87                                 break;             83                                 break;
 88                                                    84 
 89                         case NHLT_MIC_ARRAY_4C     85                         case NHLT_MIC_ARRAY_4CH_1ST_GEOM:
 90                         case NHLT_MIC_ARRAY_4C     86                         case NHLT_MIC_ARRAY_4CH_L_SHAPED:
 91                         case NHLT_MIC_ARRAY_4C     87                         case NHLT_MIC_ARRAY_4CH_2ND_GEOM:
 92                                 dmic_geo = MIC     88                                 dmic_geo = MIC_ARRAY_4CH;
 93                                 break;             89                                 break;
 94                         case NHLT_MIC_ARRAY_VE     90                         case NHLT_MIC_ARRAY_VENDOR_DEFINED:
 95                                 cfg_vendor = (     91                                 cfg_vendor = (struct nhlt_vendor_dmic_array_config *)cfg;
 96                                 dmic_geo = cfg     92                                 dmic_geo = cfg_vendor->nb_mics;
 97                                 break;             93                                 break;
 98                         default:                   94                         default:
 99                                 dev_warn(dev,  !!  95                                 dev_warn(dev, "undefined DMIC array_type 0x%0x\n",
100                                          __fun !!  96                                          cfg->array_type);
101                         }                      << 
102                                                << 
103                         if (dmic_geo > 0) {    << 
104                                 dev_dbg(dev, " << 
105                         }                      << 
106                         if (max_ch > dmic_geo) << 
107                                 dev_dbg(dev, " << 
108                                         max_ch << 
109                         }                          97                         }
110                 }                                  98                 }
                                                   >>  99                 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
111         }                                         100         }
112                                                   101 
113         dev_dbg(dev, "dmic number %d max_ch %d << 
114                                                << 
115         return dmic_geo;                          102         return dmic_geo;
116 }                                                 103 }
117 EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo);       104 EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo);
118                                                << 
119 bool intel_nhlt_has_endpoint_type(struct nhlt_ << 
120 {                                              << 
121         struct nhlt_endpoint *epnt;            << 
122         int i;                                 << 
123                                                << 
124         if (!nhlt)                             << 
125                 return false;                  << 
126                                                << 
127         epnt = (struct nhlt_endpoint *)nhlt->d << 
128         for (i = 0; i < nhlt->endpoint_count;  << 
129                 if (epnt->linktype == link_typ << 
130                         return true;           << 
131                                                << 
132                 epnt = (struct nhlt_endpoint * << 
133         }                                      << 
134         return false;                          << 
135 }                                              << 
136 EXPORT_SYMBOL(intel_nhlt_has_endpoint_type);   << 
137                                                << 
138 int intel_nhlt_ssp_endpoint_mask(struct nhlt_a << 
139 {                                              << 
140         struct nhlt_endpoint *epnt;            << 
141         int ssp_mask = 0;                      << 
142         int i;                                 << 
143                                                << 
144         if (!nhlt || (device_type != NHLT_DEVI << 
145                 return 0;                      << 
146                                                << 
147         epnt = (struct nhlt_endpoint *)nhlt->d << 
148         for (i = 0; i < nhlt->endpoint_count;  << 
149                 if (epnt->linktype == NHLT_LIN << 
150                         /* for SSP the virtual << 
151                         ssp_mask |= BIT(epnt-> << 
152                 }                              << 
153                 epnt = (struct nhlt_endpoint * << 
154         }                                      << 
155                                                << 
156         return ssp_mask;                       << 
157 }                                              << 
158 EXPORT_SYMBOL(intel_nhlt_ssp_endpoint_mask);   << 
159                                                << 
160 #define SSP_BLOB_V1_0_SIZE              84     << 
161 #define SSP_BLOB_V1_0_MDIVC_OFFSET      19 /*  << 
162                                                << 
163 #define SSP_BLOB_V1_5_SIZE              96     << 
164 #define SSP_BLOB_V1_5_MDIVC_OFFSET      21 /*  << 
165 #define SSP_BLOB_VER_1_5                0xEE00 << 
166                                                << 
167 #define SSP_BLOB_V2_0_SIZE              88     << 
168 #define SSP_BLOB_V2_0_MDIVC_OFFSET      20 /*  << 
169 #define SSP_BLOB_VER_2_0                0xEE00 << 
170                                                << 
171 int intel_nhlt_ssp_mclk_mask(struct nhlt_acpi_ << 
172 {                                              << 
173         struct nhlt_endpoint *epnt;            << 
174         struct nhlt_fmt *fmt;                  << 
175         struct nhlt_fmt_cfg *cfg;              << 
176         int mclk_mask = 0;                     << 
177         int i, j;                              << 
178                                                << 
179         if (!nhlt)                             << 
180                 return 0;                      << 
181                                                << 
182         epnt = (struct nhlt_endpoint *)nhlt->d << 
183         for (i = 0; i < nhlt->endpoint_count;  << 
184                                                << 
185                 /* we only care about endpoint << 
186                 if (epnt->linktype == NHLT_LIN << 
187                     epnt->device_type == NHLT_ << 
188                     epnt->virtual_bus_id == ss << 
189                                                << 
190                         fmt = (struct nhlt_fmt << 
191                         cfg = fmt->fmt_config; << 
192                                                << 
193                         /*                     << 
194                          * In theory all forma << 
195                          * double-check that t << 
196                          */                    << 
197                         for (j = 0; j < fmt->f << 
198                                 u32 *blob;     << 
199                                 int mdivc_offs << 
200                                 int size;      << 
201                                                << 
202                                 /* first check << 
203                                 if (cfg->confi << 
204                                         return << 
205                                                << 
206                                 blob = (u32 *) << 
207                                                << 
208                                 if (blob[1] == << 
209                                         mdivc_ << 
210                                         size = << 
211                                 } else if (blo << 
212                                         mdivc_ << 
213                                         size = << 
214                                 } else {       << 
215                                         mdivc_ << 
216                                         size = << 
217                                 }              << 
218                                                << 
219                                 /* make sure w << 
220                                 if (cfg->confi << 
221                                         return << 
222                                                << 
223                                 mclk_mask |=   << 
224                                                << 
225                                 cfg = (struct  << 
226                         }                      << 
227                 }                              << 
228                 epnt = (struct nhlt_endpoint * << 
229         }                                      << 
230                                                << 
231         /* make sure only one MCLK is used */  << 
232         if (hweight_long(mclk_mask) != 1)      << 
233                 return -EINVAL;                << 
234                                                << 
235         return mclk_mask;                      << 
236 }                                              << 
237 EXPORT_SYMBOL(intel_nhlt_ssp_mclk_mask);       << 
238                                                << 
239 static struct nhlt_specific_cfg *              << 
240 nhlt_get_specific_cfg(struct device *dev, stru << 
241                       u32 rate, u8 vbps, u8 bp << 
242 {                                              << 
243         struct nhlt_fmt_cfg *cfg = fmt->fmt_co << 
244         struct wav_fmt *wfmt;                  << 
245         u16 _bps, _vbps;                       << 
246         int i;                                 << 
247                                                << 
248         dev_dbg(dev, "Endpoint format count=%d << 
249                                                << 
250         for (i = 0; i < fmt->fmt_count; i++) { << 
251                 wfmt = &cfg->fmt_ext.fmt;      << 
252                 _bps = wfmt->bits_per_sample;  << 
253                 _vbps = cfg->fmt_ext.sample.va << 
254                                                << 
255                 dev_dbg(dev, "Endpoint format: << 
256                         wfmt->channels, _vbps, << 
257                                                << 
258                 /*                             << 
259                  * When looking for exact matc << 
260                  * from NHLT table when ignore << 
261                  */                            << 
262                 if (wfmt->channels == num_ch & << 
263                     (ignore_vbps || vbps == _v << 
264                         return &cfg->config;   << 
265                                                << 
266                 cfg = (struct nhlt_fmt_cfg *)( << 
267         }                                      << 
268                                                << 
269         return NULL;                           << 
270 }                                              << 
271                                                << 
272 static bool nhlt_check_ep_match(struct device  << 
273                                 u32 bus_id, u8 << 
274 {                                              << 
275         dev_dbg(dev, "Endpoint: vbus_id=%d lin << 
276                 epnt->virtual_bus_id, epnt->li << 
277                 epnt->direction, epnt->device_ << 
278                                                << 
279         if ((epnt->virtual_bus_id != bus_id) | << 
280             (epnt->linktype != link_type) ||   << 
281             (epnt->direction != dir))          << 
282                 return false;                  << 
283                                                << 
284         /* link of type DMIC bypasses device_t << 
285         return epnt->linktype == NHLT_LINK_DMI << 
286                epnt->device_type == dev_type;  << 
287 }                                              << 
288                                                << 
289 struct nhlt_specific_cfg *                     << 
290 intel_nhlt_get_endpoint_blob(struct device *de << 
291                              u32 bus_id, u8 li << 
292                              u8 num_ch, u32 ra << 
293 {                                              << 
294         struct nhlt_specific_cfg *cfg;         << 
295         struct nhlt_endpoint *epnt;            << 
296         bool ignore_vbps = false;              << 
297         struct nhlt_fmt *fmt;                  << 
298         int i;                                 << 
299                                                << 
300         if (!nhlt)                             << 
301                 return NULL;                   << 
302                                                << 
303         dev_dbg(dev, "Looking for configuratio << 
304         dev_dbg(dev, "  vbus_id=%d link_type=% << 
305                 bus_id, link_type, dir, dev_ty << 
306         if (link_type == NHLT_LINK_DMIC && bps << 
307                 /*                             << 
308                  * The DMIC hardware supports  << 
309                  * size, which is 24 bit sampl << 
310                  * are used for indicating the << 
311                  * It has been observed that s << 
312                  * specified as 32 while some  << 
313                  * The format these variations << 
314                  * hardware is configured and  << 
315                  * Note: when the samples assu << 
316                  * introduced by the lower two << 
317                  * real life implication on au << 
318                  */                            << 
319                 dev_dbg(dev,                   << 
320                         "  ch=%d fmt=%d rate=% << 
321                         num_ch, bps, rate);    << 
322                 ignore_vbps = true;            << 
323         } else {                               << 
324                 dev_dbg(dev, "  ch=%d fmt=%d/% << 
325         }                                      << 
326         dev_dbg(dev, "Endpoint count=%d\n", nh << 
327                                                << 
328         epnt = (struct nhlt_endpoint *)nhlt->d << 
329                                                << 
330         for (i = 0; i < nhlt->endpoint_count;  << 
331                 if (nhlt_check_ep_match(dev, e << 
332                         fmt = (struct nhlt_fmt << 
333                                                << 
334                         cfg = nhlt_get_specifi << 
335                                                << 
336                         if (cfg)               << 
337                                 return cfg;    << 
338                 }                              << 
339                                                << 
340                 epnt = (struct nhlt_endpoint * << 
341         }                                      << 
342                                                << 
343         return NULL;                           << 
344 }                                              << 
345 EXPORT_SYMBOL(intel_nhlt_get_endpoint_blob);   << 
346                                                << 
347 int intel_nhlt_ssp_device_type(struct device * << 
348                                u8 virtual_bus_ << 
349 {                                              << 
350         struct nhlt_endpoint *epnt;            << 
351         int i;                                 << 
352                                                << 
353         if (!nhlt)                             << 
354                 return -EINVAL;                << 
355                                                << 
356         epnt = (struct nhlt_endpoint *)nhlt->d << 
357         for (i = 0; i < nhlt->endpoint_count;  << 
358                 /* for SSP link the virtual bu << 
359                 if (epnt->linktype == NHLT_LIN << 
360                     epnt->virtual_bus_id == vi << 
361                         dev_dbg(dev, "SSP%d: d << 
362                                 epnt->device_t << 
363                         return epnt->device_ty << 
364                 }                              << 
365                                                << 
366                 epnt = (struct nhlt_endpoint * << 
367         }                                      << 
368                                                << 
369         return -EINVAL;                        << 
370 }                                              << 
371 EXPORT_SYMBOL(intel_nhlt_ssp_device_type);     << 
372                                                   105 

~ [ 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