ALSA: hda - Add hdmi chmap verb programming ops to chmap object
[deliverable/linux.git] / sound / hda / hdmi_chmap.c
CommitLineData
739ffee9
SP
1/*
2 * HDMI Channel map support helpers
3 */
4
5#include <sound/hda_chmap.h>
6
7static int hdmi_pin_set_slot_channel(struct hdac_device *codec,
8 hda_nid_t pin_nid, int asp_slot, int channel)
9{
10 return snd_hdac_codec_write(codec, pin_nid, 0,
11 AC_VERB_SET_HDMI_CHAN_SLOT,
12 (channel << 4) | asp_slot);
13}
14
15static int hdmi_pin_get_slot_channel(struct hdac_device *codec,
16 hda_nid_t pin_nid, int asp_slot)
17{
18 return (snd_hdac_codec_read(codec, pin_nid, 0,
19 AC_VERB_GET_HDMI_CHAN_SLOT,
20 asp_slot) & 0xf0) >> 4;
21}
22
23static int hdmi_get_channel_count(struct hdac_device *codec, hda_nid_t cvt_nid)
24{
25 return 1 + snd_hdac_codec_read(codec, cvt_nid, 0,
26 AC_VERB_GET_CVT_CHAN_COUNT, 0);
27}
28
29static void hdmi_set_channel_count(struct hdac_device *codec,
30 hda_nid_t cvt_nid, int chs)
31{
32 if (chs != hdmi_get_channel_count(codec, cvt_nid))
33 snd_hdac_codec_write(codec, cvt_nid, 0,
34 AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
35}
36
37static const struct hdac_chmap_ops chmap_ops = {
38 .pin_get_slot_channel = hdmi_pin_get_slot_channel,
39 .pin_set_slot_channel = hdmi_pin_set_slot_channel,
40 .set_channel_count = hdmi_set_channel_count,
41};
42
43void snd_hdac_register_chmap_ops(struct hdac_device *hdac,
44 struct hdac_chmap *chmap)
45{
46 chmap->ops = chmap_ops;
47 chmap->hdac = hdac;
48}
49EXPORT_SYMBOL_GPL(snd_hdac_register_chmap_ops);
This page took 0.025173 seconds and 5 git commands to generate.