sound/soc/fsl/imx-hdmi.c
Source file repositories/reference/linux-study-clean/sound/soc/fsl/imx-hdmi.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/fsl/imx-hdmi.c- Extension
.c- Size
- 6033 bytes
- Lines
- 225
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/of_platform.hsound/jack.hsound/pcm_params.hsound/hdmi-codec.hfsl_sai.h
Detected Declarations
struct cpu_privstruct imx_hdmi_datafunction imx_hdmi_hw_paramsfunction imx_hdmi_initfunction imx_hdmi_probe
Annotated Snippet
struct cpu_priv {
u32 sysclk_id[2];
u32 slot_width;
};
struct imx_hdmi_data {
struct snd_soc_dai_link dai;
struct snd_soc_card card;
struct snd_soc_jack hdmi_jack;
struct snd_soc_jack_pin hdmi_jack_pin;
struct cpu_priv cpu_priv;
u32 dai_fmt;
};
static int imx_hdmi_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct imx_hdmi_data *data = snd_soc_card_get_drvdata(rtd->card);
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
struct snd_soc_card *card = rtd->card;
struct device *dev = card->dev;
u32 slot_width = data->cpu_priv.slot_width;
int ret;
/* MCLK always is (256 or 192) * rate. */
ret = snd_soc_dai_set_sysclk(cpu_dai, data->cpu_priv.sysclk_id[tx],
8 * slot_width * params_rate(params),
tx ? SND_SOC_CLOCK_OUT : SND_SOC_CLOCK_IN);
if (ret && ret != -ENOTSUPP) {
dev_err(dev, "failed to set cpu sysclk: %d\n", ret);
return ret;
}
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0, 2, slot_width);
if (ret && ret != -ENOTSUPP) {
dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
return ret;
}
return 0;
}
static const struct snd_soc_ops imx_hdmi_ops = {
.hw_params = imx_hdmi_hw_params,
};
static const struct snd_soc_dapm_widget imx_hdmi_widgets[] = {
SND_SOC_DAPM_LINE("HDMI Jack", NULL),
};
static int imx_hdmi_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
struct snd_soc_component *component = codec_dai->component;
struct imx_hdmi_data *data = snd_soc_card_get_drvdata(card);
int ret;
data->hdmi_jack_pin.pin = "HDMI Jack";
data->hdmi_jack_pin.mask = SND_JACK_LINEOUT;
/* enable jack detection */
ret = snd_soc_card_jack_new_pins(card, "HDMI Jack", SND_JACK_LINEOUT,
&data->hdmi_jack,
&data->hdmi_jack_pin, 1);
if (ret) {
dev_err(card->dev, "Can't new HDMI Jack %d\n", ret);
return ret;
}
ret = snd_soc_component_set_jack(component, &data->hdmi_jack, NULL);
if (ret && ret != -ENOTSUPP) {
dev_err(card->dev, "Can't set HDMI Jack %d\n", ret);
return ret;
}
return 0;
};
static int imx_hdmi_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
bool hdmi_out = of_property_read_bool(np, "hdmi-out");
bool hdmi_in = of_property_read_bool(np, "hdmi-in");
struct snd_soc_dai_link_component *dlc;
struct device_node *cpu_np;
struct imx_hdmi_data *data;
int ret;
Annotation
- Immediate include surface: `linux/module.h`, `linux/of_platform.h`, `sound/jack.h`, `sound/pcm_params.h`, `sound/hdmi-codec.h`, `fsl_sai.h`.
- Detected declarations: `struct cpu_priv`, `struct imx_hdmi_data`, `function imx_hdmi_hw_params`, `function imx_hdmi_init`, `function imx_hdmi_probe`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.