Skip to content

Commit c90cc65

Browse files
committed
Merge remote-tracking branch 'takashi/for-next' into sound/upstream-20211207
2 parents 594d23e + 6fadb49 commit c90cc65

45 files changed

Lines changed: 336 additions & 425 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/sound/hda_codec.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndef __SOUND_HDA_CODEC_H
99
#define __SOUND_HDA_CODEC_H
1010

11-
#include <linux/kref.h>
11+
#include <linux/refcount.h>
1212
#include <linux/mod_devicetable.h>
1313
#include <sound/info.h>
1414
#include <sound/control.h>
@@ -166,8 +166,8 @@ struct hda_pcm {
166166
bool own_chmap; /* codec driver provides own channel maps */
167167
/* private: */
168168
struct hda_codec *codec;
169-
struct kref kref;
170169
struct list_head list;
170+
unsigned int disconnected:1;
171171
};
172172

173173
/* codec information */
@@ -187,6 +187,8 @@ struct hda_codec {
187187

188188
/* PCM to create, set by patch_ops.build_pcms callback */
189189
struct list_head pcm_list_head;
190+
refcount_t pcm_ref;
191+
wait_queue_head_t remove_sleep;
190192

191193
/* codec specific info */
192194
void *spec;
@@ -420,7 +422,7 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec);
420422

421423
static inline void snd_hda_codec_pcm_get(struct hda_pcm *pcm)
422424
{
423-
kref_get(&pcm->kref);
425+
refcount_inc(&pcm->codec->pcm_ref);
424426
}
425427
void snd_hda_codec_pcm_put(struct hda_pcm *pcm);
426428

include/sound/intel-nhlt.h

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
#include <linux/acpi.h>
1212

13+
enum nhlt_link_type {
14+
NHLT_LINK_HDA = 0,
15+
NHLT_LINK_DSP = 1,
16+
NHLT_LINK_DMIC = 2,
17+
NHLT_LINK_SSP = 3,
18+
NHLT_LINK_INVALID
19+
};
20+
1321
#if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT)
1422

1523
struct wav_fmt {
@@ -33,14 +41,6 @@ struct wav_fmt_ext {
3341
u8 sub_fmt[16];
3442
} __packed;
3543

36-
enum nhlt_link_type {
37-
NHLT_LINK_HDA = 0,
38-
NHLT_LINK_DSP = 1,
39-
NHLT_LINK_DMIC = 2,
40-
NHLT_LINK_SSP = 3,
41-
NHLT_LINK_INVALID
42-
};
43-
4444
enum nhlt_device_type {
4545
NHLT_DEVICE_BT = 0,
4646
NHLT_DEVICE_DMIC = 1,
@@ -132,6 +132,12 @@ void intel_nhlt_free(struct nhlt_acpi_table *addr);
132132

133133
int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt);
134134

135+
bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type);
136+
struct nhlt_specific_cfg *
137+
intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
138+
u32 bus_id, u8 link_type, u8 vbps, u8 bps,
139+
u8 num_ch, u32 rate, u8 dir, u8 dev_type);
140+
135141
#else
136142

137143
struct nhlt_acpi_table;
@@ -150,6 +156,21 @@ static inline int intel_nhlt_get_dmic_geo(struct device *dev,
150156
{
151157
return 0;
152158
}
159+
160+
static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt,
161+
u8 link_type)
162+
{
163+
return false;
164+
}
165+
166+
static inline struct nhlt_specific_cfg *
167+
intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
168+
u32 bus_id, u8 link_type, u8 vbps, u8 bps,
169+
u8 num_ch, u32 rate, u8 dir, u8 dev_type)
170+
{
171+
return NULL;
172+
}
173+
153174
#endif
154175

155176
#endif

