Lines Matching refs:intelhaddata

167 had_substream_get(struct snd_intelhad *intelhaddata)  in had_substream_get()  argument
172 spin_lock_irqsave(&intelhaddata->had_spinlock, flags); in had_substream_get()
173 substream = intelhaddata->stream_info.substream; in had_substream_get()
175 intelhaddata->stream_info.substream_refcount++; in had_substream_get()
176 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); in had_substream_get()
183 static void had_substream_put(struct snd_intelhad *intelhaddata) in had_substream_put() argument
187 spin_lock_irqsave(&intelhaddata->had_spinlock, flags); in had_substream_put()
188 intelhaddata->stream_info.substream_refcount--; in had_substream_put()
189 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); in had_substream_put()
247 static void had_enable_audio(struct snd_intelhad *intelhaddata, in had_enable_audio() argument
251 intelhaddata->aud_config.regx.aud_en = enable; in had_enable_audio()
252 had_write_register(intelhaddata, AUD_CONFIG, in had_enable_audio()
253 intelhaddata->aud_config.regval); in had_enable_audio()
270 static void had_reset_audio(struct snd_intelhad *intelhaddata) in had_reset_audio() argument
272 had_write_register(intelhaddata, AUD_HDMI_STATUS, in had_reset_audio()
274 had_write_register(intelhaddata, AUD_HDMI_STATUS, 0); in had_reset_audio()
282 struct snd_intelhad *intelhaddata) in had_prog_status_reg() argument
287 ch_stat0.regx.lpcm_id = (intelhaddata->aes_bits & in had_prog_status_reg()
289 ch_stat0.regx.clk_acc = (intelhaddata->aes_bits & in had_prog_status_reg()
321 had_write_register(intelhaddata, in had_prog_status_reg()
338 had_write_register(intelhaddata, in had_prog_status_reg()
349 struct snd_intelhad *intelhaddata) in had_init_audio_ctrl() argument
355 had_prog_status_reg(substream, intelhaddata); in had_init_audio_ctrl()
360 had_write_register(intelhaddata, AUD_BUF_CONFIG, buf_cfg.regval); in had_init_audio_ctrl()
378 if (intelhaddata->dp_output) { in had_init_audio_ctrl()
383 had_write_register(intelhaddata, AUD_CONFIG, cfg_val.regval); in had_init_audio_ctrl()
384 intelhaddata->aud_config = cfg_val; in had_init_audio_ctrl()
416 static int had_channel_allocation(struct snd_intelhad *intelhaddata, in had_channel_allocation() argument
437 if (intelhaddata->eld[DRM_ELD_SPEAKER] & (1 << i)) in had_channel_allocation()
451 dev_dbg(intelhaddata->dev, "select CA 0x%x for %d\n", ca, channels); in had_channel_allocation()
468 static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata) in had_build_channel_allocation_map() argument
476 kfree(intelhaddata->chmap->chmap); in had_build_channel_allocation_map()
477 intelhaddata->chmap->chmap = NULL; in had_build_channel_allocation_map()
483 dev_dbg(intelhaddata->dev, "eld speaker = %x\n", in had_build_channel_allocation_map()
484 intelhaddata->eld[DRM_ELD_SPEAKER]); in had_build_channel_allocation_map()
495 eld_high = intelhaddata->eld[DRM_ELD_SPEAKER] & eld_high_mask; in had_build_channel_allocation_map()
502 intelhaddata->eld[DRM_ELD_SPEAKER] &= in had_build_channel_allocation_map()
510 if (intelhaddata->eld[DRM_ELD_SPEAKER] & (1 << i)) in had_build_channel_allocation_map()
522 intelhaddata->chmap->chmap = chmap; in had_build_channel_allocation_map()
547 struct snd_intelhad *intelhaddata = info->private_data; in had_chmap_ctl_get() local
553 mutex_lock(&intelhaddata->mutex); in had_chmap_ctl_get()
554 if (!intelhaddata->chmap->chmap) { in had_chmap_ctl_get()
555 mutex_unlock(&intelhaddata->mutex); in had_chmap_ctl_get()
559 chmap = intelhaddata->chmap->chmap; in had_chmap_ctl_get()
562 mutex_unlock(&intelhaddata->mutex); in had_chmap_ctl_get()
567 static int had_register_chmap_ctls(struct snd_intelhad *intelhaddata, in had_register_chmap_ctls() argument
573 NULL, 0, (unsigned long)intelhaddata, in had_register_chmap_ctls()
574 &intelhaddata->chmap); in had_register_chmap_ctls()
578 intelhaddata->chmap->private_data = intelhaddata; in had_register_chmap_ctls()
579 intelhaddata->chmap->kctl->info = had_chmap_ctl_info; in had_register_chmap_ctls()
580 intelhaddata->chmap->kctl->get = had_chmap_ctl_get; in had_register_chmap_ctls()
581 intelhaddata->chmap->chmap = NULL; in had_register_chmap_ctls()
590 struct snd_intelhad *intelhaddata) in had_prog_dip() argument
603 had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.regval); in had_prog_dip()
605 ca = had_channel_allocation(intelhaddata, channels); in had_prog_dip()
606 if (intelhaddata->dp_output) { in had_prog_dip()
625 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, info_frame); in had_prog_dip()
626 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, frame2.regval); in had_prog_dip()
627 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, frame3.regval); in had_prog_dip()
631 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, 0x0); in had_prog_dip()
635 had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.regval); in had_prog_dip()
729 u32 n_param, struct snd_intelhad *intelhaddata) in had_prog_cts() argument
734 if (intelhaddata->dp_output) { in had_prog_cts()
743 dev_dbg(intelhaddata->dev, "TMDS value=%d, N value=%d, CTS Value=%d\n", in had_prog_cts()
745 had_write_register(intelhaddata, AUD_HDMI_CTS, (BIT(24) | cts_val)); in had_prog_cts()
800 struct snd_intelhad *intelhaddata) in had_prog_n() argument
804 if (intelhaddata->dp_output) { in had_prog_n()
820 had_write_register(intelhaddata, AUD_N_ENABLE, (BIT(24) | n_val)); in had_prog_n()
870 struct snd_intelhad *intelhaddata) in had_prog_bd() argument
872 int idx = intelhaddata->bd_head; in had_prog_bd()
873 int ofs = intelhaddata->pcmbuf_filled * intelhaddata->period_bytes; in had_prog_bd()
879 had_write_register(intelhaddata, AUD_BUF_ADDR(idx), addr); in had_prog_bd()
880 had_write_register(intelhaddata, AUD_BUF_LEN(idx), in had_prog_bd()
881 intelhaddata->period_bytes); in had_prog_bd()
884 intelhaddata->bd_head++; in had_prog_bd()
885 intelhaddata->bd_head %= intelhaddata->num_bds; in had_prog_bd()
886 intelhaddata->pcmbuf_filled++; in had_prog_bd()
887 intelhaddata->pcmbuf_filled %= substream->runtime->periods; in had_prog_bd()
891 static void had_invalidate_bd(struct snd_intelhad *intelhaddata, in had_invalidate_bd() argument
894 had_write_register(intelhaddata, AUD_BUF_ADDR(idx), 0); in had_invalidate_bd()
895 had_write_register(intelhaddata, AUD_BUF_LEN(idx), 0); in had_invalidate_bd()
900 struct snd_intelhad *intelhaddata) in had_init_ringbuf() argument
906 intelhaddata->num_bds = min(num_periods, HAD_NUM_OF_RING_BUFS); in had_init_ringbuf()
908 intelhaddata->num_bds = max(intelhaddata->num_bds, 2U); in had_init_ringbuf()
909 intelhaddata->period_bytes = in had_init_ringbuf()
911 WARN_ON(intelhaddata->period_bytes & 0x3f); in had_init_ringbuf()
913 intelhaddata->bd_head = 0; in had_init_ringbuf()
914 intelhaddata->pcmbuf_head = 0; in had_init_ringbuf()
915 intelhaddata->pcmbuf_filled = 0; in had_init_ringbuf()
918 if (i < intelhaddata->num_bds) in had_init_ringbuf()
919 had_prog_bd(substream, intelhaddata); in had_init_ringbuf()
921 had_invalidate_bd(intelhaddata, i); in had_init_ringbuf()
924 intelhaddata->bd_head = 0; /* reset at head again before starting */ in had_init_ringbuf()
929 struct snd_intelhad *intelhaddata) in had_advance_ringbuf() argument
934 had_prog_bd(substream, intelhaddata); in had_advance_ringbuf()
937 intelhaddata->pcmbuf_head++; in had_advance_ringbuf()
938 intelhaddata->pcmbuf_head %= num_periods; in had_advance_ringbuf()
945 struct snd_intelhad *intelhaddata) in had_process_ringbuf() argument
951 spin_lock_irqsave(&intelhaddata->had_spinlock, flags); in had_process_ringbuf()
954 had_read_register(intelhaddata, in had_process_ringbuf()
955 AUD_BUF_LEN(intelhaddata->bd_head), in had_process_ringbuf()
957 if (len < 0 || len > intelhaddata->period_bytes) { in had_process_ringbuf()
958 dev_dbg(intelhaddata->dev, "Invalid buf length %d\n", in had_process_ringbuf()
968 if (++processed >= intelhaddata->num_bds) { in had_process_ringbuf()
972 had_advance_ringbuf(substream, intelhaddata); in had_process_ringbuf()
975 len = intelhaddata->period_bytes - len; in had_process_ringbuf()
976 len += intelhaddata->period_bytes * intelhaddata->pcmbuf_head; in had_process_ringbuf()
978 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); in had_process_ringbuf()
983 static void had_process_buffer_done(struct snd_intelhad *intelhaddata) in had_process_buffer_done() argument
987 substream = had_substream_get(intelhaddata); in had_process_buffer_done()
991 if (!intelhaddata->connected) { in had_process_buffer_done()
997 if (had_process_ringbuf(substream, intelhaddata) < 0) in had_process_buffer_done()
1003 had_substream_put(intelhaddata); in had_process_buffer_done()
1010 static void wait_clear_underrun_bit(struct snd_intelhad *intelhaddata) in wait_clear_underrun_bit() argument
1017 had_read_register(intelhaddata, AUD_HDMI_STATUS, &val); in wait_clear_underrun_bit()
1022 had_write_register(intelhaddata, AUD_HDMI_STATUS, val); in wait_clear_underrun_bit()
1024 dev_err(intelhaddata->dev, "Unable to clear UNDERRUN bits\n"); in wait_clear_underrun_bit()
1031 static void had_do_reset(struct snd_intelhad *intelhaddata) in had_do_reset() argument
1033 if (!intelhaddata->need_reset || !intelhaddata->connected) in had_do_reset()
1037 had_reset_audio(intelhaddata); in had_do_reset()
1038 wait_clear_underrun_bit(intelhaddata); in had_do_reset()
1039 intelhaddata->need_reset = false; in had_do_reset()
1043 static void had_process_buffer_underrun(struct snd_intelhad *intelhaddata) in had_process_buffer_underrun() argument
1048 substream = had_substream_get(intelhaddata); in had_process_buffer_underrun()
1051 had_substream_put(intelhaddata); in had_process_buffer_underrun()
1053 intelhaddata->need_reset = true; in had_process_buffer_underrun()
1061 struct snd_intelhad *intelhaddata; in had_pcm_open() local
1065 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_open()
1068 pm_runtime_get_sync(intelhaddata->dev); in had_pcm_open()
1091 spin_lock_irq(&intelhaddata->had_spinlock); in had_pcm_open()
1092 intelhaddata->stream_info.substream = substream; in had_pcm_open()
1093 intelhaddata->stream_info.substream_refcount++; in had_pcm_open()
1094 spin_unlock_irq(&intelhaddata->had_spinlock); in had_pcm_open()
1098 pm_runtime_mark_last_busy(intelhaddata->dev); in had_pcm_open()
1099 pm_runtime_put_autosuspend(intelhaddata->dev); in had_pcm_open()
1108 struct snd_intelhad *intelhaddata; in had_pcm_close() local
1110 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_close()
1113 spin_lock_irq(&intelhaddata->had_spinlock); in had_pcm_close()
1114 intelhaddata->stream_info.substream = NULL; in had_pcm_close()
1115 intelhaddata->stream_info.substream_refcount--; in had_pcm_close()
1116 while (intelhaddata->stream_info.substream_refcount > 0) { in had_pcm_close()
1117 spin_unlock_irq(&intelhaddata->had_spinlock); in had_pcm_close()
1119 spin_lock_irq(&intelhaddata->had_spinlock); in had_pcm_close()
1121 spin_unlock_irq(&intelhaddata->had_spinlock); in had_pcm_close()
1123 pm_runtime_mark_last_busy(intelhaddata->dev); in had_pcm_close()
1124 pm_runtime_put_autosuspend(intelhaddata->dev); in had_pcm_close()
1134 struct snd_intelhad *intelhaddata; in had_pcm_hw_params() local
1137 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_hw_params()
1139 dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n", in had_pcm_hw_params()
1149 struct snd_intelhad *intelhaddata; in had_pcm_hw_free() local
1151 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_hw_free()
1152 had_do_reset(intelhaddata); in had_pcm_hw_free()
1163 struct snd_intelhad *intelhaddata; in had_pcm_trigger() local
1165 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_trigger()
1167 spin_lock(&intelhaddata->had_spinlock); in had_pcm_trigger()
1173 had_ack_irqs(intelhaddata); /* FIXME: do we need this? */ in had_pcm_trigger()
1174 had_enable_audio(intelhaddata, true); in had_pcm_trigger()
1180 had_enable_audio(intelhaddata, false); in had_pcm_trigger()
1181 intelhaddata->need_reset = true; in had_pcm_trigger()
1187 spin_unlock(&intelhaddata->had_spinlock); in had_pcm_trigger()
1199 struct snd_intelhad *intelhaddata; in had_pcm_prepare() local
1202 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_prepare()
1205 dev_dbg(intelhaddata->dev, "period_size=%d\n", in had_pcm_prepare()
1207 dev_dbg(intelhaddata->dev, "periods=%d\n", runtime->periods); in had_pcm_prepare()
1208 dev_dbg(intelhaddata->dev, "buffer_size=%d\n", in had_pcm_prepare()
1210 dev_dbg(intelhaddata->dev, "rate=%d\n", runtime->rate); in had_pcm_prepare()
1211 dev_dbg(intelhaddata->dev, "channels=%d\n", runtime->channels); in had_pcm_prepare()
1213 had_do_reset(intelhaddata); in had_pcm_prepare()
1216 disp_samp_freq = intelhaddata->tmds_clock_speed; in had_pcm_prepare()
1218 retval = had_prog_n(substream->runtime->rate, &n_param, intelhaddata); in had_pcm_prepare()
1220 dev_err(intelhaddata->dev, in had_pcm_prepare()
1225 if (intelhaddata->dp_output) in had_pcm_prepare()
1226 link_rate = intelhaddata->link_rate; in had_pcm_prepare()
1229 n_param, intelhaddata); in had_pcm_prepare()
1231 had_prog_dip(substream, intelhaddata); in had_pcm_prepare()
1233 retval = had_init_audio_ctrl(substream, intelhaddata); in had_pcm_prepare()
1236 had_init_ringbuf(substream, intelhaddata); in had_pcm_prepare()
1243 had_write_register(intelhaddata, AUD_BUF_CH_SWAP, SWAP_LFE_CENTER); in had_pcm_prepare()
1254 struct snd_intelhad *intelhaddata; in had_pcm_pointer() local
1257 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_pointer()
1259 if (!intelhaddata->connected) in had_pcm_pointer()
1262 len = had_process_ringbuf(substream, intelhaddata); in had_pcm_pointer()
1298 static int had_process_mode_change(struct snd_intelhad *intelhaddata) in had_process_mode_change() argument
1305 substream = had_substream_get(intelhaddata); in had_process_mode_change()
1310 had_enable_audio(intelhaddata, false); in had_process_mode_change()
1313 disp_samp_freq = intelhaddata->tmds_clock_speed; in had_process_mode_change()
1315 retval = had_prog_n(substream->runtime->rate, &n_param, intelhaddata); in had_process_mode_change()
1317 dev_err(intelhaddata->dev, in had_process_mode_change()
1322 if (intelhaddata->dp_output) in had_process_mode_change()
1323 link_rate = intelhaddata->link_rate; in had_process_mode_change()
1326 n_param, intelhaddata); in had_process_mode_change()
1329 had_enable_audio(intelhaddata, true); in had_process_mode_change()
1332 had_substream_put(intelhaddata); in had_process_mode_change()
1337 static void had_process_hot_plug(struct snd_intelhad *intelhaddata) in had_process_hot_plug() argument
1341 spin_lock_irq(&intelhaddata->had_spinlock); in had_process_hot_plug()
1342 if (intelhaddata->connected) { in had_process_hot_plug()
1343 dev_dbg(intelhaddata->dev, "Device already connected\n"); in had_process_hot_plug()
1344 spin_unlock_irq(&intelhaddata->had_spinlock); in had_process_hot_plug()
1349 had_enable_audio(intelhaddata, false); in had_process_hot_plug()
1351 intelhaddata->connected = true; in had_process_hot_plug()
1352 dev_dbg(intelhaddata->dev, in had_process_hot_plug()
1355 spin_unlock_irq(&intelhaddata->had_spinlock); in had_process_hot_plug()
1357 had_build_channel_allocation_map(intelhaddata); in had_process_hot_plug()
1360 substream = had_substream_get(intelhaddata); in had_process_hot_plug()
1363 had_substream_put(intelhaddata); in had_process_hot_plug()
1366 snd_jack_report(intelhaddata->jack, SND_JACK_AVOUT); in had_process_hot_plug()
1370 static void had_process_hot_unplug(struct snd_intelhad *intelhaddata) in had_process_hot_unplug() argument
1374 spin_lock_irq(&intelhaddata->had_spinlock); in had_process_hot_unplug()
1375 if (!intelhaddata->connected) { in had_process_hot_unplug()
1376 dev_dbg(intelhaddata->dev, "Device already disconnected\n"); in had_process_hot_unplug()
1377 spin_unlock_irq(&intelhaddata->had_spinlock); in had_process_hot_unplug()
1383 had_enable_audio(intelhaddata, false); in had_process_hot_unplug()
1385 intelhaddata->connected = false; in had_process_hot_unplug()
1386 dev_dbg(intelhaddata->dev, in had_process_hot_unplug()
1389 spin_unlock_irq(&intelhaddata->had_spinlock); in had_process_hot_unplug()
1391 kfree(intelhaddata->chmap->chmap); in had_process_hot_unplug()
1392 intelhaddata->chmap->chmap = NULL; in had_process_hot_unplug()
1395 substream = had_substream_get(intelhaddata); in had_process_hot_unplug()
1398 had_substream_put(intelhaddata); in had_process_hot_unplug()
1401 snd_jack_report(intelhaddata->jack, 0); in had_process_hot_unplug()
1419 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol); in had_iec958_get() local
1421 mutex_lock(&intelhaddata->mutex); in had_iec958_get()
1422 ucontrol->value.iec958.status[0] = (intelhaddata->aes_bits >> 0) & 0xff; in had_iec958_get()
1423 ucontrol->value.iec958.status[1] = (intelhaddata->aes_bits >> 8) & 0xff; in had_iec958_get()
1425 (intelhaddata->aes_bits >> 16) & 0xff; in had_iec958_get()
1427 (intelhaddata->aes_bits >> 24) & 0xff; in had_iec958_get()
1428 mutex_unlock(&intelhaddata->mutex); in had_iec958_get()
1446 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol); in had_iec958_put() local
1453 mutex_lock(&intelhaddata->mutex); in had_iec958_put()
1454 if (intelhaddata->aes_bits != val) { in had_iec958_put()
1455 intelhaddata->aes_bits = val; in had_iec958_put()
1458 mutex_unlock(&intelhaddata->mutex); in had_iec958_put()
1473 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol); in had_ctl_eld_get() local
1475 mutex_lock(&intelhaddata->mutex); in had_ctl_eld_get()
1476 memcpy(ucontrol->value.bytes.data, intelhaddata->eld, in had_ctl_eld_get()
1478 mutex_unlock(&intelhaddata->mutex); in had_ctl_eld_get()