^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0+ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * media.h - Media Controller specific ALSA driver code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2019 Shuah Khan <shuah@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * This file adds Media Controller support to the ALSA driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * to use the Media Controller API to share the tuner with DVB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * and V4L2 drivers that control the media device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * The media device is created based on the existing quirks framework.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Using this approach, the media controller API usage can be added for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * a specific device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #ifndef __MEDIA_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #ifdef CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/media.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <media/media-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <media/media-entity.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <media/media-dev-allocator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <sound/asound.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct media_ctl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct media_device *media_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct media_entity media_entity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct media_intf_devnode *intf_devnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct media_link *intf_link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct media_pad media_pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct media_pipeline media_pipe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * One source pad each for SNDRV_PCM_STREAM_CAPTURE and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * SNDRV_PCM_STREAM_PLAYBACK. One for sink pad to link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * to AUDIO Source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define MEDIA_MIXER_PAD_MAX (SNDRV_PCM_STREAM_LAST + 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct media_mixer_ctl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct media_device *media_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct media_entity media_entity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct media_intf_devnode *intf_devnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct media_link *intf_link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct media_pad media_pad[MEDIA_MIXER_PAD_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct media_pipeline media_pipe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int snd_media_device_create(struct snd_usb_audio *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct usb_interface *iface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) void snd_media_device_delete(struct snd_usb_audio *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int snd_media_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void snd_media_stream_delete(struct snd_usb_substream *subs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int snd_media_start_pipeline(struct snd_usb_substream *subs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void snd_media_stop_pipeline(struct snd_usb_substream *subs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static inline int snd_media_device_create(struct snd_usb_audio *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct usb_interface *iface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static inline void snd_media_device_delete(struct snd_usb_audio *chip) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static inline int snd_media_stream_init(struct snd_usb_substream *subs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct snd_pcm *pcm, int stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static inline void snd_media_stream_delete(struct snd_usb_substream *subs) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static inline int snd_media_start_pipeline(struct snd_usb_substream *subs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static inline void snd_media_stop_pipeline(struct snd_usb_substream *subs) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #endif /* __MEDIA_H */