Skip to content

Commit 47e9134

Browse files
committed
Merge branch 'devel' of git.alsa-project.org:alsa-kernel into topic/misc
2 parents 6b98515 + ed69c6a commit 47e9134

13 files changed

Lines changed: 591 additions & 183 deletions

‎sound/core/pcm_lib.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
394394
+ HZ/100);
395395
/* move new_hw_ptr according jiffies not pos variable */
396396
new_hw_ptr = old_hw_ptr;
397+
hw_base = delta;
397398
/* use loop to avoid checks for delta overflows */
398399
/* the delta value is small or zero in most cases */
399400
while (delta > 0) {
@@ -403,18 +404,19 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
403404
delta--;
404405
}
405406
/* align hw_base to buffer_size */
406-
hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size);
407-
delta = 0;
408407
hw_ptr_error(substream,
409408
"hw_ptr skipping! %s"
410409
"(pos=%ld, delta=%ld, period=%ld, "
411410
"jdelta=%lu/%lu/%lu, hw_ptr=%ld/%ld)\n",
412411
in_interrupt ? "[Q] " : "",
413412
(long)pos, (long)hdelta,
414413
(long)runtime->period_size, jdelta,
415-
((hdelta * HZ) / runtime->rate), delta,
414+
((hdelta * HZ) / runtime->rate), hw_base,
416415
(unsigned long)old_hw_ptr,
417416
(unsigned long)new_hw_ptr);
417+
/* reset values to proper state */
418+
delta = 0;
419+
hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size);
418420
}
419421
no_jiffies_check:
420422
if (delta > runtime->period_size + runtime->period_size / 2) {

‎sound/pci/hda/hda_codec.c‎

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,9 @@ int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
824824
struct hda_pincfg *pin;
825825
unsigned int oldcfg;
826826

827+
if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
828+
return -EINVAL;
829+
827830
oldcfg = snd_hda_codec_get_pincfg(codec, nid);
828831
pin = look_up_pincfg(codec, list, nid);
829832
if (!pin) {
@@ -899,6 +902,25 @@ static void restore_pincfgs(struct hda_codec *codec)
899902
}
900903
}
901904

905+
/**
906+
* snd_hda_shutup_pins - Shut up all pins
907+
* @codec: the HDA codec
908+
*
909+
* Clear all pin controls to shup up before suspend for avoiding click noise.
910+
* The controls aren't cached so that they can be resumed properly.
911+
*/
912+
void snd_hda_shutup_pins(struct hda_codec *codec)
913+
{
914+
int i;
915+
for (i = 0; i < codec->init_pins.used; i++) {
916+
struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
917+
/* use read here for syncing after issuing each verb */
918+
snd_hda_codec_read(codec, pin->nid, 0,
919+
AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
920+
}
921+
}
922+
EXPORT_SYMBOL_HDA(snd_hda_shutup_pins);
923+
902924
static void init_hda_cache(struct hda_cache_rec *cache,
903925
unsigned int record_size);
904926
static void free_hda_cache(struct hda_cache_rec *cache);
@@ -3537,32 +3559,6 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
35373559
}
35383560
EXPORT_SYMBOL_HDA(snd_hda_add_new_ctls);
35393561

3540-
/**
3541-
* snd_hda_add_nids - assign nids to controls from the array
3542-
* @codec: the HDA codec
3543-
* @kctl: struct snd_kcontrol
3544-
* @index: index to kctl
3545-
* @nids: the array of hda_nid_t
3546-
* @size: count of hda_nid_t items
3547-
*
3548-
* This helper function assigns NIDs in the given array to a control element.
3549-
*
3550-
* Returns 0 if successful, or a negative error code.
3551-
*/
3552-
int snd_hda_add_nids(struct hda_codec *codec, struct snd_kcontrol *kctl,
3553-
unsigned int index, hda_nid_t *nids, unsigned int size)
3554-
{
3555-
int err;
3556-
3557-
for ( ; size > 0; size--, nids++) {
3558-
err = snd_hda_add_nid(codec, kctl, index, *nids);
3559-
if (err < 0)
3560-
return err;
3561-
}
3562-
return 0;
3563-
}
3564-
EXPORT_SYMBOL_HDA(snd_hda_add_nids);
3565-
35663562
#ifdef CONFIG_SND_HDA_POWER_SAVE
35673563
static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
35683564
unsigned int power_state);

