Lines Matching +full:frc +full:- +full:shared
1 // SPDX-License-Identifier: GPL-2.0-only
3 * intel_hdmi_audio.c - Intel HDMI audio driver
23 #include <linux/dma-mapping.h>
39 for ((pipe) = 0; (pipe) < (card_ctx)->num_pipes; (pipe)++)
41 for ((port) = 0; (port) < (card_ctx)->num_ports; (port)++)
56 "Single-port mode (for compatibility)");
67 [5] = FLC | FRC,
110 { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } },
111 { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } },
112 { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } },
113 { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } },
114 { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } },
115 { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } },
116 { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } },
117 { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } },
118 { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } },
119 { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } },
120 { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } },
121 { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } },
174 spin_lock_irqsave(&intelhaddata->had_spinlock, flags); in had_substream_get()
175 substream = intelhaddata->stream_info.substream; in had_substream_get()
177 intelhaddata->stream_info.substream_refcount++; in had_substream_get()
178 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); in had_substream_get()
189 spin_lock_irqsave(&intelhaddata->had_spinlock, flags); in had_substream_put()
190 intelhaddata->stream_info.substream_refcount--; in had_substream_put()
191 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); in had_substream_put()
211 return ioread32(card_ctx->mmio_start + had_config_offset(pipe) + reg); in had_read_register_raw()
217 iowrite32(val, card_ctx->mmio_start + had_config_offset(pipe) + reg); in had_write_register_raw()
222 if (!ctx->connected) in had_read_register()
225 *val = had_read_register_raw(ctx->card_ctx, ctx->pipe, reg); in had_read_register()
230 if (ctx->connected) in had_write_register()
231 had_write_register_raw(ctx->card_ctx, ctx->pipe, reg, val); in had_write_register()
241 * HDMI IP. As a result a read-modify of AUD_CONFIG register will always
244 * more channels. Read-modify of AUD_CONFIG (Eg. for enabling audio)
247 * appropriate value when doing read-modify of AUD_CONFIG register.
253 intelhaddata->aud_config.regx.aud_en = enable; in had_enable_audio()
255 intelhaddata->aud_config.regval); in had_enable_audio()
263 if (!ctx->connected) in had_ack_irqs()
289 ch_stat0.regx.lpcm_id = (intelhaddata->aes_bits & in had_prog_status_reg()
291 ch_stat0.regx.clk_acc = (intelhaddata->aes_bits & in had_prog_status_reg()
294 switch (substream->runtime->rate) { in had_prog_status_reg()
320 return -EINVAL; in had_prog_status_reg()
326 switch (substream->runtime->format) { in had_prog_status_reg()
337 return -EINVAL; in had_prog_status_reg()
364 channels = substream->runtime->channels; in had_init_audio_ctrl()
365 cfg_val.regx.num_ch = channels - 2; in had_init_audio_ctrl()
371 if (substream->runtime->format == SNDRV_PCM_FORMAT_S16_LE) in had_init_audio_ctrl()
374 if (substream->runtime->format == SNDRV_PCM_FORMAT_S32_LE) in had_init_audio_ctrl()
380 if (intelhaddata->dp_output) { in had_init_audio_ctrl()
386 intelhaddata->aud_config = cfg_val; in had_init_audio_ctrl()
400 p->channels = 0; in init_channel_allocations()
401 p->spk_mask = 0; in init_channel_allocations()
402 for (j = 0; j < ARRAY_SIZE(p->speakers); j++) in init_channel_allocations()
403 if (p->speakers[j]) { in init_channel_allocations()
404 p->channels++; in init_channel_allocations()
405 p->spk_mask |= p->speakers[j]; in init_channel_allocations()
413 * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask
414 * spk_mask => (channel_allocations[]) => ai->CA
439 if (intelhaddata->eld[DRM_ELD_SPEAKER] & (1 << i)) in had_channel_allocation()
453 dev_dbg(intelhaddata->dev, "select CA 0x%x for %d\n", ca, channels); in had_channel_allocation()
463 for (; t->map; t++) { in spk_to_chmap()
464 if (t->spk_mask == spk) in spk_to_chmap()
465 return t->map; in spk_to_chmap()
478 kfree(intelhaddata->chmap->chmap); in had_build_channel_allocation_map()
479 intelhaddata->chmap->chmap = NULL; in had_build_channel_allocation_map()
485 dev_dbg(intelhaddata->dev, "eld speaker = %x\n", in had_build_channel_allocation_map()
486 intelhaddata->eld[DRM_ELD_SPEAKER]); in had_build_channel_allocation_map()
497 eld_high = intelhaddata->eld[DRM_ELD_SPEAKER] & eld_high_mask; in had_build_channel_allocation_map()
498 if ((eld_high & (eld_high-1)) && (eld_high > 0x1F)) { in had_build_channel_allocation_map()
499 /* eld_high & (eld_high-1): if more than 1 bit set */ in had_build_channel_allocation_map()
504 intelhaddata->eld[DRM_ELD_SPEAKER] &= in had_build_channel_allocation_map()
512 if (intelhaddata->eld[DRM_ELD_SPEAKER] & (1 << i)) in had_build_channel_allocation_map()
519 chmap->map[c] = spk_to_chmap( in had_build_channel_allocation_map()
521 (MAX_SPEAKERS - 1) - c]); in had_build_channel_allocation_map()
523 chmap->channels = channel_allocations[i].channels; in had_build_channel_allocation_map()
524 intelhaddata->chmap->chmap = chmap; in had_build_channel_allocation_map()
533 * ALSA API channel-map control callbacks
538 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in had_chmap_ctl_info()
539 uinfo->count = HAD_MAX_CHANNEL; in had_chmap_ctl_info()
540 uinfo->value.integer.min = 0; in had_chmap_ctl_info()
541 uinfo->value.integer.max = SNDRV_CHMAP_LAST; in had_chmap_ctl_info()
549 struct snd_intelhad *intelhaddata = info->private_data; in had_chmap_ctl_get()
553 memset(ucontrol->value.integer.value, 0, in had_chmap_ctl_get()
555 mutex_lock(&intelhaddata->mutex); in had_chmap_ctl_get()
556 if (!intelhaddata->chmap->chmap) { in had_chmap_ctl_get()
557 mutex_unlock(&intelhaddata->mutex); in had_chmap_ctl_get()
561 chmap = intelhaddata->chmap->chmap; in had_chmap_ctl_get()
562 for (i = 0; i < chmap->channels; i++) in had_chmap_ctl_get()
563 ucontrol->value.integer.value[i] = chmap->map[i]; in had_chmap_ctl_get()
564 mutex_unlock(&intelhaddata->mutex); in had_chmap_ctl_get()
576 &intelhaddata->chmap); in had_register_chmap_ctls()
580 intelhaddata->chmap->private_data = intelhaddata; in had_register_chmap_ctls()
581 intelhaddata->chmap->kctl->info = had_chmap_ctl_info; in had_register_chmap_ctls()
582 intelhaddata->chmap->kctl->get = had_chmap_ctl_get; in had_register_chmap_ctls()
583 intelhaddata->chmap->chmap = NULL; in had_register_chmap_ctls()
603 channels = substream->runtime->channels; in had_prog_dip()
608 if (intelhaddata->dp_output) { in had_prog_dip()
610 frame2.regval = (substream->runtime->channels - 1) | (ca << 24); in had_prog_dip()
613 frame2.regx.chnl_cnt = substream->runtime->channels - 1; in had_prog_dip()
624 frame2.regx.chksum = -(checksum); in had_prog_dip()
632 for (i = 0; i < HAD_MAX_DIP_WORDS-VALID_DIP_WORDS; i++) in had_prog_dip()
676 maud_val = -EINVAL; in had_calculate_maud_value()
710 maud_val = -EINVAL; in had_calculate_maud_value()
714 maud_val = -EINVAL; in had_calculate_maud_value()
736 if (intelhaddata->dp_output) { in had_prog_cts()
745 dev_dbg(intelhaddata->dev, "TMDS value=%d, N value=%d, CTS Value=%d\n", in had_prog_cts()
785 n_val = -EINVAL; in had_calculate_n_value()
806 if (intelhaddata->dp_output) { in had_prog_n()
835 * PCM | 0 | 1 | 2 | 3 | 4 | 5 | .... |n-1|
839 * PCM | 0 | 1 | 2 | 3 | 4 | 5 | .... |n-1|
843 * PCM | 0 | 1 | 2 | 3 | 4 | 5 | .... |n-1|
853 * pcm_head (=1) --v v-- pcm_filled (=5)
854 * PCM | 0 | 1 | 2 | 3 | 4 | 5 | .... |n-1|
856 * bd_head (=1) --^ ^-- next to fill (= bd_head)
874 int idx = intelhaddata->bd_head; in had_prog_bd()
875 int ofs = intelhaddata->pcmbuf_filled * intelhaddata->period_bytes; in had_prog_bd()
876 u32 addr = substream->runtime->dma_addr + ofs; in had_prog_bd()
879 if (!substream->runtime->no_period_wakeup) in had_prog_bd()
883 intelhaddata->period_bytes); in had_prog_bd()
886 intelhaddata->bd_head++; in had_prog_bd()
887 intelhaddata->bd_head %= intelhaddata->num_bds; in had_prog_bd()
888 intelhaddata->pcmbuf_filled++; in had_prog_bd()
889 intelhaddata->pcmbuf_filled %= substream->runtime->periods; in had_prog_bd()
904 struct snd_pcm_runtime *runtime = substream->runtime; in had_init_ringbuf()
907 num_periods = runtime->periods; in had_init_ringbuf()
908 intelhaddata->num_bds = min(num_periods, HAD_NUM_OF_RING_BUFS); in had_init_ringbuf()
910 intelhaddata->num_bds = max(intelhaddata->num_bds, 2U); in had_init_ringbuf()
911 intelhaddata->period_bytes = in had_init_ringbuf()
912 frames_to_bytes(runtime, runtime->period_size); in had_init_ringbuf()
913 WARN_ON(intelhaddata->period_bytes & 0x3f); in had_init_ringbuf()
915 intelhaddata->bd_head = 0; in had_init_ringbuf()
916 intelhaddata->pcmbuf_head = 0; in had_init_ringbuf()
917 intelhaddata->pcmbuf_filled = 0; in had_init_ringbuf()
920 if (i < intelhaddata->num_bds) in had_init_ringbuf()
926 intelhaddata->bd_head = 0; /* reset at head again before starting */ in had_init_ringbuf()
933 int num_periods = substream->runtime->periods; in had_advance_ringbuf()
939 intelhaddata->pcmbuf_head++; in had_advance_ringbuf()
940 intelhaddata->pcmbuf_head %= num_periods; in had_advance_ringbuf()
944 * returns the current PCM buffer byte position, or -EPIPE for underrun.
953 spin_lock_irqsave(&intelhaddata->had_spinlock, flags); in had_process_ringbuf()
957 AUD_BUF_LEN(intelhaddata->bd_head), in had_process_ringbuf()
959 if (len < 0 || len > intelhaddata->period_bytes) { in had_process_ringbuf()
960 dev_dbg(intelhaddata->dev, "Invalid buf length %d\n", in had_process_ringbuf()
962 len = -EPIPE; in had_process_ringbuf()
970 if (++processed >= intelhaddata->num_bds) { in had_process_ringbuf()
971 len = -EPIPE; /* all empty? - report underrun */ in had_process_ringbuf()
977 len = intelhaddata->period_bytes - len; in had_process_ringbuf()
978 len += intelhaddata->period_bytes * intelhaddata->pcmbuf_head; in had_process_ringbuf()
980 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); in had_process_ringbuf()
991 return; /* no stream? - bail out */ in had_process_buffer_done()
993 if (!intelhaddata->connected) { in had_process_buffer_done()
995 goto out; /* disconnected? - bail out */ in had_process_buffer_done()
1026 dev_err(intelhaddata->dev, "Unable to clear UNDERRUN bits\n"); in wait_clear_underrun_bit()
1037 if (!intelhaddata->connected) in had_pcm_sync_stop()
1069 runtime = substream->runtime; in had_pcm_open()
1071 retval = pm_runtime_resume_and_get(intelhaddata->dev); in had_pcm_open()
1076 runtime->hw = had_pcm_hardware; in had_pcm_open()
1086 retval = snd_pcm_hw_constraint_step(substream->runtime, 0, in had_pcm_open()
1096 spin_lock_irq(&intelhaddata->had_spinlock); in had_pcm_open()
1097 intelhaddata->stream_info.substream = substream; in had_pcm_open()
1098 intelhaddata->stream_info.substream_refcount++; in had_pcm_open()
1099 spin_unlock_irq(&intelhaddata->had_spinlock); in had_pcm_open()
1103 pm_runtime_mark_last_busy(intelhaddata->dev); in had_pcm_open()
1104 pm_runtime_put_autosuspend(intelhaddata->dev); in had_pcm_open()
1118 spin_lock_irq(&intelhaddata->had_spinlock); in had_pcm_close()
1119 intelhaddata->stream_info.substream = NULL; in had_pcm_close()
1120 intelhaddata->stream_info.substream_refcount--; in had_pcm_close()
1121 while (intelhaddata->stream_info.substream_refcount > 0) { in had_pcm_close()
1122 spin_unlock_irq(&intelhaddata->had_spinlock); in had_pcm_close()
1124 spin_lock_irq(&intelhaddata->had_spinlock); in had_pcm_close()
1126 spin_unlock_irq(&intelhaddata->had_spinlock); in had_pcm_close()
1128 pm_runtime_mark_last_busy(intelhaddata->dev); in had_pcm_close()
1129 pm_runtime_put_autosuspend(intelhaddata->dev); in had_pcm_close()
1144 dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n", in had_pcm_hw_params()
1159 spin_lock(&intelhaddata->had_spinlock); in had_pcm_trigger()
1176 retval = -EINVAL; in had_pcm_trigger()
1178 spin_unlock(&intelhaddata->had_spinlock); in had_pcm_trigger()
1194 runtime = substream->runtime; in had_pcm_prepare()
1196 dev_dbg(intelhaddata->dev, "period_size=%d\n", in had_pcm_prepare()
1197 (int)frames_to_bytes(runtime, runtime->period_size)); in had_pcm_prepare()
1198 dev_dbg(intelhaddata->dev, "periods=%d\n", runtime->periods); in had_pcm_prepare()
1199 dev_dbg(intelhaddata->dev, "buffer_size=%d\n", in had_pcm_prepare()
1201 dev_dbg(intelhaddata->dev, "rate=%d\n", runtime->rate); in had_pcm_prepare()
1202 dev_dbg(intelhaddata->dev, "channels=%d\n", runtime->channels); in had_pcm_prepare()
1205 disp_samp_freq = intelhaddata->tmds_clock_speed; in had_pcm_prepare()
1207 retval = had_prog_n(substream->runtime->rate, &n_param, intelhaddata); in had_pcm_prepare()
1209 dev_err(intelhaddata->dev, in had_pcm_prepare()
1214 if (intelhaddata->dp_output) in had_pcm_prepare()
1215 link_rate = intelhaddata->link_rate; in had_pcm_prepare()
1217 had_prog_cts(substream->runtime->rate, disp_samp_freq, link_rate, in had_pcm_prepare()
1248 if (!intelhaddata->connected) in had_pcm_pointer()
1254 len = bytes_to_frames(substream->runtime, len); in had_pcm_pointer()
1256 len %= substream->runtime->buffer_size; in had_pcm_pointer()
1289 disp_samp_freq = intelhaddata->tmds_clock_speed; in had_process_mode_change()
1291 retval = had_prog_n(substream->runtime->rate, &n_param, intelhaddata); in had_process_mode_change()
1293 dev_err(intelhaddata->dev, in had_process_mode_change()
1298 if (intelhaddata->dp_output) in had_process_mode_change()
1299 link_rate = intelhaddata->link_rate; in had_process_mode_change()
1301 had_prog_cts(substream->runtime->rate, disp_samp_freq, link_rate, in had_process_mode_change()
1317 spin_lock_irq(&intelhaddata->had_spinlock); in had_process_hot_plug()
1318 if (intelhaddata->connected) { in had_process_hot_plug()
1319 dev_dbg(intelhaddata->dev, "Device already connected\n"); in had_process_hot_plug()
1320 spin_unlock_irq(&intelhaddata->had_spinlock); in had_process_hot_plug()
1327 intelhaddata->connected = true; in had_process_hot_plug()
1328 dev_dbg(intelhaddata->dev, in had_process_hot_plug()
1331 spin_unlock_irq(&intelhaddata->had_spinlock); in had_process_hot_plug()
1342 snd_jack_report(intelhaddata->jack, SND_JACK_AVOUT); in had_process_hot_plug()
1350 spin_lock_irq(&intelhaddata->had_spinlock); in had_process_hot_unplug()
1351 if (!intelhaddata->connected) { in had_process_hot_unplug()
1352 dev_dbg(intelhaddata->dev, "Device already disconnected\n"); in had_process_hot_unplug()
1353 spin_unlock_irq(&intelhaddata->had_spinlock); in had_process_hot_unplug()
1361 intelhaddata->connected = false; in had_process_hot_unplug()
1362 dev_dbg(intelhaddata->dev, in had_process_hot_unplug()
1365 spin_unlock_irq(&intelhaddata->had_spinlock); in had_process_hot_unplug()
1367 kfree(intelhaddata->chmap->chmap); in had_process_hot_unplug()
1368 intelhaddata->chmap->chmap = NULL; in had_process_hot_unplug()
1377 snd_jack_report(intelhaddata->jack, 0); in had_process_hot_unplug()
1387 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in had_iec958_info()
1388 uinfo->count = 1; in had_iec958_info()
1397 mutex_lock(&intelhaddata->mutex); in had_iec958_get()
1398 ucontrol->value.iec958.status[0] = (intelhaddata->aes_bits >> 0) & 0xff; in had_iec958_get()
1399 ucontrol->value.iec958.status[1] = (intelhaddata->aes_bits >> 8) & 0xff; in had_iec958_get()
1400 ucontrol->value.iec958.status[2] = in had_iec958_get()
1401 (intelhaddata->aes_bits >> 16) & 0xff; in had_iec958_get()
1402 ucontrol->value.iec958.status[3] = in had_iec958_get()
1403 (intelhaddata->aes_bits >> 24) & 0xff; in had_iec958_get()
1404 mutex_unlock(&intelhaddata->mutex); in had_iec958_get()
1411 ucontrol->value.iec958.status[0] = 0xff; in had_iec958_mask_get()
1412 ucontrol->value.iec958.status[1] = 0xff; in had_iec958_mask_get()
1413 ucontrol->value.iec958.status[2] = 0xff; in had_iec958_mask_get()
1414 ucontrol->value.iec958.status[3] = 0xff; in had_iec958_mask_get()
1425 val = (ucontrol->value.iec958.status[0] << 0) | in had_iec958_put()
1426 (ucontrol->value.iec958.status[1] << 8) | in had_iec958_put()
1427 (ucontrol->value.iec958.status[2] << 16) | in had_iec958_put()
1428 (ucontrol->value.iec958.status[3] << 24); in had_iec958_put()
1429 mutex_lock(&intelhaddata->mutex); in had_iec958_put()
1430 if (intelhaddata->aes_bits != val) { in had_iec958_put()
1431 intelhaddata->aes_bits = val; in had_iec958_put()
1434 mutex_unlock(&intelhaddata->mutex); in had_iec958_put()
1441 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in had_ctl_eld_info()
1442 uinfo->count = HDMI_MAX_ELD_BYTES; in had_ctl_eld_info()
1451 mutex_lock(&intelhaddata->mutex); in had_ctl_eld_get()
1452 memcpy(ucontrol->value.bytes.data, intelhaddata->eld, in had_ctl_eld_get()
1454 mutex_unlock(&intelhaddata->mutex); in had_ctl_eld_get()
1463 .info = had_iec958_info, /* shared */
1504 struct snd_intelhad *ctx = &card_ctx->pcm_ctx[port]; in display_pipe_interrupt_handler()
1505 int pipe = ctx->pipe; in display_pipe_interrupt_handler()
1527 ctx = &card_ctx->pcm_ctx[single_port ? 0 : port]; in notify_audio_lpe()
1529 ctx->port = port; in notify_audio_lpe()
1531 schedule_work(&ctx->hdmi_audio_wq); in notify_audio_lpe()
1539 struct intel_hdmi_lpe_audio_pdata *pdata = ctx->dev->platform_data; in had_audio_wq()
1540 struct intel_hdmi_lpe_audio_port_pdata *ppdata = &pdata->port[ctx->port]; in had_audio_wq()
1543 ret = pm_runtime_resume_and_get(ctx->dev); in had_audio_wq()
1547 mutex_lock(&ctx->mutex); in had_audio_wq()
1548 if (ppdata->pipe < 0) { in had_audio_wq()
1549 dev_dbg(ctx->dev, "%s: Event: HAD_NOTIFY_HOT_UNPLUG : port = %d\n", in had_audio_wq()
1550 __func__, ctx->port); in had_audio_wq()
1552 memset(ctx->eld, 0, sizeof(ctx->eld)); /* clear the old ELD */ in had_audio_wq()
1554 ctx->dp_output = false; in had_audio_wq()
1555 ctx->tmds_clock_speed = 0; in had_audio_wq()
1556 ctx->link_rate = 0; in had_audio_wq()
1561 ctx->pipe = -1; in had_audio_wq()
1563 dev_dbg(ctx->dev, "%s: HAD_NOTIFY_ELD : port = %d, tmds = %d\n", in had_audio_wq()
1564 __func__, ctx->port, ppdata->ls_clock); in had_audio_wq()
1566 memcpy(ctx->eld, ppdata->eld, sizeof(ctx->eld)); in had_audio_wq()
1568 ctx->dp_output = ppdata->dp_output; in had_audio_wq()
1569 if (ctx->dp_output) { in had_audio_wq()
1570 ctx->tmds_clock_speed = 0; in had_audio_wq()
1571 ctx->link_rate = ppdata->ls_clock; in had_audio_wq()
1573 ctx->tmds_clock_speed = ppdata->ls_clock; in had_audio_wq()
1574 ctx->link_rate = 0; in had_audio_wq()
1583 ctx->pipe = ppdata->pipe; in had_audio_wq()
1589 mutex_unlock(&ctx->mutex); in had_audio_wq()
1590 pm_runtime_mark_last_busy(ctx->dev); in had_audio_wq()
1591 pm_runtime_put_autosuspend(ctx->dev); in had_audio_wq()
1604 "HDMI/DP,pcm=%d", pcm->device); in had_create_jack()
1606 err = snd_jack_new(ctx->card_ctx->card, hdmi_str, in had_create_jack()
1607 SND_JACK_AVOUT, &ctx->jack, in had_create_jack()
1611 ctx->jack->private_data = ctx; in had_create_jack()
1623 snd_power_change_state(card_ctx->card, SNDRV_CTL_POWER_D3hot); in hdmi_lpe_audio_suspend()
1634 snd_power_change_state(card_ctx->card, SNDRV_CTL_POWER_D0); in hdmi_lpe_audio_resume()
1642 struct snd_intelhad_card *card_ctx = card->private_data; in hdmi_lpe_audio_free()
1643 struct intel_hdmi_lpe_audio_pdata *pdata = card_ctx->dev->platform_data; in hdmi_lpe_audio_free()
1646 spin_lock_irq(&pdata->lpe_audio_slock); in hdmi_lpe_audio_free()
1647 pdata->notify_audio_lpe = NULL; in hdmi_lpe_audio_free()
1648 spin_unlock_irq(&pdata->lpe_audio_slock); in hdmi_lpe_audio_free()
1651 struct snd_intelhad *ctx = &card_ctx->pcm_ctx[port]; in hdmi_lpe_audio_free()
1653 cancel_work_sync(&ctx->hdmi_audio_wq); in hdmi_lpe_audio_free()
1658 * hdmi_lpe_audio_probe - start bridge with i915
1661 * hdmi-lpe-audio platform device.
1674 pdata = pdev->dev.platform_data; in __hdmi_lpe_audio_probe()
1676 dev_err(&pdev->dev, "%s: quit: pdata not allocated by i915!!\n", __func__); in __hdmi_lpe_audio_probe()
1677 return -EINVAL; in __hdmi_lpe_audio_probe()
1687 dev_err(&pdev->dev, "Could not get IO_MEM resources\n"); in __hdmi_lpe_audio_probe()
1688 return -ENXIO; in __hdmi_lpe_audio_probe()
1692 ret = snd_devm_card_new(&pdev->dev, hdmi_card_index, hdmi_card_id, in __hdmi_lpe_audio_probe()
1697 card_ctx = card->private_data; in __hdmi_lpe_audio_probe()
1698 card_ctx->dev = &pdev->dev; in __hdmi_lpe_audio_probe()
1699 card_ctx->card = card; in __hdmi_lpe_audio_probe()
1700 strcpy(card->driver, INTEL_HAD); in __hdmi_lpe_audio_probe()
1701 strcpy(card->shortname, "Intel HDMI/DP LPE Audio"); in __hdmi_lpe_audio_probe()
1702 strcpy(card->longname, "Intel HDMI/DP LPE Audio"); in __hdmi_lpe_audio_probe()
1704 card_ctx->irq = -1; in __hdmi_lpe_audio_probe()
1706 card->private_free = hdmi_lpe_audio_free; in __hdmi_lpe_audio_probe()
1710 card_ctx->num_pipes = pdata->num_pipes; in __hdmi_lpe_audio_probe()
1711 card_ctx->num_ports = single_port ? 1 : pdata->num_ports; in __hdmi_lpe_audio_probe()
1714 ctx = &card_ctx->pcm_ctx[port]; in __hdmi_lpe_audio_probe()
1715 ctx->card_ctx = card_ctx; in __hdmi_lpe_audio_probe()
1716 ctx->dev = card_ctx->dev; in __hdmi_lpe_audio_probe()
1717 ctx->port = single_port ? -1 : port; in __hdmi_lpe_audio_probe()
1718 ctx->pipe = -1; in __hdmi_lpe_audio_probe()
1720 spin_lock_init(&ctx->had_spinlock); in __hdmi_lpe_audio_probe()
1721 mutex_init(&ctx->mutex); in __hdmi_lpe_audio_probe()
1722 INIT_WORK(&ctx->hdmi_audio_wq, had_audio_wq); in __hdmi_lpe_audio_probe()
1725 dev_dbg(&pdev->dev, "%s: mmio_start = 0x%x, mmio_end = 0x%x\n", in __hdmi_lpe_audio_probe()
1726 __func__, (unsigned int)res_mmio->start, in __hdmi_lpe_audio_probe()
1727 (unsigned int)res_mmio->end); in __hdmi_lpe_audio_probe()
1729 card_ctx->mmio_start = in __hdmi_lpe_audio_probe()
1730 devm_ioremap(&pdev->dev, res_mmio->start, in __hdmi_lpe_audio_probe()
1732 if (!card_ctx->mmio_start) { in __hdmi_lpe_audio_probe()
1733 dev_err(&pdev->dev, "Could not get ioremap\n"); in __hdmi_lpe_audio_probe()
1734 return -EACCES; in __hdmi_lpe_audio_probe()
1738 ret = devm_request_irq(&pdev->dev, irq, display_pipe_interrupt_handler, in __hdmi_lpe_audio_probe()
1739 0, pdev->name, card_ctx); in __hdmi_lpe_audio_probe()
1741 dev_err(&pdev->dev, "request_irq failed\n"); in __hdmi_lpe_audio_probe()
1745 card_ctx->irq = irq; in __hdmi_lpe_audio_probe()
1748 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in __hdmi_lpe_audio_probe()
1754 card_ctx->num_pipes = pdata->num_pipes; in __hdmi_lpe_audio_probe()
1755 card_ctx->num_ports = single_port ? 1 : pdata->num_ports; in __hdmi_lpe_audio_probe()
1760 ctx = &card_ctx->pcm_ctx[port]; in __hdmi_lpe_audio_probe()
1767 pcm->private_data = ctx; in __hdmi_lpe_audio_probe()
1768 pcm->info_flags = 0; in __hdmi_lpe_audio_probe()
1769 strscpy(pcm->name, card->shortname, strlen(card->shortname)); in __hdmi_lpe_audio_probe()
1777 card->dev, HAD_DEFAULT_BUFFER, in __hdmi_lpe_audio_probe()
1786 return -ENOMEM; in __hdmi_lpe_audio_probe()
1788 kctl->id.device = pcm->device; in __hdmi_lpe_audio_probe()
1809 spin_lock_irq(&pdata->lpe_audio_slock); in __hdmi_lpe_audio_probe()
1810 pdata->notify_audio_lpe = notify_audio_lpe; in __hdmi_lpe_audio_probe()
1811 spin_unlock_irq(&pdata->lpe_audio_slock); in __hdmi_lpe_audio_probe()
1813 pm_runtime_set_autosuspend_delay(&pdev->dev, INTEL_HDMI_AUDIO_SUSPEND_DELAY_MS); in __hdmi_lpe_audio_probe()
1814 pm_runtime_use_autosuspend(&pdev->dev); in __hdmi_lpe_audio_probe()
1815 pm_runtime_enable(&pdev->dev); in __hdmi_lpe_audio_probe()
1816 pm_runtime_mark_last_busy(&pdev->dev); in __hdmi_lpe_audio_probe()
1817 pm_runtime_idle(&pdev->dev); in __hdmi_lpe_audio_probe()
1819 dev_dbg(&pdev->dev, "%s: handle pending notification\n", __func__); in __hdmi_lpe_audio_probe()
1821 struct snd_intelhad *ctx = &card_ctx->pcm_ctx[port]; in __hdmi_lpe_audio_probe()
1823 schedule_work(&ctx->hdmi_audio_wq); in __hdmi_lpe_audio_probe()
1831 return snd_card_free_on_error(&pdev->dev, __hdmi_lpe_audio_probe(pdev)); in hdmi_lpe_audio_probe()
1840 .name = "hdmi-lpe-audio",