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