‎sound/pci/hda/hda_codec.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid,
898898
unsigned int cfg);
899899
int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
900900
hda_nid_t nid, unsigned int cfg); /* for hwdep */
901+
void snd_hda_shutup_pins(struct hda_codec *codec);
901902

902903
/*
903904
* Mixer

‎sound/pci/hda/hda_hwdep.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,11 @@ static ssize_t type##_store(struct device *dev, \
293293
{ \
294294
struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
295295
struct hda_codec *codec = hwdep->private_data; \
296-
char *after; \
297-
codec->type = simple_strtoul(buf, &after, 0); \
296+
unsigned long val; \
297+
int err = strict_strtoul(buf, 0, &val); \
298+
if (err < 0) \
299+
return err; \
300+
codec->type = val; \
298301
return count; \
299302
}
300303

‎sound/pci/hda/hda_intel.c‎

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ struct azx_dev {
356356
*/
357357
unsigned char stream_tag; /* assigned stream */
358358
unsigned char index; /* stream index */
359+
int device; /* last device number assigned to */
359360

360361
unsigned int opened :1;
361362
unsigned int running :1;
@@ -1441,10 +1442,13 @@ static int __devinit azx_codec_configure(struct azx *chip)
14411442
*/
14421443

14431444
/* assign a stream for the PCM */
1444-
static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream)
1445+
static inline struct azx_dev *
1446+
azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
14451447
{
14461448
int dev, i, nums;
1447-
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
1449+
struct azx_dev *res = NULL;
1450+
1451+
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
14481452
dev = chip->playback_index_offset;
14491453
nums = chip->playback_streams;
14501454
} else {
@@ -1453,10 +1457,15 @@ static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream)
14531457
}
14541458
for (i = 0; i < nums; i++, dev++)
14551459
if (!chip->azx_dev[dev].opened) {
1456-
chip->azx_dev[dev].opened = 1;
1457-
return &chip->azx_dev[dev];
1460+
res = &chip->azx_dev[dev];
1461+
if (res->device == substream->pcm->device)
1462+
break;
14581463
}
1459-
return NULL;
1464+
if (res) {
1465+
res->opened = 1;
1466+
res->device = substream->pcm->device;
1467+
}
1468+
return res;
14601469
}
14611470

14621471
/* release the assigned stream */
@@ -1505,7 +1514,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
15051514
int err;
15061515

