Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 // Copyright (c) 2020 Intel Corporation
0003 
0004 /*
0005  *  sof_sdw_hdmi - Helpers to handle HDMI from generic machine driver
0006  */
0007 
0008 #include <linux/device.h>
0009 #include <linux/errno.h>
0010 #include <linux/kernel.h>
0011 #include <linux/list.h>
0012 #include <sound/soc.h>
0013 #include <sound/soc-acpi.h>
0014 #include <sound/jack.h>
0015 #include "sof_sdw_common.h"
0016 #include "hda_dsp_common.h"
0017 
0018 struct hdmi_pcm {
0019     struct list_head head;
0020     struct snd_soc_dai *codec_dai;
0021     int device;
0022 };
0023 
0024 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd)
0025 {
0026     struct mc_private *ctx = snd_soc_card_get_drvdata(rtd->card);
0027     struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
0028     struct hdmi_pcm *pcm;
0029 
0030     pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
0031     if (!pcm)
0032         return -ENOMEM;
0033 
0034     /* dai_link id is 1:1 mapped to the PCM device */
0035     pcm->device = rtd->dai_link->id;
0036     pcm->codec_dai = dai;
0037 
0038     list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
0039 
0040     return 0;
0041 }
0042 
0043 #define NAME_SIZE   32
0044 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card)
0045 {
0046     struct mc_private *ctx = snd_soc_card_get_drvdata(card);
0047     struct hdmi_pcm *pcm;
0048     struct snd_soc_component *component = NULL;
0049 
0050     if (!ctx->idisp_codec)
0051         return 0;
0052 
0053     if (list_empty(&ctx->hdmi_pcm_list))
0054         return -EINVAL;
0055 
0056     pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
0057                    head);
0058     component = pcm->codec_dai->component;
0059 
0060     return hda_dsp_hdmi_build_controls(card, component);
0061 }