Lines Matching refs:compr
442 struct wm_adsp_compr *compr; member
3447 static inline int wm_adsp_compr_attached(struct wm_adsp_compr *compr) in wm_adsp_compr_attached() argument
3449 return compr->buf != NULL; in wm_adsp_compr_attached()
3452 static int wm_adsp_compr_attach(struct wm_adsp_compr *compr) in wm_adsp_compr_attach() argument
3456 if (compr->dsp->fatal_error) in wm_adsp_compr_attach()
3459 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) { in wm_adsp_compr_attach()
3460 if (!tmp->name || !strcmp(compr->name, tmp->name)) { in wm_adsp_compr_attach()
3469 compr->buf = buf; in wm_adsp_compr_attach()
3470 buf->compr = compr; in wm_adsp_compr_attach()
3475 static void wm_adsp_compr_detach(struct wm_adsp_compr *compr) in wm_adsp_compr_detach() argument
3477 if (!compr) in wm_adsp_compr_detach()
3481 if (compr->stream) in wm_adsp_compr_detach()
3482 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_compr_detach()
3484 if (wm_adsp_compr_attached(compr)) { in wm_adsp_compr_detach()
3485 compr->buf->compr = NULL; in wm_adsp_compr_detach()
3486 compr->buf = NULL; in wm_adsp_compr_detach()
3492 struct wm_adsp_compr *compr, *tmp; in wm_adsp_compr_open() local
3521 compr = kzalloc(sizeof(*compr), GFP_KERNEL); in wm_adsp_compr_open()
3522 if (!compr) { in wm_adsp_compr_open()
3527 compr->dsp = dsp; in wm_adsp_compr_open()
3528 compr->stream = stream; in wm_adsp_compr_open()
3529 compr->name = asoc_rtd_to_codec(rtd, 0)->name; in wm_adsp_compr_open()
3531 list_add_tail(&compr->list, &dsp->compr_list); in wm_adsp_compr_open()
3533 stream->runtime->private_data = compr; in wm_adsp_compr_open()
3545 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_free() local
3546 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_free()
3550 wm_adsp_compr_detach(compr); in wm_adsp_compr_free()
3551 list_del(&compr->list); in wm_adsp_compr_free()
3553 kfree(compr->raw_buf); in wm_adsp_compr_free()
3554 kfree(compr); in wm_adsp_compr_free()
3565 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_check_params() local
3566 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_check_params()
3576 compr_err(compr, "Invalid buffer fragsize=%d fragments=%d\n", in wm_adsp_compr_check_params()
3606 compr_err(compr, "Invalid params id=%u ch=%u,%u rate=%u fmt=%u\n", in wm_adsp_compr_check_params()
3612 static inline unsigned int wm_adsp_compr_frag_words(struct wm_adsp_compr *compr) in wm_adsp_compr_frag_words() argument
3614 return compr->size.fragment_size / WM_ADSP_DATA_WORD_SIZE; in wm_adsp_compr_frag_words()
3621 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_set_params() local
3629 compr->size = params->buffer; in wm_adsp_compr_set_params()
3631 compr_dbg(compr, "fragment_size=%d fragments=%d\n", in wm_adsp_compr_set_params()
3632 compr->size.fragment_size, compr->size.fragments); in wm_adsp_compr_set_params()
3634 size = wm_adsp_compr_frag_words(compr) * sizeof(*compr->raw_buf); in wm_adsp_compr_set_params()
3635 compr->raw_buf = kmalloc(size, GFP_DMA | GFP_KERNEL); in wm_adsp_compr_set_params()
3636 if (!compr->raw_buf) in wm_adsp_compr_set_params()
3639 compr->sample_rate = params->codec.sample_rate; in wm_adsp_compr_set_params()
3649 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_get_caps() local
3650 int fw = compr->dsp->fw; in wm_adsp_compr_get_caps()
3984 wm_adsp_compr_detach(buf->compr); in wm_adsp_buffer_free()
4015 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_trigger() local
4016 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_trigger()
4019 compr_dbg(compr, "Trigger: %d\n", cmd); in wm_adsp_compr_trigger()
4025 if (!wm_adsp_compr_attached(compr)) { in wm_adsp_compr_trigger()
4026 ret = wm_adsp_compr_attach(compr); in wm_adsp_compr_trigger()
4028 compr_err(compr, "Failed to link buffer and stream: %d\n", in wm_adsp_compr_trigger()
4034 ret = wm_adsp_buffer_get_error(compr->buf); in wm_adsp_compr_trigger()
4039 ret = wm_adsp_buffer_write(compr->buf, in wm_adsp_compr_trigger()
4041 wm_adsp_compr_frag_words(compr)); in wm_adsp_compr_trigger()
4043 compr_err(compr, "Failed to set high water mark: %d\n", in wm_adsp_compr_trigger()
4049 if (wm_adsp_compr_attached(compr)) in wm_adsp_compr_trigger()
4050 wm_adsp_buffer_clear(compr->buf); in wm_adsp_compr_trigger()
4116 struct wm_adsp_compr *compr; in wm_adsp_compr_handle_irq() local
4129 compr = buf->compr; in wm_adsp_compr_handle_irq()
4152 if (compr && compr->stream) in wm_adsp_compr_handle_irq()
4153 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_compr_handle_irq()
4180 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_pointer() local
4181 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_pointer()
4185 compr_dbg(compr, "Pointer request\n"); in wm_adsp_compr_pointer()
4189 buf = compr->buf; in wm_adsp_compr_pointer()
4197 if (buf->avail < wm_adsp_compr_frag_words(compr)) { in wm_adsp_compr_pointer()
4200 compr_err(compr, "Error reading avail: %d\n", ret); in wm_adsp_compr_pointer()
4208 if (buf->avail < wm_adsp_compr_frag_words(compr)) { in wm_adsp_compr_pointer()
4219 compr_err(compr, "Failed to re-enable buffer IRQ: %d\n", in wm_adsp_compr_pointer()
4226 tstamp->copied_total = compr->copied_total; in wm_adsp_compr_pointer()
4228 tstamp->sampling_rate = compr->sample_rate; in wm_adsp_compr_pointer()
4237 static int wm_adsp_buffer_capture_block(struct wm_adsp_compr *compr, int target) in wm_adsp_buffer_capture_block() argument
4239 struct wm_adsp_compr_buf *buf = compr->buf; in wm_adsp_buffer_capture_block()
4256 max_read = wm_adsp_compr_frag_words(compr); in wm_adsp_buffer_capture_block()
4270 nwords, compr->raw_buf); in wm_adsp_buffer_capture_block()
4274 wm_adsp_remove_padding(compr->raw_buf, nwords, WM_ADSP_DATA_WORD_SIZE); in wm_adsp_buffer_capture_block()
4292 static int wm_adsp_compr_read(struct wm_adsp_compr *compr, in wm_adsp_compr_read() argument
4295 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_read()
4299 compr_dbg(compr, "Requested read of %zu bytes\n", count); in wm_adsp_compr_read()
4301 if (dsp->fatal_error || !compr->buf || compr->buf->error) { in wm_adsp_compr_read()
4302 snd_compr_stop_error(compr->stream, SNDRV_PCM_STATE_XRUN); in wm_adsp_compr_read()
4309 nwords = wm_adsp_buffer_capture_block(compr, count); in wm_adsp_compr_read()
4311 compr_err(compr, "Failed to capture block: %d\n", in wm_adsp_compr_read()
4318 compr_dbg(compr, "Read %d bytes\n", nbytes); in wm_adsp_compr_read()
4320 if (copy_to_user(buf + ntotal, compr->raw_buf, nbytes)) { in wm_adsp_compr_read()
4321 compr_err(compr, "Failed to copy data to user: %d, %d\n", in wm_adsp_compr_read()
4330 compr->copied_total += ntotal; in wm_adsp_compr_read()
4339 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_copy() local
4340 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_copy()
4346 ret = wm_adsp_compr_read(compr, buf, count); in wm_adsp_compr_copy()
4358 struct wm_adsp_compr *compr; in wm_adsp_fatal_error() local
4362 list_for_each_entry(compr, &dsp->compr_list, list) { in wm_adsp_fatal_error()
4363 if (compr->stream) in wm_adsp_fatal_error()
4364 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_fatal_error()