cx18-alsa.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ALSA interface to cx18 PCM capture streams
  4. *
  5. * Copyright (C) 2009 Andy Walls <[email protected]>
  6. */
  7. struct snd_card;
  8. struct snd_cx18_card {
  9. struct v4l2_device *v4l2_dev;
  10. struct snd_card *sc;
  11. unsigned int capture_transfer_done;
  12. unsigned int hwptr_done_capture;
  13. struct snd_pcm_substream *capture_pcm_substream;
  14. spinlock_t slock;
  15. };
  16. extern int cx18_alsa_debug;
  17. /*
  18. * File operations that manipulate the encoder or video or audio subdevices
  19. * need to be serialized. Use the same lock we use for v4l2 file ops.
  20. */
  21. static inline void snd_cx18_lock(struct snd_cx18_card *cxsc)
  22. {
  23. struct cx18 *cx = to_cx18(cxsc->v4l2_dev);
  24. mutex_lock(&cx->serialize_lock);
  25. }
  26. static inline void snd_cx18_unlock(struct snd_cx18_card *cxsc)
  27. {
  28. struct cx18 *cx = to_cx18(cxsc->v4l2_dev);
  29. mutex_unlock(&cx->serialize_lock);
  30. }
  31. #define CX18_ALSA_DBGFLG_WARN (1 << 0)
  32. #define CX18_ALSA_DBGFLG_INFO (1 << 1)
  33. #define CX18_ALSA_DEBUG(x, type, fmt, args...) \
  34. do { \
  35. if ((x) & cx18_alsa_debug) \
  36. printk(KERN_INFO "%s-alsa: " type ": " fmt, \
  37. v4l2_dev->name , ## args); \
  38. } while (0)
  39. #define CX18_ALSA_DEBUG_WARN(fmt, args...) \
  40. CX18_ALSA_DEBUG(CX18_ALSA_DBGFLG_WARN, "warning", fmt , ## args)
  41. #define CX18_ALSA_DEBUG_INFO(fmt, args...) \
  42. CX18_ALSA_DEBUG(CX18_ALSA_DBGFLG_INFO, "info", fmt , ## args)
  43. #define CX18_ALSA_ERR(fmt, args...) \
  44. printk(KERN_ERR "%s-alsa: " fmt, v4l2_dev->name , ## args)
  45. #define CX18_ALSA_WARN(fmt, args...) \
  46. printk(KERN_WARNING "%s-alsa: " fmt, v4l2_dev->name , ## args)
  47. #define CX18_ALSA_INFO(fmt, args...) \
  48. printk(KERN_INFO "%s-alsa: " fmt, v4l2_dev->name , ## args)