Lines Matching refs:intelhaddata
169 had_substream_get(struct snd_intelhad *intelhaddata)
174 spin_lock_irqsave(&intelhaddata->had_spinlock, flags);
175 substream = intelhaddata->stream_info.substream;
177 intelhaddata->stream_info.substream_refcount++;
178 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags);
185 static void had_substream_put(struct snd_intelhad *intelhaddata)
189 spin_lock_irqsave(&intelhaddata->had_spinlock, flags);
190 intelhaddata->stream_info.substream_refcount--;
191 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags);
249 static void had_enable_audio(struct snd_intelhad *intelhaddata,
253 intelhaddata->aud_config.regx.aud_en = enable;
254 had_write_register(intelhaddata, AUD_CONFIG,
255 intelhaddata->aud_config.regval);
272 static void had_reset_audio(struct snd_intelhad *intelhaddata)
274 had_write_register(intelhaddata, AUD_HDMI_STATUS,
276 had_write_register(intelhaddata, AUD_HDMI_STATUS, 0);
284 struct snd_intelhad *intelhaddata)
289 ch_stat0.regx.lpcm_id = (intelhaddata->aes_bits &
291 ch_stat0.regx.clk_acc = (intelhaddata->aes_bits &
323 had_write_register(intelhaddata,
340 had_write_register(intelhaddata,
351 struct snd_intelhad *intelhaddata)
357 had_prog_status_reg(substream, intelhaddata);
362 had_write_register(intelhaddata, AUD_BUF_CONFIG, buf_cfg.regval);
380 if (intelhaddata->dp_output) {
385 had_write_register(intelhaddata, AUD_CONFIG, cfg_val.regval);
386 intelhaddata->aud_config = cfg_val;
418 static int had_channel_allocation(struct snd_intelhad *intelhaddata,
439 if (intelhaddata->eld[DRM_ELD_SPEAKER] & (1 << i))
453 dev_dbg(intelhaddata->dev, "select CA 0x%x for %d\n", ca, channels);
470 static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata)
478 kfree(intelhaddata->chmap->chmap);
479 intelhaddata->chmap->chmap = NULL;
485 dev_dbg(intelhaddata->dev, "eld speaker = %x\n",
486 intelhaddata->eld[DRM_ELD_SPEAKER]);
497 eld_high = intelhaddata->eld[DRM_ELD_SPEAKER] & eld_high_mask;
504 intelhaddata->eld[DRM_ELD_SPEAKER] &=
512 if (intelhaddata->eld[DRM_ELD_SPEAKER] & (1 << i))
524 intelhaddata->chmap->chmap = chmap;
549 struct snd_intelhad *intelhaddata = info->private_data;
555 mutex_lock(&intelhaddata->mutex);
556 if (!intelhaddata->chmap->chmap) {
557 mutex_unlock(&intelhaddata->mutex);
561 chmap = intelhaddata->chmap->chmap;
564 mutex_unlock(&intelhaddata->mutex);
569 static int had_register_chmap_ctls(struct snd_intelhad *intelhaddata,
575 NULL, 0, (unsigned long)intelhaddata,
576 &intelhaddata->chmap);
580 intelhaddata->chmap->private_data = intelhaddata;
581 intelhaddata->chmap->kctl->info = had_chmap_ctl_info;
582 intelhaddata->chmap->kctl->get = had_chmap_ctl_get;
583 intelhaddata->chmap->chmap = NULL;
592 struct snd_intelhad *intelhaddata)
605 had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.regval);
607 ca = had_channel_allocation(intelhaddata, channels);
608 if (intelhaddata->dp_output) {
627 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, info_frame);
628 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, frame2.regval);
629 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, frame3.regval);
633 had_write_register(intelhaddata, AUD_HDMIW_INFOFR, 0x0);
637 had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.regval);
726 * @intelhaddata: substream private data
731 u32 n_param, struct snd_intelhad *intelhaddata)
736 if (intelhaddata->dp_output) {
745 dev_dbg(intelhaddata->dev, "TMDS value=%d, N value=%d, CTS Value=%d\n",
747 had_write_register(intelhaddata, AUD_HDMI_CTS, (BIT(24) | cts_val));
796 * @intelhaddata: substream private data
802 struct snd_intelhad *intelhaddata)
806 if (intelhaddata->dp_output) {
822 had_write_register(intelhaddata, AUD_N_ENABLE, (BIT(24) | n_val));
872 struct snd_intelhad *intelhaddata)
874 int idx = intelhaddata->bd_head;
875 int ofs = intelhaddata->pcmbuf_filled * intelhaddata->period_bytes;
881 had_write_register(intelhaddata, AUD_BUF_ADDR(idx), addr);
882 had_write_register(intelhaddata, AUD_BUF_LEN(idx),
883 intelhaddata->period_bytes);
886 intelhaddata->bd_head++;
887 intelhaddata->bd_head %= intelhaddata->num_bds;
888 intelhaddata->pcmbuf_filled++;
889 intelhaddata->pcmbuf_filled %= substream->runtime->periods;
893 static void had_invalidate_bd(struct snd_intelhad *intelhaddata,
896 had_write_register(intelhaddata, AUD_BUF_ADDR(idx), 0);
897 had_write_register(intelhaddata, AUD_BUF_LEN(idx), 0);
902 struct snd_intelhad *intelhaddata)
908 intelhaddata->num_bds = min(num_periods, HAD_NUM_OF_RING_BUFS);
910 intelhaddata->num_bds = max(intelhaddata->num_bds, 2U);
911 intelhaddata->period_bytes =
913 WARN_ON(intelhaddata->period_bytes & 0x3f);
915 intelhaddata->bd_head = 0;
916 intelhaddata->pcmbuf_head = 0;
917 intelhaddata->pcmbuf_filled = 0;
920 if (i < intelhaddata->num_bds)
921 had_prog_bd(substream, intelhaddata);
923 had_invalidate_bd(intelhaddata, i);
926 intelhaddata->bd_head = 0; /* reset at head again before starting */
931 struct snd_intelhad *intelhaddata)
936 had_prog_bd(substream, intelhaddata);
939 intelhaddata->pcmbuf_head++;
940 intelhaddata->pcmbuf_head %= num_periods;
947 struct snd_intelhad *intelhaddata)
953 spin_lock_irqsave(&intelhaddata->had_spinlock, flags);
956 had_read_register(intelhaddata,
957 AUD_BUF_LEN(intelhaddata->bd_head),
959 if (len < 0 || len > intelhaddata->period_bytes) {
960 dev_dbg(intelhaddata->dev, "Invalid buf length %d\n",
970 if (++processed >= intelhaddata->num_bds) {
974 had_advance_ringbuf(substream, intelhaddata);
977 len = intelhaddata->period_bytes - len;
978 len += intelhaddata->period_bytes * intelhaddata->pcmbuf_head;
980 spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags);
985 static void had_process_buffer_done(struct snd_intelhad *intelhaddata)
989 substream = had_substream_get(intelhaddata);
993 if (!intelhaddata->connected) {
999 if (had_process_ringbuf(substream, intelhaddata) < 0)
1005 had_substream_put(intelhaddata);
1012 static void wait_clear_underrun_bit(struct snd_intelhad *intelhaddata)
1019 had_read_register(intelhaddata, AUD_HDMI_STATUS, &val);
1024 had_write_register(intelhaddata, AUD_HDMI_STATUS, val);
1026 dev_err(intelhaddata->dev, "Unable to clear UNDERRUN bits\n");
1035 struct snd_intelhad *intelhaddata = snd_pcm_substream_chip(substream);
1037 if (!intelhaddata->connected)
1041 had_reset_audio(intelhaddata);
1042 wait_clear_underrun_bit(intelhaddata);
1047 static void had_process_buffer_underrun(struct snd_intelhad *intelhaddata)
1052 substream = had_substream_get(intelhaddata);
1055 had_substream_put(intelhaddata);
1064 struct snd_intelhad *intelhaddata;
1068 intelhaddata = snd_pcm_substream_chip(substream);
1071 retval = pm_runtime_resume_and_get(intelhaddata->dev);
1096 spin_lock_irq(&intelhaddata->had_spinlock);
1097 intelhaddata->stream_info.substream = substream;
1098 intelhaddata->stream_info.substream_refcount++;
1099 spin_unlock_irq(&intelhaddata->had_spinlock);
1103 pm_runtime_mark_last_busy(intelhaddata->dev);
1104 pm_runtime_put_autosuspend(intelhaddata->dev);
1113 struct snd_intelhad *intelhaddata;
1115 intelhaddata = snd_pcm_substream_chip(substream);
1118 spin_lock_irq(&intelhaddata->had_spinlock);
1119 intelhaddata->stream_info.substream = NULL;
1120 intelhaddata->stream_info.substream_refcount--;
1121 while (intelhaddata->stream_info.substream_refcount > 0) {
1122 spin_unlock_irq(&intelhaddata->had_spinlock);
1124 spin_lock_irq(&intelhaddata->had_spinlock);
1126 spin_unlock_irq(&intelhaddata->had_spinlock);
1128 pm_runtime_mark_last_busy(intelhaddata->dev);
1129 pm_runtime_put_autosuspend(intelhaddata->dev);
1139 struct snd_intelhad *intelhaddata;
1142 intelhaddata = snd_pcm_substream_chip(substream);
1144 dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n",
1155 struct snd_intelhad *intelhaddata;
1157 intelhaddata = snd_pcm_substream_chip(substream);
1159 spin_lock(&intelhaddata->had_spinlock);
1165 had_ack_irqs(intelhaddata); /* FIXME: do we need this? */
1166 had_enable_audio(intelhaddata, true);
1172 had_enable_audio(intelhaddata, false);
1178 spin_unlock(&intelhaddata->had_spinlock);
1190 struct snd_intelhad *intelhaddata;
1193 intelhaddata = snd_pcm_substream_chip(substream);
1196 dev_dbg(intelhaddata->dev, "period_size=%d\n",
1198 dev_dbg(intelhaddata->dev, "periods=%d\n", runtime->periods);
1199 dev_dbg(intelhaddata->dev, "buffer_size=%d\n",
1201 dev_dbg(intelhaddata->dev, "rate=%d\n", runtime->rate);
1202 dev_dbg(intelhaddata->dev, "channels=%d\n", runtime->channels);
1205 disp_samp_freq = intelhaddata->tmds_clock_speed;
1207 retval = had_prog_n(substream->runtime->rate, &n_param, intelhaddata);
1209 dev_err(intelhaddata->dev,
1214 if (intelhaddata->dp_output)
1215 link_rate = intelhaddata->link_rate;
1218 n_param, intelhaddata);
1220 had_prog_dip(substream, intelhaddata);
1222 retval = had_init_audio_ctrl(substream, intelhaddata);
1225 had_init_ringbuf(substream, intelhaddata);
1232 had_write_register(intelhaddata, AUD_BUF_CH_SWAP, SWAP_LFE_CENTER);
1243 struct snd_intelhad *intelhaddata;
1246 intelhaddata = snd_pcm_substream_chip(substream);
1248 if (!intelhaddata->connected)
1251 len = had_process_ringbuf(substream, intelhaddata);
1274 static int had_process_mode_change(struct snd_intelhad *intelhaddata)
1281 substream = had_substream_get(intelhaddata);
1286 had_enable_audio(intelhaddata, false);
1289 disp_samp_freq = intelhaddata->tmds_clock_speed;
1291 retval = had_prog_n(substream->runtime->rate, &n_param, intelhaddata);
1293 dev_err(intelhaddata->dev,
1298 if (intelhaddata->dp_output)
1299 link_rate = intelhaddata->link_rate;
1302 n_param, intelhaddata);
1305 had_enable_audio(intelhaddata, true);
1308 had_substream_put(intelhaddata);
1313 static void had_process_hot_plug(struct snd_intelhad *intelhaddata)
1317 spin_lock_irq(&intelhaddata->had_spinlock);
1318 if (intelhaddata->connected) {
1319 dev_dbg(intelhaddata->dev, "Device already connected\n");
1320 spin_unlock_irq(&intelhaddata->had_spinlock);
1325 had_enable_audio(intelhaddata, false);
1327 intelhaddata->connected = true;
1328 dev_dbg(intelhaddata->dev,
1331 spin_unlock_irq(&intelhaddata->had_spinlock);
1333 had_build_channel_allocation_map(intelhaddata);
1336 substream = had_substream_get(intelhaddata);
1339 had_substream_put(intelhaddata);
1342 snd_jack_report(intelhaddata->jack, SND_JACK_AVOUT);
1346 static void had_process_hot_unplug(struct snd_intelhad *intelhaddata)
1350 spin_lock_irq(&intelhaddata->had_spinlock);
1351 if (!intelhaddata->connected) {
1352 dev_dbg(intelhaddata->dev, "Device already disconnected\n");
1353 spin_unlock_irq(&intelhaddata->had_spinlock);
1359 had_enable_audio(intelhaddata, false);
1361 intelhaddata->connected = false;
1362 dev_dbg(intelhaddata->dev,
1365 spin_unlock_irq(&intelhaddata->had_spinlock);
1367 kfree(intelhaddata->chmap->chmap);
1368 intelhaddata->chmap->chmap = NULL;
1371 substream = had_substream_get(intelhaddata);
1374 had_substream_put(intelhaddata);
1377 snd_jack_report(intelhaddata->jack, 0);
1395 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol);
1397 mutex_lock(&intelhaddata->mutex);
1398 ucontrol->value.iec958.status[0] = (intelhaddata->aes_bits >> 0) & 0xff;
1399 ucontrol->value.iec958.status[1] = (intelhaddata->aes_bits >> 8) & 0xff;
1401 (intelhaddata->aes_bits >> 16) & 0xff;
1403 (intelhaddata->aes_bits >> 24) & 0xff;
1404 mutex_unlock(&intelhaddata->mutex);
1422 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol);
1429 mutex_lock(&intelhaddata->mutex);
1430 if (intelhaddata->aes_bits != val) {
1431 intelhaddata->aes_bits = val;
1434 mutex_unlock(&intelhaddata->mutex);
1449 struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol);
1451 mutex_lock(&intelhaddata->mutex);
1452 memcpy(ucontrol->value.bytes.data, intelhaddata->eld,
1454 mutex_unlock(&intelhaddata->mutex);