15071516
mutex_lock(&chip->open_mutex);
1508-
azx_dev = azx_assign_device(chip, substream->stream);
1517+
azx_dev = azx_assign_device(chip, substream);
15091518
if (azx_dev == NULL) {
15101519
mutex_unlock(&chip->open_mutex);
15111520
return -EBUSY;
@@ -2695,32 +2704,10 @@ static struct pci_device_id azx_ids[] = {
26952704
/* ULI M5461 */
26962705
{ PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI },
26972706
/* NVIDIA MCP */
2698-
{ PCI_DEVICE(0x10de, 0x026c), .driver_data = AZX_DRIVER_NVIDIA },
2699-
{ PCI_DEVICE(0x10de, 0x0371), .driver_data = AZX_DRIVER_NVIDIA },
2700-
{ PCI_DEVICE(0x10de, 0x03e4), .driver_data = AZX_DRIVER_NVIDIA },
2701-
{ PCI_DEVICE(0x10de, 0x03f0), .driver_data = AZX_DRIVER_NVIDIA },
2702-
{ PCI_DEVICE(0x10de, 0x044a), .driver_data = AZX_DRIVER_NVIDIA },
2703-
{ PCI_DEVICE(0x10de, 0x044b), .driver_data = AZX_DRIVER_NVIDIA },
2704-
{ PCI_DEVICE(0x10de, 0x055c), .driver_data = AZX_DRIVER_NVIDIA },
2705-
{ PCI_DEVICE(0x10de, 0x055d), .driver_data = AZX_DRIVER_NVIDIA },
2706-
{ PCI_DEVICE(0x10de, 0x0590), .driver_data = AZX_DRIVER_NVIDIA },
2707-
{ PCI_DEVICE(0x10de, 0x0774), .driver_data = AZX_DRIVER_NVIDIA },
2708-
{ PCI_DEVICE(0x10de, 0x0775), .driver_data = AZX_DRIVER_NVIDIA },
2709-
{ PCI_DEVICE(0x10de, 0x0776), .driver_data = AZX_DRIVER_NVIDIA },
2710-
{ PCI_DEVICE(0x10de, 0x0777), .driver_data = AZX_DRIVER_NVIDIA },
2711-
{ PCI_DEVICE(0x10de, 0x07fc), .driver_data = AZX_DRIVER_NVIDIA },
2712-
{ PCI_DEVICE(0x10de, 0x07fd), .driver_data = AZX_DRIVER_NVIDIA },
2713-
{ PCI_DEVICE(0x10de, 0x0ac0), .driver_data = AZX_DRIVER_NVIDIA },
2714-
{ PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
2715-
{ PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
2716-
{ PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
2717-
{ PCI_DEVICE(0x10de, 0x0be2), .driver_data = AZX_DRIVER_NVIDIA },
2718-
{ PCI_DEVICE(0x10de, 0x0be3), .driver_data = AZX_DRIVER_NVIDIA },
2719-
{ PCI_DEVICE(0x10de, 0x0be4), .driver_data = AZX_DRIVER_NVIDIA },
2720-
{ PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA },
2721-
{ PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA },
2722-
{ PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA },
2723-
{ PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA },
2707+
{ PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
2708+
.class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
2709+
.class_mask = 0xffffff,
2710+
.driver_data = AZX_DRIVER_NVIDIA },
27242711
/* Teradici */
27252712
{ PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
27262713
/* Creative X-Fi (CA0110-IBG) */

‎sound/pci/hda/hda_local.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,6 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
343343
const struct snd_pci_quirk *tbl);
344344
int snd_hda_add_new_ctls(struct hda_codec *codec,
345345
struct snd_kcontrol_new *knew);
346-
int snd_hda_add_nids(struct hda_codec *codec, struct snd_kcontrol *kctl,
347-
unsigned int index, hda_nid_t *nids, unsigned int size);
348346

349347
/*
350348
* unsolicited event handler

‎sound/pci/hda/patch_analog.c‎

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ static int ad198x_build_controls(struct hda_codec *codec)
244244
if (!kctl)
245245
kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
246246
for (i = 0; kctl && i < kctl->count; i++) {
247-
err = snd_hda_add_nids(codec, kctl, i, spec->capsrc_nids,
248-
spec->input_mux->num_items);
247+
err = snd_hda_add_nid(codec, kctl, i, spec->capsrc_nids[i]);
249248
if (err < 0)
250249
return err;
251250
}
@@ -442,6 +441,11 @@ static int ad198x_build_pcms(struct hda_codec *codec)
442441
return 0;
443442
}
444443

444+
static inline void ad198x_shutup(struct hda_codec *codec)
445+
{
446+
snd_hda_shutup_pins(codec);
447+
}
448+
445449
static void ad198x_free_kctls(struct hda_codec *codec)
446450
{
447451
struct ad198x_spec *spec = codec->spec;
@@ -455,18 +459,76 @@ static void ad198x_free_kctls(struct hda_codec *codec)
455459
snd_array_free(&spec->kctls);
456460
}
457461

462+
static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
463+
hda_nid_t hp)
464+
{
465+
struct ad198x_spec *spec = codec->spec;
466+
snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE,
467+
!spec->inv_eapd ? 0x00 : 0x02);
468+
snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE,
469+
!spec->inv_eapd ? 0x00 : 0x02);
470+
}
471+
472+
static void ad198x_power_eapd(struct hda_codec *codec)
473+
{
474+
/* We currently only handle front, HP */
475+
switch (codec->vendor_id) {
476+
case 0x11d41882:
477+
case 0x11d4882a:
478+
case 0x11d41884:
479+
case 0x11d41984:
480+
case 0x11d41883:
481+
case 0x11d4184a:
482+
case 0x11d4194a:
483+
case 0x11d4194b:
484+
ad198x_power_eapd_write(codec, 0x12, 0x11);
485+
break;
486+
case 0x11d41981:
487+
case 0x11d41983:
488+
ad198x_power_eapd_write(codec, 0x05, 0x06);
489+
break;
490+
case 0x11d41986:
491+
ad198x_power_eapd_write(codec, 0x1b, 0x1a);
492+
break;
493+
case 0x11d41988:
494+
case 0x11d4198b:
495+
case 0x11d4989a:
496+
case 0x11d4989b:
497+
ad198x_power_eapd_write(codec, 0x29, 0x22);
498+
break;
499+
}
500+
}
501+
458502
static void ad198x_free(struct hda_codec *codec)
459503
{
460504
struct ad198x_spec *spec = codec->spec;
461505

462506
if (!spec)
463507
return;
464508

509+
ad198x_shutup(codec);
465510
ad198x_free_kctls(codec);
466511
kfree(spec);
467512
snd_hda_detach_beep_device(codec);
468513
}
469514

515+
#ifdef SND_HDA_NEEDS_RESUME
516+
static int ad198x_suspend(struct hda_codec *codec, pm_message_t state)
517+
{
518+
ad198x_shutup(codec);
519+
ad198x_power_eapd(codec);
520+
return 0;
521+
}
522+
523+
static int ad198x_resume(struct hda_codec *codec)
524+
{
525+
ad198x_init(codec);
526+
snd_hda_codec_resume_amp(codec);
527+
snd_hda_codec_resume_cache(codec);
528+
return 0;
529+
}
530+
#endif
531+
470532
static struct hda_codec_ops ad198x_patch_ops = {
471533
.build_controls = ad198x_build_controls,
472534
.build_pcms = ad198x_build_pcms,
@@ -475,6 +537,11 @@ static struct hda_codec_ops ad198x_patch_ops = {
475537
#ifdef CONFIG_SND_HDA_POWER_SAVE
476538
.check_power_status = ad198x_check_power_status,
477539
#endif
540+
#ifdef SND_HDA_NEEDS_RESUME
541+
.suspend = ad198x_suspend,
542+
.resume = ad198x_resume,
543+
#endif
544+
.reboot_notify = ad198x_shutup,
478545
};
479546

480547

‎sound/pci/hda/patch_cirrus.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ static int build_input(struct hda_codec *codec)
753753
spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol);
754754
for (i = 0; i < 2; i++) {
755755
struct snd_kcontrol *kctl;
756+
int n;
756757
if (!spec->capture_bind[i])
757758
return -ENOMEM;
758759
kctl = snd_ctl_new1(&cs_capture_ctls[i], codec);
@@ -762,10 +763,13 @@ static int build_input(struct hda_codec *codec)
762763
err = snd_hda_ctl_add(codec, 0, kctl);
763764
if (err < 0)
764765
return err;
765-
err = snd_hda_add_nids(codec, kctl, 0, spec->adc_nid,
766-
spec->num_inputs);
767-
if (err < 0)
768-
return err;
766+
for (n = 0; n < AUTO_PIN_LAST; n++) {
767+
if (!spec->adc_nid[n])
768+
continue;
769+
err = snd_hda_add_nid(codec, kctl, 0, spec->adc_nid[i]);
770+
if (err < 0)
771+
return err;
772+
}
769773
}
770774

771775
if (spec->num_inputs > 1 && !spec->mic_detect) {

‎sound/pci/hda/patch_cmedia.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ static int cmi9880_build_controls(struct hda_codec *codec)
345345
/* assign Capture Source enums to NID */
346346
kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
347347
for (i = 0; kctl && i < kctl->count; i++) {
348-
err = snd_hda_add_nids(codec, kctl, i, spec->adc_nids,
349-
spec->input_mux->num_items);
348+
err = snd_hda_add_nid(codec, kctl, i, spec->adc_nids[i]);
350349
if (err < 0)
351350
return err;
352351
}

0 commit comments

Comments
 (0)