ivtv-alsa.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ALSA interface to ivtv PCM capture streams
  4. *
  5. * Copyright (C) 2009,2012 Andy Walls <[email protected]>
  6. * Copyright (C) 2009 Devin Heitmueller <[email protected]>
  7. */
  8. struct snd_card;
  9. struct snd_ivtv_card {
  10. struct v4l2_device *v4l2_dev;
  11. struct snd_card *sc;
  12. unsigned int capture_transfer_done;
  13. unsigned int hwptr_done_capture;
  14. struct snd_pcm_substream *capture_pcm_substream;
  15. spinlock_t slock;
  16. };
  17. extern int ivtv_alsa_debug;
  18. /*
  19. * File operations that manipulate the encoder or video or audio subdevices
  20. * need to be serialized. Use the same lock we use for v4l2 file ops.
  21. */
  22. static inline void snd_ivtv_lock(struct snd_ivtv_card *itvsc)
  23. {
  24. struct ivtv *itv = to_ivtv(itvsc->v4l2_dev);
  25. mutex_lock(&itv->serialize_lock);
  26. }
  27. static inline void snd_ivtv_unlock(struct snd_ivtv_card *itvsc)
  28. {
  29. struct ivtv *itv = to_ivtv(itvsc->v4l2_dev);
  30. mutex_unlock(&itv->serialize_lock);
  31. }
  32. #define IVTV_ALSA_DBGFLG_WARN (1 << 0)
  33. #define IVTV_ALSA_DBGFLG_INFO (1 << 1)
  34. #define IVTV_ALSA_DEBUG(x, type, fmt, args...) \
  35. do { \
  36. if ((x) & ivtv_alsa_debug) \
  37. pr_info("%s-alsa: " type ": " fmt, \
  38. v4l2_dev->name , ## args); \
  39. } while (0)
  40. #define IVTV_ALSA_DEBUG_WARN(fmt, args...) \
  41. IVTV_ALSA_DEBUG(IVTV_ALSA_DBGFLG_WARN, "warning", fmt , ## args)
  42. #define IVTV_ALSA_DEBUG_INFO(fmt, args...) \
  43. IVTV_ALSA_DEBUG(IVTV_ALSA_DBGFLG_INFO, "info", fmt , ## args)
  44. #define IVTV_ALSA_ERR(fmt, args...) \
  45. pr_err("%s-alsa: " fmt, v4l2_dev->name , ## args)
  46. #define IVTV_ALSA_WARN(fmt, args...) \
  47. pr_warn("%s-alsa: " fmt, v4l2_dev->name , ## args)
  48. #define IVTV_ALSA_INFO(fmt, args...) \
  49. pr_info("%s-alsa: " fmt, v4l2_dev->name , ## args)