diff options
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 73 |
1 files changed, 48 insertions, 25 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 88a9c20eb7a2..f560051a949e 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -1386,6 +1386,44 @@ int snd_hda_codec_configure(struct hda_codec *codec) | |||
1386 | } | 1386 | } |
1387 | EXPORT_SYMBOL_HDA(snd_hda_codec_configure); | 1387 | EXPORT_SYMBOL_HDA(snd_hda_codec_configure); |
1388 | 1388 | ||
1389 | /* update the stream-id if changed */ | ||
1390 | static void update_pcm_stream_id(struct hda_codec *codec, | ||
1391 | struct hda_cvt_setup *p, hda_nid_t nid, | ||
1392 | u32 stream_tag, int channel_id) | ||
1393 | { | ||
1394 | unsigned int oldval, newval; | ||
1395 | |||
1396 | if (p->stream_tag != stream_tag || p->channel_id != channel_id) { | ||
1397 | oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); | ||
1398 | newval = (stream_tag << 4) | channel_id; | ||
1399 | if (oldval != newval) | ||
1400 | snd_hda_codec_write(codec, nid, 0, | ||
1401 | AC_VERB_SET_CHANNEL_STREAMID, | ||
1402 | newval); | ||
1403 | p->stream_tag = stream_tag; | ||
1404 | p->channel_id = channel_id; | ||
1405 | } | ||
1406 | } | ||
1407 | |||
1408 | /* update the format-id if changed */ | ||
1409 | static void update_pcm_format(struct hda_codec *codec, struct hda_cvt_setup *p, | ||
1410 | hda_nid_t nid, int format) | ||
1411 | { | ||
1412 | unsigned int oldval; | ||
1413 | |||
1414 | if (p->format_id != format) { | ||
1415 | oldval = snd_hda_codec_read(codec, nid, 0, | ||
1416 | AC_VERB_GET_STREAM_FORMAT, 0); | ||
1417 | if (oldval != format) { | ||
1418 | msleep(1); | ||
1419 | snd_hda_codec_write(codec, nid, 0, | ||
1420 | AC_VERB_SET_STREAM_FORMAT, | ||
1421 | format); | ||
1422 | } | ||
1423 | p->format_id = format; | ||
1424 | } | ||
1425 | } | ||
1426 | |||
1389 | /** | 1427 | /** |
1390 | * snd_hda_codec_setup_stream - set up the codec for streaming | 1428 | * snd_hda_codec_setup_stream - set up the codec for streaming |
1391 | * @codec: the CODEC to set up | 1429 | * @codec: the CODEC to set up |
@@ -1400,7 +1438,6 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, | |||
1400 | { | 1438 | { |
1401 | struct hda_codec *c; | 1439 | struct hda_codec *c; |
1402 | struct hda_cvt_setup *p; | 1440 | struct hda_cvt_setup *p; |
1403 | unsigned int oldval, newval; | ||
1404 | int type; | 1441 | int type; |
1405 | int i; | 1442 | int i; |
1406 | 1443 | ||
@@ -1413,29 +1450,13 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, | |||
1413 | p = get_hda_cvt_setup(codec, nid); | 1450 | p = get_hda_cvt_setup(codec, nid); |
1414 | if (!p) | 1451 | if (!p) |
1415 | return; | 1452 | return; |
1416 | /* update the stream-id if changed */ | 1453 | |
1417 | if (p->stream_tag != stream_tag || p->channel_id != channel_id) { | 1454 | if (codec->pcm_format_first) |
1418 | oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); | 1455 | update_pcm_format(codec, p, nid, format); |
1419 | newval = (stream_tag << 4) | channel_id; | 1456 | update_pcm_stream_id(codec, p, nid, stream_tag, channel_id); |
1420 | if (oldval != newval) | 1457 | if (!codec->pcm_format_first) |
1421 | snd_hda_codec_write(codec, nid, 0, | 1458 | update_pcm_format(codec, p, nid, format); |
1422 | AC_VERB_SET_CHANNEL_STREAMID, | 1459 | |
1423 | newval); | ||
1424 | p->stream_tag = stream_tag; | ||
1425 | p->channel_id = channel_id; | ||
1426 | } | ||
1427 | /* update the format-id if changed */ | ||
1428 | if (p->format_id != format) { | ||
1429 | oldval = snd_hda_codec_read(codec, nid, 0, | ||
1430 | AC_VERB_GET_STREAM_FORMAT, 0); | ||
1431 | if (oldval != format) { | ||
1432 | msleep(1); | ||
1433 | snd_hda_codec_write(codec, nid, 0, | ||
1434 | AC_VERB_SET_STREAM_FORMAT, | ||
1435 | format); | ||
1436 | } | ||
1437 | p->format_id = format; | ||
1438 | } | ||
1439 | p->active = 1; | 1460 | p->active = 1; |
1440 | p->dirty = 0; | 1461 | p->dirty = 0; |
1441 | 1462 | ||
@@ -3497,7 +3518,7 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fg | |||
3497 | { | 3518 | { |
3498 | int sup = snd_hda_param_read(codec, fg, AC_PAR_POWER_STATE); | 3519 | int sup = snd_hda_param_read(codec, fg, AC_PAR_POWER_STATE); |
3499 | 3520 | ||
3500 | if (sup < 0) | 3521 | if (sup == -1) |
3501 | return false; | 3522 | return false; |
3502 | if (sup & power_state) | 3523 | if (sup & power_state) |
3503 | return true; | 3524 | return true; |
@@ -4433,6 +4454,8 @@ static void __snd_hda_power_up(struct hda_codec *codec, bool wait_power_down) | |||
4433 | * then there is no need to go through power up here. | 4454 | * then there is no need to go through power up here. |
4434 | */ | 4455 | */ |
4435 | if (codec->power_on) { | 4456 | if (codec->power_on) { |
4457 | if (codec->power_transition < 0) | ||
4458 | codec->power_transition = 0; | ||
4436 | spin_unlock(&codec->power_lock); | 4459 | spin_unlock(&codec->power_lock); |
4437 | return; | 4460 | return; |
4438 | } | 4461 | } |