Skip to content

Commit 50f3beb

Browse files
author
Mauro Carvalho Chehab
committed
V4L/DVB (9742): em28xx-alsa: implement another locking schema
Instead of using a spinlock, it is better to call the proper pcm stream locking schema. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 7a8f4cc commit 50f3beb

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

drivers/media/video/em28xx/em28xx-audio.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ static void em28xx_audio_isocirq(struct urb *urb)
7575
struct em28xx *dev = urb->context;
7676
int i;
7777
unsigned int oldptr;
78+
#ifdef NO_PCM_LOCK
7879
unsigned long flags;
80+
#endif
7981
int period_elapsed = 0;
8082
int status;
8183
unsigned char *cp;
@@ -96,9 +98,26 @@ static void em28xx_audio_isocirq(struct urb *urb)
9698
if (!length)
9799
continue;
98100

101+
#ifdef NO_PCM_LOCK
99102
spin_lock_irqsave(&dev->adev->slock, flags);
100-
103+
#endif
101104
oldptr = dev->adev->hwptr_done_capture;
105+
if (oldptr + length >= runtime->buffer_size) {
106+
unsigned int cnt =
107+
runtime->buffer_size - oldptr;
108+
memcpy(runtime->dma_area + oldptr * stride, cp,
109+
cnt * stride);
110+
memcpy(runtime->dma_area, cp + cnt * stride,
111+
length * stride - cnt * stride);
112+
} else {
113+
memcpy(runtime->dma_area + oldptr * stride, cp,
114+
length * stride);
115+
}
116+
117+
#ifndef NO_PCM_LOCK
118+
snd_pcm_stream_lock(substream);
119+
#endif
120+
102121
dev->adev->hwptr_done_capture += length;
103122
if (dev->adev->hwptr_done_capture >=
104123
runtime->buffer_size)
@@ -113,19 +132,11 @@ static void em28xx_audio_isocirq(struct urb *urb)
113132
period_elapsed = 1;
114133
}
115134

135+
#ifdef NO_PCM_LOCK
116136
spin_unlock_irqrestore(&dev->adev->slock, flags);
117-
118-
if (oldptr + length >= runtime->buffer_size) {
119-
unsigned int cnt =
120-
runtime->buffer_size - oldptr;
121-
memcpy(runtime->dma_area + oldptr * stride, cp,
122-
cnt * stride);
123-
memcpy(runtime->dma_area, cp + cnt * stride,
124-
length * stride - cnt * stride);
125-
} else {
126-
memcpy(runtime->dma_area + oldptr * stride, cp,
127-
length * stride);
128-
}
137+
#else
138+
snd_pcm_stream_unlock(substream);
139+
#endif
129140
}
130141
if (period_elapsed)
131142
snd_pcm_period_elapsed(substream);

0 commit comments

Comments
 (0)