Lines Matching refs:compr

442 	struct wm_adsp_compr *compr;
3447 static inline int wm_adsp_compr_attached(struct wm_adsp_compr *compr)
3449 return compr->buf != NULL;
3452 static int wm_adsp_compr_attach(struct wm_adsp_compr *compr)
3456 if (compr->dsp->fatal_error)
3459 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) {
3460 if (!tmp->name || !strcmp(compr->name, tmp->name)) {
3469 compr->buf = buf;
3470 buf->compr = compr;
3475 static void wm_adsp_compr_detach(struct wm_adsp_compr *compr)
3477 if (!compr)
3481 if (compr->stream)
3482 snd_compr_fragment_elapsed(compr->stream);
3484 if (wm_adsp_compr_attached(compr)) {
3485 compr->buf->compr = NULL;
3486 compr->buf = NULL;
3492 struct wm_adsp_compr *compr, *tmp;
3521 compr = kzalloc(sizeof(*compr), GFP_KERNEL);
3522 if (!compr) {
3527 compr->dsp = dsp;
3528 compr->stream = stream;
3529 compr->name = asoc_rtd_to_codec(rtd, 0)->name;
3531 list_add_tail(&compr->list, &dsp->compr_list);
3533 stream->runtime->private_data = compr;
3545 struct wm_adsp_compr *compr = stream->runtime->private_data;
3546 struct wm_adsp *dsp = compr->dsp;
3550 wm_adsp_compr_detach(compr);
3551 list_del(&compr->list);
3553 kfree(compr->raw_buf);
3554 kfree(compr);
3565 struct wm_adsp_compr *compr = stream->runtime->private_data;
3566 struct wm_adsp *dsp = compr->dsp;
3576 compr_err(compr, "Invalid buffer fragsize=%d fragments=%d\n",
3606 compr_err(compr, "Invalid params id=%u ch=%u,%u rate=%u fmt=%u\n",
3612 static inline unsigned int wm_adsp_compr_frag_words(struct wm_adsp_compr *compr)
3614 return compr->size.fragment_size / WM_ADSP_DATA_WORD_SIZE;
3621 struct wm_adsp_compr *compr = stream->runtime->private_data;
3629 compr->size = params->buffer;
3631 compr_dbg(compr, "fragment_size=%d fragments=%d\n",
3632 compr->size.fragment_size, compr->size.fragments);
3634 size = wm_adsp_compr_frag_words(compr) * sizeof(*compr->raw_buf);
3635 compr->raw_buf = kmalloc(size, GFP_DMA | GFP_KERNEL);
3636 if (!compr->raw_buf)
3639 compr->sample_rate = params->codec.sample_rate;
3649 struct wm_adsp_compr *compr = stream->runtime->private_data;
3650 int fw = compr->dsp->fw;
3988 wm_adsp_compr_detach(buf->compr);
4019 struct wm_adsp_compr *compr = stream->runtime->private_data;
4020 struct wm_adsp *dsp = compr->dsp;
4023 compr_dbg(compr, "Trigger: %d\n", cmd);
4029 if (!wm_adsp_compr_attached(compr)) {
4030 ret = wm_adsp_compr_attach(compr);
4032 compr_err(compr, "Failed to link buffer and stream: %d\n",
4038 ret = wm_adsp_buffer_get_error(compr->buf);
4043 ret = wm_adsp_buffer_write(compr->buf,
4045 wm_adsp_compr_frag_words(compr));
4047 compr_err(compr, "Failed to set high water mark: %d\n",
4053 if (wm_adsp_compr_attached(compr))
4054 wm_adsp_buffer_clear(compr->buf);
4120 struct wm_adsp_compr *compr;
4133 compr = buf->compr;
4156 if (compr && compr->stream)
4157 snd_compr_fragment_elapsed(compr->stream);
4184 struct wm_adsp_compr *compr = stream->runtime->private_data;
4185 struct wm_adsp *dsp = compr->dsp;
4189 compr_dbg(compr, "Pointer request\n");
4193 buf = compr->buf;
4201 if (buf->avail < wm_adsp_compr_frag_words(compr)) {
4204 compr_err(compr, "Error reading avail: %d\n", ret);
4212 if (buf->avail < wm_adsp_compr_frag_words(compr)) {
4223 compr_err(compr, "Failed to re-enable buffer IRQ: %d\n",
4230 tstamp->copied_total = compr->copied_total;
4232 tstamp->sampling_rate = compr->sample_rate;
4241 static int wm_adsp_buffer_capture_block(struct wm_adsp_compr *compr, int target)
4243 struct wm_adsp_compr_buf *buf = compr->buf;
4260 max_read = wm_adsp_compr_frag_words(compr);
4274 nwords, compr->raw_buf);
4278 wm_adsp_remove_padding(compr->raw_buf, nwords, WM_ADSP_DATA_WORD_SIZE);
4296 static int wm_adsp_compr_read(struct wm_adsp_compr *compr,
4299 struct wm_adsp *dsp = compr->dsp;
4303 compr_dbg(compr, "Requested read of %zu bytes\n", count);
4305 if (dsp->fatal_error || !compr->buf || compr->buf->error) {
4306 snd_compr_stop_error(compr->stream, SNDRV_PCM_STATE_XRUN);
4313 nwords = wm_adsp_buffer_capture_block(compr, count);
4315 compr_err(compr, "Failed to capture block: %d\n",
4322 compr_dbg(compr, "Read %d bytes\n", nbytes);
4324 if (copy_to_user(buf + ntotal, compr->raw_buf, nbytes)) {
4325 compr_err(compr, "Failed to copy data to user: %d, %d\n",
4334 compr->copied_total += ntotal;
4343 struct wm_adsp_compr *compr = stream->runtime->private_data;
4344 struct wm_adsp *dsp = compr->dsp;
4350 ret = wm_adsp_compr_read(compr, buf, count);
4362 struct wm_adsp_compr *compr;
4366 list_for_each_entry(compr, &dsp->compr_list, list) {
4367 if (compr->stream)
4368 snd_compr_fragment_elapsed(compr->stream);