cx18-alsa.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * ALSA interface to cx18 PCM capture streams
  3. *
  4. * Copyright (C) 2009 Andy Walls <awalls@md.metrocast.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. struct snd_card;
  17. struct snd_cx18_card {
  18. struct v4l2_device *v4l2_dev;
  19. struct snd_card *sc;
  20. unsigned int capture_transfer_done;
  21. unsigned int hwptr_done_capture;
  22. struct snd_pcm_substream *capture_pcm_substream;
  23. spinlock_t slock;
  24. };
  25. extern int cx18_alsa_debug;
  26. /*
  27. * File operations that manipulate the encoder or video or audio subdevices
  28. * need to be serialized. Use the same lock we use for v4l2 file ops.
  29. */
  30. static inline void snd_cx18_lock(struct snd_cx18_card *cxsc)
  31. {
  32. struct cx18 *cx = to_cx18(cxsc->v4l2_dev);
  33. mutex_lock(&cx->serialize_lock);
  34. }
  35. static inline void snd_cx18_unlock(struct snd_cx18_card *cxsc)
  36. {
  37. struct cx18 *cx = to_cx18(cxsc->v4l2_dev);
  38. mutex_unlock(&cx->serialize_lock);
  39. }
  40. #define CX18_ALSA_DBGFLG_WARN (1 << 0)
  41. #define CX18_ALSA_DBGFLG_INFO (1 << 1)
  42. #define CX18_ALSA_DEBUG(x, type, fmt, args...) \
  43. do { \
  44. if ((x) & cx18_alsa_debug) \
  45. printk(KERN_INFO "%s-alsa: " type ": " fmt, \
  46. v4l2_dev->name , ## args); \
  47. } while (0)
  48. #define CX18_ALSA_DEBUG_WARN(fmt, args...) \
  49. CX18_ALSA_DEBUG(CX18_ALSA_DBGFLG_WARN, "warning", fmt , ## args)
  50. #define CX18_ALSA_DEBUG_INFO(fmt, args...) \
  51. CX18_ALSA_DEBUG(CX18_ALSA_DBGFLG_INFO, "info", fmt , ## args)
  52. #define CX18_ALSA_ERR(fmt, args...) \
  53. printk(KERN_ERR "%s-alsa: " fmt, v4l2_dev->name , ## args)
  54. #define CX18_ALSA_WARN(fmt, args...) \
  55. printk(KERN_WARNING "%s-alsa: " fmt, v4l2_dev->name , ## args)
  56. #define CX18_ALSA_INFO(fmt, args...) \
  57. printk(KERN_INFO "%s-alsa: " fmt, v4l2_dev->name , ## args)