Ignore:
Timestamp:
Jul 24, 2021, 3:42:01 PM (4 years ago)
Author:
David Azarewicz
Message:

Merge in changes from uniaud32next branch.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/hda/intel-nhlt.c

    r629 r689  
    3232        struct nhlt_dmic_array_config *cfg;
    3333        struct nhlt_vendor_dmic_array_config *cfg_vendor;
     34        struct nhlt_fmt *fmt_configs;
    3435        unsigned int dmic_geo = 0;
    35         u8 j;
     36        u16 max_ch = 0;
     37        u8 i, j;
    3638
    3739        if (!nhlt)
    3840                return 0;
    3941
    40         epnt = (struct nhlt_endpoint *)nhlt->desc;
     42        if (nhlt->header.length <= sizeof(struct acpi_table_header)) {
     43                dev_warn(dev, "Invalid DMIC description table\n");
     44                return 0;
     45        }
    4146
    42         for (j = 0; j < nhlt->endpoint_count; j++) {
    43                 if (epnt->linktype == NHLT_LINK_DMIC) {
    44                         cfg = (struct nhlt_dmic_array_config  *)
    45                                         (epnt->config.caps);
     47        for (j = 0, epnt = nhlt->desc; j < nhlt->endpoint_count; j++,
     48             epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length)) {
     49
     50                if (epnt->linktype != NHLT_LINK_DMIC)
     51                        continue;
     52
     53                cfg = (struct nhlt_dmic_array_config  *)(epnt->config.caps);
     54                fmt_configs = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size);
     55
     56                /* find max number of channels based on format_configuration */
     57                if (fmt_configs->fmt_count) {
     58                        dev_dbg(dev, "%s: found %d format definitions\n",
     59                                __func__, fmt_configs->fmt_count);
     60
     61                        for (i = 0; i < fmt_configs->fmt_count; i++) {
     62                                struct wav_fmt_ext *fmt_ext;
     63
     64                                fmt_ext = &fmt_configs->fmt_config[i].fmt_ext;
     65
     66                                if (fmt_ext->fmt.channels > max_ch)
     67                                        max_ch = fmt_ext->fmt.channels;
     68                        }
     69                        dev_dbg(dev, "%s: max channels found %d\n", __func__, max_ch);
     70                } else {
     71                        dev_dbg(dev, "%s: No format information found\n", __func__);
     72                }
     73
     74                if (cfg->device_config.config_type != NHLT_CONFIG_TYPE_MIC_ARRAY) {
     75                        dmic_geo = max_ch;
     76                } else {
    4677                        switch (cfg->array_type) {
    4778                        case NHLT_MIC_ARRAY_2CH_SMALL:
     
    6091                                break;
    6192                        default:
    62                                 dev_warn(dev, "undefined DMIC array_type 0x%0x\n",
    63                                          cfg->array_type);
     93                                dev_warn(dev, "%s: undefined DMIC array_type 0x%0x\n",
     94                                         __func__, cfg->array_type);
     95                        }
     96
     97                        if (dmic_geo > 0) {
     98                                dev_dbg(dev, "%s: Array with %d dmics\n", __func__, dmic_geo);
     99                        }
     100                        if (max_ch > dmic_geo) {
     101                                dev_dbg(dev, "%s: max channels %d exceed dmic number %d\n",
     102                                        __func__, max_ch, dmic_geo);
    64103                        }
    65104                }
    66                 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
    67105        }
     106
     107        dev_dbg(dev, "%s: dmic number %d max_ch %d\n",
     108                __func__, dmic_geo, max_ch);
    68109
    69110        return dmic_geo;
Note: See TracChangeset for help on using the changeset viewer.