include/sound/memalloc.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ struct snd_dma_device {
3636
#define SNDRV_DMA_TYPE_CONTINUOUS 1 /* continuous no-DMA memory */
3737
#define SNDRV_DMA_TYPE_DEV 2 /* generic device continuous */
3838
#define SNDRV_DMA_TYPE_DEV_WC 5 /* continuous write-combined */
39-
#ifdef CONFIG_SND_DMA_SGBUF
40-
#define SNDRV_DMA_TYPE_DEV_SG 3 /* generic device SG-buffer */
41-
#define SNDRV_DMA_TYPE_DEV_WC_SG 6 /* SG write-combined */
42-
#else
43-
#define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV /* no SG-buf support */
44-
#define SNDRV_DMA_TYPE_DEV_WC_SG SNDRV_DMA_TYPE_DEV_WC
45-
#endif
4639
#ifdef CONFIG_GENERIC_ALLOCATOR
4740
#define SNDRV_DMA_TYPE_DEV_IRAM 4 /* generic device iram-buffer */
4841
#else
@@ -51,6 +44,13 @@ struct snd_dma_device {
5144
#define SNDRV_DMA_TYPE_VMALLOC 7 /* vmalloc'ed buffer */
5245
#define SNDRV_DMA_TYPE_NONCONTIG 8 /* non-coherent SG buffer */
5346
#define SNDRV_DMA_TYPE_NONCOHERENT 9 /* non-coherent buffer */
47+
#ifdef CONFIG_SND_DMA_SGBUF
48+
#define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_NONCONTIG
49+
#define SNDRV_DMA_TYPE_DEV_WC_SG 6 /* SG write-combined */
50+
#else
51+
#define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV /* no SG-buf support */
52+
#define SNDRV_DMA_TYPE_DEV_WC_SG SNDRV_DMA_TYPE_DEV_WC
53+
#endif
5454

5555
/*
5656
* info for buffer allocation

sound/core/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ snd-$(CONFIG_SND_JACK) += ctljack.o jack.o
1919
snd-pcm-y := pcm.o pcm_native.o pcm_lib.o pcm_misc.o \
2020
pcm_memory.o memalloc.o
2121
snd-pcm-$(CONFIG_SND_PCM_TIMER) += pcm_timer.o
22-
snd-pcm-$(CONFIG_SND_DMA_SGBUF) += sgbuf.o
2322
snd-pcm-$(CONFIG_SND_PCM_ELD) += pcm_drm_eld.o
2423
snd-pcm-$(CONFIG_SND_PCM_IEC958) += pcm_iec958.o
2524

sound/core/control_led.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ static char *parse_string(char *s, char *val, size_t val_size)
509509
return s;
510510
}
511511

512-
static char *parse_iface(char *s, unsigned int *val)
512+
static char *parse_iface(char *s, snd_ctl_elem_iface_t *val)
513513
{
514514
if (!strncasecmp(s, "card", 4))
515515
*val = SNDRV_CTL_ELEM_IFACE_CARD;

sound/core/info_oss.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ int snd_oss_info_register(int dev, int num, char *string)
3232
mutex_lock(&strings);
3333
if (string == NULL) {
3434
x = snd_sndstat_strings[num][dev];
35-
if (x) {
36-
kfree(x);
37-
x = NULL;
38-
}
35+
kfree(x);
36+
x = NULL;
3937
} else {
4038
x = kstrdup(string, GFP_KERNEL);
4139
if (x == NULL) {

sound/core/jack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ static int snd_jack_dev_free(struct snd_device *device)
6262
struct snd_card *card = device->card;
6363
struct snd_jack_kctl *jack_kctl, *tmp_jack_kctl;
6464

65+
down_write(&card->controls_rwsem);
6566
list_for_each_entry_safe(jack_kctl, tmp_jack_kctl, &jack->kctl_list, list) {
6667
list_del_init(&jack_kctl->list);
6768
snd_ctl_remove(card, jack_kctl->kctl);
6869
}
70+
up_write(&card->controls_rwsem);
71+
6972
if (jack->private_free)
7073
jack->private_free(jack);
7174

sound/core/memalloc.c

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,52 @@ static const struct snd_malloc_ops snd_dma_noncontig_ops = {
620620
.get_chunk_size = snd_dma_noncontig_get_chunk_size,
621621
};
622622

623+
/* x86-specific SG-buffer with WC pages */
624+
#ifdef CONFIG_SND_DMA_SGBUF
625+
#define sg_wc_address(it) ((unsigned long)page_address(sg_page_iter_page(it)))
626+
627+
static void *snd_dma_sg_wc_alloc(struct snd_dma_buffer *dmab, size_t size)
628+
{
629+
void *p = snd_dma_noncontig_alloc(dmab, size);
630+
struct sg_table *sgt = dmab->private_data;
631+
struct sg_page_iter iter;
632+
633+
if (!p)
634+
return NULL;
635+
for_each_sgtable_page(sgt, &iter, 0)
636+
set_memory_wc(sg_wc_address(&iter), 1);
637+
return p;
638+
}
639+
640+
static void snd_dma_sg_wc_free(struct snd_dma_buffer *dmab)
641+
{
642+
struct sg_table *sgt = dmab->private_data;
643+
struct sg_page_iter iter;
644+
645+
for_each_sgtable_page(sgt, &iter, 0)
646+
set_memory_wb(sg_wc_address(&iter), 1);
647+
snd_dma_noncontig_free(dmab);
648+
}
649+
650+
static int snd_dma_sg_wc_mmap(struct snd_dma_buffer *dmab,
651+
struct vm_area_struct *area)
652+
{
653+
area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
654+
return dma_mmap_noncontiguous(dmab->dev.dev, area,
655+
dmab->bytes, dmab->private_data);
656+
}
657+
658+
static const struct snd_malloc_ops snd_dma_sg_wc_ops = {
659+
.alloc = snd_dma_sg_wc_alloc,
660+
.free = snd_dma_sg_wc_free,
661+
.mmap = snd_dma_sg_wc_mmap,
662+
.sync = snd_dma_noncontig_sync,
663+
.get_addr = snd_dma_noncontig_get_addr,
664+
.get_page = snd_dma_noncontig_get_page,
665+
.get_chunk_size = snd_dma_noncontig_get_chunk_size,
666+
};
667+
#endif /* CONFIG_SND_DMA_SGBUF */
668+
623669
/*
624670
* Non-coherent pages allocator
625671
*/
@@ -679,14 +725,13 @@ static const struct snd_malloc_ops *dma_ops[] = {
679725
[SNDRV_DMA_TYPE_DEV_WC] = &snd_dma_wc_ops,
680726
[SNDRV_DMA_TYPE_NONCONTIG] = &snd_dma_noncontig_ops,
681727
[SNDRV_DMA_TYPE_NONCOHERENT] = &snd_dma_noncoherent_ops,
728+
#ifdef CONFIG_SND_DMA_SGBUF
729+
[SNDRV_DMA_TYPE_DEV_WC_SG] = &snd_dma_sg_wc_ops,
730+
#endif
682731
#ifdef CONFIG_GENERIC_ALLOCATOR
683732
[SNDRV_DMA_TYPE_DEV_IRAM] = &snd_dma_iram_ops,
684733
#endif /* CONFIG_GENERIC_ALLOCATOR */
685734
#endif /* CONFIG_HAS_DMA */
686-
#ifdef CONFIG_SND_DMA_SGBUF
687-
[SNDRV_DMA_TYPE_DEV_SG] = &snd_dma_sg_ops,
688-
[SNDRV_DMA_TYPE_DEV_WC_SG] = &snd_dma_sg_ops,
689-
#endif
690735
};
691736

692737
static const struct snd_malloc_ops *snd_dma_get_ops(struct snd_dma_buffer *dmab)

sound/core/oss/pcm_oss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,7 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr
20522052
int err, cmd;
20532053

20542054
#ifdef OSS_DEBUG
2055-
pcm_dbg(substream->pcm, "pcm_oss: trigger = 0x%x\n", trigger);
2055+
pr_debug("pcm_oss: trigger = 0x%x\n", trigger);
20562056
#endif
20572057

20582058
psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];

sound/core/pcm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,11 @@ EXPORT_SYMBOL(snd_pcm_new_internal);
810810
static void free_chmap(struct snd_pcm_str *pstr)
811811
{
812812
if (pstr->chmap_kctl) {
813-
snd_ctl_remove(pstr->pcm->card, pstr->chmap_kctl);
813+
struct snd_card *card = pstr->pcm->card;
814+
815+
down_write(&card->controls_rwsem);
816+
snd_ctl_remove(card, pstr->chmap_kctl);
817+
up_write(&card->controls_rwsem);
814818
pstr->chmap_kctl = NULL;
815819
}
816820
}

0 commit comments

Comments
 (0)