Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * media.h - Media Controller specific ALSA driver code
0004  *
0005  * Copyright (c) 2019 Shuah Khan <shuah@kernel.org>
0006  *
0007  */
0008 
0009 /*
0010  * This file adds Media Controller support to the ALSA driver
0011  * to use the Media Controller API to share the tuner with DVB
0012  * and V4L2 drivers that control the media device.
0013  *
0014  * The media device is created based on the existing quirks framework.
0015  * Using this approach, the media controller API usage can be added for
0016  * a specific device.
0017  */
0018 #ifndef __MEDIA_H
0019 
0020 #ifdef CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER
0021 
0022 #include <linux/media.h>
0023 #include <media/media-device.h>
0024 #include <media/media-entity.h>
0025 #include <media/media-dev-allocator.h>
0026 #include <sound/asound.h>
0027 
0028 struct media_ctl {
0029     struct media_device *media_dev;
0030     struct media_entity media_entity;
0031     struct media_intf_devnode *intf_devnode;
0032     struct media_link *intf_link;
0033     struct media_pad media_pad;
0034     struct media_pipeline media_pipe;
0035 };
0036 
0037 /*
0038  * One source pad each for SNDRV_PCM_STREAM_CAPTURE and
0039  * SNDRV_PCM_STREAM_PLAYBACK. One for sink pad to link
0040  * to AUDIO Source
0041  */
0042 #define MEDIA_MIXER_PAD_MAX    (SNDRV_PCM_STREAM_LAST + 2)
0043 
0044 struct media_mixer_ctl {
0045     struct media_device *media_dev;
0046     struct media_entity media_entity;
0047     struct media_intf_devnode *intf_devnode;
0048     struct media_link *intf_link;
0049     struct media_pad media_pad[MEDIA_MIXER_PAD_MAX];
0050     struct media_pipeline media_pipe;
0051 };
0052 
0053 int snd_media_device_create(struct snd_usb_audio *chip,
0054                 struct usb_interface *iface);
0055 void snd_media_device_delete(struct snd_usb_audio *chip);
0056 int snd_media_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,
0057               int stream);
0058 void snd_media_stream_delete(struct snd_usb_substream *subs);
0059 int snd_media_start_pipeline(struct snd_usb_substream *subs);
0060 void snd_media_stop_pipeline(struct snd_usb_substream *subs);
0061 #else
0062 static inline int snd_media_device_create(struct snd_usb_audio *chip,
0063                       struct usb_interface *iface)
0064                         { return 0; }
0065 static inline void snd_media_device_delete(struct snd_usb_audio *chip) { }
0066 static inline int snd_media_stream_init(struct snd_usb_substream *subs,
0067                     struct snd_pcm *pcm, int stream)
0068                         { return 0; }
0069 static inline void snd_media_stream_delete(struct snd_usb_substream *subs) { }
0070 static inline int snd_media_start_pipeline(struct snd_usb_substream *subs)
0071                     { return 0; }
0072 static inline void snd_media_stop_pipeline(struct snd_usb_substream *subs) { }
0073 #endif
0074 #endif /* __MEDIA_H */