Lines Matching refs:intelhaddata

169 had_substream_get(struct snd_intelhad *intelhaddata)  in had_substream_get()  argument
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()
185 static void had_substream_put(struct snd_intelhad *intelhaddata) in had_substream_put() argument
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()
249 static void had_enable_audio(struct snd_intelhad *intelhaddata, in had_enable_audio() argument
253 intelhaddata->aud_config.regx.aud_en = enable; in had_enable_audio()
254 had_write_register(intelhaddata, AUD_CONFIG, in had_enable_audio()
255 intelhaddata->aud_config.regval); in had_enable_audio()
272 static void had_reset_audio(struct snd_intelhad *intelhaddata) in had_reset_audio() argument
274 had_write_register(intelhaddata, AUD_HDMI_STATUS, in had_reset_audio()
276 had_write_register(intelhaddata, AUD_HDMI_STATUS, 0); in had_reset_audio()
284 struct snd_intelhad *intelhaddata) in had_prog_status_reg() argument
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()
323 had_write_register(intelhaddata, in had_prog_status_reg()
340 had_write_register(intelhaddata, in had_prog_status_reg()
351 struct snd_intelhad *intelhaddata) in had_init_audio_ctrl() argument
357 had_prog_status_reg(substream, intelhaddata); in had_init_audio_ctrl()
362 had_write_register(intelhaddata, AUD_BUF_CONFIG, buf_cfg.regval); in had_init_audio_ctrl()
380 if (intelhaddata->dp_output) { in had_init_audio_ctrl()
385 had_write_register(intelhaddata, AUD_CONFIG, cfg_val.regval); in had_init_audio_ctrl()
386 intelhaddata->aud_config = cfg_val; in had_init_audio_ctrl()
418 static int had_channel_allocation(struct snd_intelhad *intelhaddata, in had_channel_allocation() argument
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()
470 static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata) in had_build_channel_allocation_map() argument
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()
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()
524 intelhaddata->chmap->chmap = chmap; in had_build_channel_allocation_map()
549 struct snd_intelhad *intelhaddata = info->private_data; in had_chmap_ctl_get() local
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()
564 mutex_unlock(&intelhaddata->mutex); in had_chmap_ctl_get()
569 static int had_register_chmap_ctls(struct snd_intelhad *intelhaddata, in had_register_chmap_ctls() argument
575 NULL, 0, (unsigned long)intelhaddata, in had_register_chmap_ctls()
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()
592 struct snd_intelhad *intelhaddata) in had_prog_dip() argument
605 had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.regval); in had_prog_dip()
607 ca = had_channel_allocation(intelhaddata, channels); in had_prog_dip()
608 if (intelhaddata->dp_output) { in had_prog_dip()
627 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, info_frame); in had_prog_dip()
628 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, frame2.regval); in had_prog_dip()
629 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, frame3.regval); in had_prog_dip()
633 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, 0x0); in had_prog_dip()
637 had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.regval); in had_prog_dip()
731 u32 n_param, struct snd_intelhad *intelhaddata) in had_prog_cts() argument
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()
747 had_write_register(intelhaddata, AUD_HDMI_CTS, (BIT(24) | cts_val)); in had_prog_cts()
802 struct snd_intelhad *intelhaddata) in had_prog_n() argument
806 if (intelhaddata->dp_output) { in had_prog_n()
822 had_write_register(intelhaddata, AUD_N_ENABLE, (BIT(24) | n_val)); in had_prog_n()
872 struct snd_intelhad *intelhaddata) in had_prog_bd() argument
874 int idx = intelhaddata->bd_head; in had_prog_bd()
875 int ofs = intelhaddata->pcmbuf_filled * intelhaddata->period_bytes; in had_prog_bd()
881 had_write_register(intelhaddata, AUD_BUF_ADDR(idx), addr); in had_prog_bd()
882 had_write_register(intelhaddata, AUD_BUF_LEN(idx), 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()
893 static void had_invalidate_bd(struct snd_intelhad *intelhaddata, in had_invalidate_bd() argument
896 had_write_register(intelhaddata, AUD_BUF_ADDR(idx), 0); in had_invalidate_bd()
897 had_write_register(intelhaddata, AUD_BUF_LEN(idx), 0); in had_invalidate_bd()
902 struct snd_intelhad *intelhaddata) in had_init_ringbuf() argument
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()
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()
921 had_prog_bd(substream, intelhaddata); in had_init_ringbuf()
923 had_invalidate_bd(intelhaddata, i); in had_init_ringbuf()
926 intelhaddata->bd_head = 0; /* reset at head again before starting */ in had_init_ringbuf()
931 struct snd_intelhad *intelhaddata) in had_advance_ringbuf() argument
936 had_prog_bd(substream, intelhaddata); in had_advance_ringbuf()
939 intelhaddata->pcmbuf_head++; in had_advance_ringbuf()
940 intelhaddata->pcmbuf_head %= num_periods; in had_advance_ringbuf()
947 struct snd_intelhad *intelhaddata) in had_process_ringbuf() argument
953 spin_lock_irqsave(&intelhaddata->had_spinlock, flags); in had_process_ringbuf()
956 had_read_register(intelhaddata, 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()
970 if (++processed >= intelhaddata->num_bds) { in had_process_ringbuf()
974 had_advance_ringbuf(substream, intelhaddata); 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()
985 static void had_process_buffer_done(struct snd_intelhad *intelhaddata) in had_process_buffer_done() argument
989 substream = had_substream_get(intelhaddata); in had_process_buffer_done()
993 if (!intelhaddata->connected) { in had_process_buffer_done()
999 if (had_process_ringbuf(substream, intelhaddata) < 0) in had_process_buffer_done()
1005 had_substream_put(intelhaddata); in had_process_buffer_done()
1012 static void wait_clear_underrun_bit(struct snd_intelhad *intelhaddata) in wait_clear_underrun_bit() argument
1019 had_read_register(intelhaddata, AUD_HDMI_STATUS, &val); in wait_clear_underrun_bit()
1024 had_write_register(intelhaddata, AUD_HDMI_STATUS, val); in wait_clear_underrun_bit()
1026 dev_err(intelhaddata->dev, "Unable to clear UNDERRUN bits\n"); in wait_clear_underrun_bit()
1035 struct snd_intelhad *intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_sync_stop() local
1037 if (!intelhaddata->connected) in had_pcm_sync_stop()
1041 had_reset_audio(intelhaddata); in had_pcm_sync_stop()
1042 wait_clear_underrun_bit(intelhaddata); in had_pcm_sync_stop()
1047 static void had_process_buffer_underrun(struct snd_intelhad *intelhaddata) in had_process_buffer_underrun() argument
1052 substream = had_substream_get(intelhaddata); in had_process_buffer_underrun()
1055 had_substream_put(intelhaddata); in had_process_buffer_underrun()
1064 struct snd_intelhad *intelhaddata; in had_pcm_open() local
1068 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_open()
1071 retval = pm_runtime_resume_and_get(intelhaddata->dev); 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()
1113 struct snd_intelhad *intelhaddata; in had_pcm_close() local
1115 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_close()
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()
1139 struct snd_intelhad *intelhaddata; in had_pcm_hw_params() local
1142 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_hw_params()
1144 dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n", in had_pcm_hw_params()
1155 struct snd_intelhad *intelhaddata; in had_pcm_trigger() local
1157 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_trigger()
1159 spin_lock(&intelhaddata->had_spinlock); in had_pcm_trigger()
1165 had_ack_irqs(intelhaddata); /* FIXME: do we need this? */ in had_pcm_trigger()
1166 had_enable_audio(intelhaddata, true); in had_pcm_trigger()
1172 had_enable_audio(intelhaddata, false); in had_pcm_trigger()
1178 spin_unlock(&intelhaddata->had_spinlock); in had_pcm_trigger()
1190 struct snd_intelhad *intelhaddata; in had_pcm_prepare() local
1193 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_prepare()
1196 dev_dbg(intelhaddata->dev, "period_size=%d\n", 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()
1218 n_param, intelhaddata); in had_pcm_prepare()
1220 had_prog_dip(substream, intelhaddata); in had_pcm_prepare()
1222 retval = had_init_audio_ctrl(substream, intelhaddata); in had_pcm_prepare()
1225 had_init_ringbuf(substream, intelhaddata); in had_pcm_prepare()
1232 had_write_register(intelhaddata, AUD_BUF_CH_SWAP, SWAP_LFE_CENTER); in had_pcm_prepare()
1243 struct snd_intelhad *intelhaddata; in had_pcm_pointer() local
1246 intelhaddata = snd_pcm_substream_chip(substream); in had_pcm_pointer()
1248 if (!intelhaddata->connected) in had_pcm_pointer()
1251 len = had_process_ringbuf(substream, intelhaddata); in had_pcm_pointer()
1274 static int had_process_mode_change(struct snd_intelhad *intelhaddata) in had_process_mode_change() argument
1281 substream = had_substream_get(intelhaddata); in had_process_mode_change()
1286 had_enable_audio(intelhaddata, false); in had_process_mode_change()
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()
1302 n_param, intelhaddata); in had_process_mode_change()
1305 had_enable_audio(intelhaddata, true); in had_process_mode_change()
1308 had_substream_put(intelhaddata); in had_process_mode_change()
1313 static void had_process_hot_plug(struct snd_intelhad *intelhaddata) in had_process_hot_plug() argument
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()
1325 had_enable_audio(intelhaddata, false); 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()
1333 had_build_channel_allocation_map(intelhaddata); in had_process_hot_plug()
1336 substream = had_substream_get(intelhaddata); in had_process_hot_plug()
1339 had_substream_put(intelhaddata); in had_process_hot_plug()
1342 snd_jack_report(intelhaddata->jack, SND_JACK_AVOUT); in had_process_hot_plug()
1346 static void had_process_hot_unplug(struct snd_intelhad *intelhaddata) in had_process_hot_unplug() argument
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()
1359 had_enable_audio(intelhaddata, false); 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()
1371 substream = had_substream_get(intelhaddata); in had_process_hot_unplug()
1374 had_substream_put(intelhaddata); in had_process_hot_unplug()
1377 snd_jack_report(intelhaddata->jack, 0); in had_process_hot_unplug()
1395 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol); in had_iec958_get() local
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()
1401 (intelhaddata->aes_bits >> 16) & 0xff; in had_iec958_get()
1403 (intelhaddata->aes_bits >> 24) & 0xff; in had_iec958_get()
1404 mutex_unlock(&intelhaddata->mutex); in had_iec958_get()
1422 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol); in had_iec958_put() local
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()
1449 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol); in had_ctl_eld_get() local
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()