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 <awalls@md.metrocast.net>
6 * Copyright (C) 2009 Devin Heitmueller <dheitmueller@kernellabs.com>
7 */
8
9 struct snd_card;
10
11 struct snd_ivtv_card {
12 struct v4l2_device *v4l2_dev;
13 struct snd_card *sc;
14 unsigned int capture_transfer_done;
15 unsigned int hwptr_done_capture;
16 struct snd_pcm_substream *capture_pcm_substream;
17 spinlock_t slock;
18 };
19
20 extern int ivtv_alsa_debug;
21
22 /*
23 * File operations that manipulate the encoder or video or audio subdevices
24 * need to be serialized. Use the same lock we use for v4l2 file ops.
25 */
snd_ivtv_lock(struct snd_ivtv_card * itvsc)26 static inline void snd_ivtv_lock(struct snd_ivtv_card *itvsc)
27 {
28 struct ivtv *itv = to_ivtv(itvsc->v4l2_dev);
29 mutex_lock(&itv->serialize_lock);
30 }
31
snd_ivtv_unlock(struct snd_ivtv_card * itvsc)32 static inline void snd_ivtv_unlock(struct snd_ivtv_card *itvsc)
33 {
34 struct ivtv *itv = to_ivtv(itvsc->v4l2_dev);
35 mutex_unlock(&itv->serialize_lock);
36 }
37
38 #define IVTV_ALSA_DBGFLG_WARN (1 << 0)
39 #define IVTV_ALSA_DBGFLG_INFO (1 << 1)
40
41 #define IVTV_ALSA_DEBUG(x, type, fmt, args...) \
42 do { \
43 if ((x) & ivtv_alsa_debug) \
44 pr_info("%s-alsa: " type ": " fmt, \
45 v4l2_dev->name , ## args); \
46 } while (0)
47
48 #define IVTV_ALSA_DEBUG_WARN(fmt, args...) \
49 IVTV_ALSA_DEBUG(IVTV_ALSA_DBGFLG_WARN, "warning", fmt , ## args)
50
51 #define IVTV_ALSA_DEBUG_INFO(fmt, args...) \
52 IVTV_ALSA_DEBUG(IVTV_ALSA_DBGFLG_INFO, "info", fmt , ## args)
53
54 #define IVTV_ALSA_ERR(fmt, args...) \
55 pr_err("%s-alsa: " fmt, v4l2_dev->name , ## args)
56
57 #define IVTV_ALSA_WARN(fmt, args...) \
58 pr_warn("%s-alsa: " fmt, v4l2_dev->name , ## args)
59
60 #define IVTV_ALSA_INFO(fmt, args...) \
61 pr_info("%s-alsa: " fmt, v4l2_dev->name , ## args)
62