Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  ALSA interface to ivtv PCM capture streams
0004  *
0005  *  Copyright (C) 2009,2012  Andy Walls <awalls@md.metrocast.net>
0006  *  Copyright (C) 2009  Devin Heitmueller <dheitmueller@kernellabs.com>
0007  */
0008 
0009 struct snd_card;
0010 
0011 struct snd_ivtv_card {
0012     struct v4l2_device *v4l2_dev;
0013     struct snd_card *sc;
0014     unsigned int capture_transfer_done;
0015     unsigned int hwptr_done_capture;
0016     struct snd_pcm_substream *capture_pcm_substream;
0017     spinlock_t slock;
0018 };
0019 
0020 extern int ivtv_alsa_debug;
0021 
0022 /*
0023  * File operations that manipulate the encoder or video or audio subdevices
0024  * need to be serialized.  Use the same lock we use for v4l2 file ops.
0025  */
0026 static inline void snd_ivtv_lock(struct snd_ivtv_card *itvsc)
0027 {
0028     struct ivtv *itv = to_ivtv(itvsc->v4l2_dev);
0029     mutex_lock(&itv->serialize_lock);
0030 }
0031 
0032 static inline void snd_ivtv_unlock(struct snd_ivtv_card *itvsc)
0033 {
0034     struct ivtv *itv = to_ivtv(itvsc->v4l2_dev);
0035     mutex_unlock(&itv->serialize_lock);
0036 }
0037 
0038 #define IVTV_ALSA_DBGFLG_WARN  (1 << 0)
0039 #define IVTV_ALSA_DBGFLG_INFO  (1 << 1)
0040 
0041 #define IVTV_ALSA_DEBUG(x, type, fmt, args...) \
0042     do { \
0043         if ((x) & ivtv_alsa_debug) \
0044             pr_info("%s-alsa: " type ": " fmt, \
0045                 v4l2_dev->name , ## args); \
0046     } while (0)
0047 
0048 #define IVTV_ALSA_DEBUG_WARN(fmt, args...) \
0049     IVTV_ALSA_DEBUG(IVTV_ALSA_DBGFLG_WARN, "warning", fmt , ## args)
0050 
0051 #define IVTV_ALSA_DEBUG_INFO(fmt, args...) \
0052     IVTV_ALSA_DEBUG(IVTV_ALSA_DBGFLG_INFO, "info", fmt , ## args)
0053 
0054 #define IVTV_ALSA_ERR(fmt, args...) \
0055     pr_err("%s-alsa: " fmt, v4l2_dev->name , ## args)
0056 
0057 #define IVTV_ALSA_WARN(fmt, args...) \
0058     pr_warn("%s-alsa: " fmt, v4l2_dev->name , ## args)
0059 
0060 #define IVTV_ALSA_INFO(fmt, args...) \
0061     pr_info("%s-alsa: " fmt, v4l2_dev->name , ## args)