Lines Matching refs:intelhaddata

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