Lines Matching +full:mclk +full:- +full:fs
1 // SPDX-License-Identifier: GPL-2.0-only
3 * skl-nhlt.c - Intel SKL Platform NHLT parsing
12 #include <sound/intel-nhlt.h>
14 #include "skl-i2s.h"
33 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; in skl_nhlt_update_topology_bin()
35 struct device *dev = bus->dev; in skl_nhlt_update_topology_bin()
38 nhlt->header.oem_id, nhlt->header.oem_table_id, in skl_nhlt_update_topology_bin()
39 nhlt->header.oem_revision); in skl_nhlt_update_topology_bin()
41 snprintf(skl->tplg_name, sizeof(skl->tplg_name), "%x-%.6s-%.8s-%d%s", in skl_nhlt_update_topology_bin()
42 skl->pci_id, nhlt->header.oem_id, nhlt->header.oem_table_id, in skl_nhlt_update_topology_bin()
43 nhlt->header.oem_revision, "-tplg.bin"); in skl_nhlt_update_topology_bin()
45 skl_nhlt_trim_space(skl->tplg_name); in skl_nhlt_update_topology_bin()
56 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; in platform_id_show()
59 sprintf(platform_id, "%x-%.6s-%.8s-%d", skl->pci_id, in platform_id_show()
60 nhlt->header.oem_id, nhlt->header.oem_table_id, in platform_id_show()
61 nhlt->header.oem_revision); in platform_id_show()
71 struct device *dev = &skl->pci->dev; in skl_nhlt_create_sysfs()
73 if (sysfs_create_file(&dev->kobj, &dev_attr_platform_id.attr)) in skl_nhlt_create_sysfs()
81 struct device *dev = &skl->pci->dev; in skl_nhlt_remove_sysfs()
83 if (skl->nhlt) in skl_nhlt_remove_sysfs()
84 sysfs_remove_file(&dev->kobj, &dev_attr_platform_id.attr); in skl_nhlt_remove_sysfs()
106 u32 fs; in skl_get_ssp_clks() local
111 if (fmt->fmt_count == 0) in skl_get_ssp_clks()
114 fmt_cfg = (struct nhlt_fmt_cfg *)fmt->fmt_config; in skl_get_ssp_clks()
115 for (i = 0; i < fmt->fmt_count; i++) { in skl_get_ssp_clks()
119 wav_fmt = &saved_fmt_cfg->fmt_ext; in skl_get_ssp_clks()
121 channels = wav_fmt->fmt.channels; in skl_get_ssp_clks()
122 bps = wav_fmt->fmt.bits_per_sample; in skl_get_ssp_clks()
123 fs = wav_fmt->fmt.samples_per_sec; in skl_get_ssp_clks()
132 * So for the given fs and bps, choose blob which has in skl_get_ssp_clks()
136 for (j = i; j < fmt->fmt_count; j++) { in skl_get_ssp_clks()
139 wav_fmt = &tmp_fmt_cfg->fmt_ext; in skl_get_ssp_clks()
140 if ((fs == wav_fmt->fmt.samples_per_sec) && in skl_get_ssp_clks()
141 (bps == wav_fmt->fmt.bits_per_sample)) { in skl_get_ssp_clks()
143 wav_fmt->fmt.channels); in skl_get_ssp_clks()
147 tmp_fmt_cfg = (struct nhlt_fmt_cfg *)(tmp_fmt_cfg->config.caps + in skl_get_ssp_clks()
148 tmp_fmt_cfg->config.size); in skl_get_ssp_clks()
151 rate = channels * bps * fs; in skl_get_ssp_clks()
166 first_fmt_cfg = (struct nhlt_fmt_cfg *)fmt->fmt_config; in skl_get_ssp_clks()
168 first_fmt_cfg->config.caps; in skl_get_ssp_clks()
170 /* MCLK Divider Source Select */ in skl_get_ssp_clks()
171 if (is_legacy_blob(i2s_config_ext->hdr.sig)) { in skl_get_ssp_clks()
173 clk_src = get_clk_src(i2s_config->mclk, in skl_get_ssp_clks()
176 clk_src = get_clk_src(i2s_config_ext->mclk, in skl_get_ssp_clks()
183 fmt_cfg = (struct nhlt_fmt_cfg *)(fmt_cfg->config.caps + in skl_get_ssp_clks()
184 fmt_cfg->config.size); in skl_get_ssp_clks()
196 sclk[id].parent_name = parent->name; in skl_get_ssp_clks()
197 sclkfs[id].parent_name = parent->name; in skl_get_ssp_clks()
204 static void skl_get_mclk(struct skl_dev *skl, struct skl_ssp_clk *mclk, in skl_get_mclk() argument
214 fmt_cfg = (struct nhlt_fmt_cfg *)fmt->fmt_config; in skl_get_mclk()
215 i2s_config_ext = (struct skl_i2s_config_blob_ext *)fmt_cfg->config.caps; in skl_get_mclk()
217 /* MCLK Divider Source Select and divider */ in skl_get_mclk()
218 if (is_legacy_blob(i2s_config_ext->hdr.sig)) { in skl_get_mclk()
220 clk_src = get_clk_src(i2s_config->mclk, in skl_get_mclk()
222 clkdiv = i2s_config->mclk.mdivr & in skl_get_mclk()
225 clk_src = get_clk_src(i2s_config_ext->mclk, in skl_get_mclk()
227 clkdiv = i2s_config_ext->mclk.mdivr[0] & in skl_get_mclk()
238 /* Calculate MCLK rate from source using div value */ in skl_get_mclk()
243 mclk[id].rate_cfg[0].rate = parent->rate/div_ratio; in skl_get_mclk()
244 mclk[id].rate_cfg[0].config = fmt_cfg; in skl_get_mclk()
245 mclk[id].parent_name = parent->name; in skl_get_mclk()
250 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; in skl_get_clks()
256 epnt = (struct nhlt_endpoint *)nhlt->desc; in skl_get_clks()
257 for (i = 0; i < nhlt->endpoint_count; i++) { in skl_get_clks()
258 if (epnt->linktype == NHLT_LINK_SSP) { in skl_get_clks()
259 id = epnt->virtual_bus_id; in skl_get_clks()
261 fmt = (struct nhlt_fmt *)(epnt->config.caps in skl_get_clks()
262 + epnt->config.size); in skl_get_clks()
267 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); in skl_get_clks()