Saurabh Satija | 734aa87 | 2016-06-21 14:22:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2016 Intel Corp. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <nhlt.h> |
| 19 | #include <soc/nhlt.h> |
| 20 | |
| 21 | static const struct nhlt_format_config dmic_2ch_formats[] = { |
| 22 | /* 48 KHz 16-bits per sample. */ |
| 23 | { |
| 24 | .num_channels = 2, |
| 25 | .sample_freq_khz = 48, |
| 26 | .container_bits_per_sample = 16, |
| 27 | .valid_bits_per_sample = 16, |
| 28 | .settings_file = "dmic-2ch-48khz-16b.bin", |
| 29 | }, |
| 30 | }; |
| 31 | |
| 32 | static const struct nhlt_dmic_array_config dmic_2ch_mic_config = { |
| 33 | .tdm_config = { |
| 34 | .config_type = NHLT_TDM_MIC_ARRAY, |
| 35 | }, |
| 36 | .array_type = NHLT_MIC_ARRAY_2CH_SMALL, |
| 37 | }; |
| 38 | |
| 39 | static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = { |
| 40 | { |
| 41 | .link = NHLT_LINK_PDM, |
| 42 | .device = NHLT_PDM_DEV, |
| 43 | .direction = NHLT_DIR_CAPTURE, |
| 44 | .vid = NHLT_VID, |
| 45 | .did = NHLT_DID_DMIC, |
| 46 | .cfg = &dmic_2ch_mic_config, |
| 47 | .cfg_size = sizeof(dmic_2ch_mic_config), |
| 48 | .formats = dmic_2ch_formats, |
| 49 | .num_formats = ARRAY_SIZE(dmic_2ch_formats), |
| 50 | }, |
| 51 | }; |
| 52 | |
| 53 | static const struct nhlt_format_config da7219_formats[] = { |
| 54 | /* 48 KHz 24-bits per sample. */ |
| 55 | { |
| 56 | .num_channels = 2, |
| 57 | .sample_freq_khz = 48, |
| 58 | .container_bits_per_sample = 32, |
| 59 | .valid_bits_per_sample = 24, |
| 60 | .settings_file = "dialog-2ch-48khz-24b.bin", |
| 61 | }, |
| 62 | }; |
| 63 | |
| 64 | static const struct nhlt_tdm_config tdm_config = { |
| 65 | .virtual_slot = 0, |
| 66 | .config_type = NHLT_TDM_BASIC, |
| 67 | }; |
| 68 | |
| 69 | static const struct nhlt_endp_descriptor da7219_descriptors[] = { |
| 70 | /* Render Endpoint */ |
| 71 | { |
| 72 | .link = NHLT_LINK_SSP, |
| 73 | .device = NHLT_SSP_DEV_I2S, |
| 74 | .direction = NHLT_DIR_RENDER, |
| 75 | .vid = NHLT_VID, |
| 76 | .did = NHLT_DID_SSP, |
| 77 | .cfg = &tdm_config, |
| 78 | .cfg_size = sizeof(tdm_config), |
| 79 | .formats = da7219_formats, |
| 80 | .num_formats = ARRAY_SIZE(da7219_formats), |
| 81 | }, |
| 82 | /* Capture Endpoint */ |
| 83 | { |
| 84 | .link = NHLT_LINK_SSP, |
| 85 | .device = NHLT_SSP_DEV_I2S, |
| 86 | .direction = NHLT_DIR_CAPTURE, |
| 87 | .vid = NHLT_VID, |
| 88 | .did = NHLT_DID_SSP, |
| 89 | .cfg = &tdm_config, |
| 90 | .cfg_size = sizeof(tdm_config), |
| 91 | .formats = da7219_formats, |
| 92 | .num_formats = ARRAY_SIZE(da7219_formats), |
| 93 | }, |
| 94 | }; |
| 95 | |
| 96 | static const struct nhlt_format_config max98357_formats[] = { |
| 97 | /* 48 KHz 24-bits per sample. */ |
| 98 | { |
| 99 | .num_channels = 2, |
| 100 | .sample_freq_khz = 48, |
| 101 | .container_bits_per_sample = 32, |
| 102 | .valid_bits_per_sample = 24, |
| 103 | .settings_file = "max98357-render-2ch-48khz-24b.bin", |
| 104 | }, |
| 105 | }; |
| 106 | |
| 107 | static const struct nhlt_endp_descriptor max98357_descriptors[] = { |
| 108 | { |
| 109 | .link = NHLT_LINK_SSP, |
| 110 | .device = NHLT_SSP_DEV_I2S, |
| 111 | .direction = NHLT_DIR_RENDER, |
| 112 | .vid = NHLT_VID, |
| 113 | .did = NHLT_DID_SSP, |
| 114 | .formats = max98357_formats, |
| 115 | .num_formats = ARRAY_SIZE(max98357_formats), |
| 116 | }, |
| 117 | }; |
| 118 | |
| 119 | int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels) |
| 120 | { |
| 121 | if (num_channels != 2) { |
| 122 | printk(BIOS_ERR, "APL only supports 2CH DMIC array.\n"); |
| 123 | return -1; |
| 124 | } |
| 125 | |
| 126 | return nhlt_add_endpoints(nhlt, dmic_2ch_descriptors, |
| 127 | ARRAY_SIZE(dmic_2ch_descriptors)); |
| 128 | } |
| 129 | |
| 130 | int nhlt_soc_add_da7219(struct nhlt *nhlt, int hwlink) |
| 131 | { |
| 132 | /* Virtual bus id of SSP links are the hardware port ids proper. */ |
| 133 | return nhlt_add_ssp_endpoints(nhlt, hwlink, da7219_descriptors, |
| 134 | ARRAY_SIZE(da7219_descriptors)); |
| 135 | } |
| 136 | |
| 137 | int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink) |
| 138 | { |
| 139 | /* Virtual bus id of SSP links are the hardware port ids proper. */ |
| 140 | return nhlt_add_ssp_endpoints(nhlt, hwlink, max98357_descriptors, |
| 141 | ARRAY_SIZE(max98357_descriptors)); |
| 142 | } |