diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-02-02 11:38:50 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-02-03 11:37:50 -0500 |
commit | 73997b050c995f34f3617d344f1e767d15b2477d (patch) | |
tree | d8780d33b41b1c264e3287e248aad9c36eace97b /sound/x86 | |
parent | 44684f61b23c68786834dd2a99d4a68d40a13308 (diff) |
ALSA: x86: Yet more tidy-up and clean-ups
- Add a few more comments to functions.
- Move the initialization of some PCM state variables to open and
prepare callbacks, where these are clearer places.
- Remove superfluous NULL checks.
- Get rid of the bogus drv_status change to CONNECTED at close;
this doesn't make any sense.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/x86')
-rw-r--r-- | sound/x86/intel_hdmi_audio.c | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index 5613c675ce70..f032610d1287 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c | |||
@@ -965,7 +965,6 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream) | |||
965 | 965 | ||
966 | intelhaddata = snd_pcm_substream_chip(substream); | 966 | intelhaddata = snd_pcm_substream_chip(substream); |
967 | runtime = substream->runtime; | 967 | runtime = substream->runtime; |
968 | intelhaddata->underrun_count = 0; | ||
969 | 968 | ||
970 | pm_runtime_get_sync(intelhaddata->dev); | 969 | pm_runtime_get_sync(intelhaddata->dev); |
971 | 970 | ||
@@ -989,17 +988,20 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream) | |||
989 | */ | 988 | */ |
990 | retval = snd_pcm_hw_constraint_step(substream->runtime, 0, | 989 | retval = snd_pcm_hw_constraint_step(substream->runtime, 0, |
991 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64); | 990 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64); |
992 | if (retval < 0) { | 991 | if (retval < 0) |
993 | dev_dbg(intelhaddata->dev, "%s:step_size=64 failed,err=%d\n", | ||
994 | __func__, retval); | ||
995 | goto error; | 992 | goto error; |
996 | } | ||
997 | 993 | ||
994 | /* expose PCM substream */ | ||
998 | spin_lock_irq(&intelhaddata->had_spinlock); | 995 | spin_lock_irq(&intelhaddata->had_spinlock); |
999 | intelhaddata->stream_info.substream = substream; | 996 | intelhaddata->stream_info.substream = substream; |
1000 | intelhaddata->stream_info.substream_refcount++; | 997 | intelhaddata->stream_info.substream_refcount++; |
1001 | spin_unlock_irq(&intelhaddata->had_spinlock); | 998 | spin_unlock_irq(&intelhaddata->had_spinlock); |
1002 | 999 | ||
1000 | /* these are cleared in prepare callback, but just to be sure */ | ||
1001 | intelhaddata->curr_buf = 0; | ||
1002 | intelhaddata->underrun_count = 0; | ||
1003 | intelhaddata->stream_info.buffer_rendered = 0; | ||
1004 | |||
1003 | return retval; | 1005 | return retval; |
1004 | error: | 1006 | error: |
1005 | pm_runtime_put(intelhaddata->dev); | 1007 | pm_runtime_put(intelhaddata->dev); |
@@ -1015,7 +1017,7 @@ static int snd_intelhad_close(struct snd_pcm_substream *substream) | |||
1015 | 1017 | ||
1016 | intelhaddata = snd_pcm_substream_chip(substream); | 1018 | intelhaddata = snd_pcm_substream_chip(substream); |
1017 | 1019 | ||
1018 | intelhaddata->stream_info.buffer_rendered = 0; | 1020 | /* unreference and sync with the pending PCM accesses */ |
1019 | spin_lock_irq(&intelhaddata->had_spinlock); | 1021 | spin_lock_irq(&intelhaddata->had_spinlock); |
1020 | intelhaddata->stream_info.substream = NULL; | 1022 | intelhaddata->stream_info.substream = NULL; |
1021 | intelhaddata->stream_info.substream_refcount--; | 1023 | intelhaddata->stream_info.substream_refcount--; |
@@ -1026,13 +1028,6 @@ static int snd_intelhad_close(struct snd_pcm_substream *substream) | |||
1026 | } | 1028 | } |
1027 | spin_unlock_irq(&intelhaddata->had_spinlock); | 1029 | spin_unlock_irq(&intelhaddata->had_spinlock); |
1028 | 1030 | ||
1029 | /* Check if following drv_status modification is required - VA */ | ||
1030 | if (intelhaddata->drv_status != HAD_DRV_DISCONNECTED) { | ||
1031 | intelhaddata->drv_status = HAD_DRV_CONNECTED; | ||
1032 | dev_dbg(intelhaddata->dev, | ||
1033 | "%s @ %d:DEBUG PLUG/UNPLUG : HAD_DRV_CONNECTED\n", | ||
1034 | __func__, __LINE__); | ||
1035 | } | ||
1036 | pm_runtime_put(intelhaddata->dev); | 1031 | pm_runtime_put(intelhaddata->dev); |
1037 | return 0; | 1032 | return 0; |
1038 | } | 1033 | } |
@@ -1047,9 +1042,6 @@ static int snd_intelhad_hw_params(struct snd_pcm_substream *substream, | |||
1047 | unsigned long addr; | 1042 | unsigned long addr; |
1048 | int pages, buf_size, retval; | 1043 | int pages, buf_size, retval; |
1049 | 1044 | ||
1050 | if (!hw_params) | ||
1051 | return -EINVAL; | ||
1052 | |||
1053 | intelhaddata = snd_pcm_substream_chip(substream); | 1045 | intelhaddata = snd_pcm_substream_chip(substream); |
1054 | buf_size = params_buffer_bytes(hw_params); | 1046 | buf_size = params_buffer_bytes(hw_params); |
1055 | retval = snd_pcm_lib_malloc_pages(substream, buf_size); | 1047 | retval = snd_pcm_lib_malloc_pages(substream, buf_size); |
@@ -1124,7 +1116,6 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream, | |||
1124 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 1116 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
1125 | case SNDRV_PCM_TRIGGER_SUSPEND: | 1117 | case SNDRV_PCM_TRIGGER_SUSPEND: |
1126 | spin_lock(&intelhaddata->had_spinlock); | 1118 | spin_lock(&intelhaddata->had_spinlock); |
1127 | intelhaddata->curr_buf = 0; | ||
1128 | 1119 | ||
1129 | /* Stop reporting BUFFER_DONE/UNDERRUN to above layers */ | 1120 | /* Stop reporting BUFFER_DONE/UNDERRUN to above layers */ |
1130 | 1121 | ||
@@ -1174,6 +1165,8 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream) | |||
1174 | dev_dbg(intelhaddata->dev, "rate=%d\n", runtime->rate); | 1165 | dev_dbg(intelhaddata->dev, "rate=%d\n", runtime->rate); |
1175 | dev_dbg(intelhaddata->dev, "channels=%d\n", runtime->channels); | 1166 | dev_dbg(intelhaddata->dev, "channels=%d\n", runtime->channels); |
1176 | 1167 | ||
1168 | intelhaddata->curr_buf = 0; | ||
1169 | intelhaddata->underrun_count = 0; | ||
1177 | intelhaddata->stream_info.buffer_rendered = 0; | 1170 | intelhaddata->stream_info.buffer_rendered = 0; |
1178 | 1171 | ||
1179 | /* Get N value in KHz */ | 1172 | /* Get N value in KHz */ |
@@ -1247,7 +1240,6 @@ snd_intelhad_pcm_pointer(struct snd_pcm_substream *substream) | |||
1247 | dev_dbg(intelhaddata->dev, | 1240 | dev_dbg(intelhaddata->dev, |
1248 | "assume audio_codec_reset, underrun = %d - do xrun\n", | 1241 | "assume audio_codec_reset, underrun = %d - do xrun\n", |
1249 | intelhaddata->underrun_count); | 1242 | intelhaddata->underrun_count); |
1250 | intelhaddata->underrun_count = 0; | ||
1251 | return SNDRV_PCM_POS_XRUN; | 1243 | return SNDRV_PCM_POS_XRUN; |
1252 | } | 1244 | } |
1253 | } else { | 1245 | } else { |
@@ -1277,6 +1269,21 @@ static int snd_intelhad_pcm_mmap(struct snd_pcm_substream *substream, | |||
1277 | vma->vm_end - vma->vm_start, vma->vm_page_prot); | 1269 | vma->vm_end - vma->vm_start, vma->vm_page_prot); |
1278 | } | 1270 | } |
1279 | 1271 | ||
1272 | /* | ||
1273 | * ALSA PCM ops | ||
1274 | */ | ||
1275 | static const struct snd_pcm_ops snd_intelhad_playback_ops = { | ||
1276 | .open = snd_intelhad_open, | ||
1277 | .close = snd_intelhad_close, | ||
1278 | .ioctl = snd_pcm_lib_ioctl, | ||
1279 | .hw_params = snd_intelhad_hw_params, | ||
1280 | .hw_free = snd_intelhad_hw_free, | ||
1281 | .prepare = snd_intelhad_pcm_prepare, | ||
1282 | .trigger = snd_intelhad_pcm_trigger, | ||
1283 | .pointer = snd_intelhad_pcm_pointer, | ||
1284 | .mmap = snd_intelhad_pcm_mmap, | ||
1285 | }; | ||
1286 | |||
1280 | /* process mode change of the running stream; called in mutex */ | 1287 | /* process mode change of the running stream; called in mutex */ |
1281 | static int hdmi_audio_mode_change(struct snd_intelhad *intelhaddata) | 1288 | static int hdmi_audio_mode_change(struct snd_intelhad *intelhaddata) |
1282 | { | 1289 | { |
@@ -1564,18 +1571,9 @@ static void had_process_hot_unplug(struct snd_intelhad *intelhaddata) | |||
1564 | intelhaddata->chmap->chmap = NULL; | 1571 | intelhaddata->chmap->chmap = NULL; |
1565 | } | 1572 | } |
1566 | 1573 | ||
1567 | /* PCM operations structure and the calls back for the same */ | 1574 | /* |
1568 | static struct snd_pcm_ops snd_intelhad_playback_ops = { | 1575 | * ALSA iec958 and ELD controls |
1569 | .open = snd_intelhad_open, | 1576 | */ |
1570 | .close = snd_intelhad_close, | ||
1571 | .ioctl = snd_pcm_lib_ioctl, | ||
1572 | .hw_params = snd_intelhad_hw_params, | ||
1573 | .hw_free = snd_intelhad_hw_free, | ||
1574 | .prepare = snd_intelhad_pcm_prepare, | ||
1575 | .trigger = snd_intelhad_pcm_trigger, | ||
1576 | .pointer = snd_intelhad_pcm_pointer, | ||
1577 | .mmap = snd_intelhad_pcm_mmap, | ||
1578 | }; | ||
1579 | 1577 | ||
1580 | static int had_iec958_info(struct snd_kcontrol *kcontrol, | 1578 | static int had_iec958_info(struct snd_kcontrol *kcontrol, |
1581 | struct snd_ctl_elem_info *uinfo) | 1579 | struct snd_ctl_elem_info *uinfo) |
@@ -1651,7 +1649,7 @@ static int had_ctl_eld_get(struct snd_kcontrol *kcontrol, | |||
1651 | return 0; | 1649 | return 0; |
1652 | } | 1650 | } |
1653 | 1651 | ||
1654 | static struct snd_kcontrol_new had_controls[] = { | 1652 | static const struct snd_kcontrol_new had_controls[] = { |
1655 | { | 1653 | { |
1656 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 1654 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
1657 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | 1655 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
@@ -1676,7 +1674,9 @@ static struct snd_kcontrol_new had_controls[] = { | |||
1676 | }, | 1674 | }, |
1677 | }; | 1675 | }; |
1678 | 1676 | ||
1679 | 1677 | /* | |
1678 | * audio interrupt handler | ||
1679 | */ | ||
1680 | static irqreturn_t display_pipe_interrupt_handler(int irq, void *dev_id) | 1680 | static irqreturn_t display_pipe_interrupt_handler(int irq, void *dev_id) |
1681 | { | 1681 | { |
1682 | struct snd_intelhad *ctx = dev_id; | 1682 | struct snd_intelhad *ctx = dev_id; |
@@ -1698,6 +1698,9 @@ static irqreturn_t display_pipe_interrupt_handler(int irq, void *dev_id) | |||
1698 | return IRQ_HANDLED; | 1698 | return IRQ_HANDLED; |
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | /* | ||
1702 | * monitor plug/unplug notification from i915; just kick off the work | ||
1703 | */ | ||
1701 | static void notify_audio_lpe(struct platform_device *pdev) | 1704 | static void notify_audio_lpe(struct platform_device *pdev) |
1702 | { | 1705 | { |
1703 | struct snd_intelhad *ctx = platform_get_drvdata(pdev); | 1706 | struct snd_intelhad *ctx = platform_get_drvdata(pdev); |
@@ -1705,6 +1708,7 @@ static void notify_audio_lpe(struct platform_device *pdev) | |||
1705 | schedule_work(&ctx->hdmi_audio_wq); | 1708 | schedule_work(&ctx->hdmi_audio_wq); |
1706 | } | 1709 | } |
1707 | 1710 | ||
1711 | /* the work to handle monitor hot plug/unplug */ | ||
1708 | static void had_audio_wq(struct work_struct *work) | 1712 | static void had_audio_wq(struct work_struct *work) |
1709 | { | 1713 | { |
1710 | struct snd_intelhad *ctx = | 1714 | struct snd_intelhad *ctx = |