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