media.h 2.4 KB

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