aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-06-21 02:23:27 -0400
committerTakashi Iwai <tiwai@suse.de>2012-06-21 02:23:27 -0400
commit8ceb332df46863ac8f74114a2b1805719cf49dcc (patch)
tree6a2d8bc1f0e243e2b192282dd980d82e3fc996f6 /sound/pci
parent8b8d654b55648561287bd8baca0f75f964a17038 (diff)
ALSA: hda - Remove loop from simple_hdmi*()
The simple_hdmi stuff is designed only for a single pin and a single converter (thus a single PCM stream), and no need for loops. Let's flatten the code. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/patch_hdmi.c69
1 files changed, 27 insertions, 42 deletions
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 64f1fedfd535..0a87a1f2988e 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1364,26 +1364,22 @@ static int simple_playback_build_pcms(struct hda_codec *codec)
1364{ 1364{
1365 struct hdmi_spec *spec = codec->spec; 1365 struct hdmi_spec *spec = codec->spec;
1366 struct hda_pcm *info = spec->pcm_rec; 1366 struct hda_pcm *info = spec->pcm_rec;
1367 int i; 1367 unsigned int chans;
1368 struct hda_pcm_stream *pstr;
1368 1369
1369 codec->num_pcms = spec->num_cvts; 1370 codec->num_pcms = 1;
1370 codec->pcm_info = info; 1371 codec->pcm_info = info;
1371 1372
1372 for (i = 0; i < codec->num_pcms; i++, info++) { 1373 chans = get_wcaps(codec, spec->cvts[0].cvt_nid);
1373 unsigned int chans; 1374 chans = get_wcaps_channels(chans);
1374 struct hda_pcm_stream *pstr;
1375 1375
1376 chans = get_wcaps(codec, spec->cvts[i].cvt_nid); 1376 info->name = get_hdmi_pcm_name(0);
1377 chans = get_wcaps_channels(chans); 1377 info->pcm_type = HDA_PCM_TYPE_HDMI;
1378 1378 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
1379 info->name = get_hdmi_pcm_name(i); 1379 *pstr = spec->pcm_playback;
1380 info->pcm_type = HDA_PCM_TYPE_HDMI; 1380 pstr->nid = spec->cvts[0].cvt_nid;
1381 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; 1381 if (pstr->channels_max <= 2 && chans && chans <= 16)
1382 *pstr = spec->pcm_playback; 1382 pstr->channels_max = chans;
1383 pstr->nid = spec->cvts[i].cvt_nid;
1384 if (pstr->channels_max <= 2 && chans && chans <= 16)
1385 pstr->channels_max = chans;
1386 }
1387 1383
1388 return 0; 1384 return 0;
1389} 1385}
@@ -1405,38 +1401,27 @@ static int simple_playback_build_controls(struct hda_codec *codec)
1405{ 1401{
1406 struct hdmi_spec *spec = codec->spec; 1402 struct hdmi_spec *spec = codec->spec;
1407 int err; 1403 int err;
1408 int i;
1409
1410 for (i = 0; i < codec->num_pcms; i++) {
1411 err = snd_hda_create_spdif_out_ctls(codec,
1412 spec->cvts[i].cvt_nid,
1413 spec->cvts[i].cvt_nid);
1414 if (err < 0)
1415 return err;
1416 err = simple_hdmi_build_jack(codec, i);
1417 if (err < 0)
1418 return err;
1419 }
1420 1404
1421 return 0; 1405 err = snd_hda_create_spdif_out_ctls(codec,
1406 spec->cvts[0].cvt_nid,
1407 spec->cvts[0].cvt_nid);
1408 if (err < 0)
1409 return err;
1410 return simple_hdmi_build_jack(codec, 0);
1422} 1411}
1423 1412
1424static int simple_playback_init(struct hda_codec *codec) 1413static int simple_playback_init(struct hda_codec *codec)
1425{ 1414{
1426 struct hdmi_spec *spec = codec->spec; 1415 struct hdmi_spec *spec = codec->spec;
1427 int i; 1416 hda_nid_t pin = spec->pins[0].pin_nid;
1428 1417
1429 for (i = 0; i < spec->num_pins; i++) { 1418 snd_hda_codec_write(codec, pin, 0,
1430 hda_nid_t pin = spec->pins[i].pin_nid; 1419 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
1431 snd_hda_codec_write(codec, pin, 0, 1420 /* some codecs require to unmute the pin */
1432 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 1421 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)
1433 /* some codecs require to unmute the pin */ 1422 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1434 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) 1423 AMP_OUT_UNMUTE);
1435 snd_hda_codec_write(codec, pin, 0, 1424 snd_hda_jack_detect_enable(codec, pin, pin);
1436 AC_VERB_SET_AMP_GAIN_MUTE,
1437 AMP_OUT_UNMUTE);
1438 snd_hda_jack_detect_enable(codec, pin, pin);
1439 }
1440 snd_hda_jack_report_sync(codec); 1425 snd_hda_jack_report_sync(codec);
1441 return 0; 1426 return 0;
1442} 1427}