Lines Matching +full:virtio +full:- +full:device
1 // SPDX-License-Identifier: GPL-2.0+
3 * virtio-snd: Virtio sound device
16 * receive notifications about a plugged in/out device.
23 * struct virtio_jack - VirtIO jack.
26 * @features: Jack virtio feature bit map (1 << VIRTIO_SND_JACK_F_XXX).
43 * virtsnd_jack_get_label() - Get the name string for the jack.
44 * @vjack: VirtIO jack.
54 unsigned int defconf = vjack->defconf; in virtsnd_jack_get_label()
55 unsigned int device = in virtsnd_jack_get_label() local
60 switch (device) { in virtsnd_jack_get_label()
91 * virtsnd_jack_get_type() - Get the type for the jack.
92 * @vjack: VirtIO jack.
102 unsigned int defconf = vjack->defconf; in virtsnd_jack_get_type()
103 unsigned int device = in virtsnd_jack_get_type() local
106 switch (device) { in virtsnd_jack_get_type()
123 * virtsnd_jack_parse_cfg() - Parse the jack configuration.
124 * @snd: VirtIO sound device.
126 * This function is called during initial device initialization.
129 * Return: 0 on success, -errno on failure.
133 struct virtio_device *vdev = snd->vdev; in virtsnd_jack_parse_cfg()
138 virtio_cread_le(vdev, struct virtio_snd_config, jacks, &snd->njacks); in virtsnd_jack_parse_cfg()
139 if (!snd->njacks) in virtsnd_jack_parse_cfg()
142 snd->jacks = devm_kcalloc(&vdev->dev, snd->njacks, sizeof(*snd->jacks), in virtsnd_jack_parse_cfg()
144 if (!snd->jacks) in virtsnd_jack_parse_cfg()
145 return -ENOMEM; in virtsnd_jack_parse_cfg()
147 info = kcalloc(snd->njacks, sizeof(*info), GFP_KERNEL); in virtsnd_jack_parse_cfg()
149 return -ENOMEM; in virtsnd_jack_parse_cfg()
151 rc = virtsnd_ctl_query_info(snd, VIRTIO_SND_R_JACK_INFO, 0, snd->njacks, in virtsnd_jack_parse_cfg()
156 for (i = 0; i < snd->njacks; ++i) { in virtsnd_jack_parse_cfg()
157 struct virtio_jack *vjack = &snd->jacks[i]; in virtsnd_jack_parse_cfg()
159 vjack->nid = le32_to_cpu(info[i].hdr.hda_fn_nid); in virtsnd_jack_parse_cfg()
160 vjack->features = le32_to_cpu(info[i].features); in virtsnd_jack_parse_cfg()
161 vjack->defconf = le32_to_cpu(info[i].hda_reg_defconf); in virtsnd_jack_parse_cfg()
162 vjack->caps = le32_to_cpu(info[i].hda_reg_caps); in virtsnd_jack_parse_cfg()
163 vjack->connected = info[i].connected; in virtsnd_jack_parse_cfg()
173 * virtsnd_jack_build_devs() - Build ALSA controls for jacks.
174 * @snd: VirtIO sound device.
177 * Return: 0 on success, -errno on failure.
184 for (i = 0; i < snd->njacks; ++i) { in virtsnd_jack_build_devs()
185 struct virtio_jack *vjack = &snd->jacks[i]; in virtsnd_jack_build_devs()
187 vjack->type = virtsnd_jack_get_type(vjack); in virtsnd_jack_build_devs()
189 rc = snd_jack_new(snd->card, virtsnd_jack_get_label(vjack), in virtsnd_jack_build_devs()
190 vjack->type, &vjack->jack, true, true); in virtsnd_jack_build_devs()
194 if (vjack->jack) in virtsnd_jack_build_devs()
195 vjack->jack->private_data = vjack; in virtsnd_jack_build_devs()
197 snd_jack_report(vjack->jack, in virtsnd_jack_build_devs()
198 vjack->connected ? vjack->type : 0); in virtsnd_jack_build_devs()
205 * virtsnd_jack_event() - Handle the jack event notification.
206 * @snd: VirtIO sound device.
207 * @event: VirtIO sound event.
213 u32 jack_id = le32_to_cpu(event->data); in virtsnd_jack_event()
216 if (jack_id >= snd->njacks) in virtsnd_jack_event()
219 vjack = &snd->jacks[jack_id]; in virtsnd_jack_event()
221 switch (le32_to_cpu(event->hdr.code)) { in virtsnd_jack_event()
223 vjack->connected = true; in virtsnd_jack_event()
226 vjack->connected = false; in virtsnd_jack_event()
232 snd_jack_report(vjack->jack, vjack->connected ? vjack->type : 0); in virtsnd_jack_event()