forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/drivers/pcsp/pcsp_lib.c
....@@ -23,10 +23,10 @@
2323 #define DMIX_WANTS_S16 1
2424
2525 /*
26
- * Call snd_pcm_period_elapsed in a tasklet
26
+ * Call snd_pcm_period_elapsed in a work
2727 * This avoids spinlock messes and long-running irq contexts
2828 */
29
-static void pcsp_call_pcm_elapsed(unsigned long priv)
29
+static void pcsp_call_pcm_elapsed(struct work_struct *work)
3030 {
3131 if (atomic_read(&pcsp_chip.timer_active)) {
3232 struct snd_pcm_substream *substream;
....@@ -36,7 +36,7 @@
3636 }
3737 }
3838
39
-static DECLARE_TASKLET(pcsp_pcm_tasklet, pcsp_call_pcm_elapsed, 0);
39
+static DECLARE_WORK(pcsp_pcm_work, pcsp_call_pcm_elapsed);
4040
4141 /* write the port and returns the next expire time in ns;
4242 * called at the trigger-start and in hrtimer callback
....@@ -119,11 +119,9 @@
119119 if (periods_elapsed) {
120120 chip->period_ptr += periods_elapsed * period_bytes;
121121 chip->period_ptr %= buffer_bytes;
122
+ queue_work(system_highpri_wq, &pcsp_pcm_work);
122123 }
123124 spin_unlock_irqrestore(&chip->substream_lock, flags);
124
-
125
- if (periods_elapsed)
126
- tasklet_schedule(&pcsp_pcm_tasklet);
127125 }
128126
129127 enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
....@@ -196,7 +194,7 @@
196194 pcsp_stop_playing(chip);
197195 local_irq_enable();
198196 hrtimer_cancel(&chip->timer);
199
- tasklet_kill(&pcsp_pcm_tasklet);
197
+ cancel_work_sync(&pcsp_pcm_work);
200198 }
201199
202200 static int snd_pcsp_playback_close(struct snd_pcm_substream *substream)
....@@ -214,12 +212,7 @@
214212 struct snd_pcm_hw_params *hw_params)
215213 {
216214 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
217
- int err;
218215 pcsp_sync_stop(chip);
219
- err = snd_pcm_lib_malloc_pages(substream,
220
- params_buffer_bytes(hw_params));
221
- if (err < 0)
222
- return err;
223216 return 0;
224217 }
225218
....@@ -230,7 +223,7 @@
230223 printk(KERN_INFO "PCSP: hw_free called\n");
231224 #endif
232225 pcsp_sync_stop(chip);
233
- return snd_pcm_lib_free_pages(substream);
226
+ return 0;
234227 }
235228
236229 static int snd_pcsp_playback_prepare(struct snd_pcm_substream *substream)
....@@ -327,7 +320,6 @@
327320 static const struct snd_pcm_ops snd_pcsp_playback_ops = {
328321 .open = snd_pcsp_playback_open,
329322 .close = snd_pcsp_playback_close,
330
- .ioctl = snd_pcm_lib_ioctl,
331323 .hw_params = snd_pcsp_playback_hw_params,
332324 .hw_free = snd_pcsp_playback_hw_free,
333325 .prepare = snd_pcsp_playback_prepare,
....@@ -350,11 +342,11 @@
350342 chip->pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
351343 strcpy(chip->pcm->name, "pcsp");
352344
353
- snd_pcm_lib_preallocate_pages_for_all(chip->pcm,
354
- SNDRV_DMA_TYPE_CONTINUOUS,
355
- snd_dma_continuous_data
356
- (GFP_KERNEL), PCSP_BUFFER_SIZE,
357
- PCSP_BUFFER_SIZE);
345
+ snd_pcm_set_managed_buffer_all(chip->pcm,
346
+ SNDRV_DMA_TYPE_CONTINUOUS,
347
+ NULL,
348
+ PCSP_BUFFER_SIZE,
349
+ PCSP_BUFFER_SIZE);
358350
359351 return 0;
360352 }