~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/codecs/hda-dai.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 //
  3 // Copyright(c) 2021-2022 Intel Corporation
  4 //
  5 // Author: Cezary Rojewski <cezary.rojewski@intel.com>
  6 //
  7 
  8 #include <sound/soc.h>
  9 #include <sound/hda_codec.h>
 10 #include "hda.h"
 11 
 12 static int hda_codec_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
 13 {
 14         struct hda_pcm_stream *stream_info;
 15         struct hda_codec *codec;
 16         struct hda_pcm *pcm;
 17         int ret;
 18 
 19         codec = dev_to_hda_codec(dai->dev);
 20         stream_info = snd_soc_dai_get_dma_data(dai, substream);
 21         pcm = container_of(stream_info, struct hda_pcm, stream[substream->stream]);
 22 
 23         dev_dbg(dai->dev, "open stream codec: %08x, info: %p, pcm: %p %s substream: %p\n",
 24                 codec->core.vendor_id, stream_info, pcm, pcm->name, substream);
 25 
 26         snd_hda_codec_pcm_get(pcm);
 27 
 28         ret = stream_info->ops.open(stream_info, codec, substream);
 29         if (ret < 0) {
 30                 dev_err(dai->dev, "codec open failed: %d\n", ret);
 31                 snd_hda_codec_pcm_put(pcm);
 32                 return ret;
 33         }
 34 
 35         return 0;
 36 }
 37 
 38 static void hda_codec_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
 39 {
 40         struct hda_pcm_stream *stream_info;
 41         struct hda_codec *codec;
 42         struct hda_pcm *pcm;
 43         int ret;
 44 
 45         codec = dev_to_hda_codec(dai->dev);
 46         stream_info = snd_soc_dai_get_dma_data(dai, substream);
 47         pcm = container_of(stream_info, struct hda_pcm, stream[substream->stream]);
 48 
 49         dev_dbg(dai->dev, "close stream codec: %08x, info: %p, pcm: %p %s substream: %p\n",
 50                 codec->core.vendor_id, stream_info, pcm, pcm->name, substream);
 51 
 52         ret = stream_info->ops.close(stream_info, codec, substream);
 53         if (ret < 0)
 54                 dev_err(dai->dev, "codec close failed: %d\n", ret);
 55 
 56         snd_hda_codec_pcm_put(pcm);
 57 }
 58 
 59 static int hda_codec_dai_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
 60 {
 61         struct hda_pcm_stream *stream_info;
 62         struct hda_codec *codec;
 63 
 64         codec = dev_to_hda_codec(dai->dev);
 65         stream_info = snd_soc_dai_get_dma_data(dai, substream);
 66 
 67         snd_hda_codec_cleanup(codec, stream_info, substream);
 68 
 69         return 0;
 70 }
 71 
 72 static int hda_codec_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
 73 {
 74         struct snd_pcm_runtime *runtime = substream->runtime;
 75         struct hda_pcm_stream *stream_info;
 76         struct hdac_stream *stream;
 77         struct hda_codec *codec;
 78         unsigned int format;
 79         unsigned int bits;
 80         int ret;
 81 
 82         codec = dev_to_hda_codec(dai->dev);
 83         stream = substream->runtime->private_data;
 84         stream_info = snd_soc_dai_get_dma_data(dai, substream);
 85 
 86         bits = snd_hdac_stream_format_bits(runtime->format, runtime->subformat,
 87                                            stream_info->maxbps);
 88         format = snd_hdac_stream_format(runtime->channels, bits, runtime->rate);
 89 
 90         ret = snd_hda_codec_prepare(codec, stream_info, stream->stream_tag, format, substream);
 91         if (ret < 0) {
 92                 dev_err(dai->dev, "codec prepare failed: %d\n", ret);
 93                 return ret;
 94         }
 95 
 96         return 0;
 97 }
 98 
 99 const struct snd_soc_dai_ops snd_soc_hda_codec_dai_ops = {
100         .startup = hda_codec_dai_startup,
101         .shutdown = hda_codec_dai_shutdown,
102         .hw_free = hda_codec_dai_hw_free,
103         .prepare = hda_codec_dai_prepare,
104 };
105 EXPORT_SYMBOL_GPL(snd_soc_hda_codec_dai_ops);
106 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php